diff --git a/.hgtags b/.hgtags index 36cbfa27702..fdaa267c3a3 100644 --- a/.hgtags +++ b/.hgtags @@ -261,3 +261,7 @@ efe7dbc6088691757404e0c8745f894e3ca9c022 jdk9-b09 4a09f5d30be844ac6f714bdb0f63d8c3c08b9a98 jdk9-b16 410bccbded9e9cce80f1e13ad221e37ae97a3986 jdk9-b17 c5495e25c7258ab5f96a1ae14610887d76d2be63 jdk9-b18 +2dcf544eb7ed5ac6a3f7813a32e33acea7442405 jdk9-b19 +89731ae72a761afdf4262e8b9513f302f6563f89 jdk9-b20 +28dd0c7beb3cad9cf95f17b4b5ad87eb447a4084 jdk9-b21 +9678e0db8ff6ed845d4c2ee4a3baf7f386a777e5 jdk9-b22 diff --git a/.hgtags-top-repo b/.hgtags-top-repo index 931d3b8d4c6..f99201f034e 100644 --- a/.hgtags-top-repo +++ b/.hgtags-top-repo @@ -261,3 +261,7 @@ b114474fb25af4e73cb7219f7c04bd8994da03a5 jdk9-b15 cf22a728521f91a4692b433d39d730a0a1b23155 jdk9-b16 24152ee0ee1abef54a8bab04c099261dba7bcca5 jdk9-b17 65abab59f783fcf02ff8e133431c252f9e5f07d5 jdk9-b18 +75a08df650eb3126bab0c4d15241f5886162393c jdk9-b19 +ee4fd72b2ec3d92497f37163352f294aa695c6fb jdk9-b20 +9052803f4d01feda28b3d65f2b64dd457d21c7b6 jdk9-b21 +8e4bdab4c362aadde2d321f968cd503a2f779e2f jdk9-b22 diff --git a/common/autoconf/basics.m4 b/common/autoconf/basics.m4 index 649f8ddfc29..00ee498ed82 100644 --- a/common/autoconf/basics.m4 +++ b/common/autoconf/basics.m4 @@ -512,7 +512,7 @@ AC_DEFUN_ONCE([BASIC_SETUP_DEVKIT], ) AC_ARG_WITH(sysroot, [AS_HELP_STRING([--with-sysroot], - [use this directory as sysroot)])], + [use this directory as sysroot])], [SYSROOT=$with_sysroot] ) @@ -531,6 +531,75 @@ AC_DEFUN_ONCE([BASIC_SETUP_DEVKIT], [BASIC_PREPEND_TO_PATH([EXTRA_PATH],$with_extra_path)] ) + if test "x$OPENJDK_BUILD_OS" = "xmacosx"; then + # detect if Xcode is installed by running xcodebuild -version + # if no Xcode installed, xcodebuild exits with 1 + # if Xcode is installed, even if xcode-select is misconfigured, then it exits with 0 + if /usr/bin/xcodebuild -version >/dev/null 2>&1; then + # We need to use xcodebuild in the toolchain dir provided by the user, this will + # fall back on the stub binary in /usr/bin/xcodebuild + AC_PATH_PROG([XCODEBUILD], [xcodebuild], [/usr/bin/xcodebuild], [$TOOLCHAIN_PATH]) + else + # this should result in SYSROOT being empty, unless --with-sysroot is provided + # when only the command line tools are installed there are no SDKs, so headers + # are copied into the system frameworks + XCODEBUILD= + AC_SUBST(XCODEBUILD) + fi + + AC_MSG_CHECKING([for sdk name]) + AC_ARG_WITH([sdk-name], [AS_HELP_STRING([--with-sdk-name], + [use the platform SDK of the given name. @<:@macosx@:>@])], + [SDKNAME=$with_sdk_name] + ) + AC_MSG_RESULT([$SDKNAME]) + + # if toolchain path is specified then don't rely on system headers, they may not compile + HAVE_SYSTEM_FRAMEWORK_HEADERS=0 + test -z "$TOOLCHAIN_PATH" && \ + HAVE_SYSTEM_FRAMEWORK_HEADERS=`test ! -f /System/Library/Frameworks/Foundation.framework/Headers/Foundation.h; echo $?` + + if test -z "$SYSROOT"; then + if test -n "$XCODEBUILD"; then + # if we don't have system headers, use default SDK name (last resort) + if test -z "$SDKNAME" -a $HAVE_SYSTEM_FRAMEWORK_HEADERS -eq 0; then + SDKNAME=${SDKNAME:-macosx} + fi + + if test -n "$SDKNAME"; then + # Call xcodebuild to determine SYSROOT + SYSROOT=`"$XCODEBUILD" -sdk $SDKNAME -version | grep '^Path: ' | sed 's/Path: //'` + fi + else + if test $HAVE_SYSTEM_FRAMEWORK_HEADERS -eq 0; then + AC_MSG_ERROR([No xcodebuild tool and no system framework headers found, use --with-sysroot or --with-sdk-name to provide a path to a valid SDK]) + fi + fi + else + # warn user if --with-sdk-name was also set + if test -n "$with_sdk_name"; then + AC_MSG_WARN([Both SYSROOT and --with-sdk-name are set, only SYSROOT will be used]) + fi + fi + + if test $HAVE_SYSTEM_FRAMEWORK_HEADERS -eq 0 -a -z "$SYSROOT"; then + # If no system framework headers, then SYSROOT must be set, or we won't build + AC_MSG_ERROR([Unable to determine SYSROOT and no headers found in /System/Library/Frameworks. Check Xcode configuration, --with-sysroot or --with-sdk-name arguments.]) + fi + + # Perform a basic sanity test + if test ! -f "$SYSROOT/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h"; then + if test -z "$SYSROOT"; then + AC_MSG_ERROR([Unable to find required framework headers, provide a path to an SDK via --with-sysroot or --with-sdk-name and be sure Xcode is installed properly]) + else + AC_MSG_ERROR([Invalid SDK or SYSROOT path, dependent framework headers not found]) + fi + fi + + # set SDKROOT too, Xcode tools will pick it up + AC_SUBST(SDKROOT,$SYSROOT) + fi + # Prepend the extra path to the global path BASIC_PREPEND_TO_PATH([PATH],$EXTRA_PATH) diff --git a/common/autoconf/flags.m4 b/common/autoconf/flags.m4 index fc13f71b8aa..40f60a9c85d 100644 --- a/common/autoconf/flags.m4 +++ b/common/autoconf/flags.m4 @@ -116,21 +116,25 @@ AC_DEFUN_ONCE([FLAGS_SETUP_INIT_FLAGS], AC_SUBST(RC_FLAGS) if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then - # FIXME: likely bug, should be CCXXFLAGS_JDK? or one for C or CXX. - CCXXFLAGS="$CCXXFLAGS -nologo" + # silence copyright notice and other headers. + COMMON_CCXXFLAGS="$COMMON_CCXXFLAGS -nologo" fi if test "x$SYSROOT" != "x"; then if test "x$TOOLCHAIN_TYPE" = xsolstudio; then if test "x$OPENJDK_TARGET_OS" = xsolaris; then # Solaris Studio does not have a concept of sysroot. Instead we must - # make sure the default include and lib dirs are appended to each + # make sure the default include and lib dirs are appended to each # compile and link command line. SYSROOT_CFLAGS="-I$SYSROOT/usr/include" SYSROOT_LDFLAGS="-L$SYSROOT/usr/lib$OPENJDK_TARGET_CPU_ISADIR \ -L$SYSROOT/lib$OPENJDK_TARGET_CPU_ISADIR \ -L$SYSROOT/usr/ccs/lib$OPENJDK_TARGET_CPU_ISADIR" fi + elif test "x$OPENJDK_TARGET_OS" = xmacosx; then + # Apple only wants -isysroot , but we also need -iframework/System/Library/Frameworks + SYSROOT_CFLAGS="-isysroot \"$SYSROOT\" -iframework\"$SYSROOT/System/Library/Frameworks\"" + SYSROOT_LDFLAGS=$SYSROOT_CFLAGS elif test "x$TOOLCHAIN_TYPE" = xgcc; then SYSROOT_CFLAGS="--sysroot=\"$SYSROOT\"" SYSROOT_LDFLAGS="--sysroot=\"$SYSROOT\"" @@ -143,6 +147,14 @@ AC_DEFUN_ONCE([FLAGS_SETUP_INIT_FLAGS], LEGACY_EXTRA_CXXFLAGS="$LEGACY_EXTRA_CXXFLAGS $SYSROOT_CFLAGS" LEGACY_EXTRA_LDFLAGS="$LEGACY_EXTRA_LDFLAGS $SYSROOT_LDFLAGS" fi + + # These always need to be set, or we can't find the frameworks embedded in JavaVM.framework + # set this here so it doesn't have to be peppered throughout the forest + if test "x$OPENJDK_TARGET_OS" = xmacosx; then + SYSROOT_CFLAGS="$SYSROOT_CFLAGS -F\"$SYSROOT/System/Library/Frameworks/JavaVM.framework/Frameworks\"" + SYSROOT_LDFLAGS="$SYSROOT_LDFLAGS -F\"$SYSROOT/System/Library/Frameworks/JavaVM.framework/Frameworks\"" + fi + AC_SUBST(SYSROOT_CFLAGS) AC_SUBST(SYSROOT_LDFLAGS) ]) @@ -302,6 +314,7 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_OPTIMIZATION], # Debug symbols if test "x$TOOLCHAIN_TYPE" = xgcc; then if test "x$OPENJDK_TARGET_CPU_BITS" = "x64" && test "x$DEBUG_LEVEL" = "xfastdebug"; then + # reduce from default "-g2" option to save space CFLAGS_DEBUG_SYMBOLS="-g1" CXXFLAGS_DEBUG_SYMBOLS="-g1" else @@ -313,6 +326,7 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_OPTIMIZATION], CXXFLAGS_DEBUG_SYMBOLS="-g" elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then CFLAGS_DEBUG_SYMBOLS="-g -xs" + # FIXME: likely a bug, this disables debug symbols rather than enables them CXXFLAGS_DEBUG_SYMBOLS="-g0 -xs" elif test "x$TOOLCHAIN_TYPE" = xxlc; then CFLAGS_DEBUG_SYMBOLS="-g" @@ -321,6 +335,31 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_OPTIMIZATION], AC_SUBST(CFLAGS_DEBUG_SYMBOLS) AC_SUBST(CXXFLAGS_DEBUG_SYMBOLS) + # bounds, memory and behavior checking options + if test "x$TOOLCHAIN_TYPE" = xgcc; then + case $DEBUG_LEVEL in + release ) + # 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" + ;; + 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" + 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" + fi + ;; + esac + fi + AC_SUBST(CFLAGS_DEBUG_OPTIONS) + AC_SUBST(CXXFLAGS_DEBUG_OPTIONS) + # Optimization levels if test "x$TOOLCHAIN_TYPE" = xsolstudio; then CC_HIGHEST="$CC_HIGHEST -fns -fsimple -fsingle -xbuiltin=%all -xdepend -xrestrict -xlibmil" @@ -330,10 +369,12 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_OPTIMIZATION], C_O_FLAG_HIGHEST="-xO4 -Wu,-O4~yz $CC_HIGHEST -xalias_level=basic -xregs=no%frameptr" C_O_FLAG_HI="-xO4 -Wu,-O4~yz -xregs=no%frameptr" C_O_FLAG_NORM="-xO2 -Wu,-O2~yz -xregs=no%frameptr" + C_O_FLAG_DEBUG="-xregs=no%frameptr" C_O_FLAG_NONE="-xregs=no%frameptr" CXX_O_FLAG_HIGHEST="-xO4 -Qoption ube -O4~yz $CC_HIGHEST -xregs=no%frameptr" CXX_O_FLAG_HI="-xO4 -Qoption ube -O4~yz -xregs=no%frameptr" CXX_O_FLAG_NORM="-xO2 -Qoption ube -O2~yz -xregs=no%frameptr" + CXX_O_FLAG_DEBUG="-xregs=no%frameptr" CXX_O_FLAG_NONE="-xregs=no%frameptr" if test "x$OPENJDK_TARGET_CPU_BITS" = "x32"; then C_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST -xchip=pentium" @@ -343,10 +384,12 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_OPTIMIZATION], C_O_FLAG_HIGHEST="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0 $CC_HIGHEST -xalias_level=basic -xprefetch=auto,explicit -xchip=ultra" C_O_FLAG_HI="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0" C_O_FLAG_NORM="-xO2 -Wc,-Qrm-s -Wc,-Qiselect-T0" + C_O_FLAG_DEBUG="" C_O_FLAG_NONE="" CXX_O_FLAG_HIGHEST="-xO4 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0 $CC_HIGHEST -xprefetch=auto,explicit -xchip=ultra" CXX_O_FLAG_HI="-xO4 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0" CXX_O_FLAG_NORM="-xO2 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0" + C_O_FLAG_DEBUG="" CXX_O_FLAG_NONE="" fi else @@ -359,13 +402,17 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_OPTIMIZATION], C_O_FLAG_HIGHEST="-Os" C_O_FLAG_HI="-Os" C_O_FLAG_NORM="-Os" - C_O_FLAG_NONE="" else C_O_FLAG_HIGHEST="-O3" C_O_FLAG_HI="-O3" C_O_FLAG_NORM="-O2" - C_O_FLAG_NONE="-O0" fi + if test "x$HAS_CFLAG_OPTIMIZE_DEBUG" = "xtrue"; then + C_O_FLAG_DEBUG="$CFLAG_OPTIMIZE_DEBUG_FLAG" + else + C_O_FLAG_DEBUG="-O0" + fi + C_O_FLAG_NONE="-O0" elif test "x$TOOLCHAIN_TYPE" = xclang; then if test "x$OPENJDK_TARGET_OS" = xmacosx; then # On MacOSX we optimize for size, something @@ -373,37 +420,63 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_OPTIMIZATION], C_O_FLAG_HIGHEST="-Os" C_O_FLAG_HI="-Os" C_O_FLAG_NORM="-Os" - C_O_FLAG_NONE="" else C_O_FLAG_HIGHEST="-O3" C_O_FLAG_HI="-O3" C_O_FLAG_NORM="-O2" - C_O_FLAG_NONE="-O0" fi + C_O_FLAG_DEBUG="-O0" + C_O_FLAG_NONE="-O0" elif test "x$TOOLCHAIN_TYPE" = xxlc; then C_O_FLAG_HIGHEST="-O3" C_O_FLAG_HI="-O3 -qstrict" C_O_FLAG_NORM="-O2" - C_O_FLAG_NONE="" + C_O_FLAG_DEBUG="-qnoopt" + C_O_FLAG_NONE="-qnoop" elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then C_O_FLAG_HIGHEST="-O2" C_O_FLAG_HI="-O1" C_O_FLAG_NORM="-O1" + C_O_FLAG_DEBUG="-Od" C_O_FLAG_NONE="-Od" fi CXX_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST" CXX_O_FLAG_HI="$C_O_FLAG_HI" CXX_O_FLAG_NORM="$C_O_FLAG_NORM" + CXX_O_FLAG_DEBUG="$C_O_FLAG_DEBUG" CXX_O_FLAG_NONE="$C_O_FLAG_NONE" fi + # Adjust optimization flags according to debug level. + case $DEBUG_LEVEL in + release ) + # no adjustment + ;; + fastdebug ) + # Not quite so much optimization + C_O_FLAG_HI="$C_O_FLAG_NORM" + CXX_O_FLAG_HI="$CXX_O_FLAG_NORM" + ;; + slowdebug ) + # Disable optimization + C_O_FLAG_HIGHEST="$C_O_FLAG_DEBUG" + C_O_FLAG_HI="$C_O_FLAG_DEBUG" + C_O_FLAG_NORM="$C_O_FLAG_DEBUG" + CXX_O_FLAG_HIGHEST="$CXX_O_FLAG_DEBUG" + CXX_O_FLAG_HI="$CXX_O_FLAG_DEBUG" + CXX_O_FLAG_NORM="$CXX_O_FLAG_DEBUG" + ;; + esac + AC_SUBST(C_O_FLAG_HIGHEST) AC_SUBST(C_O_FLAG_HI) AC_SUBST(C_O_FLAG_NORM) + AC_SUBST(C_O_FLAG_DEBUG) AC_SUBST(C_O_FLAG_NONE) AC_SUBST(CXX_O_FLAG_HIGHEST) AC_SUBST(CXX_O_FLAG_HI) AC_SUBST(CXX_O_FLAG_NORM) + AC_SUBST(CXX_O_FLAG_DEBUG) AC_SUBST(CXX_O_FLAG_NONE) ]) @@ -461,11 +534,12 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK], # Later we will also have CFLAGS and LDFLAGS for the hotspot subrepo build. # - # Setup compiler/platform specific flags to CFLAGS_JDK, - # CXXFLAGS_JDK and CCXXFLAGS_JDK (common to C and CXX?) + # Setup compiler/platform specific flags into + # CFLAGS_JDK - C Compiler flags + # CXXFLAGS_JDK - C++ Compiler flags + # COMMON_CCXXFLAGS_JDK - common to C and C++ if test "x$TOOLCHAIN_TYPE" = xgcc; then - # these options are used for both C and C++ compiles - CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -Wall -Wno-parentheses -Wextra -Wno-unused -Wno-unused-parameter -Wformat=2 \ + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_CCXXFLAGS_JDK -Wall -Wno-parentheses -Wextra -Wno-unused -Wno-unused-parameter -Wformat=2 \ -pipe -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE" case $OPENJDK_TARGET_CPU_ARCH in arm ) @@ -477,31 +551,31 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK], CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing" ;; * ) - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -fno-omit-frame-pointer" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -fno-omit-frame-pointer" CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing" ;; esac elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then - CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_CCXXFLAGS_JDK -DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS" if test "x$OPENJDK_TARGET_CPU_ARCH" = xx86; then - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DcpuIntel -Di586 -D$OPENJDK_TARGET_CPU_LEGACY_LIB" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DcpuIntel -Di586 -D$OPENJDK_TARGET_CPU_LEGACY_LIB" CFLAGS_JDK="$CFLAGS_JDK -erroff=E_BAD_PRAGMA_PACK_VALUE" fi - + CFLAGS_JDK="$CFLAGS_JDK -xc99=%none -xCC -errshort=tags -Xa -v -mt -W0,-noglobal" CXXFLAGS_JDK="$CXXFLAGS_JDK -errtags=yes +w -mt -features=no%except -DCC_NOEX -norunpath -xnolib" elif test "x$TOOLCHAIN_TYPE" = xxlc; then CFLAGS_JDK="$CFLAGS_JDK -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC" CXXFLAGS_JDK="$CXXFLAGS_JDK -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC" elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then - CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -Zi -MD -Zc:wchar_t- -W3 -wd4800 \ + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_CCXXFLAGS_JDK -Zi -MD -Zc:wchar_t- -W3 -wd4800 \ -D_STATIC_CPPLIB -D_DISABLE_DEPRECATE_STATIC_CPPLIB -DWIN32_LEAN_AND_MEAN \ -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE \ -DWIN32 -DIAL" if test "x$OPENJDK_TARGET_CPU" = xx86_64; then - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_AMD64_ -Damd64" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_AMD64_ -Damd64" else - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_X86_ -Dx86" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_X86_ -Dx86" fi fi @@ -509,28 +583,20 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK], # Adjust flags according to debug level. case $DEBUG_LEVEL in - fastdebug ) - CFLAGS_JDK="$CFLAGS_JDK $CFLAGS_DEBUG_SYMBOLS" - CXXFLAGS_JDK="$CXXFLAGS_JDK $CXXFLAGS_DEBUG_SYMBOLS" - C_O_FLAG_HI="$C_O_FLAG_NORM" - C_O_FLAG_NORM="$C_O_FLAG_NORM" - CXX_O_FLAG_HI="$CXX_O_FLAG_NORM" - CXX_O_FLAG_NORM="$CXX_O_FLAG_NORM" + fastdebug | slowdebug ) + CFLAGS_JDK="$CFLAGS_JDK $CFLAGS_DEBUG_SYMBOLS $CFLAGS_DEBUG_OPTIONS" + CXXFLAGS_JDK="$CXXFLAGS_JDK $CXXFLAGS_DEBUG_SYMBOLS $CXXFLAGS_DEBUG_OPTIONS" JAVAC_FLAGS="$JAVAC_FLAGS -g" ;; - slowdebug ) - CFLAGS_JDK="$CFLAGS_JDK $CFLAGS_DEBUG_SYMBOLS" - CXXFLAGS_JDK="$CXXFLAGS_JDK $CXXFLAGS_DEBUG_SYMBOLS" - C_O_FLAG_HI="$C_O_FLAG_NONE" - C_O_FLAG_NORM="$C_O_FLAG_NONE" - CXX_O_FLAG_HI="$CXX_O_FLAG_NONE" - CXX_O_FLAG_NORM="$CXX_O_FLAG_NONE" - JAVAC_FLAGS="$JAVAC_FLAGS -g" + release ) + ;; + * ) + AC_MSG_ERROR([Unrecognized \$DEBUG_LEVEL: $DEBUG_LEVEL]) ;; esac # Setup LP64 - CCXXFLAGS_JDK="$CCXXFLAGS_JDK $ADD_LP64" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK $ADD_LP64" # Set some common defines. These works for all compilers, but assume # -D is universally accepted. @@ -543,74 +609,69 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK], # Note: -Dmacro is the same as #define macro 1 # -Dmacro= is the same as #define macro if test "x$OPENJDK_TARGET_OS" = xsolaris; then - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_LITTLE_ENDIAN=" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_LITTLE_ENDIAN=" else - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_LITTLE_ENDIAN" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_LITTLE_ENDIAN" fi else # Same goes for _BIG_ENDIAN. Do we really need to set *ENDIAN on Solaris if they # are defined in the system? if test "x$OPENJDK_TARGET_OS" = xsolaris; then - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_BIG_ENDIAN=" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_BIG_ENDIAN=" else - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_BIG_ENDIAN" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_BIG_ENDIAN" fi fi - + # Setup target OS define. Use OS target name but in upper case. OPENJDK_TARGET_OS_UPPERCASE=`$ECHO $OPENJDK_TARGET_OS | $TR 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D$OPENJDK_TARGET_OS_UPPERCASE" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D$OPENJDK_TARGET_OS_UPPERCASE" # Setup target CPU - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DARCH='\"$OPENJDK_TARGET_CPU_LEGACY\"' -D$OPENJDK_TARGET_CPU_LEGACY" - + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DARCH='\"$OPENJDK_TARGET_CPU_LEGACY\"' -D$OPENJDK_TARGET_CPU_LEGACY" + # Setup debug/release defines if test "x$DEBUG_LEVEL" = xrelease; then - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DNDEBUG" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DNDEBUG" if test "x$OPENJDK_TARGET_OS" = xsolaris; then - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DTRIMMED" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DTRIMMED" fi else - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DDEBUG" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DDEBUG" fi # Setup release name - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DRELEASE='\"\$(RELEASE)\"'" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DRELEASE='\"\$(RELEASE)\"'" # Set some additional per-OS defines. if test "x$OPENJDK_TARGET_OS" = xmacosx; then - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_ALLBSD_SOURCE -D_DARWIN_UNLIMITED_SELECT" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_ALLBSD_SOURCE -D_DARWIN_UNLIMITED_SELECT" elif test "x$OPENJDK_TARGET_OS" = xaix; then # FIXME: PPC64 should not be here. - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DPPC64" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DPPC64" elif test "x$OPENJDK_TARGET_OS" = xbsd; then - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_ALLBSD_SOURCE" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_ALLBSD_SOURCE" fi # Additional macosx handling if test "x$OPENJDK_TARGET_OS" = xmacosx; then - if test "x$TOOLCHAIN_TYPE" = xgcc; then - # FIXME: This needs to be exported in spec.gmk due to closed legacy code. - # FIXME: clean this up, and/or move it elsewhere. + # Setting these parameters makes it an error to link to macosx APIs that are + # newer than the given OS version and makes the linked binaries compatible + # even if built on a newer version of the OS. + # The expected format is X.Y.Z + MACOSX_VERSION_MIN=10.7.0 + AC_SUBST(MACOSX_VERSION_MIN) - # Setting these parameters makes it an error to link to macosx APIs that are - # newer than the given OS version and makes the linked binaries compatible - # even if built on a newer version of the OS. - # The expected format is X.Y.Z - MACOSX_VERSION_MIN=10.7.0 - AC_SUBST(MACOSX_VERSION_MIN) - - # The macro takes the version with no dots, ex: 1070 - # Let the flags variables get resolved in make for easier override on make - # command line. - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DMAC_OS_X_VERSION_MAX_ALLOWED=\$(subst .,,\$(MACOSX_VERSION_MIN)) -mmacosx-version-min=\$(MACOSX_VERSION_MIN)" - LDFLAGS_JDK="$LDFLAGS_JDK -mmacosx-version-min=\$(MACOSX_VERSION_MIN)" - fi + # The macro takes the version with no dots, ex: 1070 + # Let the flags variables get resolved in make for easier override on make + # command line. + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DMAC_OS_X_VERSION_MAX_ALLOWED=\$(subst .,,\$(MACOSX_VERSION_MIN)) -mmacosx-version-min=\$(MACOSX_VERSION_MIN)" + LDFLAGS_JDK="$LDFLAGS_JDK -mmacosx-version-min=\$(MACOSX_VERSION_MIN)" fi # Setup some hard coded includes - CCXXFLAGS_JDK="$CCXXFLAGS_JDK \ + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK \ -I${JDK_OUTPUTDIR}/include \ -I${JDK_OUTPUTDIR}/include/$OPENJDK_TARGET_OS \ -I${JDK_TOPDIR}/src/share/javavm/export \ @@ -619,12 +680,12 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK], -I${JDK_TOPDIR}/src/$OPENJDK_TARGET_OS_API_DIR/native/common" # The shared libraries are compiled using the picflag. - CFLAGS_JDKLIB="$CCXXFLAGS_JDK $CFLAGS_JDK $PICFLAG $CFLAGS_JDKLIB_EXTRA" - CXXFLAGS_JDKLIB="$CCXXFLAGS_JDK $CXXFLAGS_JDK $PICFLAG $CXXFLAGS_JDKLIB_EXTRA " + CFLAGS_JDKLIB="$COMMON_CCXXFLAGS_JDK $CFLAGS_JDK $PICFLAG $CFLAGS_JDKLIB_EXTRA" + CXXFLAGS_JDKLIB="$COMMON_CCXXFLAGS_JDK $CXXFLAGS_JDK $PICFLAG $CXXFLAGS_JDKLIB_EXTRA " # Executable flags - CFLAGS_JDKEXE="$CCXXFLAGS_JDK $CFLAGS_JDK" - CXXFLAGS_JDKEXE="$CCXXFLAGS_JDK $CXXFLAGS_JDK" + CFLAGS_JDKEXE="$COMMON_CCXXFLAGS_JDK $CFLAGS_JDK" + CXXFLAGS_JDKEXE="$COMMON_CCXXFLAGS_JDK $CXXFLAGS_JDK" AC_SUBST(CFLAGS_JDKLIB) AC_SUBST(CFLAGS_JDKEXE) @@ -633,6 +694,7 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK], # Setup LDFLAGS et al. # + # Now this is odd. The JDK native libraries have to link against libjvm.so # On 32-bit machines there is normally two distinct libjvm.so:s, client and server. # Which should we link to? Are we lucky enough that the binary api to the libjvm.so library @@ -648,39 +710,93 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK], fi # TODO: make -debug optional "--disable-full-debug-symbols" LDFLAGS_JDK="$LDFLAGS_JDK -debug" - LDFLAGS_JDKLIB="${LDFLAGS_JDK} -dll -libpath:${JDK_OUTPUTDIR}/lib" - LDFLAGS_JDKLIB_SUFFIX="" + elif test "x$TOOLCHAIN_TYPE" = xgcc; then + # If this is a --hash-style=gnu system, use --hash-style=both, why? + # We have previously set HAS_GNU_HASH if this is the case + if test -n "$HAS_GNU_HASH"; then + LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker --hash-style=both" + fi + if test "x$OPENJDK_TARGET_OS" = xlinux; then + # And since we now know that the linker is gnu, then add -z defs, to forbid + # undefined symbols in object files. + LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker -z -Xlinker defs" + case $DEBUG_LEVEL in + release ) + # tell linker to optimize libraries. + # Should this be supplied to the OSS linker as well? + LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker -O1" + ;; + slowdebug ) + if test "x$HAS_LINKER_NOW" = "xtrue"; then + # do relocations at load + LDFLAGS_JDK="$LDFLAGS_JDK $LINKER_NOW_FLAG" + LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK $LINKER_NOW_FLAG" + fi + if test "x$HAS_LINKER_RELRO" = "xtrue"; then + # mark relocations read only + LDFLAGS_JDK="$LDFLAGS_JDK $LINKER_RELRO_FLAG" + LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK $LINKER_RELRO_FLAG" + fi + ;; + fastdebug ) + if test "x$HAS_LINKER_RELRO" = "xtrue"; then + # mark relocations read only + LDFLAGS_JDK="$LDFLAGS_JDK $LINKER_RELRO_FLAG" + LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK $LINKER_RELRO_FLAG" + fi + ;; + * ) + AC_MSG_ERROR([Unrecognized \$DEBUG_LEVEL: $DEBUG_LEVEL]) + ;; + esac + fi + elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then + LDFLAGS_JDK="$LDFLAGS_JDK -z defs -xildoff -ztext" + LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK -norunpath -xnolib" + fi + + if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then + # If undefined behaviour detection is enabled then we need to tell linker. + case $DEBUG_LEVEL in + release | fastdebug ) + ;; + slowdebug ) + AC_MSG_WARN([$HAS_CFLAG_DETECT_UNDEFINED_BEHAVIOR]) + if test "x$HAS_CFLAG_DETECT_UNDEFINED_BEHAVIOR" = "xtrue"; then + # enable undefined behaviour checking + LDFLAGS_JDK="$LDFLAGS_JDK `$ECHO -n $CFLAG_DETECT_UNDEFINED_BEHAVIOR_FLAG | sed -e "s/[ ]*\([^ ]\+\)/ -Xlinker \1/g"`" + LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK `$ECHO -n $CFLAG_DETECT_UNDEFINED_BEHAVIOR_FLAG | sed -e "s/[ ]*\([^ ]\+\)/ -Xlinker \1/g"`" + fi + ;; + * ) + AC_MSG_ERROR([Unrecognized \$DEBUG_LEVEL: $DEBUG_LEVEL]) + ;; + esac + fi + + # Customize LDFLAGS for executables + + LDFLAGS_JDKEXE="${LDFLAGS_JDK}" + + if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then if test "x$OPENJDK_TARGET_CPU_BITS" = "x64"; then LDFLAGS_STACK_SIZE=1048576 else LDFLAGS_STACK_SIZE=327680 fi - LDFLAGS_JDKEXE="${LDFLAGS_JDK} /STACK:$LDFLAGS_STACK_SIZE" + LDFLAGS_JDKEXE="${LDFLAGS_JDKEXE} /STACK:$LDFLAGS_STACK_SIZE" + elif test "x$OPENJDK_TARGET_OS" = xlinux; then + LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE -Xlinker --allow-shlib-undefined" + fi + + # Customize LDFLAGS for libs + LDFLAGS_JDKLIB="${LDFLAGS_JDK}" + + if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then + LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -dll -libpath:${JDK_OUTPUTDIR}/lib" + LDFLAGS_JDKLIB_SUFFIX="" else - if test "x$TOOLCHAIN_TYPE" = xgcc; then - # If this is a --hash-style=gnu system, use --hash-style=both, why? - # We have previously set HAS_GNU_HASH if this is the case - if test -n "$HAS_GNU_HASH"; then - LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker --hash-style=both " - fi - if test "x$OPENJDK_TARGET_OS" = xlinux; then - # And since we now know that the linker is gnu, then add -z defs, to forbid - # undefined symbols in object files. - LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker -z -Xlinker defs" - if test "x$DEBUG_LEVEL" = "xrelease"; then - # When building release libraries, tell the linker optimize them. - # Should this be supplied to the OSS linker as well? - LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker -O1" - fi - fi - fi - - if test "x$TOOLCHAIN_TYPE" = xsolstudio; then - LDFLAGS_JDK="$LDFLAGS_JDK -z defs -xildoff -ztext" - LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK -norunpath -xnolib" - fi - - LDFLAGS_JDKLIB="${LDFLAGS_JDK} $SHARED_LIBRARY_FLAGS \ + LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} ${SHARED_LIBRARY_FLAGS} \ -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}" # On some platforms (mac) the linker warns about non existing -L dirs. @@ -701,12 +817,8 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK], if test "x$TOOLCHAIN_TYPE" = xsolstudio; then LDFLAGS_JDKLIB_SUFFIX="$LDFLAGS_JDKLIB_SUFFIX -lc" fi - - LDFLAGS_JDKEXE="${LDFLAGS_JDK}" - if test "x$OPENJDK_TARGET_OS" = xlinux; then - LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE -Xlinker --allow-shlib-undefined" - fi fi + AC_SUBST(LDFLAGS_JDKLIB) AC_SUBST(LDFLAGS_JDKEXE) AC_SUBST(LDFLAGS_JDKLIB_SUFFIX) @@ -714,7 +826,6 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK], AC_SUBST(LDFLAGS_CXX_JDK) ]) - # FLAGS_COMPILER_CHECK_ARGUMENTS([ARGUMENT], [RUN-IF-TRUE], # [RUN-IF-FALSE]) # ------------------------------------------------------------ @@ -727,7 +838,7 @@ AC_DEFUN([FLAGS_COMPILER_CHECK_ARGUMENTS], saved_cflags="$CFLAGS" CFLAGS="$CFLAGS $1" AC_LANG_PUSH([C]) - AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int i;]])], [], + AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int i;]])], [], [supports=no]) AC_LANG_POP([C]) CFLAGS="$saved_cflags" @@ -735,7 +846,7 @@ AC_DEFUN([FLAGS_COMPILER_CHECK_ARGUMENTS], saved_cxxflags="$CXXFLAGS" CXXFLAGS="$CXXFLAG $1" AC_LANG_PUSH([C++]) - AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int i;]])], [], + AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int i;]])], [], [supports=no]) AC_LANG_POP([C++]) CXXFLAGS="$saved_cxxflags" @@ -748,6 +859,31 @@ AC_DEFUN([FLAGS_COMPILER_CHECK_ARGUMENTS], fi ]) +# FLAGS_LINKER_CHECK_ARGUMENTS([ARGUMENT], [RUN-IF-TRUE], +# [RUN-IF-FALSE]) +# ------------------------------------------------------------ +# Check that the linker support an argument +AC_DEFUN([FLAGS_LINKER_CHECK_ARGUMENTS], +[ + AC_MSG_CHECKING([if linker supports "$1"]) + supports=yes + + saved_ldflags="$LDFLAGS" + LDFLAGS="$LDFLAGS $1" + AC_LANG_PUSH([C]) + AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])], + [], [supports=no]) + AC_LANG_POP([C]) + LDFLAGS="$saved_ldflags" + + AC_MSG_RESULT([$supports]) + if test "x$supports" = "xyes" ; then + m4_ifval([$2], [$2], [:]) + else + m4_ifval([$3], [$3], [:]) + fi +]) + AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_MISC], [ # Some Zero and Shark settings. diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index 86905690fb7..2ec5ac45fb8 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -692,13 +692,17 @@ LEGACY_EXTRA_LDFLAGS LEGACY_EXTRA_CXXFLAGS LEGACY_EXTRA_CFLAGS CXX_O_FLAG_NONE +CXX_O_FLAG_DEBUG CXX_O_FLAG_NORM CXX_O_FLAG_HI CXX_O_FLAG_HIGHEST C_O_FLAG_NONE +C_O_FLAG_DEBUG C_O_FLAG_NORM C_O_FLAG_HI C_O_FLAG_HIGHEST +CXXFLAGS_DEBUG_OPTIONS +CFLAGS_DEBUG_OPTIONS CXXFLAGS_DEBUG_SYMBOLS CFLAGS_DEBUG_SYMBOLS CXX_FLAG_DEPS @@ -870,6 +874,8 @@ PKGHANDLER OUTPUT_ROOT CONF_NAME SPEC +SDKROOT +XCODEBUILD BUILD_VARIANT_RELEASE DEBUG_CLASSFILES FASTDEBUG @@ -1036,6 +1042,7 @@ with_sysroot with_tools_dir with_toolchain_path with_extra_path +with_sdk_name with_conf_name with_builddeps_conf with_builddeps_server @@ -1070,7 +1077,6 @@ with_extra_cxxflags with_extra_ldflags enable_debug_symbols enable_zip_debug_info -enable_macosx_runtime_support with_x with_cups with_cups_include @@ -1081,6 +1087,7 @@ enable_freetype_bundling with_alsa with_alsa_include with_alsa_lib +with_libjpeg with_giflib with_lcms with_libpng @@ -1837,9 +1844,6 @@ Optional Features: --disable-debug-symbols disable generation of debug symbols [enabled] --disable-zip-debug-info disable zipping of debug-info files [enabled] - --enable-macosx-runtime-support - Deprecated. Option is kept for backwards - compatibility and is ignored --disable-freetype-bundling disable bundling of the freetype library with the build result [enabled on Windows or when using @@ -1868,12 +1872,13 @@ Optional Packages: optimized (HotSpot build only)) [release] --with-devkit use this devkit for compilers, tools and resources --with-sys-root alias for --with-sysroot for backwards compatability - --with-sysroot use this directory as sysroot) + --with-sysroot use this directory as sysroot --with-tools-dir alias for --with-toolchain-path for backwards compatibility --with-toolchain-path prepend these directories when searching for toolchain binaries (compilers etc) --with-extra-path prepend these directories to the default path + --with-sdk-name use the platform SDK of the given name. [macosx] --with-conf-name use this as the name of the configuration [generated from important configuration options] --with-builddeps-conf use this configuration file for the builddeps @@ -1938,6 +1943,8 @@ Optional Packages: headers under PATH/include) --with-alsa-include specify directory for the alsa include files --with-alsa-lib specify directory for the alsa library + --with-libjpeg use libjpeg from build system or OpenJDK source + (system, bundled) [bundled] --with-giflib use giflib from build system or OpenJDK source (system, bundled) [bundled] --with-lcms use lcms2 from build system or OpenJDK source @@ -2346,6 +2353,52 @@ fi } # ac_fn_objc_try_compile +# ac_fn_c_try_link LINENO +# ----------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_link () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext conftest$ac_exeext + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + test -x conftest$ac_exeext + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information + # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would + # interfere with the next link command; also delete a directory that is + # left behind by Apple's compiler. We do this before executing the actions. + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_link + # ac_fn_cxx_check_header_mongrel LINENO HEADER VAR INCLUDES # --------------------------------------------------------- # Tests whether HEADER exists, giving a warning if it cannot be compiled using @@ -3761,13 +3814,18 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. - # FLAGS_COMPILER_CHECK_ARGUMENTS([ARGUMENT], [RUN-IF-TRUE], # [RUN-IF-FALSE]) # ------------------------------------------------------------ # Check that the c and c++ compilers support an argument +# FLAGS_LINKER_CHECK_ARGUMENTS([ARGUMENT], [RUN-IF-TRUE], +# [RUN-IF-FALSE]) +# ------------------------------------------------------------ +# Check that the linker support an argument + + # @@ -4253,7 +4311,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=1399969244 +DATE_WHEN_GENERATED=1403557683 ############################################################################### # @@ -13552,7 +13610,7 @@ test -n "$target_alias" && VAR_CPU_BITS=32 VAR_CPU_ENDIAN=big ;; - sparcv9) + sparcv9|sparc64) VAR_CPU=sparcv9 VAR_CPU_ARCH=sparc VAR_CPU_BITS=64 @@ -13683,7 +13741,7 @@ $as_echo "$OPENJDK_BUILD_OS-$OPENJDK_BUILD_CPU" >&6; } VAR_CPU_BITS=32 VAR_CPU_ENDIAN=big ;; - sparcv9) + sparcv9|sparc64) VAR_CPU=sparcv9 VAR_CPU_ARCH=sparc VAR_CPU_BITS=64 @@ -14913,6 +14971,122 @@ if test "${with_extra_path+set}" = set; then : fi + if test "x$OPENJDK_BUILD_OS" = "xmacosx"; then + # detect if Xcode is installed by running xcodebuild -version + # if no Xcode installed, xcodebuild exits with 1 + # if Xcode is installed, even if xcode-select is misconfigured, then it exits with 0 + if /usr/bin/xcodebuild -version >/dev/null 2>&1; then + # We need to use xcodebuild in the toolchain dir provided by the user, this will + # fall back on the stub binary in /usr/bin/xcodebuild + # Extract the first word of "xcodebuild", so it can be a program name with args. +set dummy xcodebuild; 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_XCODEBUILD+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $XCODEBUILD in + [\\/]* | ?:[\\/]*) + ac_cv_path_XCODEBUILD="$XCODEBUILD" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $TOOLCHAIN_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_XCODEBUILD="$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 + + test -z "$ac_cv_path_XCODEBUILD" && ac_cv_path_XCODEBUILD="/usr/bin/xcodebuild" + ;; +esac +fi +XCODEBUILD=$ac_cv_path_XCODEBUILD +if test -n "$XCODEBUILD"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $XCODEBUILD" >&5 +$as_echo "$XCODEBUILD" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + else + # this should result in SYSROOT being empty, unless --with-sysroot is provided + # when only the command line tools are installed there are no SDKs, so headers + # are copied into the system frameworks + XCODEBUILD= + + fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sdk name" >&5 +$as_echo_n "checking for sdk name... " >&6; } + +# Check whether --with-sdk-name was given. +if test "${with_sdk_name+set}" = set; then : + withval=$with_sdk_name; SDKNAME=$with_sdk_name + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SDKNAME" >&5 +$as_echo "$SDKNAME" >&6; } + + # if toolchain path is specified then don't rely on system headers, they may not compile + HAVE_SYSTEM_FRAMEWORK_HEADERS=0 + test -z "$TOOLCHAIN_PATH" && \ + HAVE_SYSTEM_FRAMEWORK_HEADERS=`test ! -f /System/Library/Frameworks/Foundation.framework/Headers/Foundation.h; echo $?` + + if test -z "$SYSROOT"; then + if test -n "$XCODEBUILD"; then + # if we don't have system headers, use default SDK name (last resort) + if test -z "$SDKNAME" -a $HAVE_SYSTEM_FRAMEWORK_HEADERS -eq 0; then + SDKNAME=${SDKNAME:-macosx} + fi + + if test -n "$SDKNAME"; then + # Call xcodebuild to determine SYSROOT + SYSROOT=`"$XCODEBUILD" -sdk $SDKNAME -version | grep '^Path: ' | sed 's/Path: //'` + fi + else + if test $HAVE_SYSTEM_FRAMEWORK_HEADERS -eq 0; then + as_fn_error $? "No xcodebuild tool and no system framework headers found, use --with-sysroot or --with-sdk-name to provide a path to a valid SDK" "$LINENO" 5 + fi + fi + else + # warn user if --with-sdk-name was also set + if test -n "$with_sdk_name"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Both SYSROOT and --with-sdk-name are set, only SYSROOT will be used" >&5 +$as_echo "$as_me: WARNING: Both SYSROOT and --with-sdk-name are set, only SYSROOT will be used" >&2;} + fi + fi + + if test $HAVE_SYSTEM_FRAMEWORK_HEADERS -eq 0 -a -z "$SYSROOT"; then + # If no system framework headers, then SYSROOT must be set, or we won't build + as_fn_error $? "Unable to determine SYSROOT and no headers found in /System/Library/Frameworks. Check Xcode configuration, --with-sysroot or --with-sdk-name arguments." "$LINENO" 5 + fi + + # Perform a basic sanity test + if test ! -f "$SYSROOT/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h"; then + if test -z "$SYSROOT"; then + as_fn_error $? "Unable to find required framework headers, provide a path to an SDK via --with-sysroot or --with-sdk-name and be sure Xcode is installed properly" "$LINENO" 5 + else + as_fn_error $? "Invalid SDK or SYSROOT path, dependent framework headers not found" "$LINENO" 5 + fi + fi + + # set SDKROOT too, Xcode tools will pick it up + SDKROOT=$SYSROOT + + fi + # Prepend the extra path to the global path if test "x$EXTRA_PATH" != x; then @@ -26541,21 +26715,28 @@ fi VALID_TOOLCHAINS=${!toolchain_var_name} if test "x$OPENJDK_TARGET_OS" = xmacosx; then - # On Mac OS X, default toolchain to clang after Xcode 5 - XCODE_VERSION_OUTPUT=`xcodebuild -version 2>&1 | $HEAD -n 1` - $ECHO "$XCODE_VERSION_OUTPUT" | $GREP "Xcode " > /dev/null - if test $? -ne 0; then - as_fn_error $? "Failed to determine Xcode version." "$LINENO" 5 - fi - XCODE_MAJOR_VERSION=`$ECHO $XCODE_VERSION_OUTPUT | \ - $SED -e 's/^Xcode \([1-9][0-9.]*\)/\1/' | \ - $CUT -f 1 -d .` - { $as_echo "$as_me:${as_lineno-$LINENO}: Xcode major version: $XCODE_MAJOR_VERSION" >&5 + if test -n "$XCODEBUILD"; then + # On Mac OS X, default toolchain to clang after Xcode 5 + XCODE_VERSION_OUTPUT=`"$XCODEBUILD" -version 2>&1 | $HEAD -n 1` + $ECHO "$XCODE_VERSION_OUTPUT" | $GREP "Xcode " > /dev/null + if test $? -ne 0; then + as_fn_error $? "Failed to determine Xcode version." "$LINENO" 5 + fi + XCODE_MAJOR_VERSION=`$ECHO $XCODE_VERSION_OUTPUT | \ + $SED -e 's/^Xcode \([1-9][0-9.]*\)/\1/' | \ + $CUT -f 1 -d .` + { $as_echo "$as_me:${as_lineno-$LINENO}: Xcode major version: $XCODE_MAJOR_VERSION" >&5 $as_echo "$as_me: Xcode major version: $XCODE_MAJOR_VERSION" >&6;} - if test $XCODE_MAJOR_VERSION -ge 5; then - DEFAULT_TOOLCHAIN="clang" + if test $XCODE_MAJOR_VERSION -ge 5; then + DEFAULT_TOOLCHAIN="clang" + else + DEFAULT_TOOLCHAIN="gcc" + fi else - DEFAULT_TOOLCHAIN="gcc" + # If Xcode is not installed, but the command line tools are + # then we can't run xcodebuild. On these systems we should + # default to clang + DEFAULT_TOOLCHAIN="clang" fi else # First toolchain type in the list is the default @@ -40264,6 +40445,8 @@ $as_echo "$as_me: Rewriting BUILD_LD to \"$new_complete\"" >&6;} + + # The package path is used only on macosx? # FIXME: clean this up, and/or move it elsewhere. PACKAGE_PATH=/opt/local @@ -40289,6 +40472,242 @@ $as_echo "$as_me: Rewriting BUILD_LD to \"$new_complete\"" >&6;} # If this is a --hash-style=gnu system, use --hash-style=both, why? HAS_GNU_HASH=`$CC -dumpspecs 2>/dev/null | $GREP 'hash-style=gnu'` # This is later checked when setting flags. + + # "-Og" suppported for GCC 4.8 and later + CFLAG_OPTIMIZE_DEBUG_FLAG="-Og" + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler supports \"$CFLAG_OPTIMIZE_DEBUG_FLAG\"" >&5 +$as_echo_n "checking if compiler supports \"$CFLAG_OPTIMIZE_DEBUG_FLAG\"... " >&6; } + supports=yes + + saved_cflags="$CFLAGS" + CFLAGS="$CFLAGS $CFLAG_OPTIMIZE_DEBUG_FLAG" + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +int i; +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + supports=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + CFLAGS="$saved_cflags" + + saved_cxxflags="$CXXFLAGS" + CXXFLAGS="$CXXFLAG $CFLAG_OPTIMIZE_DEBUG_FLAG" + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +int i; +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + +else + supports=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + CXXFLAGS="$saved_cxxflags" + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $supports" >&5 +$as_echo "$supports" >&6; } + if test "x$supports" = "xyes" ; then + HAS_CFLAG_OPTIMIZE_DEBUG=true + else + HAS_CFLAG_OPTIMIZE_DEBUG=false + fi + + + # "-fsanitize=undefined" supported for GCC 4.9 and later + CFLAG_DETECT_UNDEFINED_BEHAVIOR_FLAG="-fsanitize=undefined -fsanitize-recover" + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler supports \"$CFLAG_DETECT_UNDEFINED_BEHAVIOR_FLAG\"" >&5 +$as_echo_n "checking if compiler supports \"$CFLAG_DETECT_UNDEFINED_BEHAVIOR_FLAG\"... " >&6; } + supports=yes + + saved_cflags="$CFLAGS" + CFLAGS="$CFLAGS $CFLAG_DETECT_UNDEFINED_BEHAVIOR_FLAG" + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +int i; +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + supports=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + CFLAGS="$saved_cflags" + + saved_cxxflags="$CXXFLAGS" + CXXFLAGS="$CXXFLAG $CFLAG_DETECT_UNDEFINED_BEHAVIOR_FLAG" + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +int i; +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + +else + supports=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + CXXFLAGS="$saved_cxxflags" + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $supports" >&5 +$as_echo "$supports" >&6; } + if test "x$supports" = "xyes" ; then + HAS_CFLAG_DETECT_UNDEFINED_BEHAVIOR=true + else + HAS_CFLAG_DETECT_UNDEFINED_BEHAVIOR=false + fi + + + # "-z relro" supported in GNU binutils 2.17 and later + LINKER_RELRO_FLAG="-Xlinker -z -Xlinker relro" + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if linker supports \"$LINKER_RELRO_FLAG\"" >&5 +$as_echo_n "checking if linker supports \"$LINKER_RELRO_FLAG\"... " >&6; } + supports=yes + + saved_ldflags="$LDFLAGS" + LDFLAGS="$LDFLAGS $LINKER_RELRO_FLAG" + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + +else + supports=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + LDFLAGS="$saved_ldflags" + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $supports" >&5 +$as_echo "$supports" >&6; } + if test "x$supports" = "xyes" ; then + HAS_LINKER_RELRO=true + else + HAS_LINKER_RELRO=false + fi + + + # "-z now" supported in GNU binutils 2.11 and later + LINKER_NOW_FLAG="-Xlinker -z -Xlinker now" + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if linker supports \"$LINKER_NOW_FLAG\"" >&5 +$as_echo_n "checking if linker supports \"$LINKER_NOW_FLAG\"... " >&6; } + supports=yes + + saved_ldflags="$LDFLAGS" + LDFLAGS="$LDFLAGS $LINKER_NOW_FLAG" + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + +else + supports=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + LDFLAGS="$saved_ldflags" + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $supports" >&5 +$as_echo "$supports" >&6; } + if test "x$supports" = "xyes" ; then + HAS_LINKER_NOW=true + else + HAS_LINKER_NOW=false + fi + fi # Check for broken SuSE 'ld' for which 'Only anonymous version tag is allowed @@ -40297,8 +40716,8 @@ $as_echo "$as_me: Rewriting BUILD_LD to \"$new_complete\"" >&6;} if test "x$OPENJDK_TARGET_OS" = xlinux && test "x$TOOLCHAIN_TYPE" = xgcc; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for broken SuSE 'ld' which only understands anonymous version tags in executables" >&5 $as_echo_n "checking for broken SuSE 'ld' which only understands anonymous version tags in executables... " >&6; } - echo "SUNWprivate_1.1 { local: *; };" > version-script.map - echo "int main() { }" > main.c + $ECHO "SUNWprivate_1.1 { local: *; };" > version-script.map + $ECHO "int main() { }" > main.c if $CXX -Xlinker -version-script=version-script.map main.c 2>&5 >&5; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } @@ -40768,8 +41187,8 @@ $as_echo "$tool_specified" >&6; } if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then - # FIXME: likely bug, should be CCXXFLAGS_JDK? or one for C or CXX. - CCXXFLAGS="$CCXXFLAGS -nologo" + # silence copyright notice and other headers. + COMMON_CCXXFLAGS="$COMMON_CCXXFLAGS -nologo" fi if test "x$SYSROOT" != "x"; then @@ -40783,6 +41202,10 @@ $as_echo "$tool_specified" >&6; } -L$SYSROOT/lib$OPENJDK_TARGET_CPU_ISADIR \ -L$SYSROOT/usr/ccs/lib$OPENJDK_TARGET_CPU_ISADIR" fi + elif test "x$OPENJDK_TARGET_OS" = xmacosx; then + # Apple only wants -isysroot , but we also need -iframework/System/Library/Frameworks + SYSROOT_CFLAGS="-isysroot \"$SYSROOT\" -iframework\"$SYSROOT/System/Library/Frameworks\"" + SYSROOT_LDFLAGS=$SYSROOT_CFLAGS elif test "x$TOOLCHAIN_TYPE" = xgcc; then SYSROOT_CFLAGS="--sysroot=\"$SYSROOT\"" SYSROOT_LDFLAGS="--sysroot=\"$SYSROOT\"" @@ -40796,6 +41219,14 @@ $as_echo "$tool_specified" >&6; } LEGACY_EXTRA_LDFLAGS="$LEGACY_EXTRA_LDFLAGS $SYSROOT_LDFLAGS" fi + # These always need to be set, or we can't find the frameworks embedded in JavaVM.framework + # set this here so it doesn't have to be peppered throughout the forest + if test "x$OPENJDK_TARGET_OS" = xmacosx; then + SYSROOT_CFLAGS="$SYSROOT_CFLAGS -F\"$SYSROOT/System/Library/Frameworks/JavaVM.framework/Frameworks\"" + SYSROOT_LDFLAGS="$SYSROOT_LDFLAGS -F\"$SYSROOT/System/Library/Frameworks/JavaVM.framework/Frameworks\"" + fi + + @@ -40803,7 +41234,6 @@ $as_echo "$tool_specified" >&6; } # Now we can test some aspects on the target using configure macros. - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if ${ac_cv_header_stdc+:} false; then : @@ -41488,6 +41918,7 @@ $as_echo "$ac_cv_c_bigendian" >&6; } # Debug symbols if test "x$TOOLCHAIN_TYPE" = xgcc; then if test "x$OPENJDK_TARGET_CPU_BITS" = "x64" && test "x$DEBUG_LEVEL" = "xfastdebug"; then + # reduce from default "-g2" option to save space CFLAGS_DEBUG_SYMBOLS="-g1" CXXFLAGS_DEBUG_SYMBOLS="-g1" else @@ -41499,6 +41930,7 @@ $as_echo "$ac_cv_c_bigendian" >&6; } CXXFLAGS_DEBUG_SYMBOLS="-g" elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then CFLAGS_DEBUG_SYMBOLS="-g -xs" + # FIXME: likely a bug, this disables debug symbols rather than enables them CXXFLAGS_DEBUG_SYMBOLS="-g0 -xs" elif test "x$TOOLCHAIN_TYPE" = xxlc; then CFLAGS_DEBUG_SYMBOLS="-g" @@ -41507,6 +41939,31 @@ $as_echo "$ac_cv_c_bigendian" >&6; } + # bounds, memory and behavior checking options + if test "x$TOOLCHAIN_TYPE" = xgcc; then + case $DEBUG_LEVEL in + release ) + # 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" + ;; + 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" + 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" + fi + ;; + esac + fi + + + # Optimization levels if test "x$TOOLCHAIN_TYPE" = xsolstudio; then CC_HIGHEST="$CC_HIGHEST -fns -fsimple -fsingle -xbuiltin=%all -xdepend -xrestrict -xlibmil" @@ -41516,10 +41973,12 @@ $as_echo "$ac_cv_c_bigendian" >&6; } C_O_FLAG_HIGHEST="-xO4 -Wu,-O4~yz $CC_HIGHEST -xalias_level=basic -xregs=no%frameptr" C_O_FLAG_HI="-xO4 -Wu,-O4~yz -xregs=no%frameptr" C_O_FLAG_NORM="-xO2 -Wu,-O2~yz -xregs=no%frameptr" + C_O_FLAG_DEBUG="-xregs=no%frameptr" C_O_FLAG_NONE="-xregs=no%frameptr" CXX_O_FLAG_HIGHEST="-xO4 -Qoption ube -O4~yz $CC_HIGHEST -xregs=no%frameptr" CXX_O_FLAG_HI="-xO4 -Qoption ube -O4~yz -xregs=no%frameptr" CXX_O_FLAG_NORM="-xO2 -Qoption ube -O2~yz -xregs=no%frameptr" + CXX_O_FLAG_DEBUG="-xregs=no%frameptr" CXX_O_FLAG_NONE="-xregs=no%frameptr" if test "x$OPENJDK_TARGET_CPU_BITS" = "x32"; then C_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST -xchip=pentium" @@ -41529,10 +41988,12 @@ $as_echo "$ac_cv_c_bigendian" >&6; } C_O_FLAG_HIGHEST="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0 $CC_HIGHEST -xalias_level=basic -xprefetch=auto,explicit -xchip=ultra" C_O_FLAG_HI="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0" C_O_FLAG_NORM="-xO2 -Wc,-Qrm-s -Wc,-Qiselect-T0" + C_O_FLAG_DEBUG="" C_O_FLAG_NONE="" CXX_O_FLAG_HIGHEST="-xO4 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0 $CC_HIGHEST -xprefetch=auto,explicit -xchip=ultra" CXX_O_FLAG_HI="-xO4 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0" CXX_O_FLAG_NORM="-xO2 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0" + C_O_FLAG_DEBUG="" CXX_O_FLAG_NONE="" fi else @@ -41545,13 +42006,17 @@ $as_echo "$ac_cv_c_bigendian" >&6; } C_O_FLAG_HIGHEST="-Os" C_O_FLAG_HI="-Os" C_O_FLAG_NORM="-Os" - C_O_FLAG_NONE="" else C_O_FLAG_HIGHEST="-O3" C_O_FLAG_HI="-O3" C_O_FLAG_NORM="-O2" - C_O_FLAG_NONE="-O0" fi + if test "x$HAS_CFLAG_OPTIMIZE_DEBUG" = "xtrue"; then + C_O_FLAG_DEBUG="$CFLAG_OPTIMIZE_DEBUG_FLAG" + else + C_O_FLAG_DEBUG="-O0" + fi + C_O_FLAG_NONE="-O0" elif test "x$TOOLCHAIN_TYPE" = xclang; then if test "x$OPENJDK_TARGET_OS" = xmacosx; then # On MacOSX we optimize for size, something @@ -41559,30 +42024,56 @@ $as_echo "$ac_cv_c_bigendian" >&6; } C_O_FLAG_HIGHEST="-Os" C_O_FLAG_HI="-Os" C_O_FLAG_NORM="-Os" - C_O_FLAG_NONE="" else C_O_FLAG_HIGHEST="-O3" C_O_FLAG_HI="-O3" C_O_FLAG_NORM="-O2" - C_O_FLAG_NONE="-O0" fi + C_O_FLAG_DEBUG="-O0" + C_O_FLAG_NONE="-O0" elif test "x$TOOLCHAIN_TYPE" = xxlc; then C_O_FLAG_HIGHEST="-O3" C_O_FLAG_HI="-O3 -qstrict" C_O_FLAG_NORM="-O2" - C_O_FLAG_NONE="" + C_O_FLAG_DEBUG="-qnoopt" + C_O_FLAG_NONE="-qnoop" elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then C_O_FLAG_HIGHEST="-O2" C_O_FLAG_HI="-O1" C_O_FLAG_NORM="-O1" + C_O_FLAG_DEBUG="-Od" C_O_FLAG_NONE="-Od" fi CXX_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST" CXX_O_FLAG_HI="$C_O_FLAG_HI" CXX_O_FLAG_NORM="$C_O_FLAG_NORM" + CXX_O_FLAG_DEBUG="$C_O_FLAG_DEBUG" CXX_O_FLAG_NONE="$C_O_FLAG_NONE" fi + # Adjust optimization flags according to debug level. + case $DEBUG_LEVEL in + release ) + # no adjustment + ;; + fastdebug ) + # Not quite so much optimization + C_O_FLAG_HI="$C_O_FLAG_NORM" + CXX_O_FLAG_HI="$CXX_O_FLAG_NORM" + ;; + slowdebug ) + # Disable optimization + C_O_FLAG_HIGHEST="$C_O_FLAG_DEBUG" + C_O_FLAG_HI="$C_O_FLAG_DEBUG" + C_O_FLAG_NORM="$C_O_FLAG_DEBUG" + CXX_O_FLAG_HIGHEST="$CXX_O_FLAG_DEBUG" + CXX_O_FLAG_HI="$CXX_O_FLAG_DEBUG" + CXX_O_FLAG_NORM="$CXX_O_FLAG_DEBUG" + ;; + esac + + + @@ -41660,11 +42151,12 @@ fi # Later we will also have CFLAGS and LDFLAGS for the hotspot subrepo build. # - # Setup compiler/platform specific flags to CFLAGS_JDK, - # CXXFLAGS_JDK and CCXXFLAGS_JDK (common to C and CXX?) + # Setup compiler/platform specific flags into + # CFLAGS_JDK - C Compiler flags + # CXXFLAGS_JDK - C++ Compiler flags + # COMMON_CCXXFLAGS_JDK - common to C and C++ if test "x$TOOLCHAIN_TYPE" = xgcc; then - # these options are used for both C and C++ compiles - CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -Wall -Wno-parentheses -Wextra -Wno-unused -Wno-unused-parameter -Wformat=2 \ + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_CCXXFLAGS_JDK -Wall -Wno-parentheses -Wextra -Wno-unused -Wno-unused-parameter -Wformat=2 \ -pipe -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE" case $OPENJDK_TARGET_CPU_ARCH in arm ) @@ -41676,14 +42168,14 @@ fi CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing" ;; * ) - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -fno-omit-frame-pointer" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -fno-omit-frame-pointer" CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing" ;; esac elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then - CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_CCXXFLAGS_JDK -DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS" if test "x$OPENJDK_TARGET_CPU_ARCH" = xx86; then - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DcpuIntel -Di586 -D$OPENJDK_TARGET_CPU_LEGACY_LIB" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DcpuIntel -Di586 -D$OPENJDK_TARGET_CPU_LEGACY_LIB" CFLAGS_JDK="$CFLAGS_JDK -erroff=E_BAD_PRAGMA_PACK_VALUE" fi @@ -41693,14 +42185,14 @@ fi CFLAGS_JDK="$CFLAGS_JDK -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC" CXXFLAGS_JDK="$CXXFLAGS_JDK -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC" elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then - CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -Zi -MD -Zc:wchar_t- -W3 -wd4800 \ + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_CCXXFLAGS_JDK -Zi -MD -Zc:wchar_t- -W3 -wd4800 \ -D_STATIC_CPPLIB -D_DISABLE_DEPRECATE_STATIC_CPPLIB -DWIN32_LEAN_AND_MEAN \ -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE \ -DWIN32 -DIAL" if test "x$OPENJDK_TARGET_CPU" = xx86_64; then - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_AMD64_ -Damd64" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_AMD64_ -Damd64" else - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_X86_ -Dx86" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_X86_ -Dx86" fi fi @@ -41708,28 +42200,20 @@ fi # Adjust flags according to debug level. case $DEBUG_LEVEL in - fastdebug ) - CFLAGS_JDK="$CFLAGS_JDK $CFLAGS_DEBUG_SYMBOLS" - CXXFLAGS_JDK="$CXXFLAGS_JDK $CXXFLAGS_DEBUG_SYMBOLS" - C_O_FLAG_HI="$C_O_FLAG_NORM" - C_O_FLAG_NORM="$C_O_FLAG_NORM" - CXX_O_FLAG_HI="$CXX_O_FLAG_NORM" - CXX_O_FLAG_NORM="$CXX_O_FLAG_NORM" + fastdebug | slowdebug ) + CFLAGS_JDK="$CFLAGS_JDK $CFLAGS_DEBUG_SYMBOLS $CFLAGS_DEBUG_OPTIONS" + CXXFLAGS_JDK="$CXXFLAGS_JDK $CXXFLAGS_DEBUG_SYMBOLS $CXXFLAGS_DEBUG_OPTIONS" JAVAC_FLAGS="$JAVAC_FLAGS -g" ;; - slowdebug ) - CFLAGS_JDK="$CFLAGS_JDK $CFLAGS_DEBUG_SYMBOLS" - CXXFLAGS_JDK="$CXXFLAGS_JDK $CXXFLAGS_DEBUG_SYMBOLS" - C_O_FLAG_HI="$C_O_FLAG_NONE" - C_O_FLAG_NORM="$C_O_FLAG_NONE" - CXX_O_FLAG_HI="$CXX_O_FLAG_NONE" - CXX_O_FLAG_NORM="$CXX_O_FLAG_NONE" - JAVAC_FLAGS="$JAVAC_FLAGS -g" + release ) + ;; + * ) + as_fn_error $? "Unrecognized \$DEBUG_LEVEL: $DEBUG_LEVEL" "$LINENO" 5 ;; esac # Setup LP64 - CCXXFLAGS_JDK="$CCXXFLAGS_JDK $ADD_LP64" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK $ADD_LP64" # Set some common defines. These works for all compilers, but assume # -D is universally accepted. @@ -41742,74 +42226,69 @@ fi # Note: -Dmacro is the same as #define macro 1 # -Dmacro= is the same as #define macro if test "x$OPENJDK_TARGET_OS" = xsolaris; then - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_LITTLE_ENDIAN=" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_LITTLE_ENDIAN=" else - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_LITTLE_ENDIAN" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_LITTLE_ENDIAN" fi else # Same goes for _BIG_ENDIAN. Do we really need to set *ENDIAN on Solaris if they # are defined in the system? if test "x$OPENJDK_TARGET_OS" = xsolaris; then - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_BIG_ENDIAN=" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_BIG_ENDIAN=" else - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_BIG_ENDIAN" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_BIG_ENDIAN" fi fi # Setup target OS define. Use OS target name but in upper case. OPENJDK_TARGET_OS_UPPERCASE=`$ECHO $OPENJDK_TARGET_OS | $TR 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D$OPENJDK_TARGET_OS_UPPERCASE" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D$OPENJDK_TARGET_OS_UPPERCASE" # Setup target CPU - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DARCH='\"$OPENJDK_TARGET_CPU_LEGACY\"' -D$OPENJDK_TARGET_CPU_LEGACY" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DARCH='\"$OPENJDK_TARGET_CPU_LEGACY\"' -D$OPENJDK_TARGET_CPU_LEGACY" # Setup debug/release defines if test "x$DEBUG_LEVEL" = xrelease; then - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DNDEBUG" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DNDEBUG" if test "x$OPENJDK_TARGET_OS" = xsolaris; then - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DTRIMMED" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DTRIMMED" fi else - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DDEBUG" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DDEBUG" fi # Setup release name - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DRELEASE='\"\$(RELEASE)\"'" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DRELEASE='\"\$(RELEASE)\"'" # Set some additional per-OS defines. if test "x$OPENJDK_TARGET_OS" = xmacosx; then - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_ALLBSD_SOURCE -D_DARWIN_UNLIMITED_SELECT" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_ALLBSD_SOURCE -D_DARWIN_UNLIMITED_SELECT" elif test "x$OPENJDK_TARGET_OS" = xaix; then # FIXME: PPC64 should not be here. - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DPPC64" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DPPC64" elif test "x$OPENJDK_TARGET_OS" = xbsd; then - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_ALLBSD_SOURCE" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_ALLBSD_SOURCE" fi # Additional macosx handling if test "x$OPENJDK_TARGET_OS" = xmacosx; then - if test "x$TOOLCHAIN_TYPE" = xgcc; then - # FIXME: This needs to be exported in spec.gmk due to closed legacy code. - # FIXME: clean this up, and/or move it elsewhere. - - # Setting these parameters makes it an error to link to macosx APIs that are - # newer than the given OS version and makes the linked binaries compatible - # even if built on a newer version of the OS. - # The expected format is X.Y.Z - MACOSX_VERSION_MIN=10.7.0 + # Setting these parameters makes it an error to link to macosx APIs that are + # newer than the given OS version and makes the linked binaries compatible + # even if built on a newer version of the OS. + # The expected format is X.Y.Z + MACOSX_VERSION_MIN=10.7.0 - # The macro takes the version with no dots, ex: 1070 - # Let the flags variables get resolved in make for easier override on make - # command line. - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DMAC_OS_X_VERSION_MAX_ALLOWED=\$(subst .,,\$(MACOSX_VERSION_MIN)) -mmacosx-version-min=\$(MACOSX_VERSION_MIN)" - LDFLAGS_JDK="$LDFLAGS_JDK -mmacosx-version-min=\$(MACOSX_VERSION_MIN)" - fi + # The macro takes the version with no dots, ex: 1070 + # Let the flags variables get resolved in make for easier override on make + # command line. + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DMAC_OS_X_VERSION_MAX_ALLOWED=\$(subst .,,\$(MACOSX_VERSION_MIN)) -mmacosx-version-min=\$(MACOSX_VERSION_MIN)" + LDFLAGS_JDK="$LDFLAGS_JDK -mmacosx-version-min=\$(MACOSX_VERSION_MIN)" fi # Setup some hard coded includes - CCXXFLAGS_JDK="$CCXXFLAGS_JDK \ + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK \ -I${JDK_OUTPUTDIR}/include \ -I${JDK_OUTPUTDIR}/include/$OPENJDK_TARGET_OS \ -I${JDK_TOPDIR}/src/share/javavm/export \ @@ -41818,12 +42297,12 @@ fi -I${JDK_TOPDIR}/src/$OPENJDK_TARGET_OS_API_DIR/native/common" # The shared libraries are compiled using the picflag. - CFLAGS_JDKLIB="$CCXXFLAGS_JDK $CFLAGS_JDK $PICFLAG $CFLAGS_JDKLIB_EXTRA" - CXXFLAGS_JDKLIB="$CCXXFLAGS_JDK $CXXFLAGS_JDK $PICFLAG $CXXFLAGS_JDKLIB_EXTRA " + CFLAGS_JDKLIB="$COMMON_CCXXFLAGS_JDK $CFLAGS_JDK $PICFLAG $CFLAGS_JDKLIB_EXTRA" + CXXFLAGS_JDKLIB="$COMMON_CCXXFLAGS_JDK $CXXFLAGS_JDK $PICFLAG $CXXFLAGS_JDKLIB_EXTRA " # Executable flags - CFLAGS_JDKEXE="$CCXXFLAGS_JDK $CFLAGS_JDK" - CXXFLAGS_JDKEXE="$CCXXFLAGS_JDK $CXXFLAGS_JDK" + CFLAGS_JDKEXE="$COMMON_CCXXFLAGS_JDK $CFLAGS_JDK" + CXXFLAGS_JDKEXE="$COMMON_CCXXFLAGS_JDK $CXXFLAGS_JDK" @@ -41832,6 +42311,7 @@ fi # Setup LDFLAGS et al. # + # Now this is odd. The JDK native libraries have to link against libjvm.so # On 32-bit machines there is normally two distinct libjvm.so:s, client and server. # Which should we link to? Are we lucky enough that the binary api to the libjvm.so library @@ -41847,39 +42327,94 @@ fi fi # TODO: make -debug optional "--disable-full-debug-symbols" LDFLAGS_JDK="$LDFLAGS_JDK -debug" - LDFLAGS_JDKLIB="${LDFLAGS_JDK} -dll -libpath:${JDK_OUTPUTDIR}/lib" - LDFLAGS_JDKLIB_SUFFIX="" + elif test "x$TOOLCHAIN_TYPE" = xgcc; then + # If this is a --hash-style=gnu system, use --hash-style=both, why? + # We have previously set HAS_GNU_HASH if this is the case + if test -n "$HAS_GNU_HASH"; then + LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker --hash-style=both" + fi + if test "x$OPENJDK_TARGET_OS" = xlinux; then + # And since we now know that the linker is gnu, then add -z defs, to forbid + # undefined symbols in object files. + LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker -z -Xlinker defs" + case $DEBUG_LEVEL in + release ) + # tell linker to optimize libraries. + # Should this be supplied to the OSS linker as well? + LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker -O1" + ;; + slowdebug ) + if test "x$HAS_LINKER_NOW" = "xtrue"; then + # do relocations at load + LDFLAGS_JDK="$LDFLAGS_JDK $LINKER_NOW_FLAG" + LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK $LINKER_NOW_FLAG" + fi + if test "x$HAS_LINKER_RELRO" = "xtrue"; then + # mark relocations read only + LDFLAGS_JDK="$LDFLAGS_JDK $LINKER_RELRO_FLAG" + LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK $LINKER_RELRO_FLAG" + fi + ;; + fastdebug ) + if test "x$HAS_LINKER_RELRO" = "xtrue"; then + # mark relocations read only + LDFLAGS_JDK="$LDFLAGS_JDK $LINKER_RELRO_FLAG" + LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK $LINKER_RELRO_FLAG" + fi + ;; + * ) + as_fn_error $? "Unrecognized \$DEBUG_LEVEL: $DEBUG_LEVEL" "$LINENO" 5 + ;; + esac + fi + elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then + LDFLAGS_JDK="$LDFLAGS_JDK -z defs -xildoff -ztext" + LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK -norunpath -xnolib" + fi + + if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then + # If undefined behaviour detection is enabled then we need to tell linker. + case $DEBUG_LEVEL in + release | fastdebug ) + ;; + slowdebug ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $HAS_CFLAG_DETECT_UNDEFINED_BEHAVIOR" >&5 +$as_echo "$as_me: WARNING: $HAS_CFLAG_DETECT_UNDEFINED_BEHAVIOR" >&2;} + if test "x$HAS_CFLAG_DETECT_UNDEFINED_BEHAVIOR" = "xtrue"; then + # enable undefined behaviour checking + LDFLAGS_JDK="$LDFLAGS_JDK `$ECHO -n $CFLAG_DETECT_UNDEFINED_BEHAVIOR_FLAG | sed -e "s/ *\(^ \+\)/ -Xlinker \1/g"`" + LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK `$ECHO -n $CFLAG_DETECT_UNDEFINED_BEHAVIOR_FLAG | sed -e "s/ *\(^ \+\)/ -Xlinker \1/g"`" + fi + ;; + * ) + as_fn_error $? "Unrecognized \$DEBUG_LEVEL: $DEBUG_LEVEL" "$LINENO" 5 + ;; + esac + fi + + # Customize LDFLAGS for executables + + LDFLAGS_JDKEXE="${LDFLAGS_JDK}" + + if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then if test "x$OPENJDK_TARGET_CPU_BITS" = "x64"; then LDFLAGS_STACK_SIZE=1048576 else LDFLAGS_STACK_SIZE=327680 fi - LDFLAGS_JDKEXE="${LDFLAGS_JDK} /STACK:$LDFLAGS_STACK_SIZE" + LDFLAGS_JDKEXE="${LDFLAGS_JDKEXE} /STACK:$LDFLAGS_STACK_SIZE" + elif test "x$OPENJDK_TARGET_OS" = xlinux; then + LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE -Xlinker --allow-shlib-undefined" + fi + + # Customize LDFLAGS for libs + LDFLAGS_JDKLIB="${LDFLAGS_JDK}" + + if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then + LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -dll -libpath:${JDK_OUTPUTDIR}/lib" + LDFLAGS_JDKLIB_SUFFIX="" else - if test "x$TOOLCHAIN_TYPE" = xgcc; then - # If this is a --hash-style=gnu system, use --hash-style=both, why? - # We have previously set HAS_GNU_HASH if this is the case - if test -n "$HAS_GNU_HASH"; then - LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker --hash-style=both " - fi - if test "x$OPENJDK_TARGET_OS" = xlinux; then - # And since we now know that the linker is gnu, then add -z defs, to forbid - # undefined symbols in object files. - LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker -z -Xlinker defs" - if test "x$DEBUG_LEVEL" = "xrelease"; then - # When building release libraries, tell the linker optimize them. - # Should this be supplied to the OSS linker as well? - LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker -O1" - fi - fi - fi - - if test "x$TOOLCHAIN_TYPE" = xsolstudio; then - LDFLAGS_JDK="$LDFLAGS_JDK -z defs -xildoff -ztext" - LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK -norunpath -xnolib" - fi - - LDFLAGS_JDKLIB="${LDFLAGS_JDK} $SHARED_LIBRARY_FLAGS \ + LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} ${SHARED_LIBRARY_FLAGS} \ -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}" # On some platforms (mac) the linker warns about non existing -L dirs. @@ -41900,11 +42435,6 @@ fi if test "x$TOOLCHAIN_TYPE" = xsolstudio; then LDFLAGS_JDKLIB_SUFFIX="$LDFLAGS_JDKLIB_SUFFIX -lc" fi - - LDFLAGS_JDKEXE="${LDFLAGS_JDK}" - if test "x$OPENJDK_TARGET_OS" = xlinux; then - LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE -Xlinker --allow-shlib-undefined" - fi fi @@ -42257,8 +42787,6 @@ $as_echo_n "checking what is not needed on MacOSX?... " >&6; } ALSA_NOT_NEEDED=yes PULSE_NOT_NEEDED=yes X11_NOT_NEEDED=yes - # If the java runtime framework is disabled, then we need X11. - # This will be adjusted below. { $as_echo "$as_me:${as_lineno-$LINENO}: result: alsa pulse x11" >&5 $as_echo "alsa pulse x11" >&6; } fi @@ -42279,33 +42807,6 @@ $as_echo "alsa" >&6; } X11_NOT_NEEDED=yes fi - ############################################################################### - # - # Check for MacOSX support for OpenJDK. - # - - - # Check whether --enable-macosx-runtime-support was given. -if test "${enable_macosx_runtime_support+set}" = set; then : - enableval=$enable_macosx_runtime_support; -fi - - if test "x$enable_macosx_runtime_support" != x; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Option --enable-macosx-runtime-support is deprecated and will be ignored." >&5 -$as_echo "$as_me: WARNING: Option --enable-macosx-runtime-support is deprecated and will be ignored." >&2;} - fi - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Mac OS X Java Framework" >&5 -$as_echo_n "checking for Mac OS X Java Framework... " >&6; } - if test -f /System/Library/Frameworks/JavaVM.framework/Frameworks/JavaRuntimeSupport.framework/Headers/JavaRuntimeSupport.h; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: /System/Library/Frameworks/JavaVM.framework" >&5 -$as_echo "/System/Library/Frameworks/JavaVM.framework" >&6; } - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - fi - ############################################################################### @@ -47176,10 +47677,43 @@ done # Check for the jpeg library # - USE_EXTERNAL_LIBJPEG=true - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -ljpeg" >&5 -$as_echo_n "checking for main in -ljpeg... " >&6; } -if ${ac_cv_lib_jpeg_main+:} false; then : + +# Check whether --with-libjpeg was given. +if test "${with_libjpeg+set}" = set; then : + withval=$with_libjpeg; +fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for which libjpeg to use" >&5 +$as_echo_n "checking for which libjpeg to use... " >&6; } + + # default is bundled + DEFAULT_LIBJPEG=bundled + + # + # if user didn't specify, use DEFAULT_LIBJPEG + # + if test "x${with_libjpeg}" = "x"; then + with_libjpeg=${DEFAULT_LIBJPEG} + fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${with_libjpeg}" >&5 +$as_echo "${with_libjpeg}" >&6; } + + if test "x${with_libjpeg}" = "xbundled"; then + USE_EXTERNAL_LIBJPEG=false + elif test "x${with_libjpeg}" = "xsystem"; then + ac_fn_cxx_check_header_mongrel "$LINENO" "jpeglib.h" "ac_cv_header_jpeglib_h" "$ac_includes_default" +if test "x$ac_cv_header_jpeglib_h" = xyes; then : + +else + as_fn_error $? "--with-libjpeg=system specified, but jpeglib.h not found!" "$LINENO" 5 +fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for jpeg_CreateDecompress in -ljpeg" >&5 +$as_echo_n "checking for jpeg_CreateDecompress in -ljpeg... " >&6; } +if ${ac_cv_lib_jpeg_jpeg_CreateDecompress+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -47187,27 +47721,33 @@ LIBS="-ljpeg $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char jpeg_CreateDecompress (); int main () { -return main (); +return jpeg_CreateDecompress (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : - ac_cv_lib_jpeg_main=yes + ac_cv_lib_jpeg_jpeg_CreateDecompress=yes else - ac_cv_lib_jpeg_main=no + ac_cv_lib_jpeg_jpeg_CreateDecompress=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_jpeg_main" >&5 -$as_echo "$ac_cv_lib_jpeg_main" >&6; } -if test "x$ac_cv_lib_jpeg_main" = xyes; then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_jpeg_jpeg_CreateDecompress" >&5 +$as_echo "$ac_cv_lib_jpeg_jpeg_CreateDecompress" >&6; } +if test "x$ac_cv_lib_jpeg_jpeg_CreateDecompress" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBJPEG 1 _ACEOF @@ -47215,13 +47755,16 @@ _ACEOF LIBS="-ljpeg $LIBS" else - USE_EXTERNAL_LIBJPEG=false - { $as_echo "$as_me:${as_lineno-$LINENO}: Will use jpeg decoder bundled with the OpenJDK source" >&5 -$as_echo "$as_me: Will use jpeg decoder bundled with the OpenJDK source" >&6;} - + as_fn_error $? "--with-libjpeg=system specified, but no libjpeg found" "$LINENO" 5 fi + USE_EXTERNAL_LIBJPEG=true + else + as_fn_error $? "Invalid use of --with-libjpeg: ${with_libjpeg}, use 'system' or 'bundled'" "$LINENO" 5 + fi + + ############################################################################### # diff --git a/common/autoconf/hotspot-spec.gmk.in b/common/autoconf/hotspot-spec.gmk.in index f7abdd40e0a..057d882c28e 100644 --- a/common/autoconf/hotspot-spec.gmk.in +++ b/common/autoconf/hotspot-spec.gmk.in @@ -69,8 +69,8 @@ ISA_DIR=$(OPENJDK_TARGET_CPU_ISADIR) # Yet another name for arch used for an extra subdir below the jvm lib. # Uses i386 and amd64, instead of x86 and x86_64. LIBARCH=$(OPENJDK_TARGET_CPU_LEGACY_LIB) -# Old name for OPENJDK_TARGET_CPU, uses i586 and amd64, instead of x86 and x86_64. -ARCH=$(OPENJDK_TARGET_CPU_LEGACY) +# Set the cpu architecture +ARCH=$(OPENJDK_TARGET_CPU_ARCH) # Legacy setting for building for a 64 bit machine. # If yes then this expands to _LP64:=1 @LP64@ diff --git a/common/autoconf/libraries.m4 b/common/autoconf/libraries.m4 index 6ee3221ad96..3a689ef62ee 100644 --- a/common/autoconf/libraries.m4 +++ b/common/autoconf/libraries.m4 @@ -65,8 +65,6 @@ AC_DEFUN_ONCE([LIB_SETUP_INIT], ALSA_NOT_NEEDED=yes PULSE_NOT_NEEDED=yes X11_NOT_NEEDED=yes - # If the java runtime framework is disabled, then we need X11. - # This will be adjusted below. AC_MSG_RESULT([alsa pulse x11]) fi @@ -83,20 +81,6 @@ AC_DEFUN_ONCE([LIB_SETUP_INIT], if test "x$SUPPORT_HEADFUL" = xno; then X11_NOT_NEEDED=yes fi - - ############################################################################### - # - # Check for MacOSX support for OpenJDK. - # - - BASIC_DEPRECATED_ARG_ENABLE(macosx-runtime-support, macosx_runtime_support) - - AC_MSG_CHECKING([for Mac OS X Java Framework]) - if test -f /System/Library/Frameworks/JavaVM.framework/Frameworks/JavaRuntimeSupport.framework/Headers/JavaRuntimeSupport.h; then - AC_MSG_RESULT([/System/Library/Frameworks/JavaVM.framework]) - else - AC_MSG_RESULT([no]) - fi ]) AC_DEFUN_ONCE([LIB_SETUP_X11], @@ -620,11 +604,36 @@ AC_DEFUN_ONCE([LIB_SETUP_MISC_LIBS], # Check for the jpeg library # - USE_EXTERNAL_LIBJPEG=true - AC_CHECK_LIB(jpeg, main, [], - [ USE_EXTERNAL_LIBJPEG=false - AC_MSG_NOTICE([Will use jpeg decoder bundled with the OpenJDK source]) - ]) + AC_ARG_WITH(libjpeg, [AS_HELP_STRING([--with-libjpeg], + [use libjpeg from build system or OpenJDK source (system, bundled) @<:@bundled@:>@])]) + + AC_MSG_CHECKING([for which libjpeg to use]) + + # default is bundled + DEFAULT_LIBJPEG=bundled + + # + # if user didn't specify, use DEFAULT_LIBJPEG + # + if test "x${with_libjpeg}" = "x"; then + with_libjpeg=${DEFAULT_LIBJPEG} + fi + + AC_MSG_RESULT(${with_libjpeg}) + + if test "x${with_libjpeg}" = "xbundled"; then + USE_EXTERNAL_LIBJPEG=false + elif test "x${with_libjpeg}" = "xsystem"; then + AC_CHECK_HEADER(jpeglib.h, [], + [ AC_MSG_ERROR([--with-libjpeg=system specified, but jpeglib.h not found!])]) + AC_CHECK_LIB(jpeg, jpeg_CreateDecompress, [], + [ AC_MSG_ERROR([--with-libjpeg=system specified, but no libjpeg found])]) + + USE_EXTERNAL_LIBJPEG=true + else + AC_MSG_ERROR([Invalid use of --with-libjpeg: ${with_libjpeg}, use 'system' or 'bundled']) + fi + AC_SUBST(USE_EXTERNAL_LIBJPEG) ############################################################################### diff --git a/common/autoconf/platform.m4 b/common/autoconf/platform.m4 index 1f06f0ce7d5..54838a3e72c 100644 --- a/common/autoconf/platform.m4 +++ b/common/autoconf/platform.m4 @@ -84,7 +84,7 @@ AC_DEFUN([PLATFORM_EXTRACT_VARS_FROM_CPU], VAR_CPU_BITS=32 VAR_CPU_ENDIAN=big ;; - sparcv9) + sparcv9|sparc64) VAR_CPU=sparcv9 VAR_CPU_ARCH=sparc VAR_CPU_BITS=64 diff --git a/common/autoconf/spec.gmk.in b/common/autoconf/spec.gmk.in index 2f6d7bd3746..bc916f636c3 100644 --- a/common/autoconf/spec.gmk.in +++ b/common/autoconf/spec.gmk.in @@ -347,6 +347,9 @@ CPP:=@FIXPATH@ @CPP@ # The linker can be gcc or ld on posix systems, or link.exe on windows systems. LD:=@FIXPATH@ @LD@ +# Xcode SDK path +SDKROOT:=@SDKROOT@ + # The linker on older SuSE distros (e.g. on SLES 10) complains with: # "Invalid version tag `SUNWprivate_1.1'. Only anonymous version tag is allowed in executable." # if feeded with a version script which contains named tags. @@ -544,7 +547,7 @@ SETFILE:=@SETFILE@ XATTR:=@XATTR@ JT_HOME:=@JT_HOME@ JTREGEXE:=@JTREGEXE@ - +XCODEBUILD=@XCODEBUILD@ FIXPATH:=@FIXPATH@ # Where the build output is stored for your convenience. diff --git a/common/autoconf/toolchain.m4 b/common/autoconf/toolchain.m4 index b7c00d4f495..f380bf446ad 100644 --- a/common/autoconf/toolchain.m4 +++ b/common/autoconf/toolchain.m4 @@ -24,11 +24,11 @@ # ######################################################################## -# This file is responsible for detecting, verifying and setting up the -# toolchain, i.e. the compiler, linker and related utilities. It will setup +# This file is responsible for detecting, verifying and setting up the +# toolchain, i.e. the compiler, linker and related utilities. It will setup # proper paths to the binaries, but it will not setup any flags. # -# The binaries used is determined by the toolchain type, which is the family of +# The binaries used is determined by the toolchain type, which is the family of # compilers and related tools that are used. ######################################################################## @@ -83,7 +83,7 @@ AC_DEFUN([TOOLCHAIN_SETUP_FILENAME_PATTERNS], AC_SUBST(SHARED_LIBRARY) AC_SUBST(STATIC_LIBRARY) AC_SUBST(OBJ_SUFFIX) - AC_SUBST(EXE_SUFFIX) + AC_SUBST(EXE_SUFFIX) ]) # Determine which toolchain type to use, and make sure it is valid for this @@ -98,26 +98,33 @@ AC_DEFUN_ONCE([TOOLCHAIN_DETERMINE_TOOLCHAIN_TYPE], VALID_TOOLCHAINS=${!toolchain_var_name} if test "x$OPENJDK_TARGET_OS" = xmacosx; then - # On Mac OS X, default toolchain to clang after Xcode 5 - XCODE_VERSION_OUTPUT=`xcodebuild -version 2>&1 | $HEAD -n 1` - $ECHO "$XCODE_VERSION_OUTPUT" | $GREP "Xcode " > /dev/null - if test $? -ne 0; then - AC_MSG_ERROR([Failed to determine Xcode version.]) - fi - XCODE_MAJOR_VERSION=`$ECHO $XCODE_VERSION_OUTPUT | \ - $SED -e 's/^Xcode \(@<:@1-9@:>@@<:@0-9.@:>@*\)/\1/' | \ - $CUT -f 1 -d .` - AC_MSG_NOTICE([Xcode major version: $XCODE_MAJOR_VERSION]) - if test $XCODE_MAJOR_VERSION -ge 5; then - DEFAULT_TOOLCHAIN="clang" + if test -n "$XCODEBUILD"; then + # On Mac OS X, default toolchain to clang after Xcode 5 + XCODE_VERSION_OUTPUT=`"$XCODEBUILD" -version 2>&1 | $HEAD -n 1` + $ECHO "$XCODE_VERSION_OUTPUT" | $GREP "Xcode " > /dev/null + if test $? -ne 0; then + AC_MSG_ERROR([Failed to determine Xcode version.]) + fi + XCODE_MAJOR_VERSION=`$ECHO $XCODE_VERSION_OUTPUT | \ + $SED -e 's/^Xcode \(@<:@1-9@:>@@<:@0-9.@:>@*\)/\1/' | \ + $CUT -f 1 -d .` + AC_MSG_NOTICE([Xcode major version: $XCODE_MAJOR_VERSION]) + if test $XCODE_MAJOR_VERSION -ge 5; then + DEFAULT_TOOLCHAIN="clang" + else + DEFAULT_TOOLCHAIN="gcc" + fi else - DEFAULT_TOOLCHAIN="gcc" + # If Xcode is not installed, but the command line tools are + # then we can't run xcodebuild. On these systems we should + # default to clang + DEFAULT_TOOLCHAIN="clang" fi else # First toolchain type in the list is the default DEFAULT_TOOLCHAIN=${VALID_TOOLCHAINS%% *} fi - + if test "x$with_toolchain_type" = xlist; then # List all toolchains AC_MSG_NOTICE([The following toolchains are valid on this platform:]) @@ -126,7 +133,7 @@ AC_DEFUN_ONCE([TOOLCHAIN_DETERMINE_TOOLCHAIN_TYPE], TOOLCHAIN_DESCRIPTION=${!toolchain_var_name} $PRINTF " %-10s %s\n" $toolchain "$TOOLCHAIN_DESCRIPTION" done - + exit 0 elif test "x$with_toolchain_type" != x; then # User override; check that it is valid @@ -168,10 +175,10 @@ AC_DEFUN_ONCE([TOOLCHAIN_DETERMINE_TOOLCHAIN_TYPE], AC_MSG_NOTICE([Using default toolchain $TOOLCHAIN_TYPE ($TOOLCHAIN_DESCRIPTION)]) else AC_MSG_NOTICE([Using user selected toolchain $TOOLCHAIN_TYPE ($TOOLCHAIN_DESCRIPTION). Default toolchain is $DEFAULT_TOOLCHAIN.]) - fi + fi ]) -# Before we start detecting the toolchain executables, we might need some +# Before we start detecting the toolchain executables, we might need some # special setup, e.g. additional paths etc. AC_DEFUN_ONCE([TOOLCHAIN_PRE_DETECTION], [ @@ -184,7 +191,7 @@ AC_DEFUN_ONCE([TOOLCHAIN_PRE_DETECTION], ORG_OBJCFLAGS="$OBJCFLAGS" # On Windows, we need to detect the visual studio installation first. - # This will change the PATH, but we need to keep that new PATH even + # This will change the PATH, but we need to keep that new PATH even # after toolchain detection is done, since the compiler (on x86) uses # it for DLL resolution in runtime. if test "x$OPENJDK_BUILD_OS" = "xwindows" && test "x$TOOLCHAIN_TYPE" = "xmicrosoft"; then @@ -208,7 +215,7 @@ AC_DEFUN_ONCE([TOOLCHAIN_PRE_DETECTION], PATH="/usr/ccs/bin:$PATH" fi - # Finally add TOOLCHAIN_PATH at the beginning, to allow --with-tools-dir to + # Finally add TOOLCHAIN_PATH at the beginning, to allow --with-tools-dir to # override all other locations. if test "x$TOOLCHAIN_PATH" != x; then PATH=$TOOLCHAIN_PATH:$PATH @@ -254,7 +261,7 @@ AC_DEFUN([TOOLCHAIN_CHECK_COMPILER_VERSION], AC_MSG_NOTICE([The result from running with --version was: "$ALT_VERSION_OUTPUT"]) AC_MSG_ERROR([A $TOOLCHAIN_TYPE compiler is required. Try setting --with-tools-dir.]) fi - # Remove usage instructions (if present), and + # Remove usage instructions (if present), and # collapse compiler output into a single line COMPILER_VERSION_STRING=`$ECHO $COMPILER_VERSION_OUTPUT | \ $SED -e 's/ *@<:@Uu@:>@sage:.*//'` @@ -282,7 +289,7 @@ AC_DEFUN([TOOLCHAIN_CHECK_COMPILER_VERSION], # There is no specific version flag, but all output starts with a version string. # First line typically looks something like: # Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.40219.01 for 80x86 - COMPILER_VERSION_OUTPUT=`$COMPILER 2>&1 | $HEAD -n 1 | $TR -d '\r'` + COMPILER_VERSION_OUTPUT=`$COMPILER 2>&1 | $HEAD -n 1 | $TR -d '\r'` # Check that this is likely to be Microsoft CL.EXE. $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "Microsoft.*Compiler" > /dev/null if test $? -ne 0; then @@ -360,7 +367,7 @@ AC_DEFUN([TOOLCHAIN_FIND_COMPILER], AC_MSG_NOTICE([Will use user supplied compiler $1=[$]$1]) if test "x`basename [$]$1`" = "x[$]$1"; then # A command without a complete path is provided, search $PATH. - + AC_PATH_PROGS(POTENTIAL_$1, [$]$1) if test "x$POTENTIAL_$1" != x; then $1=$POTENTIAL_$1 @@ -375,12 +382,12 @@ AC_DEFUN([TOOLCHAIN_FIND_COMPILER], fi else # No user supplied value. Locate compiler ourselves. - + # If we are cross compiling, assume cross compilation tools follows the # cross compilation standard where they are prefixed with the autoconf - # standard name for the target. For example the binary + # standard name for the target. For example the binary # i686-sun-solaris2.10-gcc will cross compile for i686-sun-solaris2.10. - # If we are not cross compiling, then the default compiler name will be + # If we are not cross compiling, then the default compiler name will be # used. $1= @@ -450,9 +457,9 @@ AC_DEFUN([TOOLCHAIN_FIND_COMPILER], TOOLCHAIN_CHECK_COMPILER_VERSION([$1], [$COMPILER_NAME]) ]) -# Detect the core components of the toolchain, i.e. the compilers (CC and CXX), -# preprocessor (CPP and CXXCPP), the linker (LD), the assembler (AS) and the -# archiver (AR). Verify that the compilers are correct according to the +# Detect the core components of the toolchain, i.e. the compilers (CC and CXX), +# preprocessor (CPP and CXXCPP), the linker (LD), the assembler (AS) and the +# archiver (AR). Verify that the compilers are correct according to the # toolchain type. AC_DEFUN_ONCE([TOOLCHAIN_DETECT_TOOLCHAIN_CORE], [ @@ -529,7 +536,7 @@ AC_DEFUN_ONCE([TOOLCHAIN_DETECT_TOOLCHAIN_CORE], ]) # Setup additional tools that is considered a part of the toolchain, but not the -# core part. Many of these are highly platform-specific and do not exist, +# core part. Many of these are highly platform-specific and do not exist, # and/or are not needed on all platforms. AC_DEFUN_ONCE([TOOLCHAIN_DETECT_TOOLCHAIN_EXTRA], [ @@ -551,7 +558,7 @@ AC_DEFUN_ONCE([TOOLCHAIN_DETECT_TOOLCHAIN_EXTRA], AC_CHECK_PROG([DUMPBIN], [dumpbin], [dumpbin],,,) BASIC_FIXUP_EXECUTABLE(DUMPBIN) fi - + if test "x$OPENJDK_TARGET_OS" = xsolaris; then BASIC_PATH_PROGS(STRIP, strip) BASIC_FIXUP_EXECUTABLE(STRIP) @@ -559,7 +566,7 @@ AC_DEFUN_ONCE([TOOLCHAIN_DETECT_TOOLCHAIN_EXTRA], BASIC_FIXUP_EXECUTABLE(NM) BASIC_PATH_PROGS(GNM, gnm) BASIC_FIXUP_EXECUTABLE(GNM) - + BASIC_PATH_PROGS(MCS, mcs) BASIC_FIXUP_EXECUTABLE(MCS) elif test "x$OPENJDK_TARGET_OS" != xwindows; then @@ -592,17 +599,17 @@ AC_DEFUN_ONCE([TOOLCHAIN_DETECT_TOOLCHAIN_EXTRA], # Setup the build tools (i.e, the compiler and linker used to build programs # that should be run on the build platform, not the target platform, as a build -# helper). Since the non-cross-compile case uses the normal, target compilers +# helper). Since the non-cross-compile case uses the normal, target compilers # for this, we can only do this after these have been setup. AC_DEFUN_ONCE([TOOLCHAIN_SETUP_BUILD_COMPILERS], -[ +[ if test "x$COMPILE_TYPE" = "xcross"; then # Now we need to find a C/C++ compiler that can build executables for the # build platform. We can't use the AC_PROG_CC macro, since it can only be # used once. Also, we need to do this without adding a tools dir to the # path, otherwise we might pick up cross-compilers which don't use standard # naming. - + # FIXME: we should list the discovered compilers as an exclude pattern! # If we do that, we can do this detection before POST_DETECTION, and still # find the build compilers in the tools dir, if needed. @@ -690,15 +697,39 @@ AC_DEFUN_ONCE([TOOLCHAIN_MISC_CHECKS], # If this is a --hash-style=gnu system, use --hash-style=both, why? HAS_GNU_HASH=`$CC -dumpspecs 2>/dev/null | $GREP 'hash-style=gnu'` # This is later checked when setting flags. + + # "-Og" suppported for GCC 4.8 and later + CFLAG_OPTIMIZE_DEBUG_FLAG="-Og" + FLAGS_COMPILER_CHECK_ARGUMENTS([$CFLAG_OPTIMIZE_DEBUG_FLAG], + [HAS_CFLAG_OPTIMIZE_DEBUG=true], + [HAS_CFLAG_OPTIMIZE_DEBUG=false]) + + # "-fsanitize=undefined" supported for GCC 4.9 and later + CFLAG_DETECT_UNDEFINED_BEHAVIOR_FLAG="-fsanitize=undefined -fsanitize-recover" + FLAGS_COMPILER_CHECK_ARGUMENTS([$CFLAG_DETECT_UNDEFINED_BEHAVIOR_FLAG], + [HAS_CFLAG_DETECT_UNDEFINED_BEHAVIOR=true], + [HAS_CFLAG_DETECT_UNDEFINED_BEHAVIOR=false]) + + # "-z relro" supported in GNU binutils 2.17 and later + LINKER_RELRO_FLAG="-Xlinker -z -Xlinker relro" + FLAGS_LINKER_CHECK_ARGUMENTS([$LINKER_RELRO_FLAG], + [HAS_LINKER_RELRO=true], + [HAS_LINKER_RELRO=false]) + + # "-z now" supported in GNU binutils 2.11 and later + LINKER_NOW_FLAG="-Xlinker -z -Xlinker now" + FLAGS_LINKER_CHECK_ARGUMENTS([$LINKER_NOW_FLAG], + [HAS_LINKER_NOW=true], + [HAS_LINKER_NOW=false]) fi - # Check for broken SuSE 'ld' for which 'Only anonymous version tag is allowed + # Check for broken SuSE 'ld' for which 'Only anonymous version tag is allowed # in executable.' USING_BROKEN_SUSE_LD=no if test "x$OPENJDK_TARGET_OS" = xlinux && test "x$TOOLCHAIN_TYPE" = xgcc; then AC_MSG_CHECKING([for broken SuSE 'ld' which only understands anonymous version tags in executables]) - echo "SUNWprivate_1.1 { local: *; };" > version-script.map - echo "int main() { }" > main.c + $ECHO "SUNWprivate_1.1 { local: *; };" > version-script.map + $ECHO "int main() { }" > main.c if $CXX -Xlinker -version-script=version-script.map main.c 2>&AS_MESSAGE_LOG_FD >&AS_MESSAGE_LOG_FD; then AC_MSG_RESULT(no) USING_BROKEN_SUSE_LD=no diff --git a/corba/.hgtags b/corba/.hgtags index 66b823f5f9f..e76e0325e2d 100644 --- a/corba/.hgtags +++ b/corba/.hgtags @@ -261,3 +261,7 @@ e54022d0dd92106fff7f7fe670010cd7e6517ee3 jdk9-b15 422ef9d29d84f571453f015c4cb8713c3af70ee4 jdk9-b16 4c75c2ca7cf3e0618315879acf17f42c8fcd0c09 jdk9-b17 77565aaaa2bb814e94817e92d680168052a25395 jdk9-b18 +eecc1b6adc7e193d00a0641eb0963add5a4c06e8 jdk9-b19 +87f36eecb1665012d01c5cf102494e591c943ea6 jdk9-b20 +3615a4e7f0542ca7552ad6454b742c73ee211d8e jdk9-b21 +ddc07abf4307855c0dc904cc5c96cc764023a930 jdk9-b22 diff --git a/corba/src/share/classes/com/sun/corba/se/impl/io/OutputStreamHook.java b/corba/src/share/classes/com/sun/corba/se/impl/io/OutputStreamHook.java index 1748397d065..6908cad9a83 100644 --- a/corba/src/share/classes/com/sun/corba/se/impl/io/OutputStreamHook.java +++ b/corba/src/share/classes/com/sun/corba/se/impl/io/OutputStreamHook.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 @@ -35,7 +35,8 @@ import java.io.IOException; import java.io.OutputStream; import java.io.ObjectOutputStream; import java.io.ObjectOutput; -import java.util.Hashtable; +import java.util.Map; +import java.util.HashMap; import org.omg.CORBA.INTERNAL; @@ -49,7 +50,7 @@ public abstract class OutputStreamHook extends ObjectOutputStream */ private class HookPutFields extends ObjectOutputStream.PutField { - private Hashtable fields = new Hashtable(); + private Map fields = new HashMap<>(); /** * Put the value of the named boolean field into the persistent field. @@ -140,7 +141,6 @@ public abstract class OutputStreamHook extends ObjectOutputStream public OutputStreamHook() throws java.io.IOException { super(); - } public void defaultWriteObject() throws IOException { diff --git a/get_source.sh b/get_source.sh index f83a3766c12..5e874d1cb51 100644 --- a/get_source.sh +++ b/get_source.sh @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright (c) 2010, 2012, 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,9 +25,76 @@ # questions. # -# Get clones of all nested repositories -sh ./common/bin/hgforest.sh clone "$@" || exit 1 +to_stderr() { + echo "$@" >&2 +} + +error() { + to_stderr "ERROR: $1" + exit ${2:-126} +} + +warning() { + to_stderr "WARNING: $1" +} + +version_field() { + # rev is typically omitted for minor and major releases + field=`echo ${1}.0 | cut -f ${2} -d .` + if expr 1 + $field >/dev/null 2> /dev/null; then + echo $field + else + echo -1 + fi +} + +# Version check + +# required +reqdmajor=1 +reqdminor=4 +reqdrev=0 + +# requested +rqstmajor=2 +rqstminor=6 +rqstrev=3 + + +# installed +hgwhere="`command -v hg`" +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'`" +if [ "x${hgversion}" = "x" ] ; then + error "Could not determine Mercurial version of $hgwhere" +fi + +hgmajor="`version_field $hgversion 1`" +hgminor="`version_field $hgversion 2`" +hgrev="`version_field $hgversion 3`" + +if [ $hgmajor -eq -1 -o $hgminor -eq -1 -o $hgrev -eq -1 ] ; then + error "Could not determine Mercurial version of $hgwhere from \"$hgversion\"" +fi + + +# Require +if [ $hgmajor -lt $reqdmajor -o \( $hgmajor -eq $reqdmajor -a $hgminor -lt $reqdminor \) -o \( $hgmajor -eq $reqdmajor -a $hgminor -eq $reqdminor -a $hgrev -lt $reqdrev \) ] ; then + error "Mercurial version $reqdmajor.$reqdminor.$reqdrev or later is required. $hgwhere is version $hgversion" +fi + + +# Request +if [ $hgmajor -lt $rqstmajor -o \( $hgmajor -eq $rqstmajor -a $hgminor -lt $rqstminor \) -o \( $hgmajor -eq $rqstmajor -a $hgminor -eq $rqstminor -a $hgrev -lt $rqstrev \) ] ; then + warning "Mercurial version $rqstmajor.$rqstminor.$rqstrev or later is recommended. $hgwhere is version $hgversion" +fi + + +# Get clones of all absent nested repositories (harmless if already exist) +sh ./common/bin/hgforest.sh clone "$@" || exit $? # Update all existing repositories to the latest sources sh ./common/bin/hgforest.sh pull -u - diff --git a/hotspot/.hgtags b/hotspot/.hgtags index 77d8c723248..882932d140a 100644 --- a/hotspot/.hgtags +++ b/hotspot/.hgtags @@ -421,3 +421,7 @@ bd333491bb6c012d7b606939406d0fa9a5ac7ffd jdk9-b14 b14e7c0b7d3ec04127f565cda1d84122e205680c jdk9-b16 14b656df31c2cb09c505921061e79977823de71a jdk9-b17 871fd128548480095e0dc3fc34c422666baeec75 jdk9-b18 +d4cffb3ae6213c66c7522ebffe0349360a45f0ef jdk9-b19 +c1af79d122ec9f715fa29312b5e91763f3a4dfc4 jdk9-b20 +17b4a5e831b398738feedb0afe75245744510153 jdk9-b21 +518d1fcc0799494f013e00e0a94a91b6f212d54f jdk9-b22 diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/gc_implementation/g1/HeapRegion.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/gc_implementation/g1/HeapRegion.java index 4aa7620f730..8d924973d8f 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/gc_implementation/g1/HeapRegion.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/gc_implementation/g1/HeapRegion.java @@ -24,23 +24,26 @@ package sun.jvm.hotspot.gc_implementation.g1; +import java.util.ArrayList; +import java.util.List; import java.util.Observable; import java.util.Observer; - import sun.jvm.hotspot.debugger.Address; -import sun.jvm.hotspot.memory.ContiguousSpace; +import sun.jvm.hotspot.memory.CompactibleSpace; +import sun.jvm.hotspot.memory.MemRegion; import sun.jvm.hotspot.runtime.VM; +import sun.jvm.hotspot.types.AddressField; import sun.jvm.hotspot.types.CIntegerField; import sun.jvm.hotspot.types.Type; import sun.jvm.hotspot.types.TypeDataBase; // Mirror class for HeapRegion. Currently we don't actually include -// any of its fields but only iterate over it (which we get "for free" -// as HeapRegion ultimately inherits from ContiguousSpace). +// any of its fields but only iterate over it. -public class HeapRegion extends ContiguousSpace { +public class HeapRegion extends CompactibleSpace { // static int GrainBytes; static private CIntegerField grainBytesField; + static private AddressField topField; static { VM.registerVMInitializedObserver(new Observer() { @@ -54,6 +57,8 @@ public class HeapRegion extends ContiguousSpace { Type type = db.lookupType("HeapRegion"); grainBytesField = type.getCIntegerField("GrainBytes"); + topField = type.getAddressField("_top"); + } static public long grainBytes() { @@ -63,4 +68,25 @@ public class HeapRegion extends ContiguousSpace { public HeapRegion(Address addr) { super(addr); } + + public Address top() { + return topField.getValue(addr); + } + + @Override + public List getLiveRegions() { + List res = new ArrayList(); + res.add(new MemRegion(bottom(), top())); + return res; + } + + @Override + public long used() { + return top().minus(bottom()); + } + + @Override + public long free() { + return end().minus(top()); + } } diff --git a/hotspot/make/bsd/makefiles/gcc.make b/hotspot/make/bsd/makefiles/gcc.make index b2b925b2e1c..54d319bb1eb 100644 --- a/hotspot/make/bsd/makefiles/gcc.make +++ b/hotspot/make/bsd/makefiles/gcc.make @@ -280,16 +280,7 @@ endif # optimization control flags (Used by fastdebug and release variants) OPT_CFLAGS/NOOPT=-O0 -ifeq ($(USE_CLANG), true) - # Clang does not support -Og - OPT_CFLAGS/DEBUG=-O0 -else ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 8 \) \))" "1" - # Allow basic optimizations which don't distrupt debugging. (Principally dead code elimination) - OPT_CFLAGS/DEBUG=-Og -else - # Allow no optimizations. - OPT_CFLAGS/DEBUG=-O0 -endif +OPT_CFLAGS/DEBUG=-O0 OPT_CFLAGS/SIZE=-Os OPT_CFLAGS/SPEED=-O3 @@ -457,16 +448,8 @@ ifeq ($(USE_CLANG), true) CFLAGS += -flimit-debug-info endif -ifeq ($(USE_CLANG), true) - # Clang does not support -Og - DEBUG_CFLAGS=-O0 -else ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 8 \) \))" "1" - # Allow basic optimizations which don't distrupt debugging. (Principally dead code elimination) - DEBUG_CFLAGS=-Og -else - # Allow no optimizations. - DEBUG_CFLAGS=-O0 -endif +# Allow no optimizations. +DEBUG_CFLAGS=-O0 # DEBUG_BINARIES uses full -g debug information for all configs ifeq ($(DEBUG_BINARIES), true) diff --git a/hotspot/make/excludeSrc.make b/hotspot/make/excludeSrc.make index 55495e6bef2..00db453d5f8 100644 --- a/hotspot/make/excludeSrc.make +++ b/hotspot/make/excludeSrc.make @@ -93,6 +93,7 @@ ifeq ($(INCLUDE_ALL_GCS), false) ageTable.cpp \ collectorCounters.cpp \ cSpaceCounters.cpp \ + gcId.cpp \ gcPolicyCounters.cpp \ gcStats.cpp \ gcTimer.cpp \ diff --git a/hotspot/make/jprt.properties b/hotspot/make/jprt.properties index eea0ef53391..22c7b05ad6d 100644 --- a/hotspot/make/jprt.properties +++ b/hotspot/make/jprt.properties @@ -350,21 +350,25 @@ jprt.make.rule.test.targets.standard.internalvmtests = \ ${jprt.my.windows.i586}-fastdebug-c2-internalvmtests, \ ${jprt.my.windows.x64}-fastdebug-c2-internalvmtests -jprt.make.rule.test.targets.standard.wbapi = \ - ${jprt.my.solaris.sparcv9}-{product|fastdebug}-c2-wbapitest, \ - ${jprt.my.solaris.x64}-{product|fastdebug}-c2-wbapitest, \ - ${jprt.my.linux.i586}-{product|fastdebug}-c2-wbapitest, \ - ${jprt.my.linux.x64}-{product|fastdebug}-c2-wbapitest, \ - ${jprt.my.windows.i586}-{product|fastdebug}-c2-wbapitest, \ - ${jprt.my.windows.x64}-{product|fastdebug}-c2-wbapitest, \ - ${jprt.my.linux.i586}-{product|fastdebug}-c1-wbapitest, \ - ${jprt.my.windows.i586}-{product|fastdebug}-c1-wbapitest +jprt.make.rule.test.targets.standard.reg.group = \ + ${jprt.my.solaris.sparcv9}-{product|fastdebug}-c2-GROUP, \ + ${jprt.my.solaris.x64}-{product|fastdebug}-c2-GROUP, \ + ${jprt.my.linux.i586}-{product|fastdebug}-c2-GROUP, \ + ${jprt.my.linux.x64}-{product|fastdebug}-c2-GROUP, \ + ${jprt.my.windows.i586}-{product|fastdebug}-c2-GROUP, \ + ${jprt.my.windows.x64}-{product|fastdebug}-c2-GROUP, \ + ${jprt.my.linux.i586}-{product|fastdebug}-c1-GROUP, \ + ${jprt.my.windows.i586}-{product|fastdebug}-c1-GROUP jprt.make.rule.test.targets.standard = \ ${jprt.make.rule.test.targets.standard.client}, \ ${jprt.make.rule.test.targets.standard.server}, \ ${jprt.make.rule.test.targets.standard.internalvmtests}, \ - ${jprt.make.rule.test.targets.standard.wbapi} + ${jprt.make.rule.test.targets.standard.reg.group:GROUP=hotspot_wbapitest}, \ + ${jprt.make.rule.test.targets.standard.reg.group:GROUP=hotspot_compiler}, \ + ${jprt.make.rule.test.targets.standard.reg.group:GROUP=hotspot_gc}, \ + ${jprt.make.rule.test.targets.standard.reg.group:GROUP=hotspot_runtime}, \ + ${jprt.make.rule.test.targets.standard.reg.group:GROUP=hotspot_serviceability} jprt.make.rule.test.targets.embedded = \ ${jprt.make.rule.test.targets.standard.client} diff --git a/hotspot/make/linux/makefiles/dtrace.make b/hotspot/make/linux/makefiles/dtrace.make index 3a053736aae..7585eae9429 100644 --- a/hotspot/make/linux/makefiles/dtrace.make +++ b/hotspot/make/linux/makefiles/dtrace.make @@ -40,7 +40,14 @@ else ifneq ($(ALT_SDT_H),) SDT_H_FILE = $(ALT_SDT_H) else - SDT_H_FILE = /usr/include/sys/sdt.h + ifeq ($(USE_CLANG), true) + # Clang doesn't support the -print-sysroot option and there is no known equivalent + # option, so fall back to using / as sysroot + SDT_SYSROOT= + else + SDT_SYSROOT=$(shell $(CXX) -print-sysroot) + endif + SDT_H_FILE = $(SDT_SYSROOT)/usr/include/sys/sdt.h endif DTRACE_ENABLED = $(shell test -f $(SDT_H_FILE) && echo $(SDT_H_FILE)) diff --git a/hotspot/make/linux/makefiles/gcc.make b/hotspot/make/linux/makefiles/gcc.make index df3f8bda26f..a20e7a1c18b 100644 --- a/hotspot/make/linux/makefiles/gcc.make +++ b/hotspot/make/linux/makefiles/gcc.make @@ -231,13 +231,7 @@ CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@)) # optimization control flags (Used by fastdebug and release variants) OPT_CFLAGS/NOOPT=-O0 -ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 8 \) \))" "1" - # Allow basic optimizations which don't distrupt debugging. (Principally dead code elimination) - OPT_CFLAGS/DEBUG=-Og -else - # Allow no optimizations. - OPT_CFLAGS/DEBUG=-O0 -endif +OPT_CFLAGS/DEBUG=-O0 OPT_CFLAGS/SIZE=-Os OPT_CFLAGS/SPEED=-O3 @@ -344,13 +338,8 @@ ifeq ($(USE_CLANG), true) CFLAGS += -flimit-debug-info endif -ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 8 \) \))" "1" - # Allow basic optimizations which don't distrupt debugging. (Principally dead code elimination) - DEBUG_CFLAGS=-Og -else - # Allow no optimizations. - DEBUG_CFLAGS=-O0 -endif +# Allow no optimizations. +DEBUG_CFLAGS=-O0 # DEBUG_BINARIES uses full -g debug information for all configs ifeq ($(DEBUG_BINARIES), true) diff --git a/hotspot/make/solaris/makefiles/gcc.make b/hotspot/make/solaris/makefiles/gcc.make index 801bb4ee08e..9ea05411166 100644 --- a/hotspot/make/solaris/makefiles/gcc.make +++ b/hotspot/make/solaris/makefiles/gcc.make @@ -127,13 +127,7 @@ CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@)) # optimization control flags (Used by fastdebug and release variants) OPT_CFLAGS/NOOPT=-O0 -ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 8 \) \))" "1" - # Allow basic optimizations which don't distrupt debugging. (Principally dead code elimination) - OPT_CFLAGS/DEBUG=-Og -+else - # Allow no optimizations. - OPT_CFLAGS/DEBUG=-O0 -endif +OPT_CFLAGS/DEBUG=-O0 OPT_CFLAGS/SIZE=-Os OPT_CFLAGS/SPEED=-O3 @@ -229,14 +223,8 @@ SHARED_FLAG = -shared #------------------------------------------------------------------------ # Debug flags -ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 8 \) \))" "1" - # Allow basic optimizations which don't distrupt debugging. (Principally dead code elimination) - DEBUG_CFLAGS=-Og -else - # Allow no optimizations. - DEBUG_CFLAGS=-O0 -endif - +# Allow no optimizations. +DEBUG_CFLAGS=-O0 # Use the stabs format for debugging information (this is the default # on gcc-2.91). It's good enough, has all the information about line diff --git a/hotspot/src/os/aix/vm/os_aix.cpp b/hotspot/src/os/aix/vm/os_aix.cpp index e6b92b76f12..caa0ff1ccff 100644 --- a/hotspot/src/os/aix/vm/os_aix.cpp +++ b/hotspot/src/os/aix/vm/os_aix.cpp @@ -2809,12 +2809,10 @@ bool os::dont_yield() { return DontYieldALot; } -void os::yield() { +void os::naked_yield() { sched_yield(); } -os::YieldResult os::NakedYield() { sched_yield(); return os::YIELD_UNKNOWN; } - //////////////////////////////////////////////////////////////////////////////// // thread priority support @@ -3071,7 +3069,7 @@ static bool do_suspend(OSThread* osthread) { for (int n = 0; !osthread->sr.is_suspended(); n++) { for (int i = 0; i < RANDOMLY_LARGE_INTEGER2 && !osthread->sr.is_suspended(); i++) { - os::yield(); + os::naked_yield(); } // timeout, try to cancel the request @@ -3105,7 +3103,7 @@ static void do_resume(OSThread* osthread) { if (sr_notify(osthread) == 0) { for (int n = 0; n < RANDOMLY_LARGE_INTEGER && !osthread->sr.is_running(); n++) { for (int i = 0; i < 100 && !osthread->sr.is_running(); i++) { - os::yield(); + os::naked_yield(); } } } else { diff --git a/hotspot/src/os/bsd/vm/os_bsd.cpp b/hotspot/src/os/bsd/vm/os_bsd.cpp index 13b87c571fb..70dfe81e563 100644 --- a/hotspot/src/os/bsd/vm/os_bsd.cpp +++ b/hotspot/src/os/bsd/vm/os_bsd.cpp @@ -2596,12 +2596,10 @@ bool os::dont_yield() { return DontYieldALot; } -void os::yield() { +void os::naked_yield() { sched_yield(); } -os::YieldResult os::NakedYield() { sched_yield(); return os::YIELD_UNKNOWN; } - //////////////////////////////////////////////////////////////////////////////// // thread priority support @@ -4218,22 +4216,12 @@ static struct timespec* compute_abstime(struct timespec* abstime, jlong millis) return abstime; } - -// Test-and-clear _Event, always leaves _Event set to 0, returns immediately. -// Conceptually TryPark() should be equivalent to park(0). - -int os::PlatformEvent::TryPark() { - for (;;) { - const int v = _Event; - guarantee((v == 0) || (v == 1), "invariant"); - if (Atomic::cmpxchg(0, &_Event, v) == v) return v; - } -} - void os::PlatformEvent::park() { // AKA "down()" // Invariant: Only the thread associated with the Event/PlatformEvent // may call park(). // TODO: assert that _Assoc != NULL or _Assoc == Self + assert(_nParked == 0, "invariant"); + int v; for (;;) { v = _Event; @@ -4333,8 +4321,7 @@ void os::PlatformEvent::unpark() { // 1 :=> 1 // -1 :=> either 0 or 1; must signal target thread // That is, we can safely transition _Event from -1 to either - // 0 or 1. Forcing 1 is slightly more efficient for back-to-back - // unpark() calls. + // 0 or 1. // See also: "Semaphores in Plan 9" by Mullender & Cox // // Note: Forcing a transition from "-1" to "1" on an unpark() means @@ -4541,10 +4528,9 @@ void Parker::park(bool isAbsolute, jlong time) { } void Parker::unpark() { - int s, status; - status = pthread_mutex_lock(_mutex); + int status = pthread_mutex_lock(_mutex); assert(status == 0, "invariant"); - s = _counter; + const int s = _counter; _counter = 1; if (s < 1) { if (WorkAroundNPTLTimedWaitHang) { diff --git a/hotspot/src/os/bsd/vm/os_bsd.hpp b/hotspot/src/os/bsd/vm/os_bsd.hpp index 36fb913f38a..2c1ebaf5eea 100644 --- a/hotspot/src/os/bsd/vm/os_bsd.hpp +++ b/hotspot/src/os/bsd/vm/os_bsd.hpp @@ -219,7 +219,6 @@ class PlatformEvent : public CHeapObj { int fired() { return _Event; } void park(); void unpark(); - int TryPark(); int park(jlong millis); void SetAssociation(Thread * a) { _Assoc = a; } }; diff --git a/hotspot/src/os/linux/vm/os_linux.cpp b/hotspot/src/os/linux/vm/os_linux.cpp index 8b731840b1a..ca1867ce39a 100644 --- a/hotspot/src/os/linux/vm/os_linux.cpp +++ b/hotspot/src/os/linux/vm/os_linux.cpp @@ -3791,12 +3791,10 @@ bool os::dont_yield() { return DontYieldALot; } -void os::yield() { +void os::naked_yield() { sched_yield(); } -os::YieldResult os::NakedYield() { sched_yield(); return os::YIELD_UNKNOWN; } - //////////////////////////////////////////////////////////////////////////////// // thread priority support @@ -5457,22 +5455,12 @@ static struct timespec* compute_abstime(timespec* abstime, jlong millis) { return abstime; } - -// Test-and-clear _Event, always leaves _Event set to 0, returns immediately. -// Conceptually TryPark() should be equivalent to park(0). - -int os::PlatformEvent::TryPark() { - for (;;) { - const int v = _Event; - guarantee((v == 0) || (v == 1), "invariant"); - if (Atomic::cmpxchg(0, &_Event, v) == v) return v; - } -} - void os::PlatformEvent::park() { // AKA "down()" // Invariant: Only the thread associated with the Event/PlatformEvent // may call park(). // TODO: assert that _Assoc != NULL or _Assoc == Self + assert(_nParked == 0, "invariant"); + int v; for (;;) { v = _Event; @@ -5572,8 +5560,7 @@ void os::PlatformEvent::unpark() { // 1 :=> 1 // -1 :=> either 0 or 1; must signal target thread // That is, we can safely transition _Event from -1 to either - // 0 or 1. Forcing 1 is slightly more efficient for back-to-back - // unpark() calls. + // 0 or 1. // See also: "Semaphores in Plan 9" by Mullender & Cox // // Note: Forcing a transition from "-1" to "1" on an unpark() means @@ -5801,10 +5788,9 @@ void Parker::park(bool isAbsolute, jlong time) { } void Parker::unpark() { - int s, status; - status = pthread_mutex_lock(_mutex); + int status = pthread_mutex_lock(_mutex); assert(status == 0, "invariant"); - s = _counter; + const int s = _counter; _counter = 1; if (s < 1) { // thread might be parked diff --git a/hotspot/src/os/linux/vm/os_linux.hpp b/hotspot/src/os/linux/vm/os_linux.hpp index 3e287387b05..1b62f3f35ea 100644 --- a/hotspot/src/os/linux/vm/os_linux.hpp +++ b/hotspot/src/os/linux/vm/os_linux.hpp @@ -315,7 +315,6 @@ class PlatformEvent : public CHeapObj { int fired() { return _Event; } void park(); void unpark(); - int TryPark(); int park(jlong millis); // relative timed-wait only void SetAssociation(Thread * a) { _Assoc = a; } }; diff --git a/hotspot/src/os/solaris/vm/os_solaris.cpp b/hotspot/src/os/solaris/vm/os_solaris.cpp index e963aeec5ad..ce30df44a33 100644 --- a/hotspot/src/os/solaris/vm/os_solaris.cpp +++ b/hotspot/src/os/solaris/vm/os_solaris.cpp @@ -3174,20 +3174,14 @@ bool os::dont_yield() { } } -// Caveat: Solaris os::yield() causes a thread-state transition whereas -// the linux and win32 implementations do not. This should be checked. - -void os::yield() { - // Yields to all threads with same or greater priority - os::sleep(Thread::current(), 0, false); -} - // Note that yield semantics are defined by the scheduling class to which // the thread currently belongs. Typically, yield will _not yield to // other equal or higher priority threads that reside on the dispatch queues // of other CPUs. -os::YieldResult os::NakedYield() { thr_yield(); return os::YIELD_UNKNOWN; } +void os::naked_yield() { + thr_yield(); +} // Interface for setting lwp priorities. If we are using T2 libthread, // which forces the use of BoundThreads or we manually set UseBoundThreads, @@ -5441,20 +5435,11 @@ static timestruc_t* compute_abstime(timestruc_t* abstime, jlong millis) { return abstime; } -// Test-and-clear _Event, always leaves _Event set to 0, returns immediately. -// Conceptually TryPark() should be equivalent to park(0). - -int os::PlatformEvent::TryPark() { - for (;;) { - const int v = _Event; - guarantee((v == 0) || (v == 1), "invariant"); - if (Atomic::cmpxchg(0, &_Event, v) == v) return v; - } -} - void os::PlatformEvent::park() { // AKA: down() // Invariant: Only the thread associated with the Event/PlatformEvent // may call park(). + assert(_nParked == 0, "invariant"); + int v; for (;;) { v = _Event; @@ -5541,8 +5526,7 @@ void os::PlatformEvent::unpark() { // 1 :=> 1 // -1 :=> either 0 or 1; must signal target thread // That is, we can safely transition _Event from -1 to either - // 0 or 1. Forcing 1 is slightly more efficient for back-to-back - // unpark() calls. + // 0 or 1. // See also: "Semaphores in Plan 9" by Mullender & Cox // // Note: Forcing a transition from "-1" to "1" on an unpark() means @@ -5746,10 +5730,9 @@ void Parker::park(bool isAbsolute, jlong time) { } void Parker::unpark() { - int s, status; - status = os::Solaris::mutex_lock(_mutex); + int status = os::Solaris::mutex_lock(_mutex); assert(status == 0, "invariant"); - s = _counter; + const int s = _counter; _counter = 1; status = os::Solaris::mutex_unlock(_mutex); assert(status == 0, "invariant"); diff --git a/hotspot/src/os/solaris/vm/os_solaris.hpp b/hotspot/src/os/solaris/vm/os_solaris.hpp index 28d1700ca62..ab0ab85f438 100644 --- a/hotspot/src/os/solaris/vm/os_solaris.hpp +++ b/hotspot/src/os/solaris/vm/os_solaris.hpp @@ -332,7 +332,6 @@ class PlatformEvent : public CHeapObj { int fired() { return _Event; } void park(); int park(jlong millis); - int TryPark(); void unpark(); }; diff --git a/hotspot/src/os/windows/vm/os_windows.cpp b/hotspot/src/os/windows/vm/os_windows.cpp index 86d6913299c..6ea6f62e49a 100644 --- a/hotspot/src/os/windows/vm/os_windows.cpp +++ b/hotspot/src/os/windows/vm/os_windows.cpp @@ -3516,19 +3516,16 @@ void os::infinite_sleep() { typedef BOOL (WINAPI * STTSignature)(void); -os::YieldResult os::NakedYield() { +void os::naked_yield() { // Use either SwitchToThread() or Sleep(0) // Consider passing back the return value from SwitchToThread(). if (os::Kernel32Dll::SwitchToThreadAvailable()) { - return SwitchToThread() ? os::YIELD_SWITCHED : os::YIELD_NONEREADY; + SwitchToThread(); } else { Sleep(0); } - return os::YIELD_UNKNOWN; } -void os::yield() { os::NakedYield(); } - // Win32 only gives you access to seven real priorities at a time, // so we compress Java's ten down to seven. It would be better // if we dynamically adjusted relative priorities. @@ -4877,8 +4874,7 @@ void os::PlatformEvent::unpark() { // 1 :=> 1 // -1 :=> either 0 or 1; must signal target thread // That is, we can safely transition _Event from -1 to either - // 0 or 1. Forcing 1 is slightly more efficient for back-to-back - // unpark() calls. + // 0 or 1. // See also: "Semaphores in Plan 9" by Mullender & Cox // // Note: Forcing a transition from "-1" to "1" on an unpark() means diff --git a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp index 6798e615e56..4883df22da3 100644 --- a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp +++ b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp @@ -1998,7 +1998,13 @@ void GraphBuilder::invoke(Bytecodes::Code code) { if (!UseInlineCaches && is_loaded && code == Bytecodes::_invokevirtual && !target->can_be_statically_bound()) { // Find a vtable index if one is available - vtable_index = target->resolve_vtable_index(calling_klass, callee_holder); + // For arrays, callee_holder is Object. Resolving the call with + // Object would allow an illegal call to finalize() on an + // array. We use holder instead: illegal calls to finalize() won't + // be compiled as vtable calls (IC call resolution will catch the + // illegal call) and the few legal calls on array types won't be + // either. + vtable_index = target->resolve_vtable_index(calling_klass, holder); } #endif diff --git a/hotspot/src/share/vm/c1/c1_Runtime1.cpp b/hotspot/src/share/vm/c1/c1_Runtime1.cpp index b78b787fc5b..b8dd1bbfb83 100644 --- a/hotspot/src/share/vm/c1/c1_Runtime1.cpp +++ b/hotspot/src/share/vm/c1/c1_Runtime1.cpp @@ -1051,6 +1051,7 @@ JRT_ENTRY(void, Runtime1::patch_code(JavaThread* thread, Runtime1::StubID stub_i n_copy->set_data((intx) (load_klass())); } else { assert(mirror() != NULL, "klass not set"); + // Don't need a G1 pre-barrier here since we assert above that data isn't an oop. n_copy->set_data(cast_from_oop(mirror())); } diff --git a/hotspot/src/share/vm/ci/ciConstantPoolCache.cpp b/hotspot/src/share/vm/ci/ciConstantPoolCache.cpp index a277e421a32..6ceacdc5a5a 100644 --- a/hotspot/src/share/vm/ci/ciConstantPoolCache.cpp +++ b/hotspot/src/share/vm/ci/ciConstantPoolCache.cpp @@ -38,7 +38,7 @@ ciConstantPoolCache::ciConstantPoolCache(Arena* arena, int expected_size) { _elements = new (arena) GrowableArray(arena, expected_size, 0, 0); - _keys = new (arena) GrowableArray(arena, expected_size, 0, 0); + _keys = new (arena) GrowableArray(arena, expected_size, 0, 0); } // ------------------------------------------------------------------ diff --git a/hotspot/src/share/vm/ci/ciConstantPoolCache.hpp b/hotspot/src/share/vm/ci/ciConstantPoolCache.hpp index 30ebcac2079..17cf77681e0 100644 --- a/hotspot/src/share/vm/ci/ciConstantPoolCache.hpp +++ b/hotspot/src/share/vm/ci/ciConstantPoolCache.hpp @@ -35,7 +35,7 @@ // Usage note: this klass has nothing to do with ConstantPoolCache*. class ciConstantPoolCache : public ResourceObj { private: - GrowableArray* _keys; + GrowableArray* _keys; GrowableArray* _elements; int find(int index); diff --git a/hotspot/src/share/vm/ci/ciEnv.hpp b/hotspot/src/share/vm/ci/ciEnv.hpp index 65e4bb39434..ced8d895207 100644 --- a/hotspot/src/share/vm/ci/ciEnv.hpp +++ b/hotspot/src/share/vm/ci/ciEnv.hpp @@ -185,6 +185,10 @@ private: } } + void ensure_metadata_alive(ciMetadata* m) { + _factory->ensure_metadata_alive(m); + } + ciInstance* get_instance(oop o) { if (o == NULL) return NULL; return get_object(o)->as_instance(); diff --git a/hotspot/src/share/vm/ci/ciKlass.hpp b/hotspot/src/share/vm/ci/ciKlass.hpp index b28edd7adea..e4a8a71709e 100644 --- a/hotspot/src/share/vm/ci/ciKlass.hpp +++ b/hotspot/src/share/vm/ci/ciKlass.hpp @@ -43,6 +43,7 @@ class ciKlass : public ciType { friend class ciMethod; friend class ciMethodData; friend class ciObjArrayKlass; + friend class ciReceiverTypeData; private: ciSymbol* _name; diff --git a/hotspot/src/share/vm/ci/ciMethodData.cpp b/hotspot/src/share/vm/ci/ciMethodData.cpp index 9a7c405a2d8..aa157e15283 100644 --- a/hotspot/src/share/vm/ci/ciMethodData.cpp +++ b/hotspot/src/share/vm/ci/ciMethodData.cpp @@ -170,6 +170,7 @@ void ciReceiverTypeData::translate_receiver_data_from(const ProfileData* data) { Klass* k = data->as_ReceiverTypeData()->receiver(row); if (k != NULL) { ciKlass* klass = CURRENT_ENV->get_klass(k); + CURRENT_ENV->ensure_metadata_alive(klass); set_receiver(row, klass); } } @@ -191,6 +192,7 @@ void ciReturnTypeEntry::translate_type_data_from(const ReturnTypeEntry* ret) { void ciSpeculativeTrapData::translate_from(const ProfileData* data) { Method* m = data->as_SpeculativeTrapData()->method(); ciMethod* ci_m = CURRENT_ENV->get_method(m); + CURRENT_ENV->ensure_metadata_alive(ci_m); set_method(ci_m); } diff --git a/hotspot/src/share/vm/ci/ciMethodData.hpp b/hotspot/src/share/vm/ci/ciMethodData.hpp index 9b9f67c446a..ec88c5dd26c 100644 --- a/hotspot/src/share/vm/ci/ciMethodData.hpp +++ b/hotspot/src/share/vm/ci/ciMethodData.hpp @@ -70,6 +70,7 @@ protected: Klass* v = TypeEntries::valid_klass(k); if (v != NULL) { ciKlass* klass = CURRENT_ENV->get_klass(v); + CURRENT_ENV->ensure_metadata_alive(klass); return with_status(klass, k); } return with_status(NULL, k); diff --git a/hotspot/src/share/vm/ci/ciObjectFactory.cpp b/hotspot/src/share/vm/ci/ciObjectFactory.cpp index d257e8ac467..6bacf2b2f1f 100644 --- a/hotspot/src/share/vm/ci/ciObjectFactory.cpp +++ b/hotspot/src/share/vm/ci/ciObjectFactory.cpp @@ -46,6 +46,9 @@ #include "oops/oop.inline.hpp" #include "oops/oop.inline2.hpp" #include "runtime/fieldType.hpp" +#if INCLUDE_ALL_GCS +# include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp" +#endif // ciObjectFactory // @@ -374,6 +377,37 @@ ciMetadata* ciObjectFactory::create_new_object(Metadata* o) { return NULL; } +// ------------------------------------------------------------------ +// ciObjectFactory::ensure_metadata_alive +// +// Ensure that the metadata wrapped by the ciMetadata is kept alive by GC. +// This is primarily useful for metadata which is considered as weak roots +// by the GC but need to be strong roots if reachable from a current compilation. +// +void ciObjectFactory::ensure_metadata_alive(ciMetadata* m) { + ASSERT_IN_VM; // We're handling raw oops here. + +#if INCLUDE_ALL_GCS + if (!UseG1GC) { + return; + } + Klass* metadata_owner_klass; + if (m->is_klass()) { + metadata_owner_klass = m->as_klass()->get_Klass(); + } else if (m->is_method()) { + metadata_owner_klass = m->as_method()->get_Method()->constants()->pool_holder(); + } else { + fatal("Not implemented for other types of metadata"); + } + + oop metadata_holder = metadata_owner_klass->klass_holder(); + if (metadata_holder != NULL) { + G1SATBCardTableModRefBS::enqueue(metadata_holder); + } + +#endif +} + //------------------------------------------------------------------ // ciObjectFactory::get_unloaded_method // diff --git a/hotspot/src/share/vm/ci/ciObjectFactory.hpp b/hotspot/src/share/vm/ci/ciObjectFactory.hpp index c1baca0ee62..6c228e09d40 100644 --- a/hotspot/src/share/vm/ci/ciObjectFactory.hpp +++ b/hotspot/src/share/vm/ci/ciObjectFactory.hpp @@ -75,6 +75,8 @@ private: ciObject* create_new_object(oop o); ciMetadata* create_new_object(Metadata* o); + void ensure_metadata_alive(ciMetadata* m); + static bool is_equal(NonPermObject* p, oop key) { return p->object()->get_oop() == key; } diff --git a/hotspot/src/share/vm/classfile/classFileParser.cpp b/hotspot/src/share/vm/classfile/classFileParser.cpp index e58b280b07b..b0f237a2773 100644 --- a/hotspot/src/share/vm/classfile/classFileParser.cpp +++ b/hotspot/src/share/vm/classfile/classFileParser.cpp @@ -4590,8 +4590,9 @@ void ClassFileParser::check_final_method_override(instanceKlassHandle this_klass Exceptions::fthrow( THREAD_AND_LOCATION, vmSymbols::java_lang_VerifyError(), - "class %s overrides final method %s.%s", + "class %s overrides final method %s.%s%s", this_klass->external_name(), + super_m->method_holder()->external_name(), name->as_C_string(), signature->as_C_string() ); diff --git a/hotspot/src/share/vm/classfile/classLoaderData.cpp b/hotspot/src/share/vm/classfile/classLoaderData.cpp index d04c46b7dde..71bcad2b445 100644 --- a/hotspot/src/share/vm/classfile/classLoaderData.cpp +++ b/hotspot/src/share/vm/classfile/classLoaderData.cpp @@ -332,6 +332,27 @@ void ClassLoaderData::unload() { } } +#ifdef ASSERT +class AllAliveClosure : public OopClosure { + BoolObjectClosure* _is_alive_closure; + bool _found_dead; + public: + AllAliveClosure(BoolObjectClosure* is_alive_closure) : _is_alive_closure(is_alive_closure), _found_dead(false) {} + template void do_oop_work(T* p) { + T heap_oop = oopDesc::load_heap_oop(p); + if (!oopDesc::is_null(heap_oop)) { + oop obj = oopDesc::decode_heap_oop_not_null(heap_oop); + if (!_is_alive_closure->do_object_b(obj)) { + _found_dead = true; + } + } + } + void do_oop(oop* p) { do_oop_work(p); } + void do_oop(narrowOop* p) { do_oop_work(p); } + bool found_dead() { return _found_dead; } +}; +#endif + oop ClassLoaderData::keep_alive_object() const { assert(!keep_alive(), "Don't use with CLDs that are artificially kept alive"); return is_anonymous() ? _klasses->java_mirror() : class_loader(); @@ -341,7 +362,15 @@ bool ClassLoaderData::is_alive(BoolObjectClosure* is_alive_closure) const { bool alive = keep_alive() // null class loader and incomplete anonymous klasses. || is_alive_closure->do_object_b(keep_alive_object()); - assert(!alive || claimed(), "must be claimed"); +#ifdef ASSERT + if (alive) { + AllAliveClosure all_alive_closure(is_alive_closure); + KlassToOopClosure klass_closure(&all_alive_closure); + const_cast(this)->oops_do(&all_alive_closure, &klass_closure, false); + assert(!all_alive_closure.found_dead(), err_msg("Found dead oop in alive cld: " PTR_FORMAT, p2i(this))); + } +#endif + return alive; } @@ -620,9 +649,9 @@ void ClassLoaderDataGraph::keep_alive_oops_do(OopClosure* f, KlassClosure* klass void ClassLoaderDataGraph::always_strong_oops_do(OopClosure* f, KlassClosure* klass_closure, bool must_claim) { if (ClassUnloading) { - ClassLoaderDataGraph::keep_alive_oops_do(f, klass_closure, must_claim); + keep_alive_oops_do(f, klass_closure, must_claim); } else { - ClassLoaderDataGraph::oops_do(f, klass_closure, must_claim); + oops_do(f, klass_closure, must_claim); } } @@ -632,6 +661,27 @@ void ClassLoaderDataGraph::cld_do(CLDClosure* cl) { } } +void ClassLoaderDataGraph::roots_cld_do(CLDClosure* strong, CLDClosure* weak) { + for (ClassLoaderData* cld = _head; cld != NULL; cld = cld->_next) { + CLDClosure* closure = cld->keep_alive() ? strong : weak; + if (closure != NULL) { + closure->do_cld(cld); + } + } +} + +void ClassLoaderDataGraph::keep_alive_cld_do(CLDClosure* cl) { + roots_cld_do(cl, NULL); +} + +void ClassLoaderDataGraph::always_strong_cld_do(CLDClosure* cl) { + if (ClassUnloading) { + keep_alive_cld_do(cl); + } else { + cld_do(cl); + } +} + void ClassLoaderDataGraph::classes_do(KlassClosure* klass_closure) { for (ClassLoaderData* cld = _head; cld != NULL; cld = cld->next()) { cld->classes_do(klass_closure); @@ -689,6 +739,16 @@ GrowableArray* ClassLoaderDataGraph::new_clds() { return array; } +bool ClassLoaderDataGraph::unload_list_contains(const void* x) { + assert(SafepointSynchronize::is_at_safepoint(), "only safe to call at safepoint"); + for (ClassLoaderData* cld = _unloading; cld != NULL; cld = cld->next()) { + if (cld->metaspace_or_null() != NULL && cld->metaspace_or_null()->contains(x)) { + return true; + } + } + return false; +} + #ifndef PRODUCT bool ClassLoaderDataGraph::contains_loader_data(ClassLoaderData* loader_data) { for (ClassLoaderData* data = _head; data != NULL; data = data->next()) { @@ -809,6 +869,60 @@ Metaspace* ClassLoaderData::rw_metaspace() { return _rw_metaspace; } +ClassLoaderDataGraphKlassIteratorAtomic::ClassLoaderDataGraphKlassIteratorAtomic() + : _next_klass(NULL) { + ClassLoaderData* cld = ClassLoaderDataGraph::_head; + Klass* klass = NULL; + + // Find the first klass in the CLDG. + while (cld != NULL) { + klass = cld->_klasses; + if (klass != NULL) { + _next_klass = klass; + return; + } + cld = cld->next(); + } +} + +Klass* ClassLoaderDataGraphKlassIteratorAtomic::next_klass_in_cldg(Klass* klass) { + Klass* next = klass->next_link(); + if (next != NULL) { + return next; + } + + // No more klasses in the current CLD. Time to find a new CLD. + ClassLoaderData* cld = klass->class_loader_data(); + while (next == NULL) { + cld = cld->next(); + if (cld == NULL) { + break; + } + next = cld->_klasses; + } + + return next; +} + +Klass* ClassLoaderDataGraphKlassIteratorAtomic::next_klass() { + Klass* head = (Klass*)_next_klass; + + while (head != NULL) { + Klass* next = next_klass_in_cldg(head); + + Klass* old_head = (Klass*)Atomic::cmpxchg_ptr(next, &_next_klass, head); + + if (old_head == head) { + return head; // Won the CAS. + } + + head = old_head; + } + + // Nothing more for the iterator to hand out. + assert(head == NULL, err_msg("head is " PTR_FORMAT ", expected not null:", p2i(head))); + return NULL; +} ClassLoaderDataGraphMetaspaceIterator::ClassLoaderDataGraphMetaspaceIterator() { _data = ClassLoaderDataGraph::_head; diff --git a/hotspot/src/share/vm/classfile/classLoaderData.hpp b/hotspot/src/share/vm/classfile/classLoaderData.hpp index 35088a7fbbe..f9c638c4d51 100644 --- a/hotspot/src/share/vm/classfile/classLoaderData.hpp +++ b/hotspot/src/share/vm/classfile/classLoaderData.hpp @@ -31,7 +31,6 @@ #include "memory/metaspaceCounters.hpp" #include "runtime/mutex.hpp" #include "utilities/growableArray.hpp" - #if INCLUDE_TRACE # include "utilities/ticks.hpp" #endif @@ -59,6 +58,7 @@ class Metadebug; class ClassLoaderDataGraph : public AllStatic { friend class ClassLoaderData; friend class ClassLoaderDataGraphMetaspaceIterator; + friend class ClassLoaderDataGraphKlassIteratorAtomic; friend class VMStructs; private: // All CLDs (except the null CLD) can be reached by walking _head->_next->... @@ -75,10 +75,16 @@ class ClassLoaderDataGraph : public AllStatic { static ClassLoaderData* find_or_create(Handle class_loader, TRAPS); static void purge(); static void clear_claimed_marks(); + // oops do static void oops_do(OopClosure* f, KlassClosure* klass_closure, bool must_claim); - static void always_strong_oops_do(OopClosure* blk, KlassClosure* klass_closure, bool must_claim); static void keep_alive_oops_do(OopClosure* blk, KlassClosure* klass_closure, bool must_claim); + static void always_strong_oops_do(OopClosure* blk, KlassClosure* klass_closure, bool must_claim); + // cld do static void cld_do(CLDClosure* cl); + static void roots_cld_do(CLDClosure* strong, CLDClosure* weak); + static void keep_alive_cld_do(CLDClosure* cl); + static void always_strong_cld_do(CLDClosure* cl); + // klass do static void classes_do(KlassClosure* klass_closure); static void classes_do(void f(Klass* const)); static void methods_do(void f(Method*)); @@ -104,6 +110,7 @@ class ClassLoaderDataGraph : public AllStatic { static void dump() { dump_on(tty); } static void verify(); + static bool unload_list_contains(const void* x); #ifndef PRODUCT static bool contains_loader_data(ClassLoaderData* loader_data); #endif @@ -136,6 +143,7 @@ class ClassLoaderData : public CHeapObj { }; friend class ClassLoaderDataGraph; + friend class ClassLoaderDataGraphKlassIteratorAtomic; friend class ClassLoaderDataGraphMetaspaceIterator; friend class MetaDataFactory; friend class Method; @@ -195,7 +203,6 @@ class ClassLoaderData : public CHeapObj { void unload(); bool keep_alive() const { return _keep_alive; } - bool is_alive(BoolObjectClosure* is_alive_closure) const; void classes_do(void f(Klass*)); void loaded_classes_do(KlassClosure* klass_closure); void classes_do(void f(InstanceKlass*)); @@ -208,6 +215,9 @@ class ClassLoaderData : public CHeapObj { MetaWord* allocate(size_t size); public: + + bool is_alive(BoolObjectClosure* is_alive_closure) const; + // Accessors Metaspace* metaspace_or_null() const { return _metaspace; } @@ -293,6 +303,16 @@ class ClassLoaderData : public CHeapObj { void initialize_shared_metaspaces(); }; +// An iterator that distributes Klasses to parallel worker threads. +class ClassLoaderDataGraphKlassIteratorAtomic : public StackObj { + volatile Klass* _next_klass; + public: + ClassLoaderDataGraphKlassIteratorAtomic(); + Klass* next_klass(); + private: + static Klass* next_klass_in_cldg(Klass* klass); +}; + class ClassLoaderDataGraphMetaspaceIterator : public StackObj { ClassLoaderData* _data; public: diff --git a/hotspot/src/share/vm/classfile/dictionary.cpp b/hotspot/src/share/vm/classfile/dictionary.cpp index b84475a8dbb..dcb295687aa 100644 --- a/hotspot/src/share/vm/classfile/dictionary.cpp +++ b/hotspot/src/share/vm/classfile/dictionary.cpp @@ -199,6 +199,26 @@ bool Dictionary::do_unloading() { return class_was_unloaded; } +void Dictionary::roots_oops_do(OopClosure* strong, OopClosure* weak) { + // Skip the strong roots probe marking if the closures are the same. + if (strong == weak) { + oops_do(strong); + return; + } + + for (int index = 0; index < table_size(); index++) { + for (DictionaryEntry *probe = bucket(index); + probe != NULL; + probe = probe->next()) { + Klass* e = probe->klass(); + ClassLoaderData* loader_data = probe->loader_data(); + if (is_strongly_reachable(loader_data, e)) { + probe->set_strongly_reachable(); + } + } + } + _pd_cache_table->roots_oops_do(strong, weak); +} void Dictionary::always_strong_oops_do(OopClosure* blk) { // Follow all system classes and temporary placeholders in dictionary; only @@ -490,6 +510,23 @@ void ProtectionDomainCacheTable::oops_do(OopClosure* f) { } } +void ProtectionDomainCacheTable::roots_oops_do(OopClosure* strong, OopClosure* weak) { + for (int index = 0; index < table_size(); index++) { + for (ProtectionDomainCacheEntry* probe = bucket(index); + probe != NULL; + probe = probe->next()) { + if (probe->is_strongly_reachable()) { + probe->reset_strongly_reachable(); + probe->oops_do(strong); + } else { + if (weak != NULL) { + probe->oops_do(weak); + } + } + } + } +} + uint ProtectionDomainCacheTable::bucket_size() { return sizeof(ProtectionDomainCacheEntry); } diff --git a/hotspot/src/share/vm/classfile/dictionary.hpp b/hotspot/src/share/vm/classfile/dictionary.hpp index bc25c811c52..042772f45cc 100644 --- a/hotspot/src/share/vm/classfile/dictionary.hpp +++ b/hotspot/src/share/vm/classfile/dictionary.hpp @@ -89,6 +89,7 @@ public: // GC support void oops_do(OopClosure* f); void always_strong_oops_do(OopClosure* blk); + void roots_oops_do(OopClosure* strong, OopClosure* weak); void always_strong_classes_do(KlassClosure* closure); @@ -218,6 +219,7 @@ public: // GC support void oops_do(OopClosure* f); void always_strong_oops_do(OopClosure* f); + void roots_oops_do(OopClosure* strong, OopClosure* weak); static uint bucket_size(); diff --git a/hotspot/src/share/vm/classfile/javaClasses.cpp b/hotspot/src/share/vm/classfile/javaClasses.cpp index 8ada113ffaa..cd313d27757 100644 --- a/hotspot/src/share/vm/classfile/javaClasses.cpp +++ b/hotspot/src/share/vm/classfile/javaClasses.cpp @@ -1239,6 +1239,16 @@ oop java_lang_Throwable::message(Handle throwable) { } +// Return Symbol for detailed_message or NULL +Symbol* java_lang_Throwable::detail_message(oop throwable) { + PRESERVE_EXCEPTION_MARK; // Keep original exception + oop detailed_message = java_lang_Throwable::message(throwable); + if (detailed_message != NULL) { + return java_lang_String::as_symbol(detailed_message, THREAD); + } + return NULL; +} + void java_lang_Throwable::set_message(oop throwable, oop value) { throwable->obj_field_put(detailMessage_offset, value); } diff --git a/hotspot/src/share/vm/classfile/javaClasses.hpp b/hotspot/src/share/vm/classfile/javaClasses.hpp index 88b747fdcc1..aeafbfbf8b1 100644 --- a/hotspot/src/share/vm/classfile/javaClasses.hpp +++ b/hotspot/src/share/vm/classfile/javaClasses.hpp @@ -520,6 +520,7 @@ class java_lang_Throwable: AllStatic { static oop message(oop throwable); static oop message(Handle throwable); static void set_message(oop throwable, oop value); + static Symbol* detail_message(oop throwable); static void print_stack_element(outputStream *st, Handle mirror, int method, int version, int bci); static void print_stack_element(outputStream *st, methodHandle method, int bci); diff --git a/hotspot/src/share/vm/classfile/metadataOnStackMark.cpp b/hotspot/src/share/vm/classfile/metadataOnStackMark.cpp index 032c3e3fc70..d21e19bd6f8 100644 --- a/hotspot/src/share/vm/classfile/metadataOnStackMark.cpp +++ b/hotspot/src/share/vm/classfile/metadataOnStackMark.cpp @@ -47,8 +47,11 @@ MetadataOnStackMark::MetadataOnStackMark() { if (_marked_objects == NULL) { _marked_objects = new (ResourceObj::C_HEAP, mtClass) GrowableArray(1000, true); } + Threads::metadata_do(Metadata::mark_on_stack); - CodeCache::alive_nmethods_do(nmethod::mark_on_stack); + if (JvmtiExport::has_redefined_a_class()) { + CodeCache::alive_nmethods_do(nmethod::mark_on_stack); + } CompileBroker::mark_on_stack(); JvmtiCurrentBreakpoints::metadata_do(Metadata::mark_on_stack); ThreadService::metadata_do(Metadata::mark_on_stack); diff --git a/hotspot/src/share/vm/classfile/stringTable.cpp b/hotspot/src/share/vm/classfile/stringTable.cpp index 4958e5ce7ee..46f4eba59cd 100644 --- a/hotspot/src/share/vm/classfile/stringTable.cpp +++ b/hotspot/src/share/vm/classfile/stringTable.cpp @@ -37,6 +37,7 @@ #include "runtime/mutexLocker.hpp" #include "utilities/hashtable.inline.hpp" #if INCLUDE_ALL_GCS +#include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp" #include "gc_implementation/g1/g1StringDedup.hpp" #endif @@ -157,11 +158,26 @@ oop StringTable::lookup(Symbol* symbol) { return lookup(chars, length); } +// Tell the GC that this string was looked up in the StringTable. +static void ensure_string_alive(oop string) { + // A lookup in the StringTable could return an object that was previously + // considered dead. The SATB part of G1 needs to get notified about this + // potential resurrection, otherwise the marking might not find the object. +#if INCLUDE_ALL_GCS + if (UseG1GC && string != NULL) { + G1SATBCardTableModRefBS::enqueue(string); + } +#endif +} oop StringTable::lookup(jchar* name, int len) { unsigned int hash = hash_string(name, len); int index = the_table()->hash_to_index(hash); - return the_table()->lookup(index, name, len, hash); + oop string = the_table()->lookup(index, name, len, hash); + + ensure_string_alive(string); + + return string; } @@ -172,7 +188,10 @@ oop StringTable::intern(Handle string_or_null, jchar* name, oop found_string = the_table()->lookup(index, name, len, hashValue); // Found - if (found_string != NULL) return found_string; + if (found_string != NULL) { + ensure_string_alive(found_string); + return found_string; + } debug_only(StableMemoryChecker smc(name, len * sizeof(name[0]))); assert(!Universe::heap()->is_in_reserved(name), @@ -197,11 +216,17 @@ oop StringTable::intern(Handle string_or_null, jchar* name, // Grab the StringTable_lock before getting the_table() because it could // change at safepoint. - MutexLocker ml(StringTable_lock, THREAD); + oop added_or_found; + { + MutexLocker ml(StringTable_lock, THREAD); + // Otherwise, add to symbol to table + added_or_found = the_table()->basic_add(index, string, name, len, + hashValue, CHECK_NULL); + } - // Otherwise, add to symbol to table - return the_table()->basic_add(index, string, name, len, - hashValue, CHECK_NULL); + ensure_string_alive(added_or_found); + + return added_or_found; } oop StringTable::intern(Symbol* symbol, TRAPS) { diff --git a/hotspot/src/share/vm/classfile/systemDictionary.cpp b/hotspot/src/share/vm/classfile/systemDictionary.cpp index 4a6e1c3e377..3b058b5a625 100644 --- a/hotspot/src/share/vm/classfile/systemDictionary.cpp +++ b/hotspot/src/share/vm/classfile/systemDictionary.cpp @@ -1612,13 +1612,7 @@ void SystemDictionary::add_to_hierarchy(instanceKlassHandle k, TRAPS) { // system dictionary and follows the remaining classes' contents. void SystemDictionary::always_strong_oops_do(OopClosure* blk) { - blk->do_oop(&_java_system_loader); - blk->do_oop(&_system_loader_lock_obj); - - dictionary()->always_strong_oops_do(blk); - - // Visit extra methods - invoke_method_table()->oops_do(blk); + roots_oops_do(blk, NULL); } void SystemDictionary::always_strong_classes_do(KlassClosure* closure) { @@ -1685,6 +1679,17 @@ bool SystemDictionary::do_unloading(BoolObjectClosure* is_alive) { return unloading_occurred; } +void SystemDictionary::roots_oops_do(OopClosure* strong, OopClosure* weak) { + strong->do_oop(&_java_system_loader); + strong->do_oop(&_system_loader_lock_obj); + + // Adjust dictionary + dictionary()->roots_oops_do(strong, weak); + + // Visit extra methods + invoke_method_table()->oops_do(strong); +} + void SystemDictionary::oops_do(OopClosure* f) { f->do_oop(&_java_system_loader); f->do_oop(&_system_loader_lock_obj); diff --git a/hotspot/src/share/vm/classfile/systemDictionary.hpp b/hotspot/src/share/vm/classfile/systemDictionary.hpp index f26a9d8c56e..f46f67bd9b5 100644 --- a/hotspot/src/share/vm/classfile/systemDictionary.hpp +++ b/hotspot/src/share/vm/classfile/systemDictionary.hpp @@ -330,6 +330,7 @@ public: // Applies "f->do_oop" to all root oops in the system dictionary. static void oops_do(OopClosure* f); + static void roots_oops_do(OopClosure* strong, OopClosure* weak); // System loader lock static oop system_loader_lock() { return _system_loader_lock_obj; } diff --git a/hotspot/src/share/vm/code/codeCache.cpp b/hotspot/src/share/vm/code/codeCache.cpp index 8fe9efcb427..9cdc302bf78 100644 --- a/hotspot/src/share/vm/code/codeCache.cpp +++ b/hotspot/src/share/vm/code/codeCache.cpp @@ -331,6 +331,11 @@ void CodeCache::blobs_do(CodeBlobClosure* f) { // Walk the list of methods which might contain non-perm oops. void CodeCache::scavenge_root_nmethods_do(CodeBlobClosure* f) { assert_locked_or_safepoint(CodeCache_lock); + + if (UseG1GC) { + return; + } + debug_only(mark_scavenge_root_nmethods()); for (nmethod* cur = scavenge_root_nmethods(); cur != NULL; cur = cur->scavenge_root_link()) { @@ -356,6 +361,11 @@ void CodeCache::scavenge_root_nmethods_do(CodeBlobClosure* f) { void CodeCache::add_scavenge_root_nmethod(nmethod* nm) { assert_locked_or_safepoint(CodeCache_lock); + + if (UseG1GC) { + return; + } + nm->set_on_scavenge_root_list(); nm->set_scavenge_root_link(_scavenge_root_nmethods); set_scavenge_root_nmethods(nm); @@ -364,6 +374,11 @@ void CodeCache::add_scavenge_root_nmethod(nmethod* nm) { void CodeCache::drop_scavenge_root_nmethod(nmethod* nm) { assert_locked_or_safepoint(CodeCache_lock); + + if (UseG1GC) { + return; + } + print_trace("drop_scavenge_root", nm); nmethod* last = NULL; nmethod* cur = scavenge_root_nmethods(); @@ -385,6 +400,11 @@ void CodeCache::drop_scavenge_root_nmethod(nmethod* nm) { void CodeCache::prune_scavenge_root_nmethods() { assert_locked_or_safepoint(CodeCache_lock); + + if (UseG1GC) { + return; + } + debug_only(mark_scavenge_root_nmethods()); nmethod* last = NULL; @@ -417,6 +437,10 @@ void CodeCache::prune_scavenge_root_nmethods() { #ifndef PRODUCT void CodeCache::asserted_non_scavengable_nmethods_do(CodeBlobClosure* f) { + if (UseG1GC) { + return; + } + // While we are here, verify the integrity of the list. mark_scavenge_root_nmethods(); for (nmethod* cur = scavenge_root_nmethods(); cur != NULL; cur = cur->scavenge_root_link()) { @@ -457,9 +481,36 @@ void CodeCache::verify_perm_nmethods(CodeBlobClosure* f_or_null) { } #endif //PRODUCT +void CodeCache::verify_clean_inline_caches() { +#ifdef ASSERT + FOR_ALL_ALIVE_BLOBS(cb) { + if (cb->is_nmethod()) { + nmethod* nm = (nmethod*)cb; + assert(!nm->is_unloaded(), "Tautology"); + nm->verify_clean_inline_caches(); + nm->verify(); + } + } +#endif +} + +void CodeCache::verify_icholder_relocations() { +#ifdef ASSERT + // make sure that we aren't leaking icholders + int count = 0; + FOR_ALL_BLOBS(cb) { + if (cb->is_nmethod()) { + nmethod* nm = (nmethod*)cb; + count += nm->verify_icholder_relocations(); + } + } + + assert(count + InlineCacheBuffer::pending_icholder_count() + CompiledICHolder::live_not_claimed_count() == + CompiledICHolder::live_count(), "must agree"); +#endif +} void CodeCache::gc_prologue() { - assert(!nmethod::oops_do_marking_is_active(), "oops_do_marking_epilogue must be called"); } void CodeCache::gc_epilogue() { @@ -472,41 +523,15 @@ void CodeCache::gc_epilogue() { nm->cleanup_inline_caches(); } DEBUG_ONLY(nm->verify()); - nm->fix_oop_relocations(); + DEBUG_ONLY(nm->verify_oop_relocations()); } } set_needs_cache_clean(false); prune_scavenge_root_nmethods(); - assert(!nmethod::oops_do_marking_is_active(), "oops_do_marking_prologue must be called"); -#ifdef ASSERT - // make sure that we aren't leaking icholders - int count = 0; - FOR_ALL_BLOBS(cb) { - if (cb->is_nmethod()) { - RelocIterator iter((nmethod*)cb); - while(iter.next()) { - if (iter.type() == relocInfo::virtual_call_type) { - if (CompiledIC::is_icholder_call_site(iter.virtual_call_reloc())) { - CompiledIC *ic = CompiledIC_at(iter.reloc()); - if (TraceCompiledIC) { - tty->print("noticed icholder " INTPTR_FORMAT " ", p2i(ic->cached_icholder())); - ic->print(); - } - assert(ic->cached_icholder() != NULL, "must be non-NULL"); - count++; - } - } - } - } - } - - assert(count + InlineCacheBuffer::pending_icholder_count() + CompiledICHolder::live_not_claimed_count() == - CompiledICHolder::live_count(), "must agree"); -#endif + verify_icholder_relocations(); } - void CodeCache::verify_oops() { MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); VerifyOopClosure voc; diff --git a/hotspot/src/share/vm/code/codeCache.hpp b/hotspot/src/share/vm/code/codeCache.hpp index f9f656cc35a..9bd75bfd97d 100644 --- a/hotspot/src/share/vm/code/codeCache.hpp +++ b/hotspot/src/share/vm/code/codeCache.hpp @@ -134,10 +134,6 @@ class CodeCache : AllStatic { // to) any unmarked codeBlobs in the cache. Sets "marked_for_unloading" // to "true" iff some code got unloaded. static void do_unloading(BoolObjectClosure* is_alive, bool unloading_occurred); - static void oops_do(OopClosure* f) { - CodeBlobToOopClosure oopc(f, /*do_marking=*/ false); - blobs_do(&oopc); - } static void asserted_non_scavengable_nmethods_do(CodeBlobClosure* f = NULL) PRODUCT_RETURN; static void scavenge_root_nmethods_do(CodeBlobClosure* f); @@ -173,6 +169,9 @@ class CodeCache : AllStatic { static void set_needs_cache_clean(bool v) { _needs_cache_clean = v; } static void clear_inline_caches(); // clear all inline caches + static void verify_clean_inline_caches(); + static void verify_icholder_relocations(); + // Deoptimization static int mark_for_deoptimization(DepChange& changes); #ifdef HOTSWAP diff --git a/hotspot/src/share/vm/code/compiledIC.cpp b/hotspot/src/share/vm/code/compiledIC.cpp index 2ce7c3c6793..25ef072b128 100644 --- a/hotspot/src/share/vm/code/compiledIC.cpp +++ b/hotspot/src/share/vm/code/compiledIC.cpp @@ -99,13 +99,13 @@ void CompiledIC::internal_set_ic_destination(address entry_point, bool is_icstub } { - MutexLockerEx pl(Patching_lock, Mutex::_no_safepoint_check_flag); + MutexLockerEx pl(SafepointSynchronize::is_at_safepoint() ? NULL : Patching_lock, Mutex::_no_safepoint_check_flag); #ifdef ASSERT - CodeBlob* cb = CodeCache::find_blob_unsafe(_ic_call); - assert(cb != NULL && cb->is_nmethod(), "must be nmethod"); + CodeBlob* cb = CodeCache::find_blob_unsafe(_ic_call); + assert(cb != NULL && cb->is_nmethod(), "must be nmethod"); #endif - _ic_call->set_destination_mt_safe(entry_point); -} + _ic_call->set_destination_mt_safe(entry_point); + } if (is_optimized() || is_icstub) { // Optimized call sites don't have a cache value and ICStub call @@ -159,10 +159,24 @@ address CompiledIC::stub_address() const { //----------------------------------------------------------------------------- // High-level access to an inline cache. Guaranteed to be MT-safe. +void CompiledIC::initialize_from_iter(RelocIterator* iter) { + assert(iter->addr() == _ic_call->instruction_address(), "must find ic_call"); + + if (iter->type() == relocInfo::virtual_call_type) { + virtual_call_Relocation* r = iter->virtual_call_reloc(); + _is_optimized = false; + _value = nativeMovConstReg_at(r->cached_value()); + } else { + assert(iter->type() == relocInfo::opt_virtual_call_type, "must be a virtual call"); + _is_optimized = true; + _value = NULL; + } +} + CompiledIC::CompiledIC(nmethod* nm, NativeCall* call) : _ic_call(call) { - address ic_call = call->instruction_address(); + address ic_call = _ic_call->instruction_address(); assert(ic_call != NULL, "ic_call address must be set"); assert(nm != NULL, "must pass nmethod"); @@ -173,15 +187,21 @@ CompiledIC::CompiledIC(nmethod* nm, NativeCall* call) bool ret = iter.next(); assert(ret == true, "relocInfo must exist at this address"); assert(iter.addr() == ic_call, "must find ic_call"); - if (iter.type() == relocInfo::virtual_call_type) { - virtual_call_Relocation* r = iter.virtual_call_reloc(); - _is_optimized = false; - _value = nativeMovConstReg_at(r->cached_value()); - } else { - assert(iter.type() == relocInfo::opt_virtual_call_type, "must be a virtual call"); - _is_optimized = true; - _value = NULL; - } + + initialize_from_iter(&iter); +} + +CompiledIC::CompiledIC(RelocIterator* iter) + : _ic_call(nativeCall_at(iter->addr())) +{ + address ic_call = _ic_call->instruction_address(); + + nmethod* nm = iter->code(); + assert(ic_call != NULL, "ic_call address must be set"); + assert(nm != NULL, "must pass nmethod"); + assert(nm->contains(ic_call), "must be in nmethod"); + + initialize_from_iter(iter); } bool CompiledIC::set_to_megamorphic(CallInfo* call_info, Bytecodes::Code bytecode, TRAPS) { @@ -509,7 +529,7 @@ bool CompiledIC::is_icholder_entry(address entry) { void CompiledStaticCall::set_to_clean() { assert (CompiledIC_lock->is_locked() || SafepointSynchronize::is_at_safepoint(), "mt unsafe call"); // Reset call site - MutexLockerEx pl(Patching_lock, Mutex::_no_safepoint_check_flag); + MutexLockerEx pl(SafepointSynchronize::is_at_safepoint() ? NULL : Patching_lock, Mutex::_no_safepoint_check_flag); #ifdef ASSERT CodeBlob* cb = CodeCache::find_blob_unsafe(this); assert(cb != NULL && cb->is_nmethod(), "must be nmethod"); diff --git a/hotspot/src/share/vm/code/compiledIC.hpp b/hotspot/src/share/vm/code/compiledIC.hpp index ec36381b1f2..d1e9b9a2bce 100644 --- a/hotspot/src/share/vm/code/compiledIC.hpp +++ b/hotspot/src/share/vm/code/compiledIC.hpp @@ -136,6 +136,9 @@ class CompiledIC: public ResourceObj { bool _is_optimized; // an optimized virtual call (i.e., no compiled IC) CompiledIC(nmethod* nm, NativeCall* ic_call); + CompiledIC(RelocIterator* iter); + + void initialize_from_iter(RelocIterator* iter); static bool is_icholder_entry(address entry); @@ -169,6 +172,7 @@ class CompiledIC: public ResourceObj { friend CompiledIC* CompiledIC_before(nmethod* nm, address return_addr); friend CompiledIC* CompiledIC_at(nmethod* nm, address call_site); friend CompiledIC* CompiledIC_at(Relocation* call_site); + friend CompiledIC* CompiledIC_at(RelocIterator* reloc_iter); // This is used to release CompiledICHolder*s from nmethods that // are about to be freed. The callsite might contain other stale @@ -249,6 +253,13 @@ inline CompiledIC* CompiledIC_at(Relocation* call_site) { return c_ic; } +inline CompiledIC* CompiledIC_at(RelocIterator* reloc_iter) { + assert(reloc_iter->type() == relocInfo::virtual_call_type || + reloc_iter->type() == relocInfo::opt_virtual_call_type, "wrong reloc. info"); + CompiledIC* c_ic = new CompiledIC(reloc_iter); + c_ic->verify(); + return c_ic; +} //----------------------------------------------------------------------------- // The CompiledStaticCall represents a call to a static method in the compiled diff --git a/hotspot/src/share/vm/code/nmethod.cpp b/hotspot/src/share/vm/code/nmethod.cpp index 795c700fa1b..f654ffb4bc2 100644 --- a/hotspot/src/share/vm/code/nmethod.cpp +++ b/hotspot/src/share/vm/code/nmethod.cpp @@ -51,6 +51,8 @@ PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC +unsigned char nmethod::_global_unloading_clock = 0; + #ifdef DTRACE_ENABLED // Only bother with this argument setup if dtrace is available @@ -446,6 +448,7 @@ const char* nmethod::compile_kind() const { // Fill in default values for various flag fields void nmethod::init_defaults() { _state = in_use; + _unloading_clock = 0; _marked_for_reclamation = 0; _has_flushed_dependencies = 0; _has_unsafe_access = 0; @@ -464,7 +467,11 @@ void nmethod::init_defaults() { _oops_do_mark_link = NULL; _jmethod_id = NULL; _osr_link = NULL; - _scavenge_root_link = NULL; + if (UseG1GC) { + _unloading_next = NULL; + } else { + _scavenge_root_link = NULL; + } _scavenge_root_state = 0; _compiler = NULL; #if INCLUDE_RTM_OPT @@ -1146,7 +1153,7 @@ void nmethod::cleanup_inline_caches() { switch(iter.type()) { case relocInfo::virtual_call_type: case relocInfo::opt_virtual_call_type: { - CompiledIC *ic = CompiledIC_at(iter.reloc()); + CompiledIC *ic = CompiledIC_at(&iter); // Ok, to lookup references to zombies here CodeBlob *cb = CodeCache::find_blob_unsafe(ic->ic_destination()); if( cb != NULL && cb->is_nmethod() ) { @@ -1170,6 +1177,77 @@ void nmethod::cleanup_inline_caches() { } } +void nmethod::verify_clean_inline_caches() { + assert_locked_or_safepoint(CompiledIC_lock); + + // If the method is not entrant or zombie then a JMP is plastered over the + // first few bytes. If an oop in the old code was there, that oop + // should not get GC'd. Skip the first few bytes of oops on + // not-entrant methods. + address low_boundary = verified_entry_point(); + if (!is_in_use()) { + low_boundary += NativeJump::instruction_size; + // %%% Note: On SPARC we patch only a 4-byte trap, not a full NativeJump. + // This means that the low_boundary is going to be a little too high. + // This shouldn't matter, since oops of non-entrant methods are never used. + // In fact, why are we bothering to look at oops in a non-entrant method?? + } + + ResourceMark rm; + RelocIterator iter(this, low_boundary); + while(iter.next()) { + switch(iter.type()) { + case relocInfo::virtual_call_type: + case relocInfo::opt_virtual_call_type: { + CompiledIC *ic = CompiledIC_at(&iter); + // Ok, to lookup references to zombies here + CodeBlob *cb = CodeCache::find_blob_unsafe(ic->ic_destination()); + if( cb != NULL && cb->is_nmethod() ) { + nmethod* nm = (nmethod*)cb; + // Verify that inline caches pointing to both zombie and not_entrant methods are clean + if (!nm->is_in_use() || (nm->method()->code() != nm)) { + assert(ic->is_clean(), "IC should be clean"); + } + } + break; + } + case relocInfo::static_call_type: { + CompiledStaticCall *csc = compiledStaticCall_at(iter.reloc()); + CodeBlob *cb = CodeCache::find_blob_unsafe(csc->destination()); + if( cb != NULL && cb->is_nmethod() ) { + nmethod* nm = (nmethod*)cb; + // Verify that inline caches pointing to both zombie and not_entrant methods are clean + if (!nm->is_in_use() || (nm->method()->code() != nm)) { + assert(csc->is_clean(), "IC should be clean"); + } + } + break; + } + } + } +} + +int nmethod::verify_icholder_relocations() { + int count = 0; + + RelocIterator iter(this); + while(iter.next()) { + if (iter.type() == relocInfo::virtual_call_type) { + if (CompiledIC::is_icholder_call_site(iter.virtual_call_reloc())) { + CompiledIC *ic = CompiledIC_at(&iter); + if (TraceCompiledIC) { + tty->print("noticed icholder " INTPTR_FORMAT " ", p2i(ic->cached_icholder())); + ic->print(); + } + assert(ic->cached_icholder() != NULL, "must be non-NULL"); + count++; + } + } + } + + return count; +} + // This is a private interface with the sweeper. void nmethod::mark_as_seen_on_stack() { assert(is_alive(), "Must be an alive method"); @@ -1202,6 +1280,23 @@ void nmethod::inc_decompile_count() { mdo->inc_decompile_count(); } +void nmethod::increase_unloading_clock() { + _global_unloading_clock++; + if (_global_unloading_clock == 0) { + // _nmethods are allocated with _unloading_clock == 0, + // so 0 is never used as a clock value. + _global_unloading_clock = 1; + } +} + +void nmethod::set_unloading_clock(unsigned char unloading_clock) { + OrderAccess::release_store((volatile jubyte*)&_unloading_clock, unloading_clock); +} + +unsigned char nmethod::unloading_clock() { + return (unsigned char)OrderAccess::load_acquire((volatile jubyte*)&_unloading_clock); +} + void nmethod::make_unloaded(BoolObjectClosure* is_alive, oop cause) { post_compiled_method_unload(); @@ -1247,6 +1342,10 @@ void nmethod::make_unloaded(BoolObjectClosure* is_alive, oop cause) { // for later on. CodeCache::set_needs_cache_clean(true); } + + // Unregister must be done before the state change + Universe::heap()->unregister_nmethod(this); + _state = unloaded; // Log the unloading. @@ -1590,6 +1689,35 @@ void nmethod::post_compiled_method_unload() { set_unload_reported(); } +void static clean_ic_if_metadata_is_dead(CompiledIC *ic, BoolObjectClosure *is_alive) { + if (ic->is_icholder_call()) { + // The only exception is compiledICHolder oops which may + // yet be marked below. (We check this further below). + CompiledICHolder* cichk_oop = ic->cached_icholder(); + if (cichk_oop->holder_method()->method_holder()->is_loader_alive(is_alive) && + cichk_oop->holder_klass()->is_loader_alive(is_alive)) { + return; + } + } else { + Metadata* ic_oop = ic->cached_metadata(); + if (ic_oop != NULL) { + if (ic_oop->is_klass()) { + if (((Klass*)ic_oop)->is_loader_alive(is_alive)) { + return; + } + } else if (ic_oop->is_method()) { + if (((Method*)ic_oop)->method_holder()->is_loader_alive(is_alive)) { + return; + } + } else { + ShouldNotReachHere(); + } + } + } + + ic->set_to_clean(); +} + // This is called at the end of the strong tracing/marking phase of a // GC to unload an nmethod if it contains otherwise unreachable // oops. @@ -1632,32 +1760,8 @@ void nmethod::do_unloading(BoolObjectClosure* is_alive, bool unloading_occurred) RelocIterator iter(this, low_boundary); while(iter.next()) { if (iter.type() == relocInfo::virtual_call_type) { - CompiledIC *ic = CompiledIC_at(iter.reloc()); - if (ic->is_icholder_call()) { - // The only exception is compiledICHolder oops which may - // yet be marked below. (We check this further below). - CompiledICHolder* cichk_oop = ic->cached_icholder(); - if (cichk_oop->holder_method()->method_holder()->is_loader_alive(is_alive) && - cichk_oop->holder_klass()->is_loader_alive(is_alive)) { - continue; - } - } else { - Metadata* ic_oop = ic->cached_metadata(); - if (ic_oop != NULL) { - if (ic_oop->is_klass()) { - if (((Klass*)ic_oop)->is_loader_alive(is_alive)) { - continue; - } - } else if (ic_oop->is_method()) { - if (((Method*)ic_oop)->method_holder()->is_loader_alive(is_alive)) { - continue; - } - } else { - ShouldNotReachHere(); - } - } - } - ic->set_to_clean(); + CompiledIC *ic = CompiledIC_at(&iter); + clean_ic_if_metadata_is_dead(ic, is_alive); } } } @@ -1695,6 +1799,175 @@ void nmethod::do_unloading(BoolObjectClosure* is_alive, bool unloading_occurred) verify_metadata_loaders(low_boundary, is_alive); } +template +static bool clean_if_nmethod_is_unloaded(CompiledICorStaticCall *ic, address addr, BoolObjectClosure *is_alive, nmethod* from) { + // Ok, to lookup references to zombies here + CodeBlob *cb = CodeCache::find_blob_unsafe(addr); + if (cb != NULL && cb->is_nmethod()) { + nmethod* nm = (nmethod*)cb; + + if (nm->unloading_clock() != nmethod::global_unloading_clock()) { + // The nmethod has not been processed yet. + return true; + } + + // Clean inline caches pointing to both zombie and not_entrant methods + if (!nm->is_in_use() || (nm->method()->code() != nm)) { + ic->set_to_clean(); + assert(ic->is_clean(), err_msg("nmethod " PTR_FORMAT "not clean %s", from, from->method()->name_and_sig_as_C_string())); + } + } + + return false; +} + +static bool clean_if_nmethod_is_unloaded(CompiledIC *ic, BoolObjectClosure *is_alive, nmethod* from) { + return clean_if_nmethod_is_unloaded(ic, ic->ic_destination(), is_alive, from); +} + +static bool clean_if_nmethod_is_unloaded(CompiledStaticCall *csc, BoolObjectClosure *is_alive, nmethod* from) { + return clean_if_nmethod_is_unloaded(csc, csc->destination(), is_alive, from); +} + +bool nmethod::do_unloading_parallel(BoolObjectClosure* is_alive, bool unloading_occurred) { + ResourceMark rm; + + // Make sure the oop's ready to receive visitors + assert(!is_zombie() && !is_unloaded(), + "should not call follow on zombie or unloaded nmethod"); + + // If the method is not entrant then a JMP is plastered over the + // first few bytes. If an oop in the old code was there, that oop + // should not get GC'd. Skip the first few bytes of oops on + // not-entrant methods. + address low_boundary = verified_entry_point(); + if (is_not_entrant()) { + low_boundary += NativeJump::instruction_size; + // %%% Note: On SPARC we patch only a 4-byte trap, not a full NativeJump. + // (See comment above.) + } + + // The RedefineClasses() API can cause the class unloading invariant + // to no longer be true. See jvmtiExport.hpp for details. + // Also, leave a debugging breadcrumb in local flag. + bool a_class_was_redefined = JvmtiExport::has_redefined_a_class(); + if (a_class_was_redefined) { + // This set of the unloading_occurred flag is done before the + // call to post_compiled_method_unload() so that the unloading + // of this nmethod is reported. + unloading_occurred = true; + } + + // Exception cache + clean_exception_cache(is_alive); + + bool is_unloaded = false; + bool postponed = false; + + RelocIterator iter(this, low_boundary); + while(iter.next()) { + + switch (iter.type()) { + + case relocInfo::virtual_call_type: + if (unloading_occurred) { + // If class unloading occurred we first iterate over all inline caches and + // clear ICs where the cached oop is referring to an unloaded klass or method. + clean_ic_if_metadata_is_dead(CompiledIC_at(&iter), is_alive); + } + + postponed |= clean_if_nmethod_is_unloaded(CompiledIC_at(&iter), is_alive, this); + break; + + case relocInfo::opt_virtual_call_type: + postponed |= clean_if_nmethod_is_unloaded(CompiledIC_at(&iter), is_alive, this); + break; + + case relocInfo::static_call_type: + postponed |= clean_if_nmethod_is_unloaded(compiledStaticCall_at(iter.reloc()), is_alive, this); + break; + + case relocInfo::oop_type: + if (!is_unloaded) { + // Unload check + oop_Relocation* r = iter.oop_reloc(); + // Traverse those oops directly embedded in the code. + // Other oops (oop_index>0) are seen as part of scopes_oops. + assert(1 == (r->oop_is_immediate()) + + (r->oop_addr() >= oops_begin() && r->oop_addr() < oops_end()), + "oop must be found in exactly one place"); + if (r->oop_is_immediate() && r->oop_value() != NULL) { + if (can_unload(is_alive, r->oop_addr(), unloading_occurred)) { + is_unloaded = true; + } + } + } + break; + + } + } + + if (is_unloaded) { + return postponed; + } + + // Scopes + for (oop* p = oops_begin(); p < oops_end(); p++) { + if (*p == Universe::non_oop_word()) continue; // skip non-oops + if (can_unload(is_alive, p, unloading_occurred)) { + is_unloaded = true; + break; + } + } + + if (is_unloaded) { + return postponed; + } + + // Ensure that all metadata is still alive + verify_metadata_loaders(low_boundary, is_alive); + + return postponed; +} + +void nmethod::do_unloading_parallel_postponed(BoolObjectClosure* is_alive, bool unloading_occurred) { + ResourceMark rm; + + // Make sure the oop's ready to receive visitors + assert(!is_zombie(), + "should not call follow on zombie nmethod"); + + // If the method is not entrant then a JMP is plastered over the + // first few bytes. If an oop in the old code was there, that oop + // should not get GC'd. Skip the first few bytes of oops on + // not-entrant methods. + address low_boundary = verified_entry_point(); + if (is_not_entrant()) { + low_boundary += NativeJump::instruction_size; + // %%% Note: On SPARC we patch only a 4-byte trap, not a full NativeJump. + // (See comment above.) + } + + RelocIterator iter(this, low_boundary); + while(iter.next()) { + + switch (iter.type()) { + + case relocInfo::virtual_call_type: + clean_if_nmethod_is_unloaded(CompiledIC_at(&iter), is_alive, this); + break; + + case relocInfo::opt_virtual_call_type: + clean_if_nmethod_is_unloaded(CompiledIC_at(&iter), is_alive, this); + break; + + case relocInfo::static_call_type: + clean_if_nmethod_is_unloaded(compiledStaticCall_at(iter.reloc()), is_alive, this); + break; + } + } +} + #ifdef ASSERT class CheckClass : AllStatic { @@ -1741,7 +2014,7 @@ void nmethod::verify_metadata_loaders(address low_boundary, BoolObjectClosure* i // compiled code is maintaining a link to dead metadata. address static_call_addr = NULL; if (iter.type() == relocInfo::opt_virtual_call_type) { - CompiledIC* cic = CompiledIC_at(iter.reloc()); + CompiledIC* cic = CompiledIC_at(&iter); if (!cic->is_call_to_interpreted()) { static_call_addr = iter.addr(); } @@ -1793,7 +2066,7 @@ void nmethod::metadata_do(void f(Metadata*)) { } } else if (iter.type() == relocInfo::virtual_call_type) { // Check compiledIC holders associated with this nmethod - CompiledIC *ic = CompiledIC_at(iter.reloc()); + CompiledIC *ic = CompiledIC_at(&iter); if (ic->is_icholder_call()) { CompiledICHolder* cichk = ic->cached_icholder(); f(cichk->holder_method()); @@ -1911,7 +2184,7 @@ void nmethod::oops_do_marking_epilogue() { assert(cur != NULL, "not NULL-terminated"); nmethod* next = cur->_oops_do_mark_link; cur->_oops_do_mark_link = NULL; - cur->fix_oop_relocations(); + cur->verify_oop_relocations(); NOT_PRODUCT(if (TraceScavenge) cur->print_on(tty, "oops_do, unmark")); cur = next; } @@ -2479,6 +2752,10 @@ public: }; void nmethod::verify_scavenge_root_oops() { + if (UseG1GC) { + return; + } + if (!on_scavenge_root_list()) { // Actually look inside, to verify the claim that it's clean. DebugScavengeRoot debug_scavenge_root(this); @@ -2922,7 +3199,7 @@ void nmethod::print_calls(outputStream* st) { case relocInfo::virtual_call_type: case relocInfo::opt_virtual_call_type: { VerifyMutexLocker mc(CompiledIC_lock); - CompiledIC_at(iter.reloc())->print(); + CompiledIC_at(&iter)->print(); break; } case relocInfo::static_call_type: diff --git a/hotspot/src/share/vm/code/nmethod.hpp b/hotspot/src/share/vm/code/nmethod.hpp index 5ffbde6ad70..5ea2ca8891d 100644 --- a/hotspot/src/share/vm/code/nmethod.hpp +++ b/hotspot/src/share/vm/code/nmethod.hpp @@ -111,6 +111,11 @@ class nmethod : public CodeBlob { friend class NMethodSweeper; friend class CodeCache; // scavengable oops private: + + // GC support to help figure out if an nmethod has been + // cleaned/unloaded by the current GC. + static unsigned char _global_unloading_clock; + // Shared fields for all nmethod's Method* _method; int _entry_bci; // != InvocationEntryBci if this nmethod is an on-stack replacement method @@ -118,7 +123,13 @@ class nmethod : public CodeBlob { // To support simple linked-list chaining of nmethods: nmethod* _osr_link; // from InstanceKlass::osr_nmethods_head - nmethod* _scavenge_root_link; // from CodeCache::scavenge_root_nmethods + + union { + // Used by G1 to chain nmethods. + nmethod* _unloading_next; + // Used by non-G1 GCs to chain nmethods. + nmethod* _scavenge_root_link; // from CodeCache::scavenge_root_nmethods + }; static nmethod* volatile _oops_do_mark_nmethods; nmethod* volatile _oops_do_mark_link; @@ -180,6 +191,8 @@ class nmethod : public CodeBlob { // Protected by Patching_lock volatile unsigned char _state; // {alive, not_entrant, zombie, unloaded} + volatile unsigned char _unloading_clock; // Incremented after GC unloaded/cleaned the nmethod + #ifdef ASSERT bool _oops_are_stale; // indicates that it's no longer safe to access oops section #endif @@ -437,6 +450,15 @@ class nmethod : public CodeBlob { bool unload_reported() { return _unload_reported; } void set_unload_reported() { _unload_reported = true; } + void set_unloading_next(nmethod* next) { _unloading_next = next; } + nmethod* unloading_next() { return _unloading_next; } + + static unsigned char global_unloading_clock() { return _global_unloading_clock; } + static void increase_unloading_clock(); + + void set_unloading_clock(unsigned char unloading_clock); + unsigned char unloading_clock(); + bool is_marked_for_deoptimization() const { return _marked_for_deoptimization; } void mark_for_deoptimization() { _marked_for_deoptimization = true; } @@ -552,6 +574,10 @@ public: return (addr >= code_begin() && addr < verified_entry_point()); } + // Verify calls to dead methods have been cleaned. + void verify_clean_inline_caches(); + // Verify and count cached icholder relocations. + int verify_icholder_relocations(); // Check that all metadata is still alive void verify_metadata_loaders(address low_boundary, BoolObjectClosure* is_alive); @@ -577,6 +603,10 @@ public: // GC support void do_unloading(BoolObjectClosure* is_alive, bool unloading_occurred); + // The parallel versions are used by G1. + bool do_unloading_parallel(BoolObjectClosure* is_alive, bool unloading_occurred); + void do_unloading_parallel_postponed(BoolObjectClosure* is_alive, bool unloading_occurred); + // Unload a nmethod if the *root object is dead. bool can_unload(BoolObjectClosure* is_alive, oop* root, bool unloading_occurred); void preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map, diff --git a/hotspot/src/share/vm/code/vtableStubs.cpp b/hotspot/src/share/vm/code/vtableStubs.cpp index ac99da40e1c..07a1083518f 100644 --- a/hotspot/src/share/vm/code/vtableStubs.cpp +++ b/hotspot/src/share/vm/code/vtableStubs.cpp @@ -24,6 +24,7 @@ #include "precompiled.hpp" #include "code/vtableStubs.hpp" +#include "compiler/compileBroker.hpp" #include "compiler/disassembler.hpp" #include "memory/allocation.inline.hpp" #include "memory/resourceArea.hpp" @@ -62,6 +63,7 @@ void* VtableStub::operator new(size_t size, int code_size) throw() { // If changing the name, update the other file accordingly. BufferBlob* blob = BufferBlob::create("vtable chunks", bytes); if (blob == NULL) { + CompileBroker::handle_full_code_cache(); return NULL; } _chunk = blob->content_begin(); diff --git a/hotspot/src/share/vm/compiler/compileBroker.cpp b/hotspot/src/share/vm/compiler/compileBroker.cpp index b97a554192d..b328fdd90b4 100644 --- a/hotspot/src/share/vm/compiler/compileBroker.cpp +++ b/hotspot/src/share/vm/compiler/compileBroker.cpp @@ -1048,7 +1048,7 @@ CompilerThread* CompileBroker::make_compiler_thread(const char* name, CompileQue } // Let go of Threads_lock before yielding - os::yield(); // make sure that the compiler thread is started early (especially helpful on SOLARIS) + os::naked_yield(); // make sure that the compiler thread is started early (especially helpful on SOLARIS) return compiler_thread; } diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsAdaptiveSizePolicy.cpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsAdaptiveSizePolicy.cpp deleted file mode 100644 index 3882916e472..00000000000 --- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsAdaptiveSizePolicy.cpp +++ /dev/null @@ -1,1340 +0,0 @@ -/* - * Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#include "precompiled.hpp" -#include "gc_implementation/concurrentMarkSweep/cmsAdaptiveSizePolicy.hpp" -#include "gc_implementation/shared/gcStats.hpp" -#include "memory/defNewGeneration.hpp" -#include "memory/genCollectedHeap.hpp" -#include "runtime/thread.hpp" - -elapsedTimer CMSAdaptiveSizePolicy::_concurrent_timer; -elapsedTimer CMSAdaptiveSizePolicy::_STW_timer; - -// Defined if the granularity of the time measurements is potentially too large. -#define CLOCK_GRANULARITY_TOO_LARGE - -CMSAdaptiveSizePolicy::CMSAdaptiveSizePolicy(size_t init_eden_size, - size_t init_promo_size, - size_t init_survivor_size, - double max_gc_minor_pause_sec, - double max_gc_pause_sec, - uint gc_cost_ratio) : - AdaptiveSizePolicy(init_eden_size, - init_promo_size, - init_survivor_size, - max_gc_pause_sec, - gc_cost_ratio) { - - clear_internal_time_intervals(); - - _processor_count = os::active_processor_count(); - - if (CMSConcurrentMTEnabled && (ConcGCThreads > 1)) { - assert(_processor_count > 0, "Processor count is suspect"); - _concurrent_processor_count = MIN2((uint) ConcGCThreads, - (uint) _processor_count); - } else { - _concurrent_processor_count = 1; - } - - _avg_concurrent_time = new AdaptiveWeightedAverage(AdaptiveTimeWeight); - _avg_concurrent_interval = new AdaptiveWeightedAverage(AdaptiveTimeWeight); - _avg_concurrent_gc_cost = new AdaptiveWeightedAverage(AdaptiveTimeWeight); - - _avg_initial_pause = new AdaptivePaddedAverage(AdaptiveTimeWeight, - PausePadding); - _avg_remark_pause = new AdaptivePaddedAverage(AdaptiveTimeWeight, - PausePadding); - - _avg_cms_STW_time = new AdaptiveWeightedAverage(AdaptiveTimeWeight); - _avg_cms_STW_gc_cost = new AdaptiveWeightedAverage(AdaptiveTimeWeight); - - _avg_cms_free = new AdaptiveWeightedAverage(AdaptiveTimeWeight); - _avg_cms_free_at_sweep = new AdaptiveWeightedAverage(AdaptiveTimeWeight); - _avg_cms_promo = new AdaptiveWeightedAverage(AdaptiveTimeWeight); - - // Mark-sweep-compact - _avg_msc_pause = new AdaptiveWeightedAverage(AdaptiveTimeWeight); - _avg_msc_interval = new AdaptiveWeightedAverage(AdaptiveTimeWeight); - _avg_msc_gc_cost = new AdaptiveWeightedAverage(AdaptiveTimeWeight); - - // Mark-sweep - _avg_ms_pause = new AdaptiveWeightedAverage(AdaptiveTimeWeight); - _avg_ms_interval = new AdaptiveWeightedAverage(AdaptiveTimeWeight); - _avg_ms_gc_cost = new AdaptiveWeightedAverage(AdaptiveTimeWeight); - - // Variables that estimate pause times as a function of generation - // size. - _remark_pause_old_estimator = - new LinearLeastSquareFit(AdaptiveSizePolicyWeight); - _initial_pause_old_estimator = - new LinearLeastSquareFit(AdaptiveSizePolicyWeight); - _remark_pause_young_estimator = - new LinearLeastSquareFit(AdaptiveSizePolicyWeight); - _initial_pause_young_estimator = - new LinearLeastSquareFit(AdaptiveSizePolicyWeight); - - // Alignment comes from that used in ReservedSpace. - _generation_alignment = os::vm_allocation_granularity(); - - // Start the concurrent timer here so that the first - // concurrent_phases_begin() measures a finite mutator - // time. A finite mutator time is used to determine - // if a concurrent collection has been started. If this - // proves to be a problem, use some explicit flag to - // signal that a concurrent collection has been started. - _concurrent_timer.start(); - _STW_timer.start(); -} - -double CMSAdaptiveSizePolicy::concurrent_processor_fraction() { - // For now assume no other daemon threads are taking alway - // cpu's from the application. - return ((double) _concurrent_processor_count / (double) _processor_count); -} - -double CMSAdaptiveSizePolicy::concurrent_collection_cost( - double interval_in_seconds) { - // When the precleaning and sweeping phases use multiple - // threads, change one_processor_fraction to - // concurrent_processor_fraction(). - double one_processor_fraction = 1.0 / ((double) processor_count()); - double concurrent_cost = - collection_cost(_latest_cms_concurrent_marking_time_secs, - interval_in_seconds) * concurrent_processor_fraction() + - collection_cost(_latest_cms_concurrent_precleaning_time_secs, - interval_in_seconds) * one_processor_fraction + - collection_cost(_latest_cms_concurrent_sweeping_time_secs, - interval_in_seconds) * one_processor_fraction; - if (PrintAdaptiveSizePolicy && Verbose) { - gclog_or_tty->print_cr( - "\nCMSAdaptiveSizePolicy::scaled_concurrent_collection_cost(%f) " - "_latest_cms_concurrent_marking_cost %f " - "_latest_cms_concurrent_precleaning_cost %f " - "_latest_cms_concurrent_sweeping_cost %f " - "concurrent_processor_fraction %f " - "concurrent_cost %f ", - interval_in_seconds, - collection_cost(_latest_cms_concurrent_marking_time_secs, - interval_in_seconds), - collection_cost(_latest_cms_concurrent_precleaning_time_secs, - interval_in_seconds), - collection_cost(_latest_cms_concurrent_sweeping_time_secs, - interval_in_seconds), - concurrent_processor_fraction(), - concurrent_cost); - } - return concurrent_cost; -} - -double CMSAdaptiveSizePolicy::concurrent_collection_time() { - double latest_cms_sum_concurrent_phases_time_secs = - _latest_cms_concurrent_marking_time_secs + - _latest_cms_concurrent_precleaning_time_secs + - _latest_cms_concurrent_sweeping_time_secs; - return latest_cms_sum_concurrent_phases_time_secs; -} - -double CMSAdaptiveSizePolicy::scaled_concurrent_collection_time() { - // When the precleaning and sweeping phases use multiple - // threads, change one_processor_fraction to - // concurrent_processor_fraction(). - double one_processor_fraction = 1.0 / ((double) processor_count()); - double latest_cms_sum_concurrent_phases_time_secs = - _latest_cms_concurrent_marking_time_secs * concurrent_processor_fraction() + - _latest_cms_concurrent_precleaning_time_secs * one_processor_fraction + - _latest_cms_concurrent_sweeping_time_secs * one_processor_fraction ; - if (PrintAdaptiveSizePolicy && Verbose) { - gclog_or_tty->print_cr( - "\nCMSAdaptiveSizePolicy::scaled_concurrent_collection_time " - "_latest_cms_concurrent_marking_time_secs %f " - "_latest_cms_concurrent_precleaning_time_secs %f " - "_latest_cms_concurrent_sweeping_time_secs %f " - "concurrent_processor_fraction %f " - "latest_cms_sum_concurrent_phases_time_secs %f ", - _latest_cms_concurrent_marking_time_secs, - _latest_cms_concurrent_precleaning_time_secs, - _latest_cms_concurrent_sweeping_time_secs, - concurrent_processor_fraction(), - latest_cms_sum_concurrent_phases_time_secs); - } - return latest_cms_sum_concurrent_phases_time_secs; -} - -void CMSAdaptiveSizePolicy::update_minor_pause_old_estimator( - double minor_pause_in_ms) { - // Get the equivalent of the free space - // that is available for promotions in the CMS generation - // and use that to update _minor_pause_old_estimator - - // Don't implement this until it is needed. A warning is - // printed if _minor_pause_old_estimator is used. -} - -void CMSAdaptiveSizePolicy::concurrent_marking_begin() { - if (PrintAdaptiveSizePolicy && Verbose) { - gclog_or_tty->print(" "); - gclog_or_tty->stamp(); - gclog_or_tty->print(": concurrent_marking_begin "); - } - // Update the interval time - _concurrent_timer.stop(); - _latest_cms_collection_end_to_collection_start_secs = _concurrent_timer.seconds(); - if (PrintAdaptiveSizePolicy && Verbose) { - gclog_or_tty->print_cr("CMSAdaptiveSizePolicy::concurrent_marking_begin: " - "mutator time %f", _latest_cms_collection_end_to_collection_start_secs); - } - _concurrent_timer.reset(); - _concurrent_timer.start(); -} - -void CMSAdaptiveSizePolicy::concurrent_marking_end() { - if (PrintAdaptiveSizePolicy && Verbose) { - gclog_or_tty->stamp(); - gclog_or_tty->print_cr("CMSAdaptiveSizePolicy::concurrent_marking_end()"); - } - - _concurrent_timer.stop(); - _latest_cms_concurrent_marking_time_secs = _concurrent_timer.seconds(); - - if (PrintAdaptiveSizePolicy && Verbose) { - gclog_or_tty->print_cr("\n CMSAdaptiveSizePolicy::concurrent_marking_end" - ":concurrent marking time (s) %f", - _latest_cms_concurrent_marking_time_secs); - } -} - -void CMSAdaptiveSizePolicy::concurrent_precleaning_begin() { - if (PrintAdaptiveSizePolicy && Verbose) { - gclog_or_tty->stamp(); - gclog_or_tty->print_cr( - "CMSAdaptiveSizePolicy::concurrent_precleaning_begin()"); - } - _concurrent_timer.reset(); - _concurrent_timer.start(); -} - - -void CMSAdaptiveSizePolicy::concurrent_precleaning_end() { - if (PrintAdaptiveSizePolicy && Verbose) { - gclog_or_tty->stamp(); - gclog_or_tty->print_cr("CMSAdaptiveSizePolicy::concurrent_precleaning_end()"); - } - - _concurrent_timer.stop(); - // May be set again by a second call during the same collection. - _latest_cms_concurrent_precleaning_time_secs = _concurrent_timer.seconds(); - - if (PrintAdaptiveSizePolicy && Verbose) { - gclog_or_tty->print_cr("\n CMSAdaptiveSizePolicy::concurrent_precleaning_end" - ":concurrent precleaning time (s) %f", - _latest_cms_concurrent_precleaning_time_secs); - } -} - -void CMSAdaptiveSizePolicy::concurrent_sweeping_begin() { - if (PrintAdaptiveSizePolicy && Verbose) { - gclog_or_tty->stamp(); - gclog_or_tty->print_cr( - "CMSAdaptiveSizePolicy::concurrent_sweeping_begin()"); - } - _concurrent_timer.reset(); - _concurrent_timer.start(); -} - - -void CMSAdaptiveSizePolicy::concurrent_sweeping_end() { - if (PrintAdaptiveSizePolicy && Verbose) { - gclog_or_tty->stamp(); - gclog_or_tty->print_cr("CMSAdaptiveSizePolicy::concurrent_sweeping_end()"); - } - - _concurrent_timer.stop(); - _latest_cms_concurrent_sweeping_time_secs = _concurrent_timer.seconds(); - - if (PrintAdaptiveSizePolicy && Verbose) { - gclog_or_tty->print_cr("\n CMSAdaptiveSizePolicy::concurrent_sweeping_end" - ":concurrent sweeping time (s) %f", - _latest_cms_concurrent_sweeping_time_secs); - } -} - -void CMSAdaptiveSizePolicy::concurrent_phases_end(GCCause::Cause gc_cause, - size_t cur_eden, - size_t cur_promo) { - if (PrintAdaptiveSizePolicy && Verbose) { - gclog_or_tty->print(" "); - gclog_or_tty->stamp(); - gclog_or_tty->print(": concurrent_phases_end "); - } - - // Update the concurrent timer - _concurrent_timer.stop(); - - if (gc_cause != GCCause::_java_lang_system_gc || - UseAdaptiveSizePolicyWithSystemGC) { - - avg_cms_free()->sample(cur_promo); - double latest_cms_sum_concurrent_phases_time_secs = - concurrent_collection_time(); - - _avg_concurrent_time->sample(latest_cms_sum_concurrent_phases_time_secs); - - // Cost of collection (unit-less) - - // Total interval for collection. May not be valid. Tests - // below determine whether to use this. - // - if (PrintAdaptiveSizePolicy && Verbose) { - gclog_or_tty->print_cr("\nCMSAdaptiveSizePolicy::concurrent_phases_end \n" - "_latest_cms_reset_end_to_initial_mark_start_secs %f \n" - "_latest_cms_initial_mark_start_to_end_time_secs %f \n" - "_latest_cms_remark_start_to_end_time_secs %f \n" - "_latest_cms_concurrent_marking_time_secs %f \n" - "_latest_cms_concurrent_precleaning_time_secs %f \n" - "_latest_cms_concurrent_sweeping_time_secs %f \n" - "latest_cms_sum_concurrent_phases_time_secs %f \n" - "_latest_cms_collection_end_to_collection_start_secs %f \n" - "concurrent_processor_fraction %f", - _latest_cms_reset_end_to_initial_mark_start_secs, - _latest_cms_initial_mark_start_to_end_time_secs, - _latest_cms_remark_start_to_end_time_secs, - _latest_cms_concurrent_marking_time_secs, - _latest_cms_concurrent_precleaning_time_secs, - _latest_cms_concurrent_sweeping_time_secs, - latest_cms_sum_concurrent_phases_time_secs, - _latest_cms_collection_end_to_collection_start_secs, - concurrent_processor_fraction()); - } - double interval_in_seconds = - _latest_cms_initial_mark_start_to_end_time_secs + - _latest_cms_remark_start_to_end_time_secs + - latest_cms_sum_concurrent_phases_time_secs + - _latest_cms_collection_end_to_collection_start_secs; - assert(interval_in_seconds >= 0.0, - "Bad interval between cms collections"); - - // Sample for performance counter - avg_concurrent_interval()->sample(interval_in_seconds); - - // STW costs (initial and remark pauses) - // Cost of collection (unit-less) - assert(_latest_cms_initial_mark_start_to_end_time_secs >= 0.0, - "Bad initial mark pause"); - assert(_latest_cms_remark_start_to_end_time_secs >= 0.0, - "Bad remark pause"); - double STW_time_in_seconds = - _latest_cms_initial_mark_start_to_end_time_secs + - _latest_cms_remark_start_to_end_time_secs; - double STW_collection_cost = 0.0; - if (interval_in_seconds > 0.0) { - // cost for the STW phases of the concurrent collection. - STW_collection_cost = STW_time_in_seconds / interval_in_seconds; - avg_cms_STW_gc_cost()->sample(STW_collection_cost); - } - if (PrintAdaptiveSizePolicy && Verbose) { - gclog_or_tty->print("cmsAdaptiveSizePolicy::STW_collection_end: " - "STW gc cost: %f average: %f", STW_collection_cost, - avg_cms_STW_gc_cost()->average()); - gclog_or_tty->print_cr(" STW pause: %f (ms) STW period %f (ms)", - (double) STW_time_in_seconds * MILLIUNITS, - (double) interval_in_seconds * MILLIUNITS); - } - - double concurrent_cost = 0.0; - if (latest_cms_sum_concurrent_phases_time_secs > 0.0) { - concurrent_cost = concurrent_collection_cost(interval_in_seconds); - - avg_concurrent_gc_cost()->sample(concurrent_cost); - // Average this ms cost into all the other types gc costs - - if (PrintAdaptiveSizePolicy && Verbose) { - gclog_or_tty->print("cmsAdaptiveSizePolicy::concurrent_phases_end: " - "concurrent gc cost: %f average: %f", - concurrent_cost, - _avg_concurrent_gc_cost->average()); - gclog_or_tty->print_cr(" concurrent time: %f (ms) cms period %f (ms)" - " processor fraction: %f", - latest_cms_sum_concurrent_phases_time_secs * MILLIUNITS, - interval_in_seconds * MILLIUNITS, - concurrent_processor_fraction()); - } - } - double total_collection_cost = STW_collection_cost + concurrent_cost; - avg_major_gc_cost()->sample(total_collection_cost); - - // Gather information for estimating future behavior - double initial_pause_in_ms = _latest_cms_initial_mark_start_to_end_time_secs * MILLIUNITS; - double remark_pause_in_ms = _latest_cms_remark_start_to_end_time_secs * MILLIUNITS; - - double cur_promo_size_in_mbytes = ((double)cur_promo)/((double)M); - initial_pause_old_estimator()->update(cur_promo_size_in_mbytes, - initial_pause_in_ms); - remark_pause_old_estimator()->update(cur_promo_size_in_mbytes, - remark_pause_in_ms); - major_collection_estimator()->update(cur_promo_size_in_mbytes, - total_collection_cost); - - // This estimate uses the average eden size. It could also - // have used the latest eden size. Which is better? - double cur_eden_size_in_mbytes = ((double)cur_eden)/((double) M); - initial_pause_young_estimator()->update(cur_eden_size_in_mbytes, - initial_pause_in_ms); - remark_pause_young_estimator()->update(cur_eden_size_in_mbytes, - remark_pause_in_ms); - } - - clear_internal_time_intervals(); - - set_first_after_collection(); - - // The concurrent phases keeps track of it's own mutator interval - // with this timer. This allows the stop-the-world phase to - // be included in the mutator time so that the stop-the-world time - // is not double counted. Reset and start it. - _concurrent_timer.reset(); - _concurrent_timer.start(); - - // The mutator time between STW phases does not include the - // concurrent collection time. - _STW_timer.reset(); - _STW_timer.start(); -} - -void CMSAdaptiveSizePolicy::checkpoint_roots_initial_begin() { - // Update the interval time - _STW_timer.stop(); - _latest_cms_reset_end_to_initial_mark_start_secs = _STW_timer.seconds(); - // Reset for the initial mark - _STW_timer.reset(); - _STW_timer.start(); -} - -void CMSAdaptiveSizePolicy::checkpoint_roots_initial_end( - GCCause::Cause gc_cause) { - _STW_timer.stop(); - - if (gc_cause != GCCause::_java_lang_system_gc || - UseAdaptiveSizePolicyWithSystemGC) { - _latest_cms_initial_mark_start_to_end_time_secs = _STW_timer.seconds(); - avg_initial_pause()->sample(_latest_cms_initial_mark_start_to_end_time_secs); - - if (PrintAdaptiveSizePolicy && Verbose) { - gclog_or_tty->print( - "cmsAdaptiveSizePolicy::checkpoint_roots_initial_end: " - "initial pause: %f ", _latest_cms_initial_mark_start_to_end_time_secs); - } - } - - _STW_timer.reset(); - _STW_timer.start(); -} - -void CMSAdaptiveSizePolicy::checkpoint_roots_final_begin() { - _STW_timer.stop(); - _latest_cms_initial_mark_end_to_remark_start_secs = _STW_timer.seconds(); - // Start accumulating time for the remark in the STW timer. - _STW_timer.reset(); - _STW_timer.start(); -} - -void CMSAdaptiveSizePolicy::checkpoint_roots_final_end( - GCCause::Cause gc_cause) { - _STW_timer.stop(); - if (gc_cause != GCCause::_java_lang_system_gc || - UseAdaptiveSizePolicyWithSystemGC) { - // Total initial mark pause + remark pause. - _latest_cms_remark_start_to_end_time_secs = _STW_timer.seconds(); - double STW_time_in_seconds = _latest_cms_initial_mark_start_to_end_time_secs + - _latest_cms_remark_start_to_end_time_secs; - double STW_time_in_ms = STW_time_in_seconds * MILLIUNITS; - - avg_remark_pause()->sample(_latest_cms_remark_start_to_end_time_secs); - - // Sample total for initial mark + remark - avg_cms_STW_time()->sample(STW_time_in_seconds); - - if (PrintAdaptiveSizePolicy && Verbose) { - gclog_or_tty->print("cmsAdaptiveSizePolicy::checkpoint_roots_final_end: " - "remark pause: %f", _latest_cms_remark_start_to_end_time_secs); - } - - } - // Don't start the STW times here because the concurrent - // sweep and reset has not happened. - // Keep the old comment above in case I don't understand - // what is going on but now - // Start the STW timer because it is used by ms_collection_begin() - // and ms_collection_end() to get the sweep time if a MS is being - // done in the foreground. - _STW_timer.reset(); - _STW_timer.start(); -} - -void CMSAdaptiveSizePolicy::msc_collection_begin() { - if (PrintAdaptiveSizePolicy && Verbose) { - gclog_or_tty->print(" "); - gclog_or_tty->stamp(); - gclog_or_tty->print(": msc_collection_begin "); - } - _STW_timer.stop(); - _latest_cms_msc_end_to_msc_start_time_secs = _STW_timer.seconds(); - if (PrintAdaptiveSizePolicy && Verbose) { - gclog_or_tty->print_cr("CMSAdaptiveSizePolicy::msc_collection_begin: " - "mutator time %f", - _latest_cms_msc_end_to_msc_start_time_secs); - } - avg_msc_interval()->sample(_latest_cms_msc_end_to_msc_start_time_secs); - _STW_timer.reset(); - _STW_timer.start(); -} - -void CMSAdaptiveSizePolicy::msc_collection_end(GCCause::Cause gc_cause) { - if (PrintAdaptiveSizePolicy && Verbose) { - gclog_or_tty->print(" "); - gclog_or_tty->stamp(); - gclog_or_tty->print(": msc_collection_end "); - } - _STW_timer.stop(); - if (gc_cause != GCCause::_java_lang_system_gc || - UseAdaptiveSizePolicyWithSystemGC) { - double msc_pause_in_seconds = _STW_timer.seconds(); - if ((_latest_cms_msc_end_to_msc_start_time_secs > 0.0) && - (msc_pause_in_seconds > 0.0)) { - avg_msc_pause()->sample(msc_pause_in_seconds); - double mutator_time_in_seconds = 0.0; - if (_latest_cms_collection_end_to_collection_start_secs == 0.0) { - // This assertion may fail because of time stamp granularity. - // Comment it out and investigate it at a later time. The large - // time stamp granularity occurs on some older linux systems. -#ifndef CLOCK_GRANULARITY_TOO_LARGE - assert((_latest_cms_concurrent_marking_time_secs == 0.0) && - (_latest_cms_concurrent_precleaning_time_secs == 0.0) && - (_latest_cms_concurrent_sweeping_time_secs == 0.0), - "There should not be any concurrent time"); -#endif - // A concurrent collection did not start. Mutator time - // between collections comes from the STW MSC timer. - mutator_time_in_seconds = _latest_cms_msc_end_to_msc_start_time_secs; - } else { - // The concurrent collection did start so count the mutator - // time to the start of the concurrent collection. In this - // case the _latest_cms_msc_end_to_msc_start_time_secs measures - // the time between the initial mark or remark and the - // start of the MSC. That has no real meaning. - mutator_time_in_seconds = _latest_cms_collection_end_to_collection_start_secs; - } - - double latest_cms_sum_concurrent_phases_time_secs = - concurrent_collection_time(); - double interval_in_seconds = - mutator_time_in_seconds + - _latest_cms_initial_mark_start_to_end_time_secs + - _latest_cms_remark_start_to_end_time_secs + - latest_cms_sum_concurrent_phases_time_secs + - msc_pause_in_seconds; - - if (PrintAdaptiveSizePolicy && Verbose) { - gclog_or_tty->print_cr(" interval_in_seconds %f \n" - " mutator_time_in_seconds %f \n" - " _latest_cms_initial_mark_start_to_end_time_secs %f\n" - " _latest_cms_remark_start_to_end_time_secs %f\n" - " latest_cms_sum_concurrent_phases_time_secs %f\n" - " msc_pause_in_seconds %f\n", - interval_in_seconds, - mutator_time_in_seconds, - _latest_cms_initial_mark_start_to_end_time_secs, - _latest_cms_remark_start_to_end_time_secs, - latest_cms_sum_concurrent_phases_time_secs, - msc_pause_in_seconds); - } - - // The concurrent cost is wasted cost but it should be - // included. - double concurrent_cost = concurrent_collection_cost(interval_in_seconds); - - // Initial mark and remark, also wasted. - double STW_time_in_seconds = _latest_cms_initial_mark_start_to_end_time_secs + - _latest_cms_remark_start_to_end_time_secs; - double STW_collection_cost = - collection_cost(STW_time_in_seconds, interval_in_seconds) + - concurrent_cost; - - if (PrintAdaptiveSizePolicy && Verbose) { - gclog_or_tty->print_cr(" msc_collection_end:\n" - "_latest_cms_collection_end_to_collection_start_secs %f\n" - "_latest_cms_msc_end_to_msc_start_time_secs %f\n" - "_latest_cms_initial_mark_start_to_end_time_secs %f\n" - "_latest_cms_remark_start_to_end_time_secs %f\n" - "latest_cms_sum_concurrent_phases_time_secs %f\n", - _latest_cms_collection_end_to_collection_start_secs, - _latest_cms_msc_end_to_msc_start_time_secs, - _latest_cms_initial_mark_start_to_end_time_secs, - _latest_cms_remark_start_to_end_time_secs, - latest_cms_sum_concurrent_phases_time_secs); - - gclog_or_tty->print_cr(" msc_collection_end: \n" - "latest_cms_sum_concurrent_phases_time_secs %f\n" - "STW_time_in_seconds %f\n" - "msc_pause_in_seconds %f\n", - latest_cms_sum_concurrent_phases_time_secs, - STW_time_in_seconds, - msc_pause_in_seconds); - } - - double cost = concurrent_cost + STW_collection_cost + - collection_cost(msc_pause_in_seconds, interval_in_seconds); - - _avg_msc_gc_cost->sample(cost); - - // Average this ms cost into all the other types gc costs - avg_major_gc_cost()->sample(cost); - - // Sample for performance counter - _avg_msc_interval->sample(interval_in_seconds); - if (PrintAdaptiveSizePolicy && Verbose) { - gclog_or_tty->print("cmsAdaptiveSizePolicy::msc_collection_end: " - "MSC gc cost: %f average: %f", cost, - _avg_msc_gc_cost->average()); - - double msc_pause_in_ms = msc_pause_in_seconds * MILLIUNITS; - gclog_or_tty->print_cr(" MSC pause: %f (ms) MSC period %f (ms)", - msc_pause_in_ms, (double) interval_in_seconds * MILLIUNITS); - } - } - } - - clear_internal_time_intervals(); - - // Can this call be put into the epilogue? - set_first_after_collection(); - - // The concurrent phases keeps track of it's own mutator interval - // with this timer. This allows the stop-the-world phase to - // be included in the mutator time so that the stop-the-world time - // is not double counted. Reset and start it. - _concurrent_timer.stop(); - _concurrent_timer.reset(); - _concurrent_timer.start(); - - _STW_timer.reset(); - _STW_timer.start(); -} - -void CMSAdaptiveSizePolicy::ms_collection_begin() { - if (PrintAdaptiveSizePolicy && Verbose) { - gclog_or_tty->print(" "); - gclog_or_tty->stamp(); - gclog_or_tty->print(": ms_collection_begin "); - } - _STW_timer.stop(); - _latest_cms_ms_end_to_ms_start = _STW_timer.seconds(); - if (PrintAdaptiveSizePolicy && Verbose) { - gclog_or_tty->print_cr("CMSAdaptiveSizePolicy::ms_collection_begin: " - "mutator time %f", - _latest_cms_ms_end_to_ms_start); - } - avg_ms_interval()->sample(_STW_timer.seconds()); - _STW_timer.reset(); - _STW_timer.start(); -} - -void CMSAdaptiveSizePolicy::ms_collection_end(GCCause::Cause gc_cause) { - if (PrintAdaptiveSizePolicy && Verbose) { - gclog_or_tty->print(" "); - gclog_or_tty->stamp(); - gclog_or_tty->print(": ms_collection_end "); - } - _STW_timer.stop(); - if (gc_cause != GCCause::_java_lang_system_gc || - UseAdaptiveSizePolicyWithSystemGC) { - // The MS collection is a foreground collection that does all - // the parts of a mostly concurrent collection. - // - // For this collection include the cost of the - // initial mark - // remark - // all concurrent time (scaled down by the - // concurrent_processor_fraction). Some - // may be zero if the baton was passed before - // it was reached. - // concurrent marking - // sweeping - // resetting - // STW after baton was passed (STW_in_foreground_in_seconds) - double STW_in_foreground_in_seconds = _STW_timer.seconds(); - - double latest_cms_sum_concurrent_phases_time_secs = - concurrent_collection_time(); - if (PrintAdaptiveSizePolicy && Verbose) { - gclog_or_tty->print_cr("\nCMSAdaptiveSizePolicy::ms_collection_end " - "STW_in_foreground_in_seconds %f " - "_latest_cms_initial_mark_start_to_end_time_secs %f " - "_latest_cms_remark_start_to_end_time_secs %f " - "latest_cms_sum_concurrent_phases_time_secs %f " - "_latest_cms_ms_marking_start_to_end_time_secs %f " - "_latest_cms_ms_end_to_ms_start %f", - STW_in_foreground_in_seconds, - _latest_cms_initial_mark_start_to_end_time_secs, - _latest_cms_remark_start_to_end_time_secs, - latest_cms_sum_concurrent_phases_time_secs, - _latest_cms_ms_marking_start_to_end_time_secs, - _latest_cms_ms_end_to_ms_start); - } - - double STW_marking_in_seconds = _latest_cms_initial_mark_start_to_end_time_secs + - _latest_cms_remark_start_to_end_time_secs; -#ifndef CLOCK_GRANULARITY_TOO_LARGE - assert(_latest_cms_ms_marking_start_to_end_time_secs == 0.0 || - latest_cms_sum_concurrent_phases_time_secs == 0.0, - "marking done twice?"); -#endif - double ms_time_in_seconds = STW_marking_in_seconds + - STW_in_foreground_in_seconds + - _latest_cms_ms_marking_start_to_end_time_secs + - scaled_concurrent_collection_time(); - avg_ms_pause()->sample(ms_time_in_seconds); - // Use the STW costs from the initial mark and remark plus - // the cost of the concurrent phase to calculate a - // collection cost. - double cost = 0.0; - if ((_latest_cms_ms_end_to_ms_start > 0.0) && - (ms_time_in_seconds > 0.0)) { - double interval_in_seconds = - _latest_cms_ms_end_to_ms_start + ms_time_in_seconds; - - if (PrintAdaptiveSizePolicy && Verbose) { - gclog_or_tty->print_cr("\n ms_time_in_seconds %f " - "latest_cms_sum_concurrent_phases_time_secs %f " - "interval_in_seconds %f", - ms_time_in_seconds, - latest_cms_sum_concurrent_phases_time_secs, - interval_in_seconds); - } - - cost = collection_cost(ms_time_in_seconds, interval_in_seconds); - - _avg_ms_gc_cost->sample(cost); - // Average this ms cost into all the other types gc costs - avg_major_gc_cost()->sample(cost); - - // Sample for performance counter - _avg_ms_interval->sample(interval_in_seconds); - } - if (PrintAdaptiveSizePolicy && Verbose) { - gclog_or_tty->print("cmsAdaptiveSizePolicy::ms_collection_end: " - "MS gc cost: %f average: %f", cost, _avg_ms_gc_cost->average()); - - double ms_time_in_ms = ms_time_in_seconds * MILLIUNITS; - gclog_or_tty->print_cr(" MS pause: %f (ms) MS period %f (ms)", - ms_time_in_ms, - _latest_cms_ms_end_to_ms_start * MILLIUNITS); - } - } - - // Consider putting this code (here to end) into a - // method for convenience. - clear_internal_time_intervals(); - - set_first_after_collection(); - - // The concurrent phases keeps track of it's own mutator interval - // with this timer. This allows the stop-the-world phase to - // be included in the mutator time so that the stop-the-world time - // is not double counted. Reset and start it. - _concurrent_timer.stop(); - _concurrent_timer.reset(); - _concurrent_timer.start(); - - _STW_timer.reset(); - _STW_timer.start(); -} - -void CMSAdaptiveSizePolicy::clear_internal_time_intervals() { - _latest_cms_reset_end_to_initial_mark_start_secs = 0.0; - _latest_cms_initial_mark_end_to_remark_start_secs = 0.0; - _latest_cms_collection_end_to_collection_start_secs = 0.0; - _latest_cms_concurrent_marking_time_secs = 0.0; - _latest_cms_concurrent_precleaning_time_secs = 0.0; - _latest_cms_concurrent_sweeping_time_secs = 0.0; - _latest_cms_msc_end_to_msc_start_time_secs = 0.0; - _latest_cms_ms_end_to_ms_start = 0.0; - _latest_cms_remark_start_to_end_time_secs = 0.0; - _latest_cms_initial_mark_start_to_end_time_secs = 0.0; - _latest_cms_ms_marking_start_to_end_time_secs = 0.0; -} - -void CMSAdaptiveSizePolicy::clear_generation_free_space_flags() { - AdaptiveSizePolicy::clear_generation_free_space_flags(); - - set_change_young_gen_for_maj_pauses(0); -} - -void CMSAdaptiveSizePolicy::concurrent_phases_resume() { - if (PrintAdaptiveSizePolicy && Verbose) { - gclog_or_tty->stamp(); - gclog_or_tty->print_cr("CMSAdaptiveSizePolicy::concurrent_phases_resume()"); - } - _concurrent_timer.start(); -} - -double CMSAdaptiveSizePolicy::time_since_major_gc() const { - _concurrent_timer.stop(); - double time_since_cms_gc = _concurrent_timer.seconds(); - _concurrent_timer.start(); - _STW_timer.stop(); - double time_since_STW_gc = _STW_timer.seconds(); - _STW_timer.start(); - - return MIN2(time_since_cms_gc, time_since_STW_gc); -} - -double CMSAdaptiveSizePolicy::major_gc_interval_average_for_decay() const { - double cms_interval = _avg_concurrent_interval->average(); - double msc_interval = _avg_msc_interval->average(); - double ms_interval = _avg_ms_interval->average(); - - return MAX3(cms_interval, msc_interval, ms_interval); -} - -double CMSAdaptiveSizePolicy::cms_gc_cost() const { - return avg_major_gc_cost()->average(); -} - -void CMSAdaptiveSizePolicy::ms_collection_marking_begin() { - _STW_timer.stop(); - // Start accumulating time for the marking in the STW timer. - _STW_timer.reset(); - _STW_timer.start(); -} - -void CMSAdaptiveSizePolicy::ms_collection_marking_end( - GCCause::Cause gc_cause) { - _STW_timer.stop(); - if (gc_cause != GCCause::_java_lang_system_gc || - UseAdaptiveSizePolicyWithSystemGC) { - _latest_cms_ms_marking_start_to_end_time_secs = _STW_timer.seconds(); - if (PrintAdaptiveSizePolicy && Verbose) { - gclog_or_tty->print_cr("CMSAdaptiveSizePolicy::" - "msc_collection_marking_end: mutator time %f", - _latest_cms_ms_marking_start_to_end_time_secs); - } - } - _STW_timer.reset(); - _STW_timer.start(); -} - -double CMSAdaptiveSizePolicy::gc_cost() const { - double cms_gen_cost = cms_gc_cost(); - double result = MIN2(1.0, minor_gc_cost() + cms_gen_cost); - assert(result >= 0.0, "Both minor and major costs are non-negative"); - return result; -} - -// Cost of collection (unit-less) -double CMSAdaptiveSizePolicy::collection_cost(double pause_in_seconds, - double interval_in_seconds) { - // Cost of collection (unit-less) - double cost = 0.0; - if ((interval_in_seconds > 0.0) && - (pause_in_seconds > 0.0)) { - cost = - pause_in_seconds / interval_in_seconds; - } - return cost; -} - -size_t CMSAdaptiveSizePolicy::adjust_eden_for_pause_time(size_t cur_eden) { - size_t change = 0; - size_t desired_eden = cur_eden; - - // reduce eden size - change = eden_decrement_aligned_down(cur_eden); - desired_eden = cur_eden - change; - - if (PrintAdaptiveSizePolicy && Verbose) { - gclog_or_tty->print_cr( - "CMSAdaptiveSizePolicy::adjust_eden_for_pause_time " - "adjusting eden for pause time. " - " starting eden size " SIZE_FORMAT - " reduced eden size " SIZE_FORMAT - " eden delta " SIZE_FORMAT, - cur_eden, desired_eden, change); - } - - return desired_eden; -} - -size_t CMSAdaptiveSizePolicy::adjust_eden_for_throughput(size_t cur_eden) { - - size_t desired_eden = cur_eden; - - set_change_young_gen_for_throughput(increase_young_gen_for_througput_true); - - size_t change = eden_increment_aligned_up(cur_eden); - size_t scaled_change = scale_by_gen_gc_cost(change, minor_gc_cost()); - - if (cur_eden + scaled_change > cur_eden) { - desired_eden = cur_eden + scaled_change; - } - - _young_gen_change_for_minor_throughput++; - - if (PrintAdaptiveSizePolicy && Verbose) { - gclog_or_tty->print_cr( - "CMSAdaptiveSizePolicy::adjust_eden_for_throughput " - "adjusting eden for throughput. " - " starting eden size " SIZE_FORMAT - " increased eden size " SIZE_FORMAT - " eden delta " SIZE_FORMAT, - cur_eden, desired_eden, scaled_change); - } - - return desired_eden; -} - -size_t CMSAdaptiveSizePolicy::adjust_eden_for_footprint(size_t cur_eden) { - - set_decrease_for_footprint(decrease_young_gen_for_footprint_true); - - size_t change = eden_decrement(cur_eden); - size_t desired_eden_size = cur_eden - change; - - if (PrintAdaptiveSizePolicy && Verbose) { - gclog_or_tty->print_cr( - "CMSAdaptiveSizePolicy::adjust_eden_for_footprint " - "adjusting eden for footprint. " - " starting eden size " SIZE_FORMAT - " reduced eden size " SIZE_FORMAT - " eden delta " SIZE_FORMAT, - cur_eden, desired_eden_size, change); - } - return desired_eden_size; -} - -// The eden and promo versions should be combined if possible. -// They are the same except that the sizes of the decrement -// and increment are different for eden and promo. -size_t CMSAdaptiveSizePolicy::eden_decrement_aligned_down(size_t cur_eden) { - size_t delta = eden_decrement(cur_eden); - return align_size_down(delta, generation_alignment()); -} - -size_t CMSAdaptiveSizePolicy::eden_increment_aligned_up(size_t cur_eden) { - size_t delta = eden_increment(cur_eden); - return align_size_up(delta, generation_alignment()); -} - -size_t CMSAdaptiveSizePolicy::promo_decrement_aligned_down(size_t cur_promo) { - size_t delta = promo_decrement(cur_promo); - return align_size_down(delta, generation_alignment()); -} - -size_t CMSAdaptiveSizePolicy::promo_increment_aligned_up(size_t cur_promo) { - size_t delta = promo_increment(cur_promo); - return align_size_up(delta, generation_alignment()); -} - - -void CMSAdaptiveSizePolicy::compute_eden_space_size(size_t cur_eden, - size_t max_eden_size) -{ - size_t desired_eden_size = cur_eden; - size_t eden_limit = max_eden_size; - - // Printout input - if (PrintGC && PrintAdaptiveSizePolicy) { - gclog_or_tty->print_cr( - "CMSAdaptiveSizePolicy::compute_eden_space_size: " - "cur_eden " SIZE_FORMAT, - cur_eden); - } - - // Used for diagnostics - clear_generation_free_space_flags(); - - if (_avg_minor_pause->padded_average() > gc_pause_goal_sec()) { - if (minor_pause_young_estimator()->decrement_will_decrease()) { - // If the minor pause is too long, shrink the young gen. - set_change_young_gen_for_min_pauses( - decrease_young_gen_for_min_pauses_true); - desired_eden_size = adjust_eden_for_pause_time(desired_eden_size); - } - } else if ((avg_remark_pause()->padded_average() > gc_pause_goal_sec()) || - (avg_initial_pause()->padded_average() > gc_pause_goal_sec())) { - // The remark or initial pauses are not meeting the goal. Should - // the generation be shrunk? - if (get_and_clear_first_after_collection() && - ((avg_remark_pause()->padded_average() > gc_pause_goal_sec() && - remark_pause_young_estimator()->decrement_will_decrease()) || - (avg_initial_pause()->padded_average() > gc_pause_goal_sec() && - initial_pause_young_estimator()->decrement_will_decrease()))) { - - set_change_young_gen_for_maj_pauses( - decrease_young_gen_for_maj_pauses_true); - - // If the remark or initial pause is too long and this is the - // first young gen collection after a cms collection, shrink - // the young gen. - desired_eden_size = adjust_eden_for_pause_time(desired_eden_size); - } - // If not the first young gen collection after a cms collection, - // don't do anything. In this case an adjustment has already - // been made and the results of the adjustment has not yet been - // measured. - } else if ((minor_gc_cost() >= 0.0) && - (adjusted_mutator_cost() < _throughput_goal)) { - desired_eden_size = adjust_eden_for_throughput(desired_eden_size); - } else { - desired_eden_size = adjust_eden_for_footprint(desired_eden_size); - } - - if (PrintGC && PrintAdaptiveSizePolicy) { - gclog_or_tty->print_cr( - "CMSAdaptiveSizePolicy::compute_eden_space_size limits:" - " desired_eden_size: " SIZE_FORMAT - " old_eden_size: " SIZE_FORMAT, - desired_eden_size, cur_eden); - } - - set_eden_size(desired_eden_size); -} - -size_t CMSAdaptiveSizePolicy::adjust_promo_for_pause_time(size_t cur_promo) { - size_t change = 0; - size_t desired_promo = cur_promo; - // Move this test up to caller like the adjust_eden_for_pause_time() - // call. - if ((AdaptiveSizePausePolicy == 0) && - ((avg_remark_pause()->padded_average() > gc_pause_goal_sec()) || - (avg_initial_pause()->padded_average() > gc_pause_goal_sec()))) { - set_change_old_gen_for_maj_pauses(decrease_old_gen_for_maj_pauses_true); - change = promo_decrement_aligned_down(cur_promo); - desired_promo = cur_promo - change; - } else if ((AdaptiveSizePausePolicy > 0) && - (((avg_remark_pause()->padded_average() > gc_pause_goal_sec()) && - remark_pause_old_estimator()->decrement_will_decrease()) || - ((avg_initial_pause()->padded_average() > gc_pause_goal_sec()) && - initial_pause_old_estimator()->decrement_will_decrease()))) { - set_change_old_gen_for_maj_pauses(decrease_old_gen_for_maj_pauses_true); - change = promo_decrement_aligned_down(cur_promo); - desired_promo = cur_promo - change; - } - - if ((change != 0) &&PrintAdaptiveSizePolicy && Verbose) { - gclog_or_tty->print_cr( - "CMSAdaptiveSizePolicy::adjust_promo_for_pause_time " - "adjusting promo for pause time. " - " starting promo size " SIZE_FORMAT - " reduced promo size " SIZE_FORMAT - " promo delta " SIZE_FORMAT, - cur_promo, desired_promo, change); - } - - return desired_promo; -} - -// Try to share this with PS. -size_t CMSAdaptiveSizePolicy::scale_by_gen_gc_cost(size_t base_change, - double gen_gc_cost) { - - // Calculate the change to use for the tenured gen. - size_t scaled_change = 0; - // Can the increment to the generation be scaled? - if (gc_cost() >= 0.0 && gen_gc_cost >= 0.0) { - double scale_by_ratio = gen_gc_cost / gc_cost(); - scaled_change = - (size_t) (scale_by_ratio * (double) base_change); - if (PrintAdaptiveSizePolicy && Verbose) { - gclog_or_tty->print_cr( - "Scaled tenured increment: " SIZE_FORMAT " by %f down to " - SIZE_FORMAT, - base_change, scale_by_ratio, scaled_change); - } - } else if (gen_gc_cost >= 0.0) { - // Scaling is not going to work. If the major gc time is the - // larger than the other GC costs, give it a full increment. - if (gen_gc_cost >= (gc_cost() - gen_gc_cost)) { - scaled_change = base_change; - } - } else { - // Don't expect to get here but it's ok if it does - // in the product build since the delta will be 0 - // and nothing will change. - assert(false, "Unexpected value for gc costs"); - } - - return scaled_change; -} - -size_t CMSAdaptiveSizePolicy::adjust_promo_for_throughput(size_t cur_promo) { - - size_t desired_promo = cur_promo; - - set_change_old_gen_for_throughput(increase_old_gen_for_throughput_true); - - size_t change = promo_increment_aligned_up(cur_promo); - size_t scaled_change = scale_by_gen_gc_cost(change, major_gc_cost()); - - if (cur_promo + scaled_change > cur_promo) { - desired_promo = cur_promo + scaled_change; - } - - _old_gen_change_for_major_throughput++; - - if (PrintAdaptiveSizePolicy && Verbose) { - gclog_or_tty->print_cr( - "CMSAdaptiveSizePolicy::adjust_promo_for_throughput " - "adjusting promo for throughput. " - " starting promo size " SIZE_FORMAT - " increased promo size " SIZE_FORMAT - " promo delta " SIZE_FORMAT, - cur_promo, desired_promo, scaled_change); - } - - return desired_promo; -} - -size_t CMSAdaptiveSizePolicy::adjust_promo_for_footprint(size_t cur_promo, - size_t cur_eden) { - - set_decrease_for_footprint(decrease_young_gen_for_footprint_true); - - size_t change = promo_decrement(cur_promo); - size_t desired_promo_size = cur_promo - change; - - if (PrintAdaptiveSizePolicy && Verbose) { - gclog_or_tty->print_cr( - "CMSAdaptiveSizePolicy::adjust_promo_for_footprint " - "adjusting promo for footprint. " - " starting promo size " SIZE_FORMAT - " reduced promo size " SIZE_FORMAT - " promo delta " SIZE_FORMAT, - cur_promo, desired_promo_size, change); - } - return desired_promo_size; -} - -void CMSAdaptiveSizePolicy::compute_tenured_generation_free_space( - size_t cur_tenured_free, - size_t max_tenured_available, - size_t cur_eden) { - // This can be bad if the desired value grows/shrinks without - // any connection to the read free space - size_t desired_promo_size = promo_size(); - size_t tenured_limit = max_tenured_available; - - // Printout input - if (PrintGC && PrintAdaptiveSizePolicy) { - gclog_or_tty->print_cr( - "CMSAdaptiveSizePolicy::compute_tenured_generation_free_space: " - "cur_tenured_free " SIZE_FORMAT - " max_tenured_available " SIZE_FORMAT, - cur_tenured_free, max_tenured_available); - } - - // Used for diagnostics - clear_generation_free_space_flags(); - - set_decide_at_full_gc(decide_at_full_gc_true); - if (avg_remark_pause()->padded_average() > gc_pause_goal_sec() || - avg_initial_pause()->padded_average() > gc_pause_goal_sec()) { - desired_promo_size = adjust_promo_for_pause_time(cur_tenured_free); - } else if (avg_minor_pause()->padded_average() > gc_pause_goal_sec()) { - // Nothing to do since the minor collections are too large and - // this method only deals with the cms generation. - } else if ((cms_gc_cost() >= 0.0) && - (adjusted_mutator_cost() < _throughput_goal)) { - desired_promo_size = adjust_promo_for_throughput(cur_tenured_free); - } else { - desired_promo_size = adjust_promo_for_footprint(cur_tenured_free, - cur_eden); - } - - if (PrintGC && PrintAdaptiveSizePolicy) { - gclog_or_tty->print_cr( - "CMSAdaptiveSizePolicy::compute_tenured_generation_free_space limits:" - " desired_promo_size: " SIZE_FORMAT - " old_promo_size: " SIZE_FORMAT, - desired_promo_size, cur_tenured_free); - } - - set_promo_size(desired_promo_size); -} - -uint CMSAdaptiveSizePolicy::compute_survivor_space_size_and_threshold( - bool is_survivor_overflow, - uint tenuring_threshold, - size_t survivor_limit) { - assert(survivor_limit >= generation_alignment(), - "survivor_limit too small"); - assert((size_t)align_size_down(survivor_limit, generation_alignment()) - == survivor_limit, "survivor_limit not aligned"); - - // Change UsePSAdaptiveSurvivorSizePolicy -> UseAdaptiveSurvivorSizePolicy? - if (!UsePSAdaptiveSurvivorSizePolicy || - !young_gen_policy_is_ready()) { - return tenuring_threshold; - } - - // We'll decide whether to increase or decrease the tenuring - // threshold based partly on the newly computed survivor size - // (if we hit the maximum limit allowed, we'll always choose to - // decrement the threshold). - bool incr_tenuring_threshold = false; - bool decr_tenuring_threshold = false; - - set_decrement_tenuring_threshold_for_gc_cost(false); - set_increment_tenuring_threshold_for_gc_cost(false); - set_decrement_tenuring_threshold_for_survivor_limit(false); - - if (!is_survivor_overflow) { - // Keep running averages on how much survived - - // We use the tenuring threshold to equalize the cost of major - // and minor collections. - // ThresholdTolerance is used to indicate how sensitive the - // tenuring threshold is to differences in cost between the - // collection types. - - // Get the times of interest. This involves a little work, so - // we cache the values here. - const double major_cost = major_gc_cost(); - const double minor_cost = minor_gc_cost(); - - if (minor_cost > major_cost * _threshold_tolerance_percent) { - // Minor times are getting too long; lower the threshold so - // less survives and more is promoted. - decr_tenuring_threshold = true; - set_decrement_tenuring_threshold_for_gc_cost(true); - } else if (major_cost > minor_cost * _threshold_tolerance_percent) { - // Major times are too long, so we want less promotion. - incr_tenuring_threshold = true; - set_increment_tenuring_threshold_for_gc_cost(true); - } - - } else { - // Survivor space overflow occurred, so promoted and survived are - // not accurate. We'll make our best guess by combining survived - // and promoted and count them as survivors. - // - // We'll lower the tenuring threshold to see if we can correct - // things. Also, set the survivor size conservatively. We're - // trying to avoid many overflows from occurring if defnew size - // is just too small. - - decr_tenuring_threshold = true; - } - - // The padded average also maintains a deviation from the average; - // we use this to see how good of an estimate we have of what survived. - // We're trying to pad the survivor size as little as possible without - // overflowing the survivor spaces. - size_t target_size = align_size_up((size_t)_avg_survived->padded_average(), - generation_alignment()); - target_size = MAX2(target_size, generation_alignment()); - - if (target_size > survivor_limit) { - // Target size is bigger than we can handle. Let's also reduce - // the tenuring threshold. - target_size = survivor_limit; - decr_tenuring_threshold = true; - set_decrement_tenuring_threshold_for_survivor_limit(true); - } - - // Finally, increment or decrement the tenuring threshold, as decided above. - // We test for decrementing first, as we might have hit the target size - // limit. - if (decr_tenuring_threshold && !(AlwaysTenure || NeverTenure)) { - if (tenuring_threshold > 1) { - tenuring_threshold--; - } - } else if (incr_tenuring_threshold && !(AlwaysTenure || NeverTenure)) { - if (tenuring_threshold < MaxTenuringThreshold) { - tenuring_threshold++; - } - } - - // We keep a running average of the amount promoted which is used - // to decide when we should collect the old generation (when - // the amount of old gen free space is less than what we expect to - // promote). - - if (PrintAdaptiveSizePolicy) { - // A little more detail if Verbose is on - GenCollectedHeap* gch = GenCollectedHeap::heap(); - if (Verbose) { - gclog_or_tty->print( " avg_survived: %f" - " avg_deviation: %f", - _avg_survived->average(), - _avg_survived->deviation()); - } - - gclog_or_tty->print( " avg_survived_padded_avg: %f", - _avg_survived->padded_average()); - - if (Verbose) { - gclog_or_tty->print( " avg_promoted_avg: %f" - " avg_promoted_dev: %f", - gch->gc_stats(1)->avg_promoted()->average(), - gch->gc_stats(1)->avg_promoted()->deviation()); - } - - gclog_or_tty->print( " avg_promoted_padded_avg: %f" - " avg_pretenured_padded_avg: %f" - " tenuring_thresh: %u" - " target_size: " SIZE_FORMAT - " survivor_limit: " SIZE_FORMAT, - gch->gc_stats(1)->avg_promoted()->padded_average(), - _avg_pretenured->padded_average(), - tenuring_threshold, target_size, survivor_limit); - gclog_or_tty->cr(); - } - - set_survivor_size(target_size); - - return tenuring_threshold; -} - -bool CMSAdaptiveSizePolicy::get_and_clear_first_after_collection() { - bool result = _first_after_collection; - _first_after_collection = false; - return result; -} - -bool CMSAdaptiveSizePolicy::print_adaptive_size_policy_on( - outputStream* st) const { - - if (!UseAdaptiveSizePolicy) { - return false; - } - - GenCollectedHeap* gch = GenCollectedHeap::heap(); - Generation* young = gch->get_gen(0); - DefNewGeneration* def_new = young->as_DefNewGeneration(); - return AdaptiveSizePolicy::print_adaptive_size_policy_on( - st, - def_new->tenuring_threshold()); -} diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsAdaptiveSizePolicy.hpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsAdaptiveSizePolicy.hpp deleted file mode 100644 index 1bf4ca34cf1..00000000000 --- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsAdaptiveSizePolicy.hpp +++ /dev/null @@ -1,477 +0,0 @@ -/* - * Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#ifndef SHARE_VM_GC_IMPLEMENTATION_CONCURRENTMARKSWEEP_CMSADAPTIVESIZEPOLICY_HPP -#define SHARE_VM_GC_IMPLEMENTATION_CONCURRENTMARKSWEEP_CMSADAPTIVESIZEPOLICY_HPP - -#include "gc_implementation/shared/adaptiveSizePolicy.hpp" -#include "runtime/timer.hpp" - -// This class keeps statistical information and computes the -// size of the heap for the concurrent mark sweep collector. -// -// Cost for garbage collector include cost for -// minor collection -// concurrent collection -// stop-the-world component -// concurrent component -// major compacting collection -// uses decaying cost - -// Forward decls -class elapsedTimer; - -class CMSAdaptiveSizePolicy : public AdaptiveSizePolicy { - friend class CMSGCAdaptivePolicyCounters; - friend class CMSCollector; - private: - - // Total number of processors available - int _processor_count; - // Number of processors used by the concurrent phases of GC - // This number is assumed to be the same for all concurrent - // phases. - int _concurrent_processor_count; - - // Time that the mutators run exclusive of a particular - // phase. For example, the time the mutators run excluding - // the time during which the cms collector runs concurrently - // with the mutators. - // Between end of most recent cms reset and start of initial mark - // This may be redundant - double _latest_cms_reset_end_to_initial_mark_start_secs; - // Between end of the most recent initial mark and start of remark - double _latest_cms_initial_mark_end_to_remark_start_secs; - // Between end of most recent collection and start of - // a concurrent collection - double _latest_cms_collection_end_to_collection_start_secs; - // Times of the concurrent phases of the most recent - // concurrent collection - double _latest_cms_concurrent_marking_time_secs; - double _latest_cms_concurrent_precleaning_time_secs; - double _latest_cms_concurrent_sweeping_time_secs; - // Between end of most recent STW MSC and start of next STW MSC - double _latest_cms_msc_end_to_msc_start_time_secs; - // Between end of most recent MS and start of next MS - // This does not include any time spent during a concurrent - // collection. - double _latest_cms_ms_end_to_ms_start; - // Between start and end of the initial mark of the most recent - // concurrent collection. - double _latest_cms_initial_mark_start_to_end_time_secs; - // Between start and end of the remark phase of the most recent - // concurrent collection - double _latest_cms_remark_start_to_end_time_secs; - // Between start and end of the most recent MS STW marking phase - double _latest_cms_ms_marking_start_to_end_time_secs; - - // Pause time timers - static elapsedTimer _STW_timer; - // Concurrent collection timer. Used for total of all concurrent phases - // during 1 collection cycle. - static elapsedTimer _concurrent_timer; - - // When the size of the generation is changed, the size - // of the change will rounded up or down (depending on the - // type of change) by this value. - size_t _generation_alignment; - - // If this variable is true, the size of the young generation - // may be changed in order to reduce the pause(s) of the - // collection of the tenured generation in order to meet the - // pause time goal. It is common to change the size of the - // tenured generation in order to meet the pause time goal - // for the tenured generation. With the CMS collector for - // the tenured generation, the size of the young generation - // can have an significant affect on the pause times for collecting the - // tenured generation. - // This is a duplicate of a variable in PSAdaptiveSizePolicy. It - // is duplicated because it is not clear that it is general enough - // to go into AdaptiveSizePolicy. - int _change_young_gen_for_maj_pauses; - - // Variable that is set to true after a collection. - bool _first_after_collection; - - // Fraction of collections that are of each type - double concurrent_fraction() const; - double STW_msc_fraction() const; - double STW_ms_fraction() const; - - // This call cannot be put into the epilogue as long as some - // of the counters can be set during concurrent phases. - virtual void clear_generation_free_space_flags(); - - void set_first_after_collection() { _first_after_collection = true; } - - protected: - // Average of the sum of the concurrent times for - // one collection in seconds. - AdaptiveWeightedAverage* _avg_concurrent_time; - // Average time between concurrent collections in seconds. - AdaptiveWeightedAverage* _avg_concurrent_interval; - // Average cost of the concurrent part of a collection - // in seconds. - AdaptiveWeightedAverage* _avg_concurrent_gc_cost; - - // Average of the initial pause of a concurrent collection in seconds. - AdaptivePaddedAverage* _avg_initial_pause; - // Average of the remark pause of a concurrent collection in seconds. - AdaptivePaddedAverage* _avg_remark_pause; - - // Average of the stop-the-world (STW) (initial mark + remark) - // times in seconds for concurrent collections. - AdaptiveWeightedAverage* _avg_cms_STW_time; - // Average of the STW collection cost for concurrent collections. - AdaptiveWeightedAverage* _avg_cms_STW_gc_cost; - - // Average of the bytes free at the start of the sweep. - AdaptiveWeightedAverage* _avg_cms_free_at_sweep; - // Average of the bytes free at the end of the collection. - AdaptiveWeightedAverage* _avg_cms_free; - // Average of the bytes promoted between cms collections. - AdaptiveWeightedAverage* _avg_cms_promo; - - // stop-the-world (STW) mark-sweep-compact - // Average of the pause time in seconds for STW mark-sweep-compact - // collections. - AdaptiveWeightedAverage* _avg_msc_pause; - // Average of the interval in seconds between STW mark-sweep-compact - // collections. - AdaptiveWeightedAverage* _avg_msc_interval; - // Average of the collection costs for STW mark-sweep-compact - // collections. - AdaptiveWeightedAverage* _avg_msc_gc_cost; - - // Averages for mark-sweep collections. - // The collection may have started as a background collection - // that completes in a stop-the-world (STW) collection. - // Average of the pause time in seconds for mark-sweep - // collections. - AdaptiveWeightedAverage* _avg_ms_pause; - // Average of the interval in seconds between mark-sweep - // collections. - AdaptiveWeightedAverage* _avg_ms_interval; - // Average of the collection costs for mark-sweep - // collections. - AdaptiveWeightedAverage* _avg_ms_gc_cost; - - // These variables contain a linear fit of - // a generation size as the independent variable - // and a pause time as the dependent variable. - // For example _remark_pause_old_estimator - // is a fit of the old generation size as the - // independent variable and the remark pause - // as the dependent variable. - // remark pause time vs. cms gen size - LinearLeastSquareFit* _remark_pause_old_estimator; - // initial pause time vs. cms gen size - LinearLeastSquareFit* _initial_pause_old_estimator; - // remark pause time vs. young gen size - LinearLeastSquareFit* _remark_pause_young_estimator; - // initial pause time vs. young gen size - LinearLeastSquareFit* _initial_pause_young_estimator; - - // Accessors - int processor_count() const { return _processor_count; } - int concurrent_processor_count() const { return _concurrent_processor_count; } - - AdaptiveWeightedAverage* avg_concurrent_time() const { - return _avg_concurrent_time; - } - - AdaptiveWeightedAverage* avg_concurrent_interval() const { - return _avg_concurrent_interval; - } - - AdaptiveWeightedAverage* avg_concurrent_gc_cost() const { - return _avg_concurrent_gc_cost; - } - - AdaptiveWeightedAverage* avg_cms_STW_time() const { - return _avg_cms_STW_time; - } - - AdaptiveWeightedAverage* avg_cms_STW_gc_cost() const { - return _avg_cms_STW_gc_cost; - } - - AdaptivePaddedAverage* avg_initial_pause() const { - return _avg_initial_pause; - } - - AdaptivePaddedAverage* avg_remark_pause() const { - return _avg_remark_pause; - } - - AdaptiveWeightedAverage* avg_cms_free() const { - return _avg_cms_free; - } - - AdaptiveWeightedAverage* avg_cms_free_at_sweep() const { - return _avg_cms_free_at_sweep; - } - - AdaptiveWeightedAverage* avg_msc_pause() const { - return _avg_msc_pause; - } - - AdaptiveWeightedAverage* avg_msc_interval() const { - return _avg_msc_interval; - } - - AdaptiveWeightedAverage* avg_msc_gc_cost() const { - return _avg_msc_gc_cost; - } - - AdaptiveWeightedAverage* avg_ms_pause() const { - return _avg_ms_pause; - } - - AdaptiveWeightedAverage* avg_ms_interval() const { - return _avg_ms_interval; - } - - AdaptiveWeightedAverage* avg_ms_gc_cost() const { - return _avg_ms_gc_cost; - } - - LinearLeastSquareFit* remark_pause_old_estimator() { - return _remark_pause_old_estimator; - } - LinearLeastSquareFit* initial_pause_old_estimator() { - return _initial_pause_old_estimator; - } - LinearLeastSquareFit* remark_pause_young_estimator() { - return _remark_pause_young_estimator; - } - LinearLeastSquareFit* initial_pause_young_estimator() { - return _initial_pause_young_estimator; - } - - // These *slope() methods return the slope - // m for the linear fit of an independent - // variable vs. a dependent variable. For - // example - // remark_pause = m * old_generation_size + c - // These may be used to determine if an - // adjustment should be made to achieve a goal. - // For example, if remark_pause_old_slope() is - // positive, a reduction of the old generation - // size has on average resulted in the reduction - // of the remark pause. - float remark_pause_old_slope() { - return _remark_pause_old_estimator->slope(); - } - - float initial_pause_old_slope() { - return _initial_pause_old_estimator->slope(); - } - - float remark_pause_young_slope() { - return _remark_pause_young_estimator->slope(); - } - - float initial_pause_young_slope() { - return _initial_pause_young_estimator->slope(); - } - - // Update estimators - void update_minor_pause_old_estimator(double minor_pause_in_ms); - - // Fraction of processors used by the concurrent phases. - double concurrent_processor_fraction(); - - // Returns the total times for the concurrent part of the - // latest collection in seconds. - double concurrent_collection_time(); - - // Return the total times for the concurrent part of the - // latest collection in seconds where the times of the various - // concurrent phases are scaled by the processor fraction used - // during the phase. - double scaled_concurrent_collection_time(); - - // Dimensionless concurrent GC cost for all the concurrent phases. - double concurrent_collection_cost(double interval_in_seconds); - - // Dimensionless GC cost - double collection_cost(double pause_in_seconds, double interval_in_seconds); - - virtual GCPolicyKind kind() const { return _gc_cms_adaptive_size_policy; } - - virtual double time_since_major_gc() const; - - // This returns the maximum average for the concurrent, ms, and - // msc collections. This is meant to be used for the calculation - // of the decayed major gc cost and is not in general the - // average of all the different types of major collections. - virtual double major_gc_interval_average_for_decay() const; - - public: - CMSAdaptiveSizePolicy(size_t init_eden_size, - size_t init_promo_size, - size_t init_survivor_size, - double max_gc_minor_pause_sec, - double max_gc_pause_sec, - uint gc_cost_ratio); - - // The timers for the stop-the-world phases measure a total - // stop-the-world time. The timer is started and stopped - // for each phase but is only reset after the final checkpoint. - void checkpoint_roots_initial_begin(); - void checkpoint_roots_initial_end(GCCause::Cause gc_cause); - void checkpoint_roots_final_begin(); - void checkpoint_roots_final_end(GCCause::Cause gc_cause); - - // Methods for gathering information about the - // concurrent marking phase of the collection. - // Records the mutator times and - // resets the concurrent timer. - void concurrent_marking_begin(); - // Resets concurrent phase timer in the begin methods and - // saves the time for a phase in the end methods. - void concurrent_marking_end(); - void concurrent_sweeping_begin(); - void concurrent_sweeping_end(); - // Similar to the above (e.g., concurrent_marking_end()) and - // is used for both the precleaning an abortable precleaning - // phases. - void concurrent_precleaning_begin(); - void concurrent_precleaning_end(); - // Stops the concurrent phases time. Gathers - // information and resets the timer. - void concurrent_phases_end(GCCause::Cause gc_cause, - size_t cur_eden, - size_t cur_promo); - - // Methods for gather information about STW Mark-Sweep-Compact - void msc_collection_begin(); - void msc_collection_end(GCCause::Cause gc_cause); - - // Methods for gather information about Mark-Sweep done - // in the foreground. - void ms_collection_begin(); - void ms_collection_end(GCCause::Cause gc_cause); - - // Cost for a mark-sweep tenured gen collection done in the foreground - double ms_gc_cost() const { - return MAX2(0.0F, _avg_ms_gc_cost->average()); - } - - // Cost of collecting the tenured generation. Includes - // concurrent collection and STW collection costs - double cms_gc_cost() const; - - // Cost of STW mark-sweep-compact tenured gen collection. - double msc_gc_cost() const { - return MAX2(0.0F, _avg_msc_gc_cost->average()); - } - - // - double compacting_gc_cost() const { - double result = MIN2(1.0, minor_gc_cost() + msc_gc_cost()); - assert(result >= 0.0, "Both minor and major costs are non-negative"); - return result; - } - - // Restarts the concurrent phases timer. - void concurrent_phases_resume(); - - // Time beginning and end of the marking phase for - // a synchronous MS collection. A MS collection - // that finishes in the foreground can have started - // in the background. These methods capture the - // completion of the marking (after the initial - // marking) that is done in the foreground. - void ms_collection_marking_begin(); - void ms_collection_marking_end(GCCause::Cause gc_cause); - - static elapsedTimer* concurrent_timer_ptr() { - return &_concurrent_timer; - } - - AdaptiveWeightedAverage* avg_cms_promo() const { - return _avg_cms_promo; - } - - int change_young_gen_for_maj_pauses() { - return _change_young_gen_for_maj_pauses; - } - void set_change_young_gen_for_maj_pauses(int v) { - _change_young_gen_for_maj_pauses = v; - } - - void clear_internal_time_intervals(); - - - // Either calculated_promo_size_in_bytes() or promo_size() - // should be deleted. - size_t promo_size() { return _promo_size; } - void set_promo_size(size_t v) { _promo_size = v; } - - // Cost of GC for all types of collections. - virtual double gc_cost() const; - - size_t generation_alignment() { return _generation_alignment; } - - virtual void compute_eden_space_size(size_t cur_eden, - size_t max_eden_size); - // Calculates new survivor space size; returns a new tenuring threshold - // value. Stores new survivor size in _survivor_size. - virtual uint compute_survivor_space_size_and_threshold( - bool is_survivor_overflow, - uint tenuring_threshold, - size_t survivor_limit); - - virtual void compute_tenured_generation_free_space(size_t cur_tenured_free, - size_t max_tenured_available, - size_t cur_eden); - - size_t eden_decrement_aligned_down(size_t cur_eden); - size_t eden_increment_aligned_up(size_t cur_eden); - - size_t adjust_eden_for_pause_time(size_t cur_eden); - size_t adjust_eden_for_throughput(size_t cur_eden); - size_t adjust_eden_for_footprint(size_t cur_eden); - - size_t promo_decrement_aligned_down(size_t cur_promo); - size_t promo_increment_aligned_up(size_t cur_promo); - - size_t adjust_promo_for_pause_time(size_t cur_promo); - size_t adjust_promo_for_throughput(size_t cur_promo); - size_t adjust_promo_for_footprint(size_t cur_promo, size_t cur_eden); - - // Scale down the input size by the ratio of the cost to collect the - // generation to the total GC cost. - size_t scale_by_gen_gc_cost(size_t base_change, double gen_gc_cost); - - // Return the value and clear it. - bool get_and_clear_first_after_collection(); - - // Printing support - virtual bool print_adaptive_size_policy_on(outputStream* st) const; -}; - -#endif // SHARE_VM_GC_IMPLEMENTATION_CONCURRENTMARKSWEEP_CMSADAPTIVESIZEPOLICY_HPP diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.cpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.cpp index 19d49f039a3..c2df7a29512 100644 --- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.cpp +++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.cpp @@ -23,9 +23,8 @@ */ #include "precompiled.hpp" -#include "gc_implementation/concurrentMarkSweep/cmsAdaptiveSizePolicy.hpp" +#include "gc_implementation/shared/adaptiveSizePolicy.hpp" #include "gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.hpp" -#include "gc_implementation/concurrentMarkSweep/cmsGCAdaptivePolicyCounters.hpp" #include "gc_implementation/parNew/parNewGeneration.hpp" #include "gc_implementation/shared/gcPolicyCounters.hpp" #include "gc_implementation/shared/vmGCOperations.hpp" @@ -57,25 +56,12 @@ void ConcurrentMarkSweepPolicy::initialize_generations() { if (_generations == NULL) vm_exit_during_initialization("Unable to allocate gen spec"); - if (UseParNewGC) { - if (UseAdaptiveSizePolicy) { - _generations[0] = new GenerationSpec(Generation::ASParNew, - _initial_young_size, _max_young_size); - } else { - _generations[0] = new GenerationSpec(Generation::ParNew, - _initial_young_size, _max_young_size); - } - } else { - _generations[0] = new GenerationSpec(Generation::DefNew, - _initial_young_size, _max_young_size); - } - if (UseAdaptiveSizePolicy) { - _generations[1] = new GenerationSpec(Generation::ASConcurrentMarkSweep, - _initial_old_size, _max_old_size); - } else { - _generations[1] = new GenerationSpec(Generation::ConcurrentMarkSweep, - _initial_old_size, _max_old_size); - } + Generation::Name yg_name = + UseParNewGC ? Generation::ParNew : Generation::DefNew; + _generations[0] = new GenerationSpec(yg_name, _initial_young_size, + _max_young_size); + _generations[1] = new GenerationSpec(Generation::ConcurrentMarkSweep, + _initial_old_size, _max_old_size); if (_generations[0] == NULL || _generations[1] == NULL) { vm_exit_during_initialization("Unable to allocate gen spec"); @@ -85,14 +71,12 @@ void ConcurrentMarkSweepPolicy::initialize_generations() { void ConcurrentMarkSweepPolicy::initialize_size_policy(size_t init_eden_size, size_t init_promo_size, size_t init_survivor_size) { - double max_gc_minor_pause_sec = ((double) MaxGCMinorPauseMillis)/1000.0; double max_gc_pause_sec = ((double) MaxGCPauseMillis)/1000.0; - _size_policy = new CMSAdaptiveSizePolicy(init_eden_size, - init_promo_size, - init_survivor_size, - max_gc_minor_pause_sec, - max_gc_pause_sec, - GCTimeRatio); + _size_policy = new AdaptiveSizePolicy(init_eden_size, + init_promo_size, + init_survivor_size, + max_gc_pause_sec, + GCTimeRatio); } void ConcurrentMarkSweepPolicy::initialize_gc_policy_counters() { @@ -110,22 +94,3 @@ bool ConcurrentMarkSweepPolicy::has_soft_ended_eden() { return CMSIncrementalMode; } - - -// -// ASConcurrentMarkSweepPolicy methods -// - -void ASConcurrentMarkSweepPolicy::initialize_gc_policy_counters() { - - assert(size_policy() != NULL, "A size policy is required"); - // initialize the policy counters - 2 collectors, 3 generations - if (UseParNewGC) { - _gc_policy_counters = new CMSGCAdaptivePolicyCounters("ParNew:CMS", 2, 3, - size_policy()); - } - else { - _gc_policy_counters = new CMSGCAdaptivePolicyCounters("Copy:CMS", 2, 3, - size_policy()); - } -} diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.hpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.hpp index aaa5a1bb770..24c59ac83ab 100644 --- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.hpp +++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.hpp @@ -47,19 +47,4 @@ class ConcurrentMarkSweepPolicy : public GenCollectorPolicy { virtual bool has_soft_ended_eden(); }; -class ASConcurrentMarkSweepPolicy : public ConcurrentMarkSweepPolicy { - public: - - // Initialize the jstat counters. This method requires a - // size policy. The size policy is expected to be created - // after the generations are fully initialized so the - // initialization of the counters need to be done post - // the initialization of the generations. - void initialize_gc_policy_counters(); - - virtual CollectorPolicy::Name kind() { - return CollectorPolicy::ASConcurrentMarkSweepPolicyKind; - } -}; - #endif // SHARE_VM_GC_IMPLEMENTATION_CONCURRENTMARKSWEEP_CMSCOLLECTORPOLICY_HPP diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsGCAdaptivePolicyCounters.cpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsGCAdaptivePolicyCounters.cpp deleted file mode 100644 index 8e633b65f15..00000000000 --- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsGCAdaptivePolicyCounters.cpp +++ /dev/null @@ -1,303 +0,0 @@ -/* - * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#include "precompiled.hpp" -#include "gc_implementation/concurrentMarkSweep/cmsGCAdaptivePolicyCounters.hpp" -#include "memory/resourceArea.hpp" - -CMSGCAdaptivePolicyCounters::CMSGCAdaptivePolicyCounters(const char* name_arg, - int collectors, - int generations, - AdaptiveSizePolicy* size_policy_arg) - : GCAdaptivePolicyCounters(name_arg, - collectors, - generations, - size_policy_arg) { - if (UsePerfData) { - EXCEPTION_MARK; - ResourceMark rm; - - const char* cname = - PerfDataManager::counter_name(name_space(), "cmsCapacity"); - _cms_capacity_counter = PerfDataManager::create_variable(SUN_GC, cname, - PerfData::U_Bytes, (jlong) OldSize, CHECK); -#ifdef NOT_PRODUCT - cname = - PerfDataManager::counter_name(name_space(), "initialPause"); - _initial_pause_counter = PerfDataManager::create_variable(SUN_GC, cname, - PerfData::U_Ticks, - (jlong) cms_size_policy()->avg_initial_pause()->last_sample(), - CHECK); - - cname = PerfDataManager::counter_name(name_space(), "remarkPause"); - _remark_pause_counter = PerfDataManager::create_variable(SUN_GC, cname, - PerfData::U_Ticks, - (jlong) cms_size_policy()->avg_remark_pause()->last_sample(), - CHECK); -#endif - cname = - PerfDataManager::counter_name(name_space(), "avgInitialPause"); - _avg_initial_pause_counter = PerfDataManager::create_variable(SUN_GC, cname, - PerfData::U_Ticks, - (jlong) cms_size_policy()->avg_initial_pause()->average(), - CHECK); - - cname = PerfDataManager::counter_name(name_space(), "avgRemarkPause"); - _avg_remark_pause_counter = PerfDataManager::create_variable(SUN_GC, cname, - PerfData::U_Ticks, - (jlong) cms_size_policy()->avg_remark_pause()->average(), - CHECK); - - cname = PerfDataManager::counter_name(name_space(), "avgSTWGcCost"); - _avg_cms_STW_gc_cost_counter = PerfDataManager::create_variable(SUN_GC, - cname, - PerfData::U_Ticks, - (jlong) cms_size_policy()->avg_cms_STW_gc_cost()->average(), - CHECK); - - cname = PerfDataManager::counter_name(name_space(), "avgSTWTime"); - _avg_cms_STW_time_counter = PerfDataManager::create_variable(SUN_GC, - cname, - PerfData::U_Ticks, - (jlong) cms_size_policy()->avg_cms_STW_time()->average(), - CHECK); - - - cname = PerfDataManager::counter_name(name_space(), "avgConcurrentTime"); - _avg_concurrent_time_counter = PerfDataManager::create_variable(SUN_GC, - cname, - PerfData::U_Ticks, - (jlong) cms_size_policy()->avg_concurrent_time()->average(), - CHECK); - - cname = - PerfDataManager::counter_name(name_space(), "avgConcurrentInterval"); - _avg_concurrent_interval_counter = PerfDataManager::create_variable(SUN_GC, - cname, - PerfData::U_Ticks, - (jlong) cms_size_policy()->avg_concurrent_interval()->average(), - CHECK); - - cname = PerfDataManager::counter_name(name_space(), "avgConcurrentGcCost"); - _avg_concurrent_gc_cost_counter = PerfDataManager::create_variable(SUN_GC, - cname, - PerfData::U_Ticks, - (jlong) cms_size_policy()->avg_concurrent_gc_cost()->average(), - CHECK); - - cname = PerfDataManager::counter_name(name_space(), "avgCMSFreeAtSweep"); - _avg_cms_free_at_sweep_counter = PerfDataManager::create_variable(SUN_GC, - cname, - PerfData::U_Ticks, - (jlong) cms_size_policy()->avg_cms_free_at_sweep()->average(), - CHECK); - - cname = PerfDataManager::counter_name(name_space(), "avgCMSFree"); - _avg_cms_free_counter = PerfDataManager::create_variable(SUN_GC, - cname, - PerfData::U_Ticks, - (jlong) cms_size_policy()->avg_cms_free()->average(), - CHECK); - - cname = PerfDataManager::counter_name(name_space(), "avgCMSPromo"); - _avg_cms_promo_counter = PerfDataManager::create_variable(SUN_GC, - cname, - PerfData::U_Ticks, - (jlong) cms_size_policy()->avg_cms_promo()->average(), - CHECK); - - cname = PerfDataManager::counter_name(name_space(), "avgMscPause"); - _avg_msc_pause_counter = PerfDataManager::create_variable(SUN_GC, - cname, - PerfData::U_Ticks, - (jlong) cms_size_policy()->avg_msc_pause()->average(), - CHECK); - - cname = PerfDataManager::counter_name(name_space(), "avgMscInterval"); - _avg_msc_interval_counter = PerfDataManager::create_variable(SUN_GC, - cname, - PerfData::U_Ticks, - (jlong) cms_size_policy()->avg_msc_interval()->average(), - CHECK); - - cname = PerfDataManager::counter_name(name_space(), "mscGcCost"); - _msc_gc_cost_counter = PerfDataManager::create_variable(SUN_GC, - cname, - PerfData::U_Ticks, - (jlong) cms_size_policy()->avg_msc_gc_cost()->average(), - CHECK); - - cname = PerfDataManager::counter_name(name_space(), "avgMsPause"); - _avg_ms_pause_counter = PerfDataManager::create_variable(SUN_GC, - cname, - PerfData::U_Ticks, - (jlong) cms_size_policy()->avg_ms_pause()->average(), - CHECK); - - cname = PerfDataManager::counter_name(name_space(), "avgMsInterval"); - _avg_ms_interval_counter = PerfDataManager::create_variable(SUN_GC, - cname, - PerfData::U_Ticks, - (jlong) cms_size_policy()->avg_ms_interval()->average(), - CHECK); - - cname = PerfDataManager::counter_name(name_space(), "msGcCost"); - _ms_gc_cost_counter = PerfDataManager::create_variable(SUN_GC, - cname, - PerfData::U_Ticks, - (jlong) cms_size_policy()->avg_ms_gc_cost()->average(), - CHECK); - - cname = PerfDataManager::counter_name(name_space(), "majorGcCost"); - _major_gc_cost_counter = PerfDataManager::create_variable(SUN_GC, cname, - PerfData::U_Ticks, (jlong) cms_size_policy()->cms_gc_cost(), CHECK); - - cname = PerfDataManager::counter_name(name_space(), "avgPromotedAvg"); - _promoted_avg_counter = - PerfDataManager::create_variable(SUN_GC, cname, PerfData::U_Bytes, - cms_size_policy()->calculated_promo_size_in_bytes(), CHECK); - - cname = PerfDataManager::counter_name(name_space(), "avgPromotedDev"); - _promoted_avg_dev_counter = - PerfDataManager::create_variable(SUN_GC, cname, PerfData::U_Bytes, - (jlong) 0 , CHECK); - - cname = PerfDataManager::counter_name(name_space(), "avgPromotedPaddedAvg"); - _promoted_padded_avg_counter = - PerfDataManager::create_variable(SUN_GC, cname, PerfData::U_Bytes, - cms_size_policy()->calculated_promo_size_in_bytes(), CHECK); - - cname = PerfDataManager::counter_name(name_space(), - "changeYoungGenForMajPauses"); - _change_young_gen_for_maj_pauses_counter = - PerfDataManager::create_variable(SUN_GC, cname, PerfData::U_Events, - (jlong)0, CHECK); - - cname = PerfDataManager::counter_name(name_space(), "remarkPauseOldSlope"); - _remark_pause_old_slope_counter = - PerfDataManager::create_variable(SUN_GC, cname, PerfData::U_Bytes, - (jlong) cms_size_policy()->remark_pause_old_slope(), CHECK); - - cname = PerfDataManager::counter_name(name_space(), "initialPauseOldSlope"); - _initial_pause_old_slope_counter = - PerfDataManager::create_variable(SUN_GC, cname, PerfData::U_Bytes, - (jlong) cms_size_policy()->initial_pause_old_slope(), CHECK); - - cname = - PerfDataManager::counter_name(name_space(), "remarkPauseYoungSlope") ; - _remark_pause_young_slope_counter = - PerfDataManager::create_variable(SUN_GC, cname, PerfData::U_Bytes, - (jlong) cms_size_policy()->remark_pause_young_slope(), CHECK); - - cname = - PerfDataManager::counter_name(name_space(), "initialPauseYoungSlope"); - _initial_pause_young_slope_counter = - PerfDataManager::create_variable(SUN_GC, cname, PerfData::U_Bytes, - (jlong) cms_size_policy()->initial_pause_young_slope(), CHECK); - - - } - assert(size_policy()->is_gc_cms_adaptive_size_policy(), - "Wrong type of size policy"); -} - -void CMSGCAdaptivePolicyCounters::update_counters() { - if (UsePerfData) { - GCAdaptivePolicyCounters::update_counters_from_policy(); - update_counters_from_policy(); - } -} - -void CMSGCAdaptivePolicyCounters::update_counters(CMSGCStats* gc_stats) { - if (UsePerfData) { - update_counters(); - update_promoted((size_t) gc_stats->avg_promoted()->last_sample()); - update_avg_promoted_avg(gc_stats); - update_avg_promoted_dev(gc_stats); - update_avg_promoted_padded_avg(gc_stats); - } -} - -void CMSGCAdaptivePolicyCounters::update_counters_from_policy() { - if (UsePerfData && (cms_size_policy() != NULL)) { - - GCAdaptivePolicyCounters::update_counters_from_policy(); - - update_major_gc_cost_counter(); - update_mutator_cost_counter(); - - update_eden_size(); - update_promo_size(); - - // If these updates from the last_sample() work, - // revise the update methods for these counters - // (both here and in PS). - update_survived((size_t) cms_size_policy()->avg_survived()->last_sample()); - - update_avg_concurrent_time_counter(); - update_avg_concurrent_interval_counter(); - update_avg_concurrent_gc_cost_counter(); -#ifdef NOT_PRODUCT - update_initial_pause_counter(); - update_remark_pause_counter(); -#endif - update_avg_initial_pause_counter(); - update_avg_remark_pause_counter(); - - update_avg_cms_STW_time_counter(); - update_avg_cms_STW_gc_cost_counter(); - - update_avg_cms_free_counter(); - update_avg_cms_free_at_sweep_counter(); - update_avg_cms_promo_counter(); - - update_avg_msc_pause_counter(); - update_avg_msc_interval_counter(); - update_msc_gc_cost_counter(); - - update_avg_ms_pause_counter(); - update_avg_ms_interval_counter(); - update_ms_gc_cost_counter(); - - update_avg_old_live_counter(); - - update_survivor_size_counters(); - update_avg_survived_avg_counters(); - update_avg_survived_dev_counters(); - - update_decrement_tenuring_threshold_for_gc_cost(); - update_increment_tenuring_threshold_for_gc_cost(); - update_decrement_tenuring_threshold_for_survivor_limit(); - - update_change_young_gen_for_maj_pauses(); - - update_major_collection_slope_counter(); - update_remark_pause_old_slope_counter(); - update_initial_pause_old_slope_counter(); - update_remark_pause_young_slope_counter(); - update_initial_pause_young_slope_counter(); - - update_decide_at_full_gc_counter(); - } -} diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsGCAdaptivePolicyCounters.hpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsGCAdaptivePolicyCounters.hpp deleted file mode 100644 index b6e91c1b349..00000000000 --- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsGCAdaptivePolicyCounters.hpp +++ /dev/null @@ -1,308 +0,0 @@ -/* - * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#ifndef SHARE_VM_GC_IMPLEMENTATION_CONCURRENTMARKSWEEP_CMSGCADAPTIVEPOLICYCOUNTERS_HPP -#define SHARE_VM_GC_IMPLEMENTATION_CONCURRENTMARKSWEEP_CMSGCADAPTIVEPOLICYCOUNTERS_HPP - -#include "gc_implementation/concurrentMarkSweep/cmsAdaptiveSizePolicy.hpp" -#include "gc_implementation/shared/gcAdaptivePolicyCounters.hpp" -#include "gc_implementation/shared/gcStats.hpp" -#include "runtime/perfData.hpp" - -// CMSGCAdaptivePolicyCounters is a holder class for performance counters -// that track the data and decisions for the ergonomics policy for the -// concurrent mark sweep collector - -class CMSGCAdaptivePolicyCounters : public GCAdaptivePolicyCounters { - friend class VMStructs; - - private: - - // Capacity of tenured generation recorded at the end of - // any collection. - PerfVariable* _cms_capacity_counter; // Make this common with PS _old_capacity - - // Average stop-the-world pause time for both initial and - // remark pauses sampled at the end of the checkpointRootsFinalWork. - PerfVariable* _avg_cms_STW_time_counter; - // Average stop-the-world (STW) GC cost for the STW pause time - // _avg_cms_STW_time_counter. - PerfVariable* _avg_cms_STW_gc_cost_counter; - -#ifdef NOT_PRODUCT - // These are useful to see how the most recent values of these - // counters compare to their respective averages but - // do not control behavior. - PerfVariable* _initial_pause_counter; - PerfVariable* _remark_pause_counter; -#endif - - // Average of the initial marking pause for a concurrent collection. - PerfVariable* _avg_initial_pause_counter; - // Average of the remark pause for a concurrent collection. - PerfVariable* _avg_remark_pause_counter; - - // Average for the sum of all the concurrent times per collection. - PerfVariable* _avg_concurrent_time_counter; - // Average for the time between the most recent end of a - // concurrent collection and the beginning of the next - // concurrent collection. - PerfVariable* _avg_concurrent_interval_counter; - // Average of the concurrent GC costs based on _avg_concurrent_time_counter - // and _avg_concurrent_interval_counter. - PerfVariable* _avg_concurrent_gc_cost_counter; - - // Average of the free space in the tenured generation at the - // end of the sweep of the tenured generation. - PerfVariable* _avg_cms_free_counter; - // Average of the free space in the tenured generation at the - // start of the sweep of the tenured generation. - PerfVariable* _avg_cms_free_at_sweep_counter; - // Average of the free space in the tenured generation at the - // after any resizing of the tenured generation at the end - // of a collection of the tenured generation. - PerfVariable* _avg_cms_promo_counter; - - // Average of the mark-sweep-compact (MSC) pause time for a collection - // of the tenured generation. - PerfVariable* _avg_msc_pause_counter; - // Average for the time between the most recent end of a - // MSC collection and the beginning of the next MSC collection. - PerfVariable* _avg_msc_interval_counter; - // Average for the GC cost of a MSC collection based on - // _avg_msc_pause_counter and _avg_msc_interval_counter. - PerfVariable* _msc_gc_cost_counter; - - // Average of the mark-sweep (MS) pause time for a collection - // of the tenured generation. - PerfVariable* _avg_ms_pause_counter; - // Average for the time between the most recent end of a - // MS collection and the beginning of the next MS collection. - PerfVariable* _avg_ms_interval_counter; - // Average for the GC cost of a MS collection based on - // _avg_ms_pause_counter and _avg_ms_interval_counter. - PerfVariable* _ms_gc_cost_counter; - - // Average of the bytes promoted per minor collection. - PerfVariable* _promoted_avg_counter; - // Average of the deviation of the promoted average. - PerfVariable* _promoted_avg_dev_counter; - // Padded average of the bytes promoted per minor collection. - PerfVariable* _promoted_padded_avg_counter; - - // See description of the _change_young_gen_for_maj_pauses - // variable recently in cmsAdaptiveSizePolicy.hpp. - PerfVariable* _change_young_gen_for_maj_pauses_counter; - - // See descriptions of _remark_pause_old_slope, _initial_pause_old_slope, - // etc. variables recently in cmsAdaptiveSizePolicy.hpp. - PerfVariable* _remark_pause_old_slope_counter; - PerfVariable* _initial_pause_old_slope_counter; - PerfVariable* _remark_pause_young_slope_counter; - PerfVariable* _initial_pause_young_slope_counter; - - CMSAdaptiveSizePolicy* cms_size_policy() { - assert(_size_policy->kind() == - AdaptiveSizePolicy::_gc_cms_adaptive_size_policy, - "Wrong size policy"); - return (CMSAdaptiveSizePolicy*)_size_policy; - } - - inline void update_avg_cms_STW_time_counter() { - _avg_cms_STW_time_counter->set_value( - (jlong) (cms_size_policy()->avg_cms_STW_time()->average() * - (double) MILLIUNITS)); - } - - inline void update_avg_cms_STW_gc_cost_counter() { - _avg_cms_STW_gc_cost_counter->set_value( - (jlong) (cms_size_policy()->avg_cms_STW_gc_cost()->average() * 100.0)); - } - - inline void update_avg_initial_pause_counter() { - _avg_initial_pause_counter->set_value( - (jlong) (cms_size_policy()->avg_initial_pause()->average() * - (double) MILLIUNITS)); - } -#ifdef NOT_PRODUCT - inline void update_avg_remark_pause_counter() { - _avg_remark_pause_counter->set_value( - (jlong) (cms_size_policy()-> avg_remark_pause()->average() * - (double) MILLIUNITS)); - } - - inline void update_initial_pause_counter() { - _initial_pause_counter->set_value( - (jlong) (cms_size_policy()->avg_initial_pause()->average() * - (double) MILLIUNITS)); - } -#endif - inline void update_remark_pause_counter() { - _remark_pause_counter->set_value( - (jlong) (cms_size_policy()-> avg_remark_pause()->last_sample() * - (double) MILLIUNITS)); - } - - inline void update_avg_concurrent_time_counter() { - _avg_concurrent_time_counter->set_value( - (jlong) (cms_size_policy()->avg_concurrent_time()->last_sample() * - (double) MILLIUNITS)); - } - - inline void update_avg_concurrent_interval_counter() { - _avg_concurrent_interval_counter->set_value( - (jlong) (cms_size_policy()->avg_concurrent_interval()->average() * - (double) MILLIUNITS)); - } - - inline void update_avg_concurrent_gc_cost_counter() { - _avg_concurrent_gc_cost_counter->set_value( - (jlong) (cms_size_policy()->avg_concurrent_gc_cost()->average() * 100.0)); - } - - inline void update_avg_cms_free_counter() { - _avg_cms_free_counter->set_value( - (jlong) cms_size_policy()->avg_cms_free()->average()); - } - - inline void update_avg_cms_free_at_sweep_counter() { - _avg_cms_free_at_sweep_counter->set_value( - (jlong) cms_size_policy()->avg_cms_free_at_sweep()->average()); - } - - inline void update_avg_cms_promo_counter() { - _avg_cms_promo_counter->set_value( - (jlong) cms_size_policy()->avg_cms_promo()->average()); - } - - inline void update_avg_old_live_counter() { - _avg_old_live_counter->set_value( - (jlong)(cms_size_policy()->avg_old_live()->average()) - ); - } - - inline void update_avg_msc_pause_counter() { - _avg_msc_pause_counter->set_value( - (jlong) (cms_size_policy()->avg_msc_pause()->average() * - (double) MILLIUNITS)); - } - - inline void update_avg_msc_interval_counter() { - _avg_msc_interval_counter->set_value( - (jlong) (cms_size_policy()->avg_msc_interval()->average() * - (double) MILLIUNITS)); - } - - inline void update_msc_gc_cost_counter() { - _msc_gc_cost_counter->set_value( - (jlong) (cms_size_policy()->avg_msc_gc_cost()->average() * 100.0)); - } - - inline void update_avg_ms_pause_counter() { - _avg_ms_pause_counter->set_value( - (jlong) (cms_size_policy()->avg_ms_pause()->average() * - (double) MILLIUNITS)); - } - - inline void update_avg_ms_interval_counter() { - _avg_ms_interval_counter->set_value( - (jlong) (cms_size_policy()->avg_ms_interval()->average() * - (double) MILLIUNITS)); - } - - inline void update_ms_gc_cost_counter() { - _ms_gc_cost_counter->set_value( - (jlong) (cms_size_policy()->avg_ms_gc_cost()->average() * 100.0)); - } - - inline void update_major_gc_cost_counter() { - _major_gc_cost_counter->set_value( - (jlong)(cms_size_policy()->cms_gc_cost() * 100.0) - ); - } - inline void update_mutator_cost_counter() { - _mutator_cost_counter->set_value( - (jlong)(cms_size_policy()->mutator_cost() * 100.0) - ); - } - - inline void update_avg_promoted_avg(CMSGCStats* gc_stats) { - _promoted_avg_counter->set_value( - (jlong)(gc_stats->avg_promoted()->average()) - ); - } - inline void update_avg_promoted_dev(CMSGCStats* gc_stats) { - _promoted_avg_dev_counter->set_value( - (jlong)(gc_stats->avg_promoted()->deviation()) - ); - } - inline void update_avg_promoted_padded_avg(CMSGCStats* gc_stats) { - _promoted_padded_avg_counter->set_value( - (jlong)(gc_stats->avg_promoted()->padded_average()) - ); - } - inline void update_remark_pause_old_slope_counter() { - _remark_pause_old_slope_counter->set_value( - (jlong)(cms_size_policy()->remark_pause_old_slope() * 1000) - ); - } - inline void update_initial_pause_old_slope_counter() { - _initial_pause_old_slope_counter->set_value( - (jlong)(cms_size_policy()->initial_pause_old_slope() * 1000) - ); - } - inline void update_remark_pause_young_slope_counter() { - _remark_pause_young_slope_counter->set_value( - (jlong)(cms_size_policy()->remark_pause_young_slope() * 1000) - ); - } - inline void update_initial_pause_young_slope_counter() { - _initial_pause_young_slope_counter->set_value( - (jlong)(cms_size_policy()->initial_pause_young_slope() * 1000) - ); - } - inline void update_change_young_gen_for_maj_pauses() { - _change_young_gen_for_maj_pauses_counter->set_value( - cms_size_policy()->change_young_gen_for_maj_pauses()); - } - - public: - CMSGCAdaptivePolicyCounters(const char* name, int collectors, int generations, - AdaptiveSizePolicy* size_policy); - - // update counters - void update_counters(); - void update_counters(CMSGCStats* gc_stats); - void update_counters_from_policy(); - - inline void update_cms_capacity_counter(size_t size_in_bytes) { - _cms_capacity_counter->set_value(size_in_bytes); - } - - virtual GCPolicyCounters::Name kind() const { - return GCPolicyCounters::CMSGCAdaptivePolicyCountersKind; - } -}; - -#endif // SHARE_VM_GC_IMPLEMENTATION_CONCURRENTMARKSWEEP_CMSGCADAPTIVEPOLICYCOUNTERS_HPP diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp index e1d5e29a84b..ba2ff9c55ff 100644 --- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp +++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp @@ -70,7 +70,6 @@ class LinearAllocBlock VALUE_OBJ_CLASS_SPEC { class CompactibleFreeListSpace: public CompactibleSpace { friend class VMStructs; friend class ConcurrentMarkSweepGeneration; - friend class ASConcurrentMarkSweepGeneration; friend class CMSCollector; // Local alloc buffer for promotion into this space. friend class CFLS_LAB; diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp index c0daf2c32ec..7dbc7f1d503 100644 --- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp +++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp @@ -27,9 +27,8 @@ #include "classfile/stringTable.hpp" #include "classfile/systemDictionary.hpp" #include "code/codeCache.hpp" -#include "gc_implementation/concurrentMarkSweep/cmsAdaptiveSizePolicy.hpp" +#include "gc_implementation/shared/adaptiveSizePolicy.hpp" #include "gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.hpp" -#include "gc_implementation/concurrentMarkSweep/cmsGCAdaptivePolicyCounters.hpp" #include "gc_implementation/concurrentMarkSweep/cmsOopClosures.inline.hpp" #include "gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp" #include "gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.inline.hpp" @@ -319,27 +318,13 @@ void CMSCollector::ref_processor_init() { } } -CMSAdaptiveSizePolicy* CMSCollector::size_policy() { +AdaptiveSizePolicy* CMSCollector::size_policy() { GenCollectedHeap* gch = GenCollectedHeap::heap(); assert(gch->kind() == CollectedHeap::GenCollectedHeap, "Wrong type of heap"); - CMSAdaptiveSizePolicy* sp = (CMSAdaptiveSizePolicy*) - gch->gen_policy()->size_policy(); - assert(sp->is_gc_cms_adaptive_size_policy(), - "Wrong type of size policy"); - return sp; + return gch->gen_policy()->size_policy(); } -CMSGCAdaptivePolicyCounters* CMSCollector::gc_adaptive_policy_counters() { - CMSGCAdaptivePolicyCounters* results = - (CMSGCAdaptivePolicyCounters*) collector_policy()->counters(); - assert( - results->kind() == GCPolicyCounters::CMSGCAdaptivePolicyCountersKind, - "Wrong gc policy counter kind"); - return results; -} - - void ConcurrentMarkSweepGeneration::initialize_performance_counters() { const char* gen_name = "old"; @@ -1573,11 +1558,11 @@ bool CMSCollector::shouldConcurrentCollect() { } if (MetaspaceGC::should_concurrent_collect()) { - if (Verbose && PrintGCDetails) { + if (Verbose && PrintGCDetails) { gclog_or_tty->print("CMSCollector: collect for metadata allocation "); - } - return true; } + return true; + } // CMSTriggerInterval starts a CMS cycle if enough time has passed. if (CMSTriggerInterval >= 0) { @@ -2031,11 +2016,6 @@ void CMSCollector::do_compaction_work(bool clear_all_soft_refs) { "collections passed to foreground collector", _full_gcs_since_conc_gc); } - // Sample collection interval time and reset for collection pause. - if (UseAdaptiveSizePolicy) { - size_policy()->msc_collection_begin(); - } - // Temporarily widen the span of the weak reference processing to // the entire heap. MemRegion new_span(GenCollectedHeap::heap()->reserved_region()); @@ -2111,11 +2091,6 @@ void CMSCollector::do_compaction_work(bool clear_all_soft_refs) { _inter_sweep_timer.reset(); _inter_sweep_timer.start(); - // Sample collection pause time and reset for collection interval. - if (UseAdaptiveSizePolicy) { - size_policy()->msc_collection_end(gch->gc_cause()); - } - gc_timer->register_gc_end(); gc_tracer->report_gc_end(gc_timer->gc_end(), gc_timer->time_partitions()); @@ -2373,26 +2348,14 @@ void CMSCollector::collect_in_background(bool clear_all_soft_refs, GCCause::Caus } break; case Precleaning: - if (UseAdaptiveSizePolicy) { - size_policy()->concurrent_precleaning_begin(); - } // marking from roots in markFromRoots has been completed preclean(); - if (UseAdaptiveSizePolicy) { - size_policy()->concurrent_precleaning_end(); - } assert(_collectorState == AbortablePreclean || _collectorState == FinalMarking, "Collector state should have changed"); break; case AbortablePreclean: - if (UseAdaptiveSizePolicy) { - size_policy()->concurrent_phases_resume(); - } abortable_preclean(); - if (UseAdaptiveSizePolicy) { - size_policy()->concurrent_precleaning_end(); - } assert(_collectorState == FinalMarking, "Collector state should " "have changed"); break; @@ -2406,23 +2369,12 @@ void CMSCollector::collect_in_background(bool clear_all_soft_refs, GCCause::Caus assert(_foregroundGCShouldWait, "block post-condition"); break; case Sweeping: - if (UseAdaptiveSizePolicy) { - size_policy()->concurrent_sweeping_begin(); - } // final marking in checkpointRootsFinal has been completed sweep(true); assert(_collectorState == Resizing, "Collector state change " "to Resizing must be done under the free_list_lock"); _full_gcs_since_conc_gc = 0; - // Stop the timers for adaptive size policy for the concurrent phases - if (UseAdaptiveSizePolicy) { - size_policy()->concurrent_sweeping_end(); - size_policy()->concurrent_phases_end(gch->gc_cause(), - gch->prev_gen(_cmsGen)->capacity(), - _cmsGen->free()); - } - case Resizing: { // Sweeping has been completed... // At this point the background collection has completed. @@ -2539,9 +2491,6 @@ void CMSCollector::collect_in_foreground(bool clear_all_soft_refs, GCCause::Caus const GCId gc_id = _collectorState == InitialMarking ? GCId::peek() : _gc_tracer_cm->gc_id(); NOT_PRODUCT(GCTraceTime t("CMS:MS (foreground) ", PrintGCDetails && Verbose, true, NULL, gc_id);) - if (UseAdaptiveSizePolicy) { - size_policy()->ms_collection_begin(); - } COMPILER2_PRESENT(DerivedPointerTableDeactivate dpt_deact); HandleMark hm; // Discard invalid handles created during verification @@ -2633,11 +2582,6 @@ void CMSCollector::collect_in_foreground(bool clear_all_soft_refs, GCCause::Caus } } - if (UseAdaptiveSizePolicy) { - GenCollectedHeap* gch = GenCollectedHeap::heap(); - size_policy()->ms_collection_end(gch->gc_cause()); - } - if (VerifyAfterGC && GenCollectedHeap::heap()->total_collections() >= VerifyGCStartAt) { Universe::verify(); @@ -3053,20 +2997,21 @@ void CMSCollector::verify_after_remark_work_1() { HandleMark hm; GenCollectedHeap* gch = GenCollectedHeap::heap(); - // Get a clear set of claim bits for the strong roots processing to work with. + // Get a clear set of claim bits for the roots processing to work with. ClassLoaderDataGraph::clear_claimed_marks(); // Mark from roots one level into CMS MarkRefsIntoClosure notOlder(_span, verification_mark_bm()); gch->rem_set()->prepare_for_younger_refs_iterate(false); // Not parallel. - gch->gen_process_strong_roots(_cmsGen->level(), - true, // younger gens are roots - true, // activate StrongRootsScope - SharedHeap::ScanningOption(roots_scanning_options()), - ¬Older, - NULL, - NULL); // SSS: Provide correct closure + gch->gen_process_roots(_cmsGen->level(), + true, // younger gens are roots + true, // activate StrongRootsScope + SharedHeap::ScanningOption(roots_scanning_options()), + should_unload_classes(), + ¬Older, + NULL, + NULL); // SSS: Provide correct closure // Now mark from the roots MarkFromRootsClosure markFromRootsClosure(this, _span, @@ -3117,22 +3062,24 @@ void CMSCollector::verify_after_remark_work_2() { HandleMark hm; GenCollectedHeap* gch = GenCollectedHeap::heap(); - // Get a clear set of claim bits for the strong roots processing to work with. + // Get a clear set of claim bits for the roots processing to work with. ClassLoaderDataGraph::clear_claimed_marks(); // Mark from roots one level into CMS MarkRefsIntoVerifyClosure notOlder(_span, verification_mark_bm(), markBitMap()); - KlassToOopClosure klass_closure(¬Older); + CLDToOopClosure cld_closure(¬Older, true); gch->rem_set()->prepare_for_younger_refs_iterate(false); // Not parallel. - gch->gen_process_strong_roots(_cmsGen->level(), - true, // younger gens are roots - true, // activate StrongRootsScope - SharedHeap::ScanningOption(roots_scanning_options()), - ¬Older, - NULL, - &klass_closure); + + gch->gen_process_roots(_cmsGen->level(), + true, // younger gens are roots + true, // activate StrongRootsScope + SharedHeap::ScanningOption(roots_scanning_options()), + should_unload_classes(), + ¬Older, + NULL, + &cld_closure); // Now mark from the roots MarkFromRootsVerifyClosure markFromRootsClosure(this, _span, @@ -3319,12 +3266,10 @@ bool ConcurrentMarkSweepGeneration::is_too_full() const { void CMSCollector::setup_cms_unloading_and_verification_state() { const bool should_verify = VerifyBeforeGC || VerifyAfterGC || VerifyDuringGC || VerifyBeforeExit; - const int rso = SharedHeap::SO_Strings | SharedHeap::SO_AllCodeCache; + const int rso = SharedHeap::SO_AllCodeCache; // We set the proper root for this CMS cycle here. if (should_unload_classes()) { // Should unload classes this cycle - remove_root_scanning_option(SharedHeap::SO_AllClasses); - add_root_scanning_option(SharedHeap::SO_SystemClasses); remove_root_scanning_option(rso); // Shrink the root set appropriately set_verifying(should_verify); // Set verification state for this cycle return; // Nothing else needs to be done at this time @@ -3332,8 +3277,6 @@ void CMSCollector::setup_cms_unloading_and_verification_state() { // Not unloading classes this cycle assert(!should_unload_classes(), "Inconsistency!"); - remove_root_scanning_option(SharedHeap::SO_SystemClasses); - add_root_scanning_option(SharedHeap::SO_AllClasses); if ((!verifying() || unloaded_classes_last_cycle()) && should_verify) { // Include symbols, strings and code cache elements to prevent their resurrection. @@ -3687,9 +3630,6 @@ void CMSCollector::checkpointRootsInitialWork(bool asynch) { NOT_PRODUCT(GCTraceTime t("\ncheckpointRootsInitialWork", PrintGCDetails && Verbose, true, _gc_timer_cm, _gc_tracer_cm->gc_id());) - if (UseAdaptiveSizePolicy) { - size_policy()->checkpoint_roots_initial_begin(); - } // Reset all the PLAB chunk arrays if necessary. if (_survivor_plab_array != NULL && !CMSPLABRecordAlways) { @@ -3744,15 +3684,16 @@ void CMSCollector::checkpointRootsInitialWork(bool asynch) { gch->set_par_threads(0); } else { // The serial version. - KlassToOopClosure klass_closure(¬Older); + CLDToOopClosure cld_closure(¬Older, true); gch->rem_set()->prepare_for_younger_refs_iterate(false); // Not parallel. - gch->gen_process_strong_roots(_cmsGen->level(), - true, // younger gens are roots - true, // activate StrongRootsScope - SharedHeap::ScanningOption(roots_scanning_options()), - ¬Older, - NULL, - &klass_closure); + gch->gen_process_roots(_cmsGen->level(), + true, // younger gens are roots + true, // activate StrongRootsScope + SharedHeap::ScanningOption(roots_scanning_options()), + should_unload_classes(), + ¬Older, + NULL, + &cld_closure); } } @@ -3769,9 +3710,6 @@ void CMSCollector::checkpointRootsInitialWork(bool asynch) { // Save the end of the used_region of the constituent generations // to be used to limit the extent of sweep in each generation. save_sweep_limits(); - if (UseAdaptiveSizePolicy) { - size_policy()->checkpoint_roots_initial_end(gch->gc_cause()); - } verify_overflow_empty(); } @@ -3788,15 +3726,6 @@ bool CMSCollector::markFromRoots(bool asynch) { bool res; if (asynch) { - - // Start the timers for adaptive size policy for the concurrent phases - // Do it here so that the foreground MS can use the concurrent - // timer since a foreground MS might has the sweep done concurrently - // or STW. - if (UseAdaptiveSizePolicy) { - size_policy()->concurrent_marking_begin(); - } - // Weak ref discovery note: We may be discovering weak // refs in this generation concurrent (but interleaved) with // weak ref discovery by a younger generation collector. @@ -3814,22 +3743,12 @@ bool CMSCollector::markFromRoots(bool asynch) { gclog_or_tty->print_cr("bailing out to foreground collection"); } } - if (UseAdaptiveSizePolicy) { - size_policy()->concurrent_marking_end(); - } } else { assert(SafepointSynchronize::is_at_safepoint(), "inconsistent with asynch == false"); - if (UseAdaptiveSizePolicy) { - size_policy()->ms_collection_marking_begin(); - } // already have locks res = markFromRootsWork(asynch); _collectorState = FinalMarking; - if (UseAdaptiveSizePolicy) { - GenCollectedHeap* gch = GenCollectedHeap::heap(); - size_policy()->ms_collection_marking_end(gch->gc_cause()); - } } verify_overflow_empty(); return res; @@ -4705,8 +4624,7 @@ size_t CMSCollector::preclean_work(bool clean_refs, bool clean_survivor) { if (clean_survivor) { // preclean the active survivor space(s) assert(_young_gen->kind() == Generation::DefNew || - _young_gen->kind() == Generation::ParNew || - _young_gen->kind() == Generation::ASParNew, + _young_gen->kind() == Generation::ParNew, "incorrect type for cast"); DefNewGeneration* dng = (DefNewGeneration*)_young_gen; PushAndMarkClosure pam_cl(this, _span, ref_processor(), @@ -5077,10 +4995,6 @@ void CMSCollector::checkpointRootsFinalWork(bool asynch, assert(haveFreelistLocks(), "must have free list locks"); assert_lock_strong(bitMapLock()); - if (UseAdaptiveSizePolicy) { - size_policy()->checkpoint_roots_final_begin(); - } - ResourceMark rm; HandleMark hm; @@ -5214,9 +5128,6 @@ void CMSCollector::checkpointRootsFinalWork(bool asynch, "Should be clear by end of the final marking"); assert(_ct->klass_rem_set()->mod_union_is_clear(), "Should be clear by end of the final marking"); - if (UseAdaptiveSizePolicy) { - size_policy()->checkpoint_roots_final_end(gch->gc_cause()); - } } void CMSParInitialMarkTask::work(uint worker_id) { @@ -5228,7 +5139,6 @@ void CMSParInitialMarkTask::work(uint worker_id) { _timer.start(); GenCollectedHeap* gch = GenCollectedHeap::heap(); Par_MarkRefsIntoClosure par_mri_cl(_collector->_span, &(_collector->_markBitMap)); - KlassToOopClosure klass_closure(&par_mri_cl); // ---------- young gen roots -------------- { @@ -5244,13 +5154,17 @@ void CMSParInitialMarkTask::work(uint worker_id) { // ---------- remaining roots -------------- _timer.reset(); _timer.start(); - gch->gen_process_strong_roots(_collector->_cmsGen->level(), - false, // yg was scanned above - false, // this is parallel code - SharedHeap::ScanningOption(_collector->CMSCollector::roots_scanning_options()), - &par_mri_cl, - NULL, - &klass_closure); + + CLDToOopClosure cld_closure(&par_mri_cl, true); + + gch->gen_process_roots(_collector->_cmsGen->level(), + false, // yg was scanned above + false, // this is parallel code + SharedHeap::ScanningOption(_collector->CMSCollector::roots_scanning_options()), + _collector->should_unload_classes(), + &par_mri_cl, + NULL, + &cld_closure); assert(_collector->should_unload_classes() || (_collector->CMSCollector::roots_scanning_options() & SharedHeap::SO_AllCodeCache), "if we didn't scan the code cache, we have to be ready to drop nmethods with expired weak oops"); @@ -5379,13 +5293,15 @@ void CMSParRemarkTask::work(uint worker_id) { // ---------- remaining roots -------------- _timer.reset(); _timer.start(); - gch->gen_process_strong_roots(_collector->_cmsGen->level(), - false, // yg was scanned above - false, // this is parallel code - SharedHeap::ScanningOption(_collector->CMSCollector::roots_scanning_options()), - &par_mrias_cl, - NULL, - NULL); // The dirty klasses will be handled below + gch->gen_process_roots(_collector->_cmsGen->level(), + false, // yg was scanned above + false, // this is parallel code + SharedHeap::ScanningOption(_collector->CMSCollector::roots_scanning_options()), + _collector->should_unload_classes(), + &par_mrias_cl, + NULL, + NULL); // The dirty klasses will be handled below + assert(_collector->should_unload_classes() || (_collector->CMSCollector::roots_scanning_options() & SharedHeap::SO_AllCodeCache), "if we didn't scan the code cache, we have to be ready to drop nmethods with expired weak oops"); @@ -5440,7 +5356,7 @@ void CMSParRemarkTask::work(uint worker_id) { // We might have added oops to ClassLoaderData::_handles during the // concurrent marking phase. These oops point to newly allocated objects // that are guaranteed to be kept alive. Either by the direct allocation - // code, or when the young collector processes the strong roots. Hence, + // code, or when the young collector processes the roots. Hence, // we don't have to revisit the _handles block during the remark phase. // ---------- rescan dirty cards ------------ @@ -5862,7 +5778,7 @@ void CMSCollector::do_remark_parallel() { cms_space, n_workers, workers, task_queues()); - // Set up for parallel process_strong_roots work. + // Set up for parallel process_roots work. gch->set_par_threads(n_workers); // We won't be iterating over the cards in the card table updating // the younger_gen cards, so we shouldn't call the following else @@ -5871,7 +5787,7 @@ void CMSCollector::do_remark_parallel() { // gch->rem_set()->prepare_for_younger_refs_iterate(true); // parallel // The young gen rescan work will not be done as part of - // process_strong_roots (which currently doesn't knw how to + // process_roots (which currently doesn't know how to // parallelize such a scan), but rather will be broken up into // a set of parallel tasks (via the sampling that the [abortable] // preclean phase did of EdenSpace, plus the [two] tasks of @@ -5968,13 +5884,15 @@ void CMSCollector::do_remark_non_parallel() { gch->rem_set()->prepare_for_younger_refs_iterate(false); // Not parallel. GenCollectedHeap::StrongRootsScope srs(gch); - gch->gen_process_strong_roots(_cmsGen->level(), - true, // younger gens as roots - false, // use the local StrongRootsScope - SharedHeap::ScanningOption(roots_scanning_options()), - &mrias_cl, - NULL, - NULL); // The dirty klasses will be handled below + + gch->gen_process_roots(_cmsGen->level(), + true, // younger gens as roots + false, // use the local StrongRootsScope + SharedHeap::ScanningOption(roots_scanning_options()), + should_unload_classes(), + &mrias_cl, + NULL, + NULL); // The dirty klasses will be handled below assert(should_unload_classes() || (roots_scanning_options() & SharedHeap::SO_AllCodeCache), @@ -6014,7 +5932,7 @@ void CMSCollector::do_remark_non_parallel() { // We might have added oops to ClassLoaderData::_handles during the // concurrent marking phase. These oops point to newly allocated objects // that are guaranteed to be kept alive. Either by the direct allocation - // code, or when the young collector processes the strong roots. Hence, + // code, or when the young collector processes the roots. Hence, // we don't have to revisit the _handles block during the remark phase. verify_work_stacks_empty(); @@ -6264,15 +6182,14 @@ void CMSCollector::refProcessingWork(bool asynch, bool clear_all_soft_refs) { // Clean up unreferenced symbols in symbol table. SymbolTable::unlink(); } + + { + GCTraceTime t("scrub string table", PrintGCDetails, false, _gc_timer_cm, _gc_tracer_cm->gc_id()); + // Delete entries for dead interned strings. + StringTable::unlink(&_is_alive_closure); + } } - // CMS doesn't use the StringTable as hard roots when class unloading is turned off. - // Need to check if we really scanned the StringTable. - if ((roots_scanning_options() & SharedHeap::SO_Strings) == 0) { - GCTraceTime t("scrub string table", PrintGCDetails, false, _gc_timer_cm, _gc_tracer_cm->gc_id()); - // Delete entries for dead interned strings. - StringTable::unlink(&_is_alive_closure); - } // Restore any preserved marks as a result of mark stack or // work queue overflow @@ -6329,7 +6246,6 @@ void CMSCollector::sweep(bool asynch) { _inter_sweep_timer.stop(); _inter_sweep_estimate.sample(_inter_sweep_timer.seconds()); - size_policy()->avg_cms_free_at_sweep()->sample(_cmsGen->free()); assert(!_intra_sweep_timer.is_active(), "Should not be active"); _intra_sweep_timer.reset(); @@ -6454,17 +6370,6 @@ void ConcurrentMarkSweepGeneration::update_gc_stats(int current_level, } } -CMSAdaptiveSizePolicy* ConcurrentMarkSweepGeneration::size_policy() { - GenCollectedHeap* gch = GenCollectedHeap::heap(); - assert(gch->kind() == CollectedHeap::GenCollectedHeap, - "Wrong type of heap"); - CMSAdaptiveSizePolicy* sp = (CMSAdaptiveSizePolicy*) - gch->gen_policy()->size_policy(); - assert(sp->is_gc_cms_adaptive_size_policy(), - "Wrong type of size policy"); - return sp; -} - void ConcurrentMarkSweepGeneration::rotate_debug_collection_type() { if (PrintGCDetails && Verbose) { gclog_or_tty->print("Rotate from %d ", _debug_collection_type); @@ -6540,9 +6445,6 @@ void CMSCollector::sweepWork(ConcurrentMarkSweepGeneration* gen, // Reset CMS data structures (for now just the marking bit map) // preparatory for the next cycle. void CMSCollector::reset(bool asynch) { - GenCollectedHeap* gch = GenCollectedHeap::heap(); - CMSAdaptiveSizePolicy* sp = size_policy(); - AdaptiveSizePolicyOutput(sp, gch->total_collections()); if (asynch) { CMSTokenSyncWithLocks ts(true, bitMapLock()); @@ -6597,7 +6499,7 @@ void CMSCollector::reset(bool asynch) { // Because only the full (i.e., concurrent mode failure) collections // are being measured for gc overhead limits, clean the "near" flag // and count. - sp->reset_gc_overhead_limit_count(); + size_policy()->reset_gc_overhead_limit_count(); _collectorState = Idling; } else { // already have the lock @@ -7064,7 +6966,6 @@ void MarkRefsIntoAndScanClosure::do_yield_work() { ConcurrentMarkSweepThread::desynchronize(true); ConcurrentMarkSweepThread::acknowledge_yield_request(); _collector->stopTimer(); - GCPauseTimer p(_collector->size_policy()->concurrent_timer_ptr()); if (PrintCMSStatistics != 0) { _collector->incrementYields(); } @@ -7225,7 +7126,6 @@ void ScanMarkedObjectsAgainCarefullyClosure::do_yield_work() { ConcurrentMarkSweepThread::desynchronize(true); ConcurrentMarkSweepThread::acknowledge_yield_request(); _collector->stopTimer(); - GCPauseTimer p(_collector->size_policy()->concurrent_timer_ptr()); if (PrintCMSStatistics != 0) { _collector->incrementYields(); } @@ -7298,7 +7198,6 @@ void SurvivorSpacePrecleanClosure::do_yield_work() { ConcurrentMarkSweepThread::desynchronize(true); ConcurrentMarkSweepThread::acknowledge_yield_request(); _collector->stopTimer(); - GCPauseTimer p(_collector->size_policy()->concurrent_timer_ptr()); if (PrintCMSStatistics != 0) { _collector->incrementYields(); } @@ -7457,7 +7356,6 @@ void MarkFromRootsClosure::do_yield_work() { ConcurrentMarkSweepThread::desynchronize(true); ConcurrentMarkSweepThread::acknowledge_yield_request(); _collector->stopTimer(); - GCPauseTimer p(_collector->size_policy()->concurrent_timer_ptr()); if (PrintCMSStatistics != 0) { _collector->incrementYields(); } @@ -8099,7 +7997,6 @@ void CMSPrecleanRefsYieldClosure::do_yield_work() { ConcurrentMarkSweepThread::acknowledge_yield_request(); _collector->stopTimer(); - GCPauseTimer p(_collector->size_policy()->concurrent_timer_ptr()); if (PrintCMSStatistics != 0) { _collector->incrementYields(); } @@ -8780,7 +8677,6 @@ void SweepClosure::do_yield_work(HeapWord* addr) { ConcurrentMarkSweepThread::desynchronize(true); ConcurrentMarkSweepThread::acknowledge_yield_request(); _collector->stopTimer(); - GCPauseTimer p(_collector->size_policy()->concurrent_timer_ptr()); if (PrintCMSStatistics != 0) { _collector->incrementYields(); } @@ -9327,172 +9223,6 @@ bool CMSCollector::no_preserved_marks() const { } #endif -CMSAdaptiveSizePolicy* ASConcurrentMarkSweepGeneration::cms_size_policy() const -{ - GenCollectedHeap* gch = (GenCollectedHeap*) GenCollectedHeap::heap(); - CMSAdaptiveSizePolicy* size_policy = - (CMSAdaptiveSizePolicy*) gch->gen_policy()->size_policy(); - assert(size_policy->is_gc_cms_adaptive_size_policy(), - "Wrong type for size policy"); - return size_policy; -} - -void ASConcurrentMarkSweepGeneration::resize(size_t cur_promo_size, - size_t desired_promo_size) { - if (cur_promo_size < desired_promo_size) { - size_t expand_bytes = desired_promo_size - cur_promo_size; - if (PrintAdaptiveSizePolicy && Verbose) { - gclog_or_tty->print_cr(" ASConcurrentMarkSweepGeneration::resize " - "Expanding tenured generation by " SIZE_FORMAT " (bytes)", - expand_bytes); - } - expand(expand_bytes, - MinHeapDeltaBytes, - CMSExpansionCause::_adaptive_size_policy); - } else if (desired_promo_size < cur_promo_size) { - size_t shrink_bytes = cur_promo_size - desired_promo_size; - if (PrintAdaptiveSizePolicy && Verbose) { - gclog_or_tty->print_cr(" ASConcurrentMarkSweepGeneration::resize " - "Shrinking tenured generation by " SIZE_FORMAT " (bytes)", - shrink_bytes); - } - shrink(shrink_bytes); - } -} - -CMSGCAdaptivePolicyCounters* ASConcurrentMarkSweepGeneration::gc_adaptive_policy_counters() { - GenCollectedHeap* gch = GenCollectedHeap::heap(); - CMSGCAdaptivePolicyCounters* counters = - (CMSGCAdaptivePolicyCounters*) gch->collector_policy()->counters(); - assert(counters->kind() == GCPolicyCounters::CMSGCAdaptivePolicyCountersKind, - "Wrong kind of counters"); - return counters; -} - - -void ASConcurrentMarkSweepGeneration::update_counters() { - if (UsePerfData) { - _space_counters->update_all(); - _gen_counters->update_all(); - CMSGCAdaptivePolicyCounters* counters = gc_adaptive_policy_counters(); - GenCollectedHeap* gch = GenCollectedHeap::heap(); - CMSGCStats* gc_stats_l = (CMSGCStats*) gc_stats(); - assert(gc_stats_l->kind() == GCStats::CMSGCStatsKind, - "Wrong gc statistics type"); - counters->update_counters(gc_stats_l); - } -} - -void ASConcurrentMarkSweepGeneration::update_counters(size_t used) { - if (UsePerfData) { - _space_counters->update_used(used); - _space_counters->update_capacity(); - _gen_counters->update_all(); - - CMSGCAdaptivePolicyCounters* counters = gc_adaptive_policy_counters(); - GenCollectedHeap* gch = GenCollectedHeap::heap(); - CMSGCStats* gc_stats_l = (CMSGCStats*) gc_stats(); - assert(gc_stats_l->kind() == GCStats::CMSGCStatsKind, - "Wrong gc statistics type"); - counters->update_counters(gc_stats_l); - } -} - -void ASConcurrentMarkSweepGeneration::shrink_by(size_t desired_bytes) { - assert_locked_or_safepoint(Heap_lock); - assert_lock_strong(freelistLock()); - HeapWord* old_end = _cmsSpace->end(); - HeapWord* unallocated_start = _cmsSpace->unallocated_block(); - assert(old_end >= unallocated_start, "Miscalculation of unallocated_start"); - FreeChunk* chunk_at_end = find_chunk_at_end(); - if (chunk_at_end == NULL) { - // No room to shrink - if (PrintGCDetails && Verbose) { - gclog_or_tty->print_cr("No room to shrink: old_end " - PTR_FORMAT " unallocated_start " PTR_FORMAT - " chunk_at_end " PTR_FORMAT, - old_end, unallocated_start, chunk_at_end); - } - return; - } else { - - // Find the chunk at the end of the space and determine - // how much it can be shrunk. - size_t shrinkable_size_in_bytes = chunk_at_end->size(); - size_t aligned_shrinkable_size_in_bytes = - align_size_down(shrinkable_size_in_bytes, os::vm_page_size()); - assert(unallocated_start <= (HeapWord*) chunk_at_end->end(), - "Inconsistent chunk at end of space"); - size_t bytes = MIN2(desired_bytes, aligned_shrinkable_size_in_bytes); - size_t word_size_before = heap_word_size(_virtual_space.committed_size()); - - // Shrink the underlying space - _virtual_space.shrink_by(bytes); - if (PrintGCDetails && Verbose) { - gclog_or_tty->print_cr("ConcurrentMarkSweepGeneration::shrink_by:" - " desired_bytes " SIZE_FORMAT - " shrinkable_size_in_bytes " SIZE_FORMAT - " aligned_shrinkable_size_in_bytes " SIZE_FORMAT - " bytes " SIZE_FORMAT, - desired_bytes, shrinkable_size_in_bytes, - aligned_shrinkable_size_in_bytes, bytes); - gclog_or_tty->print_cr(" old_end " SIZE_FORMAT - " unallocated_start " SIZE_FORMAT, - old_end, unallocated_start); - } - - // If the space did shrink (shrinking is not guaranteed), - // shrink the chunk at the end by the appropriate amount. - if (((HeapWord*)_virtual_space.high()) < old_end) { - size_t new_word_size = - heap_word_size(_virtual_space.committed_size()); - - // Have to remove the chunk from the dictionary because it is changing - // size and might be someplace elsewhere in the dictionary. - - // Get the chunk at end, shrink it, and put it - // back. - _cmsSpace->removeChunkFromDictionary(chunk_at_end); - size_t word_size_change = word_size_before - new_word_size; - size_t chunk_at_end_old_size = chunk_at_end->size(); - assert(chunk_at_end_old_size >= word_size_change, - "Shrink is too large"); - chunk_at_end->set_size(chunk_at_end_old_size - - word_size_change); - _cmsSpace->freed((HeapWord*) chunk_at_end->end(), - word_size_change); - - _cmsSpace->returnChunkToDictionary(chunk_at_end); - - MemRegion mr(_cmsSpace->bottom(), new_word_size); - _bts->resize(new_word_size); // resize the block offset shared array - Universe::heap()->barrier_set()->resize_covered_region(mr); - _cmsSpace->assert_locked(); - _cmsSpace->set_end((HeapWord*)_virtual_space.high()); - - NOT_PRODUCT(_cmsSpace->dictionary()->verify()); - - // update the space and generation capacity counters - if (UsePerfData) { - _space_counters->update_capacity(); - _gen_counters->update_all(); - } - - if (Verbose && PrintGCDetails) { - size_t new_mem_size = _virtual_space.committed_size(); - size_t old_mem_size = new_mem_size + bytes; - gclog_or_tty->print_cr("Shrinking %s from " SIZE_FORMAT "K by " SIZE_FORMAT "K to " SIZE_FORMAT "K", - name(), old_mem_size/K, bytes/K, new_mem_size/K); - } - } - - assert(_cmsSpace->unallocated_block() <= _cmsSpace->end(), - "Inconsistency at end of space"); - assert(chunk_at_end->end() == (uintptr_t*) _cmsSpace->end(), - "Shrinking is inconsistent"); - return; - } -} // Transfer some number of overflown objects to usual marking // stack. Return true if some objects were transferred. bool MarkRefsIntoAndScanClosure::take_from_overflow_list() { diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp index 7e3ef58605f..8d3d6ef128e 100644 --- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp +++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp @@ -32,6 +32,7 @@ #include "gc_implementation/shared/generationCounters.hpp" #include "memory/freeBlockDictionary.hpp" #include "memory/generation.hpp" +#include "memory/iterator.hpp" #include "runtime/mutexLocker.hpp" #include "runtime/virtualspace.hpp" #include "services/memoryService.hpp" @@ -52,7 +53,7 @@ // Concurrent mode failures are currently handled by // means of a sliding mark-compact. -class CMSAdaptiveSizePolicy; +class AdaptiveSizePolicy; class CMSConcMarkingTask; class CMSGCAdaptivePolicyCounters; class CMSTracer; @@ -1009,8 +1010,7 @@ class CMSCollector: public CHeapObj { void icms_wait(); // Called at yield points. // Adaptive size policy - CMSAdaptiveSizePolicy* size_policy(); - CMSGCAdaptivePolicyCounters* gc_adaptive_policy_counters(); + AdaptiveSizePolicy* size_policy(); static void print_on_error(outputStream* st); @@ -1150,9 +1150,6 @@ class ConcurrentMarkSweepGeneration: public CardGeneration { virtual Generation::Name kind() { return Generation::ConcurrentMarkSweep; } - // Adaptive size policy - CMSAdaptiveSizePolicy* size_policy(); - void set_did_compact(bool v) { _did_compact = v; } bool refs_discovery_is_atomic() const { return false; } @@ -1346,37 +1343,6 @@ class ConcurrentMarkSweepGeneration: public CardGeneration { void rotate_debug_collection_type(); }; -class ASConcurrentMarkSweepGeneration : public ConcurrentMarkSweepGeneration { - - // Return the size policy from the heap's collector - // policy casted to CMSAdaptiveSizePolicy*. - CMSAdaptiveSizePolicy* cms_size_policy() const; - - // Resize the generation based on the adaptive size - // policy. - void resize(size_t cur_promo, size_t desired_promo); - - // Return the GC counters from the collector policy - CMSGCAdaptivePolicyCounters* gc_adaptive_policy_counters(); - - virtual void shrink_by(size_t bytes); - - public: - ASConcurrentMarkSweepGeneration(ReservedSpace rs, size_t initial_byte_size, - int level, CardTableRS* ct, - bool use_adaptive_freelists, - FreeBlockDictionary::DictionaryChoice - dictionaryChoice) : - ConcurrentMarkSweepGeneration(rs, initial_byte_size, level, ct, - use_adaptive_freelists, dictionaryChoice) {} - - virtual const char* short_name() const { return "ASCMS"; } - virtual Generation::Name kind() { return Generation::ASConcurrentMarkSweep; } - - virtual void update_counters(); - virtual void update_counters(size_t used); -}; - // // Closures of various sorts used by CMS to accomplish its work // diff --git a/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp b/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp index aba4dbb11f3..74c079d8ccf 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp @@ -24,6 +24,7 @@ #include "precompiled.hpp" #include "classfile/symbolTable.hpp" +#include "code/codeCache.hpp" #include "gc_implementation/g1/concurrentMark.inline.hpp" #include "gc_implementation/g1/concurrentMarkThread.inline.hpp" #include "gc_implementation/g1/g1CollectedHeap.inline.hpp" @@ -39,6 +40,7 @@ #include "gc_implementation/shared/gcTimer.hpp" #include "gc_implementation/shared/gcTrace.hpp" #include "gc_implementation/shared/gcTraceTime.hpp" +#include "memory/allocation.hpp" #include "memory/genOopClosures.inline.hpp" #include "memory/referencePolicy.hpp" #include "memory/resourceArea.hpp" @@ -58,8 +60,8 @@ CMBitMapRO::CMBitMapRO(int shifter) : _bmWordSize = 0; } -HeapWord* CMBitMapRO::getNextMarkedWordAddress(HeapWord* addr, - HeapWord* limit) const { +HeapWord* CMBitMapRO::getNextMarkedWordAddress(const HeapWord* addr, + const HeapWord* limit) const { // First we must round addr *up* to a possible object boundary. addr = (HeapWord*)align_size_up((intptr_t)addr, HeapWordSize << _shifter); @@ -76,8 +78,8 @@ HeapWord* CMBitMapRO::getNextMarkedWordAddress(HeapWord* addr, return nextAddr; } -HeapWord* CMBitMapRO::getNextUnmarkedWordAddress(HeapWord* addr, - HeapWord* limit) const { +HeapWord* CMBitMapRO::getNextUnmarkedWordAddress(const HeapWord* addr, + const HeapWord* limit) const { size_t addrOffset = heapWordToOffset(addr); if (limit == NULL) { limit = _bmStartWord + _bmWordSize; @@ -1223,6 +1225,9 @@ public: }; void ConcurrentMark::scanRootRegions() { + // Start of concurrent marking. + ClassLoaderDataGraph::clear_claimed_marks(); + // scan_in_progress() will have been set to true only if there was // at least one root region to scan. So, if it's false, we // should not attempt to do any further work. @@ -1271,7 +1276,7 @@ void ConcurrentMark::markFromRoots() { CMConcurrentMarkingTask markingTask(this, cmThread()); if (use_parallel_marking_threads()) { _parallel_workers->set_active_workers((int)active_workers); - // Don't set _n_par_threads because it affects MT in process_strong_roots() + // Don't set _n_par_threads because it affects MT in process_roots() // and the decisions on that MT processing is made elsewhere. assert(_parallel_workers->active_workers() > 0, "Should have been set"); _parallel_workers->run_task(&markingTask); @@ -2142,23 +2147,29 @@ void ConcurrentMark::cleanup() { // Update the soft reference policy with the new heap occupancy. Universe::update_heap_info_at_gc(); - // We need to make this be a "collection" so any collection pause that - // races with it goes around and waits for completeCleanup to finish. - g1h->increment_total_collections(); - - // We reclaimed old regions so we should calculate the sizes to make - // sure we update the old gen/space data. - g1h->g1mm()->update_sizes(); - if (VerifyDuringGC) { HandleMark hm; // handle scope Universe::heap()->prepare_for_verify(); Universe::verify(VerifyOption_G1UsePrevMarking, " VerifyDuringGC:(after)"); } + g1h->check_bitmaps("Cleanup End"); g1h->verify_region_sets_optional(); + + // We need to make this be a "collection" so any collection pause that + // races with it goes around and waits for completeCleanup to finish. + g1h->increment_total_collections(); + + // Clean out dead classes and update Metaspace sizes. + ClassLoaderDataGraph::purge(); + MetaspaceGC::compute_new_size(); + + // We reclaimed old regions so we should calculate the sizes to make + // sure we update the old gen/space data. + g1h->g1mm()->update_sizes(); + g1h->trace_heap_after_concurrent_cycle(); } @@ -2445,6 +2456,26 @@ void G1CMRefProcTaskExecutor::execute(EnqueueTask& enq_task) { _g1h->set_par_threads(0); } +void ConcurrentMark::weakRefsWorkParallelPart(BoolObjectClosure* is_alive, bool purged_classes) { + G1CollectedHeap::heap()->parallel_cleaning(is_alive, true, true, purged_classes); +} + +// Helper class to get rid of some boilerplate code. +class G1RemarkGCTraceTime : public GCTraceTime { + static bool doit_and_prepend(bool doit) { + if (doit) { + gclog_or_tty->put(' '); + } + return doit; + } + + public: + G1RemarkGCTraceTime(const char* title, bool doit) + : GCTraceTime(title, doit_and_prepend(doit), false, G1CollectedHeap::heap()->gc_timer_cm(), + G1CollectedHeap::heap()->concurrent_mark()->concurrent_gc_id()) { + } +}; + void ConcurrentMark::weakRefsWork(bool clear_all_soft_refs) { if (has_overflown()) { // Skip processing the discovered references if we have @@ -2557,9 +2588,28 @@ void ConcurrentMark::weakRefsWork(bool clear_all_soft_refs) { return; } - g1h->unlink_string_and_symbol_table(&g1_is_alive, - /* process_strings */ false, // currently strings are always roots - /* process_symbols */ true); + assert(_markStack.isEmpty(), "Marking should have completed"); + + // Unload Klasses, String, Symbols, Code Cache, etc. + + G1RemarkGCTraceTime trace("Unloading", G1Log::finer()); + + bool purged_classes; + + { + G1RemarkGCTraceTime trace("System Dictionary Unloading", G1Log::finest()); + purged_classes = SystemDictionary::do_unloading(&g1_is_alive); + } + + { + G1RemarkGCTraceTime trace("Parallel Unloading", G1Log::finest()); + weakRefsWorkParallelPart(&g1_is_alive, purged_classes); + } + + if (G1StringDedup::is_enabled()) { + G1RemarkGCTraceTime trace("String Deduplication Unlink", G1Log::finest()); + G1StringDedup::unlink(&g1_is_alive); + } } void ConcurrentMark::swapMarkBitMaps() { @@ -2568,6 +2618,57 @@ void ConcurrentMark::swapMarkBitMaps() { _nextMarkBitMap = (CMBitMap*) temp; } +class CMObjectClosure; + +// Closure for iterating over objects, currently only used for +// processing SATB buffers. +class CMObjectClosure : public ObjectClosure { +private: + CMTask* _task; + +public: + void do_object(oop obj) { + _task->deal_with_reference(obj); + } + + CMObjectClosure(CMTask* task) : _task(task) { } +}; + +class G1RemarkThreadsClosure : public ThreadClosure { + CMObjectClosure _cm_obj; + G1CMOopClosure _cm_cl; + MarkingCodeBlobClosure _code_cl; + int _thread_parity; + bool _is_par; + + public: + G1RemarkThreadsClosure(G1CollectedHeap* g1h, CMTask* task, bool is_par) : + _cm_obj(task), _cm_cl(g1h, g1h->concurrent_mark(), task), _code_cl(&_cm_cl, !CodeBlobToOopClosure::FixRelocations), + _thread_parity(SharedHeap::heap()->strong_roots_parity()), _is_par(is_par) {} + + void do_thread(Thread* thread) { + if (thread->is_Java_thread()) { + if (thread->claim_oops_do(_is_par, _thread_parity)) { + JavaThread* jt = (JavaThread*)thread; + + // In theory it should not be neccessary to explicitly walk the nmethods to find roots for concurrent marking + // however the liveness of oops reachable from nmethods have very complex lifecycles: + // * Alive if on the stack of an executing method + // * Weakly reachable otherwise + // Some objects reachable from nmethods, such as the class loader (or klass_holder) of the receiver should be + // live by the SATB invariant but other oops recorded in nmethods may behave differently. + jt->nmethods_do(&_code_cl); + + jt->satb_mark_queue().apply_closure_and_empty(&_cm_obj); + } + } else if (thread->is_VM_thread()) { + if (thread->claim_oops_do(_is_par, _thread_parity)) { + JavaThread::satb_mark_queue_set().shared_satb_queue()->apply_closure_and_empty(&_cm_obj); + } + } + } +}; + class CMRemarkTask: public AbstractGangTask { private: ConcurrentMark* _cm; @@ -2579,6 +2680,14 @@ public: if (worker_id < _cm->active_tasks()) { CMTask* task = _cm->task(worker_id); task->record_start_time(); + { + ResourceMark rm; + HandleMark hm; + + G1RemarkThreadsClosure threads_f(G1CollectedHeap::heap(), task, !_is_serial); + Threads::threads_do(&threads_f); + } + do { task->do_marking_step(1000000000.0 /* something very large */, true /* do_termination */, @@ -2601,6 +2710,8 @@ void ConcurrentMark::checkpointRootsFinalWork() { HandleMark hm; G1CollectedHeap* g1h = G1CollectedHeap::heap(); + G1RemarkGCTraceTime trace("Finalize Marking", G1Log::finer()); + g1h->ensure_parsability(false); if (G1CollectedHeap::use_parallel_gc_threads()) { @@ -3430,20 +3541,6 @@ public: } }; -// Closure for iterating over objects, currently only used for -// processing SATB buffers. -class CMObjectClosure : public ObjectClosure { -private: - CMTask* _task; - -public: - void do_object(oop obj) { - _task->deal_with_reference(obj); - } - - CMObjectClosure(CMTask* task) : _task(task) { } -}; - G1CMOopClosure::G1CMOopClosure(G1CollectedHeap* g1h, ConcurrentMark* cm, CMTask* task) @@ -3908,15 +4005,6 @@ void CMTask::drain_satb_buffers() { } } - if (!concurrent() && !has_aborted()) { - // We should only do this during remark. - if (G1CollectedHeap::use_parallel_gc_threads()) { - satb_mq_set.par_iterate_closure_all_threads(_worker_id); - } else { - satb_mq_set.iterate_closure_all_threads(); - } - } - _draining_satb_buffers = false; assert(has_aborted() || diff --git a/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.hpp b/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.hpp index 1e4ad366c75..d0b67b39f97 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.hpp @@ -25,6 +25,7 @@ #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_CONCURRENTMARK_HPP #define SHARE_VM_GC_IMPLEMENTATION_G1_CONCURRENTMARK_HPP +#include "classfile/javaClasses.hpp" #include "gc_implementation/g1/heapRegionSet.hpp" #include "gc_implementation/shared/gcId.hpp" #include "utilities/taskqueue.hpp" @@ -86,19 +87,19 @@ class CMBitMapRO VALUE_OBJ_CLASS_SPEC { // Return the address corresponding to the next marked bit at or after // "addr", and before "limit", if "limit" is non-NULL. If there is no // such bit, returns "limit" if that is non-NULL, or else "endWord()". - HeapWord* getNextMarkedWordAddress(HeapWord* addr, - HeapWord* limit = NULL) const; + HeapWord* getNextMarkedWordAddress(const HeapWord* addr, + const HeapWord* limit = NULL) const; // Return the address corresponding to the next unmarked bit at or after // "addr", and before "limit", if "limit" is non-NULL. If there is no // such bit, returns "limit" if that is non-NULL, or else "endWord()". - HeapWord* getNextUnmarkedWordAddress(HeapWord* addr, - HeapWord* limit = NULL) const; + HeapWord* getNextUnmarkedWordAddress(const HeapWord* addr, + const HeapWord* limit = NULL) const; // conversion utilities HeapWord* offsetToHeapWord(size_t offset) const { return _bmStartWord + (offset << _shifter); } - size_t heapWordToOffset(HeapWord* addr) const { + size_t heapWordToOffset(const HeapWord* addr) const { return pointer_delta(addr, _bmStartWord) >> _shifter; } int heapWordDiffToOffsetDiff(size_t diff) const; @@ -476,6 +477,7 @@ protected: ForceOverflowSettings _force_overflow_conc; ForceOverflowSettings _force_overflow_stw; + void weakRefsWorkParallelPart(BoolObjectClosure* is_alive, bool purged_classes); void weakRefsWork(bool clear_all_soft_refs); void swapMarkBitMaps(); diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1AllocRegion.inline.hpp b/hotspot/src/share/vm/gc_implementation/g1/g1AllocRegion.inline.hpp index 05efc6ebc3d..2f3529d3e3c 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1AllocRegion.inline.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1AllocRegion.inline.hpp @@ -26,6 +26,7 @@ #define SHARE_VM_GC_IMPLEMENTATION_G1_G1ALLOCREGION_INLINE_HPP #include "gc_implementation/g1/g1AllocRegion.hpp" +#include "gc_implementation/g1/heapRegion.inline.hpp" inline HeapWord* G1AllocRegion::allocate(HeapRegion* alloc_region, size_t word_size, diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.cpp index c07fa50f04d..c7d4ff3431a 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.cpp @@ -426,7 +426,7 @@ G1BlockOffsetArray::forward_to_block_containing_addr_slow(HeapWord* q, q = n; oop obj = oop(q); if (obj->klass_or_null() == NULL) return q; - n += obj->size(); + n += block_size(q); } assert(q <= next_boundary && n > next_boundary, "Consequence of loop"); // [q, n) is the block that crosses the boundary. diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.inline.hpp b/hotspot/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.inline.hpp index 24f97f35dcb..4cf0a06cd74 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.inline.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.inline.hpp @@ -26,7 +26,8 @@ #define SHARE_VM_GC_IMPLEMENTATION_G1_G1BLOCKOFFSETTABLE_INLINE_HPP #include "gc_implementation/g1/g1BlockOffsetTable.hpp" -#include "gc_implementation/g1/heapRegion.hpp" +#include "gc_implementation/g1/g1CollectedHeap.inline.hpp" +#include "gc_implementation/g1/heapRegion.inline.hpp" #include "memory/space.hpp" inline HeapWord* G1BlockOffsetTable::block_start(const void* addr) { @@ -112,7 +113,7 @@ forward_to_block_containing_addr_const(HeapWord* q, HeapWord* n, q = n; oop obj = oop(q); if (obj->klass_or_null() == NULL) return q; - n += obj->size(); + n += block_size(q); } assert(q <= n, "wrong order for q and addr"); assert(addr < n, "wrong order for addr and n"); diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1CodeCacheRemSet.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1CodeCacheRemSet.cpp index fbe7095f75c..159a445b325 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1CodeCacheRemSet.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1CodeCacheRemSet.cpp @@ -30,23 +30,52 @@ PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC -G1CodeRootChunk::G1CodeRootChunk() : _top(NULL), _next(NULL), _prev(NULL) { +G1CodeRootChunk::G1CodeRootChunk() : _top(NULL), _next(NULL), _prev(NULL), _free(NULL) { _top = bottom(); } void G1CodeRootChunk::reset() { _next = _prev = NULL; + _free = NULL; _top = bottom(); } void G1CodeRootChunk::nmethods_do(CodeBlobClosure* cl) { - nmethod** cur = bottom(); + NmethodOrLink* cur = bottom(); while (cur != _top) { - cl->do_code_blob(*cur); + if (is_nmethod(cur)) { + cl->do_code_blob(cur->_nmethod); + } cur++; } } +bool G1CodeRootChunk::remove_lock_free(nmethod* method) { + NmethodOrLink* cur = bottom(); + + for (NmethodOrLink* cur = bottom(); cur != _top; cur++) { + if (cur->_nmethod == method) { + bool result = Atomic::cmpxchg_ptr(NULL, &cur->_nmethod, method) == method; + + if (!result) { + // Someone else cleared out this entry. + return false; + } + + // The method was cleared. Time to link it into the free list. + NmethodOrLink* prev_free; + do { + prev_free = (NmethodOrLink*)_free; + cur->_link = prev_free; + } while (Atomic::cmpxchg_ptr(cur, &_free, prev_free) != prev_free); + + return true; + } + } + + return false; +} + G1CodeRootChunkManager::G1CodeRootChunkManager() : _free_list(), _num_chunks_handed_out(0) { _free_list.initialize(); _free_list.set_size(G1CodeRootChunk::word_size()); @@ -140,34 +169,43 @@ G1CodeRootSet::~G1CodeRootSet() { void G1CodeRootSet::add(nmethod* method) { if (!contains(method)) { - // Try to add the nmethod. If there is not enough space, get a new chunk. - if (_list.head() == NULL || _list.head()->is_full()) { - G1CodeRootChunk* cur = new_chunk(); + // Find the first chunk that isn't full. + G1CodeRootChunk* cur = _list.head(); + while (cur != NULL) { + if (!cur->is_full()) { + break; + } + cur = cur->next(); + } + + // All chunks are full, get a new chunk. + if (cur == NULL) { + cur = new_chunk(); _list.return_chunk_at_head(cur); } - bool result = _list.head()->add(method); + + // Add the nmethod. + bool result = cur->add(method); + guarantee(result, err_msg("Not able to add nmethod "PTR_FORMAT" to newly allocated chunk.", method)); + _length++; } } -void G1CodeRootSet::remove(nmethod* method) { +void G1CodeRootSet::remove_lock_free(nmethod* method) { G1CodeRootChunk* found = find(method); if (found != NULL) { - bool result = found->remove(method); - guarantee(result, err_msg("could not find nmethod "PTR_FORMAT" during removal although we previously found it", method)); - // eventually free completely emptied chunk - if (found->is_empty()) { - _list.remove_chunk(found); - free(found); + bool result = found->remove_lock_free(method); + if (result) { + Atomic::dec_ptr((volatile intptr_t*)&_length); } - _length--; } assert(!contains(method), err_msg(PTR_FORMAT" still contains nmethod "PTR_FORMAT, this, method)); } nmethod* G1CodeRootSet::pop() { - do { + while (true) { G1CodeRootChunk* cur = _list.head(); if (cur == NULL) { assert(_length == 0, "when there are no chunks, there should be no elements"); @@ -180,7 +218,7 @@ nmethod* G1CodeRootSet::pop() { } else { free(_list.get_chunk_at_head()); } - } while (true); + } } G1CodeRootChunk* G1CodeRootSet::find(nmethod* method) { diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1CodeCacheRemSet.hpp b/hotspot/src/share/vm/gc_implementation/g1/g1CodeCacheRemSet.hpp index 84008213dbc..c351330f12f 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1CodeCacheRemSet.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1CodeCacheRemSet.hpp @@ -31,6 +31,14 @@ class CodeBlobClosure; +// The elements of the G1CodeRootChunk is either: +// 1) nmethod pointers +// 2) nodes in an internally chained free list +typedef union { + nmethod* _nmethod; + void* _link; +} NmethodOrLink; + class G1CodeRootChunk : public CHeapObj { private: static const int NUM_ENTRIES = 32; @@ -38,16 +46,28 @@ class G1CodeRootChunk : public CHeapObj { G1CodeRootChunk* _next; G1CodeRootChunk* _prev; - nmethod** _top; + NmethodOrLink* _top; + // First free position within the chunk. + volatile NmethodOrLink* _free; - nmethod* _data[NUM_ENTRIES]; + NmethodOrLink _data[NUM_ENTRIES]; - nmethod** bottom() const { - return (nmethod**) &(_data[0]); + NmethodOrLink* bottom() const { + return (NmethodOrLink*) &(_data[0]); } - nmethod** end() const { - return (nmethod**) &(_data[NUM_ENTRIES]); + NmethodOrLink* end() const { + return (NmethodOrLink*) &(_data[NUM_ENTRIES]); + } + + bool is_link(NmethodOrLink* nmethod_or_link) { + return nmethod_or_link->_link == NULL || + (bottom() <= nmethod_or_link->_link + && nmethod_or_link->_link < end()); + } + + bool is_nmethod(NmethodOrLink* nmethod_or_link) { + return !is_link(nmethod_or_link); } public: @@ -85,46 +105,55 @@ class G1CodeRootChunk : public CHeapObj { } bool is_full() const { - return _top == (nmethod**)end(); + return _top == end() && _free == NULL; } bool contains(nmethod* method) { - nmethod** cur = bottom(); + NmethodOrLink* cur = bottom(); while (cur != _top) { - if (*cur == method) return true; + if (cur->_nmethod == method) return true; cur++; } return false; } bool add(nmethod* method) { - if (is_full()) return false; - *_top = method; - _top++; + if (is_full()) { + return false; + } + + if (_free != NULL) { + // Take from internally chained free list + NmethodOrLink* first_free = (NmethodOrLink*)_free; + _free = (NmethodOrLink*)_free->_link; + first_free->_nmethod = method; + } else { + // Take from top. + _top->_nmethod = method; + _top++; + } + return true; } - bool remove(nmethod* method) { - nmethod** cur = bottom(); - while (cur != _top) { - if (*cur == method) { - memmove(cur, cur + 1, (_top - (cur + 1)) * sizeof(nmethod**)); - _top--; - return true; - } - cur++; - } - return false; - } + bool remove_lock_free(nmethod* method); void nmethods_do(CodeBlobClosure* blk); nmethod* pop() { - if (is_empty()) { - return NULL; + if (_free != NULL) { + // Kill the free list. + _free = NULL; } - _top--; - return *_top; + + while (!is_empty()) { + _top--; + if (is_nmethod(_top)) { + return _top->_nmethod; + } + } + + return NULL; } }; @@ -193,7 +222,7 @@ class G1CodeRootSet VALUE_OBJ_CLASS_SPEC { // method is likely to be repeatedly called with the same nmethod. void add(nmethod* method); - void remove(nmethod* method); + void remove_lock_free(nmethod* method); nmethod* pop(); bool contains(nmethod* method); diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp index f020f0d53a1..aca5699351b 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp @@ -44,6 +44,7 @@ #include "gc_implementation/g1/g1Log.hpp" #include "gc_implementation/g1/g1MarkSweep.hpp" #include "gc_implementation/g1/g1OopClosures.inline.hpp" +#include "gc_implementation/g1/g1ParScanThreadState.inline.hpp" #include "gc_implementation/g1/g1RemSet.inline.hpp" #include "gc_implementation/g1/g1StringDedup.hpp" #include "gc_implementation/g1/g1YCTypes.hpp" @@ -56,6 +57,7 @@ #include "gc_implementation/shared/gcTrace.hpp" #include "gc_implementation/shared/gcTraceTime.hpp" #include "gc_implementation/shared/isGCActiveMark.hpp" +#include "memory/allocation.hpp" #include "memory/gcLocker.inline.hpp" #include "memory/generationSpec.hpp" #include "memory/iterator.hpp" @@ -63,11 +65,9 @@ #include "oops/oop.inline.hpp" #include "oops/oop.pcgc.inline.hpp" #include "runtime/atomic.inline.hpp" -#include "runtime/prefetch.inline.hpp" #include "runtime/orderAccess.inline.hpp" #include "runtime/vmThread.hpp" #include "utilities/globalDefinitions.hpp" -#include "utilities/ticks.hpp" size_t G1CollectedHeap::_humongous_object_threshold_in_words = 0; @@ -92,10 +92,10 @@ size_t G1CollectedHeap::_humongous_object_threshold_in_words = 0; // G1ParVerifyTask uses heap_region_par_iterate_chunked() for parallelism. // The number of GC workers is passed to heap_region_par_iterate_chunked(). // It does use run_task() which sets _n_workers in the task. -// G1ParTask executes g1_process_strong_roots() -> -// SharedHeap::process_strong_roots() which calls eventually to +// G1ParTask executes g1_process_roots() -> +// SharedHeap::process_roots() which calls eventually to // CardTableModRefBS::par_non_clean_card_iterate_work() which uses -// SequentialSubTasksDone. SharedHeap::process_strong_roots() also +// SequentialSubTasksDone. SharedHeap::process_roots() also // directly uses SubTasksDone (_process_strong_tasks field in SharedHeap). // @@ -3380,25 +3380,19 @@ void G1CollectedHeap::verify(bool silent, VerifyOption vo) { if (!silent) { gclog_or_tty->print("Roots "); } VerifyRootsClosure rootsCl(vo); VerifyKlassClosure klassCl(this, &rootsCl); + CLDToKlassAndOopClosure cldCl(&klassCl, &rootsCl, false); // We apply the relevant closures to all the oops in the - // system dictionary, class loader data graph and the string table. - // Don't verify the code cache here, since it's verified below. - const int so = SO_AllClasses | SO_Strings; - - // Need cleared claim bits for the strong roots processing - ClassLoaderDataGraph::clear_claimed_marks(); - - process_strong_roots(true, // activate StrongRootsScope - ScanningOption(so), // roots scanning options - &rootsCl, - &klassCl - ); - - // Verify the nmethods in the code cache. + // system dictionary, class loader data graph, the string table + // and the nmethods in the code cache. G1VerifyCodeRootOopClosure codeRootsCl(this, &rootsCl, vo); G1VerifyCodeRootBlobClosure blobsCl(&codeRootsCl); - CodeCache::blobs_do(&blobsCl); + + process_all_roots(true, // activate StrongRootsScope + SO_AllCodeCache, // roots scanning options + &rootsCl, + &cldCl, + &blobsCl); bool failures = rootsCl.failures() || codeRootsCl.failures(); @@ -3980,6 +3974,7 @@ G1CollectedHeap::do_collection_pause_at_safepoint(double target_pause_time_ms) { increment_gc_time_stamp(); verify_before_gc(); + check_bitmaps("GC Start"); COMPILER2_PRESENT(DerivedPointerTable::clear()); @@ -4330,11 +4325,7 @@ void G1CollectedHeap::release_mutator_alloc_region() { assert(_mutator_alloc_region.get() == NULL, "post-condition"); } -void G1CollectedHeap::init_gc_alloc_regions(EvacuationInfo& evacuation_info) { - assert_at_safepoint(true /* should_be_vm_thread */); - - _survivor_gc_alloc_region.init(); - _old_gc_alloc_region.init(); +void G1CollectedHeap::use_retained_old_gc_alloc_region(EvacuationInfo& evacuation_info) { HeapRegion* retained_region = _retained_old_gc_alloc_region; _retained_old_gc_alloc_region = NULL; @@ -4352,7 +4343,7 @@ void G1CollectedHeap::init_gc_alloc_regions(EvacuationInfo& evacuation_info) { !(retained_region->top() == retained_region->end()) && !retained_region->is_empty() && !retained_region->isHumongous()) { - retained_region->set_saved_mark(); + retained_region->record_top_and_timestamp(); // The retained region was added to the old region set when it was // retired. We have to remove it now, since we don't allow regions // we allocate to in the region sets. We'll re-add it later, when @@ -4366,6 +4357,15 @@ void G1CollectedHeap::init_gc_alloc_regions(EvacuationInfo& evacuation_info) { } } +void G1CollectedHeap::init_gc_alloc_regions(EvacuationInfo& evacuation_info) { + assert_at_safepoint(true /* should_be_vm_thread */); + + _survivor_gc_alloc_region.init(); + _old_gc_alloc_region.init(); + + use_retained_old_gc_alloc_region(evacuation_info); +} + void G1CollectedHeap::release_gc_alloc_regions(uint no_of_gc_workers, EvacuationInfo& evacuation_info) { evacuation_info.set_allocation_regions(_survivor_gc_alloc_region.count() + _old_gc_alloc_region.count()); @@ -4559,126 +4559,6 @@ HeapWord* G1CollectedHeap::par_allocate_during_gc(GCAllocPurpose purpose, G1ParGCAllocBuffer::G1ParGCAllocBuffer(size_t gclab_word_size) : ParGCAllocBuffer(gclab_word_size), _retired(true) { } -G1ParScanThreadState::G1ParScanThreadState(G1CollectedHeap* g1h, uint queue_num, ReferenceProcessor* rp) - : _g1h(g1h), - _refs(g1h->task_queue(queue_num)), - _dcq(&g1h->dirty_card_queue_set()), - _ct_bs(g1h->g1_barrier_set()), - _g1_rem(g1h->g1_rem_set()), - _hash_seed(17), _queue_num(queue_num), - _term_attempts(0), - _surviving_alloc_buffer(g1h->desired_plab_sz(GCAllocForSurvived)), - _tenured_alloc_buffer(g1h->desired_plab_sz(GCAllocForTenured)), - _age_table(false), _scanner(g1h, this, rp), - _strong_roots_time(0), _term_time(0), - _alloc_buffer_waste(0), _undo_waste(0) { - // we allocate G1YoungSurvRateNumRegions plus one entries, since - // we "sacrifice" entry 0 to keep track of surviving bytes for - // non-young regions (where the age is -1) - // We also add a few elements at the beginning and at the end in - // an attempt to eliminate cache contention - uint real_length = 1 + _g1h->g1_policy()->young_cset_region_length(); - uint array_length = PADDING_ELEM_NUM + - real_length + - PADDING_ELEM_NUM; - _surviving_young_words_base = NEW_C_HEAP_ARRAY(size_t, array_length, mtGC); - if (_surviving_young_words_base == NULL) - vm_exit_out_of_memory(array_length * sizeof(size_t), OOM_MALLOC_ERROR, - "Not enough space for young surv histo."); - _surviving_young_words = _surviving_young_words_base + PADDING_ELEM_NUM; - memset(_surviving_young_words, 0, (size_t) real_length * sizeof(size_t)); - - _alloc_buffers[GCAllocForSurvived] = &_surviving_alloc_buffer; - _alloc_buffers[GCAllocForTenured] = &_tenured_alloc_buffer; - - _start = os::elapsedTime(); -} - -void -G1ParScanThreadState::print_termination_stats_hdr(outputStream* const st) -{ - st->print_raw_cr("GC Termination Stats"); - st->print_raw_cr(" elapsed --strong roots-- -------termination-------" - " ------waste (KiB)------"); - st->print_raw_cr("thr ms ms % ms % attempts" - " total alloc undo"); - st->print_raw_cr("--- --------- --------- ------ --------- ------ --------" - " ------- ------- -------"); -} - -void -G1ParScanThreadState::print_termination_stats(int i, - outputStream* const st) const -{ - const double elapsed_ms = elapsed_time() * 1000.0; - const double s_roots_ms = strong_roots_time() * 1000.0; - const double term_ms = term_time() * 1000.0; - st->print_cr("%3d %9.2f %9.2f %6.2f " - "%9.2f %6.2f " SIZE_FORMAT_W(8) " " - SIZE_FORMAT_W(7) " " SIZE_FORMAT_W(7) " " SIZE_FORMAT_W(7), - i, elapsed_ms, s_roots_ms, s_roots_ms * 100 / elapsed_ms, - term_ms, term_ms * 100 / elapsed_ms, term_attempts(), - (alloc_buffer_waste() + undo_waste()) * HeapWordSize / K, - alloc_buffer_waste() * HeapWordSize / K, - undo_waste() * HeapWordSize / K); -} - -#ifdef ASSERT -bool G1ParScanThreadState::verify_ref(narrowOop* ref) const { - assert(ref != NULL, "invariant"); - assert(UseCompressedOops, "sanity"); - assert(!has_partial_array_mask(ref), err_msg("ref=" PTR_FORMAT, ref)); - oop p = oopDesc::load_decode_heap_oop(ref); - assert(_g1h->is_in_g1_reserved(p), - err_msg("ref=" PTR_FORMAT " p=" PTR_FORMAT, ref, (void *)p)); - return true; -} - -bool G1ParScanThreadState::verify_ref(oop* ref) const { - assert(ref != NULL, "invariant"); - if (has_partial_array_mask(ref)) { - // Must be in the collection set--it's already been copied. - oop p = clear_partial_array_mask(ref); - assert(_g1h->obj_in_cs(p), - err_msg("ref=" PTR_FORMAT " p=" PTR_FORMAT, ref, (void *)p)); - } else { - oop p = oopDesc::load_decode_heap_oop(ref); - assert(_g1h->is_in_g1_reserved(p), - err_msg("ref=" PTR_FORMAT " p=" PTR_FORMAT, ref, (void *)p)); - } - return true; -} - -bool G1ParScanThreadState::verify_task(StarTask ref) const { - if (ref.is_narrow()) { - return verify_ref((narrowOop*) ref); - } else { - return verify_ref((oop*) ref); - } -} -#endif // ASSERT - -void G1ParScanThreadState::trim_queue() { - assert(_evac_failure_cl != NULL, "not set"); - - StarTask ref; - do { - // Drain the overflow stack first, so other threads can steal. - while (refs()->pop_overflow(ref)) { - deal_with_reference(ref); - } - - while (refs()->pop_local(ref)) { - deal_with_reference(ref); - } - } while (!refs()->is_empty()); -} - -G1ParClosureSuper::G1ParClosureSuper(G1CollectedHeap* g1, - G1ParScanThreadState* par_scan_state) : - _g1(g1), _par_scan_state(par_scan_state), - _worker_id(par_scan_state->queue_num()) { } - void G1ParCopyHelper::mark_object(oop obj) { assert(!_g1->heap_region_containing(obj)->in_collection_set(), "should not mark objects in the CSet"); @@ -4701,107 +4581,6 @@ void G1ParCopyHelper::mark_forwarded_object(oop from_obj, oop to_obj) { _cm->grayRoot(to_obj, (size_t) from_obj->size(), _worker_id); } -oop G1ParScanThreadState::copy_to_survivor_space(oop const old) { - size_t word_sz = old->size(); - HeapRegion* from_region = _g1h->heap_region_containing_raw(old); - // +1 to make the -1 indexes valid... - int young_index = from_region->young_index_in_cset()+1; - assert( (from_region->is_young() && young_index > 0) || - (!from_region->is_young() && young_index == 0), "invariant" ); - G1CollectorPolicy* g1p = _g1h->g1_policy(); - markOop m = old->mark(); - int age = m->has_displaced_mark_helper() ? m->displaced_mark_helper()->age() - : m->age(); - GCAllocPurpose alloc_purpose = g1p->evacuation_destination(from_region, age, - word_sz); - HeapWord* obj_ptr = allocate(alloc_purpose, word_sz); -#ifndef PRODUCT - // Should this evacuation fail? - if (_g1h->evacuation_should_fail()) { - if (obj_ptr != NULL) { - undo_allocation(alloc_purpose, obj_ptr, word_sz); - obj_ptr = NULL; - } - } -#endif // !PRODUCT - - if (obj_ptr == NULL) { - // This will either forward-to-self, or detect that someone else has - // installed a forwarding pointer. - return _g1h->handle_evacuation_failure_par(this, old); - } - - oop obj = oop(obj_ptr); - - // We're going to allocate linearly, so might as well prefetch ahead. - Prefetch::write(obj_ptr, PrefetchCopyIntervalInBytes); - - oop forward_ptr = old->forward_to_atomic(obj); - if (forward_ptr == NULL) { - Copy::aligned_disjoint_words((HeapWord*) old, obj_ptr, word_sz); - - // alloc_purpose is just a hint to allocate() above, recheck the type of region - // we actually allocated from and update alloc_purpose accordingly - HeapRegion* to_region = _g1h->heap_region_containing_raw(obj_ptr); - alloc_purpose = to_region->is_young() ? GCAllocForSurvived : GCAllocForTenured; - - if (g1p->track_object_age(alloc_purpose)) { - // We could simply do obj->incr_age(). However, this causes a - // performance issue. obj->incr_age() will first check whether - // the object has a displaced mark by checking its mark word; - // getting the mark word from the new location of the object - // stalls. So, given that we already have the mark word and we - // are about to install it anyway, it's better to increase the - // age on the mark word, when the object does not have a - // displaced mark word. We're not expecting many objects to have - // a displaced marked word, so that case is not optimized - // further (it could be...) and we simply call obj->incr_age(). - - if (m->has_displaced_mark_helper()) { - // in this case, we have to install the mark word first, - // otherwise obj looks to be forwarded (the old mark word, - // which contains the forward pointer, was copied) - obj->set_mark(m); - obj->incr_age(); - } else { - m = m->incr_age(); - obj->set_mark(m); - } - age_table()->add(obj, word_sz); - } else { - obj->set_mark(m); - } - - if (G1StringDedup::is_enabled()) { - G1StringDedup::enqueue_from_evacuation(from_region->is_young(), - to_region->is_young(), - queue_num(), - obj); - } - - size_t* surv_young_words = surviving_young_words(); - surv_young_words[young_index] += word_sz; - - if (obj->is_objArray() && arrayOop(obj)->length() >= ParGCArrayScanChunk) { - // We keep track of the next start index in the length field of - // the to-space object. The actual length can be found in the - // length field of the from-space object. - arrayOop(obj)->set_length(0); - oop* old_p = set_partial_array_mask(old); - push_on_queue(old_p); - } else { - // No point in using the slower heap_region_containing() method, - // given that we know obj is in the heap. - _scanner.set_region(_g1h->heap_region_containing_raw(obj)); - obj->oop_iterate_backwards(&_scanner); - } - } else { - undo_allocation(alloc_purpose, obj_ptr, word_sz); - obj = forward_ptr; - } - return obj; -} - template void G1ParCopyHelper::do_klass_barrier(T* p, oop new_obj) { if (_g1->heap_region_containing_raw(new_obj)->is_young()) { @@ -4809,7 +4588,7 @@ void G1ParCopyHelper::do_klass_barrier(T* p, oop new_obj) { } } -template +template template void G1ParCopyClosure::do_oop_work(T* p) { T heap_oop = oopDesc::load_heap_oop(p); @@ -4831,7 +4610,7 @@ void G1ParCopyClosure::do_oop_work(T* p) { } assert(forwardee != NULL, "forwardee should not be NULL"); oopDesc::encode_store_heap_oop(p, forwardee); - if (do_mark_object && forwardee != obj) { + if (do_mark_object != G1MarkNone && forwardee != obj) { // If the object is self-forwarded we don't need to explicitly // mark it, the evacuation failure protocol will do so. mark_forwarded_object(obj, forwardee); @@ -4842,9 +4621,8 @@ void G1ParCopyClosure::do_oop_work(T* p) { } } else { // The object is not in collection set. If we're a root scanning - // closure during an initial mark pause (i.e. do_mark_object will - // be true) then attempt to mark the object. - if (do_mark_object) { + // closure during an initial mark pause then attempt to mark the object. + if (do_mark_object == G1MarkFromRoot) { mark_object(obj); } } @@ -4854,8 +4632,8 @@ void G1ParCopyClosure::do_oop_work(T* p) { } } -template void G1ParCopyClosure::do_oop_work(oop* p); -template void G1ParCopyClosure::do_oop_work(narrowOop* p); +template void G1ParCopyClosure::do_oop_work(oop* p); +template void G1ParCopyClosure::do_oop_work(narrowOop* p); class G1ParEvacuateFollowersClosure : public VoidClosure { protected: @@ -4891,24 +4669,10 @@ bool G1ParEvacuateFollowersClosure::offer_termination() { } void G1ParEvacuateFollowersClosure::do_void() { - StarTask stolen_task; G1ParScanThreadState* const pss = par_scan_state(); pss->trim_queue(); - do { - while (queues()->steal(pss->queue_num(), pss->hash_seed(), stolen_task)) { - assert(pss->verify_task(stolen_task), "sanity"); - if (stolen_task.is_narrow()) { - pss->deal_with_reference((narrowOop*) stolen_task); - } else { - pss->deal_with_reference((oop*) stolen_task); - } - - // We've just processed a reference and we might have made - // available new entries on the queues. So we have to make sure - // we drain the queues as necessary. - pss->trim_queue(); - } + pss->steal_and_trim_queue(queues()); } while (!offer_termination()); } @@ -4954,8 +4718,7 @@ protected: } public: - G1ParTask(G1CollectedHeap* g1h, - RefToScanQueueSet *task_queues) + G1ParTask(G1CollectedHeap* g1h, RefToScanQueueSet *task_queues) : AbstractGangTask("G1 collection"), _g1h(g1h), _queues(task_queues), @@ -4983,6 +4746,51 @@ public: _n_workers = active_workers; } + // Helps out with CLD processing. + // + // During InitialMark we need to: + // 1) Scavenge all CLDs for the young GC. + // 2) Mark all objects directly reachable from strong CLDs. + template + class G1CLDClosure : public CLDClosure { + G1ParCopyClosure* _oop_closure; + G1ParCopyClosure _oop_in_klass_closure; + G1KlassScanClosure _klass_in_cld_closure; + bool _claim; + + public: + G1CLDClosure(G1ParCopyClosure* oop_closure, + bool only_young, bool claim) + : _oop_closure(oop_closure), + _oop_in_klass_closure(oop_closure->g1(), + oop_closure->pss(), + oop_closure->rp()), + _klass_in_cld_closure(&_oop_in_klass_closure, only_young), + _claim(claim) { + + } + + void do_cld(ClassLoaderData* cld) { + cld->oops_do(_oop_closure, &_klass_in_cld_closure, _claim); + } + }; + + class G1CodeBlobClosure: public CodeBlobClosure { + OopClosure* _f; + + public: + G1CodeBlobClosure(OopClosure* f) : _f(f) {} + void do_code_blob(CodeBlob* blob) { + nmethod* that = blob->as_nmethod_or_null(); + if (that != NULL) { + if (!that->test_set_oops_do_mark()) { + that->oops_do(_f); + that->fix_oop_relocations(); + } + } + } + }; + void work(uint worker_id) { if (worker_id >= _n_workers) return; // no work needed this round @@ -5000,40 +4808,62 @@ public: pss.set_evac_failure_closure(&evac_failure_cl); - G1ParScanExtRootClosure only_scan_root_cl(_g1h, &pss, rp); - G1ParScanMetadataClosure only_scan_metadata_cl(_g1h, &pss, rp); + bool only_young = _g1h->g1_policy()->gcs_are_young(); - G1ParScanAndMarkExtRootClosure scan_mark_root_cl(_g1h, &pss, rp); - G1ParScanAndMarkMetadataClosure scan_mark_metadata_cl(_g1h, &pss, rp); + // Non-IM young GC. + G1ParCopyClosure scan_only_root_cl(_g1h, &pss, rp); + G1CLDClosure scan_only_cld_cl(&scan_only_root_cl, + only_young, // Only process dirty klasses. + false); // No need to claim CLDs. + // IM young GC. + // Strong roots closures. + G1ParCopyClosure scan_mark_root_cl(_g1h, &pss, rp); + G1CLDClosure scan_mark_cld_cl(&scan_mark_root_cl, + false, // Process all klasses. + true); // Need to claim CLDs. + // Weak roots closures. + G1ParCopyClosure scan_mark_weak_root_cl(_g1h, &pss, rp); + G1CLDClosure scan_mark_weak_cld_cl(&scan_mark_weak_root_cl, + false, // Process all klasses. + true); // Need to claim CLDs. - bool only_young = _g1h->g1_policy()->gcs_are_young(); - G1KlassScanClosure scan_mark_klasses_cl_s(&scan_mark_metadata_cl, false); - G1KlassScanClosure only_scan_klasses_cl_s(&only_scan_metadata_cl, only_young); + G1CodeBlobClosure scan_only_code_cl(&scan_only_root_cl); + G1CodeBlobClosure scan_mark_code_cl(&scan_mark_root_cl); + // IM Weak code roots are handled later. - OopClosure* scan_root_cl = &only_scan_root_cl; - G1KlassScanClosure* scan_klasses_cl = &only_scan_klasses_cl_s; + OopClosure* strong_root_cl; + OopClosure* weak_root_cl; + CLDClosure* strong_cld_cl; + CLDClosure* weak_cld_cl; + CodeBlobClosure* strong_code_cl; if (_g1h->g1_policy()->during_initial_mark_pause()) { // We also need to mark copied objects. - scan_root_cl = &scan_mark_root_cl; - scan_klasses_cl = &scan_mark_klasses_cl_s; + strong_root_cl = &scan_mark_root_cl; + weak_root_cl = &scan_mark_weak_root_cl; + strong_cld_cl = &scan_mark_cld_cl; + weak_cld_cl = &scan_mark_weak_cld_cl; + strong_code_cl = &scan_mark_code_cl; + } else { + strong_root_cl = &scan_only_root_cl; + weak_root_cl = &scan_only_root_cl; + strong_cld_cl = &scan_only_cld_cl; + weak_cld_cl = &scan_only_cld_cl; + strong_code_cl = &scan_only_code_cl; } - G1ParPushHeapRSClosure push_heap_rs_cl(_g1h, &pss); - // Don't scan the scavengable methods in the code cache as part - // of strong root scanning. The code roots that point into a - // region in the collection set are scanned when we scan the - // region's RSet. - int so = SharedHeap::SO_AllClasses | SharedHeap::SO_Strings; + G1ParPushHeapRSClosure push_heap_rs_cl(_g1h, &pss); pss.start_strong_roots(); - _g1h->g1_process_strong_roots(/* is scavenging */ true, - SharedHeap::ScanningOption(so), - scan_root_cl, - &push_heap_rs_cl, - scan_klasses_cl, - worker_id); + _g1h->g1_process_roots(strong_root_cl, + weak_root_cl, + &push_heap_rs_cl, + strong_cld_cl, + weak_cld_cl, + strong_code_cl, + worker_id); + pss.end_strong_roots(); { @@ -5053,7 +4883,7 @@ public: pss.print_termination_stats(worker_id); } - assert(pss.refs()->is_empty(), "should be empty"); + assert(pss.queue_is_empty(), "should be empty"); // Close the inner scope so that the ResourceMark and HandleMark // destructors are executed here and are included as part of the @@ -5071,24 +4901,31 @@ public: void G1CollectedHeap:: -g1_process_strong_roots(bool is_scavenging, - ScanningOption so, - OopClosure* scan_non_heap_roots, - OopsInHeapRegionClosure* scan_rs, - G1KlassScanClosure* scan_klasses, - uint worker_i) { +g1_process_roots(OopClosure* scan_non_heap_roots, + OopClosure* scan_non_heap_weak_roots, + OopsInHeapRegionClosure* scan_rs, + CLDClosure* scan_strong_clds, + CLDClosure* scan_weak_clds, + CodeBlobClosure* scan_strong_code, + uint worker_i) { - // First scan the strong roots + // First scan the shared roots. double ext_roots_start = os::elapsedTime(); double closure_app_time_sec = 0.0; - BufferingOopClosure buf_scan_non_heap_roots(scan_non_heap_roots); + bool during_im = _g1h->g1_policy()->during_initial_mark_pause(); - process_strong_roots(false, // no scoping; this is parallel code - so, - &buf_scan_non_heap_roots, - scan_klasses - ); + BufferingOopClosure buf_scan_non_heap_roots(scan_non_heap_roots); + BufferingOopClosure buf_scan_non_heap_weak_roots(scan_non_heap_weak_roots); + + process_roots(false, // no scoping; this is parallel code + SharedHeap::SO_None, + &buf_scan_non_heap_roots, + &buf_scan_non_heap_weak_roots, + scan_strong_clds, + // Initial Mark handles the weak CLDs separately. + (during_im ? NULL : scan_weak_clds), + scan_strong_code); // Now the CM ref_processor roots. if (!_process_strong_tasks->is_task_claimed(G1H_PS_refProcessor_oops_do)) { @@ -5099,10 +4936,21 @@ g1_process_strong_roots(bool is_scavenging, ref_processor_cm()->weak_oops_do(&buf_scan_non_heap_roots); } + if (during_im) { + // Barrier to make sure all workers passed + // the strong CLD and strong nmethods phases. + active_strong_roots_scope()->wait_until_all_workers_done_with_threads(n_par_threads()); + + // Now take the complement of the strong CLDs. + ClassLoaderDataGraph::roots_cld_do(NULL, scan_weak_clds); + } + // Finish up any enqueued closure apps (attributed as object copy time). buf_scan_non_heap_roots.done(); + buf_scan_non_heap_weak_roots.done(); - double obj_copy_time_sec = buf_scan_non_heap_roots.closure_app_seconds(); + double obj_copy_time_sec = buf_scan_non_heap_roots.closure_app_seconds() + + buf_scan_non_heap_weak_roots.closure_app_seconds(); g1_policy()->phase_times()->record_obj_copy_time(worker_i, obj_copy_time_sec * 1000.0); @@ -5126,22 +4974,10 @@ g1_process_strong_roots(bool is_scavenging, } g1_policy()->phase_times()->record_satb_filtering_time(worker_i, satb_filtering_ms); - // If this is an initial mark pause, and we're not scanning - // the entire code cache, we need to mark the oops in the - // strong code root lists for the regions that are not in - // the collection set. - // Note all threads participate in this set of root tasks. - double mark_strong_code_roots_ms = 0.0; - if (g1_policy()->during_initial_mark_pause() && !(so & SO_AllCodeCache)) { - double mark_strong_roots_start = os::elapsedTime(); - mark_strong_code_roots(worker_i); - mark_strong_code_roots_ms = (os::elapsedTime() - mark_strong_roots_start) * 1000.0; - } - g1_policy()->phase_times()->record_strong_code_root_mark_time(worker_i, mark_strong_code_roots_ms); - // Now scan the complement of the collection set. - CodeBlobToOopClosure eager_scan_code_roots(scan_non_heap_roots, true /* do_marking */); - g1_rem_set()->oops_into_collection_set_do(scan_rs, &eager_scan_code_roots, worker_i); + MarkingCodeBlobClosure scavenge_cs_nmethods(scan_non_heap_weak_roots, CodeBlobToOopClosure::FixRelocations); + + g1_rem_set()->oops_into_collection_set_do(scan_rs, &scavenge_cs_nmethods, worker_i); _process_strong_tasks->all_tasks_completed(); } @@ -5163,7 +4999,8 @@ private: bool _do_in_parallel; public: G1StringSymbolTableUnlinkTask(BoolObjectClosure* is_alive, bool process_strings, bool process_symbols) : - AbstractGangTask("Par String/Symbol table unlink"), _is_alive(is_alive), + AbstractGangTask("String/Symbol Unlinking"), + _is_alive(is_alive), _do_in_parallel(G1CollectedHeap::use_parallel_gc_threads()), _process_strings(process_strings), _strings_processed(0), _strings_removed(0), _process_symbols(process_symbols), _symbols_processed(0), _symbols_removed(0) { @@ -5185,6 +5022,14 @@ public: guarantee(!_process_symbols || !_do_in_parallel || SymbolTable::parallel_claimed_index() >= _initial_symbol_table_size, err_msg("claim value %d after unlink less than initial symbol table size %d", SymbolTable::parallel_claimed_index(), _initial_symbol_table_size)); + + if (G1TraceStringSymbolTableScrubbing) { + gclog_or_tty->print_cr("Cleaned string and symbol table, " + "strings: "SIZE_FORMAT" processed, "SIZE_FORMAT" removed, " + "symbols: "SIZE_FORMAT" processed, "SIZE_FORMAT" removed", + strings_processed(), strings_removed(), + symbols_processed(), symbols_removed()); + } } void work(uint worker_id) { @@ -5220,12 +5065,279 @@ public: size_t symbols_removed() const { return (size_t)_symbols_removed; } }; -void G1CollectedHeap::unlink_string_and_symbol_table(BoolObjectClosure* is_alive, - bool process_strings, bool process_symbols) { - uint n_workers = (G1CollectedHeap::use_parallel_gc_threads() ? - _g1h->workers()->active_workers() : 1); +class G1CodeCacheUnloadingTask VALUE_OBJ_CLASS_SPEC { +private: + static Monitor* _lock; - G1StringSymbolTableUnlinkTask g1_unlink_task(is_alive, process_strings, process_symbols); + BoolObjectClosure* const _is_alive; + const bool _unloading_occurred; + const uint _num_workers; + + // Variables used to claim nmethods. + nmethod* _first_nmethod; + volatile nmethod* _claimed_nmethod; + + // The list of nmethods that need to be processed by the second pass. + volatile nmethod* _postponed_list; + volatile uint _num_entered_barrier; + + public: + G1CodeCacheUnloadingTask(uint num_workers, BoolObjectClosure* is_alive, bool unloading_occurred) : + _is_alive(is_alive), + _unloading_occurred(unloading_occurred), + _num_workers(num_workers), + _first_nmethod(NULL), + _claimed_nmethod(NULL), + _postponed_list(NULL), + _num_entered_barrier(0) + { + nmethod::increase_unloading_clock(); + _first_nmethod = CodeCache::alive_nmethod(CodeCache::first()); + _claimed_nmethod = (volatile nmethod*)_first_nmethod; + } + + ~G1CodeCacheUnloadingTask() { + CodeCache::verify_clean_inline_caches(); + + CodeCache::set_needs_cache_clean(false); + guarantee(CodeCache::scavenge_root_nmethods() == NULL, "Must be"); + + CodeCache::verify_icholder_relocations(); + } + + private: + void add_to_postponed_list(nmethod* nm) { + nmethod* old; + do { + old = (nmethod*)_postponed_list; + nm->set_unloading_next(old); + } while ((nmethod*)Atomic::cmpxchg_ptr(nm, &_postponed_list, old) != old); + } + + void clean_nmethod(nmethod* nm) { + bool postponed = nm->do_unloading_parallel(_is_alive, _unloading_occurred); + + if (postponed) { + // This nmethod referred to an nmethod that has not been cleaned/unloaded yet. + add_to_postponed_list(nm); + } + + // Mark that this thread has been cleaned/unloaded. + // After this call, it will be safe to ask if this nmethod was unloaded or not. + nm->set_unloading_clock(nmethod::global_unloading_clock()); + } + + void clean_nmethod_postponed(nmethod* nm) { + nm->do_unloading_parallel_postponed(_is_alive, _unloading_occurred); + } + + static const int MaxClaimNmethods = 16; + + void claim_nmethods(nmethod** claimed_nmethods, int *num_claimed_nmethods) { + nmethod* first; + nmethod* last; + + do { + *num_claimed_nmethods = 0; + + first = last = (nmethod*)_claimed_nmethod; + + if (first != NULL) { + for (int i = 0; i < MaxClaimNmethods; i++) { + last = CodeCache::alive_nmethod(CodeCache::next(last)); + + if (last == NULL) { + break; + } + + claimed_nmethods[i] = last; + (*num_claimed_nmethods)++; + } + } + + } while ((nmethod*)Atomic::cmpxchg_ptr(last, &_claimed_nmethod, first) != first); + } + + nmethod* claim_postponed_nmethod() { + nmethod* claim; + nmethod* next; + + do { + claim = (nmethod*)_postponed_list; + if (claim == NULL) { + return NULL; + } + + next = claim->unloading_next(); + + } while ((nmethod*)Atomic::cmpxchg_ptr(next, &_postponed_list, claim) != claim); + + return claim; + } + + public: + // Mark that we're done with the first pass of nmethod cleaning. + void barrier_mark(uint worker_id) { + MonitorLockerEx ml(_lock, Mutex::_no_safepoint_check_flag); + _num_entered_barrier++; + if (_num_entered_barrier == _num_workers) { + ml.notify_all(); + } + } + + // See if we have to wait for the other workers to + // finish their first-pass nmethod cleaning work. + void barrier_wait(uint worker_id) { + if (_num_entered_barrier < _num_workers) { + MonitorLockerEx ml(_lock, Mutex::_no_safepoint_check_flag); + while (_num_entered_barrier < _num_workers) { + ml.wait(Mutex::_no_safepoint_check_flag, 0, false); + } + } + } + + // Cleaning and unloading of nmethods. Some work has to be postponed + // to the second pass, when we know which nmethods survive. + void work_first_pass(uint worker_id) { + // The first nmethods is claimed by the first worker. + if (worker_id == 0 && _first_nmethod != NULL) { + clean_nmethod(_first_nmethod); + _first_nmethod = NULL; + } + + int num_claimed_nmethods; + nmethod* claimed_nmethods[MaxClaimNmethods]; + + while (true) { + claim_nmethods(claimed_nmethods, &num_claimed_nmethods); + + if (num_claimed_nmethods == 0) { + break; + } + + for (int i = 0; i < num_claimed_nmethods; i++) { + clean_nmethod(claimed_nmethods[i]); + } + } + } + + void work_second_pass(uint worker_id) { + nmethod* nm; + // Take care of postponed nmethods. + while ((nm = claim_postponed_nmethod()) != NULL) { + clean_nmethod_postponed(nm); + } + } +}; + +Monitor* G1CodeCacheUnloadingTask::_lock = new Monitor(Mutex::leaf, "Code Cache Unload lock"); + +class G1KlassCleaningTask : public StackObj { + BoolObjectClosure* _is_alive; + volatile jint _clean_klass_tree_claimed; + ClassLoaderDataGraphKlassIteratorAtomic _klass_iterator; + + public: + G1KlassCleaningTask(BoolObjectClosure* is_alive) : + _is_alive(is_alive), + _clean_klass_tree_claimed(0), + _klass_iterator() { + } + + private: + bool claim_clean_klass_tree_task() { + if (_clean_klass_tree_claimed) { + return false; + } + + return Atomic::cmpxchg(1, (jint*)&_clean_klass_tree_claimed, 0) == 0; + } + + InstanceKlass* claim_next_klass() { + Klass* klass; + do { + klass =_klass_iterator.next_klass(); + } while (klass != NULL && !klass->oop_is_instance()); + + return (InstanceKlass*)klass; + } + +public: + + void clean_klass(InstanceKlass* ik) { + ik->clean_implementors_list(_is_alive); + ik->clean_method_data(_is_alive); + + // G1 specific cleanup work that has + // been moved here to be done in parallel. + ik->clean_dependent_nmethods(); + } + + void work() { + ResourceMark rm; + + // One worker will clean the subklass/sibling klass tree. + if (claim_clean_klass_tree_task()) { + Klass::clean_subklass_tree(_is_alive); + } + + // All workers will help cleaning the classes, + InstanceKlass* klass; + while ((klass = claim_next_klass()) != NULL) { + clean_klass(klass); + } + } +}; + +// To minimize the remark pause times, the tasks below are done in parallel. +class G1ParallelCleaningTask : public AbstractGangTask { +private: + G1StringSymbolTableUnlinkTask _string_symbol_task; + G1CodeCacheUnloadingTask _code_cache_task; + G1KlassCleaningTask _klass_cleaning_task; + +public: + // The constructor is run in the VMThread. + G1ParallelCleaningTask(BoolObjectClosure* is_alive, bool process_strings, bool process_symbols, uint num_workers, bool unloading_occurred) : + AbstractGangTask("Parallel Cleaning"), + _string_symbol_task(is_alive, process_strings, process_symbols), + _code_cache_task(num_workers, is_alive, unloading_occurred), + _klass_cleaning_task(is_alive) { + } + + // The parallel work done by all worker threads. + void work(uint worker_id) { + // Do first pass of code cache cleaning. + _code_cache_task.work_first_pass(worker_id); + + // Let the threads mark that the first pass is done. + _code_cache_task.barrier_mark(worker_id); + + // Clean the Strings and Symbols. + _string_symbol_task.work(worker_id); + + // Wait for all workers to finish the first code cache cleaning pass. + _code_cache_task.barrier_wait(worker_id); + + // Do the second code cache cleaning work, which realize on + // the liveness information gathered during the first pass. + _code_cache_task.work_second_pass(worker_id); + + // Clean all klasses that were not unloaded. + _klass_cleaning_task.work(); + } +}; + + +void G1CollectedHeap::parallel_cleaning(BoolObjectClosure* is_alive, + bool process_strings, + bool process_symbols, + bool class_unloading_occurred) { + uint n_workers = (G1CollectedHeap::use_parallel_gc_threads() ? + workers()->active_workers() : 1); + + G1ParallelCleaningTask g1_unlink_task(is_alive, process_strings, process_symbols, + n_workers, class_unloading_occurred); if (G1CollectedHeap::use_parallel_gc_threads()) { set_par_threads(n_workers); workers()->run_task(&g1_unlink_task); @@ -5233,12 +5345,21 @@ void G1CollectedHeap::unlink_string_and_symbol_table(BoolObjectClosure* is_alive } else { g1_unlink_task.work(0); } - if (G1TraceStringSymbolTableScrubbing) { - gclog_or_tty->print_cr("Cleaned string and symbol table, " - "strings: "SIZE_FORMAT" processed, "SIZE_FORMAT" removed, " - "symbols: "SIZE_FORMAT" processed, "SIZE_FORMAT" removed", - g1_unlink_task.strings_processed(), g1_unlink_task.strings_removed(), - g1_unlink_task.symbols_processed(), g1_unlink_task.symbols_removed()); +} + +void G1CollectedHeap::unlink_string_and_symbol_table(BoolObjectClosure* is_alive, + bool process_strings, bool process_symbols) { + { + uint n_workers = (G1CollectedHeap::use_parallel_gc_threads() ? + _g1h->workers()->active_workers() : 1); + G1StringSymbolTableUnlinkTask g1_unlink_task(is_alive, process_strings, process_symbols); + if (G1CollectedHeap::use_parallel_gc_threads()) { + set_par_threads(n_workers); + workers()->run_task(&g1_unlink_task); + set_par_threads(0); + } else { + g1_unlink_task.work(0); + } } if (G1StringDedup::is_enabled()) { @@ -5577,8 +5698,7 @@ public: pss.set_evac_failure_closure(&evac_failure_cl); - assert(pss.refs()->is_empty(), "both queue and overflow should be empty"); - + assert(pss.queue_is_empty(), "both queue and overflow should be empty"); G1ParScanExtRootClosure only_copy_non_heap_cl(_g1h, &pss, NULL); @@ -5632,7 +5752,7 @@ public: G1ParEvacuateFollowersClosure drain_queue(_g1h, &pss, _queues, &_terminator); drain_queue.do_void(); // Allocation buffers were retired at the end of G1ParEvacuateFollowersClosure - assert(pss.refs()->is_empty(), "should be"); + assert(pss.queue_is_empty(), "should be"); } }; @@ -5699,7 +5819,7 @@ void G1CollectedHeap::process_discovered_references(uint no_of_gc_workers) { pss.set_evac_failure_closure(&evac_failure_cl); - assert(pss.refs()->is_empty(), "pre-condition"); + assert(pss.queue_is_empty(), "pre-condition"); G1ParScanExtRootClosure only_copy_non_heap_cl(this, &pss, NULL); @@ -5747,7 +5867,7 @@ void G1CollectedHeap::process_discovered_references(uint no_of_gc_workers) { _gc_tracer_stw->report_gc_reference_stats(stats); // We have completed copying any necessary live referent objects. - assert(pss.refs()->is_empty(), "both queue and overflow should be empty"); + assert(pss.queue_is_empty(), "both queue and overflow should be empty"); double ref_proc_time = os::elapsedTime() - ref_proc_start; g1_policy()->phase_times()->record_ref_proc_time(ref_proc_time * 1000.0); @@ -5832,6 +5952,10 @@ void G1CollectedHeap::evacuate_collection_set(EvacuationInfo& evacuation_info) { { StrongRootsScope srs(this); + // InitialMark needs claim bits to keep track of the marked-through CLDs. + if (g1_policy()->during_initial_mark_pause()) { + ClassLoaderDataGraph::clear_claimed_marks(); + } if (G1CollectedHeap::use_parallel_gc_threads()) { // The individual threads will set their evac-failure closures. @@ -6603,7 +6727,7 @@ HeapRegion* G1CollectedHeap::new_gc_alloc_region(size_t word_size, // We really only need to do this for old regions given that we // should never scan survivors. But it doesn't hurt to do it // for survivors too. - new_alloc_region->set_saved_mark(); + new_alloc_region->record_top_and_timestamp(); if (survivor) { new_alloc_region->set_survivor(); _hr_printer.alloc(new_alloc_region, G1HRPrinter::Survivor); @@ -6867,106 +6991,6 @@ void G1CollectedHeap::purge_code_root_memory() { g1_policy()->phase_times()->record_strong_code_root_purge_time(purge_time_ms); } -// Mark all the code roots that point into regions *not* in the -// collection set. -// -// Note we do not want to use a "marking" CodeBlobToOopClosure while -// walking the the code roots lists of regions not in the collection -// set. Suppose we have an nmethod (M) that points to objects in two -// separate regions - one in the collection set (R1) and one not (R2). -// Using a "marking" CodeBlobToOopClosure here would result in "marking" -// nmethod M when walking the code roots for R1. When we come to scan -// the code roots for R2, we would see that M is already marked and it -// would be skipped and the objects in R2 that are referenced from M -// would not be evacuated. - -class MarkStrongCodeRootCodeBlobClosure: public CodeBlobClosure { - - class MarkStrongCodeRootOopClosure: public OopClosure { - ConcurrentMark* _cm; - HeapRegion* _hr; - uint _worker_id; - - template void do_oop_work(T* p) { - T heap_oop = oopDesc::load_heap_oop(p); - if (!oopDesc::is_null(heap_oop)) { - oop obj = oopDesc::decode_heap_oop_not_null(heap_oop); - // Only mark objects in the region (which is assumed - // to be not in the collection set). - if (_hr->is_in(obj)) { - _cm->grayRoot(obj, (size_t) obj->size(), _worker_id); - } - } - } - - public: - MarkStrongCodeRootOopClosure(ConcurrentMark* cm, HeapRegion* hr, uint worker_id) : - _cm(cm), _hr(hr), _worker_id(worker_id) { - assert(!_hr->in_collection_set(), "sanity"); - } - - void do_oop(narrowOop* p) { do_oop_work(p); } - void do_oop(oop* p) { do_oop_work(p); } - }; - - MarkStrongCodeRootOopClosure _oop_cl; - -public: - MarkStrongCodeRootCodeBlobClosure(ConcurrentMark* cm, HeapRegion* hr, uint worker_id): - _oop_cl(cm, hr, worker_id) {} - - void do_code_blob(CodeBlob* cb) { - nmethod* nm = (cb == NULL) ? NULL : cb->as_nmethod_or_null(); - if (nm != NULL) { - nm->oops_do(&_oop_cl); - } - } -}; - -class MarkStrongCodeRootsHRClosure: public HeapRegionClosure { - G1CollectedHeap* _g1h; - uint _worker_id; - -public: - MarkStrongCodeRootsHRClosure(G1CollectedHeap* g1h, uint worker_id) : - _g1h(g1h), _worker_id(worker_id) {} - - bool doHeapRegion(HeapRegion *hr) { - HeapRegionRemSet* hrrs = hr->rem_set(); - if (hr->continuesHumongous()) { - // Code roots should never be attached to a continuation of a humongous region - assert(hrrs->strong_code_roots_list_length() == 0, - err_msg("code roots should never be attached to continuations of humongous region "HR_FORMAT - " starting at "HR_FORMAT", but has "SIZE_FORMAT, - HR_FORMAT_PARAMS(hr), HR_FORMAT_PARAMS(hr->humongous_start_region()), - hrrs->strong_code_roots_list_length())); - return false; - } - - if (hr->in_collection_set()) { - // Don't mark code roots into regions in the collection set here. - // They will be marked when we scan them. - return false; - } - - MarkStrongCodeRootCodeBlobClosure cb_cl(_g1h->concurrent_mark(), hr, _worker_id); - hr->strong_code_roots_do(&cb_cl); - return false; - } -}; - -void G1CollectedHeap::mark_strong_code_roots(uint worker_id) { - MarkStrongCodeRootsHRClosure cl(this, worker_id); - if (G1CollectedHeap::use_parallel_gc_threads()) { - heap_region_par_iterate_chunked(&cl, - worker_id, - workers()->active_workers(), - HeapRegion::ParMarkRootClaimValue); - } else { - heap_region_iterate(&cl); - } -} - class RebuildStrongCodeRootClosure: public CodeBlobClosure { G1CollectedHeap* _g1h; diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp index f4d0baae983..30a3d7ebcb8 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp @@ -31,7 +31,6 @@ #include "gc_implementation/g1/g1BiasedArray.hpp" #include "gc_implementation/g1/g1HRPrinter.hpp" #include "gc_implementation/g1/g1MonitoringSupport.hpp" -#include "gc_implementation/g1/g1RemSet.hpp" #include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp" #include "gc_implementation/g1/g1YCTypes.hpp" #include "gc_implementation/g1/heapRegionSeq.hpp" @@ -211,6 +210,7 @@ class G1FastCSetBiasedMappedArray : public G1BiasedMappedArray { class RefineCardTableEntryClosure; class G1CollectedHeap : public SharedHeap { + friend class VM_CollectForMetadataAllocation; friend class VM_G1CollectForAllocation; friend class VM_G1CollectFull; friend class VM_G1IncCollectionPause; @@ -220,7 +220,7 @@ class G1CollectedHeap : public SharedHeap { friend class OldGCAllocRegion; // Closures used in implementation. - template + template friend class G1ParCopyClosure; friend class G1IsAliveClosure; friend class G1EvacuateFollowersClosure; @@ -347,6 +347,9 @@ private: // It initializes the GC alloc regions at the start of a GC. void init_gc_alloc_regions(EvacuationInfo& evacuation_info); + // Setup the retained old gc alloc region as the currrent old gc alloc region. + void use_retained_old_gc_alloc_region(EvacuationInfo& evacuation_info); + // It releases the GC alloc regions at the end of a GC. void release_gc_alloc_regions(uint no_of_gc_workers, EvacuationInfo& evacuation_info); @@ -828,12 +831,13 @@ protected: // param is for use with parallel roots processing, and should be // the "i" of the calling parallel worker thread's work(i) function. // In the sequential case this param will be ignored. - void g1_process_strong_roots(bool is_scavenging, - ScanningOption so, - OopClosure* scan_non_heap_roots, - OopsInHeapRegionClosure* scan_rs, - G1KlassScanClosure* scan_klasses, - uint worker_i); + void g1_process_roots(OopClosure* scan_non_heap_roots, + OopClosure* scan_non_heap_weak_roots, + OopsInHeapRegionClosure* scan_rs, + CLDClosure* scan_strong_clds, + CLDClosure* scan_weak_clds, + CodeBlobClosure* scan_strong_code, + uint worker_i); // Notifies all the necessary spaces that the committed space has // been updated (either expanded or shrunk). It should be called @@ -1026,7 +1030,7 @@ protected: // of G1CollectedHeap::_gc_time_stamp. unsigned int* _worker_cset_start_region_time_stamp; - enum G1H_process_strong_roots_tasks { + enum G1H_process_roots_tasks { G1H_PS_filter_satb_buffers, G1H_PS_refProcessor_oops_do, // Leave this one last. @@ -1608,10 +1612,6 @@ public: // Free up superfluous code root memory. void purge_code_root_memory(); - // During an initial mark pause, mark all the code roots that - // point into regions *not* in the collection set. - void mark_strong_code_roots(uint worker_id); - // Rebuild the strong code root lists for each region // after a full GC. void rebuild_strong_code_roots(); @@ -1620,6 +1620,9 @@ public: // in symbol table, possibly in parallel. void unlink_string_and_symbol_table(BoolObjectClosure* is_alive, bool unlink_strings = true, bool unlink_symbols = true); + // Parallel phase of unloading/cleaning after G1 concurrent mark. + void parallel_cleaning(BoolObjectClosure* is_alive, bool process_strings, bool process_symbols, bool class_unloading_occurred); + // Redirty logged cards in the refinement queue. void redirty_logged_cards(); // Verification @@ -1715,256 +1718,4 @@ public: } }; -class G1ParScanThreadState : public StackObj { -protected: - G1CollectedHeap* _g1h; - RefToScanQueue* _refs; - DirtyCardQueue _dcq; - G1SATBCardTableModRefBS* _ct_bs; - G1RemSet* _g1_rem; - - G1ParGCAllocBuffer _surviving_alloc_buffer; - G1ParGCAllocBuffer _tenured_alloc_buffer; - G1ParGCAllocBuffer* _alloc_buffers[GCAllocPurposeCount]; - ageTable _age_table; - - G1ParScanClosure _scanner; - - size_t _alloc_buffer_waste; - size_t _undo_waste; - - OopsInHeapRegionClosure* _evac_failure_cl; - - int _hash_seed; - uint _queue_num; - - size_t _term_attempts; - - double _start; - double _start_strong_roots; - double _strong_roots_time; - double _start_term; - double _term_time; - - // Map from young-age-index (0 == not young, 1 is youngest) to - // surviving words. base is what we get back from the malloc call - size_t* _surviving_young_words_base; - // this points into the array, as we use the first few entries for padding - size_t* _surviving_young_words; - -#define PADDING_ELEM_NUM (DEFAULT_CACHE_LINE_SIZE / sizeof(size_t)) - - void add_to_alloc_buffer_waste(size_t waste) { _alloc_buffer_waste += waste; } - - void add_to_undo_waste(size_t waste) { _undo_waste += waste; } - - DirtyCardQueue& dirty_card_queue() { return _dcq; } - G1SATBCardTableModRefBS* ctbs() { return _ct_bs; } - - template inline void immediate_rs_update(HeapRegion* from, T* p, int tid); - - template void deferred_rs_update(HeapRegion* from, T* p, int tid) { - // If the new value of the field points to the same region or - // is the to-space, we don't need to include it in the Rset updates. - if (!from->is_in_reserved(oopDesc::load_decode_heap_oop(p)) && !from->is_survivor()) { - size_t card_index = ctbs()->index_for(p); - // If the card hasn't been added to the buffer, do it. - if (ctbs()->mark_card_deferred(card_index)) { - dirty_card_queue().enqueue((jbyte*)ctbs()->byte_for_index(card_index)); - } - } - } - -public: - G1ParScanThreadState(G1CollectedHeap* g1h, uint queue_num, ReferenceProcessor* rp); - - ~G1ParScanThreadState() { - retire_alloc_buffers(); - FREE_C_HEAP_ARRAY(size_t, _surviving_young_words_base, mtGC); - } - - RefToScanQueue* refs() { return _refs; } - ageTable* age_table() { return &_age_table; } - - G1ParGCAllocBuffer* alloc_buffer(GCAllocPurpose purpose) { - return _alloc_buffers[purpose]; - } - - size_t alloc_buffer_waste() const { return _alloc_buffer_waste; } - size_t undo_waste() const { return _undo_waste; } - -#ifdef ASSERT - bool verify_ref(narrowOop* ref) const; - bool verify_ref(oop* ref) const; - bool verify_task(StarTask ref) const; -#endif // ASSERT - - template void push_on_queue(T* ref) { - assert(verify_ref(ref), "sanity"); - refs()->push(ref); - } - - template inline void update_rs(HeapRegion* from, T* p, int tid); - - HeapWord* allocate_slow(GCAllocPurpose purpose, size_t word_sz) { - HeapWord* obj = NULL; - size_t gclab_word_size = _g1h->desired_plab_sz(purpose); - if (word_sz * 100 < gclab_word_size * ParallelGCBufferWastePct) { - G1ParGCAllocBuffer* alloc_buf = alloc_buffer(purpose); - add_to_alloc_buffer_waste(alloc_buf->words_remaining()); - alloc_buf->retire(false /* end_of_gc */, false /* retain */); - - HeapWord* buf = _g1h->par_allocate_during_gc(purpose, gclab_word_size); - if (buf == NULL) return NULL; // Let caller handle allocation failure. - // Otherwise. - alloc_buf->set_word_size(gclab_word_size); - alloc_buf->set_buf(buf); - - obj = alloc_buf->allocate(word_sz); - assert(obj != NULL, "buffer was definitely big enough..."); - } else { - obj = _g1h->par_allocate_during_gc(purpose, word_sz); - } - return obj; - } - - HeapWord* allocate(GCAllocPurpose purpose, size_t word_sz) { - HeapWord* obj = alloc_buffer(purpose)->allocate(word_sz); - if (obj != NULL) return obj; - return allocate_slow(purpose, word_sz); - } - - void undo_allocation(GCAllocPurpose purpose, HeapWord* obj, size_t word_sz) { - if (alloc_buffer(purpose)->contains(obj)) { - assert(alloc_buffer(purpose)->contains(obj + word_sz - 1), - "should contain whole object"); - alloc_buffer(purpose)->undo_allocation(obj, word_sz); - } else { - CollectedHeap::fill_with_object(obj, word_sz); - add_to_undo_waste(word_sz); - } - } - - void set_evac_failure_closure(OopsInHeapRegionClosure* evac_failure_cl) { - _evac_failure_cl = evac_failure_cl; - } - OopsInHeapRegionClosure* evac_failure_closure() { - return _evac_failure_cl; - } - - int* hash_seed() { return &_hash_seed; } - uint queue_num() { return _queue_num; } - - size_t term_attempts() const { return _term_attempts; } - void note_term_attempt() { _term_attempts++; } - - void start_strong_roots() { - _start_strong_roots = os::elapsedTime(); - } - void end_strong_roots() { - _strong_roots_time += (os::elapsedTime() - _start_strong_roots); - } - double strong_roots_time() const { return _strong_roots_time; } - - void start_term_time() { - note_term_attempt(); - _start_term = os::elapsedTime(); - } - void end_term_time() { - _term_time += (os::elapsedTime() - _start_term); - } - double term_time() const { return _term_time; } - - double elapsed_time() const { - return os::elapsedTime() - _start; - } - - static void - print_termination_stats_hdr(outputStream* const st = gclog_or_tty); - void - print_termination_stats(int i, outputStream* const st = gclog_or_tty) const; - - size_t* surviving_young_words() { - // We add on to hide entry 0 which accumulates surviving words for - // age -1 regions (i.e. non-young ones) - return _surviving_young_words; - } - -private: - void retire_alloc_buffers() { - for (int ap = 0; ap < GCAllocPurposeCount; ++ap) { - size_t waste = _alloc_buffers[ap]->words_remaining(); - add_to_alloc_buffer_waste(waste); - _alloc_buffers[ap]->flush_stats_and_retire(_g1h->stats_for_purpose((GCAllocPurpose)ap), - true /* end_of_gc */, - false /* retain */); - } - } - -#define G1_PARTIAL_ARRAY_MASK 0x2 - - inline bool has_partial_array_mask(oop* ref) const { - return ((uintptr_t)ref & G1_PARTIAL_ARRAY_MASK) == G1_PARTIAL_ARRAY_MASK; - } - - // We never encode partial array oops as narrowOop*, so return false immediately. - // This allows the compiler to create optimized code when popping references from - // the work queue. - inline bool has_partial_array_mask(narrowOop* ref) const { - assert(((uintptr_t)ref & G1_PARTIAL_ARRAY_MASK) != G1_PARTIAL_ARRAY_MASK, "Partial array oop reference encoded as narrowOop*"); - return false; - } - - // Only implement set_partial_array_mask() for regular oops, not for narrowOops. - // We always encode partial arrays as regular oop, to allow the - // specialization for has_partial_array_mask() for narrowOops above. - // This means that unintentional use of this method with narrowOops are caught - // by the compiler. - inline oop* set_partial_array_mask(oop obj) const { - assert(((uintptr_t)(void *)obj & G1_PARTIAL_ARRAY_MASK) == 0, "Information loss!"); - return (oop*) ((uintptr_t)(void *)obj | G1_PARTIAL_ARRAY_MASK); - } - - inline oop clear_partial_array_mask(oop* ref) const { - return cast_to_oop((intptr_t)ref & ~G1_PARTIAL_ARRAY_MASK); - } - - inline void do_oop_partial_array(oop* p); - - // This method is applied to the fields of the objects that have just been copied. - template void do_oop_evac(T* p, HeapRegion* from) { - assert(!oopDesc::is_null(oopDesc::load_decode_heap_oop(p)), - "Reference should not be NULL here as such are never pushed to the task queue."); - oop obj = oopDesc::load_decode_heap_oop_not_null(p); - - // Although we never intentionally push references outside of the collection - // set, due to (benign) races in the claim mechanism during RSet scanning more - // than one thread might claim the same card. So the same card may be - // processed multiple times. So redo this check. - if (_g1h->in_cset_fast_test(obj)) { - oop forwardee; - if (obj->is_forwarded()) { - forwardee = obj->forwardee(); - } else { - forwardee = copy_to_survivor_space(obj); - } - assert(forwardee != NULL, "forwardee should not be NULL"); - oopDesc::encode_store_heap_oop(p, forwardee); - } - - assert(obj != NULL, "Must be"); - update_rs(from, p, queue_num()); - } -public: - - oop copy_to_survivor_space(oop const obj); - - template inline void deal_with_reference(T* ref_to_scan); - - inline void deal_with_reference(StarTask ref); - -public: - void trim_queue(); -}; - #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTEDHEAP_HPP diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.inline.hpp b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.inline.hpp index 42a5931815b..7d5e530c497 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.inline.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.inline.hpp @@ -29,7 +29,6 @@ #include "gc_implementation/g1/g1CollectedHeap.hpp" #include "gc_implementation/g1/g1AllocRegion.inline.hpp" #include "gc_implementation/g1/g1CollectorPolicy.hpp" -#include "gc_implementation/g1/g1RemSet.inline.hpp" #include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp" #include "gc_implementation/g1/heapRegionSet.inline.hpp" #include "gc_implementation/g1/heapRegionSeq.inline.hpp" @@ -289,89 +288,4 @@ inline bool G1CollectedHeap::is_obj_ill(const oop obj) const { return is_obj_ill(obj, heap_region_containing(obj)); } -template inline void G1ParScanThreadState::immediate_rs_update(HeapRegion* from, T* p, int tid) { - if (!from->is_survivor()) { - _g1_rem->par_write_ref(from, p, tid); - } -} - -template void G1ParScanThreadState::update_rs(HeapRegion* from, T* p, int tid) { - if (G1DeferredRSUpdate) { - deferred_rs_update(from, p, tid); - } else { - immediate_rs_update(from, p, tid); - } -} - - -inline void G1ParScanThreadState::do_oop_partial_array(oop* p) { - assert(has_partial_array_mask(p), "invariant"); - oop from_obj = clear_partial_array_mask(p); - - assert(Universe::heap()->is_in_reserved(from_obj), "must be in heap."); - assert(from_obj->is_objArray(), "must be obj array"); - objArrayOop from_obj_array = objArrayOop(from_obj); - // The from-space object contains the real length. - int length = from_obj_array->length(); - - assert(from_obj->is_forwarded(), "must be forwarded"); - oop to_obj = from_obj->forwardee(); - assert(from_obj != to_obj, "should not be chunking self-forwarded objects"); - objArrayOop to_obj_array = objArrayOop(to_obj); - // We keep track of the next start index in the length field of the - // to-space object. - int next_index = to_obj_array->length(); - assert(0 <= next_index && next_index < length, - err_msg("invariant, next index: %d, length: %d", next_index, length)); - - int start = next_index; - int end = length; - int remainder = end - start; - // We'll try not to push a range that's smaller than ParGCArrayScanChunk. - if (remainder > 2 * ParGCArrayScanChunk) { - end = start + ParGCArrayScanChunk; - to_obj_array->set_length(end); - // Push the remainder before we process the range in case another - // worker has run out of things to do and can steal it. - oop* from_obj_p = set_partial_array_mask(from_obj); - push_on_queue(from_obj_p); - } else { - assert(length == end, "sanity"); - // We'll process the final range for this object. Restore the length - // so that the heap remains parsable in case of evacuation failure. - to_obj_array->set_length(end); - } - _scanner.set_region(_g1h->heap_region_containing_raw(to_obj)); - // Process indexes [start,end). It will also process the header - // along with the first chunk (i.e., the chunk with start == 0). - // Note that at this point the length field of to_obj_array is not - // correct given that we are using it to keep track of the next - // start index. oop_iterate_range() (thankfully!) ignores the length - // field and only relies on the start / end parameters. It does - // however return the size of the object which will be incorrect. So - // we have to ignore it even if we wanted to use it. - to_obj_array->oop_iterate_range(&_scanner, start, end); -} - -template inline void G1ParScanThreadState::deal_with_reference(T* ref_to_scan) { - if (!has_partial_array_mask(ref_to_scan)) { - // Note: we can use "raw" versions of "region_containing" because - // "obj_to_scan" is definitely in the heap, and is not in a - // humongous region. - HeapRegion* r = _g1h->heap_region_containing_raw(ref_to_scan); - do_oop_evac(ref_to_scan, r); - } else { - do_oop_partial_array((oop*)ref_to_scan); - } -} - -inline void G1ParScanThreadState::deal_with_reference(StarTask ref) { - assert(verify_task(ref), "sanity"); - if (ref.is_narrow()) { - deal_with_reference((narrowOop*)ref); - } else { - deal_with_reference((oop*)ref); - } -} - #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTEDHEAP_INLINE_HPP diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1EvacFailure.hpp b/hotspot/src/share/vm/gc_implementation/g1/g1EvacFailure.hpp index cb6fd08d77e..4b25d904063 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1EvacFailure.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1EvacFailure.hpp @@ -71,6 +71,9 @@ private: bool _during_initial_mark; bool _during_conc_mark; uint _worker_id; + HeapWord* _end_of_last_gap; + HeapWord* _last_gap_threshold; + HeapWord* _last_obj_threshold; public: RemoveSelfForwardPtrObjClosure(G1CollectedHeap* g1, ConcurrentMark* cm, @@ -83,7 +86,10 @@ public: _update_rset_cl(update_rset_cl), _during_initial_mark(during_initial_mark), _during_conc_mark(during_conc_mark), - _worker_id(worker_id) { } + _worker_id(worker_id), + _end_of_last_gap(hr->bottom()), + _last_gap_threshold(hr->bottom()), + _last_obj_threshold(hr->bottom()) { } size_t marked_bytes() { return _marked_bytes; } @@ -107,7 +113,12 @@ public: HeapWord* obj_addr = (HeapWord*) obj; assert(_hr->is_in(obj_addr), "sanity"); size_t obj_size = obj->size(); - _hr->update_bot_for_object(obj_addr, obj_size); + HeapWord* obj_end = obj_addr + obj_size; + + if (_end_of_last_gap != obj_addr) { + // there was a gap before obj_addr + _last_gap_threshold = _hr->cross_threshold(_end_of_last_gap, obj_addr); + } if (obj->is_forwarded() && obj->forwardee() == obj) { // The object failed to move. @@ -115,7 +126,9 @@ public: // We consider all objects that we find self-forwarded to be // live. What we'll do is that we'll update the prev marking // info so that they are all under PTAMS and explicitly marked. - _cm->markPrev(obj); + if (!_cm->isPrevMarked(obj)) { + _cm->markPrev(obj); + } if (_during_initial_mark) { // For the next marking info we'll only mark the // self-forwarded objects explicitly if we are during @@ -145,13 +158,18 @@ public: // remembered set entries missing given that we skipped cards on // the collection set. So, we'll recreate such entries now. obj->oop_iterate(_update_rset_cl); - assert(_cm->isPrevMarked(obj), "Should be marked!"); } else { + // The object has been either evacuated or is dead. Fill it with a // dummy object. - MemRegion mr((HeapWord*) obj, obj_size); + MemRegion mr(obj_addr, obj_size); CollectedHeap::fill_with_object(mr); + + // must nuke all dead objects which we skipped when iterating over the region + _cm->clearRangePrevBitmap(MemRegion(_end_of_last_gap, obj_end)); } + _end_of_last_gap = obj_end; + _last_obj_threshold = _hr->cross_threshold(obj_addr, obj_end); } }; @@ -182,13 +200,6 @@ public: during_conc_mark, _worker_id); - MemRegion mr(hr->bottom(), hr->end()); - // We'll recreate the prev marking info so we'll first clear - // the prev bitmap range for this region. We never mark any - // CSet objects explicitly so the next bitmap range should be - // cleared anyway. - _cm->clearRangePrevBitmap(mr); - hr->note_self_forwarding_removal_start(during_initial_mark, during_conc_mark); _g1h->check_bitmaps("Self-Forwarding Ptr Removal", hr); diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1GCPhaseTimes.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1GCPhaseTimes.cpp index 3dc72522c07..49232d60728 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1GCPhaseTimes.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1GCPhaseTimes.cpp @@ -167,7 +167,6 @@ G1GCPhaseTimes::G1GCPhaseTimes(uint max_gc_threads) : _last_update_rs_processed_buffers(_max_gc_threads, "%d"), _last_scan_rs_times_ms(_max_gc_threads, "%.1lf"), _last_strong_code_root_scan_times_ms(_max_gc_threads, "%.1lf"), - _last_strong_code_root_mark_times_ms(_max_gc_threads, "%.1lf"), _last_obj_copy_times_ms(_max_gc_threads, "%.1lf"), _last_termination_times_ms(_max_gc_threads, "%.1lf"), _last_termination_attempts(_max_gc_threads, SIZE_FORMAT), @@ -194,7 +193,6 @@ void G1GCPhaseTimes::note_gc_start(uint active_gc_threads) { _last_update_rs_processed_buffers.reset(); _last_scan_rs_times_ms.reset(); _last_strong_code_root_scan_times_ms.reset(); - _last_strong_code_root_mark_times_ms.reset(); _last_obj_copy_times_ms.reset(); _last_termination_times_ms.reset(); _last_termination_attempts.reset(); @@ -215,7 +213,6 @@ void G1GCPhaseTimes::note_gc_end() { _last_update_rs_processed_buffers.verify(); _last_scan_rs_times_ms.verify(); _last_strong_code_root_scan_times_ms.verify(); - _last_strong_code_root_mark_times_ms.verify(); _last_obj_copy_times_ms.verify(); _last_termination_times_ms.verify(); _last_termination_attempts.verify(); @@ -230,7 +227,6 @@ void G1GCPhaseTimes::note_gc_end() { _last_update_rs_times_ms.get(i) + _last_scan_rs_times_ms.get(i) + _last_strong_code_root_scan_times_ms.get(i) + - _last_strong_code_root_mark_times_ms.get(i) + _last_obj_copy_times_ms.get(i) + _last_termination_times_ms.get(i); @@ -302,9 +298,6 @@ void G1GCPhaseTimes::print(double pause_time_sec) { if (_last_satb_filtering_times_ms.sum() > 0.0) { _last_satb_filtering_times_ms.print(2, "SATB Filtering (ms)"); } - if (_last_strong_code_root_mark_times_ms.sum() > 0.0) { - _last_strong_code_root_mark_times_ms.print(2, "Code Root Marking (ms)"); - } _last_update_rs_times_ms.print(2, "Update RS (ms)"); _last_update_rs_processed_buffers.print(3, "Processed Buffers"); _last_scan_rs_times_ms.print(2, "Scan RS (ms)"); @@ -322,9 +315,6 @@ void G1GCPhaseTimes::print(double pause_time_sec) { if (_last_satb_filtering_times_ms.sum() > 0.0) { _last_satb_filtering_times_ms.print(1, "SATB Filtering (ms)"); } - if (_last_strong_code_root_mark_times_ms.sum() > 0.0) { - _last_strong_code_root_mark_times_ms.print(1, "Code Root Marking (ms)"); - } _last_update_rs_times_ms.print(1, "Update RS (ms)"); _last_update_rs_processed_buffers.print(2, "Processed Buffers"); _last_scan_rs_times_ms.print(1, "Scan RS (ms)"); diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1GCPhaseTimes.hpp b/hotspot/src/share/vm/gc_implementation/g1/g1GCPhaseTimes.hpp index 221a7a1240d..12a3a7dd21b 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1GCPhaseTimes.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1GCPhaseTimes.hpp @@ -120,7 +120,6 @@ class G1GCPhaseTimes : public CHeapObj { WorkerDataArray _last_update_rs_processed_buffers; WorkerDataArray _last_scan_rs_times_ms; WorkerDataArray _last_strong_code_root_scan_times_ms; - WorkerDataArray _last_strong_code_root_mark_times_ms; WorkerDataArray _last_obj_copy_times_ms; WorkerDataArray _last_termination_times_ms; WorkerDataArray _last_termination_attempts; @@ -199,10 +198,6 @@ class G1GCPhaseTimes : public CHeapObj { _last_strong_code_root_scan_times_ms.set(worker_i, ms); } - void record_strong_code_root_mark_time(uint worker_i, double ms) { - _last_strong_code_root_mark_times_ms.set(worker_i, ms); - } - void record_obj_copy_time(uint worker_i, double ms) { _last_obj_copy_times_ms.set(worker_i, ms); } @@ -369,10 +364,6 @@ class G1GCPhaseTimes : public CHeapObj { return _last_strong_code_root_scan_times_ms.average(); } - double average_last_strong_code_root_mark_time(){ - return _last_strong_code_root_mark_times_ms.average(); - } - double average_last_obj_copy_time() { return _last_obj_copy_times_ms.average(); } diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp index ae3b83072da..6a2627d10fc 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp @@ -129,13 +129,15 @@ void G1MarkSweep::mark_sweep_phase1(bool& marked_for_unloading, SharedHeap* sh = SharedHeap::heap(); - // Need cleared claim bits for the strong roots processing + // Need cleared claim bits for the roots processing ClassLoaderDataGraph::clear_claimed_marks(); - sh->process_strong_roots(true, // activate StrongRootsScope - SharedHeap::SO_SystemClasses, + MarkingCodeBlobClosure follow_code_closure(&GenMarkSweep::follow_root_closure, !CodeBlobToOopClosure::FixRelocations); + sh->process_strong_roots(true, // activate StrongRootsScope + SharedHeap::SO_None, &GenMarkSweep::follow_root_closure, - &GenMarkSweep::follow_klass_closure); + &GenMarkSweep::follow_cld_closure, + &follow_code_closure); // Process reference objects found during marking ReferenceProcessor* rp = GenMarkSweep::ref_processor(); @@ -304,13 +306,15 @@ void G1MarkSweep::mark_sweep_phase3() { SharedHeap* sh = SharedHeap::heap(); - // Need cleared claim bits for the strong roots processing + // Need cleared claim bits for the roots processing ClassLoaderDataGraph::clear_claimed_marks(); - sh->process_strong_roots(true, // activate StrongRootsScope - SharedHeap::SO_AllClasses | SharedHeap::SO_Strings | SharedHeap::SO_AllCodeCache, - &GenMarkSweep::adjust_pointer_closure, - &GenMarkSweep::adjust_klass_closure); + CodeBlobToOopClosure adjust_code_closure(&GenMarkSweep::adjust_pointer_closure, CodeBlobToOopClosure::FixRelocations); + sh->process_all_roots(true, // activate StrongRootsScope + SharedHeap::SO_AllCodeCache, + &GenMarkSweep::adjust_pointer_closure, + &GenMarkSweep::adjust_cld_closure, + &adjust_code_closure); assert(GenMarkSweep::ref_processor() == g1h->ref_processor_stw(), "Sanity"); g1h->ref_processor_stw()->weak_oops_do(&GenMarkSweep::adjust_pointer_closure); diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1OopClosures.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1OopClosures.cpp index a30b00416bc..2bdbca58686 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1OopClosures.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1OopClosures.cpp @@ -25,7 +25,28 @@ #include "precompiled.hpp" #include "gc_implementation/g1/g1CollectedHeap.inline.hpp" #include "gc_implementation/g1/g1OopClosures.inline.hpp" +#include "gc_implementation/g1/g1ParScanThreadState.hpp" G1ParCopyHelper::G1ParCopyHelper(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state) : G1ParClosureSuper(g1, par_scan_state), _scanned_klass(NULL), _cm(_g1->concurrent_mark()) {} + +G1ParClosureSuper::G1ParClosureSuper(G1CollectedHeap* g1) : + _g1(g1), _par_scan_state(NULL), _worker_id(UINT_MAX) { } + +G1ParClosureSuper::G1ParClosureSuper(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state) : + _g1(g1), _par_scan_state(NULL), + _worker_id(UINT_MAX) { + set_par_scan_thread_state(par_scan_state); +} + +void G1ParClosureSuper::set_par_scan_thread_state(G1ParScanThreadState* par_scan_state) { + assert(_par_scan_state == NULL, "_par_scan_state must only be set once"); + assert(par_scan_state != NULL, "Must set par_scan_state to non-NULL."); + + _par_scan_state = par_scan_state; + _worker_id = par_scan_state->queue_num(); + + assert(_worker_id < MAX2((uint)ParallelGCThreads, 1u), + err_msg("The given worker id %u must be less than the number of threads %u", _worker_id, MAX2((uint)ParallelGCThreads, 1u))); +} diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1OopClosures.hpp b/hotspot/src/share/vm/gc_implementation/g1/g1OopClosures.hpp index fd22e81bdca..79f8b52f682 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1OopClosures.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1OopClosures.hpp @@ -25,6 +25,8 @@ #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1OOPCLOSURES_HPP #define SHARE_VM_GC_IMPLEMENTATION_G1_G1OOPCLOSURES_HPP +#include "memory/iterator.hpp" + class HeapRegion; class G1CollectedHeap; class G1RemSet; @@ -51,8 +53,13 @@ protected: G1ParScanThreadState* _par_scan_state; uint _worker_id; public: + // Initializes the instance, leaving _par_scan_state uninitialized. Must be done + // later using the set_par_scan_thread_state() method. + G1ParClosureSuper(G1CollectedHeap* g1); G1ParClosureSuper(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state); bool apply_to_weak_ref_discovered_field() { return true; } + + void set_par_scan_thread_state(G1ParScanThreadState* par_scan_state); }; class G1ParPushHeapRSClosure : public G1ParClosureSuper { @@ -68,9 +75,8 @@ public: class G1ParScanClosure : public G1ParClosureSuper { public: - G1ParScanClosure(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state, ReferenceProcessor* rp) : - G1ParClosureSuper(g1, par_scan_state) - { + G1ParScanClosure(G1CollectedHeap* g1, ReferenceProcessor* rp) : + G1ParClosureSuper(g1) { assert(_ref_processor == NULL, "sanity"); _ref_processor = rp; } @@ -102,7 +108,7 @@ protected: template void do_klass_barrier(T* p, oop new_obj); }; -template +template class G1ParCopyClosure : public G1ParCopyHelper { private: template void do_oop_work(T* p); @@ -117,19 +123,19 @@ public: template void do_oop_nv(T* p) { do_oop_work(p); } virtual void do_oop(oop* p) { do_oop_nv(p); } virtual void do_oop(narrowOop* p) { do_oop_nv(p); } + + G1CollectedHeap* g1() { return _g1; }; + G1ParScanThreadState* pss() { return _par_scan_state; } + ReferenceProcessor* rp() { return _ref_processor; }; }; -typedef G1ParCopyClosure G1ParScanExtRootClosure; -typedef G1ParCopyClosure G1ParScanMetadataClosure; - - -typedef G1ParCopyClosure G1ParScanAndMarkExtRootClosure; -typedef G1ParCopyClosure G1ParScanAndMarkMetadataClosure; - +typedef G1ParCopyClosure G1ParScanExtRootClosure; +typedef G1ParCopyClosure G1ParScanAndMarkExtRootClosure; +typedef G1ParCopyClosure G1ParScanAndMarkWeakExtRootClosure; // We use a separate closure to handle references during evacuation // failure processing. -typedef G1ParCopyClosure G1ParScanHeapEvacFailureClosure; +typedef G1ParCopyClosure G1ParScanHeapEvacFailureClosure; class FilterIntoCSClosure: public ExtendedOopClosure { G1CollectedHeap* _g1; @@ -160,10 +166,11 @@ public: }; // Closure for iterating over object fields during concurrent marking -class G1CMOopClosure : public ExtendedOopClosure { +class G1CMOopClosure : public MetadataAwareOopClosure { +protected: + ConcurrentMark* _cm; private: G1CollectedHeap* _g1h; - ConcurrentMark* _cm; CMTask* _task; public: G1CMOopClosure(G1CollectedHeap* g1h, ConcurrentMark* cm, CMTask* task); @@ -173,7 +180,7 @@ public: }; // Closure to scan the root regions during concurrent marking -class G1RootRegionScanClosure : public ExtendedOopClosure { +class G1RootRegionScanClosure : public MetadataAwareOopClosure { private: G1CollectedHeap* _g1h; ConcurrentMark* _cm; diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1OopClosures.inline.hpp b/hotspot/src/share/vm/gc_implementation/g1/g1OopClosures.inline.hpp index 48c024d7470..2db5b9bfa1a 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1OopClosures.inline.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1OopClosures.inline.hpp @@ -28,9 +28,11 @@ #include "gc_implementation/g1/concurrentMark.inline.hpp" #include "gc_implementation/g1/g1CollectedHeap.hpp" #include "gc_implementation/g1/g1OopClosures.hpp" +#include "gc_implementation/g1/g1ParScanThreadState.inline.hpp" #include "gc_implementation/g1/g1RemSet.hpp" #include "gc_implementation/g1/g1RemSet.inline.hpp" #include "gc_implementation/g1/heapRegionRemSet.hpp" +#include "memory/iterator.inline.hpp" #include "runtime/prefetch.inline.hpp" /* @@ -107,10 +109,6 @@ inline void G1ParPushHeapRSClosure::do_oop_nv(T* p) { template inline void G1CMOopClosure::do_oop_nv(T* p) { - assert(_g1h->is_in_g1_reserved((HeapWord*) p), "invariant"); - assert(!_g1h->is_on_master_free_list( - _g1h->heap_region_containing((HeapWord*) p)), "invariant"); - oop obj = oopDesc::load_decode_heap_oop(p); if (_cm->verbose_high()) { gclog_or_tty->print_cr("[%u] we're looking at location " diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1ParScanThreadState.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1ParScanThreadState.cpp new file mode 100644 index 00000000000..89e3e813b98 --- /dev/null +++ b/hotspot/src/share/vm/gc_implementation/g1/g1ParScanThreadState.cpp @@ -0,0 +1,306 @@ +/* + * 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#include "precompiled.hpp" +#include "gc_implementation/g1/g1CollectedHeap.inline.hpp" +#include "gc_implementation/g1/g1OopClosures.inline.hpp" +#include "gc_implementation/g1/g1ParScanThreadState.inline.hpp" +#include "oops/oop.inline.hpp" +#include "oops/oop.pcgc.inline.hpp" +#include "runtime/prefetch.inline.hpp" + +G1ParScanThreadState::G1ParScanThreadState(G1CollectedHeap* g1h, uint queue_num, ReferenceProcessor* rp) + : _g1h(g1h), + _refs(g1h->task_queue(queue_num)), + _dcq(&g1h->dirty_card_queue_set()), + _ct_bs(g1h->g1_barrier_set()), + _g1_rem(g1h->g1_rem_set()), + _hash_seed(17), _queue_num(queue_num), + _term_attempts(0), + _surviving_alloc_buffer(g1h->desired_plab_sz(GCAllocForSurvived)), + _tenured_alloc_buffer(g1h->desired_plab_sz(GCAllocForTenured)), + _age_table(false), _scanner(g1h, rp), + _strong_roots_time(0), _term_time(0), + _alloc_buffer_waste(0), _undo_waste(0) { + _scanner.set_par_scan_thread_state(this); + // we allocate G1YoungSurvRateNumRegions plus one entries, since + // we "sacrifice" entry 0 to keep track of surviving bytes for + // non-young regions (where the age is -1) + // We also add a few elements at the beginning and at the end in + // an attempt to eliminate cache contention + uint real_length = 1 + _g1h->g1_policy()->young_cset_region_length(); + uint array_length = PADDING_ELEM_NUM + + real_length + + PADDING_ELEM_NUM; + _surviving_young_words_base = NEW_C_HEAP_ARRAY(size_t, array_length, mtGC); + if (_surviving_young_words_base == NULL) + vm_exit_out_of_memory(array_length * sizeof(size_t), OOM_MALLOC_ERROR, + "Not enough space for young surv histo."); + _surviving_young_words = _surviving_young_words_base + PADDING_ELEM_NUM; + memset(_surviving_young_words, 0, (size_t) real_length * sizeof(size_t)); + + _alloc_buffers[GCAllocForSurvived] = &_surviving_alloc_buffer; + _alloc_buffers[GCAllocForTenured] = &_tenured_alloc_buffer; + + _start = os::elapsedTime(); +} + +G1ParScanThreadState::~G1ParScanThreadState() { + retire_alloc_buffers(); + FREE_C_HEAP_ARRAY(size_t, _surviving_young_words_base, mtGC); +} + +void +G1ParScanThreadState::print_termination_stats_hdr(outputStream* const st) +{ + st->print_raw_cr("GC Termination Stats"); + st->print_raw_cr(" elapsed --strong roots-- -------termination-------" + " ------waste (KiB)------"); + st->print_raw_cr("thr ms ms % ms % attempts" + " total alloc undo"); + st->print_raw_cr("--- --------- --------- ------ --------- ------ --------" + " ------- ------- -------"); +} + +void +G1ParScanThreadState::print_termination_stats(int i, + outputStream* const st) const +{ + const double elapsed_ms = elapsed_time() * 1000.0; + const double s_roots_ms = strong_roots_time() * 1000.0; + const double term_ms = term_time() * 1000.0; + st->print_cr("%3d %9.2f %9.2f %6.2f " + "%9.2f %6.2f " SIZE_FORMAT_W(8) " " + SIZE_FORMAT_W(7) " " SIZE_FORMAT_W(7) " " SIZE_FORMAT_W(7), + i, elapsed_ms, s_roots_ms, s_roots_ms * 100 / elapsed_ms, + term_ms, term_ms * 100 / elapsed_ms, term_attempts(), + (alloc_buffer_waste() + undo_waste()) * HeapWordSize / K, + alloc_buffer_waste() * HeapWordSize / K, + undo_waste() * HeapWordSize / K); +} + +#ifdef ASSERT +bool G1ParScanThreadState::verify_ref(narrowOop* ref) const { + assert(ref != NULL, "invariant"); + assert(UseCompressedOops, "sanity"); + assert(!has_partial_array_mask(ref), err_msg("ref=" PTR_FORMAT, p2i(ref))); + oop p = oopDesc::load_decode_heap_oop(ref); + assert(_g1h->is_in_g1_reserved(p), + err_msg("ref=" PTR_FORMAT " p=" PTR_FORMAT, p2i(ref), p2i(p))); + return true; +} + +bool G1ParScanThreadState::verify_ref(oop* ref) const { + assert(ref != NULL, "invariant"); + if (has_partial_array_mask(ref)) { + // Must be in the collection set--it's already been copied. + oop p = clear_partial_array_mask(ref); + assert(_g1h->obj_in_cs(p), + err_msg("ref=" PTR_FORMAT " p=" PTR_FORMAT, p2i(ref), p2i(p))); + } else { + oop p = oopDesc::load_decode_heap_oop(ref); + assert(_g1h->is_in_g1_reserved(p), + err_msg("ref=" PTR_FORMAT " p=" PTR_FORMAT, p2i(ref), p2i(p))); + } + return true; +} + +bool G1ParScanThreadState::verify_task(StarTask ref) const { + if (ref.is_narrow()) { + return verify_ref((narrowOop*) ref); + } else { + return verify_ref((oop*) ref); + } +} +#endif // ASSERT + +void G1ParScanThreadState::trim_queue() { + assert(_evac_failure_cl != NULL, "not set"); + + StarTask ref; + do { + // Drain the overflow stack first, so other threads can steal. + while (_refs->pop_overflow(ref)) { + dispatch_reference(ref); + } + + while (_refs->pop_local(ref)) { + dispatch_reference(ref); + } + } while (!_refs->is_empty()); +} + +oop G1ParScanThreadState::copy_to_survivor_space(oop const old) { + size_t word_sz = old->size(); + HeapRegion* from_region = _g1h->heap_region_containing_raw(old); + // +1 to make the -1 indexes valid... + int young_index = from_region->young_index_in_cset()+1; + assert( (from_region->is_young() && young_index > 0) || + (!from_region->is_young() && young_index == 0), "invariant" ); + G1CollectorPolicy* g1p = _g1h->g1_policy(); + markOop m = old->mark(); + int age = m->has_displaced_mark_helper() ? m->displaced_mark_helper()->age() + : m->age(); + GCAllocPurpose alloc_purpose = g1p->evacuation_destination(from_region, age, + word_sz); + HeapWord* obj_ptr = allocate(alloc_purpose, word_sz); +#ifndef PRODUCT + // Should this evacuation fail? + if (_g1h->evacuation_should_fail()) { + if (obj_ptr != NULL) { + undo_allocation(alloc_purpose, obj_ptr, word_sz); + obj_ptr = NULL; + } + } +#endif // !PRODUCT + + if (obj_ptr == NULL) { + // This will either forward-to-self, or detect that someone else has + // installed a forwarding pointer. + return _g1h->handle_evacuation_failure_par(this, old); + } + + oop obj = oop(obj_ptr); + + // We're going to allocate linearly, so might as well prefetch ahead. + Prefetch::write(obj_ptr, PrefetchCopyIntervalInBytes); + + oop forward_ptr = old->forward_to_atomic(obj); + if (forward_ptr == NULL) { + Copy::aligned_disjoint_words((HeapWord*) old, obj_ptr, word_sz); + + // alloc_purpose is just a hint to allocate() above, recheck the type of region + // we actually allocated from and update alloc_purpose accordingly + HeapRegion* to_region = _g1h->heap_region_containing_raw(obj_ptr); + alloc_purpose = to_region->is_young() ? GCAllocForSurvived : GCAllocForTenured; + + if (g1p->track_object_age(alloc_purpose)) { + // We could simply do obj->incr_age(). However, this causes a + // performance issue. obj->incr_age() will first check whether + // the object has a displaced mark by checking its mark word; + // getting the mark word from the new location of the object + // stalls. So, given that we already have the mark word and we + // are about to install it anyway, it's better to increase the + // age on the mark word, when the object does not have a + // displaced mark word. We're not expecting many objects to have + // a displaced marked word, so that case is not optimized + // further (it could be...) and we simply call obj->incr_age(). + + if (m->has_displaced_mark_helper()) { + // in this case, we have to install the mark word first, + // otherwise obj looks to be forwarded (the old mark word, + // which contains the forward pointer, was copied) + obj->set_mark(m); + obj->incr_age(); + } else { + m = m->incr_age(); + obj->set_mark(m); + } + age_table()->add(obj, word_sz); + } else { + obj->set_mark(m); + } + + if (G1StringDedup::is_enabled()) { + G1StringDedup::enqueue_from_evacuation(from_region->is_young(), + to_region->is_young(), + queue_num(), + obj); + } + + size_t* surv_young_words = surviving_young_words(); + surv_young_words[young_index] += word_sz; + + if (obj->is_objArray() && arrayOop(obj)->length() >= ParGCArrayScanChunk) { + // We keep track of the next start index in the length field of + // the to-space object. The actual length can be found in the + // length field of the from-space object. + arrayOop(obj)->set_length(0); + oop* old_p = set_partial_array_mask(old); + push_on_queue(old_p); + } else { + // No point in using the slower heap_region_containing() method, + // given that we know obj is in the heap. + _scanner.set_region(_g1h->heap_region_containing_raw(obj)); + obj->oop_iterate_backwards(&_scanner); + } + } else { + undo_allocation(alloc_purpose, obj_ptr, word_sz); + obj = forward_ptr; + } + return obj; +} + +HeapWord* G1ParScanThreadState::allocate_slow(GCAllocPurpose purpose, size_t word_sz) { + HeapWord* obj = NULL; + size_t gclab_word_size = _g1h->desired_plab_sz(purpose); + if (word_sz * 100 < gclab_word_size * ParallelGCBufferWastePct) { + G1ParGCAllocBuffer* alloc_buf = alloc_buffer(purpose); + add_to_alloc_buffer_waste(alloc_buf->words_remaining()); + alloc_buf->retire(false /* end_of_gc */, false /* retain */); + + HeapWord* buf = _g1h->par_allocate_during_gc(purpose, gclab_word_size); + if (buf == NULL) { + return NULL; // Let caller handle allocation failure. + } + // Otherwise. + alloc_buf->set_word_size(gclab_word_size); + alloc_buf->set_buf(buf); + + obj = alloc_buf->allocate(word_sz); + assert(obj != NULL, "buffer was definitely big enough..."); + } else { + obj = _g1h->par_allocate_during_gc(purpose, word_sz); + } + return obj; +} + +void G1ParScanThreadState::undo_allocation(GCAllocPurpose purpose, HeapWord* obj, size_t word_sz) { + if (alloc_buffer(purpose)->contains(obj)) { + assert(alloc_buffer(purpose)->contains(obj + word_sz - 1), + "should contain whole object"); + alloc_buffer(purpose)->undo_allocation(obj, word_sz); + } else { + CollectedHeap::fill_with_object(obj, word_sz); + add_to_undo_waste(word_sz); + } +} + +HeapWord* G1ParScanThreadState::allocate(GCAllocPurpose purpose, size_t word_sz) { + HeapWord* obj = alloc_buffer(purpose)->allocate(word_sz); + if (obj != NULL) { + return obj; + } + return allocate_slow(purpose, word_sz); +} + +void G1ParScanThreadState::retire_alloc_buffers() { + for (int ap = 0; ap < GCAllocPurposeCount; ++ap) { + size_t waste = _alloc_buffers[ap]->words_remaining(); + add_to_alloc_buffer_waste(waste); + _alloc_buffers[ap]->flush_stats_and_retire(_g1h->stats_for_purpose((GCAllocPurpose)ap), + true /* end_of_gc */, + false /* retain */); + } +} diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1ParScanThreadState.hpp b/hotspot/src/share/vm/gc_implementation/g1/g1ParScanThreadState.hpp new file mode 100644 index 00000000000..e590a9ee86d --- /dev/null +++ b/hotspot/src/share/vm/gc_implementation/g1/g1ParScanThreadState.hpp @@ -0,0 +1,227 @@ +/* + * 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1PARSCANTHREADSTATE_HPP +#define SHARE_VM_GC_IMPLEMENTATION_G1_G1PARSCANTHREADSTATE_HPP + +#include "gc_implementation/g1/dirtyCardQueue.hpp" +#include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp" +#include "gc_implementation/g1/g1CollectedHeap.hpp" +#include "gc_implementation/g1/g1CollectorPolicy.hpp" +#include "gc_implementation/g1/g1OopClosures.hpp" +#include "gc_implementation/g1/g1RemSet.hpp" +#include "gc_implementation/shared/ageTable.hpp" +#include "memory/allocation.hpp" +#include "oops/oop.hpp" + +class HeapRegion; +class outputStream; + +class G1ParScanThreadState : public StackObj { + private: + G1CollectedHeap* _g1h; + RefToScanQueue* _refs; + DirtyCardQueue _dcq; + G1SATBCardTableModRefBS* _ct_bs; + G1RemSet* _g1_rem; + + G1ParGCAllocBuffer _surviving_alloc_buffer; + G1ParGCAllocBuffer _tenured_alloc_buffer; + G1ParGCAllocBuffer* _alloc_buffers[GCAllocPurposeCount]; + ageTable _age_table; + + G1ParScanClosure _scanner; + + size_t _alloc_buffer_waste; + size_t _undo_waste; + + OopsInHeapRegionClosure* _evac_failure_cl; + + int _hash_seed; + uint _queue_num; + + size_t _term_attempts; + + double _start; + double _start_strong_roots; + double _strong_roots_time; + double _start_term; + double _term_time; + + // Map from young-age-index (0 == not young, 1 is youngest) to + // surviving words. base is what we get back from the malloc call + size_t* _surviving_young_words_base; + // this points into the array, as we use the first few entries for padding + size_t* _surviving_young_words; + +#define PADDING_ELEM_NUM (DEFAULT_CACHE_LINE_SIZE / sizeof(size_t)) + + void add_to_alloc_buffer_waste(size_t waste) { _alloc_buffer_waste += waste; } + + void add_to_undo_waste(size_t waste) { _undo_waste += waste; } + + DirtyCardQueue& dirty_card_queue() { return _dcq; } + G1SATBCardTableModRefBS* ctbs() { return _ct_bs; } + + template inline void immediate_rs_update(HeapRegion* from, T* p, int tid); + + template void deferred_rs_update(HeapRegion* from, T* p, int tid) { + // If the new value of the field points to the same region or + // is the to-space, we don't need to include it in the Rset updates. + if (!from->is_in_reserved(oopDesc::load_decode_heap_oop(p)) && !from->is_survivor()) { + size_t card_index = ctbs()->index_for(p); + // If the card hasn't been added to the buffer, do it. + if (ctbs()->mark_card_deferred(card_index)) { + dirty_card_queue().enqueue((jbyte*)ctbs()->byte_for_index(card_index)); + } + } + } + + public: + G1ParScanThreadState(G1CollectedHeap* g1h, uint queue_num, ReferenceProcessor* rp); + ~G1ParScanThreadState(); + + ageTable* age_table() { return &_age_table; } + + G1ParGCAllocBuffer* alloc_buffer(GCAllocPurpose purpose) { + return _alloc_buffers[purpose]; + } + + size_t alloc_buffer_waste() const { return _alloc_buffer_waste; } + size_t undo_waste() const { return _undo_waste; } + +#ifdef ASSERT + bool queue_is_empty() const { return _refs->is_empty(); } + + bool verify_ref(narrowOop* ref) const; + bool verify_ref(oop* ref) const; + bool verify_task(StarTask ref) const; +#endif // ASSERT + + template void push_on_queue(T* ref) { + assert(verify_ref(ref), "sanity"); + _refs->push(ref); + } + + template inline void update_rs(HeapRegion* from, T* p, int tid); + + private: + + inline HeapWord* allocate(GCAllocPurpose purpose, size_t word_sz); + inline HeapWord* allocate_slow(GCAllocPurpose purpose, size_t word_sz); + inline void undo_allocation(GCAllocPurpose purpose, HeapWord* obj, size_t word_sz); + + public: + + void set_evac_failure_closure(OopsInHeapRegionClosure* evac_failure_cl) { + _evac_failure_cl = evac_failure_cl; + } + + OopsInHeapRegionClosure* evac_failure_closure() { return _evac_failure_cl; } + + int* hash_seed() { return &_hash_seed; } + uint queue_num() { return _queue_num; } + + size_t term_attempts() const { return _term_attempts; } + void note_term_attempt() { _term_attempts++; } + + void start_strong_roots() { + _start_strong_roots = os::elapsedTime(); + } + void end_strong_roots() { + _strong_roots_time += (os::elapsedTime() - _start_strong_roots); + } + double strong_roots_time() const { return _strong_roots_time; } + + void start_term_time() { + note_term_attempt(); + _start_term = os::elapsedTime(); + } + void end_term_time() { + _term_time += (os::elapsedTime() - _start_term); + } + double term_time() const { return _term_time; } + + double elapsed_time() const { + return os::elapsedTime() - _start; + } + + static void print_termination_stats_hdr(outputStream* const st = gclog_or_tty); + void print_termination_stats(int i, outputStream* const st = gclog_or_tty) const; + + size_t* surviving_young_words() { + // We add on to hide entry 0 which accumulates surviving words for + // age -1 regions (i.e. non-young ones) + return _surviving_young_words; + } + + private: + void retire_alloc_buffers(); + + #define G1_PARTIAL_ARRAY_MASK 0x2 + + inline bool has_partial_array_mask(oop* ref) const { + return ((uintptr_t)ref & G1_PARTIAL_ARRAY_MASK) == G1_PARTIAL_ARRAY_MASK; + } + + // We never encode partial array oops as narrowOop*, so return false immediately. + // This allows the compiler to create optimized code when popping references from + // the work queue. + inline bool has_partial_array_mask(narrowOop* ref) const { + assert(((uintptr_t)ref & G1_PARTIAL_ARRAY_MASK) != G1_PARTIAL_ARRAY_MASK, "Partial array oop reference encoded as narrowOop*"); + return false; + } + + // Only implement set_partial_array_mask() for regular oops, not for narrowOops. + // We always encode partial arrays as regular oop, to allow the + // specialization for has_partial_array_mask() for narrowOops above. + // This means that unintentional use of this method with narrowOops are caught + // by the compiler. + inline oop* set_partial_array_mask(oop obj) const { + assert(((uintptr_t)(void *)obj & G1_PARTIAL_ARRAY_MASK) == 0, "Information loss!"); + return (oop*) ((uintptr_t)(void *)obj | G1_PARTIAL_ARRAY_MASK); + } + + inline oop clear_partial_array_mask(oop* ref) const { + return cast_to_oop((intptr_t)ref & ~G1_PARTIAL_ARRAY_MASK); + } + + inline void do_oop_partial_array(oop* p); + + // This method is applied to the fields of the objects that have just been copied. + template inline void do_oop_evac(T* p, HeapRegion* from); + + template inline void deal_with_reference(T* ref_to_scan); + + inline void dispatch_reference(StarTask ref); + public: + + oop copy_to_survivor_space(oop const obj); + + void trim_queue(); + + inline void steal_and_trim_queue(RefToScanQueueSet *task_queues); +}; + +#endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1PARSCANTHREADSTATE_HPP diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1ParScanThreadState.inline.hpp b/hotspot/src/share/vm/gc_implementation/g1/g1ParScanThreadState.inline.hpp new file mode 100644 index 00000000000..fc2fbe3ff45 --- /dev/null +++ b/hotspot/src/share/vm/gc_implementation/g1/g1ParScanThreadState.inline.hpp @@ -0,0 +1,154 @@ +/* + * 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1PARSCANTHREADSTATE_INLINE_HPP +#define SHARE_VM_GC_IMPLEMENTATION_G1_G1PARSCANTHREADSTATE_INLINE_HPP + +#include "gc_implementation/g1/g1ParScanThreadState.hpp" +#include "gc_implementation/g1/g1RemSet.inline.hpp" +#include "oops/oop.inline.hpp" + +template inline void G1ParScanThreadState::immediate_rs_update(HeapRegion* from, T* p, int tid) { + if (!from->is_survivor()) { + _g1_rem->par_write_ref(from, p, tid); + } +} + +template void G1ParScanThreadState::update_rs(HeapRegion* from, T* p, int tid) { + if (G1DeferredRSUpdate) { + deferred_rs_update(from, p, tid); + } else { + immediate_rs_update(from, p, tid); + } +} + +template void G1ParScanThreadState::do_oop_evac(T* p, HeapRegion* from) { + assert(!oopDesc::is_null(oopDesc::load_decode_heap_oop(p)), + "Reference should not be NULL here as such are never pushed to the task queue."); + oop obj = oopDesc::load_decode_heap_oop_not_null(p); + + // Although we never intentionally push references outside of the collection + // set, due to (benign) races in the claim mechanism during RSet scanning more + // than one thread might claim the same card. So the same card may be + // processed multiple times. So redo this check. + if (_g1h->in_cset_fast_test(obj)) { + oop forwardee; + if (obj->is_forwarded()) { + forwardee = obj->forwardee(); + } else { + forwardee = copy_to_survivor_space(obj); + } + assert(forwardee != NULL, "forwardee should not be NULL"); + oopDesc::encode_store_heap_oop(p, forwardee); + } + + assert(obj != NULL, "Must be"); + update_rs(from, p, queue_num()); +} + +inline void G1ParScanThreadState::do_oop_partial_array(oop* p) { + assert(has_partial_array_mask(p), "invariant"); + oop from_obj = clear_partial_array_mask(p); + + assert(Universe::heap()->is_in_reserved(from_obj), "must be in heap."); + assert(from_obj->is_objArray(), "must be obj array"); + objArrayOop from_obj_array = objArrayOop(from_obj); + // The from-space object contains the real length. + int length = from_obj_array->length(); + + assert(from_obj->is_forwarded(), "must be forwarded"); + oop to_obj = from_obj->forwardee(); + assert(from_obj != to_obj, "should not be chunking self-forwarded objects"); + objArrayOop to_obj_array = objArrayOop(to_obj); + // We keep track of the next start index in the length field of the + // to-space object. + int next_index = to_obj_array->length(); + assert(0 <= next_index && next_index < length, + err_msg("invariant, next index: %d, length: %d", next_index, length)); + + int start = next_index; + int end = length; + int remainder = end - start; + // We'll try not to push a range that's smaller than ParGCArrayScanChunk. + if (remainder > 2 * ParGCArrayScanChunk) { + end = start + ParGCArrayScanChunk; + to_obj_array->set_length(end); + // Push the remainder before we process the range in case another + // worker has run out of things to do and can steal it. + oop* from_obj_p = set_partial_array_mask(from_obj); + push_on_queue(from_obj_p); + } else { + assert(length == end, "sanity"); + // We'll process the final range for this object. Restore the length + // so that the heap remains parsable in case of evacuation failure. + to_obj_array->set_length(end); + } + _scanner.set_region(_g1h->heap_region_containing_raw(to_obj)); + // Process indexes [start,end). It will also process the header + // along with the first chunk (i.e., the chunk with start == 0). + // Note that at this point the length field of to_obj_array is not + // correct given that we are using it to keep track of the next + // start index. oop_iterate_range() (thankfully!) ignores the length + // field and only relies on the start / end parameters. It does + // however return the size of the object which will be incorrect. So + // we have to ignore it even if we wanted to use it. + to_obj_array->oop_iterate_range(&_scanner, start, end); +} + +template inline void G1ParScanThreadState::deal_with_reference(T* ref_to_scan) { + if (!has_partial_array_mask(ref_to_scan)) { + // Note: we can use "raw" versions of "region_containing" because + // "obj_to_scan" is definitely in the heap, and is not in a + // humongous region. + HeapRegion* r = _g1h->heap_region_containing_raw(ref_to_scan); + do_oop_evac(ref_to_scan, r); + } else { + do_oop_partial_array((oop*)ref_to_scan); + } +} + +inline void G1ParScanThreadState::dispatch_reference(StarTask ref) { + assert(verify_task(ref), "sanity"); + if (ref.is_narrow()) { + deal_with_reference((narrowOop*)ref); + } else { + deal_with_reference((oop*)ref); + } +} + +void G1ParScanThreadState::steal_and_trim_queue(RefToScanQueueSet *task_queues) { + StarTask stolen_task; + while (task_queues->steal(queue_num(), hash_seed(), stolen_task)) { + assert(verify_task(stolen_task), "sanity"); + dispatch_reference(stolen_task); + + // We've just processed a reference and we might have made + // available new entries on the queues. So we have to make sure + // we drain the queues as necessary. + trim_queue(); + } +} + +#endif /* SHARE_VM_GC_IMPLEMENTATION_G1_G1PARSCANTHREADSTATE_INLINE_HPP */ + diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1RemSet.inline.hpp b/hotspot/src/share/vm/gc_implementation/g1/g1RemSet.inline.hpp index cf90d9ca23c..949614b28fc 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1RemSet.inline.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1RemSet.inline.hpp @@ -26,6 +26,7 @@ #define SHARE_VM_GC_IMPLEMENTATION_G1_G1REMSET_INLINE_HPP #include "gc_implementation/g1/g1RemSet.hpp" +#include "gc_implementation/g1/heapRegion.hpp" #include "gc_implementation/g1/heapRegionRemSet.hpp" #include "oops/oop.inline.hpp" diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1SATBCardTableModRefBS.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1SATBCardTableModRefBS.cpp index 53d88d9cb64..bcabcdd9bfa 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1SATBCardTableModRefBS.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1SATBCardTableModRefBS.cpp @@ -66,6 +66,17 @@ G1SATBCardTableModRefBS::write_ref_array_pre_work(T* dst, int count) { } } +void G1SATBCardTableModRefBS::write_ref_array_pre(oop* dst, int count, bool dest_uninitialized) { + if (!dest_uninitialized) { + write_ref_array_pre_work(dst, count); + } +} +void G1SATBCardTableModRefBS::write_ref_array_pre(narrowOop* dst, int count, bool dest_uninitialized) { + if (!dest_uninitialized) { + write_ref_array_pre_work(dst, count); + } +} + bool G1SATBCardTableModRefBS::mark_card_deferred(size_t card_index) { jbyte val = _byte_map[card_index]; // It's already processed diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1SATBCardTableModRefBS.hpp b/hotspot/src/share/vm/gc_implementation/g1/g1SATBCardTableModRefBS.hpp index 99d49cc6185..3e612605c02 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1SATBCardTableModRefBS.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1SATBCardTableModRefBS.hpp @@ -86,16 +86,8 @@ public: } template void write_ref_array_pre_work(T* dst, int count); - virtual void write_ref_array_pre(oop* dst, int count, bool dest_uninitialized) { - if (!dest_uninitialized) { - write_ref_array_pre_work(dst, count); - } - } - virtual void write_ref_array_pre(narrowOop* dst, int count, bool dest_uninitialized) { - if (!dest_uninitialized) { - write_ref_array_pre_work(dst, count); - } - } + virtual void write_ref_array_pre(oop* dst, int count, bool dest_uninitialized); + virtual void write_ref_array_pre(narrowOop* dst, int count, bool dest_uninitialized); /* Claimed and deferred bits are used together in G1 during the evacuation diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1_specialized_oop_closures.hpp b/hotspot/src/share/vm/gc_implementation/g1/g1_specialized_oop_closures.hpp index 538ca4452b9..309392cc0ce 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1_specialized_oop_closures.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1_specialized_oop_closures.hpp @@ -30,14 +30,21 @@ // non-virtually, using a mechanism defined in this file. Extend these // macros in the obvious way to add specializations for new closures. -// Forward declarations. enum G1Barrier { G1BarrierNone, G1BarrierEvac, G1BarrierKlass }; -template +enum G1Mark { + G1MarkNone, + G1MarkFromRoot, + G1MarkPromotedFromRoot +}; + +// Forward declarations. + +template class G1ParCopyClosure; class G1ParScanClosure; diff --git a/hotspot/src/share/vm/gc_implementation/g1/heapRegion.cpp b/hotspot/src/share/vm/gc_implementation/g1/heapRegion.cpp index 037d76ca8aa..cecf891306a 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/heapRegion.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegion.cpp @@ -30,6 +30,7 @@ #include "gc_implementation/g1/heapRegion.inline.hpp" #include "gc_implementation/g1/heapRegionRemSet.hpp" #include "gc_implementation/g1/heapRegionSeq.inline.hpp" +#include "gc_implementation/shared/liveRange.hpp" #include "memory/genOopClosures.inline.hpp" #include "memory/iterator.hpp" #include "memory/space.inline.hpp" @@ -61,7 +62,7 @@ HeapWord* walk_mem_region_loop(ClosureType* cl, G1CollectedHeap* g1h, HeapRegion* hr, HeapWord* cur, HeapWord* top) { oop cur_oop = oop(cur); - int oop_size = cur_oop->size(); + size_t oop_size = hr->block_size(cur); HeapWord* next_obj = cur + oop_size; while (next_obj < top) { // Keep filtering the remembered set. @@ -72,7 +73,7 @@ HeapWord* walk_mem_region_loop(ClosureType* cl, G1CollectedHeap* g1h, } cur = next_obj; cur_oop = oop(cur); - oop_size = cur_oop->size(); + oop_size = hr->block_size(cur); next_obj = cur + oop_size; } return cur; @@ -82,7 +83,7 @@ void HeapRegionDCTOC::walk_mem_region(MemRegion mr, HeapWord* bottom, HeapWord* top) { G1CollectedHeap* g1h = _g1; - int oop_size; + size_t oop_size; ExtendedOopClosure* cl2 = NULL; FilterIntoCSClosure intoCSFilt(this, g1h, _cl); @@ -102,7 +103,7 @@ void HeapRegionDCTOC::walk_mem_region(MemRegion mr, if (!g1h->is_obj_dead(oop(bottom), _hr)) { oop_size = oop(bottom)->oop_iterate(cl2, mr); } else { - oop_size = oop(bottom)->size(); + oop_size = _hr->block_size(bottom); } bottom += oop_size; @@ -374,7 +375,7 @@ HeapRegion::HeapRegion(uint hrs_index, // region. hr_clear(false /*par*/, false /*clear_space*/); set_top(bottom()); - set_saved_mark(); + record_top_and_timestamp(); assert(HeapRegionRemSet::num_par_rem_sets() > 0, "Invariant."); } @@ -394,38 +395,11 @@ CompactibleSpace* HeapRegion::next_compaction_space() const { return NULL; } -void HeapRegion::save_marks() { - set_saved_mark(); -} - -void HeapRegion::oops_in_mr_iterate(MemRegion mr, ExtendedOopClosure* cl) { - HeapWord* p = mr.start(); - HeapWord* e = mr.end(); - oop obj; - while (p < e) { - obj = oop(p); - p += obj->oop_iterate(cl); - } - assert(p == e, "bad memregion: doesn't end on obj boundary"); -} - -#define HeapRegion_OOP_SINCE_SAVE_MARKS_DEFN(OopClosureType, nv_suffix) \ -void HeapRegion::oop_since_save_marks_iterate##nv_suffix(OopClosureType* cl) { \ - ContiguousSpace::oop_since_save_marks_iterate##nv_suffix(cl); \ -} -SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES(HeapRegion_OOP_SINCE_SAVE_MARKS_DEFN) - - -void HeapRegion::oop_before_save_marks_iterate(ExtendedOopClosure* cl) { - oops_in_mr_iterate(MemRegion(bottom(), saved_mark_word()), cl); -} - void HeapRegion::note_self_forwarding_removal_start(bool during_initial_mark, bool during_conc_mark) { // We always recreate the prev marking info and we'll explicitly // mark all objects we find to be self-forwarded on the prev // bitmap. So all objects need to be below PTAMS. - _prev_top_at_mark_start = top(); _prev_marked_bytes = 0; if (during_initial_mark) { @@ -449,6 +423,7 @@ void HeapRegion::note_self_forwarding_removal_end(bool during_initial_mark, assert(0 <= marked_bytes && marked_bytes <= used(), err_msg("marked: "SIZE_FORMAT" used: "SIZE_FORMAT, marked_bytes, used())); + _prev_top_at_mark_start = top(); _prev_marked_bytes = marked_bytes; } @@ -476,7 +451,7 @@ HeapRegion::object_iterate_mem_careful(MemRegion mr, } else if (!g1h->is_obj_dead(obj)) { cl->do_object(obj); } - cur += obj->size(); + cur += block_size(cur); } return NULL; } @@ -548,7 +523,7 @@ oops_on_card_seq_iterate_careful(MemRegion mr, return cur; } // Otherwise... - next = (cur + obj->size()); + next = cur + block_size(cur); } // If we finish the above loop...We have a parseable object that @@ -556,10 +531,9 @@ oops_on_card_seq_iterate_careful(MemRegion mr, // inside or spans the entire region. assert(obj == oop(cur), "sanity"); - assert(cur <= start && - obj->klass_or_null() != NULL && - (cur + obj->size()) > start, - "Loop postcondition"); + assert(cur <= start, "Loop postcondition"); + assert(obj->klass_or_null() != NULL, "Loop postcondition"); + assert((cur + block_size(cur)) > start, "Loop postcondition"); if (!g1h->is_obj_dead(obj)) { obj->oop_iterate(cl, mr); @@ -573,7 +547,7 @@ oops_on_card_seq_iterate_careful(MemRegion mr, }; // Otherwise: - next = (cur + obj->size()); + next = cur + block_size(cur); if (!g1h->is_obj_dead(obj)) { if (next < end || !obj->is_objArray()) { @@ -928,10 +902,11 @@ void HeapRegion::verify(VerifyOption vo, size_t object_num = 0; while (p < top()) { oop obj = oop(p); - size_t obj_size = obj->size(); + size_t obj_size = block_size(p); object_num += 1; - if (is_humongous != g1->isHumongous(obj_size)) { + if (is_humongous != g1->isHumongous(obj_size) && + !g1->is_obj_dead(obj, this)) { // Dead objects may have bigger block_size since they span several objects. gclog_or_tty->print_cr("obj "PTR_FORMAT" is of %shumongous size (" SIZE_FORMAT" words) in a %shumongous region", p, g1->isHumongous(obj_size) ? "" : "non-", @@ -942,7 +917,9 @@ void HeapRegion::verify(VerifyOption vo, // If it returns false, verify_for_object() will output the // appropriate messasge. - if (do_bot_verify && !_offsets.verify_for_object(p, obj_size)) { + if (do_bot_verify && + !g1->is_obj_dead(obj, this) && + !_offsets.verify_for_object(p, obj_size)) { *failures = true; return; } @@ -950,7 +927,10 @@ void HeapRegion::verify(VerifyOption vo, if (!g1->is_obj_dead_cond(obj, this, vo)) { if (obj->is_oop()) { Klass* klass = obj->klass(); - if (!klass->is_metaspace_object()) { + bool is_metaspace_object = Metaspace::contains(klass) || + (vo == VerifyOption_G1UsePrevMarking && + ClassLoaderDataGraph::unload_list_contains(klass)); + if (!is_metaspace_object) { gclog_or_tty->print_cr("klass "PTR_FORMAT" of object "PTR_FORMAT" " "not metadata", klass, (void *)obj); *failures = true; @@ -1064,7 +1044,9 @@ void HeapRegion::verify() const { // away eventually. void G1OffsetTableContigSpace::clear(bool mangle_space) { - ContiguousSpace::clear(mangle_space); + set_top(bottom()); + set_saved_mark_word(bottom()); + CompactibleSpace::clear(mangle_space); _offsets.zero_bottom_entry(); _offsets.initialize_threshold(); } @@ -1102,10 +1084,10 @@ HeapWord* G1OffsetTableContigSpace::saved_mark_word() const { if (_gc_time_stamp < g1h->get_gc_time_stamp()) return top(); else - return ContiguousSpace::saved_mark_word(); + return Space::saved_mark_word(); } -void G1OffsetTableContigSpace::set_saved_mark() { +void G1OffsetTableContigSpace::record_top_and_timestamp() { G1CollectedHeap* g1h = G1CollectedHeap::heap(); unsigned curr_gc_time_stamp = g1h->get_gc_time_stamp(); @@ -1117,7 +1099,7 @@ void G1OffsetTableContigSpace::set_saved_mark() { // of region. If it does so after _gc_time_stamp = ..., then it // will pick up the right saved_mark_word() as the high water mark // of the region. Either way, the behavior will be correct. - ContiguousSpace::set_saved_mark(); + Space::set_saved_mark_word(top()); OrderAccess::storestore(); _gc_time_stamp = curr_gc_time_stamp; // No need to do another barrier to flush the writes above. If @@ -1128,6 +1110,26 @@ void G1OffsetTableContigSpace::set_saved_mark() { } } +void G1OffsetTableContigSpace::safe_object_iterate(ObjectClosure* blk) { + object_iterate(blk); +} + +void G1OffsetTableContigSpace::object_iterate(ObjectClosure* blk) { + HeapWord* p = bottom(); + while (p < top()) { + if (block_is_obj(p)) { + blk->do_object(oop(p)); + } + p += block_size(p); + } +} + +#define block_is_always_obj(q) true +void G1OffsetTableContigSpace::prepare_for_compaction(CompactPoint* cp) { + SCAN_AND_FORWARD(cp, top, block_is_always_obj, block_size); +} +#undef block_is_always_obj + G1OffsetTableContigSpace:: G1OffsetTableContigSpace(G1BlockOffsetSharedArray* sharedOffsetArray, MemRegion mr) : @@ -1137,7 +1139,8 @@ G1OffsetTableContigSpace(G1BlockOffsetSharedArray* sharedOffsetArray, { _offsets.set_space(this); // false ==> we'll do the clearing if there's clearing to be done. - ContiguousSpace::initialize(mr, false, SpaceDecorator::Mangle); + CompactibleSpace::initialize(mr, false, SpaceDecorator::Mangle); + _top = bottom(); _offsets.zero_bottom_entry(); _offsets.initialize_threshold(); } diff --git a/hotspot/src/share/vm/gc_implementation/g1/heapRegion.hpp b/hotspot/src/share/vm/gc_implementation/g1/heapRegion.hpp index 0b9fce740fb..42c9eac5431 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/heapRegion.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegion.hpp @@ -46,8 +46,6 @@ // The solution is to remove this method from the definition // of a Space. -class CompactibleSpace; -class ContiguousSpace; class HeapRegionRemSet; class HeapRegionRemSetIterator; class HeapRegion; @@ -125,9 +123,9 @@ public: // the regions anyway) and at the end of a Full GC. The current scheme // that uses sequential unsigned ints will fail only if we have 4b // evacuation pauses between two cleanups, which is _highly_ unlikely. - -class G1OffsetTableContigSpace: public ContiguousSpace { +class G1OffsetTableContigSpace: public CompactibleSpace { friend class VMStructs; + HeapWord* _top; protected: G1BlockOffsetArrayContigSpace _offsets; Mutex _par_alloc_lock; @@ -144,11 +142,32 @@ class G1OffsetTableContigSpace: public ContiguousSpace { G1OffsetTableContigSpace(G1BlockOffsetSharedArray* sharedOffsetArray, MemRegion mr); + void set_top(HeapWord* value) { _top = value; } + HeapWord* top() const { return _top; } + + protected: + HeapWord** top_addr() { return &_top; } + // Allocation helpers (return NULL if full). + inline HeapWord* allocate_impl(size_t word_size, HeapWord* end_value); + inline HeapWord* par_allocate_impl(size_t word_size, HeapWord* end_value); + + public: + void reset_after_compaction() { set_top(compaction_top()); } + + size_t used() const { return byte_size(bottom(), top()); } + size_t free() const { return byte_size(top(), end()); } + bool is_free_block(const HeapWord* p) const { return p >= top(); } + + MemRegion used_region() const { return MemRegion(bottom(), top()); } + + void object_iterate(ObjectClosure* blk); + void safe_object_iterate(ObjectClosure* blk); + void set_bottom(HeapWord* value); void set_end(HeapWord* value); virtual HeapWord* saved_mark_word() const; - virtual void set_saved_mark(); + void record_top_and_timestamp(); void reset_gc_time_stamp() { _gc_time_stamp = 0; } unsigned get_gc_time_stamp() { return _gc_time_stamp; } @@ -168,6 +187,8 @@ class G1OffsetTableContigSpace: public ContiguousSpace { HeapWord* block_start(const void* p); HeapWord* block_start_const(const void* p) const; + void prepare_for_compaction(CompactPoint* cp); + // Add offset table update. virtual HeapWord* allocate(size_t word_size); HeapWord* par_allocate(size_t word_size); @@ -202,10 +223,6 @@ class HeapRegion: public G1OffsetTableContigSpace { ContinuesHumongous }; - // Requires that the region "mr" be dense with objects, and begin and end - // with an object. - void oops_in_mr_iterate(MemRegion mr, ExtendedOopClosure* cl); - // The remembered set for this region. // (Might want to make this "inline" later, to avoid some alloc failure // issues.) @@ -230,11 +247,9 @@ class HeapRegion: public G1OffsetTableContigSpace { bool _evacuation_failed; // A heap region may be a member one of a number of special subsets, each - // represented as linked lists through the field below. Currently, these - // sets include: + // represented as linked lists through the field below. Currently, there + // is only one set: // The collection set. - // The set of allocation regions used in a collection pause. - // Spaces that may contain gray objects. HeapRegion* _next_in_special_set; // next region in the young "generation" region set @@ -353,14 +368,15 @@ class HeapRegion: public G1OffsetTableContigSpace { ParMarkRootClaimValue = 9 }; - inline HeapWord* par_allocate_no_bot_updates(size_t word_size) { - assert(is_young(), "we can only skip BOT updates on young regions"); - return ContiguousSpace::par_allocate(word_size); - } - inline HeapWord* allocate_no_bot_updates(size_t word_size) { - assert(is_young(), "we can only skip BOT updates on young regions"); - return ContiguousSpace::allocate(word_size); - } + // All allocated blocks are occupied by objects in a HeapRegion + bool block_is_obj(const HeapWord* p) const; + + // Returns the object size for all valid block starts + // and the amount of unallocated words if called on top() + size_t block_size(const HeapWord* p) const; + + inline HeapWord* par_allocate_no_bot_updates(size_t word_size); + inline HeapWord* allocate_no_bot_updates(size_t word_size); // If this region is a member of a HeapRegionSeq, the index in that // sequence, otherwise -1. @@ -569,9 +585,6 @@ class HeapRegion: public G1OffsetTableContigSpace { HeapWord* orig_end() { return _orig_end; } - // Allows logical separation between objects allocated before and after. - void save_marks(); - // Reset HR stuff to default values. void hr_clear(bool par, bool clear_space, bool locked = false); void par_clear(); @@ -580,10 +593,6 @@ class HeapRegion: public G1OffsetTableContigSpace { HeapWord* prev_top_at_mark_start() const { return _prev_top_at_mark_start; } HeapWord* next_top_at_mark_start() const { return _next_top_at_mark_start; } - // Apply "cl->do_oop" to (the addresses of) all reference fields in objects - // allocated in the current region before the last call to "save_mark". - void oop_before_save_marks_iterate(ExtendedOopClosure* cl); - // Note the start or end of marking. This tells the heap region // that the collector is about to start or has finished (concurrently) // marking the heap. @@ -769,10 +778,6 @@ class HeapRegion: public G1OffsetTableContigSpace { _predicted_bytes_to_copy = bytes; } -#define HeapRegion_OOP_SINCE_SAVE_MARKS_DECL(OopClosureType, nv_suffix) \ - virtual void oop_since_save_marks_iterate##nv_suffix(OopClosureType* cl); - SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES(HeapRegion_OOP_SINCE_SAVE_MARKS_DECL) - virtual CompactibleSpace* next_compaction_space() const; virtual void reset_after_compaction(); diff --git a/hotspot/src/share/vm/gc_implementation/g1/heapRegion.inline.hpp b/hotspot/src/share/vm/gc_implementation/g1/heapRegion.inline.hpp index b85c448d161..ebe4c067b9d 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/heapRegion.inline.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegion.inline.hpp @@ -26,9 +26,48 @@ #define SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGION_INLINE_HPP #include "gc_implementation/g1/g1BlockOffsetTable.inline.hpp" +#include "gc_implementation/g1/g1CollectedHeap.hpp" +#include "gc_implementation/g1/heapRegion.hpp" +#include "memory/space.hpp" +#include "runtime/atomic.inline.hpp" + +// This version requires locking. +inline HeapWord* G1OffsetTableContigSpace::allocate_impl(size_t size, + HeapWord* const end_value) { + HeapWord* obj = top(); + if (pointer_delta(end_value, obj) >= size) { + HeapWord* new_top = obj + size; + set_top(new_top); + assert(is_aligned(obj) && is_aligned(new_top), "checking alignment"); + return obj; + } else { + return NULL; + } +} + +// This version is lock-free. +inline HeapWord* G1OffsetTableContigSpace::par_allocate_impl(size_t size, + HeapWord* const end_value) { + do { + HeapWord* obj = top(); + if (pointer_delta(end_value, obj) >= size) { + HeapWord* new_top = obj + size; + HeapWord* result = (HeapWord*)Atomic::cmpxchg_ptr(new_top, top_addr(), obj); + // result can be one of two: + // the old top value: the exchange succeeded + // otherwise: the new value of the top is returned. + if (result == obj) { + assert(is_aligned(obj) && is_aligned(new_top), "checking alignment"); + return obj; + } + } else { + return NULL; + } + } while (true); +} inline HeapWord* G1OffsetTableContigSpace::allocate(size_t size) { - HeapWord* res = ContiguousSpace::allocate(size); + HeapWord* res = allocate_impl(size, end()); if (res != NULL) { _offsets.alloc_block(res, size); } @@ -40,12 +79,7 @@ inline HeapWord* G1OffsetTableContigSpace::allocate(size_t size) { // this is used for larger LAB allocations only. inline HeapWord* G1OffsetTableContigSpace::par_allocate(size_t size) { MutexLocker x(&_par_alloc_lock); - // Given that we take the lock no need to use par_allocate() here. - HeapWord* res = ContiguousSpace::allocate(size); - if (res != NULL) { - _offsets.alloc_block(res, size); - } - return res; + return allocate(size); } inline HeapWord* G1OffsetTableContigSpace::block_start(const void* p) { @@ -57,6 +91,41 @@ G1OffsetTableContigSpace::block_start_const(const void* p) const { return _offsets.block_start_const(p); } +inline bool +HeapRegion::block_is_obj(const HeapWord* p) const { + G1CollectedHeap* g1h = G1CollectedHeap::heap(); + return !g1h->is_obj_dead(oop(p), this); +} + +inline size_t +HeapRegion::block_size(const HeapWord *addr) const { + // Old regions' dead objects may have dead classes + // We need to find the next live object in some other + // manner than getting the oop size + G1CollectedHeap* g1h = G1CollectedHeap::heap(); + if (g1h->is_obj_dead(oop(addr), this)) { + HeapWord* next = g1h->concurrent_mark()->prevMarkBitMap()-> + getNextMarkedWordAddress(addr, prev_top_at_mark_start()); + + assert(next > addr, "must get the next live object"); + + return pointer_delta(next, addr); + } else if (addr == top()) { + return pointer_delta(end(), addr); + } + return oop(addr)->size(); +} + +inline HeapWord* HeapRegion::par_allocate_no_bot_updates(size_t word_size) { + assert(is_young(), "we can only skip BOT updates on young regions"); + return par_allocate_impl(word_size, end()); +} + +inline HeapWord* HeapRegion::allocate_no_bot_updates(size_t word_size) { + assert(is_young(), "we can only skip BOT updates on young regions"); + return allocate_impl(word_size, end()); +} + inline void HeapRegion::note_start_of_marking() { _next_marked_bytes = 0; _next_top_at_mark_start = top(); diff --git a/hotspot/src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp b/hotspot/src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp index 08f016d83d9..df65940100d 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp @@ -931,7 +931,10 @@ void HeapRegionRemSet::add_strong_code_root(nmethod* nm) { void HeapRegionRemSet::remove_strong_code_root(nmethod* nm) { assert(nm != NULL, "sanity"); - _code_roots.remove(nm); + assert_locked_or_safepoint(CodeCache_lock); + + _code_roots.remove_lock_free(nm); + // Check that there were no duplicates guarantee(!_code_roots.contains(nm), "duplicate entry found"); } diff --git a/hotspot/src/share/vm/gc_implementation/g1/satbQueue.cpp b/hotspot/src/share/vm/gc_implementation/g1/satbQueue.cpp index 8a0e42ea4e5..5831650cf36 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/satbQueue.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/satbQueue.cpp @@ -285,37 +285,6 @@ void SATBMarkQueueSet::set_par_closure(int i, ObjectClosure* par_closure) { _par_closures[i] = par_closure; } -void SATBMarkQueueSet::iterate_closure_all_threads() { - for(JavaThread* t = Threads::first(); t; t = t->next()) { - t->satb_mark_queue().apply_closure_and_empty(_closure); - } - shared_satb_queue()->apply_closure_and_empty(_closure); -} - -void SATBMarkQueueSet::par_iterate_closure_all_threads(uint worker) { - SharedHeap* sh = SharedHeap::heap(); - int parity = sh->strong_roots_parity(); - - for(JavaThread* t = Threads::first(); t; t = t->next()) { - if (t->claim_oops_do(true, parity)) { - t->satb_mark_queue().apply_closure_and_empty(_par_closures[worker]); - } - } - - // We also need to claim the VMThread so that its parity is updated - // otherwise the next call to Thread::possibly_parallel_oops_do inside - // a StrongRootsScope might skip the VMThread because it has a stale - // parity that matches the parity set by the StrongRootsScope - // - // Whichever worker succeeds in claiming the VMThread gets to do - // the shared queue. - - VMThread* vmt = VMThread::vm_thread(); - if (vmt->claim_oops_do(true, parity)) { - shared_satb_queue()->apply_closure_and_empty(_par_closures[worker]); - } -} - bool SATBMarkQueueSet::apply_closure_to_completed_buffer_work(bool par, uint worker) { BufferNode* nd = NULL; diff --git a/hotspot/src/share/vm/gc_implementation/g1/satbQueue.hpp b/hotspot/src/share/vm/gc_implementation/g1/satbQueue.hpp index dca73d0dbd4..4da54470128 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/satbQueue.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/satbQueue.hpp @@ -33,7 +33,9 @@ class SATBMarkQueueSet; // A ptrQueue whose elements are "oops", pointers to object heads. class ObjPtrQueue: public PtrQueue { + friend class Threads; friend class SATBMarkQueueSet; + friend class G1RemarkThreadsClosure; private: // Filter out unwanted entries from the buffer. @@ -119,13 +121,6 @@ public: // closures, one for each parallel GC thread. void set_par_closure(int i, ObjectClosure* closure); - // Apply the registered closure to all entries on each - // currently-active buffer and then empty the buffer. It should only - // be called serially and at a safepoint. - void iterate_closure_all_threads(); - // Parallel version of the above. - void par_iterate_closure_all_threads(uint worker); - // If there exists some completed buffer, pop it, then apply the // registered closure to all its elements, and return true. If no // completed buffers exist, return false. diff --git a/hotspot/src/share/vm/gc_implementation/g1/vmStructs_g1.hpp b/hotspot/src/share/vm/gc_implementation/g1/vmStructs_g1.hpp index d7820f89abe..f32bfb0e3a3 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/vmStructs_g1.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/vmStructs_g1.hpp @@ -34,6 +34,8 @@ static_field(HeapRegion, GrainBytes, size_t) \ static_field(HeapRegion, LogOfHRGrainBytes, int) \ \ + nonstatic_field(G1OffsetTableContigSpace, _top, HeapWord*) \ + \ nonstatic_field(G1HeapRegionTable, _base, address) \ nonstatic_field(G1HeapRegionTable, _length, size_t) \ nonstatic_field(G1HeapRegionTable, _biased_base, address) \ @@ -69,7 +71,8 @@ \ declare_type(G1CollectedHeap, SharedHeap) \ \ - declare_type(HeapRegion, ContiguousSpace) \ + declare_type(G1OffsetTableContigSpace, CompactibleSpace) \ + declare_type(HeapRegion, G1OffsetTableContigSpace) \ declare_toplevel_type(HeapRegionSeq) \ declare_toplevel_type(HeapRegionSetBase) \ declare_toplevel_type(HeapRegionSetCount) \ diff --git a/hotspot/src/share/vm/gc_implementation/parNew/asParNewGeneration.cpp b/hotspot/src/share/vm/gc_implementation/parNew/asParNewGeneration.cpp deleted file mode 100644 index 9b39c289900..00000000000 --- a/hotspot/src/share/vm/gc_implementation/parNew/asParNewGeneration.cpp +++ /dev/null @@ -1,657 +0,0 @@ -/* - * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#include "precompiled.hpp" -#include "gc_implementation/concurrentMarkSweep/cmsAdaptiveSizePolicy.hpp" -#include "gc_implementation/concurrentMarkSweep/cmsGCAdaptivePolicyCounters.hpp" -#include "gc_implementation/parNew/asParNewGeneration.hpp" -#include "gc_implementation/parNew/parNewGeneration.hpp" -#include "gc_implementation/shared/markSweep.inline.hpp" -#include "gc_implementation/shared/spaceDecorator.hpp" -#include "memory/defNewGeneration.inline.hpp" -#include "memory/referencePolicy.hpp" -#include "oops/markOop.inline.hpp" -#include "oops/oop.pcgc.inline.hpp" - -ASParNewGeneration::ASParNewGeneration(ReservedSpace rs, - size_t initial_byte_size, - size_t min_byte_size, - int level) : - ParNewGeneration(rs, initial_byte_size, level), - _min_gen_size(min_byte_size) {} - -const char* ASParNewGeneration::name() const { - return "adaptive size par new generation"; -} - -void ASParNewGeneration::adjust_desired_tenuring_threshold() { - assert(UseAdaptiveSizePolicy, - "Should only be used with UseAdaptiveSizePolicy"); -} - -void ASParNewGeneration::resize(size_t eden_size, size_t survivor_size) { - // Resize the generation if needed. If the generation resize - // reports false, do not attempt to resize the spaces. - if (resize_generation(eden_size, survivor_size)) { - // Then we lay out the spaces inside the generation - resize_spaces(eden_size, survivor_size); - - space_invariants(); - - if (PrintAdaptiveSizePolicy && Verbose) { - gclog_or_tty->print_cr("Young generation size: " - "desired eden: " SIZE_FORMAT " survivor: " SIZE_FORMAT - " used: " SIZE_FORMAT " capacity: " SIZE_FORMAT - " gen limits: " SIZE_FORMAT " / " SIZE_FORMAT, - eden_size, survivor_size, used(), capacity(), - max_gen_size(), min_gen_size()); - } - } -} - -size_t ASParNewGeneration::available_to_min_gen() { - assert(virtual_space()->committed_size() >= min_gen_size(), "Invariant"); - return virtual_space()->committed_size() - min_gen_size(); -} - -// This method assumes that from-space has live data and that -// any shrinkage of the young gen is limited by location of -// from-space. -size_t ASParNewGeneration::available_to_live() const { -#undef SHRINKS_AT_END_OF_EDEN -#ifdef SHRINKS_AT_END_OF_EDEN - size_t delta_in_survivor = 0; - ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); - const size_t space_alignment = heap->intra_heap_alignment(); - const size_t gen_alignment = heap->object_heap_alignment(); - - MutableSpace* space_shrinking = NULL; - if (from_space()->end() > to_space()->end()) { - space_shrinking = from_space(); - } else { - space_shrinking = to_space(); - } - - // Include any space that is committed but not included in - // the survivor spaces. - assert(((HeapWord*)virtual_space()->high()) >= space_shrinking->end(), - "Survivor space beyond high end"); - size_t unused_committed = pointer_delta(virtual_space()->high(), - space_shrinking->end(), sizeof(char)); - - if (space_shrinking->is_empty()) { - // Don't let the space shrink to 0 - assert(space_shrinking->capacity_in_bytes() >= space_alignment, - "Space is too small"); - delta_in_survivor = space_shrinking->capacity_in_bytes() - space_alignment; - } else { - delta_in_survivor = pointer_delta(space_shrinking->end(), - space_shrinking->top(), - sizeof(char)); - } - - size_t delta_in_bytes = unused_committed + delta_in_survivor; - delta_in_bytes = align_size_down(delta_in_bytes, gen_alignment); - return delta_in_bytes; -#else - // The only space available for shrinking is in to-space if it - // is above from-space. - if (to()->bottom() > from()->bottom()) { - const size_t alignment = os::vm_page_size(); - if (to()->capacity() < alignment) { - return 0; - } else { - return to()->capacity() - alignment; - } - } else { - return 0; - } -#endif -} - -// Return the number of bytes available for resizing down the young -// generation. This is the minimum of -// input "bytes" -// bytes to the minimum young gen size -// bytes to the size currently being used + some small extra -size_t ASParNewGeneration::limit_gen_shrink (size_t bytes) { - // Allow shrinkage into the current eden but keep eden large enough - // to maintain the minimum young gen size - bytes = MIN3(bytes, available_to_min_gen(), available_to_live()); - return align_size_down(bytes, os::vm_page_size()); -} - -// Note that the the alignment used is the OS page size as -// opposed to an alignment associated with the virtual space -// (as is done in the ASPSYoungGen/ASPSOldGen) -bool ASParNewGeneration::resize_generation(size_t eden_size, - size_t survivor_size) { - const size_t alignment = os::vm_page_size(); - size_t orig_size = virtual_space()->committed_size(); - bool size_changed = false; - - // There used to be this guarantee there. - // guarantee ((eden_size + 2*survivor_size) <= _max_gen_size, "incorrect input arguments"); - // Code below forces this requirement. In addition the desired eden - // size and desired survivor sizes are desired goals and may - // exceed the total generation size. - - assert(min_gen_size() <= orig_size && orig_size <= max_gen_size(), - "just checking"); - - // Adjust new generation size - const size_t eden_plus_survivors = - align_size_up(eden_size + 2 * survivor_size, alignment); - size_t desired_size = MAX2(MIN2(eden_plus_survivors, max_gen_size()), - min_gen_size()); - assert(desired_size <= max_gen_size(), "just checking"); - - if (desired_size > orig_size) { - // Grow the generation - size_t change = desired_size - orig_size; - assert(change % alignment == 0, "just checking"); - if (expand(change)) { - return false; // Error if we fail to resize! - } - size_changed = true; - } else if (desired_size < orig_size) { - size_t desired_change = orig_size - desired_size; - assert(desired_change % alignment == 0, "just checking"); - - desired_change = limit_gen_shrink(desired_change); - - if (desired_change > 0) { - virtual_space()->shrink_by(desired_change); - reset_survivors_after_shrink(); - - size_changed = true; - } - } else { - if (Verbose && PrintGC) { - if (orig_size == max_gen_size()) { - gclog_or_tty->print_cr("ASParNew generation size at maximum: " - SIZE_FORMAT "K", orig_size/K); - } else if (orig_size == min_gen_size()) { - gclog_or_tty->print_cr("ASParNew generation size at minium: " - SIZE_FORMAT "K", orig_size/K); - } - } - } - - if (size_changed) { - MemRegion cmr((HeapWord*)virtual_space()->low(), - (HeapWord*)virtual_space()->high()); - GenCollectedHeap::heap()->barrier_set()->resize_covered_region(cmr); - - if (Verbose && PrintGC) { - size_t current_size = virtual_space()->committed_size(); - gclog_or_tty->print_cr("ASParNew generation size changed: " - SIZE_FORMAT "K->" SIZE_FORMAT "K", - orig_size/K, current_size/K); - } - } - - guarantee(eden_plus_survivors <= virtual_space()->committed_size() || - virtual_space()->committed_size() == max_gen_size(), "Sanity"); - - return true; -} - -void ASParNewGeneration::reset_survivors_after_shrink() { - - GenCollectedHeap* gch = GenCollectedHeap::heap(); - HeapWord* new_end = (HeapWord*)virtual_space()->high(); - - if (from()->end() > to()->end()) { - assert(new_end >= from()->end(), "Shrinking past from-space"); - } else { - assert(new_end >= to()->bottom(), "Shrink was too large"); - // Was there a shrink of the survivor space? - if (new_end < to()->end()) { - MemRegion mr(to()->bottom(), new_end); - to()->initialize(mr, - SpaceDecorator::DontClear, - SpaceDecorator::DontMangle); - } - } -} -void ASParNewGeneration::resize_spaces(size_t requested_eden_size, - size_t requested_survivor_size) { - assert(UseAdaptiveSizePolicy, "sanity check"); - assert(requested_eden_size > 0 && requested_survivor_size > 0, - "just checking"); - CollectedHeap* heap = Universe::heap(); - assert(heap->kind() == CollectedHeap::GenCollectedHeap, "Sanity"); - - - // We require eden and to space to be empty - if ((!eden()->is_empty()) || (!to()->is_empty())) { - return; - } - - size_t cur_eden_size = eden()->capacity(); - - if (PrintAdaptiveSizePolicy && Verbose) { - gclog_or_tty->print_cr("ASParNew::resize_spaces(requested_eden_size: " - SIZE_FORMAT - ", requested_survivor_size: " SIZE_FORMAT ")", - requested_eden_size, requested_survivor_size); - gclog_or_tty->print_cr(" eden: [" PTR_FORMAT ".." PTR_FORMAT ") " - SIZE_FORMAT, - p2i(eden()->bottom()), - p2i(eden()->end()), - pointer_delta(eden()->end(), - eden()->bottom(), - sizeof(char))); - gclog_or_tty->print_cr(" from: [" PTR_FORMAT ".." PTR_FORMAT ") " - SIZE_FORMAT, - p2i(from()->bottom()), - p2i(from()->end()), - pointer_delta(from()->end(), - from()->bottom(), - sizeof(char))); - gclog_or_tty->print_cr(" to: [" PTR_FORMAT ".." PTR_FORMAT ") " - SIZE_FORMAT, - p2i(to()->bottom()), - p2i(to()->end()), - pointer_delta( to()->end(), - to()->bottom(), - sizeof(char))); - } - - // There's nothing to do if the new sizes are the same as the current - if (requested_survivor_size == to()->capacity() && - requested_survivor_size == from()->capacity() && - requested_eden_size == eden()->capacity()) { - if (PrintAdaptiveSizePolicy && Verbose) { - gclog_or_tty->print_cr(" capacities are the right sizes, returning"); - } - return; - } - - char* eden_start = (char*)eden()->bottom(); - char* eden_end = (char*)eden()->end(); - char* from_start = (char*)from()->bottom(); - char* from_end = (char*)from()->end(); - char* to_start = (char*)to()->bottom(); - char* to_end = (char*)to()->end(); - - const size_t alignment = os::vm_page_size(); - const bool maintain_minimum = - (requested_eden_size + 2 * requested_survivor_size) <= min_gen_size(); - - // Check whether from space is below to space - if (from_start < to_start) { - // Eden, from, to - if (PrintAdaptiveSizePolicy && Verbose) { - gclog_or_tty->print_cr(" Eden, from, to:"); - } - - // Set eden - // "requested_eden_size" is a goal for the size of eden - // and may not be attainable. "eden_size" below is - // calculated based on the location of from-space and - // the goal for the size of eden. from-space is - // fixed in place because it contains live data. - // The calculation is done this way to avoid 32bit - // overflow (i.e., eden_start + requested_eden_size - // may too large for representation in 32bits). - size_t eden_size; - if (maintain_minimum) { - // Only make eden larger than the requested size if - // the minimum size of the generation has to be maintained. - // This could be done in general but policy at a higher - // level is determining a requested size for eden and that - // should be honored unless there is a fundamental reason. - eden_size = pointer_delta(from_start, - eden_start, - sizeof(char)); - } else { - eden_size = MIN2(requested_eden_size, - pointer_delta(from_start, eden_start, sizeof(char))); - } - - eden_size = align_size_down(eden_size, alignment); - eden_end = eden_start + eden_size; - assert(eden_end >= eden_start, "addition overflowed"); - - // To may resize into from space as long as it is clear of live data. - // From space must remain page aligned, though, so we need to do some - // extra calculations. - - // First calculate an optimal to-space - to_end = (char*)virtual_space()->high(); - to_start = (char*)pointer_delta(to_end, (char*)requested_survivor_size, - sizeof(char)); - - // Does the optimal to-space overlap from-space? - if (to_start < (char*)from()->end()) { - // Calculate the minimum offset possible for from_end - size_t from_size = pointer_delta(from()->top(), from_start, sizeof(char)); - - // Should we be in this method if from_space is empty? Why not the set_space method? FIX ME! - if (from_size == 0) { - from_size = alignment; - } else { - from_size = align_size_up(from_size, alignment); - } - - from_end = from_start + from_size; - assert(from_end > from_start, "addition overflow or from_size problem"); - - guarantee(from_end <= (char*)from()->end(), "from_end moved to the right"); - - // Now update to_start with the new from_end - to_start = MAX2(from_end, to_start); - } else { - // If shrinking, move to-space down to abut the end of from-space - // so that shrinking will move to-space down. If not shrinking - // to-space is moving up to allow for growth on the next expansion. - if (requested_eden_size <= cur_eden_size) { - to_start = from_end; - if (to_start + requested_survivor_size > to_start) { - to_end = to_start + requested_survivor_size; - } - } - // else leave to_end pointing to the high end of the virtual space. - } - - guarantee(to_start != to_end, "to space is zero sized"); - - if (PrintAdaptiveSizePolicy && Verbose) { - gclog_or_tty->print_cr(" [eden_start .. eden_end): " - "[" PTR_FORMAT " .. " PTR_FORMAT ") " SIZE_FORMAT, - p2i(eden_start), - p2i(eden_end), - pointer_delta(eden_end, eden_start, sizeof(char))); - gclog_or_tty->print_cr(" [from_start .. from_end): " - "[" PTR_FORMAT " .. " PTR_FORMAT ") " SIZE_FORMAT, - p2i(from_start), - p2i(from_end), - pointer_delta(from_end, from_start, sizeof(char))); - gclog_or_tty->print_cr(" [ to_start .. to_end): " - "[" PTR_FORMAT " .. " PTR_FORMAT ") " SIZE_FORMAT, - p2i(to_start), - p2i(to_end), - pointer_delta( to_end, to_start, sizeof(char))); - } - } else { - // Eden, to, from - if (PrintAdaptiveSizePolicy && Verbose) { - gclog_or_tty->print_cr(" Eden, to, from:"); - } - - // Calculate the to-space boundaries based on - // the start of from-space. - to_end = from_start; - to_start = (char*)pointer_delta(from_start, - (char*)requested_survivor_size, - sizeof(char)); - // Calculate the ideal eden boundaries. - // eden_end is already at the bottom of the generation - assert(eden_start == virtual_space()->low(), - "Eden is not starting at the low end of the virtual space"); - if (eden_start + requested_eden_size >= eden_start) { - eden_end = eden_start + requested_eden_size; - } else { - eden_end = to_start; - } - - // Does eden intrude into to-space? to-space - // gets priority but eden is not allowed to shrink - // to 0. - if (eden_end > to_start) { - eden_end = to_start; - } - - // Don't let eden shrink down to 0 or less. - eden_end = MAX2(eden_end, eden_start + alignment); - assert(eden_start + alignment >= eden_start, "Overflow"); - - size_t eden_size; - if (maintain_minimum) { - // Use all the space available. - eden_end = MAX2(eden_end, to_start); - eden_size = pointer_delta(eden_end, eden_start, sizeof(char)); - eden_size = MIN2(eden_size, cur_eden_size); - } else { - eden_size = pointer_delta(eden_end, eden_start, sizeof(char)); - } - eden_size = align_size_down(eden_size, alignment); - assert(maintain_minimum || eden_size <= requested_eden_size, - "Eden size is too large"); - assert(eden_size >= alignment, "Eden size is too small"); - eden_end = eden_start + eden_size; - - // Move to-space down to eden. - if (requested_eden_size < cur_eden_size) { - to_start = eden_end; - if (to_start + requested_survivor_size > to_start) { - to_end = MIN2(from_start, to_start + requested_survivor_size); - } else { - to_end = from_start; - } - } - - // eden_end may have moved so again make sure - // the to-space and eden don't overlap. - to_start = MAX2(eden_end, to_start); - - // from-space - size_t from_used = from()->used(); - if (requested_survivor_size > from_used) { - if (from_start + requested_survivor_size >= from_start) { - from_end = from_start + requested_survivor_size; - } - if (from_end > virtual_space()->high()) { - from_end = virtual_space()->high(); - } - } - - assert(to_start >= eden_end, "to-space should be above eden"); - if (PrintAdaptiveSizePolicy && Verbose) { - gclog_or_tty->print_cr(" [eden_start .. eden_end): " - "[" PTR_FORMAT " .. " PTR_FORMAT ") " SIZE_FORMAT, - p2i(eden_start), - p2i(eden_end), - pointer_delta(eden_end, eden_start, sizeof(char))); - gclog_or_tty->print_cr(" [ to_start .. to_end): " - "[" PTR_FORMAT " .. " PTR_FORMAT ") " SIZE_FORMAT, - p2i(to_start), - p2i(to_end), - pointer_delta( to_end, to_start, sizeof(char))); - gclog_or_tty->print_cr(" [from_start .. from_end): " - "[" PTR_FORMAT " .. " PTR_FORMAT ") " SIZE_FORMAT, - p2i(from_start), - p2i(from_end), - pointer_delta(from_end, from_start, sizeof(char))); - } - } - - - guarantee((HeapWord*)from_start <= from()->bottom(), - "from start moved to the right"); - guarantee((HeapWord*)from_end >= from()->top(), - "from end moved into live data"); - assert(is_object_aligned((intptr_t)eden_start), "checking alignment"); - assert(is_object_aligned((intptr_t)from_start), "checking alignment"); - assert(is_object_aligned((intptr_t)to_start), "checking alignment"); - - MemRegion edenMR((HeapWord*)eden_start, (HeapWord*)eden_end); - MemRegion toMR ((HeapWord*)to_start, (HeapWord*)to_end); - MemRegion fromMR((HeapWord*)from_start, (HeapWord*)from_end); - - // Let's make sure the call to initialize doesn't reset "top"! - HeapWord* old_from_top = from()->top(); - - // For PrintAdaptiveSizePolicy block below - size_t old_from = from()->capacity(); - size_t old_to = to()->capacity(); - - // If not clearing the spaces, do some checking to verify that - // the spaces are already mangled. - - // Must check mangling before the spaces are reshaped. Otherwise, - // the bottom or end of one space may have moved into another - // a failure of the check may not correctly indicate which space - // is not properly mangled. - if (ZapUnusedHeapArea) { - HeapWord* limit = (HeapWord*) virtual_space()->high(); - eden()->check_mangled_unused_area(limit); - from()->check_mangled_unused_area(limit); - to()->check_mangled_unused_area(limit); - } - - // The call to initialize NULL's the next compaction space - eden()->initialize(edenMR, - SpaceDecorator::Clear, - SpaceDecorator::DontMangle); - eden()->set_next_compaction_space(from()); - to()->initialize(toMR , - SpaceDecorator::Clear, - SpaceDecorator::DontMangle); - from()->initialize(fromMR, - SpaceDecorator::DontClear, - SpaceDecorator::DontMangle); - - assert(from()->top() == old_from_top, "from top changed!"); - - if (PrintAdaptiveSizePolicy) { - GenCollectedHeap* gch = GenCollectedHeap::heap(); - assert(gch->kind() == CollectedHeap::GenCollectedHeap, "Sanity"); - - gclog_or_tty->print("AdaptiveSizePolicy::survivor space sizes: " - "collection: %d " - "(" SIZE_FORMAT ", " SIZE_FORMAT ") -> " - "(" SIZE_FORMAT ", " SIZE_FORMAT ") ", - gch->total_collections(), - old_from, old_to, - from()->capacity(), - to()->capacity()); - gclog_or_tty->cr(); - } -} - -void ASParNewGeneration::compute_new_size() { - GenCollectedHeap* gch = GenCollectedHeap::heap(); - assert(gch->kind() == CollectedHeap::GenCollectedHeap, - "not a CMS generational heap"); - - - CMSAdaptiveSizePolicy* size_policy = - (CMSAdaptiveSizePolicy*)gch->gen_policy()->size_policy(); - assert(size_policy->is_gc_cms_adaptive_size_policy(), - "Wrong type of size policy"); - - size_t survived = from()->used(); - if (!survivor_overflow()) { - // Keep running averages on how much survived - size_policy->avg_survived()->sample(survived); - } else { - size_t promoted = - (size_t) next_gen()->gc_stats()->avg_promoted()->last_sample(); - assert(promoted < gch->capacity(), "Conversion problem?"); - size_t survived_guess = survived + promoted; - size_policy->avg_survived()->sample(survived_guess); - } - - size_t survivor_limit = max_survivor_size(); - _tenuring_threshold = - size_policy->compute_survivor_space_size_and_threshold( - _survivor_overflow, - _tenuring_threshold, - survivor_limit); - size_policy->avg_young_live()->sample(used()); - size_policy->avg_eden_live()->sample(eden()->used()); - - size_policy->compute_eden_space_size(eden()->capacity(), max_gen_size()); - - resize(size_policy->calculated_eden_size_in_bytes(), - size_policy->calculated_survivor_size_in_bytes()); - - if (UsePerfData) { - CMSGCAdaptivePolicyCounters* counters = - (CMSGCAdaptivePolicyCounters*) gch->collector_policy()->counters(); - assert(counters->kind() == - GCPolicyCounters::CMSGCAdaptivePolicyCountersKind, - "Wrong kind of counters"); - counters->update_tenuring_threshold(_tenuring_threshold); - counters->update_survivor_overflowed(_survivor_overflow); - counters->update_young_capacity(capacity()); - } -} - - -#ifndef PRODUCT -// Changes from PSYoungGen version -// value of "alignment" -void ASParNewGeneration::space_invariants() { - const size_t alignment = os::vm_page_size(); - - // Currently, our eden size cannot shrink to zero - guarantee(eden()->capacity() >= alignment, "eden too small"); - guarantee(from()->capacity() >= alignment, "from too small"); - guarantee(to()->capacity() >= alignment, "to too small"); - - // Relationship of spaces to each other - char* eden_start = (char*)eden()->bottom(); - char* eden_end = (char*)eden()->end(); - char* from_start = (char*)from()->bottom(); - char* from_end = (char*)from()->end(); - char* to_start = (char*)to()->bottom(); - char* to_end = (char*)to()->end(); - - guarantee(eden_start >= virtual_space()->low(), "eden bottom"); - guarantee(eden_start < eden_end, "eden space consistency"); - guarantee(from_start < from_end, "from space consistency"); - guarantee(to_start < to_end, "to space consistency"); - - // Check whether from space is below to space - if (from_start < to_start) { - // Eden, from, to - guarantee(eden_end <= from_start, "eden/from boundary"); - guarantee(from_end <= to_start, "from/to boundary"); - guarantee(to_end <= virtual_space()->high(), "to end"); - } else { - // Eden, to, from - guarantee(eden_end <= to_start, "eden/to boundary"); - guarantee(to_end <= from_start, "to/from boundary"); - guarantee(from_end <= virtual_space()->high(), "from end"); - } - - // More checks that the virtual space is consistent with the spaces - assert(virtual_space()->committed_size() >= - (eden()->capacity() + - to()->capacity() + - from()->capacity()), "Committed size is inconsistent"); - assert(virtual_space()->committed_size() <= virtual_space()->reserved_size(), - "Space invariant"); - char* eden_top = (char*)eden()->top(); - char* from_top = (char*)from()->top(); - char* to_top = (char*)to()->top(); - assert(eden_top <= virtual_space()->high(), "eden top"); - assert(from_top <= virtual_space()->high(), "from top"); - assert(to_top <= virtual_space()->high(), "to top"); -} -#endif diff --git a/hotspot/src/share/vm/gc_implementation/parNew/asParNewGeneration.hpp b/hotspot/src/share/vm/gc_implementation/parNew/asParNewGeneration.hpp deleted file mode 100644 index 70646fe9b08..00000000000 --- a/hotspot/src/share/vm/gc_implementation/parNew/asParNewGeneration.hpp +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#ifndef SHARE_VM_GC_IMPLEMENTATION_PARNEW_ASPARNEWGENERATION_HPP -#define SHARE_VM_GC_IMPLEMENTATION_PARNEW_ASPARNEWGENERATION_HPP - -#include "gc_implementation/parNew/parNewGeneration.hpp" -#include "gc_implementation/shared/adaptiveSizePolicy.hpp" - -// A Generation that does parallel young-gen collection extended -// for adaptive size policy. - -// Division of generation into spaces -// done by DefNewGeneration::compute_space_boundaries() -// +---------------+ -// | uncommitted | -// |---------------| -// | ss0 | -// |---------------| -// | ss1 | -// |---------------| -// | | -// | eden | -// | | -// +---------------+ <-- low end of VirtualSpace -// -class ASParNewGeneration: public ParNewGeneration { - - size_t _min_gen_size; - - // Resize the generation based on the desired sizes of - // the constituent spaces. - bool resize_generation(size_t eden_size, size_t survivor_size); - // Resize the spaces based on their desired sizes but - // respecting the maximum size of the generation. - void resize_spaces(size_t eden_size, size_t survivor_size); - // Return the byte size remaining to the minimum generation size. - size_t available_to_min_gen(); - // Return the byte size remaining to the live data in the generation. - size_t available_to_live() const; - // Return the byte size that the generation is allowed to shrink. - size_t limit_gen_shrink(size_t bytes); - // Reset the size of the spaces after a shrink of the generation. - void reset_survivors_after_shrink(); - - // Accessor - VirtualSpace* virtual_space() { return &_virtual_space; } - - virtual void adjust_desired_tenuring_threshold(); - - public: - - ASParNewGeneration(ReservedSpace rs, - size_t initial_byte_size, - size_t min_byte_size, - int level); - - virtual const char* short_name() const { return "ASParNew"; } - virtual const char* name() const; - virtual Generation::Name kind() { return ASParNew; } - - // Change the sizes of eden and the survivor spaces in - // the generation. The parameters are desired sizes - // and are not guaranteed to be met. For example, if - // the total is larger than the generation. - void resize(size_t eden_size, size_t survivor_size); - - virtual void compute_new_size(); - - size_t max_gen_size() { return _reserved.byte_size(); } - size_t min_gen_size() const { return _min_gen_size; } - - // Space boundary invariant checker - void space_invariants() PRODUCT_RETURN; -}; - -#endif // SHARE_VM_GC_IMPLEMENTATION_PARNEW_ASPARNEWGENERATION_HPP diff --git a/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp b/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp index c97f97516f1..bddc6f678a3 100644 --- a/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp +++ b/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp @@ -614,18 +614,21 @@ void ParNewGenTask::work(uint worker_id) { KlassScanClosure klass_scan_closure(&par_scan_state.to_space_root_closure(), gch->rem_set()->klass_rem_set()); - - int so = SharedHeap::SO_AllClasses | SharedHeap::SO_Strings | SharedHeap::SO_ScavengeCodeCache; + CLDToKlassAndOopClosure cld_scan_closure(&klass_scan_closure, + &par_scan_state.to_space_root_closure(), + false); par_scan_state.start_strong_roots(); - gch->gen_process_strong_roots(_gen->level(), - true, // Process younger gens, if any, - // as strong roots. - false, // no scope; this is parallel code - SharedHeap::ScanningOption(so), - &par_scan_state.to_space_root_closure(), - &par_scan_state.older_gen_closure(), - &klass_scan_closure); + gch->gen_process_roots(_gen->level(), + true, // Process younger gens, if any, + // as strong roots. + false, // no scope; this is parallel code + SharedHeap::SO_ScavengeCodeCache, + GenCollectedHeap::StrongAndWeakRoots, + &par_scan_state.to_space_root_closure(), + &par_scan_state.older_gen_closure(), + &cld_scan_closure); + par_scan_state.end_strong_roots(); // "evacuate followers". diff --git a/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.hpp b/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.hpp index 6d3b25d9545..bde15f7b8f8 100644 --- a/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.hpp +++ b/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.hpp @@ -69,7 +69,7 @@ class ParScanThreadState { ParScanWithoutBarrierClosure _to_space_closure; // scan_without_gc_barrier ParScanWithBarrierClosure _old_gen_closure; // scan_with_gc_barrier ParRootScanWithoutBarrierClosure _to_space_root_closure; // scan_root_without_gc_barrier - // One of these two will be passed to process_strong_roots, which will + // One of these two will be passed to process_roots, which will // set its generation. The first is for two-gen configs where the // old gen collects the perm gen; the second is for arbitrary configs. // The second isn't used right now (it used to be used for the train, an diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/pcTasks.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/pcTasks.cpp index 01790ef9310..bd22eb5574f 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/pcTasks.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/pcTasks.cpp @@ -59,7 +59,7 @@ void ThreadRootsMarkingTask::do_it(GCTaskManager* manager, uint which) { PSParallelCompact::MarkAndPushClosure mark_and_push_closure(cm); CLDToOopClosure mark_and_push_from_clds(&mark_and_push_closure, true); - CodeBlobToOopClosure mark_and_push_in_blobs(&mark_and_push_closure, /*do_marking=*/ true); + MarkingCodeBlobClosure mark_and_push_in_blobs(&mark_and_push_closure, !CodeBlobToOopClosure::FixRelocations); if (_java_thread != NULL) _java_thread->oops_do( @@ -100,7 +100,7 @@ void MarkFromRootsTask::do_it(GCTaskManager* manager, uint which) { case threads: { ResourceMark rm; - CodeBlobToOopClosure each_active_code_blob(&mark_and_push_closure, /*do_marking=*/ true); + MarkingCodeBlobClosure each_active_code_blob(&mark_and_push_closure, !CodeBlobToOopClosure::FixRelocations); CLDToOopClosure mark_and_push_from_cld(&mark_and_push_closure); Threads::oops_do(&mark_and_push_closure, &mark_and_push_from_cld, &each_active_code_blob); } diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp index 51867d1622f..647ed85ecdb 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp @@ -536,14 +536,14 @@ void PSMarkSweep::mark_sweep_phase1(bool clear_all_softrefs) { Universe::oops_do(mark_and_push_closure()); JNIHandles::oops_do(mark_and_push_closure()); // Global (strong) JNI handles CLDToOopClosure mark_and_push_from_cld(mark_and_push_closure()); - CodeBlobToOopClosure each_active_code_blob(mark_and_push_closure(), /*do_marking=*/ true); + MarkingCodeBlobClosure each_active_code_blob(mark_and_push_closure(), !CodeBlobToOopClosure::FixRelocations); Threads::oops_do(mark_and_push_closure(), &mark_and_push_from_cld, &each_active_code_blob); ObjectSynchronizer::oops_do(mark_and_push_closure()); FlatProfiler::oops_do(mark_and_push_closure()); Management::oops_do(mark_and_push_closure()); JvmtiExport::oops_do(mark_and_push_closure()); SystemDictionary::always_strong_oops_do(mark_and_push_closure()); - ClassLoaderDataGraph::always_strong_oops_do(mark_and_push_closure(), follow_klass_closure(), true); + ClassLoaderDataGraph::always_strong_cld_do(follow_cld_closure()); // Do not treat nmethods as strong roots for mark/sweep, since we can unload them. //CodeCache::scavenge_root_nmethods_do(CodeBlobToOopClosure(mark_and_push_closure())); } @@ -633,16 +633,16 @@ void PSMarkSweep::mark_sweep_phase3() { FlatProfiler::oops_do(adjust_pointer_closure()); Management::oops_do(adjust_pointer_closure()); JvmtiExport::oops_do(adjust_pointer_closure()); - // SO_AllClasses SystemDictionary::oops_do(adjust_pointer_closure()); - ClassLoaderDataGraph::oops_do(adjust_pointer_closure(), adjust_klass_closure(), true); + ClassLoaderDataGraph::cld_do(adjust_cld_closure()); // Now adjust pointers in remaining weak roots. (All of which should // have been cleared if they pointed to non-surviving objects.) // Global (weak) JNI handles JNIHandles::weak_oops_do(&always_true, adjust_pointer_closure()); - CodeCache::oops_do(adjust_pointer_closure()); + CodeBlobToOopClosure adjust_from_blobs(adjust_pointer_closure(), CodeBlobToOopClosure::FixRelocations); + CodeCache::blobs_do(&adjust_from_blobs); StringTable::oops_do(adjust_pointer_closure()); ref_processor()->weak_oops_do(adjust_pointer_closure()); PSScavenge::reference_processor()->weak_oops_do(adjust_pointer_closure()); diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.hpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.hpp index 68b3de470ea..46073f9e293 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.hpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.hpp @@ -40,11 +40,11 @@ class PSMarkSweep : public MarkSweep { static CollectorCounters* _counters; // Closure accessors - static OopClosure* mark_and_push_closure() { return &MarkSweep::mark_and_push_closure; } - static KlassClosure* follow_klass_closure() { return &MarkSweep::follow_klass_closure; } - static VoidClosure* follow_stack_closure() { return (VoidClosure*)&MarkSweep::follow_stack_closure; } - static OopClosure* adjust_pointer_closure() { return (OopClosure*)&MarkSweep::adjust_pointer_closure; } - static KlassClosure* adjust_klass_closure() { return &MarkSweep::adjust_klass_closure; } + static OopClosure* mark_and_push_closure() { return &MarkSweep::mark_and_push_closure; } + static VoidClosure* follow_stack_closure() { return (VoidClosure*)&MarkSweep::follow_stack_closure; } + static CLDClosure* follow_cld_closure() { return &MarkSweep::follow_cld_closure; } + static OopClosure* adjust_pointer_closure() { return (OopClosure*)&MarkSweep::adjust_pointer_closure; } + static CLDClosure* adjust_cld_closure() { return &MarkSweep::adjust_cld_closure; } static BoolObjectClosure* is_alive_closure() { return (BoolObjectClosure*)&MarkSweep::is_alive; } debug_only(public:) // Used for PSParallelCompact debugging diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp index 9f552fd1874..7246a61b634 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp @@ -2474,7 +2474,6 @@ void PSParallelCompact::adjust_roots() { FlatProfiler::oops_do(adjust_pointer_closure()); Management::oops_do(adjust_pointer_closure()); JvmtiExport::oops_do(adjust_pointer_closure()); - // SO_AllClasses SystemDictionary::oops_do(adjust_pointer_closure()); ClassLoaderDataGraph::oops_do(adjust_pointer_closure(), adjust_klass_closure(), true); @@ -2483,7 +2482,8 @@ void PSParallelCompact::adjust_roots() { // Global (weak) JNI handles JNIHandles::weak_oops_do(&always_true, adjust_pointer_closure()); - CodeCache::oops_do(adjust_pointer_closure()); + CodeBlobToOopClosure adjust_from_blobs(adjust_pointer_closure(), CodeBlobToOopClosure::FixRelocations); + CodeCache::blobs_do(&adjust_from_blobs); StringTable::oops_do(adjust_pointer_closure()); ref_processor()->weak_oops_do(adjust_pointer_closure()); // Roots were visited so references into the young gen in roots diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psTasks.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psTasks.cpp index ea0e627dc79..f829e934408 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psTasks.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psTasks.cpp @@ -100,7 +100,7 @@ void ScavengeRootsTask::do_it(GCTaskManager* manager, uint which) { case code_cache: { - CodeBlobToOopClosure each_scavengable_code_blob(&roots_to_old_closure, /*do_marking=*/ true); + MarkingCodeBlobClosure each_scavengable_code_blob(&roots_to_old_closure, CodeBlobToOopClosure::FixRelocations); CodeCache::scavenge_root_nmethods_do(&each_scavengable_code_blob); } break; @@ -123,7 +123,7 @@ void ThreadRootsTask::do_it(GCTaskManager* manager, uint which) { PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(which); PSScavengeRootsClosure roots_closure(pm); CLDClosure* roots_from_clds = NULL; // Not needed. All CLDs are already visited. - CodeBlobToOopClosure roots_in_blobs(&roots_closure, /*do_marking=*/ true); + MarkingCodeBlobClosure roots_in_blobs(&roots_closure, CodeBlobToOopClosure::FixRelocations); if (_java_thread != NULL) _java_thread->oops_do(&roots_closure, roots_from_clds, &roots_in_blobs); diff --git a/hotspot/src/share/vm/gc_implementation/shared/adaptiveSizePolicy.hpp b/hotspot/src/share/vm/gc_implementation/shared/adaptiveSizePolicy.hpp index f2f4b53c7f5..2695fccec7a 100644 --- a/hotspot/src/share/vm/gc_implementation/shared/adaptiveSizePolicy.hpp +++ b/hotspot/src/share/vm/gc_implementation/shared/adaptiveSizePolicy.hpp @@ -507,7 +507,7 @@ class AdaptiveSizePolicyOutput : StackObj { // always fail (never do the print based on the interval test). return PrintGCDetails && UseAdaptiveSizePolicy && - (UseParallelGC || UseConcMarkSweepGC) && + UseParallelGC && (AdaptiveSizePolicyOutputInterval > 0) && ((count == 0) || ((count % AdaptiveSizePolicyOutputInterval) == 0)); diff --git a/hotspot/src/share/vm/gc_implementation/shared/concurrentGCThread.cpp b/hotspot/src/share/vm/gc_implementation/shared/concurrentGCThread.cpp index 8a105bfa3fb..b85be793146 100644 --- a/hotspot/src/share/vm/gc_implementation/shared/concurrentGCThread.cpp +++ b/hotspot/src/share/vm/gc_implementation/shared/concurrentGCThread.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -134,7 +134,7 @@ SurrogateLockerThread* SurrogateLockerThread::make(TRAPS) { Threads::add(res); Thread::start(res); } - os::yield(); // This seems to help with initial start-up of SLT + os::naked_yield(); // This seems to help with initial start-up of SLT return res; } diff --git a/hotspot/src/share/vm/gc_implementation/shared/gcUtil.hpp b/hotspot/src/share/vm/gc_implementation/shared/gcUtil.hpp index 0e32e2a970f..f1292ebcd7d 100644 --- a/hotspot/src/share/vm/gc_implementation/shared/gcUtil.hpp +++ b/hotspot/src/share/vm/gc_implementation/shared/gcUtil.hpp @@ -216,16 +216,4 @@ class LinearLeastSquareFit : public CHeapObj { bool increment_will_decrease(); }; -class GCPauseTimer : StackObj { - elapsedTimer* _timer; - public: - GCPauseTimer(elapsedTimer* timer) { - _timer = timer; - _timer->stop(); - } - ~GCPauseTimer() { - _timer->start(); - } -}; - #endif // SHARE_VM_GC_IMPLEMENTATION_SHARED_GCUTIL_HPP diff --git a/hotspot/src/share/vm/gc_implementation/shared/markSweep.cpp b/hotspot/src/share/vm/gc_implementation/shared/markSweep.cpp index 07cbb23de4a..309a955d8a3 100644 --- a/hotspot/src/share/vm/gc_implementation/shared/markSweep.cpp +++ b/hotspot/src/share/vm/gc_implementation/shared/markSweep.cpp @@ -54,21 +54,14 @@ void MarkSweep::FollowRootClosure::do_oop(oop* p) { follow_root(p); } void MarkSweep::FollowRootClosure::do_oop(narrowOop* p) { follow_root(p); } MarkSweep::MarkAndPushClosure MarkSweep::mark_and_push_closure; -MarkSweep::FollowKlassClosure MarkSweep::follow_klass_closure; -MarkSweep::AdjustKlassClosure MarkSweep::adjust_klass_closure; +CLDToOopClosure MarkSweep::follow_cld_closure(&mark_and_push_closure); +CLDToOopClosure MarkSweep::adjust_cld_closure(&adjust_pointer_closure); void MarkSweep::MarkAndPushClosure::do_oop(oop* p) { mark_and_push(p); } void MarkSweep::MarkAndPushClosure::do_oop(narrowOop* p) { mark_and_push(p); } -void MarkSweep::FollowKlassClosure::do_klass(Klass* klass) { - klass->oops_do(&MarkSweep::mark_and_push_closure); -} -void MarkSweep::AdjustKlassClosure::do_klass(Klass* klass) { - klass->oops_do(&MarkSweep::adjust_pointer_closure); -} - void MarkSweep::follow_class_loader(ClassLoaderData* cld) { - cld->oops_do(&MarkSweep::mark_and_push_closure, &MarkSweep::follow_klass_closure, true); + MarkSweep::follow_cld_closure.do_cld(cld); } void MarkSweep::follow_stack() { diff --git a/hotspot/src/share/vm/gc_implementation/shared/markSweep.hpp b/hotspot/src/share/vm/gc_implementation/shared/markSweep.hpp index 1857c2a3acc..462643e2f52 100644 --- a/hotspot/src/share/vm/gc_implementation/shared/markSweep.hpp +++ b/hotspot/src/share/vm/gc_implementation/shared/markSweep.hpp @@ -65,17 +65,6 @@ class MarkSweep : AllStatic { virtual void do_oop(narrowOop* p); }; - // The one and only place to start following the classes. - // Should only be applied to the ClassLoaderData klasses list. - class FollowKlassClosure : public KlassClosure { - public: - void do_klass(Klass* klass); - }; - class AdjustKlassClosure : public KlassClosure { - public: - void do_klass(Klass* klass); - }; - class FollowStackClosure: public VoidClosure { public: virtual void do_void(); @@ -144,10 +133,10 @@ class MarkSweep : AllStatic { static IsAliveClosure is_alive; static FollowRootClosure follow_root_closure; static MarkAndPushClosure mark_and_push_closure; - static FollowKlassClosure follow_klass_closure; static FollowStackClosure follow_stack_closure; + static CLDToOopClosure follow_cld_closure; static AdjustPointerClosure adjust_pointer_closure; - static AdjustKlassClosure adjust_klass_closure; + static CLDToOopClosure adjust_cld_closure; // Accessors static uint total_invocations() { return _total_invocations; } diff --git a/hotspot/src/share/vm/gc_implementation/shared/vmGCOperations.cpp b/hotspot/src/share/vm/gc_implementation/shared/vmGCOperations.cpp index bdbbae7f412..439256140a6 100644 --- a/hotspot/src/share/vm/gc_implementation/shared/vmGCOperations.cpp +++ b/hotspot/src/share/vm/gc_implementation/shared/vmGCOperations.cpp @@ -195,6 +195,43 @@ void VM_GenCollectFull::doit() { gch->do_full_collection(gch->must_clear_all_soft_refs(), _max_level); } +bool VM_CollectForMetadataAllocation::initiate_concurrent_GC() { +#if INCLUDE_ALL_GCS + if (UseConcMarkSweepGC || UseG1GC) { + if (UseConcMarkSweepGC && CMSClassUnloadingEnabled) { + MetaspaceGC::set_should_concurrent_collect(true); + } else if (UseG1GC) { + G1CollectedHeap* g1h = G1CollectedHeap::heap(); + g1h->g1_policy()->set_initiate_conc_mark_if_possible(); + + GCCauseSetter x(g1h, _gc_cause); + + // At this point we are supposed to start a concurrent cycle. We + // will do so if one is not already in progress. + bool should_start = g1h->g1_policy()->force_initial_mark_if_outside_cycle(_gc_cause); + + if (should_start) { + double pause_target = g1h->g1_policy()->max_pause_time_ms(); + g1h->do_collection_pause_at_safepoint(pause_target); + } + } + + return true; + } +#endif + return false; +} + +static void log_metaspace_alloc_failure_for_concurrent_GC() { + if (Verbose && PrintGCDetails) { + if (UseConcMarkSweepGC) { + gclog_or_tty->print_cr("\nCMS full GC for Metaspace"); + } else if (UseG1GC) { + gclog_or_tty->print_cr("\nG1 full GC for Metaspace"); + } + } +} + void VM_CollectForMetadataAllocation::doit() { SvcGCMarker sgcm(SvcGCMarker::FULL); @@ -206,54 +243,57 @@ void VM_CollectForMetadataAllocation::doit() { // a GC that freed space for the allocation. if (!MetadataAllocationFailALot) { _result = _loader_data->metaspace_non_null()->allocate(_size, _mdtype); - } - - if (_result == NULL) { - if (UseConcMarkSweepGC) { - if (CMSClassUnloadingEnabled) { - MetaspaceGC::set_should_concurrent_collect(true); - } - // For CMS expand since the collection is going to be concurrent. - _result = - _loader_data->metaspace_non_null()->expand_and_allocate(_size, _mdtype); - } - if (_result == NULL) { - // Don't clear the soft refs yet. - if (Verbose && PrintGCDetails && UseConcMarkSweepGC) { - gclog_or_tty->print_cr("\nCMS full GC for Metaspace"); - } - heap->collect_as_vm_thread(GCCause::_metadata_GC_threshold); - // After a GC try to allocate without expanding. Could fail - // and expansion will be tried below. - _result = - _loader_data->metaspace_non_null()->allocate(_size, _mdtype); - } - if (_result == NULL) { - // If still failing, allow the Metaspace to expand. - // See delta_capacity_until_GC() for explanation of the - // amount of the expansion. - // This should work unless there really is no more space - // or a MaxMetaspaceSize has been specified on the command line. - _result = - _loader_data->metaspace_non_null()->expand_and_allocate(_size, _mdtype); - if (_result == NULL) { - // If expansion failed, do a last-ditch collection and try allocating - // again. A last-ditch collection will clear softrefs. This - // behavior is similar to the last-ditch collection done for perm - // gen when it was full and a collection for failed allocation - // did not free perm gen space. - heap->collect_as_vm_thread(GCCause::_last_ditch_collection); - _result = - _loader_data->metaspace_non_null()->allocate(_size, _mdtype); - } - } - if (Verbose && PrintGCDetails && _result == NULL) { - gclog_or_tty->print_cr("\nAfter Metaspace GC failed to allocate size " - SIZE_FORMAT, _size); + if (_result != NULL) { + return; } } - if (_result == NULL && GC_locker::is_active_and_needs_gc()) { + if (initiate_concurrent_GC()) { + // For CMS and G1 expand since the collection is going to be concurrent. + _result = _loader_data->metaspace_non_null()->expand_and_allocate(_size, _mdtype); + if (_result != NULL) { + return; + } + + log_metaspace_alloc_failure_for_concurrent_GC(); + } + + // Don't clear the soft refs yet. + heap->collect_as_vm_thread(GCCause::_metadata_GC_threshold); + // After a GC try to allocate without expanding. Could fail + // and expansion will be tried below. + _result = _loader_data->metaspace_non_null()->allocate(_size, _mdtype); + if (_result != NULL) { + return; + } + + // If still failing, allow the Metaspace to expand. + // See delta_capacity_until_GC() for explanation of the + // amount of the expansion. + // This should work unless there really is no more space + // or a MaxMetaspaceSize has been specified on the command line. + _result = _loader_data->metaspace_non_null()->expand_and_allocate(_size, _mdtype); + if (_result != NULL) { + return; + } + + // If expansion failed, do a last-ditch collection and try allocating + // again. A last-ditch collection will clear softrefs. This + // behavior is similar to the last-ditch collection done for perm + // gen when it was full and a collection for failed allocation + // did not free perm gen space. + heap->collect_as_vm_thread(GCCause::_last_ditch_collection); + _result = _loader_data->metaspace_non_null()->allocate(_size, _mdtype); + if (_result != NULL) { + return; + } + + if (Verbose && PrintGCDetails) { + gclog_or_tty->print_cr("\nAfter Metaspace GC failed to allocate size " + SIZE_FORMAT, _size); + } + + if (GC_locker::is_active_and_needs_gc()) { set_gc_locked(); } } diff --git a/hotspot/src/share/vm/gc_implementation/shared/vmGCOperations.hpp b/hotspot/src/share/vm/gc_implementation/shared/vmGCOperations.hpp index 82cbf231fa6..8f60dcbdb2a 100644 --- a/hotspot/src/share/vm/gc_implementation/shared/vmGCOperations.hpp +++ b/hotspot/src/share/vm/gc_implementation/shared/vmGCOperations.hpp @@ -217,6 +217,8 @@ class VM_CollectForMetadataAllocation: public VM_GC_Operation { virtual VMOp_Type type() const { return VMOp_CollectForMetadataAllocation; } virtual void doit(); MetaWord* result() const { return _result; } + + bool initiate_concurrent_GC(); }; class SvcGCMarker : public StackObj { diff --git a/hotspot/src/share/vm/interpreter/interpreterRuntime.cpp b/hotspot/src/share/vm/interpreter/interpreterRuntime.cpp index b736d8edbdb..23d4bddca1b 100644 --- a/hotspot/src/share/vm/interpreter/interpreterRuntime.cpp +++ b/hotspot/src/share/vm/interpreter/interpreterRuntime.cpp @@ -416,9 +416,18 @@ IRT_ENTRY(address, InterpreterRuntime::exception_handler_for_exception(JavaThrea // tracing if (TraceExceptions) { - ttyLocker ttyl; ResourceMark rm(thread); - tty->print_cr("Exception <%s> (" INTPTR_FORMAT ")", h_exception->print_value_string(), (address)h_exception()); + Symbol* message = java_lang_Throwable::detail_message(h_exception()); + ttyLocker ttyl; // Lock after getting the detail message + if (message != NULL) { + tty->print_cr("Exception <%s: %s> (" INTPTR_FORMAT ")", + h_exception->print_value_string(), message->as_C_string(), + (address)h_exception()); + } else { + tty->print_cr("Exception <%s> (" INTPTR_FORMAT ")", + h_exception->print_value_string(), + (address)h_exception()); + } tty->print_cr(" thrown in interpreter method <%s>", h_method->print_value_string()); tty->print_cr(" at bci %d for thread " INTPTR_FORMAT, current_bci, thread); } @@ -1079,6 +1088,7 @@ IRT_END address SignatureHandlerLibrary::set_handler_blob() { BufferBlob* handler_blob = BufferBlob::create("native signature handlers", blob_size); if (handler_blob == NULL) { + CompileBroker::handle_full_code_cache(); return NULL; } address handler = handler_blob->code_begin(); diff --git a/hotspot/src/share/vm/interpreter/oopMapCache.cpp b/hotspot/src/share/vm/interpreter/oopMapCache.cpp index 79e2bba8bad..d3f188863ae 100644 --- a/hotspot/src/share/vm/interpreter/oopMapCache.cpp +++ b/hotspot/src/share/vm/interpreter/oopMapCache.cpp @@ -180,7 +180,7 @@ InterpreterOopMap::~InterpreterOopMap() { } } -bool InterpreterOopMap::is_empty() { +bool InterpreterOopMap::is_empty() const { bool result = _method == NULL; assert(_method != NULL || (_bci == 0 && (_mask_size == 0 || _mask_size == USHRT_MAX) && @@ -196,7 +196,7 @@ void InterpreterOopMap::initialize() { for (int i = 0; i < N; i++) _bit_mask[i] = 0; } -void InterpreterOopMap::iterate_oop(OffsetClosure* oop_closure) { +void InterpreterOopMap::iterate_oop(OffsetClosure* oop_closure) const { int n = number_of_entries(); int word_index = 0; uintptr_t value = 0; @@ -238,16 +238,14 @@ void InterpreterOopMap::iterate_all(OffsetClosure* oop_closure, OffsetClosure* v #endif -void InterpreterOopMap::print() { +void InterpreterOopMap::print() const { int n = number_of_entries(); tty->print("oop map for "); method()->print_value(); tty->print(" @ %d = [%d] { ", bci(), n); for (int i = 0; i < n; i++) { -#ifdef ENABLE_ZAP_DEAD_LOCALS if (is_dead(i)) tty->print("%d+ ", i); else -#endif if (is_oop(i)) tty->print("%d ", i); } tty->print_cr("}"); @@ -402,13 +400,11 @@ void OopMapCacheEntry::set_mask(CellTypeState *vars, CellTypeState *stack, int s value |= (mask << oop_bit_number ); } - #ifdef ENABLE_ZAP_DEAD_LOCALS // set dead bit if (!cell->is_live()) { value |= (mask << dead_bit_number); assert(!cell->is_reference(), "dead value marked as oop"); } - #endif } // make sure last word is stored @@ -469,7 +465,7 @@ void InterpreterOopMap::resource_copy(OopMapCacheEntry* from) { } } -inline unsigned int OopMapCache::hash_value_for(methodHandle method, int bci) { +inline unsigned int OopMapCache::hash_value_for(methodHandle method, int bci) const { // We use method->code_size() rather than method->identity_hash() below since // the mark may not be present if a pointer to the method is already reversed. return ((unsigned int) bci) @@ -522,7 +518,7 @@ void OopMapCache::flush_obsolete_entries() { void OopMapCache::lookup(methodHandle method, int bci, - InterpreterOopMap* entry_for) { + InterpreterOopMap* entry_for) const { MutexLocker x(&_mut); OopMapCacheEntry* entry = NULL; diff --git a/hotspot/src/share/vm/interpreter/oopMapCache.hpp b/hotspot/src/share/vm/interpreter/oopMapCache.hpp index 5b9980b2984..dbdd4cb1a88 100644 --- a/hotspot/src/share/vm/interpreter/oopMapCache.hpp +++ b/hotspot/src/share/vm/interpreter/oopMapCache.hpp @@ -66,19 +66,15 @@ class InterpreterOopMap: ResourceObj { public: enum { - N = 2, // the number of words reserved + N = 4, // the number of words reserved // for inlined mask storage small_mask_limit = N * BitsPerWord, // the maximum number of bits // available for small masks, // small_mask_limit can be set to 0 // for testing bit_mask allocation -#ifdef ENABLE_ZAP_DEAD_LOCALS bits_per_entry = 2, dead_bit_number = 1, -#else - bits_per_entry = 1, -#endif oop_bit_number = 0 }; @@ -101,32 +97,27 @@ class InterpreterOopMap: ResourceObj { // access methods Method* method() const { return _method; } - void set_method(Method* v) { _method = v; } + void set_method(Method* v) { _method = v; } int bci() const { return _bci; } void set_bci(int v) { _bci = v; } int mask_size() const { return _mask_size; } void set_mask_size(int v) { _mask_size = v; } - int number_of_entries() const { return mask_size() / bits_per_entry; } // Test bit mask size and return either the in-line bit mask or allocated // bit mask. - uintptr_t* bit_mask() { return (uintptr_t*)(mask_size() <= small_mask_limit ? (intptr_t)_bit_mask : _bit_mask[0]); } + uintptr_t* bit_mask() const { return (uintptr_t*)(mask_size() <= small_mask_limit ? (intptr_t)_bit_mask : _bit_mask[0]); } // return the word size of_bit_mask. mask_size() <= 4 * MAX_USHORT - size_t mask_word_size() { + size_t mask_word_size() const { return (mask_size() + BitsPerWord - 1) / BitsPerWord; } - uintptr_t entry_at(int offset) { int i = offset * bits_per_entry; return bit_mask()[i / BitsPerWord] >> (i % BitsPerWord); } + uintptr_t entry_at(int offset) const { int i = offset * bits_per_entry; return bit_mask()[i / BitsPerWord] >> (i % BitsPerWord); } - void set_expression_stack_size(int sz) { _expression_stack_size = sz; } - -#ifdef ENABLE_ZAP_DEAD_LOCALS - bool is_dead(int offset) { return (entry_at(offset) & (1 << dead_bit_number)) != 0; } -#endif + void set_expression_stack_size(int sz) { _expression_stack_size = sz; } // Lookup - bool match(methodHandle method, int bci) { return _method == method() && _bci == bci; } - bool is_empty(); + bool match(methodHandle method, int bci) const { return _method == method() && _bci == bci; } + bool is_empty() const; // Initialization void initialize(); @@ -141,12 +132,14 @@ class InterpreterOopMap: ResourceObj { // in-line), allocate the space from a Resource area. void resource_copy(OopMapCacheEntry* from); - void iterate_oop(OffsetClosure* oop_closure); - void print(); + void iterate_oop(OffsetClosure* oop_closure) const; + void print() const; - bool is_oop (int offset) { return (entry_at(offset) & (1 << oop_bit_number )) != 0; } + int number_of_entries() const { return mask_size() / bits_per_entry; } + bool is_dead(int offset) const { return (entry_at(offset) & (1 << dead_bit_number)) != 0; } + bool is_oop (int offset) const { return (entry_at(offset) & (1 << oop_bit_number )) != 0; } - int expression_stack_size() { return _expression_stack_size; } + int expression_stack_size() const { return _expression_stack_size; } #ifdef ENABLE_ZAP_DEAD_LOCALS void iterate_all(OffsetClosure* oop_closure, OffsetClosure* value_closure, OffsetClosure* dead_closure); @@ -161,10 +154,10 @@ class OopMapCache : public CHeapObj { OopMapCacheEntry* _array; - unsigned int hash_value_for(methodHandle method, int bci); + unsigned int hash_value_for(methodHandle method, int bci) const; OopMapCacheEntry* entry_at(int i) const; - Mutex _mut; + mutable Mutex _mut; void flush(); @@ -177,7 +170,7 @@ class OopMapCache : public CHeapObj { // Returns the oopMap for (method, bci) in parameter "entry". // Returns false if an oop map was not found. - void lookup(methodHandle method, int bci, InterpreterOopMap* entry); + void lookup(methodHandle method, int bci, InterpreterOopMap* entry) const; // Compute an oop map without updating the cache or grabbing any locks (for debugging) static void compute_one_oop_map(methodHandle method, int bci, InterpreterOopMap* entry); diff --git a/hotspot/src/share/vm/memory/cardTableModRefBS.cpp b/hotspot/src/share/vm/memory/cardTableModRefBS.cpp index f5ff6aad2c1..1f56344c95d 100644 --- a/hotspot/src/share/vm/memory/cardTableModRefBS.cpp +++ b/hotspot/src/share/vm/memory/cardTableModRefBS.cpp @@ -429,7 +429,7 @@ void CardTableModRefBS::non_clean_card_iterate_possibly_parallel(Space* sp, OopsInGenClosure* cl, CardTableRS* ct) { if (!mr.is_empty()) { - // Caller (process_strong_roots()) claims that all GC threads + // Caller (process_roots()) claims that all GC threads // execute this call. With UseDynamicNumberOfGCThreads now all // active GC threads execute this call. The number of active GC // threads needs to be passed to par_non_clean_card_iterate_work() @@ -438,7 +438,7 @@ void CardTableModRefBS::non_clean_card_iterate_possibly_parallel(Space* sp, // This is an example of where n_par_threads() is used instead // of workers()->active_workers(). n_par_threads can be set to 0 to // turn off parallelism. For example when this code is called as - // part of verification and SharedHeap::process_strong_roots() is being + // part of verification and SharedHeap::process_roots() is being // used, then n_par_threads() may have been set to 0. active_workers // is not overloaded with the meaning that it is a switch to disable // parallelism and so keeps the meaning of the number of diff --git a/hotspot/src/share/vm/memory/collectorPolicy.cpp b/hotspot/src/share/vm/memory/collectorPolicy.cpp index de33c9107d7..af6e39d05f0 100644 --- a/hotspot/src/share/vm/memory/collectorPolicy.cpp +++ b/hotspot/src/share/vm/memory/collectorPolicy.cpp @@ -40,10 +40,6 @@ #include "runtime/thread.inline.hpp" #include "runtime/vmThread.hpp" #include "utilities/macros.hpp" -#if INCLUDE_ALL_GCS -#include "gc_implementation/concurrentMarkSweep/cmsAdaptiveSizePolicy.hpp" -#include "gc_implementation/concurrentMarkSweep/cmsGCAdaptivePolicyCounters.hpp" -#endif // INCLUDE_ALL_GCS // CollectorPolicy methods diff --git a/hotspot/src/share/vm/memory/collectorPolicy.hpp b/hotspot/src/share/vm/memory/collectorPolicy.hpp index 57f59b2bd92..faffc6fec34 100644 --- a/hotspot/src/share/vm/memory/collectorPolicy.hpp +++ b/hotspot/src/share/vm/memory/collectorPolicy.hpp @@ -115,7 +115,6 @@ class CollectorPolicy : public CHeapObj { CollectorPolicyKind, GenCollectorPolicyKind, ConcurrentMarkSweepPolicyKind, - ASConcurrentMarkSweepPolicyKind, G1CollectorPolicyKind }; diff --git a/hotspot/src/share/vm/memory/defNewGeneration.cpp b/hotspot/src/share/vm/memory/defNewGeneration.cpp index 1a904b5c636..281228d28eb 100644 --- a/hotspot/src/share/vm/memory/defNewGeneration.cpp +++ b/hotspot/src/share/vm/memory/defNewGeneration.cpp @@ -614,6 +614,9 @@ void DefNewGeneration::collect(bool full, KlassScanClosure klass_scan_closure(&fsc_with_no_gc_barrier, gch->rem_set()->klass_rem_set()); + CLDToKlassAndOopClosure cld_scan_closure(&klass_scan_closure, + &fsc_with_no_gc_barrier, + false); set_promo_failure_scan_stack_closure(&fsc_with_no_gc_barrier); FastEvacuateFollowersClosure evacuate_followers(gch, _level, this, @@ -623,16 +626,15 @@ void DefNewGeneration::collect(bool full, assert(gch->no_allocs_since_save_marks(0), "save marks have not been newly set."); - int so = SharedHeap::SO_AllClasses | SharedHeap::SO_Strings | SharedHeap::SO_ScavengeCodeCache; - - gch->gen_process_strong_roots(_level, - true, // Process younger gens, if any, - // as strong roots. - true, // activate StrongRootsScope - SharedHeap::ScanningOption(so), - &fsc_with_no_gc_barrier, - &fsc_with_gc_barrier, - &klass_scan_closure); + gch->gen_process_roots(_level, + true, // Process younger gens, if any, + // as strong roots. + true, // activate StrongRootsScope + SharedHeap::SO_ScavengeCodeCache, + GenCollectedHeap::StrongAndWeakRoots, + &fsc_with_no_gc_barrier, + &fsc_with_gc_barrier, + &cld_scan_closure); // "evacuate followers". evacuate_followers.do_void(); diff --git a/hotspot/src/share/vm/memory/genCollectedHeap.cpp b/hotspot/src/share/vm/memory/genCollectedHeap.cpp index bdb915ebb0c..bbca44a36f6 100644 --- a/hotspot/src/share/vm/memory/genCollectedHeap.cpp +++ b/hotspot/src/share/vm/memory/genCollectedHeap.cpp @@ -61,8 +61,8 @@ GenCollectedHeap* GenCollectedHeap::_gch; NOT_PRODUCT(size_t GenCollectedHeap::_skip_header_HeapWords = 0;) -// The set of potentially parallel tasks in strong root scanning. -enum GCH_process_strong_roots_tasks { +// The set of potentially parallel tasks in root scanning. +enum GCH_strong_roots_tasks { // We probably want to parallelize both of these internally, but for now... GCH_PS_younger_gens, // Leave this one last. @@ -72,11 +72,11 @@ enum GCH_process_strong_roots_tasks { GenCollectedHeap::GenCollectedHeap(GenCollectorPolicy *policy) : SharedHeap(policy), _gen_policy(policy), - _gen_process_strong_tasks(new SubTasksDone(GCH_PS_NumElements)), + _gen_process_roots_tasks(new SubTasksDone(GCH_PS_NumElements)), _full_collections_completed(0) { - if (_gen_process_strong_tasks == NULL || - !_gen_process_strong_tasks->valid()) { + if (_gen_process_roots_tasks == NULL || + !_gen_process_roots_tasks->valid()) { vm_exit_during_initialization("Failed necessary allocation."); } assert(policy != NULL, "Sanity check"); @@ -202,13 +202,11 @@ void GenCollectedHeap::post_initialize() { guarantee(policy->is_generation_policy(), "Illegal policy type"); DefNewGeneration* def_new_gen = (DefNewGeneration*) get_gen(0); assert(def_new_gen->kind() == Generation::DefNew || - def_new_gen->kind() == Generation::ParNew || - def_new_gen->kind() == Generation::ASParNew, + def_new_gen->kind() == Generation::ParNew, "Wrong generation kind"); Generation* old_gen = get_gen(1); assert(old_gen->kind() == Generation::ConcurrentMarkSweep || - old_gen->kind() == Generation::ASConcurrentMarkSweep || old_gen->kind() == Generation::MarkSweepCompact, "Wrong generation kind"); @@ -573,9 +571,6 @@ void GenCollectedHeap::do_collection(bool full, } } - AdaptiveSizePolicy* sp = gen_policy()->size_policy(); - AdaptiveSizePolicyOutput(sp, total_collections()); - print_heap_after_gc(); #ifdef TRACESPINNING @@ -589,24 +584,29 @@ HeapWord* GenCollectedHeap::satisfy_failed_allocation(size_t size, bool is_tlab) void GenCollectedHeap::set_par_threads(uint t) { SharedHeap::set_par_threads(t); - _gen_process_strong_tasks->set_n_threads(t); + _gen_process_roots_tasks->set_n_threads(t); } void GenCollectedHeap:: -gen_process_strong_roots(int level, - bool younger_gens_as_roots, - bool activate_scope, - SharedHeap::ScanningOption so, - OopsInGenClosure* not_older_gens, - OopsInGenClosure* older_gens, - KlassClosure* klass_closure) { - // General strong roots. +gen_process_roots(int level, + bool younger_gens_as_roots, + bool activate_scope, + SharedHeap::ScanningOption so, + OopsInGenClosure* not_older_gens, + OopsInGenClosure* weak_roots, + OopsInGenClosure* older_gens, + CLDClosure* cld_closure, + CLDClosure* weak_cld_closure, + CodeBlobClosure* code_closure) { - SharedHeap::process_strong_roots(activate_scope, so, - not_older_gens, klass_closure); + // General roots. + SharedHeap::process_roots(activate_scope, so, + not_older_gens, weak_roots, + cld_closure, weak_cld_closure, + code_closure); if (younger_gens_as_roots) { - if (!_gen_process_strong_tasks->is_task_claimed(GCH_PS_younger_gens)) { + if (!_gen_process_roots_tasks->is_task_claimed(GCH_PS_younger_gens)) { for (int i = 0; i < level; i++) { not_older_gens->set_generation(_gens[i]); _gens[i]->oop_iterate(not_older_gens); @@ -622,7 +622,38 @@ gen_process_strong_roots(int level, older_gens->reset_generation(); } - _gen_process_strong_tasks->all_tasks_completed(); + _gen_process_roots_tasks->all_tasks_completed(); +} + +void GenCollectedHeap:: +gen_process_roots(int level, + bool younger_gens_as_roots, + bool activate_scope, + SharedHeap::ScanningOption so, + bool only_strong_roots, + OopsInGenClosure* not_older_gens, + OopsInGenClosure* older_gens, + CLDClosure* cld_closure) { + + const bool is_adjust_phase = !only_strong_roots && !younger_gens_as_roots; + + bool is_moving_collection = false; + if (level == 0 || is_adjust_phase) { + // young collections are always moving + is_moving_collection = true; + } + + MarkingCodeBlobClosure mark_code_closure(not_older_gens, is_moving_collection); + CodeBlobClosure* code_closure = &mark_code_closure; + + gen_process_roots(level, + younger_gens_as_roots, + activate_scope, so, + not_older_gens, only_strong_roots ? NULL : not_older_gens, + older_gens, + cld_closure, only_strong_roots ? NULL : cld_closure, + code_closure); + } void GenCollectedHeap::gen_process_weak_roots(OopClosure* root_closure) { @@ -724,8 +755,7 @@ void GenCollectedHeap::collect_locked(GCCause::Cause cause, int max_level) { #if INCLUDE_ALL_GCS bool GenCollectedHeap::create_cms_collector() { - assert(((_gens[1]->kind() == Generation::ConcurrentMarkSweep) || - (_gens[1]->kind() == Generation::ASConcurrentMarkSweep)), + assert(_gens[1]->kind() == Generation::ConcurrentMarkSweep, "Unexpected generation kinds"); // Skip two header words in the block content verification NOT_PRODUCT(_skip_header_HeapWords = CMSCollector::skip_header_HeapWords();) diff --git a/hotspot/src/share/vm/memory/genCollectedHeap.hpp b/hotspot/src/share/vm/memory/genCollectedHeap.hpp index dcd389cc90d..dab317d71ff 100644 --- a/hotspot/src/share/vm/memory/genCollectedHeap.hpp +++ b/hotspot/src/share/vm/memory/genCollectedHeap.hpp @@ -78,9 +78,9 @@ public: unsigned int _full_collections_completed; // Data structure for claiming the (potentially) parallel tasks in - // (gen-specific) strong roots processing. - SubTasksDone* _gen_process_strong_tasks; - SubTasksDone* gen_process_strong_tasks() { return _gen_process_strong_tasks; } + // (gen-specific) roots processing. + SubTasksDone* _gen_process_roots_tasks; + SubTasksDone* gen_process_roots_tasks() { return _gen_process_roots_tasks; } // In block contents verification, the number of header words to skip NOT_PRODUCT(static size_t _skip_header_HeapWords;) @@ -403,18 +403,30 @@ public: // The "so" argument determines which of the roots // the closure is applied to: // "SO_None" does none; - // "SO_AllClasses" applies the closure to all entries in the SystemDictionary; - // "SO_SystemClasses" to all the "system" classes and loaders; - // "SO_Strings" applies the closure to all entries in the StringTable. - void gen_process_strong_roots(int level, - bool younger_gens_as_roots, - // The remaining arguments are in an order - // consistent with SharedHeap::process_strong_roots: - bool activate_scope, - SharedHeap::ScanningOption so, - OopsInGenClosure* not_older_gens, - OopsInGenClosure* older_gens, - KlassClosure* klass_closure); + private: + void gen_process_roots(int level, + bool younger_gens_as_roots, + bool activate_scope, + SharedHeap::ScanningOption so, + OopsInGenClosure* not_older_gens, + OopsInGenClosure* weak_roots, + OopsInGenClosure* older_gens, + CLDClosure* cld_closure, + CLDClosure* weak_cld_closure, + CodeBlobClosure* code_closure); + + public: + static const bool StrongAndWeakRoots = false; + static const bool StrongRootsOnly = true; + + void gen_process_roots(int level, + bool younger_gens_as_roots, + bool activate_scope, + SharedHeap::ScanningOption so, + bool only_strong_roots, + OopsInGenClosure* not_older_gens, + OopsInGenClosure* older_gens, + CLDClosure* cld_closure); // Apply "root_closure" to all the weak roots of the system. // These include JNI weak roots, string table, diff --git a/hotspot/src/share/vm/memory/genMarkSweep.cpp b/hotspot/src/share/vm/memory/genMarkSweep.cpp index dcd7308843e..5faab645408 100644 --- a/hotspot/src/share/vm/memory/genMarkSweep.cpp +++ b/hotspot/src/share/vm/memory/genMarkSweep.cpp @@ -207,13 +207,14 @@ void GenMarkSweep::mark_sweep_phase1(int level, // Need new claim bits before marking starts. ClassLoaderDataGraph::clear_claimed_marks(); - gch->gen_process_strong_roots(level, - false, // Younger gens are not roots. - true, // activate StrongRootsScope - SharedHeap::SO_SystemClasses, - &follow_root_closure, - &follow_root_closure, - &follow_klass_closure); + gch->gen_process_roots(level, + false, // Younger gens are not roots. + true, // activate StrongRootsScope + SharedHeap::SO_None, + GenCollectedHeap::StrongRootsOnly, + &follow_root_closure, + &follow_root_closure, + &follow_cld_closure); // Process reference objects found during marking { @@ -291,13 +292,14 @@ void GenMarkSweep::mark_sweep_phase3(int level) { // are run. adjust_pointer_closure.set_orig_generation(gch->get_gen(level)); - gch->gen_process_strong_roots(level, - false, // Younger gens are not roots. - true, // activate StrongRootsScope - SharedHeap::SO_AllClasses | SharedHeap::SO_Strings | SharedHeap::SO_AllCodeCache, - &adjust_pointer_closure, - &adjust_pointer_closure, - &adjust_klass_closure); + gch->gen_process_roots(level, + false, // Younger gens are not roots. + true, // activate StrongRootsScope + SharedHeap::SO_AllCodeCache, + GenCollectedHeap::StrongAndWeakRoots, + &adjust_pointer_closure, + &adjust_pointer_closure, + &adjust_cld_closure); gch->gen_process_weak_roots(&adjust_pointer_closure); diff --git a/hotspot/src/share/vm/memory/generation.cpp b/hotspot/src/share/vm/memory/generation.cpp index 0c121503a17..7a7d21f2563 100644 --- a/hotspot/src/share/vm/memory/generation.cpp +++ b/hotspot/src/share/vm/memory/generation.cpp @@ -154,8 +154,7 @@ bool Generation::is_in(const void* p) const { DefNewGeneration* Generation::as_DefNewGeneration() { assert((kind() == Generation::DefNew) || - (kind() == Generation::ParNew) || - (kind() == Generation::ASParNew), + (kind() == Generation::ParNew), "Wrong youngest generation type"); return (DefNewGeneration*) this; } diff --git a/hotspot/src/share/vm/memory/generation.hpp b/hotspot/src/share/vm/memory/generation.hpp index de60d23f197..feb2fb7946d 100644 --- a/hotspot/src/share/vm/memory/generation.hpp +++ b/hotspot/src/share/vm/memory/generation.hpp @@ -131,8 +131,6 @@ class Generation: public CHeapObj { public: // The set of possible generation kinds. enum Name { - ASParNew, - ASConcurrentMarkSweep, DefNew, ParNew, MarkSweepCompact, diff --git a/hotspot/src/share/vm/memory/generationSpec.cpp b/hotspot/src/share/vm/memory/generationSpec.cpp index 128387cc952..bed0d5484ab 100644 --- a/hotspot/src/share/vm/memory/generationSpec.cpp +++ b/hotspot/src/share/vm/memory/generationSpec.cpp @@ -32,7 +32,6 @@ #include "runtime/java.hpp" #include "utilities/macros.hpp" #if INCLUDE_ALL_GCS -#include "gc_implementation/parNew/asParNewGeneration.hpp" #include "gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp" #include "gc_implementation/parNew/parNewGeneration.hpp" #endif // INCLUDE_ALL_GCS @@ -50,12 +49,6 @@ Generation* GenerationSpec::init(ReservedSpace rs, int level, case Generation::ParNew: return new ParNewGeneration(rs, init_size(), level); - case Generation::ASParNew: - return new ASParNewGeneration(rs, - init_size(), - init_size() /* min size */, - level); - case Generation::ConcurrentMarkSweep: { assert(UseConcMarkSweepGC, "UseConcMarkSweepGC should be set"); CardTableRS* ctrs = remset->as_CardTableRS(); @@ -75,26 +68,6 @@ Generation* GenerationSpec::init(ReservedSpace rs, int level, return g; } - - case Generation::ASConcurrentMarkSweep: { - assert(UseConcMarkSweepGC, "UseConcMarkSweepGC should be set"); - CardTableRS* ctrs = remset->as_CardTableRS(); - if (ctrs == NULL) { - vm_exit_during_initialization("Rem set incompatibility."); - } - // Otherwise - // The constructor creates the CMSCollector if needed, - // else registers with an existing CMSCollector - - ASConcurrentMarkSweepGeneration* g = NULL; - g = new ASConcurrentMarkSweepGeneration(rs, - init_size(), level, ctrs, UseCMSAdaptiveFreeLists, - (FreeBlockDictionary::DictionaryChoice)CMSDictionaryChoice); - - g->initialize_performance_counters(); - - return g; - } #endif // INCLUDE_ALL_GCS default: diff --git a/hotspot/src/share/vm/memory/iterator.cpp b/hotspot/src/share/vm/memory/iterator.cpp index 6cd8e965922..1022ece4617 100644 --- a/hotspot/src/share/vm/memory/iterator.cpp +++ b/hotspot/src/share/vm/memory/iterator.cpp @@ -35,6 +35,10 @@ void CLDToOopClosure::do_cld(ClassLoaderData* cld) { cld->oops_do(_oop_closure, &_klass_closure, _must_claim_cld); } +void CLDToKlassAndOopClosure::do_cld(ClassLoaderData* cld) { + cld->oops_do(_oop_closure, _klass_closure, _must_claim_cld); +} + void ObjectToOopClosure::do_object(oop obj) { obj->oop_iterate(_cl); } @@ -43,6 +47,20 @@ void VoidClosure::do_void() { ShouldNotCallThis(); } +void CodeBlobToOopClosure::do_nmethod(nmethod* nm) { + nm->oops_do(_cl); + if (_fix_relocations) { + nm->fix_oop_relocations(); + } +} + +void CodeBlobToOopClosure::do_code_blob(CodeBlob* cb) { + nmethod* nm = cb->as_nmethod_or_null(); + if (nm != NULL) { + do_nmethod(nm); + } +} + MarkingCodeBlobClosure::MarkScope::MarkScope(bool activate) : _active(activate) { @@ -55,32 +73,7 @@ MarkingCodeBlobClosure::MarkScope::~MarkScope() { void MarkingCodeBlobClosure::do_code_blob(CodeBlob* cb) { nmethod* nm = cb->as_nmethod_or_null(); - if (nm == NULL) return; - if (!nm->test_set_oops_do_mark()) { - NOT_PRODUCT(if (TraceScavenge) nm->print_on(tty, "oops_do, 1st visit\n")); - do_newly_marked_nmethod(nm); - } else { - NOT_PRODUCT(if (TraceScavenge) nm->print_on(tty, "oops_do, skipped on 2nd visit\n")); + if (nm != NULL && !nm->test_set_oops_do_mark()) { + do_nmethod(nm); } } - -void CodeBlobToOopClosure::do_newly_marked_nmethod(nmethod* nm) { - nm->oops_do(_cl, /*allow_zombie=*/ false); -} - -void CodeBlobToOopClosure::do_code_blob(CodeBlob* cb) { - if (!_do_marking) { - nmethod* nm = cb->as_nmethod_or_null(); - NOT_PRODUCT(if (TraceScavenge && Verbose && nm != NULL) nm->print_on(tty, "oops_do, unmarked visit\n")); - // This assert won't work, since there are lots of mini-passes - // (mostly in debug mode) that co-exist with marking phases. - //assert(!(cb->is_nmethod() && ((nmethod*)cb)->test_oops_do_mark()), "found marked nmethod during mark-free phase"); - if (nm != NULL) { - nm->oops_do(_cl); - } - } else { - MarkingCodeBlobClosure::do_code_blob(cb); - } -} - - diff --git a/hotspot/src/share/vm/memory/iterator.hpp b/hotspot/src/share/vm/memory/iterator.hpp index e91d42974b1..12684527023 100644 --- a/hotspot/src/share/vm/memory/iterator.hpp +++ b/hotspot/src/share/vm/memory/iterator.hpp @@ -70,8 +70,8 @@ class ExtendedOopClosure : public OopClosure { // // Providing default implementations of the _nv functions unfortunately // removes the compile-time safeness, but reduces the clutter for the - // ExtendedOopClosures that don't need to walk the metadata. Currently, - // only CMS needs these. + // ExtendedOopClosures that don't need to walk the metadata. + // Currently, only CMS and G1 need these. virtual bool do_metadata() { return do_metadata_nv(); } bool do_metadata_v() { return do_metadata(); } @@ -126,15 +126,16 @@ class KlassToOopClosure : public KlassClosure { _oop_closure = oop_closure; } -public: + public: KlassToOopClosure(OopClosure* oop_closure = NULL) : _oop_closure(oop_closure) {} + virtual void do_klass(Klass* k); }; class CLDToOopClosure : public CLDClosure { - OopClosure* _oop_closure; + OopClosure* _oop_closure; KlassToOopClosure _klass_closure; - bool _must_claim_cld; + bool _must_claim_cld; public: CLDToOopClosure(OopClosure* oop_closure, bool must_claim_cld = true) : @@ -145,6 +146,23 @@ class CLDToOopClosure : public CLDClosure { void do_cld(ClassLoaderData* cld); }; +class CLDToKlassAndOopClosure : public CLDClosure { + friend class SharedHeap; + friend class G1CollectedHeap; + protected: + OopClosure* _oop_closure; + KlassClosure* _klass_closure; + bool _must_claim_cld; + public: + CLDToKlassAndOopClosure(KlassClosure* klass_closure, + OopClosure* oop_closure, + bool must_claim_cld) : + _oop_closure(oop_closure), + _klass_closure(klass_closure), + _must_claim_cld(must_claim_cld) {} + void do_cld(ClassLoaderData* cld); +}; + // The base class for all concurrent marking closures, // that participates in class unloading. // It's used to proxy through the metadata to the oops defined in them. @@ -246,14 +264,26 @@ class CodeBlobClosure : public Closure { virtual void do_code_blob(CodeBlob* cb) = 0; }; - -class MarkingCodeBlobClosure : public CodeBlobClosure { +// Applies an oop closure to all ref fields in code blobs +// iterated over in an object iteration. +class CodeBlobToOopClosure : public CodeBlobClosure { + OopClosure* _cl; + bool _fix_relocations; + protected: + void do_nmethod(nmethod* nm); public: + CodeBlobToOopClosure(OopClosure* cl, bool fix_relocations) : _cl(cl), _fix_relocations(fix_relocations) {} + virtual void do_code_blob(CodeBlob* cb); + + const static bool FixRelocations = true; +}; + +class MarkingCodeBlobClosure : public CodeBlobToOopClosure { + public: + MarkingCodeBlobClosure(OopClosure* cl, bool fix_relocations) : CodeBlobToOopClosure(cl, fix_relocations) {} // Called for each code blob, but at most once per unique blob. - virtual void do_newly_marked_nmethod(nmethod* nm) = 0; virtual void do_code_blob(CodeBlob* cb); - // = { if (!nmethod(cb)->test_set_oops_do_mark()) do_newly_marked_nmethod(cb); } class MarkScope : public StackObj { protected: @@ -266,23 +296,6 @@ class MarkingCodeBlobClosure : public CodeBlobClosure { }; }; - -// Applies an oop closure to all ref fields in code blobs -// iterated over in an object iteration. -class CodeBlobToOopClosure: public MarkingCodeBlobClosure { - OopClosure* _cl; - bool _do_marking; -public: - virtual void do_newly_marked_nmethod(nmethod* cb); - // = { cb->oops_do(_cl); } - virtual void do_code_blob(CodeBlob* cb); - // = { if (_do_marking) super::do_code_blob(cb); else cb->oops_do(_cl); } - CodeBlobToOopClosure(OopClosure* cl, bool do_marking) - : _cl(cl), _do_marking(do_marking) {} -}; - - - // MonitorClosure is used for iterating over monitors in the monitors cache class ObjectMonitor; diff --git a/hotspot/src/share/vm/memory/metadataFactory.hpp b/hotspot/src/share/vm/memory/metadataFactory.hpp index 9f7a22eaf55..dbb936fdf57 100644 --- a/hotspot/src/share/vm/memory/metadataFactory.hpp +++ b/hotspot/src/share/vm/memory/metadataFactory.hpp @@ -25,6 +25,7 @@ #ifndef SHARE_VM_MEMORY_METADATAFACTORY_HPP #define SHARE_VM_MEMORY_METADATAFACTORY_HPP +#include "classfile/classLoaderData.hpp" #include "utilities/array.hpp" #include "utilities/exceptions.hpp" #include "utilities/globalDefinitions.hpp" diff --git a/hotspot/src/share/vm/memory/sharedHeap.cpp b/hotspot/src/share/vm/memory/sharedHeap.cpp index 77011f7a166..e0a5d9961cb 100644 --- a/hotspot/src/share/vm/memory/sharedHeap.cpp +++ b/hotspot/src/share/vm/memory/sharedHeap.cpp @@ -29,6 +29,7 @@ #include "gc_interface/collectedHeap.inline.hpp" #include "memory/sharedHeap.hpp" #include "oops/oop.inline.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/fprofiler.hpp" #include "runtime/java.hpp" #include "services/management.hpp" @@ -39,8 +40,8 @@ PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC SharedHeap* SharedHeap::_sh; -// The set of potentially parallel tasks in strong root scanning. -enum SH_process_strong_roots_tasks { +// The set of potentially parallel tasks in root scanning. +enum SH_process_roots_tasks { SH_PS_Universe_oops_do, SH_PS_JNIHandles_oops_do, SH_PS_ObjectSynchronizer_oops_do, @@ -58,6 +59,7 @@ SharedHeap::SharedHeap(CollectorPolicy* policy_) : CollectedHeap(), _collector_policy(policy_), _rem_set(NULL), + _strong_roots_scope(NULL), _strong_roots_parity(0), _process_strong_tasks(new SubTasksDone(SH_PS_NumElements)), _workers(NULL) @@ -114,6 +116,19 @@ public: static AssertNonScavengableClosure assert_is_non_scavengable_closure; #endif +SharedHeap::StrongRootsScope* SharedHeap::active_strong_roots_scope() const { + return _strong_roots_scope; +} +void SharedHeap::register_strong_roots_scope(SharedHeap::StrongRootsScope* scope) { + assert(_strong_roots_scope == NULL, "Should only have one StrongRootsScope active"); + assert(scope != NULL, "Illegal argument"); + _strong_roots_scope = scope; +} +void SharedHeap::unregister_strong_roots_scope(SharedHeap::StrongRootsScope* scope) { + assert(_strong_roots_scope == scope, "Wrong scope unregistered"); + _strong_roots_scope = NULL; +} + void SharedHeap::change_strong_roots_parity() { // Also set the new collection parity. assert(_strong_roots_parity >= 0 && _strong_roots_parity <= 2, @@ -124,112 +139,161 @@ void SharedHeap::change_strong_roots_parity() { "Not in range."); } -SharedHeap::StrongRootsScope::StrongRootsScope(SharedHeap* outer, bool activate) - : MarkScope(activate) +SharedHeap::StrongRootsScope::StrongRootsScope(SharedHeap* heap, bool activate) + : MarkScope(activate), _sh(heap), _n_workers_done_with_threads(0) { if (_active) { - outer->change_strong_roots_parity(); + _sh->register_strong_roots_scope(this); + _sh->change_strong_roots_parity(); // Zero the claimed high water mark in the StringTable StringTable::clear_parallel_claimed_index(); } } SharedHeap::StrongRootsScope::~StrongRootsScope() { - // nothing particular + if (_active) { + _sh->unregister_strong_roots_scope(this); + } } -void SharedHeap::process_strong_roots(bool activate_scope, - ScanningOption so, - OopClosure* roots, - KlassClosure* klass_closure) { +Monitor* SharedHeap::StrongRootsScope::_lock = new Monitor(Mutex::leaf, "StrongRootsScope lock", false); + +void SharedHeap::StrongRootsScope::mark_worker_done_with_threads(uint n_workers) { + // The Thread work barrier is only needed by G1. + // No need to use the barrier if this is single-threaded code. + if (UseG1GC && n_workers > 0) { + uint new_value = (uint)Atomic::add(1, &_n_workers_done_with_threads); + if (new_value == n_workers) { + // This thread is last. Notify the others. + MonitorLockerEx ml(_lock, Mutex::_no_safepoint_check_flag); + _lock->notify_all(); + } + } +} + +void SharedHeap::StrongRootsScope::wait_until_all_workers_done_with_threads(uint n_workers) { + // No need to use the barrier if this is single-threaded code. + if (n_workers > 0 && (uint)_n_workers_done_with_threads != n_workers) { + MonitorLockerEx ml(_lock, Mutex::_no_safepoint_check_flag); + while ((uint)_n_workers_done_with_threads != n_workers) { + _lock->wait(Mutex::_no_safepoint_check_flag, 0, false); + } + } +} + +void SharedHeap::process_roots(bool activate_scope, + ScanningOption so, + OopClosure* strong_roots, + OopClosure* weak_roots, + CLDClosure* strong_cld_closure, + CLDClosure* weak_cld_closure, + CodeBlobClosure* code_roots) { StrongRootsScope srs(this, activate_scope); - // General strong roots. + // General roots. assert(_strong_roots_parity != 0, "must have called prologue code"); + assert(code_roots != NULL, "code root closure should always be set"); // _n_termination for _process_strong_tasks should be set up stream // in a method not running in a GC worker. Otherwise the GC worker // could be trying to change the termination condition while the task // is executing in another GC worker. + + // Iterating over the CLDG and the Threads are done early to allow G1 to + // first process the strong CLDs and nmethods and then, after a barrier, + // let the thread process the weak CLDs and nmethods. + + if (!_process_strong_tasks->is_task_claimed(SH_PS_ClassLoaderDataGraph_oops_do)) { + ClassLoaderDataGraph::roots_cld_do(strong_cld_closure, weak_cld_closure); + } + + // Some CLDs contained in the thread frames should be considered strong. + // Don't process them if they will be processed during the ClassLoaderDataGraph phase. + CLDClosure* roots_from_clds_p = (strong_cld_closure != weak_cld_closure) ? strong_cld_closure : NULL; + // Only process code roots from thread stacks if we aren't visiting the entire CodeCache anyway + CodeBlobClosure* roots_from_code_p = (so & SO_AllCodeCache) ? NULL : code_roots; + + Threads::possibly_parallel_oops_do(strong_roots, roots_from_clds_p, roots_from_code_p); + + // This is the point where this worker thread will not find more strong CLDs/nmethods. + // Report this so G1 can synchronize the strong and weak CLDs/nmethods processing. + active_strong_roots_scope()->mark_worker_done_with_threads(n_par_threads()); + if (!_process_strong_tasks->is_task_claimed(SH_PS_Universe_oops_do)) { - Universe::oops_do(roots); + Universe::oops_do(strong_roots); } // Global (strong) JNI handles if (!_process_strong_tasks->is_task_claimed(SH_PS_JNIHandles_oops_do)) - JNIHandles::oops_do(roots); - - CodeBlobToOopClosure code_roots(roots, true); - - CLDToOopClosure roots_from_clds(roots); - // If we limit class scanning to SO_SystemClasses we need to apply a CLD closure to - // CLDs which are strongly reachable from the thread stacks. - CLDToOopClosure* roots_from_clds_p = ((so & SO_SystemClasses) ? &roots_from_clds : NULL); - // All threads execute this; the individual threads are task groups. - if (CollectedHeap::use_parallel_gc_threads()) { - Threads::possibly_parallel_oops_do(roots, roots_from_clds_p, &code_roots); - } else { - Threads::oops_do(roots, roots_from_clds_p, &code_roots); - } + JNIHandles::oops_do(strong_roots); if (!_process_strong_tasks-> is_task_claimed(SH_PS_ObjectSynchronizer_oops_do)) - ObjectSynchronizer::oops_do(roots); + ObjectSynchronizer::oops_do(strong_roots); if (!_process_strong_tasks->is_task_claimed(SH_PS_FlatProfiler_oops_do)) - FlatProfiler::oops_do(roots); + FlatProfiler::oops_do(strong_roots); if (!_process_strong_tasks->is_task_claimed(SH_PS_Management_oops_do)) - Management::oops_do(roots); + Management::oops_do(strong_roots); if (!_process_strong_tasks->is_task_claimed(SH_PS_jvmti_oops_do)) - JvmtiExport::oops_do(roots); + JvmtiExport::oops_do(strong_roots); if (!_process_strong_tasks->is_task_claimed(SH_PS_SystemDictionary_oops_do)) { - if (so & SO_AllClasses) { - SystemDictionary::oops_do(roots); - } else if (so & SO_SystemClasses) { - SystemDictionary::always_strong_oops_do(roots); - } else { - fatal("We should always have selected either SO_AllClasses or SO_SystemClasses"); - } - } - - if (!_process_strong_tasks->is_task_claimed(SH_PS_ClassLoaderDataGraph_oops_do)) { - if (so & SO_AllClasses) { - ClassLoaderDataGraph::oops_do(roots, klass_closure, /* must_claim */ false); - } else if (so & SO_SystemClasses) { - ClassLoaderDataGraph::always_strong_oops_do(roots, klass_closure, /* must_claim */ true); - } + SystemDictionary::roots_oops_do(strong_roots, weak_roots); } // All threads execute the following. A specific chunk of buckets // from the StringTable are the individual tasks. - if (so & SO_Strings) { + if (weak_roots != NULL) { if (CollectedHeap::use_parallel_gc_threads()) { - StringTable::possibly_parallel_oops_do(roots); + StringTable::possibly_parallel_oops_do(weak_roots); } else { - StringTable::oops_do(roots); + StringTable::oops_do(weak_roots); } } if (!_process_strong_tasks->is_task_claimed(SH_PS_CodeCache_oops_do)) { if (so & SO_ScavengeCodeCache) { - assert(&code_roots != NULL, "must supply closure for code cache"); + assert(code_roots != NULL, "must supply closure for code cache"); // We only visit parts of the CodeCache when scavenging. - CodeCache::scavenge_root_nmethods_do(&code_roots); + CodeCache::scavenge_root_nmethods_do(code_roots); } if (so & SO_AllCodeCache) { - assert(&code_roots != NULL, "must supply closure for code cache"); + assert(code_roots != NULL, "must supply closure for code cache"); // CMSCollector uses this to do intermediate-strength collections. // We scan the entire code cache, since CodeCache::do_unloading is not called. - CodeCache::blobs_do(&code_roots); + CodeCache::blobs_do(code_roots); } // Verify that the code cache contents are not subject to // movement by a scavenging collection. - DEBUG_ONLY(CodeBlobToOopClosure assert_code_is_non_scavengable(&assert_is_non_scavengable_closure, /*do_marking=*/ false)); + DEBUG_ONLY(CodeBlobToOopClosure assert_code_is_non_scavengable(&assert_is_non_scavengable_closure, !CodeBlobToOopClosure::FixRelocations)); DEBUG_ONLY(CodeCache::asserted_non_scavengable_nmethods_do(&assert_code_is_non_scavengable)); } _process_strong_tasks->all_tasks_completed(); } +void SharedHeap::process_all_roots(bool activate_scope, + ScanningOption so, + OopClosure* roots, + CLDClosure* cld_closure, + CodeBlobClosure* code_closure) { + process_roots(activate_scope, so, + roots, roots, + cld_closure, cld_closure, + code_closure); +} + +void SharedHeap::process_strong_roots(bool activate_scope, + ScanningOption so, + OopClosure* roots, + CLDClosure* cld_closure, + CodeBlobClosure* code_closure) { + process_roots(activate_scope, so, + roots, NULL, + cld_closure, NULL, + code_closure); +} + + class AlwaysTrueClosure: public BoolObjectClosure { public: bool do_object_b(oop p) { return true; } diff --git a/hotspot/src/share/vm/memory/sharedHeap.hpp b/hotspot/src/share/vm/memory/sharedHeap.hpp index fef0a3da068..c934b6bdf15 100644 --- a/hotspot/src/share/vm/memory/sharedHeap.hpp +++ b/hotspot/src/share/vm/memory/sharedHeap.hpp @@ -69,14 +69,10 @@ class KlassClosure; // number of active GC workers. CompactibleFreeListSpace and Space // have SequentialSubTasksDone's. // Example of using SubTasksDone and SequentialSubTasksDone -// G1CollectedHeap::g1_process_strong_roots() calls -// process_strong_roots(false, // no scoping; this is parallel code -// is_scavenging, so, -// &buf_scan_non_heap_roots, -// &eager_scan_code_roots); -// which delegates to SharedHeap::process_strong_roots() and uses +// G1CollectedHeap::g1_process_roots() +// to SharedHeap::process_roots() and uses // SubTasksDone* _process_strong_tasks to claim tasks. -// process_strong_roots() calls +// process_roots() calls // rem_set()->younger_refs_iterate() // to scan the card table and which eventually calls down into // CardTableModRefBS::par_non_clean_card_iterate_work(). This method @@ -182,12 +178,12 @@ public: // task. (This also means that a parallel thread may only call // process_strong_roots once.) // - // For calls to process_strong_roots by sequential code, the parity is + // For calls to process_roots by sequential code, the parity is // updated automatically. // // The idea is that objects representing fine-grained tasks, such as // threads, will contain a "parity" field. A task will is claimed in the - // current "process_strong_roots" call only if its parity field is the + // current "process_roots" call only if its parity field is the // same as the "strong_roots_parity"; task claiming is accomplished by // updating the parity field to the strong_roots_parity with a CAS. // @@ -198,27 +194,44 @@ public: // c) to never return a distinguished value (zero) with which such // task-claiming variables may be initialized, to indicate "never // claimed". - private: - void change_strong_roots_parity(); public: int strong_roots_parity() { return _strong_roots_parity; } - // Call these in sequential code around process_strong_roots. + // Call these in sequential code around process_roots. // strong_roots_prologue calls change_strong_roots_parity, if // parallel tasks are enabled. class StrongRootsScope : public MarkingCodeBlobClosure::MarkScope { - public: - StrongRootsScope(SharedHeap* outer, bool activate = true); + // Used to implement the Thread work barrier. + static Monitor* _lock; + + SharedHeap* _sh; + volatile jint _n_workers_done_with_threads; + + public: + StrongRootsScope(SharedHeap* heap, bool activate = true); ~StrongRootsScope(); + + // Mark that this thread is done with the Threads work. + void mark_worker_done_with_threads(uint n_workers); + // Wait until all n_workers are done with the Threads work. + void wait_until_all_workers_done_with_threads(uint n_workers); }; friend class StrongRootsScope; + // The current active StrongRootScope + StrongRootsScope* _strong_roots_scope; + + StrongRootsScope* active_strong_roots_scope() const; + + private: + void register_strong_roots_scope(StrongRootsScope* scope); + void unregister_strong_roots_scope(StrongRootsScope* scope); + void change_strong_roots_parity(); + + public: enum ScanningOption { - SO_None = 0x0, - SO_AllClasses = 0x1, - SO_SystemClasses = 0x2, - SO_Strings = 0x4, - SO_AllCodeCache = 0x8, + SO_None = 0x0, + SO_AllCodeCache = 0x8, SO_ScavengeCodeCache = 0x10 }; @@ -227,15 +240,26 @@ public: // Invoke the "do_oop" method the closure "roots" on all root locations. // The "so" argument determines which roots the closure is applied to: // "SO_None" does none; - // "SO_AllClasses" applies the closure to all entries in the SystemDictionary; - // "SO_SystemClasses" to all the "system" classes and loaders; - // "SO_Strings" applies the closure to all entries in StringTable; // "SO_AllCodeCache" applies the closure to all elements of the CodeCache. // "SO_ScavengeCodeCache" applies the closure to elements on the scavenge root list in the CodeCache. + void process_roots(bool activate_scope, + ScanningOption so, + OopClosure* strong_roots, + OopClosure* weak_roots, + CLDClosure* strong_cld_closure, + CLDClosure* weak_cld_closure, + CodeBlobClosure* code_roots); + void process_all_roots(bool activate_scope, + ScanningOption so, + OopClosure* roots, + CLDClosure* cld_closure, + CodeBlobClosure* code_roots); void process_strong_roots(bool activate_scope, ScanningOption so, OopClosure* roots, - KlassClosure* klass_closure); + CLDClosure* cld_closure, + CodeBlobClosure* code_roots); + // Apply "root_closure" to the JNI weak roots.. void process_weak_roots(OopClosure* root_closure); @@ -251,7 +275,7 @@ public: virtual void gc_epilogue(bool full) = 0; // Sets the number of parallel threads that will be doing tasks - // (such as process strong roots) subsequently. + // (such as process roots) subsequently. virtual void set_par_threads(uint t); int n_termination(); diff --git a/hotspot/src/share/vm/memory/space.cpp b/hotspot/src/share/vm/memory/space.cpp index 396a743ac3b..330dd3fdef9 100644 --- a/hotspot/src/share/vm/memory/space.cpp +++ b/hotspot/src/share/vm/memory/space.cpp @@ -685,14 +685,8 @@ size_t ContiguousSpace::block_size(const HeapWord* p) const { // This version requires locking. inline HeapWord* ContiguousSpace::allocate_impl(size_t size, HeapWord* const end_value) { - // In G1 there are places where a GC worker can allocates into a - // region using this serial allocation code without being prone to a - // race with other GC workers (we ensure that no other GC worker can - // access the same region at the same time). So the assert below is - // too strong in the case of G1. assert(Heap_lock->owned_by_self() || - (SafepointSynchronize::is_at_safepoint() && - (Thread::current()->is_VM_thread() || UseG1GC)), + (SafepointSynchronize::is_at_safepoint() && Thread::current()->is_VM_thread()), "not locked"); HeapWord* obj = top(); if (pointer_delta(end_value, obj) >= size) { diff --git a/hotspot/src/share/vm/memory/universe.cpp b/hotspot/src/share/vm/memory/universe.cpp index 9d5a2a6cbae..8ea866f4dec 100644 --- a/hotspot/src/share/vm/memory/universe.cpp +++ b/hotspot/src/share/vm/memory/universe.cpp @@ -72,7 +72,7 @@ #include "utilities/preserveException.hpp" #include "utilities/macros.hpp" #if INCLUDE_ALL_GCS -#include "gc_implementation/concurrentMarkSweep/cmsAdaptiveSizePolicy.hpp" +#include "gc_implementation/shared/adaptiveSizePolicy.hpp" #include "gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.hpp" #include "gc_implementation/g1/g1CollectedHeap.inline.hpp" #include "gc_implementation/g1/g1CollectorPolicy.hpp" @@ -802,13 +802,9 @@ jint Universe::initialize_heap() { gc_policy = new MarkSweepPolicy(); } else if (UseConcMarkSweepGC) { #if INCLUDE_ALL_GCS - if (UseAdaptiveSizePolicy) { - gc_policy = new ASConcurrentMarkSweepPolicy(); - } else { - gc_policy = new ConcurrentMarkSweepPolicy(); - } + gc_policy = new ConcurrentMarkSweepPolicy(); #else // INCLUDE_ALL_GCS - fatal("UseConcMarkSweepGC not supported in this VM."); + fatal("UseConcMarkSweepGC not supported in this VM."); #endif // INCLUDE_ALL_GCS } else { // default old generation gc_policy = new MarkSweepPolicy(); diff --git a/hotspot/src/share/vm/oops/constantPool.cpp b/hotspot/src/share/vm/oops/constantPool.cpp index 111d55b3af7..f26c0d4318a 100644 --- a/hotspot/src/share/vm/oops/constantPool.cpp +++ b/hotspot/src/share/vm/oops/constantPool.cpp @@ -520,13 +520,9 @@ bool ConstantPool::resolve_class_constants(TRAPS) { Symbol* ConstantPool::exception_message(constantPoolHandle this_cp, int which, constantTag tag, oop pending_exception) { // Dig out the detailed message to reuse if possible - Symbol* message = NULL; - oop detailed_message = java_lang_Throwable::message(pending_exception); - if (detailed_message != NULL) { - message = java_lang_String::as_symbol_or_null(detailed_message); - if (message != NULL) { - return message; - } + Symbol* message = java_lang_Throwable::detail_message(pending_exception); + if (message != NULL) { + return message; } // Return specific message for the tag diff --git a/hotspot/src/share/vm/oops/instanceKlass.cpp b/hotspot/src/share/vm/oops/instanceKlass.cpp index 91d00f8fdea..2dba59265b1 100644 --- a/hotspot/src/share/vm/oops/instanceKlass.cpp +++ b/hotspot/src/share/vm/oops/instanceKlass.cpp @@ -245,6 +245,7 @@ InstanceKlass::InstanceKlass(int vtable_len, set_static_oop_field_count(0); set_nonstatic_field_size(0); set_is_marked_dependent(false); + set_has_unloaded_dependent(false); set_init_state(InstanceKlass::allocated); set_init_thread(NULL); set_reference_type(rt); @@ -1801,6 +1802,9 @@ jmethodID InstanceKlass::jmethod_id_or_null(Method* method) { return id; } +int nmethodBucket::decrement() { + return Atomic::add(-1, (volatile int *)&_count); +} // // Walk the list of dependent nmethods searching for nmethods which @@ -1815,7 +1819,7 @@ int InstanceKlass::mark_dependent_nmethods(DepChange& changes) { nmethod* nm = b->get_nmethod(); // since dependencies aren't removed until an nmethod becomes a zombie, // the dependency list may contain nmethods which aren't alive. - if (nm->is_alive() && !nm->is_marked_for_deoptimization() && nm->check_dependency_on(changes)) { + if (b->count() > 0 && nm->is_alive() && !nm->is_marked_for_deoptimization() && nm->check_dependency_on(changes)) { if (TraceDependencies) { ResourceMark rm; tty->print_cr("Marked for deoptimization"); @@ -1832,6 +1836,43 @@ int InstanceKlass::mark_dependent_nmethods(DepChange& changes) { return found; } +void InstanceKlass::clean_dependent_nmethods() { + assert_locked_or_safepoint(CodeCache_lock); + + if (has_unloaded_dependent()) { + nmethodBucket* b = _dependencies; + nmethodBucket* last = NULL; + while (b != NULL) { + assert(b->count() >= 0, err_msg("bucket count: %d", b->count())); + + nmethodBucket* next = b->next(); + + if (b->count() == 0) { + if (last == NULL) { + _dependencies = next; + } else { + last->set_next(next); + } + delete b; + // last stays the same. + } else { + last = b; + } + + b = next; + } + set_has_unloaded_dependent(false); + } +#ifdef ASSERT + else { + // Verification + for (nmethodBucket* b = _dependencies; b != NULL; b = b->next()) { + assert(b->count() >= 0, err_msg("bucket count: %d", b->count())); + assert(b->count() != 0, "empty buckets need to be cleaned"); + } + } +#endif +} // // Add an nmethodBucket to the list of dependencies for this nmethod. @@ -1866,13 +1907,10 @@ void InstanceKlass::remove_dependent_nmethod(nmethod* nm) { nmethodBucket* last = NULL; while (b != NULL) { if (nm == b->get_nmethod()) { - if (b->decrement() == 0) { - if (last == NULL) { - _dependencies = b->next(); - } else { - last->set_next(b->next()); - } - delete b; + int val = b->decrement(); + guarantee(val >= 0, err_msg("Underflow: %d", val)); + if (val == 0) { + set_has_unloaded_dependent(true); } return; } @@ -1911,6 +1949,10 @@ bool InstanceKlass::is_dependent_nmethod(nmethod* nm) { nmethodBucket* b = _dependencies; while (b != NULL) { if (nm == b->get_nmethod()) { +#ifdef ASSERT + int count = b->count(); + assert(count >= 0, err_msg("count shouldn't be negative: %d", count)); +#endif return true; } b = b->next(); @@ -2209,7 +2251,7 @@ int InstanceKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) { #endif // INCLUDE_ALL_GCS void InstanceKlass::clean_implementors_list(BoolObjectClosure* is_alive) { - assert(is_loader_alive(is_alive), "this klass should be live"); + assert(class_loader_data()->is_alive(is_alive), "this klass should be live"); if (is_interface()) { if (ClassUnloading) { Klass* impl = implementor(); diff --git a/hotspot/src/share/vm/oops/instanceKlass.hpp b/hotspot/src/share/vm/oops/instanceKlass.hpp index d6c919e9462..f2904057146 100644 --- a/hotspot/src/share/vm/oops/instanceKlass.hpp +++ b/hotspot/src/share/vm/oops/instanceKlass.hpp @@ -197,6 +197,7 @@ class InstanceKlass: public Klass { // _is_marked_dependent can be set concurrently, thus cannot be part of the // _misc_flags. bool _is_marked_dependent; // used for marking during flushing and deoptimization + bool _has_unloaded_dependent; enum { _misc_rewritten = 1 << 0, // methods rewritten. @@ -444,6 +445,9 @@ class InstanceKlass: public Klass { bool is_marked_dependent() const { return _is_marked_dependent; } void set_is_marked_dependent(bool value) { _is_marked_dependent = value; } + bool has_unloaded_dependent() const { return _has_unloaded_dependent; } + void set_has_unloaded_dependent(bool value) { _has_unloaded_dependent = value; } + // initialization (virtuals from Klass) bool should_be_initialized() const; // means that initialize should be called void initialize(TRAPS); @@ -922,6 +926,7 @@ class InstanceKlass: public Klass { void clean_implementors_list(BoolObjectClosure* is_alive); void clean_method_data(BoolObjectClosure* is_alive); + void clean_dependent_nmethods(); // Explicit metaspace deallocation of fields // For RedefineClasses and class file parsing errors, we need to deallocate @@ -1210,7 +1215,7 @@ class nmethodBucket: public CHeapObj { } int count() { return _count; } int increment() { _count += 1; return _count; } - int decrement() { _count -= 1; assert(_count >= 0, "don't underflow"); return _count; } + int decrement(); nmethodBucket* next() { return _next; } void set_next(nmethodBucket* b) { _next = b; } nmethod* get_nmethod() { return _nmethod; } diff --git a/hotspot/src/share/vm/oops/klass.cpp b/hotspot/src/share/vm/oops/klass.cpp index 77e2561258f..1df975312c7 100644 --- a/hotspot/src/share/vm/oops/klass.cpp +++ b/hotspot/src/share/vm/oops/klass.cpp @@ -42,6 +42,7 @@ #include "utilities/stack.hpp" #include "utilities/macros.hpp" #if INCLUDE_ALL_GCS +#include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp" #include "gc_implementation/parallelScavenge/psParallelCompact.hpp" #include "gc_implementation/parallelScavenge/psPromotionManager.hpp" #include "gc_implementation/parallelScavenge/psScavenge.hpp" @@ -159,7 +160,12 @@ Klass::Klass() { _primary_supers[0] = k; set_super_check_offset(in_bytes(primary_supers_offset())); - set_java_mirror(NULL); + // The constructor is used from init_self_patching_vtbl_list, + // which doesn't zero out the memory before calling the constructor. + // Need to set the field explicitly to not hit an assert that the field + // should be NULL before setting it. + _java_mirror = NULL; + set_modifier_flags(0); set_layout_helper(Klass::_lh_neutral_value); set_name(NULL); @@ -383,7 +389,7 @@ bool Klass::is_loader_alive(BoolObjectClosure* is_alive) { return mirror_alive; } -void Klass::clean_weak_klass_links(BoolObjectClosure* is_alive) { +void Klass::clean_weak_klass_links(BoolObjectClosure* is_alive, bool clean_alive_klasses) { if (!ClassUnloading) { return; } @@ -428,7 +434,7 @@ void Klass::clean_weak_klass_links(BoolObjectClosure* is_alive) { } // Clean the implementors list and method data. - if (current->oop_is_instance()) { + if (clean_alive_klasses && current->oop_is_instance()) { InstanceKlass* ik = InstanceKlass::cast(current); ik->clean_implementors_list(is_alive); ik->clean_method_data(is_alive); @@ -440,12 +446,18 @@ void Klass::klass_update_barrier_set(oop v) { record_modified_oops(); } -void Klass::klass_update_barrier_set_pre(void* p, oop v) { - // This barrier used by G1, where it's used remember the old oop values, - // so that we don't forget any objects that were live at the snapshot at - // the beginning. This function is only used when we write oops into - // Klasses. Since the Klasses are used as roots in G1, we don't have to - // do anything here. +// This barrier is used by G1 to remember the old oop values, so +// that we don't forget any objects that were live at the snapshot at +// the beginning. This function is only used when we write oops into Klasses. +void Klass::klass_update_barrier_set_pre(oop* p, oop v) { +#if INCLUDE_ALL_GCS + if (UseG1GC) { + oop obj = *p; + if (obj != NULL) { + G1SATBCardTableModRefBS::enqueue(obj); + } + } +#endif } void Klass::klass_oop_store(oop* p, oop v) { @@ -456,7 +468,7 @@ void Klass::klass_oop_store(oop* p, oop v) { if (always_do_update_barrier) { klass_oop_store((volatile oop*)p, v); } else { - klass_update_barrier_set_pre((void*)p, v); + klass_update_barrier_set_pre(p, v); *p = v; klass_update_barrier_set(v); } @@ -466,7 +478,7 @@ void Klass::klass_oop_store(volatile oop* p, oop v) { assert(!Universe::heap()->is_in_reserved((void*)p), "Should store pointer into metadata"); assert(v == NULL || Universe::heap()->is_in_reserved((void*)v), "Should store pointer to an object"); - klass_update_barrier_set_pre((void*)p, v); + klass_update_barrier_set_pre((oop*)p, v); // Cast away volatile. OrderAccess::release_store_ptr(p, v); klass_update_barrier_set(v); } diff --git a/hotspot/src/share/vm/oops/klass.hpp b/hotspot/src/share/vm/oops/klass.hpp index 06198fbb11c..e443dddeed8 100644 --- a/hotspot/src/share/vm/oops/klass.hpp +++ b/hotspot/src/share/vm/oops/klass.hpp @@ -553,7 +553,10 @@ class Klass : public Metadata { // The is_alive closure passed in depends on the Garbage Collector used. bool is_loader_alive(BoolObjectClosure* is_alive); - static void clean_weak_klass_links(BoolObjectClosure* is_alive); + static void clean_weak_klass_links(BoolObjectClosure* is_alive, bool clean_alive_klasses = true); + static void clean_subklass_tree(BoolObjectClosure* is_alive) { + clean_weak_klass_links(is_alive, false /* clean_alive_klasses */); + } // iterators virtual int oop_oop_iterate(oop obj, ExtendedOopClosure* blk) = 0; @@ -660,7 +663,7 @@ class Klass : public Metadata { private: // barriers used by klass_oop_store void klass_update_barrier_set(oop v); - void klass_update_barrier_set_pre(void* p, oop v); + void klass_update_barrier_set_pre(oop* p, oop v); }; #endif // SHARE_VM_OOPS_KLASS_HPP diff --git a/hotspot/src/share/vm/oops/oopsHierarchy.hpp b/hotspot/src/share/vm/oops/oopsHierarchy.hpp index cd63547c38c..b6c12faec37 100644 --- a/hotspot/src/share/vm/oops/oopsHierarchy.hpp +++ b/hotspot/src/share/vm/oops/oopsHierarchy.hpp @@ -124,7 +124,7 @@ public: operator oopDesc* () const volatile { return obj(); } operator intptr_t* () const { return (intptr_t*)obj(); } operator PromotedObject* () const { return (PromotedObject*)obj(); } - operator markOop () const { return markOop(obj()); } + operator markOop () const volatile { return markOop(obj()); } operator address () const { return (address)obj(); } // from javaCalls.cpp diff --git a/hotspot/src/share/vm/opto/callGenerator.cpp b/hotspot/src/share/vm/opto/callGenerator.cpp index 73282119981..246446167ca 100644 --- a/hotspot/src/share/vm/opto/callGenerator.cpp +++ b/hotspot/src/share/vm/opto/callGenerator.cpp @@ -871,8 +871,11 @@ CallGenerator* CallGenerator::for_method_handle_inline(JVMState* jvms, ciMethod* Node* receiver_node = kit.argument(0); const TypeOopPtr* receiver_type = gvn.type(receiver_node)->isa_oopptr(); // call_does_dispatch and vtable_index are out-parameters. They might be changed. - target = C->optimize_virtual_call(caller, jvms->bci(), klass, target, receiver_type, - is_virtual, + // optimize_virtual_call() takes 2 different holder + // arguments for a corner case that doesn't apply here (see + // Parse::do_call()) + target = C->optimize_virtual_call(caller, jvms->bci(), klass, klass, + target, receiver_type, is_virtual, call_does_dispatch, vtable_index); // out-parameters // We lack profiling at this call but type speculation may // provide us with a type diff --git a/hotspot/src/share/vm/opto/compile.cpp b/hotspot/src/share/vm/opto/compile.cpp index 86f566c5877..585f9315241 100644 --- a/hotspot/src/share/vm/opto/compile.cpp +++ b/hotspot/src/share/vm/opto/compile.cpp @@ -29,6 +29,7 @@ #include "classfile/systemDictionary.hpp" #include "code/exceptionHandlerTable.hpp" #include "code/nmethod.hpp" +#include "compiler/compileBroker.hpp" #include "compiler/compileLog.hpp" #include "compiler/disassembler.hpp" #include "compiler/oopMap.hpp" @@ -534,6 +535,7 @@ void Compile::init_scratch_buffer_blob(int const_size) { if (scratch_buffer_blob() == NULL) { // Let CompilerBroker disable further compilations. record_failure("Not enough space for scratch buffer in CodeCache"); + CompileBroker::handle_full_code_cache(); return; } } diff --git a/hotspot/src/share/vm/opto/compile.hpp b/hotspot/src/share/vm/opto/compile.hpp index 7d7dd653aaa..29380e1f898 100644 --- a/hotspot/src/share/vm/opto/compile.hpp +++ b/hotspot/src/share/vm/opto/compile.hpp @@ -852,8 +852,8 @@ class Compile : public Phase { // Helper functions to identify inlining potential at call-site ciMethod* optimize_virtual_call(ciMethod* caller, int bci, ciInstanceKlass* klass, - ciMethod* callee, const TypeOopPtr* receiver_type, - bool is_virtual, + ciKlass* holder, ciMethod* callee, + const TypeOopPtr* receiver_type, bool is_virtual, bool &call_does_dispatch, int &vtable_index); ciMethod* optimize_inlining(ciMethod* caller, int bci, ciInstanceKlass* klass, ciMethod* callee, const TypeOopPtr* receiver_type); diff --git a/hotspot/src/share/vm/opto/doCall.cpp b/hotspot/src/share/vm/opto/doCall.cpp index 72dc6b8a79c..62eb88460f1 100644 --- a/hotspot/src/share/vm/opto/doCall.cpp +++ b/hotspot/src/share/vm/opto/doCall.cpp @@ -468,8 +468,14 @@ void Parse::do_call() { Node* receiver_node = stack(sp() - nargs); const TypeOopPtr* receiver_type = _gvn.type(receiver_node)->isa_oopptr(); // call_does_dispatch and vtable_index are out-parameters. They might be changed. - callee = C->optimize_virtual_call(method(), bci(), klass, orig_callee, receiver_type, - is_virtual, + // For arrays, klass below is Object. When vtable calls are used, + // resolving the call with Object would allow an illegal call to + // finalize() on an array. We use holder instead: illegal calls to + // finalize() won't be compiled as vtable calls (IC call + // resolution will catch the illegal call) and the few legal calls + // on array types won't be either. + callee = C->optimize_virtual_call(method(), bci(), klass, holder, orig_callee, + receiver_type, is_virtual, call_does_dispatch, vtable_index); // out-parameters speculative_receiver_type = receiver_type != NULL ? receiver_type->speculative_type() : NULL; } @@ -940,8 +946,8 @@ void Parse::count_compiled_calls(bool at_method_entry, bool is_inline) { ciMethod* Compile::optimize_virtual_call(ciMethod* caller, int bci, ciInstanceKlass* klass, - ciMethod* callee, const TypeOopPtr* receiver_type, - bool is_virtual, + ciKlass* holder, ciMethod* callee, + const TypeOopPtr* receiver_type, bool is_virtual, bool& call_does_dispatch, int& vtable_index) { // Set default values for out-parameters. call_does_dispatch = true; @@ -956,7 +962,7 @@ ciMethod* Compile::optimize_virtual_call(ciMethod* caller, int bci, ciInstanceKl call_does_dispatch = false; } else if (!UseInlineCaches && is_virtual && callee->is_loaded()) { // We can make a vtable call at this site - vtable_index = callee->resolve_vtable_index(caller->holder(), klass); + vtable_index = callee->resolve_vtable_index(caller->holder(), holder); } return callee; } @@ -979,8 +985,10 @@ ciMethod* Compile::optimize_inlining(ciMethod* caller, int bci, ciInstanceKlass* ciInstanceKlass* actual_receiver = klass; if (receiver_type != NULL) { // Array methods are all inherited from Object, and are monomorphic. + // finalize() call on array is not allowed. if (receiver_type->isa_aryptr() && - callee->holder() == env()->Object_klass()) { + callee->holder() == env()->Object_klass() && + callee->name() != ciSymbol::finalize_method_name()) { return callee; } diff --git a/hotspot/src/share/vm/opto/output.cpp b/hotspot/src/share/vm/opto/output.cpp index d6768a7fdf8..dac317cad9b 100644 --- a/hotspot/src/share/vm/opto/output.cpp +++ b/hotspot/src/share/vm/opto/output.cpp @@ -1165,6 +1165,7 @@ CodeBuffer* Compile::init_buffer(uint* blk_starts) { // Have we run out of code space? if ((cb->blob() == NULL) || (!CompileBroker::should_compile_new_jobs())) { C->record_failure("CodeCache is full"); + CompileBroker::handle_full_code_cache(); return NULL; } // Configure the code buffer. @@ -1489,6 +1490,7 @@ void Compile::fill_buffer(CodeBuffer* cb, uint* blk_starts) { cb->insts()->maybe_expand_to_ensure_remaining(MAX_inst_size); if ((cb->blob() == NULL) || (!CompileBroker::should_compile_new_jobs())) { C->record_failure("CodeCache is full"); + CompileBroker::handle_full_code_cache(); return; } @@ -1645,6 +1647,7 @@ void Compile::fill_buffer(CodeBuffer* cb, uint* blk_starts) { // One last check for failed CodeBuffer::expand: if ((cb->blob() == NULL) || (!CompileBroker::should_compile_new_jobs())) { C->record_failure("CodeCache is full"); + CompileBroker::handle_full_code_cache(); return; } diff --git a/hotspot/src/share/vm/opto/parse.hpp b/hotspot/src/share/vm/opto/parse.hpp index fe941c07298..34c4eb4b045 100644 --- a/hotspot/src/share/vm/opto/parse.hpp +++ b/hotspot/src/share/vm/opto/parse.hpp @@ -557,8 +557,9 @@ class Parse : public GraphKit { float dynamic_branch_prediction(float &cnt); float branch_prediction(float &cnt, BoolTest::mask btest, int target_bci); - bool seems_never_taken(float prob); - bool seems_stable_comparison(BoolTest::mask btest, Node* c); + bool seems_never_taken(float prob) const; + bool path_is_suitable_for_uncommon_trap(float prob) const; + bool seems_stable_comparison() const; void do_ifnull(BoolTest::mask btest, Node* c); void do_if(BoolTest::mask btest, Node* c); diff --git a/hotspot/src/share/vm/opto/parse2.cpp b/hotspot/src/share/vm/opto/parse2.cpp index 15826863ee5..7ed28ea1d45 100644 --- a/hotspot/src/share/vm/opto/parse2.cpp +++ b/hotspot/src/share/vm/opto/parse2.cpp @@ -886,7 +886,7 @@ float Parse::branch_prediction(float& cnt, // some branches (e.g., _213_javac.Assembler.eliminate) validly produce // very small but nonzero probabilities, which if confused with zero // counts would keep the program recompiling indefinitely. -bool Parse::seems_never_taken(float prob) { +bool Parse::seems_never_taken(float prob) const { return prob < PROB_MIN; } @@ -898,7 +898,7 @@ bool Parse::seems_never_taken(float prob) { // already acting in a stable fashion. If the comparison // seems stable, we will put an expensive uncommon trap // on the untaken path. -bool Parse::seems_stable_comparison(BoolTest::mask btest, Node* cmp) { +bool Parse::seems_stable_comparison() const { if (C->too_many_traps(method(), bci(), Deoptimization::Reason_unstable_if)) { return false; } @@ -1127,6 +1127,14 @@ void Parse::do_if(BoolTest::mask btest, Node* c) { } } +bool Parse::path_is_suitable_for_uncommon_trap(float prob) const { + // Don't want to speculate on uncommon traps when running with -Xcomp + if (!UseInterpreter) { + return false; + } + return (seems_never_taken(prob) && seems_stable_comparison()); +} + //----------------------------adjust_map_after_if------------------------------ // Adjust the JVM state to reflect the result of taking this path. // Basically, it means inspecting the CmpNode controlling this @@ -1140,7 +1148,7 @@ void Parse::adjust_map_after_if(BoolTest::mask btest, Node* c, float prob, bool is_fallthrough = (path == successor_for_bci(iter().next_bci())); - if (seems_never_taken(prob) && seems_stable_comparison(btest, c)) { + if (path_is_suitable_for_uncommon_trap(prob)) { repush_if_args(); uncommon_trap(Deoptimization::Reason_unstable_if, Deoptimization::Action_reinterpret, diff --git a/hotspot/src/share/vm/prims/jni.cpp b/hotspot/src/share/vm/prims/jni.cpp index 135a6318e7c..b1b38c948cc 100644 --- a/hotspot/src/share/vm/prims/jni.cpp +++ b/hotspot/src/share/vm/prims/jni.cpp @@ -247,15 +247,6 @@ void jfieldIDWorkaround::verify_instance_jfieldID(Klass* k, jfieldID id) { "Bug in native code: jfieldID offset must address interior of object"); } -// Pick a reasonable higher bound for local capacity requested -// for EnsureLocalCapacity and PushLocalFrame. We don't want it too -// high because a test (or very unusual application) may try to allocate -// that many handles and run out of swap space. An implementation is -// permitted to allocate more handles than the ensured capacity, so this -// value is set high enough to prevent compatibility problems. -const int MAX_REASONABLE_LOCAL_CAPACITY = 4*K; - - // Wrapper to trace JNI functions #ifdef ASSERT @@ -741,7 +732,8 @@ JNI_ENTRY(jint, jni_PushLocalFrame(JNIEnv *env, jint capacity)) HOTSPOT_JNI_PUSHLOCALFRAME_ENTRY(env, capacity); //%note jni_11 - if (capacity < 0 || capacity > MAX_REASONABLE_LOCAL_CAPACITY) { + if (capacity < 0 || + ((MaxJNILocalCapacity > 0) && (capacity > MaxJNILocalCapacity))) { HOTSPOT_JNI_PUSHLOCALFRAME_RETURN((uint32_t)JNI_ERR); return JNI_ERR; } @@ -844,7 +836,8 @@ JNI_LEAF(jint, jni_EnsureLocalCapacity(JNIEnv *env, jint capacity)) HOTSPOT_JNI_ENSURELOCALCAPACITY_ENTRY(env, capacity); jint ret; - if (capacity >= 0 && capacity <= MAX_REASONABLE_LOCAL_CAPACITY) { + if (capacity >= 0 && + ((MaxJNILocalCapacity <= 0) || (capacity <= MaxJNILocalCapacity))) { ret = JNI_OK; } else { ret = JNI_ERR; @@ -3325,7 +3318,7 @@ static bool initializeDirectBufferSupport(JNIEnv* env, JavaThread* thread) { directBufferSupportInitializeEnded = 1; } else { while (!directBufferSupportInitializeEnded && !directBufferSupportInitializeFailed) { - os::yield(); + os::naked_yield(); } } diff --git a/hotspot/src/share/vm/prims/jniCheck.cpp b/hotspot/src/share/vm/prims/jniCheck.cpp index 73a2965004e..1de4f021017 100644 --- a/hotspot/src/share/vm/prims/jniCheck.cpp +++ b/hotspot/src/share/vm/prims/jniCheck.cpp @@ -170,6 +170,9 @@ static void NativeReportJNIWarning(JavaThread* thr, const char *msg) { * throw an ArrayIndexOutOfBoundsException or ArrayStoreException. * * In all other cases, a non-error return value guarantees that no exceptions have been thrown. + * + * Programmers often defend against ArrayIndexOutOfBoundsException, so warning + * for these functions would be pedantic. */ static inline void check_pending_exception(JavaThread* thr) { @@ -186,6 +189,16 @@ check_pending_exception(JavaThread* thr) { } } +/** + * Add to the planned number of handles. I.e. plus current live & warning threshold + */ +static inline void +add_planned_handle_capacity(JNIHandleBlock* handles, size_t capacity) { + handles->set_planned_capacity(capacity + + handles->get_number_of_live_handles() + + CHECK_JNI_LOCAL_REF_CAP_WARN_THRESHOLD); +} + static inline void functionEnterCritical(JavaThread* thr) @@ -228,7 +241,7 @@ functionExit(JavaThread* thr) thr->print_stack(); ) // Complain just the once, reset to current + warn threshold - handles->set_planned_capacity(live_handles + CHECK_JNI_LOCAL_REF_CAP_WARN_THRESHOLD); + add_planned_handle_capacity(handles, 0); } } @@ -705,7 +718,7 @@ JNI_ENTRY_CHECKED(jint, NativeReportJNIFatalError(thr, "negative capacity"); jint result = UNCHECKED()->PushLocalFrame(env, capacity); if (result == JNI_OK) { - thr->active_handles()->set_planned_capacity(capacity + CHECK_JNI_LOCAL_REF_CAP_WARN_THRESHOLD); + add_planned_handle_capacity(thr->active_handles(), capacity); } functionExit(thr); return result; @@ -809,7 +822,7 @@ JNI_ENTRY_CHECKED(jint, } jint result = UNCHECKED()->EnsureLocalCapacity(env, capacity); if (result == JNI_OK) { - thr->active_handles()->set_planned_capacity(capacity + CHECK_JNI_LOCAL_REF_CAP_WARN_THRESHOLD); + add_planned_handle_capacity(thr->active_handles(), capacity); } functionExit(thr); return result; @@ -1613,7 +1626,6 @@ JNI_ENTRY_CHECKED(jobject, check_is_obj_array(thr, array); ) jobject result = UNCHECKED()->GetObjectArrayElement(env,array,index); - thr->set_pending_jni_exception_check("GetObjectArrayElement"); functionExit(thr); return result; JNI_END @@ -1628,7 +1640,6 @@ JNI_ENTRY_CHECKED(void, check_is_obj_array(thr, array); ) UNCHECKED()->SetObjectArrayElement(env,array,index,val); - thr->set_pending_jni_exception_check("SetObjectArrayElement"); functionExit(thr); JNI_END @@ -1718,7 +1729,6 @@ JNI_ENTRY_CHECKED(void, \ check_primitive_array_type(thr, array, ElementTag); \ ) \ UNCHECKED()->Get##Result##ArrayRegion(env,array,start,len,buf); \ - thr->set_pending_jni_exception_check("Get"#Result"ArrayRegion"); \ functionExit(thr); \ JNI_END @@ -1743,7 +1753,6 @@ JNI_ENTRY_CHECKED(void, \ check_primitive_array_type(thr, array, ElementTag); \ ) \ UNCHECKED()->Set##Result##ArrayRegion(env,array,start,len,buf); \ - thr->set_pending_jni_exception_check("Set"#Result"ArrayRegion"); \ functionExit(thr); \ JNI_END @@ -1820,7 +1829,6 @@ JNI_ENTRY_CHECKED(void, checkString(thr, str); ) UNCHECKED()->GetStringRegion(env, str, start, len, buf); - thr->set_pending_jni_exception_check("GetStringRegion"); functionExit(thr); JNI_END @@ -1835,7 +1843,6 @@ JNI_ENTRY_CHECKED(void, checkString(thr, str); ) UNCHECKED()->GetStringUTFRegion(env, str, start, len, buf); - thr->set_pending_jni_exception_check("GetStringUTFRegion"); functionExit(thr); JNI_END diff --git a/hotspot/src/share/vm/prims/jvm.cpp b/hotspot/src/share/vm/prims/jvm.cpp index 6e03e784952..1970d715ebc 100644 --- a/hotspot/src/share/vm/prims/jvm.cpp +++ b/hotspot/src/share/vm/prims/jvm.cpp @@ -3043,7 +3043,7 @@ JVM_ENTRY(void, JVM_Yield(JNIEnv *env, jclass threadClass)) if (ConvertYieldToSleep) { os::sleep(thread, MinSleepInterval, false); } else { - os::yield(); + os::naked_yield(); } JVM_END @@ -3073,7 +3073,7 @@ JVM_ENTRY(void, JVM_Sleep(JNIEnv* env, jclass threadClass, jlong millis)) // It appears that in certain GUI contexts, it may be beneficial to do a short sleep // for SOLARIS if (ConvertSleepToYield) { - os::yield(); + os::naked_yield(); } else { ThreadState old_state = thread->osthread()->get_state(); thread->osthread()->set_state(SLEEPING); diff --git a/hotspot/src/share/vm/prims/jvmtiImpl.cpp b/hotspot/src/share/vm/prims/jvmtiImpl.cpp index 328e9d869af..55aec25613e 100644 --- a/hotspot/src/share/vm/prims/jvmtiImpl.cpp +++ b/hotspot/src/share/vm/prims/jvmtiImpl.cpp @@ -25,6 +25,7 @@ #include "precompiled.hpp" #include "classfile/systemDictionary.hpp" #include "interpreter/interpreter.hpp" +#include "interpreter/oopMapCache.hpp" #include "jvmtifiles/jvmtiEnv.hpp" #include "memory/resourceArea.hpp" #include "oops/instanceKlass.hpp" @@ -744,6 +745,13 @@ bool VM_GetOrSetLocal::doit_prologue() { } void VM_GetOrSetLocal::doit() { + InterpreterOopMap oop_mask; + _jvf->method()->mask_for(_jvf->bci(), &oop_mask); + if (oop_mask.is_dead(_index)) { + // The local can be invalid and uninitialized in the scope of current bci + _result = JVMTI_ERROR_INVALID_SLOT; + return; + } if (_set) { // Force deoptimization of frame if compiled because it's // possible the compiler emitted some locals as constant values, diff --git a/hotspot/src/share/vm/prims/jvmtiTagMap.cpp b/hotspot/src/share/vm/prims/jvmtiTagMap.cpp index 70e9a98e30a..89680d13ea6 100644 --- a/hotspot/src/share/vm/prims/jvmtiTagMap.cpp +++ b/hotspot/src/share/vm/prims/jvmtiTagMap.cpp @@ -3020,7 +3020,7 @@ inline bool VM_HeapWalkOperation::collect_simple_roots() { // If there are any non-perm roots in the code cache, visit them. blk.set_kind(JVMTI_HEAP_REFERENCE_OTHER); - CodeBlobToOopClosure look_in_blobs(&blk, false); + CodeBlobToOopClosure look_in_blobs(&blk, !CodeBlobToOopClosure::FixRelocations); CodeCache::scavenge_root_nmethods_do(&look_in_blobs); return true; diff --git a/hotspot/src/share/vm/prims/whitebox.cpp b/hotspot/src/share/vm/prims/whitebox.cpp index 683ac097c3f..e6805b12e5b 100644 --- a/hotspot/src/share/vm/prims/whitebox.cpp +++ b/hotspot/src/share/vm/prims/whitebox.cpp @@ -25,7 +25,7 @@ #include "precompiled.hpp" #include "code/codeCache.hpp" - +#include "memory/metadataFactory.hpp" #include "memory/universe.hpp" #include "oops/oop.inline.hpp" @@ -41,6 +41,7 @@ #include "runtime/os.hpp" #include "runtime/vm_version.hpp" +#include "utilities/array.hpp" #include "utilities/debug.hpp" #include "utilities/macros.hpp" #include "utilities/exceptions.hpp" @@ -729,7 +730,6 @@ WB_ENTRY(jobjectArray, WB_GetNMethod(JNIEnv* env, jobject o, jobject method, jbo return result; WB_END - WB_ENTRY(jlong, WB_GetThreadStackSize(JNIEnv* env, jobject o)) return (jlong) Thread::current()->stack_size(); WB_END @@ -739,6 +739,35 @@ WB_ENTRY(jlong, WB_GetThreadRemainingStackSize(JNIEnv* env, jobject o)) return (jlong) t->stack_available(os::current_stack_pointer()) - (jlong) StackShadowPages * os::vm_page_size(); WB_END +int WhiteBox::array_bytes_to_length(size_t bytes) { + return Array::bytes_to_length(bytes); +} + +WB_ENTRY(jlong, WB_AllocateMetaspace(JNIEnv* env, jobject wb, jobject class_loader, jlong size)) + if (size < 0) { + THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), + err_msg("WB_AllocateMetaspace: size is negative: " JLONG_FORMAT, size)); + } + + oop class_loader_oop = JNIHandles::resolve(class_loader); + ClassLoaderData* cld = class_loader_oop != NULL + ? java_lang_ClassLoader::loader_data(class_loader_oop) + : ClassLoaderData::the_null_class_loader_data(); + + void* metadata = MetadataFactory::new_writeable_array(cld, WhiteBox::array_bytes_to_length((size_t)size), thread); + + return (jlong)(uintptr_t)metadata; +WB_END + +WB_ENTRY(void, WB_FreeMetaspace(JNIEnv* env, jobject wb, jobject class_loader, jlong addr, jlong size)) + oop class_loader_oop = JNIHandles::resolve(class_loader); + ClassLoaderData* cld = class_loader_oop != NULL + ? java_lang_ClassLoader::loader_data(class_loader_oop) + : ClassLoaderData::the_null_class_loader_data(); + + MetadataFactory::free_array(cld, (Array*)(uintptr_t)addr); +WB_END + //Some convenience methods to deal with objects from java int WhiteBox::offset_for_field(const char* field_name, oop object, Symbol* signature_symbol) { @@ -869,6 +898,10 @@ static JNINativeMethod methods[] = { {CC"isInStringTable", CC"(Ljava/lang/String;)Z", (void*)&WB_IsInStringTable }, {CC"fullGC", CC"()V", (void*)&WB_FullGC }, {CC"readReservedMemory", CC"()V", (void*)&WB_ReadReservedMemory }, + {CC"allocateMetaspace", + CC"(Ljava/lang/ClassLoader;J)J", (void*)&WB_AllocateMetaspace }, + {CC"freeMetaspace", + CC"(Ljava/lang/ClassLoader;JJ)V", (void*)&WB_FreeMetaspace }, {CC"getCPUFeatures", CC"()Ljava/lang/String;", (void*)&WB_GetCPUFeatures }, {CC"getNMethod", CC"(Ljava/lang/reflect/Executable;Z)[Ljava/lang/Object;", (void*)&WB_GetNMethod }, diff --git a/hotspot/src/share/vm/prims/whitebox.hpp b/hotspot/src/share/vm/prims/whitebox.hpp index a9854f3ffea..9ab406fc672 100644 --- a/hotspot/src/share/vm/prims/whitebox.hpp +++ b/hotspot/src/share/vm/prims/whitebox.hpp @@ -62,6 +62,8 @@ class WhiteBox : public AllStatic { Symbol* signature_symbol); static const char* lookup_jstring(const char* field_name, oop object); static bool lookup_bool(const char* field_name, oop object); + + static int array_bytes_to_length(size_t bytes); }; diff --git a/hotspot/src/share/vm/runtime/atomic.hpp b/hotspot/src/share/vm/runtime/atomic.hpp index b2b56171362..52e122fce48 100644 --- a/hotspot/src/share/vm/runtime/atomic.hpp +++ b/hotspot/src/share/vm/runtime/atomic.hpp @@ -35,6 +35,18 @@ class Atomic : AllStatic { // can provide an alternative action if not - see supports_cx8() for // a means to test availability. + // The memory operations that are mentioned with each of the atomic + // function families come from src/share/vm/runtime/orderAccess.hpp, + // e.g., is described in that file and is implemented by the + // OrderAccess::fence() function. See that file for the gory details + // on the Memory Access Ordering Model. + + // All of the atomic operations that imply a read-modify-write action + // guarantee a two-way memory barrier across that operation. Historically + // these semantics reflect the strength of atomic operations that are + // provided on SPARC/X86. We assume that strength is necessary unless + // we can prove that a weaker form is sufficiently safe. + // Atomically store to a location inline static void store (jbyte store_value, jbyte* dest); inline static void store (jshort store_value, jshort* dest); @@ -55,7 +67,8 @@ class Atomic : AllStatic { // See comment above about using jlong atomics on 32-bit platforms inline static jlong load(volatile jlong* src); - // Atomically add to a location, return updated value + // Atomically add to a location. Returns updated value. add*() provide: + // add-value-to-dest inline static jint add (jint add_value, volatile jint* dest); inline static size_t add (size_t add_value, volatile size_t* dest); inline static intptr_t add_ptr(intptr_t add_value, volatile intptr_t* dest); @@ -63,30 +76,35 @@ class Atomic : AllStatic { // See comment above about using jlong atomics on 32-bit platforms static jlong add (jlong add_value, volatile jlong* dest); - // Atomically increment location + // Atomically increment location. inc*() provide: + // increment-dest inline static void inc (volatile jint* dest); static void inc (volatile jshort* dest); inline static void inc (volatile size_t* dest); inline static void inc_ptr(volatile intptr_t* dest); inline static void inc_ptr(volatile void* dest); - // Atomically decrement a location + // Atomically decrement a location. dec*() provide: + // decrement-dest inline static void dec (volatile jint* dest); static void dec (volatile jshort* dest); inline static void dec (volatile size_t* dest); inline static void dec_ptr(volatile intptr_t* dest); inline static void dec_ptr(volatile void* dest); - // Performs atomic exchange of *dest with exchange_value. Returns old prior value of *dest. + // Performs atomic exchange of *dest with exchange_value. Returns old + // prior value of *dest. xchg*() provide: + // exchange-value-with-dest inline static jint xchg(jint exchange_value, volatile jint* dest); static unsigned int xchg(unsigned int exchange_value, volatile unsigned int* dest); inline static intptr_t xchg_ptr(intptr_t exchange_value, volatile intptr_t* dest); inline static void* xchg_ptr(void* exchange_value, volatile void* dest); - // Performs atomic compare of *dest and compare_value, and exchanges *dest with exchange_value - // if the comparison succeeded. Returns prior value of *dest. Guarantees a two-way memory - // barrier across the cmpxchg. I.e., it's really a 'fence_cmpxchg_acquire'. + // Performs atomic compare of *dest and compare_value, and exchanges + // *dest with exchange_value if the comparison succeeded. Returns prior + // value of *dest. cmpxchg*() provide: + // compare-and-exchange static jbyte cmpxchg (jbyte exchange_value, volatile jbyte* dest, jbyte compare_value); inline static jint cmpxchg (jint exchange_value, volatile jint* dest, jint compare_value); // See comment above about using jlong atomics on 32-bit platforms diff --git a/hotspot/src/share/vm/runtime/globals.hpp b/hotspot/src/share/vm/runtime/globals.hpp index 56cafb65600..2d1805e2fb6 100644 --- a/hotspot/src/share/vm/runtime/globals.hpp +++ b/hotspot/src/share/vm/runtime/globals.hpp @@ -1130,29 +1130,30 @@ class CommandLineFlags { "Use LWP-based instead of libthread-based synchronization " \ "(SPARC only)") \ \ - product(ccstr, SyncKnobs, NULL, \ - "(Unstable) Various monitor synchronization tunables") \ + experimental(ccstr, SyncKnobs, NULL, \ + "(Unstable) Various monitor synchronization tunables") \ \ - product(intx, EmitSync, 0, \ - "(Unsafe, Unstable) " \ - "Control emission of inline sync fast-path code") \ + experimental(intx, EmitSync, 0, \ + "(Unsafe, Unstable) " \ + "Control emission of inline sync fast-path code") \ \ product(intx, MonitorBound, 0, "Bound Monitor population") \ \ product(bool, MonitorInUseLists, false, "Track Monitors for Deflation") \ \ - product(intx, SyncFlags, 0, "(Unsafe, Unstable) Experimental Sync flags") \ + experimental(intx, SyncFlags, 0, "(Unsafe, Unstable) " \ + "Experimental Sync flags") \ \ - product(intx, SyncVerbose, 0, "(Unstable)") \ + experimental(intx, SyncVerbose, 0, "(Unstable)") \ \ - product(intx, ClearFPUAtPark, 0, "(Unsafe, Unstable)") \ + experimental(intx, ClearFPUAtPark, 0, "(Unsafe, Unstable)") \ \ - product(intx, hashCode, 5, \ - "(Unstable) select hashCode generation algorithm") \ + experimental(intx, hashCode, 5, \ + "(Unstable) select hashCode generation algorithm") \ \ - product(intx, WorkAroundNPTLTimedWaitHang, 1, \ - "(Unstable, Linux-specific) " \ - "avoid NPTL-FUTEX hang pthread_cond_timedwait") \ + experimental(intx, WorkAroundNPTLTimedWaitHang, 1, \ + "(Unstable, Linux-specific) " \ + "avoid NPTL-FUTEX hang pthread_cond_timedwait") \ \ product(bool, FilterSpuriousWakeups, true, \ "When true prevents OS-level spurious, or premature, wakeups " \ @@ -1215,6 +1216,11 @@ class CommandLineFlags { product(bool, UseFastJNIAccessors, true, \ "Use optimized versions of GetField") \ \ + product(intx, MaxJNILocalCapacity, 65536, \ + "Maximum allowable local JNI handle capacity to " \ + "EnsureLocalCapacity() and PushLocalFrame(), " \ + "where <= 0 is unlimited, default: 65536") \ + \ product(bool, EagerXrunInit, false, \ "Eagerly initialize -Xrun libraries; allows startup profiling, " \ "but not all -Xrun libraries may support the state of the VM " \ diff --git a/hotspot/src/share/vm/runtime/icache.cpp b/hotspot/src/share/vm/runtime/icache.cpp index 02ac795b372..02f36d54d6c 100644 --- a/hotspot/src/share/vm/runtime/icache.cpp +++ b/hotspot/src/share/vm/runtime/icache.cpp @@ -34,6 +34,9 @@ void AbstractICache::initialize() { ResourceMark rm; BufferBlob* b = BufferBlob::create("flush_icache_stub", ICache::stub_size); + if (b == NULL) { + vm_exit_out_of_memory(ICache::stub_size, OOM_MALLOC_ERROR, "CodeCache: no space for flush_icache_stub"); + } CodeBuffer c(b); ICacheStubGenerator g(&c); diff --git a/hotspot/src/share/vm/runtime/mutex.cpp b/hotspot/src/share/vm/runtime/mutex.cpp index f903c00291c..aa10bfbc761 100644 --- a/hotspot/src/share/vm/runtime/mutex.cpp +++ b/hotspot/src/share/vm/runtime/mutex.cpp @@ -1,4 +1,3 @@ - /* * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -488,7 +487,6 @@ void Monitor::ILock (Thread * Self) { for (;;) { assert(_OnDeck == ESelf, "invariant"); if (TrySpin(Self)) break; - // CONSIDER: if ESelf->TryPark() && TryLock() break ... // It's probably wise to spin only if we *actually* blocked // CONSIDER: check the lockbyte, if it remains set then // preemptively drain the cxq into the EntryList. diff --git a/hotspot/src/share/vm/runtime/objectMonitor.cpp b/hotspot/src/share/vm/runtime/objectMonitor.cpp index 9480de55e3d..d763a84e07b 100644 --- a/hotspot/src/share/vm/runtime/objectMonitor.cpp +++ b/hotspot/src/share/vm/runtime/objectMonitor.cpp @@ -46,9 +46,9 @@ #if defined(__GNUC__) && !defined(IA64) && !defined(PPC64) // Need to inhibit inlining for older versions of GCC to avoid build-time failures - #define ATTR __attribute__((noinline)) + #define NOINLINE __attribute__((noinline)) #else - #define ATTR + #define NOINLINE #endif @@ -103,38 +103,39 @@ // The knob* variables are effectively final. Once set they should // never be modified hence. Consider using __read_mostly with GCC. -int ObjectMonitor::Knob_Verbose = 0; -int ObjectMonitor::Knob_SpinLimit = 5000; // derived by an external tool - -static int Knob_LogSpins = 0; // enable jvmstat tally for spins -static int Knob_HandOff = 0; -static int Knob_ReportSettings = 0; +int ObjectMonitor::Knob_Verbose = 0; +int ObjectMonitor::Knob_VerifyInUse = 0; +int ObjectMonitor::Knob_SpinLimit = 5000; // derived by an external tool - +static int Knob_LogSpins = 0; // enable jvmstat tally for spins +static int Knob_HandOff = 0; +static int Knob_ReportSettings = 0; -static int Knob_SpinBase = 0; // Floor AKA SpinMin -static int Knob_SpinBackOff = 0; // spin-loop backoff -static int Knob_CASPenalty = -1; // Penalty for failed CAS -static int Knob_OXPenalty = -1; // Penalty for observed _owner change -static int Knob_SpinSetSucc = 1; // spinners set the _succ field -static int Knob_SpinEarly = 1; -static int Knob_SuccEnabled = 1; // futile wake throttling -static int Knob_SuccRestrict = 0; // Limit successors + spinners to at-most-one -static int Knob_MaxSpinners = -1; // Should be a function of # CPUs -static int Knob_Bonus = 100; // spin success bonus -static int Knob_BonusB = 100; // spin success bonus -static int Knob_Penalty = 200; // spin failure penalty -static int Knob_Poverty = 1000; -static int Knob_SpinAfterFutile = 1; // Spin after returning from park() -static int Knob_FixedSpin = 0; -static int Knob_OState = 3; // Spinner checks thread state of _owner -static int Knob_UsePause = 1; -static int Knob_ExitPolicy = 0; -static int Knob_PreSpin = 10; // 20-100 likely better -static int Knob_ResetEvent = 0; -static int BackOffMask = 0; +static int Knob_SpinBase = 0; // Floor AKA SpinMin +static int Knob_SpinBackOff = 0; // spin-loop backoff +static int Knob_CASPenalty = -1; // Penalty for failed CAS +static int Knob_OXPenalty = -1; // Penalty for observed _owner change +static int Knob_SpinSetSucc = 1; // spinners set the _succ field +static int Knob_SpinEarly = 1; +static int Knob_SuccEnabled = 1; // futile wake throttling +static int Knob_SuccRestrict = 0; // Limit successors + spinners to at-most-one +static int Knob_MaxSpinners = -1; // Should be a function of # CPUs +static int Knob_Bonus = 100; // spin success bonus +static int Knob_BonusB = 100; // spin success bonus +static int Knob_Penalty = 200; // spin failure penalty +static int Knob_Poverty = 1000; +static int Knob_SpinAfterFutile = 1; // Spin after returning from park() +static int Knob_FixedSpin = 0; +static int Knob_OState = 3; // Spinner checks thread state of _owner +static int Knob_UsePause = 1; +static int Knob_ExitPolicy = 0; +static int Knob_PreSpin = 10; // 20-100 likely better +static int Knob_ResetEvent = 0; +static int BackOffMask = 0; -static int Knob_FastHSSEC = 0; -static int Knob_MoveNotifyee = 2; // notify() - disposition of notifyee -static int Knob_QMode = 0; // EntryList-cxq policy - queue discipline -static volatile int InitDone = 0; +static int Knob_FastHSSEC = 0; +static int Knob_MoveNotifyee = 2; // notify() - disposition of notifyee +static int Knob_QMode = 0; // EntryList-cxq policy - queue discipline +static volatile int InitDone = 0; #define TrySpin TrySpin_VaryDuration @@ -199,7 +200,7 @@ static volatile int InitDone = 0; // on EntryList|cxq. That is, spinning relieves contention on the "inner" // locks and monitor metadata. // -// Cxq points to the the set of Recently Arrived Threads attempting entry. +// Cxq points to the set of Recently Arrived Threads attempting entry. // Because we push threads onto _cxq with CAS, the RATs must take the form of // a singly-linked LIFO. We drain _cxq into EntryList at unlock-time when // the unlocking thread notices that EntryList is null but _cxq is != null. @@ -269,13 +270,12 @@ bool ObjectMonitor::try_enter(Thread* THREAD) { } } -void ATTR ObjectMonitor::enter(TRAPS) { +void NOINLINE ObjectMonitor::enter(TRAPS) { // The following code is ordered to check the most common cases first // and to reduce RTS->RTO cache line upgrades on SPARC and IA32 processors. Thread * const Self = THREAD; - void * cur; - cur = Atomic::cmpxchg_ptr(Self, &_owner, NULL); + void * cur = Atomic::cmpxchg_ptr (Self, &_owner, NULL); if (cur == NULL) { // Either ASSERT _recursions == 0 or explicitly set _recursions = 0. assert(_recursions == 0 , "invariant"); @@ -435,26 +435,24 @@ void ATTR ObjectMonitor::enter(TRAPS) { // Callers must compensate as needed. int ObjectMonitor::TryLock (Thread * Self) { - for (;;) { - void * own = _owner; - if (own != NULL) return 0; - if (Atomic::cmpxchg_ptr (Self, &_owner, NULL) == NULL) { - // Either guarantee _recursions == 0 or set _recursions = 0. - assert(_recursions == 0, "invariant"); - assert(_owner == Self, "invariant"); - // CONSIDER: set or assert that OwnerIsThread == 1 - return 1; - } - // The lock had been free momentarily, but we lost the race to the lock. - // Interference -- the CAS failed. - // We can either return -1 or retry. - // Retry doesn't make as much sense because the lock was just acquired. - if (true) return -1; - } + void * own = _owner; + if (own != NULL) return 0; + if (Atomic::cmpxchg_ptr (Self, &_owner, NULL) == NULL) { + // Either guarantee _recursions == 0 or set _recursions = 0. + assert(_recursions == 0, "invariant"); + assert(_owner == Self, "invariant"); + // CONSIDER: set or assert that OwnerIsThread == 1 + return 1; + } + // The lock had been free momentarily, but we lost the race to the lock. + // Interference -- the CAS failed. + // We can either return -1 or retry. + // Retry doesn't make as much sense because the lock was just acquired. + return -1; } -void ATTR ObjectMonitor::EnterI (TRAPS) { - Thread * Self = THREAD; +void NOINLINE ObjectMonitor::EnterI (TRAPS) { + Thread * const Self = THREAD; assert(Self->is_Java_thread(), "invariant"); assert(((JavaThread *) Self)->thread_state() == _thread_blocked , "invariant"); @@ -550,7 +548,7 @@ void ATTR ObjectMonitor::EnterI (TRAPS) { Atomic::cmpxchg_ptr(Self, &_Responsible, NULL); } - // The lock have been released while this thread was occupied queueing + // The lock might have been released while this thread was occupied queueing // itself onto _cxq. To close the race and avoid "stranding" and // progress-liveness failure we must resample-retry _owner before parking. // Note the Dekker/Lamport duality: ST cxq; MEMBAR; LD Owner. @@ -702,7 +700,7 @@ void ATTR ObjectMonitor::EnterI (TRAPS) { // Knob_Reset and Knob_SpinAfterFutile support and restructuring the // loop accordingly. -void ATTR ObjectMonitor::ReenterI (Thread * Self, ObjectWaiter * SelfNode) { +void NOINLINE ObjectMonitor::ReenterI (Thread * Self, ObjectWaiter * SelfNode) { assert(Self != NULL , "invariant"); assert(SelfNode != NULL , "invariant"); assert(SelfNode->_thread == Self , "invariant"); @@ -790,6 +788,7 @@ void ATTR ObjectMonitor::ReenterI (Thread * Self, ObjectWaiter * SelfNode) { OrderAccess::fence(); // see comments at the end of EnterI() } +// By convention we unlink a contending thread from EntryList|cxq immediately // after the thread acquires the lock in ::enter(). Equally, we could defer // unlinking the thread until ::exit()-time. @@ -810,7 +809,7 @@ void ObjectMonitor::UnlinkAfterAcquire (Thread * Self, ObjectWaiter * SelfNode) assert(prv == NULL || prv->TState == ObjectWaiter::TS_ENTER, "invariant"); TEVENT(Unlink from EntryList); } else { - guarantee(SelfNode->TState == ObjectWaiter::TS_CXQ, "invariant"); + assert(SelfNode->TState == ObjectWaiter::TS_CXQ, "invariant"); // Inopportune interleaving -- Self is still on the cxq. // This usually means the enqueue of self raced an exiting thread. // Normally we'll find Self near the front of the cxq, so @@ -850,10 +849,12 @@ void ObjectMonitor::UnlinkAfterAcquire (Thread * Self, ObjectWaiter * SelfNode) TEVENT(Unlink from cxq); } +#ifdef ASSERT // Diagnostic hygiene ... SelfNode->_prev = (ObjectWaiter *) 0xBAD; SelfNode->_next = (ObjectWaiter *) 0xBAD; SelfNode->TState = ObjectWaiter::TS_RUN; +#endif } // ----------------------------------------------------------------------------- @@ -906,9 +907,15 @@ void ObjectMonitor::UnlinkAfterAcquire (Thread * Self, ObjectWaiter * SelfNode) // the integral of the # of active timers at any instant over time). // Both impinge on OS scalability. Given that, at most one thread parked on // a monitor will use a timer. +// +// There is also the risk of a futile wake-up. If we drop the lock +// another thread can reacquire the lock immediately, and we can +// then wake a thread unnecessarily. This is benign, and we've +// structured the code so the windows are short and the frequency +// of such futile wakups is low. -void ATTR ObjectMonitor::exit(bool not_suspended, TRAPS) { - Thread * Self = THREAD; +void NOINLINE ObjectMonitor::exit(bool not_suspended, TRAPS) { + Thread * const Self = THREAD; if (THREAD != _owner) { if (THREAD->is_lock_owned((address) _owner)) { // Transmute _owner from a BasicLock pointer to a Thread address. @@ -920,14 +927,17 @@ void ATTR ObjectMonitor::exit(bool not_suspended, TRAPS) { _recursions = 0; OwnerIsThread = 1; } else { - // NOTE: we need to handle unbalanced monitor enter/exit - // in native code by throwing an exception. - // TODO: Throw an IllegalMonitorStateException ? + // Apparent unbalanced locking ... + // Naively we'd like to throw IllegalMonitorStateException. + // As a practical matter we can neither allocate nor throw an + // exception as ::exit() can be called from leaf routines. + // see x86_32.ad Fast_Unlock() and the I1 and I2 properties. + // Upon deeper reflection, however, in a properly run JVM the only + // way we should encounter this situation is in the presence of + // unbalanced JNI locking. TODO: CheckJNICalls. + // See also: CR4414101 TEVENT(Exit - Throw IMSX); - assert(false, "Non-balanced monitor enter/exit!"); - if (false) { - THROW(vmSymbols::java_lang_IllegalMonitorStateException()); - } + assert(false, "Non-balanced monitor enter/exit! Likely JNI locking"); return; } } @@ -976,6 +986,7 @@ void ATTR ObjectMonitor::exit(bool not_suspended, TRAPS) { return; } TEVENT(Inflated exit - complex egress); + // Other threads are blocked trying to acquire the lock. // Normally the exiting thread is responsible for ensuring succession, // but if other successors are ready or other entering threads are spinning @@ -1142,9 +1153,9 @@ void ATTR ObjectMonitor::exit(bool not_suspended, TRAPS) { if (w != NULL) { // I'd like to write: guarantee (w->_thread != Self). // But in practice an exiting thread may find itself on the EntryList. - // Lets say thread T1 calls O.wait(). Wait() enqueues T1 on O's waitset and + // Let's say thread T1 calls O.wait(). Wait() enqueues T1 on O's waitset and // then calls exit(). Exit release the lock by setting O._owner to NULL. - // Lets say T1 then stalls. T2 acquires O and calls O.notify(). The + // Let's say T1 then stalls. T2 acquires O and calls O.notify(). The // notify() operation moves T1 from O's waitset to O's EntryList. T2 then // release the lock "O". T2 resumes immediately after the ST of null into // _owner, above. T2 notices that the EntryList is populated, so it @@ -1261,10 +1272,13 @@ void ATTR ObjectMonitor::exit(bool not_suspended, TRAPS) { // MEMBAR // LD Self_>_suspend_flags // +// UPDATE 2007-10-6: since I've replaced the native Mutex/Monitor subsystem +// with a more efficient implementation, the need to use "FastHSSEC" has +// decreased. - Dave bool ObjectMonitor::ExitSuspendEquivalent (JavaThread * jSelf) { - int Mode = Knob_FastHSSEC; + const int Mode = Knob_FastHSSEC; if (Mode && !jSelf->is_external_suspend()) { assert(jSelf->is_suspend_equivalent(), "invariant"); jSelf->clear_suspend_equivalent(); @@ -1413,7 +1427,7 @@ void ObjectMonitor::post_monitor_wait_event(EventJavaMonitorWait* event, // Wait/Notify/NotifyAll // // Note: a subset of changes to ObjectMonitor::wait() -// will need to be replicated in complete_exit above +// will need to be replicated in complete_exit void ObjectMonitor::wait(jlong millis, bool interruptible, TRAPS) { Thread * const Self = THREAD; assert(Self->is_Java_thread(), "Must be Java thread!"); @@ -2268,12 +2282,12 @@ ObjectWaiter::ObjectWaiter(Thread* thread) { assert(_event != NULL, "invariant"); } -void ObjectWaiter::wait_reenter_begin(ObjectMonitor *mon) { +void ObjectWaiter::wait_reenter_begin(ObjectMonitor * const mon) { JavaThread *jt = (JavaThread *)this->_thread; _active = JavaThreadBlockedOnMonitorEnterState::wait_reenter_begin(jt, mon); } -void ObjectWaiter::wait_reenter_end(ObjectMonitor *mon) { +void ObjectWaiter::wait_reenter_end(ObjectMonitor * const mon) { JavaThread *jt = (JavaThread *)this->_thread; JavaThreadBlockedOnMonitorEnterState::wait_reenter_end(jt, _active); } @@ -2455,6 +2469,7 @@ void ObjectMonitor::DeferredInitialize() { #define SETKNOB(x) { Knob_##x = kvGetInt (knobs, #x, Knob_##x); } SETKNOB(ReportSettings); SETKNOB(Verbose); + SETKNOB(VerifyInUse); SETKNOB(FixedSpin); SETKNOB(SpinLimit); SETKNOB(SpinBase); diff --git a/hotspot/src/share/vm/runtime/objectMonitor.hpp b/hotspot/src/share/vm/runtime/objectMonitor.hpp index 9feaf7b8a90..c7c6886a2ba 100644 --- a/hotspot/src/share/vm/runtime/objectMonitor.hpp +++ b/hotspot/src/share/vm/runtime/objectMonitor.hpp @@ -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 @@ -311,6 +311,7 @@ public: public: static int Knob_Verbose; + static int Knob_VerifyInUse; static int Knob_SpinLimit; void* operator new (size_t size) throw() { return AllocateHeap(size, mtInternal); diff --git a/hotspot/src/share/vm/runtime/os.hpp b/hotspot/src/share/vm/runtime/os.hpp index 093d16122ee..1624a61b357 100644 --- a/hotspot/src/share/vm/runtime/os.hpp +++ b/hotspot/src/share/vm/runtime/os.hpp @@ -442,16 +442,7 @@ class os: AllStatic { // ms = 0, will sleep for the least amount of time allowed by the OS. static void naked_short_sleep(jlong ms); static void infinite_sleep(); // never returns, use with CAUTION - static void yield(); // Yields to all threads with same priority - enum YieldResult { - YIELD_SWITCHED = 1, // caller descheduled, other ready threads exist & ran - YIELD_NONEREADY = 0, // No other runnable/ready threads. - // platform-specific yield return immediately - YIELD_UNKNOWN = -1 // Unknown: platform doesn't support _SWITCHED or _NONEREADY - // YIELD_SWITCHED and YIELD_NONREADY imply the platform supports a "strong" - // yield that can be used in lieu of blocking. - } ; - static YieldResult NakedYield () ; + static void naked_yield () ; static OSReturn set_priority(Thread* thread, ThreadPriority priority); static OSReturn get_priority(const Thread* const thread, ThreadPriority& priority); diff --git a/hotspot/src/share/vm/runtime/safepoint.cpp b/hotspot/src/share/vm/runtime/safepoint.cpp index 05bb2224a53..4b16f6b04a8 100644 --- a/hotspot/src/share/vm/runtime/safepoint.cpp +++ b/hotspot/src/share/vm/runtime/safepoint.cpp @@ -302,7 +302,7 @@ void SafepointSynchronize::begin() { SpinPause() ; // MP-Polite spin } else if (steps < DeferThrSuspendLoopCount) { - os::NakedYield() ; + os::naked_yield() ; } else { os::naked_short_sleep(1); } diff --git a/hotspot/src/share/vm/runtime/sharedRuntime.cpp b/hotspot/src/share/vm/runtime/sharedRuntime.cpp index 1656cdc1cd5..8ccee76cdb6 100644 --- a/hotspot/src/share/vm/runtime/sharedRuntime.cpp +++ b/hotspot/src/share/vm/runtime/sharedRuntime.cpp @@ -1791,14 +1791,8 @@ JRT_END // Handles the uncommon case in locking, i.e., contention or an inflated lock. -#ifndef PRODUCT -int SharedRuntime::_monitor_enter_ctr=0; -#endif JRT_ENTRY_NO_ASYNC(void, SharedRuntime::complete_monitor_locking_C(oopDesc* _obj, BasicLock* lock, JavaThread* thread)) oop obj(_obj); -#ifndef PRODUCT - _monitor_enter_ctr++; // monitor enter slow -#endif if (PrintBiasedLockingStatistics) { Atomic::inc(BiasedLocking::slow_path_entry_count_addr()); } @@ -1812,15 +1806,9 @@ JRT_ENTRY_NO_ASYNC(void, SharedRuntime::complete_monitor_locking_C(oopDesc* _obj assert(!HAS_PENDING_EXCEPTION, "Should have no exception here"); JRT_END -#ifndef PRODUCT -int SharedRuntime::_monitor_exit_ctr=0; -#endif // Handles the uncommon cases of monitor unlocking in compiled code JRT_LEAF(void, SharedRuntime::complete_monitor_unlocking_C(oopDesc* _obj, BasicLock* lock)) oop obj(_obj); -#ifndef PRODUCT - _monitor_exit_ctr++; // monitor exit slow -#endif Thread* THREAD = JavaThread::current(); // I'm not convinced we need the code contained by MIGHT_HAVE_PENDING anymore // testing was unable to ever fire the assert that guarded it so I have removed it. @@ -1860,8 +1848,6 @@ void SharedRuntime::print_statistics() { ttyLocker ttyl; if (xtty != NULL) xtty->head("statistics type='SharedRuntime'"); - if (_monitor_enter_ctr) tty->print_cr("%5d monitor enter slow", _monitor_enter_ctr); - if (_monitor_exit_ctr) tty->print_cr("%5d monitor exit slow", _monitor_exit_ctr); if (_throw_null_ctr) tty->print_cr("%5d implicit null throw", _throw_null_ctr); SharedRuntime::print_ic_miss_histogram(); @@ -2445,9 +2431,9 @@ AdapterHandlerEntry* AdapterHandlerLibrary::get_adapter(methodHandle method) { if (PrintAdapterHandlers || PrintStubCode) { ttyLocker ttyl; entry->print_adapter_on(tty); - tty->print_cr("i2c argument handler #%d for: %s %s (%d bytes generated)", + tty->print_cr("i2c argument handler #%d for: %s %s %s (%d bytes generated)", _adapters->number_of_entries(), (method->is_static() ? "static" : "receiver"), - method->signature()->as_C_string(), insts_size); + method->signature()->as_C_string(), fingerprint->as_string(), insts_size); tty->print_cr("c2i argument handler starts at %p", entry->get_c2i_entry()); if (Verbose || PrintStubCode) { address first_pc = entry->base_address(); diff --git a/hotspot/src/share/vm/runtime/sharedRuntime.hpp b/hotspot/src/share/vm/runtime/sharedRuntime.hpp index a6d4dfd704d..93fa35d1b2f 100644 --- a/hotspot/src/share/vm/runtime/sharedRuntime.hpp +++ b/hotspot/src/share/vm/runtime/sharedRuntime.hpp @@ -516,8 +516,6 @@ class SharedRuntime: AllStatic { static void trace_ic_miss(address at); public: - static int _monitor_enter_ctr; // monitor enter slow - static int _monitor_exit_ctr; // monitor exit slow static int _throw_null_ctr; // throwing a null-pointer exception static int _ic_miss_ctr; // total # of IC misses static int _wrong_method_ctr; diff --git a/hotspot/src/share/vm/runtime/synchronizer.cpp b/hotspot/src/share/vm/runtime/synchronizer.cpp index b8f0a45f390..fbdda196980 100644 --- a/hotspot/src/share/vm/runtime/synchronizer.cpp +++ b/hotspot/src/share/vm/runtime/synchronizer.cpp @@ -44,9 +44,9 @@ #if defined(__GNUC__) && !defined(PPC64) // Need to inhibit inlining for older versions of GCC to avoid build-time failures - #define ATTR __attribute__((noinline)) + #define NOINLINE __attribute__((noinline)) #else - #define ATTR + #define NOINLINE #endif PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC @@ -206,14 +206,6 @@ void ObjectSynchronizer::slow_enter(Handle obj, BasicLock* lock, TRAPS) { return; } -#if 0 - // The following optimization isn't particularly useful. - if (mark->has_monitor() && mark->monitor()->is_entered(THREAD)) { - lock->set_displaced_header(NULL); - return; - } -#endif - // The object header will never be displaced to this lock, // so it does not matter what the value is, except that it // must be non-zero to avoid looking like a re-entrant lock, @@ -457,7 +449,7 @@ static markOop ReadStableMark (oop obj) { ++its; if (its > 10000 || !os::is_MP()) { if (its & 1) { - os::NakedYield(); + os::naked_yield(); TEVENT(Inflate: INFLATING - yield); } else { // Note that the following code attenuates the livelock problem but is not @@ -487,7 +479,7 @@ static markOop ReadStableMark (oop obj) { if ((YieldThenBlock++) >= 16) { Thread::current()->_ParkEvent->park(1); } else { - os::NakedYield(); + os::naked_yield(); } } Thread::muxRelease(InflationLocks + ix); @@ -573,7 +565,7 @@ intptr_t ObjectSynchronizer::FastHashCode (Thread * Self, oop obj) { // added check of the bias pattern is to avoid useless calls to // thread-local storage. if (obj->mark()->has_bias_pattern()) { - // Box and unbox the raw reference just in case we cause a STW safepoint. + // Handle for oop obj in case of STW safepoint Handle hobj(Self, obj); // Relaxing assertion for bug 6320749. assert(Universe::verify_in_progress() || @@ -890,23 +882,23 @@ static void InduceScavenge (Thread * Self, const char * Whence) { } } } -/* Too slow for general assert or debug + void ObjectSynchronizer::verifyInUse (Thread *Self) { ObjectMonitor* mid; int inusetally = 0; for (mid = Self->omInUseList; mid != NULL; mid = mid->FreeNext) { - inusetally ++; + inusetally++; } assert(inusetally == Self->omInUseCount, "inuse count off"); int freetally = 0; for (mid = Self->omFreeList; mid != NULL; mid = mid->FreeNext) { - freetally ++; + freetally++; } assert(freetally == Self->omFreeCount, "free count off"); } -*/ -ObjectMonitor * ATTR ObjectSynchronizer::omAlloc (Thread * Self) { + +ObjectMonitor * NOINLINE ObjectSynchronizer::omAlloc (Thread * Self) { // A large MAXPRIVATE value reduces both list lock contention // and list coherency traffic, but also tends to increase the // number of objectMonitors in circulation as well as the STW @@ -932,7 +924,9 @@ ObjectMonitor * ATTR ObjectSynchronizer::omAlloc (Thread * Self) { m->FreeNext = Self->omInUseList; Self->omInUseList = m; Self->omInUseCount++; - // verifyInUse(Self); + if (ObjectMonitor::Knob_VerifyInUse) { + verifyInUse(Self); + } } else { m->FreeNext = NULL; } @@ -1052,7 +1046,9 @@ void ObjectSynchronizer::omRelease (Thread * Self, ObjectMonitor * m, bool fromP curmidinuse->FreeNext = mid->FreeNext; // maintain the current thread inuselist } Self->omInUseCount--; - // verifyInUse(Self); + if (ObjectMonitor::Knob_VerifyInUse) { + verifyInUse(Self); + } break; } else { curmidinuse = mid; @@ -1061,7 +1057,7 @@ void ObjectSynchronizer::omRelease (Thread * Self, ObjectMonitor * m, bool fromP } } - // FreeNext is used for both onInUseList and omFreeList, so clear old before setting new + // FreeNext is used for both omInUseList and omFreeList, so clear old before setting new m->FreeNext = Self->omFreeList; Self->omFreeList = m; Self->omFreeCount++; @@ -1074,7 +1070,7 @@ void ObjectSynchronizer::omRelease (Thread * Self, ObjectMonitor * m, bool fromP // consecutive STW safepoints. Relatedly, we might decay // omFreeProvision at STW safepoints. // -// Also return the monitors of a moribund thread"s omInUseList to +// Also return the monitors of a moribund thread's omInUseList to // a global gOmInUseList under the global list lock so these // will continue to be scanned. // @@ -1115,7 +1111,6 @@ void ObjectSynchronizer::omFlush (Thread * Self) { InUseTail = curom; InUseTally++; } -// TODO debug assert(Self->omInUseCount == InUseTally, "inuse count off"); Self->omInUseCount = 0; guarantee(InUseTail != NULL && InUseList != NULL, "invariant"); @@ -1154,7 +1149,7 @@ ObjectMonitor* ObjectSynchronizer::inflate_helper(oop obj) { // multiple locks occupy the same $ line. Padding might be appropriate. -ObjectMonitor * ATTR ObjectSynchronizer::inflate (Thread * Self, oop object) { +ObjectMonitor * NOINLINE ObjectSynchronizer::inflate (Thread * Self, oop object) { // Inflate mutates the heap ... // Relaxing assertion for bug 6320749. assert(Universe::verify_in_progress() || @@ -1385,7 +1380,7 @@ enum ManifestConstants { // Deflate a single monitor if not in use // Return true if deflated, false if in use bool ObjectSynchronizer::deflate_monitor(ObjectMonitor* mid, oop obj, - ObjectMonitor** FreeHeadp, ObjectMonitor** FreeTailp) { + ObjectMonitor** freeHeadp, ObjectMonitor** freeTailp) { bool deflated; // Normal case ... The monitor is associated with obj. guarantee(obj->mark() == markOopDesc::encode(mid), "invariant"); @@ -1415,13 +1410,13 @@ bool ObjectSynchronizer::deflate_monitor(ObjectMonitor* mid, oop obj, assert(mid->object() == NULL, "invariant"); // Move the object to the working free list defined by FreeHead,FreeTail. - if (*FreeHeadp == NULL) *FreeHeadp = mid; - if (*FreeTailp != NULL) { - ObjectMonitor * prevtail = *FreeTailp; + if (*freeHeadp == NULL) *freeHeadp = mid; + if (*freeTailp != NULL) { + ObjectMonitor * prevtail = *freeTailp; assert(prevtail->FreeNext == NULL, "cleaned up deflated?"); // TODO KK prevtail->FreeNext = mid; } - *FreeTailp = mid; + *freeTailp = mid; deflated = true; } return deflated; @@ -1429,7 +1424,7 @@ bool ObjectSynchronizer::deflate_monitor(ObjectMonitor* mid, oop obj, // Caller acquires ListLock int ObjectSynchronizer::walk_monitor_list(ObjectMonitor** listheadp, - ObjectMonitor** FreeHeadp, ObjectMonitor** FreeTailp) { + ObjectMonitor** freeHeadp, ObjectMonitor** freeTailp) { ObjectMonitor* mid; ObjectMonitor* next; ObjectMonitor* curmidinuse = NULL; @@ -1439,7 +1434,7 @@ int ObjectSynchronizer::walk_monitor_list(ObjectMonitor** listheadp, oop obj = (oop) mid->object(); bool deflated = false; if (obj != NULL) { - deflated = deflate_monitor(mid, obj, FreeHeadp, FreeTailp); + deflated = deflate_monitor(mid, obj, freeHeadp, freeTailp); } if (deflated) { // extract from per-thread in-use-list @@ -1482,7 +1477,9 @@ void ObjectSynchronizer::deflate_idle_monitors() { nInCirculation+= cur->omInUseCount; int deflatedcount = walk_monitor_list(cur->omInUseList_addr(), &FreeHead, &FreeTail); cur->omInUseCount-= deflatedcount; - // verifyInUse(cur); + if (ObjectMonitor::Knob_VerifyInUse) { + verifyInUse(cur); + } nScavenged += deflatedcount; nInuse += cur->omInUseCount; } diff --git a/hotspot/src/share/vm/runtime/synchronizer.hpp b/hotspot/src/share/vm/runtime/synchronizer.hpp index bf3959be688..07af7e325ef 100644 --- a/hotspot/src/share/vm/runtime/synchronizer.hpp +++ b/hotspot/src/share/vm/runtime/synchronizer.hpp @@ -84,7 +84,7 @@ class ObjectSynchronizer : AllStatic { static void reenter (Handle obj, intptr_t recursion, TRAPS); // thread-specific and global objectMonitor free list accessors -// static void verifyInUse (Thread * Self) ; too slow for general assert/debug + static void verifyInUse(Thread * Self); static ObjectMonitor * omAlloc(Thread * Self); static void omRelease(Thread * Self, ObjectMonitor * m, bool FromPerThreadAlloc); static void omFlush(Thread * Self); @@ -114,10 +114,10 @@ class ObjectSynchronizer : AllStatic { // An adaptive profile-based deflation policy could be used if needed static void deflate_idle_monitors(); static int walk_monitor_list(ObjectMonitor** listheadp, - ObjectMonitor** FreeHeadp, - ObjectMonitor** FreeTailp); - static bool deflate_monitor(ObjectMonitor* mid, oop obj, ObjectMonitor** FreeHeadp, - ObjectMonitor** FreeTailp); + ObjectMonitor** freeHeadp, + ObjectMonitor** freeTailp); + static bool deflate_monitor(ObjectMonitor* mid, oop obj, ObjectMonitor** freeHeadp, + ObjectMonitor** freeTailp); static void oops_do(OopClosure* f); // debugging @@ -130,7 +130,10 @@ class ObjectSynchronizer : AllStatic { enum { _BLOCKSIZE = 128 }; static ObjectMonitor* gBlockList; static ObjectMonitor * volatile gFreeList; - static ObjectMonitor * volatile gOmInUseList; // for moribund thread, so monitors they inflated still get scanned + // global monitor in use list, for moribund threads, + // monitors they inflated need to be scanned for deflation + static ObjectMonitor * volatile gOmInUseList; + // count of entries in gOmInUseList static int gOmInUseCount; }; diff --git a/hotspot/src/share/vm/runtime/thread.cpp b/hotspot/src/share/vm/runtime/thread.cpp index 69c2326a6ff..f2ad3d5d2b6 100644 --- a/hotspot/src/share/vm/runtime/thread.cpp +++ b/hotspot/src/share/vm/runtime/thread.cpp @@ -4101,8 +4101,8 @@ void Threads::possibly_parallel_oops_do(OopClosure* f, CLDClosure* cld_f, CodeBl SharedHeap* sh = SharedHeap::heap(); // Cannot yet substitute active_workers for n_par_threads // because of G1CollectedHeap::verify() use of - // SharedHeap::process_strong_roots(). n_par_threads == 0 will - // turn off parallelism in process_strong_roots while active_workers + // SharedHeap::process_roots(). n_par_threads == 0 will + // turn off parallelism in process_roots while active_workers // is being used for parallelism elsewhere. bool is_par = sh->n_par_threads() > 0; assert(!is_par || @@ -4376,7 +4376,7 @@ void Thread::SpinAcquire (volatile int * adr, const char * LockName) { if (Yields > 5) { os::naked_short_sleep(1); } else { - os::NakedYield(); + os::naked_yield(); ++Yields; } } else { @@ -4394,6 +4394,12 @@ void Thread::SpinRelease (volatile int * adr) { // It's safe if subsequent LDs and STs float "up" into the critical section, // but prior LDs and STs within the critical section can't be allowed // to reorder or float past the ST that releases the lock. + // Loads and stores in the critical section - which appear in program + // order before the store that releases the lock - must also appear + // before the store that releases the lock in memory visibility order. + // Conceptually we need a #loadstore|#storestore "release" MEMBAR before + // the ST of 0 into the lock-word which releases the lock, so fence + // more than covers this on all platforms. *adr = 0; } @@ -4575,18 +4581,25 @@ void Thread::muxAcquireW (volatile intptr_t * Lock, ParkEvent * ev) { // This implementation pops from the head of the list. This is unfair, // but tends to provide excellent throughput as hot threads remain hot. // (We wake recently run threads first). - +// +// All paths through muxRelease() will execute a CAS. +// Release consistency -- We depend on the CAS in muxRelease() to provide full +// bidirectional fence/MEMBAR semantics, ensuring that all prior memory operations +// executed within the critical section are complete and globally visible before the +// store (CAS) to the lock-word that releases the lock becomes globally visible. void Thread::muxRelease (volatile intptr_t * Lock) { for (;;) { const intptr_t w = Atomic::cmpxchg_ptr(0, Lock, LOCKBIT); assert(w & LOCKBIT, "invariant"); if (w == LOCKBIT) return; - ParkEvent * List = (ParkEvent *)(w & ~LOCKBIT); + ParkEvent * const List = (ParkEvent *) (w & ~LOCKBIT); assert(List != NULL, "invariant"); assert(List->OnList == intptr_t(Lock), "invariant"); - ParkEvent * nxt = List->ListNext; + ParkEvent * const nxt = List->ListNext; + guarantee((intptr_t(nxt) & LOCKBIT) == 0, "invariant"); // The following CAS() releases the lock and pops the head element. + // The CAS() also ratifies the previously fetched lock-word value. if (Atomic::cmpxchg_ptr (intptr_t(nxt), Lock, w) != w) { continue; } diff --git a/hotspot/src/share/vm/runtime/thread.hpp b/hotspot/src/share/vm/runtime/thread.hpp index 501a4b4f186..715e50a552f 100644 --- a/hotspot/src/share/vm/runtime/thread.hpp +++ b/hotspot/src/share/vm/runtime/thread.hpp @@ -452,7 +452,7 @@ class Thread: public ThreadShadow { private: bool claim_oops_do_par_case(int collection_parity); public: - // Requires that "collection_parity" is that of the current strong roots + // Requires that "collection_parity" is that of the current roots // iteration. If "is_par" is false, sets the parity of "this" to // "collection_parity", and returns "true". If "is_par" is true, // uses an atomic instruction to set the current threads parity to diff --git a/hotspot/src/share/vm/runtime/vframe.cpp b/hotspot/src/share/vm/runtime/vframe.cpp index 57900245436..53f344956cc 100644 --- a/hotspot/src/share/vm/runtime/vframe.cpp +++ b/hotspot/src/share/vm/runtime/vframe.cpp @@ -260,66 +260,156 @@ Method* interpretedVFrame::method() const { return fr().interpreter_frame_method(); } -StackValueCollection* interpretedVFrame::locals() const { - int length = method()->max_locals(); +static StackValue* create_stack_value_from_oop_map(const InterpreterOopMap& oop_mask, + int index, + const intptr_t* const addr) { - if (method()->is_native()) { - // If the method is native, max_locals is not telling the truth. - // maxlocals then equals the size of parameters - length = method()->size_of_parameters(); + assert(index >= 0 && + index < oop_mask.number_of_entries(), "invariant"); + + // categorize using oop_mask + if (oop_mask.is_oop(index)) { + // reference (oop) "r" + Handle h(addr != NULL ? (*(oop*)addr) : (oop)NULL); + return new StackValue(h); + } + // value (integer) "v" + return new StackValue(addr != NULL ? *addr : 0); +} + +static bool is_in_expression_stack(const frame& fr, const intptr_t* const addr) { + assert(addr != NULL, "invariant"); + + // Ensure to be 'inside' the expresion stack (i.e., addr >= sp for Intel). + // In case of exceptions, the expression stack is invalid and the sp + // will be reset to express this condition. + if (frame::interpreter_frame_expression_stack_direction() > 0) { + return addr <= fr.interpreter_frame_tos_address(); } - StackValueCollection* result = new StackValueCollection(length); + return addr >= fr.interpreter_frame_tos_address(); +} + +static void stack_locals(StackValueCollection* result, + int length, + const InterpreterOopMap& oop_mask, + const frame& fr) { + + assert(result != NULL, "invariant"); + + for (int i = 0; i < length; ++i) { + const intptr_t* const addr = fr.interpreter_frame_local_at(i); + assert(addr != NULL, "invariant"); + assert(addr >= fr.sp(), "must be inside the frame"); + + StackValue* const sv = create_stack_value_from_oop_map(oop_mask, i, addr); + assert(sv != NULL, "sanity check"); + + result->add(sv); + } +} + +static void stack_expressions(StackValueCollection* result, + int length, + int max_locals, + const InterpreterOopMap& oop_mask, + const frame& fr) { + + assert(result != NULL, "invariant"); + + for (int i = 0; i < length; ++i) { + const intptr_t* addr = fr.interpreter_frame_expression_stack_at(i); + assert(addr != NULL, "invariant"); + if (!is_in_expression_stack(fr, addr)) { + // Need to ensure no bogus escapes. + addr = NULL; + } + + StackValue* const sv = create_stack_value_from_oop_map(oop_mask, + i + max_locals, + addr); + assert(sv != NULL, "sanity check"); + + result->add(sv); + } +} + +StackValueCollection* interpretedVFrame::locals() const { + return stack_data(false); +} + +StackValueCollection* interpretedVFrame::expressions() const { + return stack_data(true); +} + +/* + * Worker routine for fetching references and/or values + * for a particular bci in the interpretedVFrame. + * + * Returns data for either "locals" or "expressions", + * using bci relative oop_map (oop_mask) information. + * + * @param expressions bool switch controlling what data to return + (false == locals / true == expression) + * + */ +StackValueCollection* interpretedVFrame::stack_data(bool expressions) const { - // Get oopmap describing oops and int for current bci InterpreterOopMap oop_mask; + // oopmap for current bci if (TraceDeoptimization && Verbose) { - // need the current JavaThread and not thread() methodHandle m_h(Thread::current(), method()); OopMapCache::compute_one_oop_map(m_h, bci(), &oop_mask); } else { method()->mask_for(bci(), &oop_mask); } - // handle locals - for(int i=0; i < length; i++) { - // Find stack location - intptr_t *addr = locals_addr_at(i); - // Depending on oop/int put it in the right package - StackValue *sv; - if (oop_mask.is_oop(i)) { - // oop value - Handle h(*(oop *)addr); - sv = new StackValue(h); - } else { - // integer - sv = new StackValue(*addr); - } - assert(sv != NULL, "sanity check"); - result->add(sv); + const int mask_len = oop_mask.number_of_entries(); + + // If the method is native, method()->max_locals() is not telling the truth. + // For our purposes, max locals instead equals the size of parameters. + const int max_locals = method()->is_native() ? + method()->size_of_parameters() : method()->max_locals(); + + assert(mask_len >= max_locals, "invariant"); + + const int length = expressions ? mask_len - max_locals : max_locals; + assert(length >= 0, "invariant"); + + StackValueCollection* const result = new StackValueCollection(length); + + if (0 == length) { + return result; } + + if (expressions) { + stack_expressions(result, length, max_locals, oop_mask, fr()); + } else { + stack_locals(result, length, oop_mask, fr()); + } + + assert(length == result->size(), "invariant"); + return result; } void interpretedVFrame::set_locals(StackValueCollection* values) const { if (values == NULL || values->size() == 0) return; - int length = method()->max_locals(); - if (method()->is_native()) { - // If the method is native, max_locals is not telling the truth. - // maxlocals then equals the size of parameters - length = method()->size_of_parameters(); - } + // If the method is native, max_locals is not telling the truth. + // maxlocals then equals the size of parameters + const int max_locals = method()->is_native() ? + method()->size_of_parameters() : method()->max_locals(); - assert(length == values->size(), "Mismatch between actual stack format and supplied data"); + assert(max_locals == values->size(), "Mismatch between actual stack format and supplied data"); // handle locals - for (int i = 0; i < length; i++) { + for (int i = 0; i < max_locals; i++) { // Find stack location intptr_t *addr = locals_addr_at(i); // Depending on oop/int put it in the right package - StackValue *sv = values->at(i); + const StackValue* const sv = values->at(i); assert(sv != NULL, "sanity check"); if (sv->type() == T_OBJECT) { *(oop *) addr = (sv->get_obj())(); @@ -329,61 +419,6 @@ void interpretedVFrame::set_locals(StackValueCollection* values) const { } } -StackValueCollection* interpretedVFrame::expressions() const { - - InterpreterOopMap oop_mask; - - if (!method()->is_native()) { - // Get oopmap describing oops and int for current bci - if (TraceDeoptimization && Verbose) { - // need the current JavaThread and not thread() - methodHandle m_h(Thread::current(), method()); - OopMapCache::compute_one_oop_map(m_h, bci(), &oop_mask); - } else { - method()->mask_for(bci(), &oop_mask); - } - } - - // If the bci is a call instruction, i.e. any of the invoke* instructions, - // the InterpreterOopMap does not include expression/operand stack liveness - // info in the oop_mask/bit_mask. This can lead to a discrepancy of what - // is actually on the expression stack compared to what is given by the - // oop_map. We need to use the length reported in the oop_map. - int length = oop_mask.expression_stack_size(); - - assert(fr().interpreter_frame_expression_stack_size() >= length, - "error in expression stack!"); - - StackValueCollection* result = new StackValueCollection(length); - - if (0 == length) { - return result; - } - - int nof_locals = method()->max_locals(); - - // handle expressions - for(int i=0; i < length; i++) { - // Find stack location - intptr_t *addr = fr().interpreter_frame_expression_stack_at(i); - - // Depending on oop/int put it in the right package - StackValue *sv; - if (oop_mask.is_oop(i + nof_locals)) { - // oop value - Handle h(*(oop *)addr); - sv = new StackValue(h); - } else { - // integer - sv = new StackValue(*addr); - } - assert(sv != NULL, "sanity check"); - result->add(sv); - } - return result; -} - - // ------------- cChunk -------------- entryVFrame::entryVFrame(const frame* fr, const RegisterMap* reg_map, JavaThread* thread) diff --git a/hotspot/src/share/vm/runtime/vframe.hpp b/hotspot/src/share/vm/runtime/vframe.hpp index a284b13de0c..70f31b14c51 100644 --- a/hotspot/src/share/vm/runtime/vframe.hpp +++ b/hotspot/src/share/vm/runtime/vframe.hpp @@ -186,7 +186,7 @@ class interpretedVFrame: public javaVFrame { private: static const int bcp_offset; intptr_t* locals_addr_at(int offset) const; - + StackValueCollection* stack_data(bool expressions) const; // returns where the parameters starts relative to the frame pointer int start_of_parameters() const; diff --git a/hotspot/src/share/vm/services/memTracker.hpp b/hotspot/src/share/vm/services/memTracker.hpp index 52715a68764..8573c1f6530 100644 --- a/hotspot/src/share/vm/services/memTracker.hpp +++ b/hotspot/src/share/vm/services/memTracker.hpp @@ -484,7 +484,7 @@ class MemTracker : AllStatic { // as short sleep. os::naked_short_sleep(1); #else - os::NakedYield(); + os::naked_yield(); #endif } } diff --git a/hotspot/src/share/vm/services/memoryService.cpp b/hotspot/src/share/vm/services/memoryService.cpp index ea9cb59873d..625d367a265 100644 --- a/hotspot/src/share/vm/services/memoryService.cpp +++ b/hotspot/src/share/vm/services/memoryService.cpp @@ -136,7 +136,6 @@ void MemoryService::add_gen_collected_heap_info(GenCollectedHeap* heap) { break; #if INCLUDE_ALL_GCS case Generation::ParNew: - case Generation::ASParNew: _minor_gc_manager = MemoryManager::get_parnew_memory_manager(); break; #endif // INCLUDE_ALL_GCS @@ -268,7 +267,6 @@ void MemoryService::add_generation_memory_pool(Generation* gen, #if INCLUDE_ALL_GCS case Generation::ParNew: - case Generation::ASParNew: { assert(major_mgr != NULL && minor_mgr != NULL, "Should have two managers"); // Add a memory pool for each space and young gen doesn't @@ -300,7 +298,6 @@ void MemoryService::add_generation_memory_pool(Generation* gen, #if INCLUDE_ALL_GCS case Generation::ConcurrentMarkSweep: - case Generation::ASConcurrentMarkSweep: { assert(major_mgr != NULL && minor_mgr == NULL, "Should have only one manager"); ConcurrentMarkSweepGeneration* cms = (ConcurrentMarkSweepGeneration*) gen; @@ -548,23 +545,20 @@ Handle MemoryService::create_MemoryUsage_obj(MemoryUsage usage, TRAPS) { // GC manager type depends on the type of Generation. Depending on the space // availablity and vm options the gc uses major gc manager or minor gc // manager or both. The type of gc manager depends on the generation kind. -// For DefNew, ParNew and ASParNew generation doing scavenge gc uses minor -// gc manager (so _fullGC is set to false ) and for other generation kinds -// doing mark-sweep-compact uses major gc manager (so _fullGC is set -// to true). +// For DefNew and ParNew generation doing scavenge gc uses minor gc manager (so +// _fullGC is set to false ) and for other generation kinds doing +// mark-sweep-compact uses major gc manager (so _fullGC is set to true). TraceMemoryManagerStats::TraceMemoryManagerStats(Generation::Name kind, GCCause::Cause cause) { switch (kind) { case Generation::DefNew: #if INCLUDE_ALL_GCS case Generation::ParNew: - case Generation::ASParNew: #endif // INCLUDE_ALL_GCS _fullGC=false; break; case Generation::MarkSweepCompact: #if INCLUDE_ALL_GCS case Generation::ConcurrentMarkSweep: - case Generation::ASConcurrentMarkSweep: #endif // INCLUDE_ALL_GCS _fullGC=true; break; diff --git a/hotspot/src/share/vm/utilities/array.hpp b/hotspot/src/share/vm/utilities/array.hpp index 632b7c656b2..b7ce8e71588 100644 --- a/hotspot/src/share/vm/utilities/array.hpp +++ b/hotspot/src/share/vm/utilities/array.hpp @@ -305,6 +305,7 @@ class Array: public MetaspaceObj { friend class MetadataFactory; friend class VMStructs; friend class MethodHandleCompiler; // special case + friend class WhiteBox; protected: int _length; // the number of array elements T _data[1]; // the array memory @@ -326,6 +327,31 @@ protected: static size_t byte_sizeof(int length) { return sizeof(Array) + MAX2(length - 1, 0) * sizeof(T); } + // WhiteBox API helper. + // Can't distinguish between array of length 0 and length 1, + // will always return 0 in those cases. + static int bytes_to_length(size_t bytes) { + assert(is_size_aligned(bytes, BytesPerWord), "Must be, for now"); + + if (sizeof(Array) >= bytes) { + return 0; + } + + size_t left = bytes - sizeof(Array); + assert(is_size_aligned(left, sizeof(T)), "Must be"); + + size_t elements = left / sizeof(T); + assert(elements <= (size_t)INT_MAX, err_msg("number of elements " SIZE_FORMAT "doesn't fit into an int.", elements)); + + int length = (int)elements; + + assert((size_t)size(length) * BytesPerWord == bytes, + err_msg("Expected: " SIZE_FORMAT " got: " SIZE_FORMAT, + bytes, (size_t)size(length) * BytesPerWord)); + + return length; + } + explicit Array(int length) : _length(length) { assert(length >= 0, "illegal length"); } diff --git a/hotspot/src/share/vm/utilities/taskqueue.cpp b/hotspot/src/share/vm/utilities/taskqueue.cpp index 9a992c1664d..bb63fe6385e 100644 --- a/hotspot/src/share/vm/utilities/taskqueue.cpp +++ b/hotspot/src/share/vm/utilities/taskqueue.cpp @@ -142,7 +142,7 @@ bool ParallelTaskTerminator::peek_in_queue_set() { void ParallelTaskTerminator::yield() { assert(_offered_termination <= _n_threads, "Invariant"); - os::yield(); + os::naked_yield(); } void ParallelTaskTerminator::sleep(uint millis) { diff --git a/hotspot/test/Makefile b/hotspot/test/Makefile index f81cc8d64df..929de70cdf0 100644 --- a/hotspot/test/Makefile +++ b/hotspot/test/Makefile @@ -23,14 +23,36 @@ # # -# Makefile to run various jdk tests +# Makefile to run various hotspot tests # GETMIXEDPATH=echo -# Get OS/ARCH specifics -OSNAME = $(shell uname -s) -ifeq ($(OSNAME), SunOS) +# Utilities used +AWK = awk +CAT = cat +CD = cd +CHMOD = chmod +CP = cp +CUT = cut +DIRNAME = dirname +ECHO = echo +EGREP = egrep +EXPAND = expand +FIND = find +MKDIR = mkdir +PWD = pwd +SED = sed +SORT = sort +TEE = tee +UNAME = uname +UNIQ = uniq +WC = wc +ZIP = zip + +# Get OS name from uname (Cygwin inexplicably adds _NT-5.1) +UNAME_S := $(shell $(UNAME) -s | $(CUT) -f1 -d_) +ifeq ($(UNAME_S), SunOS) PLATFORM = solaris SLASH_JAVA = /java ARCH = $(shell uname -p) @@ -38,7 +60,7 @@ ifeq ($(OSNAME), SunOS) ARCH=i586 endif endif -ifeq ($(OSNAME), Linux) +ifeq ($(UNAME_S), Linux) PLATFORM = linux SLASH_JAVA = /java ARCH = $(shell uname -m) @@ -46,7 +68,7 @@ ifeq ($(OSNAME), Linux) ARCH = i586 endif endif -ifeq ($(OSNAME), Darwin) +ifeq ($(UNAME_S), Darwin) PLATFORM = bsd SLASH_JAVA = /java ARCH = $(shell uname -m) @@ -54,7 +76,7 @@ ifeq ($(OSNAME), Darwin) ARCH = i586 endif endif -ifeq ($(findstring BSD,$(OSNAME)), BSD) +ifeq ($(findstring BSD,$(UNAME_S)), BSD) PLATFORM = bsd SLASH_JAVA = /java ARCH = $(shell uname -m) @@ -63,12 +85,12 @@ ifeq ($(findstring BSD,$(OSNAME)), BSD) endif endif ifeq ($(PLATFORM),) - # detect wether we're running in MKS or cygwin - ifeq ($(OSNAME), Windows_NT) # MKS + # detect whether we're running in MKS or cygwin + ifeq ($(UNAME_S), Windows_NT) # MKS GETMIXEDPATH=dosname -s endif - ifeq ($(findstring CYGWIN,$(OSNAME)), CYGWIN) - GETMIXEDPATH=cygpath -m -s + ifeq ($(findstring CYGWIN,$(UNAME_S)), CYGWIN) + GETMIXEDPATH=cygpath -m endif PLATFORM = windows SLASH_JAVA = J: @@ -92,13 +114,6 @@ ifdef ALT_SLASH_JAVA SLASH_JAVA = $(ALT_SLASH_JAVA) endif -# Utilities used -CD = cd -CP = cp -ECHO = echo -MKDIR = mkdir -ZIP = zip - # Root of this test area (important to use full paths in some places) TEST_ROOT := $(shell pwd) @@ -136,21 +151,82 @@ ifdef JPRT_ARCHIVE_BUNDLE endif # How to create the test bundle (pass or fail, we want to create this) -BUNDLE_UP = ( $(MKDIR) -p `dirname $(ARCHIVE_BUNDLE)` \ - && $(CD) $(ABS_TEST_OUTPUT_DIR) \ - && $(ZIP) -q -r $(ARCHIVE_BUNDLE) . ) -BUNDLE_UP_FAILED = ( exitCode=$$? && $(BUNDLE_UP) && exit $${exitCode} ) +# Follow command with ";$(BUNDLE_UP_AND_EXIT)", so it always gets executed. +ZIP_UP_RESULTS = ( $(MKDIR) -p `$(DIRNAME) $(ARCHIVE_BUNDLE)` \ + && $(CD) $(ABS_TEST_OUTPUT_DIR) \ + && $(CHMOD) -R a+r . \ + && $(ZIP) -q -r $(ARCHIVE_BUNDLE) . ) + +# important results files +SUMMARY_TXT = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/JTreport/text/summary.txt") +STATS_TXT_NAME = Stats.txt +STATS_TXT = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/$(STATS_TXT_NAME)") +RUNLIST = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/runlist.txt") +PASSLIST = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/passlist.txt") +FAILLIST = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/faillist.txt") +EXITCODE = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/exitcode.txt") + +TESTEXIT = \ + if [ ! -s $(EXITCODE) ] ; then \ + $(ECHO) "ERROR: EXITCODE file not filled in."; \ + $(ECHO) "1" > $(EXITCODE); \ + fi ; \ + testExitCode=`$(CAT) $(EXITCODE)`; \ + $(ECHO) "EXIT CODE: $${testExitCode}"; \ + exit $${testExitCode} + +BUNDLE_UP_AND_EXIT = \ +( \ + jtregExitCode=$$? && \ + _summary="$(SUMMARY_TXT)"; \ + $(RM) -f $(STATS_TXT) $(RUNLIST) $(PASSLIST) $(FAILLIST) $(EXITCODE); \ + $(ECHO) "$${jtregExitCode}" > $(EXITCODE); \ + if [ -r "$${_summary}" ] ; then \ + $(ECHO) "Summary: $(UNIQUE_DIR)" > $(STATS_TXT); \ + $(EXPAND) $${_summary} | $(EGREP) -v ' Not run\.' > $(RUNLIST); \ + $(EGREP) ' Passed\.' $(RUNLIST) \ + | $(EGREP) -v ' Error\.' \ + | $(EGREP) -v ' Failed\.' > $(PASSLIST); \ + ( $(EGREP) ' Failed\.' $(RUNLIST); \ + $(EGREP) ' Error\.' $(RUNLIST); \ + $(EGREP) -v ' Passed\.' $(RUNLIST) ) \ + | $(SORT) | $(UNIQ) > $(FAILLIST); \ + if [ $${jtregExitCode} != 0 -o -s $(FAILLIST) ] ; then \ + $(EXPAND) $(FAILLIST) \ + | $(CUT) -d' ' -f1 \ + | $(SED) -e 's@^@FAILED: @' >> $(STATS_TXT); \ + if [ $${jtregExitCode} = 0 ] ; then \ + jtregExitCode=1; \ + fi; \ + fi; \ + runc="`$(CAT) $(RUNLIST) | $(WC) -l | $(AWK) '{print $$1;}'`"; \ + passc="`$(CAT) $(PASSLIST) | $(WC) -l | $(AWK) '{print $$1;}'`"; \ + failc="`$(CAT) $(FAILLIST) | $(WC) -l | $(AWK) '{print $$1;}'`"; \ + exclc="FIXME CODETOOLS-7900176"; \ + $(ECHO) "TEST STATS: name=$(UNIQUE_DIR) run=$${runc} pass=$${passc} fail=$${failc}" \ + >> $(STATS_TXT); \ + else \ + $(ECHO) "Missing file: $${_summary}" >> $(STATS_TXT); \ + fi; \ + if [ -f $(STATS_TXT) ] ; then \ + $(CAT) $(STATS_TXT); \ + fi; \ + $(ZIP_UP_RESULTS) ; \ + $(TESTEXIT) \ +) ################################################################ # Default make rule (runs jtreg_tests) -all: jtreg_tests +all: hotspot_all @$(ECHO) "Testing completed successfully" -# Support "hotspot_" prefixed test make targets too -# The hotspot_% targets are for example invoked by the top level Makefile +# Support "hotspot_" prefixed test make targets (too) +# The hotspot_% targets are used by the top level Makefile +# Unless explicitly defined below, hotspot_ is interpreted as a jtreg test group name hotspot_%: - $(MAKE) $* + $(ECHO) "Running tests: $@" + $(MAKE) -j 1 TEST_SELECTION=":$@" UNIQUE_DIR=$@ jtreg_tests; # Prep for output prep: clean @@ -168,41 +244,64 @@ clean: # Expect JT_HOME to be set for jtreg tests. (home for jtreg) ifndef JT_HOME - JT_HOME = $(SLASH_JAVA)/re/jtreg/4.0/promoted/latest/binaries/jtreg -endif -ifdef JPRT_JTREG_HOME - JT_HOME = $(JPRT_JTREG_HOME) + JT_HOME = $(SLASH_JAVA)/re/jtreg/4.1/promoted/latest/binaries/jtreg + ifdef JPRT_JTREG_HOME + JT_HOME = $(JPRT_JTREG_HOME) + endif endif -# Expect JPRT to set TESTDIRS to the jtreg test dirs -JTREG_TESTDIRS = demo/jvmti/gctest demo/jvmti/hprof +# When called from JPRT the TESTDIRS variable is set to the jtreg tests to run ifdef TESTDIRS - JTREG_TESTDIRS = $(TESTDIRS) + TEST_SELECTION = $(TESTDIRS) +endif + +ifdef CONCURRENCY + EXTRA_JTREG_OPTIONS += -concurrency:$(CONCURRENCY) endif # Default JTREG to run (win32 script works for everybody) JTREG = $(JT_HOME)/win32/bin/jtreg +# Only run automatic tests +JTREG_BASIC_OPTIONS += -a +# Report details on all failed or error tests, times too +JTREG_BASIC_OPTIONS += -v:fail,error,time +# Retain all files for failing tests +JTREG_BASIC_OPTIONS += -retain:fail,error +# Ignore tests are not run and completely silent about it +JTREG_IGNORE_OPTION = -ignore:quiet +JTREG_BASIC_OPTIONS += $(JTREG_IGNORE_OPTION) +# Add any extra options +JTREG_BASIC_OPTIONS += $(EXTRA_JTREG_OPTIONS) +# Set other vm and test options +JTREG_TEST_OPTIONS = $(JAVA_ARGS:%=-javaoptions:%) $(JAVA_OPTIONS:%=-vmoption:%) $(JAVA_VM_ARGS:%=-vmoption:%) + # Option to tell jtreg to not run tests marked with "ignore" ifeq ($(PLATFORM), windows) JTREG_KEY_OPTION = -k:!ignore else JTREG_KEY_OPTION = -k:\!ignore endif +JTREG_BASIC_OPTIONS += $(JTREG_KEY_OPTION) -#EXTRA_JTREG_OPTIONS = +# Make sure jtreg exists +$(JTREG): $(JT_HOME) -jtreg_tests: prep $(JT_HOME) $(PRODUCT_HOME) $(JTREG) - $(JTREG) -a -v:fail,error \ - $(JTREG_KEY_OPTION) \ - $(EXTRA_JTREG_OPTIONS) \ - -r:$(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)")/JTreport \ - -w:$(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)")/JTwork \ - -jdk:$(shell $(GETMIXEDPATH) "$(PRODUCT_HOME)") \ - $(JAVA_OPTIONS:%=-vmoption:%) \ - $(JTREG_TESTDIRS) \ - || $(BUNDLE_UP_FAILED) - $(BUNDLE_UP) +jtreg_tests: prep $(PRODUCT_HOME) $(JTREG) + ( \ + ( JT_HOME=$(shell $(GETMIXEDPATH) "$(JT_HOME)"); \ + export JT_HOME; \ + $(shell $(GETMIXEDPATH) "$(JTREG)") \ + $(JTREG_BASIC_OPTIONS) \ + -r:$(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/JTreport") \ + -w:$(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/JTwork") \ + -jdk:$(shell $(GETMIXEDPATH) "$(PRODUCT_HOME)") \ + $(JTREG_EXCLUSIONS) \ + $(JTREG_TEST_OPTIONS) \ + $(TEST_SELECTION) \ + ) ; \ + $(BUNDLE_UP_AND_EXIT) \ + ) 2>&1 | $(TEE) $(ABS_TEST_OUTPUT_DIR)/output.txt ; $(TESTEXIT) PHONY_LIST += jtreg_tests @@ -210,7 +309,7 @@ PHONY_LIST += jtreg_tests # clienttest (make sure various basic java client options work) -clienttest: prep $(PRODUCT_HOME) +hotspot_clienttest clienttest: prep $(PRODUCT_HOME) $(PRODUCT_HOME)/bin/java $(JAVA_OPTIONS) -version $(PRODUCT_HOME)/bin/java $(JAVA_OPTIONS) -help $(PRODUCT_HOME)/bin/java $(JAVA_OPTIONS) -X @@ -218,73 +317,27 @@ clienttest: prep $(PRODUCT_HOME) $(RM) $(PRODUCT_HOME)/jre/bin/client/classes.jsa $(PRODUCT_HOME)/bin/java $(JAVA_OPTIONS) -Xshare:dump -PHONY_LIST += clienttest +PHONY_LIST += hotspot_clienttest clienttest ################################################################ # servertest (make sure various basic java server options work) -servertest: prep $(PRODUCT_HOME) +hotspot_servertest servertest: prep $(PRODUCT_HOME) $(PRODUCT_HOME)/bin/java $(JAVA_OPTIONS) -version $(PRODUCT_HOME)/bin/java $(JAVA_OPTIONS) -help $(PRODUCT_HOME)/bin/java $(JAVA_OPTIONS) -X -PHONY_LIST += servertest +PHONY_LIST += hotspot_servertest servertest ################################################################ # internalvmtests (run internal unit tests inside the VM) -internalvmtests: prep $(PRODUCT_HOME) +hotspot_internalvmtests internalvmtests: prep $(PRODUCT_HOME) $(PRODUCT_HOME)/bin/java $(JAVA_OPTIONS) -XX:+ExecuteInternalVMTests -version -PHONY_LIST += internalvmtests - -################################################################ - -# wbapitest (make sure the whitebox testing api classes work - -wbapitest: prep $(JT_HOME) $(PRODUCT_HOME) $(JTREG) - $(JTREG) -a -v:fail,error \ - $(JTREG_KEY_OPTION) \ - $(EXTRA_JTREG_OPTIONS) \ - -r:$(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)")/JTreport \ - -w:$(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)")/JTwork \ - -jdk:$(shell $(GETMIXEDPATH) "$(PRODUCT_HOME)") \ - $(JAVA_OPTIONS:%=-vmoption:%) \ - $(shell $(GETMIXEDPATH) "$(TEST_ROOT)")/sanity \ - || $(BUNDLE_UP_FAILED) - $(BUNDLE_UP) - -PHONY_LIST += wbapitest - -################################################################ - -# packtest - -# Expect JPRT to set JPRT_PACKTEST_HOME. -PACKTEST_HOME = /net/jprt-web.sfbay.sun.com/jprt/allproducts/packtest -ifdef JPRT_PACKTEST_HOME - PACKTEST_HOME = $(JPRT_PACKTEST_HOME) -endif - -#EXTRA_PACKTEST_OPTIONS = - -packtest: prep $(PACKTEST_HOME)/ptest $(PRODUCT_HOME) - ( $(CD) $(PACKTEST_HOME) && \ - $(PACKTEST_HOME)/ptest \ - -t "$(PRODUCT_HOME)" \ - $(PACKTEST_STRESS_OPTION) \ - $(EXTRA_PACKTEST_OPTIONS) \ - -W $(ABS_TEST_OUTPUT_DIR) \ - $(JAVA_OPTIONS:%=-J %) \ - ) || $(BUNDLE_UP_FAILED) - $(BUNDLE_UP) - -packtest_stress: PACKTEST_STRESS_OPTION=-s -packtest_stress: packtest - -PHONY_LIST += packtest packtest_stress +PHONY_LIST += hotspot_internalvmtests internalvmtests ################################################################ @@ -292,4 +345,3 @@ PHONY_LIST += packtest packtest_stress .PHONY: all clean prep $(PHONY_LIST) ################################################################ - diff --git a/hotspot/test/TEST.groups b/hotspot/test/TEST.groups index 22ff9c82228..b3c46afbaeb 100644 --- a/hotspot/test/TEST.groups +++ b/hotspot/test/TEST.groups @@ -325,3 +325,24 @@ applicable_cmsgc = \ -:needs_parallelgc +# When called from top level the test suites use the hotspot_ prefix +hotspot_wbapitest = \ + sanity/ + +hotspot_compiler = \ + sanity/ExecuteInternalVMTests.java + +hotspot_gc = \ + sanity/ExecuteInternalVMTests.java + +hotspot_runtime = \ + sanity/ExecuteInternalVMTests.java + +hotspot_serviceability = \ + sanity/ExecuteInternalVMTests.java + +hotspot_all = \ + :hotspot_compiler \ + :hotspot_gc \ + :hotspot_runtime \ + :hotspot_serviceability diff --git a/hotspot/test/compiler/6775880/Test.java b/hotspot/test/compiler/6775880/Test.java index e9cdd9fc237..f5a51fe4597 100644 --- a/hotspot/test/compiler/6775880/Test.java +++ b/hotspot/test/compiler/6775880/Test.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009, 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 @@ -26,7 +26,6 @@ * @test * @bug 6775880 * @summary EA +DeoptimizeALot: assert(mon_info->owner()->is_locked(),"object must be locked now") - * @compile -source 1.4 -target 1.4 Test.java * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -Xbatch -XX:+DoEscapeAnalysis -XX:+DeoptimizeALot -XX:CompileCommand=exclude,java.lang.AbstractStringBuilder::append Test */ diff --git a/hotspot/test/compiler/8009761/Test8009761.java b/hotspot/test/compiler/8009761/Test8009761.java index 39a25748348..ed0f94665e4 100644 --- a/hotspot/test/compiler/8009761/Test8009761.java +++ b/hotspot/test/compiler/8009761/Test8009761.java @@ -21,11 +21,7 @@ * questions. */ -import com.sun.management.HotSpotDiagnosticMXBean; -import com.sun.management.VMOption; import sun.hotspot.WhiteBox; -import sun.management.ManagementFactoryHelper; - import java.lang.reflect.Method; /* @@ -40,6 +36,7 @@ import java.lang.reflect.Method; public class Test8009761 { private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox(); + private static int COMP_LEVEL_SIMPLE = 1; private static int COMP_LEVEL_FULL_OPTIMIZATION = 4; private static Method m3 = null; @@ -236,7 +233,7 @@ public class Test8009761 { static public void main(String[] args) { // Make sure background compilation is disabled - if (backgroundCompilationEnabled()) { + if (WHITE_BOX.getBooleanVMFlag("BackgroundCompilation")) { throw new RuntimeException("Background compilation enabled"); } @@ -256,7 +253,11 @@ public class Test8009761 { c1 = count; // Force the compilation of m3() that will inline m1() - WHITE_BOX.enqueueMethodForCompilation(m3, COMP_LEVEL_FULL_OPTIMIZATION); + if(!WHITE_BOX.enqueueMethodForCompilation(m3, COMP_LEVEL_FULL_OPTIMIZATION)) { + // C2 compiler not available, compile with C1 + WHITE_BOX.enqueueMethodForCompilation(m3, COMP_LEVEL_SIMPLE); + } + // Because background compilation is disabled, method should now be compiled if(!WHITE_BOX.isMethodCompiled(m3)) { throw new RuntimeException(m3 + " not compiled"); @@ -278,19 +279,4 @@ public class Test8009761 { System.out.println("PASSED " + c1); } } - - /** - * Checks if background compilation (-XX:+BackgroundCompilation) is enabled. - * @return True if background compilation is enabled, false otherwise - */ - private static boolean backgroundCompilationEnabled() { - HotSpotDiagnosticMXBean diagnostic = ManagementFactoryHelper.getDiagnosticMXBean(); - VMOption backgroundCompilation; - try { - backgroundCompilation = diagnostic.getVMOption("BackgroundCompilation"); - } catch (IllegalArgumentException e) { - return false; - } - return Boolean.valueOf(backgroundCompilation.getValue()); - } } diff --git a/hotspot/test/compiler/tiered/NonTieredLevelsTest.java b/hotspot/test/compiler/tiered/NonTieredLevelsTest.java index 13411a0dd73..08321b87266 100644 --- a/hotspot/test/compiler/tiered/NonTieredLevelsTest.java +++ b/hotspot/test/compiler/tiered/NonTieredLevelsTest.java @@ -25,6 +25,7 @@ import java.util.function.IntPredicate; /** * @test NonTieredLevelsTest + * @ignore 8046268 * @library /testlibrary /testlibrary/whitebox /compiler/whitebox * @build NonTieredLevelsTest * @run main ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/tiered/TieredLevelsTest.java b/hotspot/test/compiler/tiered/TieredLevelsTest.java index 9fb2254d0b5..4b9a0a4a906 100644 --- a/hotspot/test/compiler/tiered/TieredLevelsTest.java +++ b/hotspot/test/compiler/tiered/TieredLevelsTest.java @@ -23,6 +23,7 @@ /** * @test TieredLevelsTest + * @ignore 8046268 * @library /testlibrary /testlibrary/whitebox /compiler/whitebox * @build TieredLevelsTest * @run main ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/whitebox/ClearMethodStateTest.java b/hotspot/test/compiler/whitebox/ClearMethodStateTest.java index 89fff68460f..195221658cf 100644 --- a/hotspot/test/compiler/whitebox/ClearMethodStateTest.java +++ b/hotspot/test/compiler/whitebox/ClearMethodStateTest.java @@ -25,6 +25,7 @@ import java.util.function.Function; /* * @test ClearMethodStateTest + * @ignore 8046268 * @bug 8006683 8007288 8022832 * @library /testlibrary /testlibrary/whitebox * @build ClearMethodStateTest diff --git a/hotspot/test/compiler/whitebox/DeoptimizeAllTest.java b/hotspot/test/compiler/whitebox/DeoptimizeAllTest.java index ea4e36400eb..a5b9d794c66 100644 --- a/hotspot/test/compiler/whitebox/DeoptimizeAllTest.java +++ b/hotspot/test/compiler/whitebox/DeoptimizeAllTest.java @@ -23,6 +23,7 @@ /* * @test DeoptimizeAllTest + * @ignore 8046268 * @bug 8006683 8007288 8022832 * @library /testlibrary /testlibrary/whitebox * @build DeoptimizeAllTest diff --git a/hotspot/test/compiler/whitebox/DeoptimizeMethodTest.java b/hotspot/test/compiler/whitebox/DeoptimizeMethodTest.java index 0b9ffd2d9db..e257a1e5e25 100644 --- a/hotspot/test/compiler/whitebox/DeoptimizeMethodTest.java +++ b/hotspot/test/compiler/whitebox/DeoptimizeMethodTest.java @@ -23,6 +23,7 @@ /* * @test DeoptimizeMethodTest + * @ignore 8046268 * @bug 8006683 8007288 8022832 * @library /testlibrary /testlibrary/whitebox * @build DeoptimizeMethodTest diff --git a/hotspot/test/compiler/whitebox/EnqueueMethodForCompilationTest.java b/hotspot/test/compiler/whitebox/EnqueueMethodForCompilationTest.java index d9139dd3674..4acebb2b123 100644 --- a/hotspot/test/compiler/whitebox/EnqueueMethodForCompilationTest.java +++ b/hotspot/test/compiler/whitebox/EnqueueMethodForCompilationTest.java @@ -23,6 +23,7 @@ /* * @test EnqueueMethodForCompilationTest + * @ignore 8046268 * @bug 8006683 8007288 8022832 * @library /testlibrary /testlibrary/whitebox * @build EnqueueMethodForCompilationTest diff --git a/hotspot/test/compiler/whitebox/GetNMethodTest.java b/hotspot/test/compiler/whitebox/GetNMethodTest.java index bb95f01b991..9800f3a3eb3 100644 --- a/hotspot/test/compiler/whitebox/GetNMethodTest.java +++ b/hotspot/test/compiler/whitebox/GetNMethodTest.java @@ -26,6 +26,7 @@ import sun.hotspot.code.NMethod; /* * @test GetNMethodTest + * @ignore 8046268 * @bug 8038240 * @library /testlibrary /testlibrary/whitebox * @build GetNMethodTest diff --git a/hotspot/test/compiler/whitebox/MakeMethodNotCompilableTest.java b/hotspot/test/compiler/whitebox/MakeMethodNotCompilableTest.java index d6586879778..604175c38ef 100644 --- a/hotspot/test/compiler/whitebox/MakeMethodNotCompilableTest.java +++ b/hotspot/test/compiler/whitebox/MakeMethodNotCompilableTest.java @@ -23,6 +23,7 @@ /* * @test MakeMethodNotCompilableTest + * @ignore 8046268 * @bug 8012322 8006683 8007288 8022832 * @library /testlibrary /testlibrary/whitebox * @build MakeMethodNotCompilableTest diff --git a/hotspot/test/gc/g1/TestDeferredRSUpdate.java b/hotspot/test/gc/g1/TestDeferredRSUpdate.java new file mode 100644 index 00000000000..7d2ebdc4eb3 --- /dev/null +++ b/hotspot/test/gc/g1/TestDeferredRSUpdate.java @@ -0,0 +1,78 @@ +/* + * 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test TestDeferredRSUpdate + * @bug 8040977 + * @summary Ensure that running with -XX:-G1DeferredRSUpdate does not crash the VM + * @key gc + * @library /testlibrary + */ + +import com.oracle.java.testlibrary.ProcessTools; +import com.oracle.java.testlibrary.OutputAnalyzer; + +public class TestDeferredRSUpdate { + public static void main(String[] args) throws Exception { + GCTest.main(args); + + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC", + "-Xmx10M", + // G1DeferredRSUpdate is a develop option, but we cannot limit execution of this test to only debug VMs. + "-XX:+IgnoreUnrecognizedVMOptions", + "-XX:-G1DeferredRSUpdate", + GCTest.class.getName()); + + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.shouldHaveExitValue(0); + } + + static class GCTest { + private static Object[] garbage = new Object[32]; + + public static void main(String [] args) { + System.out.println("Creating garbage"); + // Create 128MB of garbage. This should result in at least one minor GC, with + // some objects copied to old gen. As references from old to young are installed, + // the crash due to the use before initialize occurs. + Object prev = null; + Object prevPrev = null; + for (int i = 0; i < 1024; i++) { + Object[] next = new Object[32 * 1024]; + next[0] = prev; + next[1] = prevPrev; + + Object[] cur = (Object[]) garbage[i % garbage.length]; + if (cur != null) { + cur[0] = null; + cur[1] = null; + } + garbage[i % garbage.length] = next; + + prevPrev = prev; + prev = next; + } + System.out.println("Done"); + } + } +} diff --git a/hotspot/test/runtime/6626217/Test6626217.sh b/hotspot/test/runtime/6626217/Test6626217.sh index 52031ed7beb..99ee83a06ec 100644 --- a/hotspot/test/runtime/6626217/Test6626217.sh +++ b/hotspot/test/runtime/6626217/Test6626217.sh @@ -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 @@ -54,7 +54,7 @@ sleep 2 # Compile all the usual suspects, including the default 'many_loader' ${CP} many_loader1.java.foo many_loader.java -${JAVAC} ${TESTJAVACOPTS} -source 1.4 -target 1.4 -Xlint *.java +${JAVAC} ${TESTJAVACOPTS} -Xlint *.java # Rename the class files, so the custom loader (and not the system loader) will find it ${MV} from_loader2.class from_loader2.impl2 @@ -62,7 +62,7 @@ ${MV} from_loader2.class from_loader2.impl2 # Compile the next version of 'many_loader' ${MV} many_loader.class many_loader.impl1 ${CP} many_loader2.java.foo many_loader.java -${JAVAC} ${TESTJAVACOPTS} -source 1.4 -target 1.4 -Xlint many_loader.java +${JAVAC} ${TESTJAVACOPTS} -Xlint many_loader.java # Rename the class file, so the custom loader (and not the system loader) will find it ${MV} many_loader.class many_loader.impl2 diff --git a/hotspot/test/runtime/8003720/Test8003720.java b/hotspot/test/runtime/8003720/Test8003720.java index 88682712a2a..0963628a80a 100644 --- a/hotspot/test/runtime/8003720/Test8003720.java +++ b/hotspot/test/runtime/8003720/Test8003720.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 @@ -26,7 +26,7 @@ * @test * @bug 8003720 * @summary Method in interpreter stack frame can be deallocated - * @compile -XDignore.symbol.file -source 1.7 -target 1.7 Victim.java + * @compile -XDignore.symbol.file Victim.java * @run main/othervm -Xverify:all -Xint Test8003720 */ diff --git a/hotspot/test/runtime/CommandLine/TraceExceptionsTest.java b/hotspot/test/runtime/CommandLine/TraceExceptionsTest.java new file mode 100644 index 00000000000..8cba4a5bf72 --- /dev/null +++ b/hotspot/test/runtime/CommandLine/TraceExceptionsTest.java @@ -0,0 +1,48 @@ +/* + * 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8048933 + * @summary TraceExceptions output should have the exception message - useful for ClassNotFoundExceptions especially + * @library /testlibrary + */ + +import com.oracle.java.testlibrary.*; + +public class TraceExceptionsTest { + public static void main(String[] args) throws Exception { + + if (!Platform.isDebugBuild()) { + System.out.println("Skip the test on product builds since XX:+TraceExceptions is not available on product builds"); + return; + } + + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + "-XX:+TraceExceptions", "NoClassFound"); + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.shouldContain(""); + output.shouldNotContain(""); + output.shouldHaveExitValue(1); + } +} diff --git a/hotspot/test/runtime/verifier/OverriderMsg.java b/hotspot/test/runtime/verifier/OverriderMsg.java new file mode 100644 index 00000000000..f8c7155ee57 --- /dev/null +++ b/hotspot/test/runtime/verifier/OverriderMsg.java @@ -0,0 +1,131 @@ +/* + * 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.io.File; +import java.io.FileOutputStream; +import jdk.internal.org.objectweb.asm.ClassWriter; +import jdk.internal.org.objectweb.asm.MethodVisitor; +import static jdk.internal.org.objectweb.asm.Opcodes.*; +import com.oracle.java.testlibrary.*; + +/* + * @test OverriderMsg + * @bug 8026894 + * @library /testlibrary + * @compile -XDignore.symbol.file OverriderMsg.java + * @run main/othervm OverriderMsg + */ + +// This test checks that the super class name is included in the message when +// a method is detected overriding a final method in its super class. The +// asm part of the test creates these two classes: +// +// public class HasFinal { +// public final void m(String s) { } +// } +// +// public class Overrider extends HasFinal { +// public void m(String s) { } +// public static void main(String[] args) { } +// } +// +public class OverriderMsg { + + public static void dump_HasFinal () throws Exception { + + ClassWriter cw = new ClassWriter(0); + MethodVisitor mv; + + cw.visit(V1_7, ACC_PUBLIC + ACC_SUPER, "HasFinal", null, "java/lang/Object", null); + + { + mv = cw.visitMethod(ACC_PUBLIC, "", "()V", null, null); + mv.visitCode(); + mv.visitVarInsn(ALOAD, 0); + mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "", "()V"); + mv.visitInsn(RETURN); + mv.visitMaxs(1, 1); + mv.visitEnd(); + } + { + mv = cw.visitMethod(ACC_PUBLIC + ACC_FINAL, "m", "(Ljava/lang/String;)V", null, null); + mv.visitCode(); + mv.visitInsn(RETURN); + mv.visitMaxs(0, 2); + mv.visitEnd(); + } + cw.visitEnd(); + try (FileOutputStream fos = new FileOutputStream(new File("HasFinal.class"))) { + fos.write(cw.toByteArray()); + } + } + + + public static void dump_Overrider () throws Exception { + + ClassWriter cw = new ClassWriter(0); + MethodVisitor mv; + cw.visit(V1_7, ACC_PUBLIC + ACC_SUPER, "Overrider", null, "HasFinal", null); + + { + mv = cw.visitMethod(ACC_PUBLIC, "", "()V", null, null); + mv.visitCode(); + mv.visitVarInsn(ALOAD, 0); + mv.visitMethodInsn(INVOKESPECIAL, "HasFinal", "", "()V"); + mv.visitInsn(RETURN); + mv.visitMaxs(1, 1); + mv.visitEnd(); + } + { + mv = cw.visitMethod(ACC_PUBLIC, "m", "(Ljava/lang/String;)V", null, null); + mv.visitCode(); + mv.visitInsn(RETURN); + mv.visitMaxs(0, 2); + mv.visitEnd(); + } + { + mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "main", "([Ljava/lang/String;)V", null, null); + mv.visitCode(); + mv.visitInsn(RETURN); + mv.visitMaxs(0, 1); + mv.visitEnd(); + } + cw.visitEnd(); + + try (FileOutputStream fos = new FileOutputStream(new File("Overrider.class"))) { + fos.write(cw.toByteArray()); + } + } + + + public static void main(String... args) throws Exception { + dump_HasFinal(); + dump_Overrider(); + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, "-cp", ".", "Overrider"); + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.shouldContain( + "java.lang.VerifyError: class Overrider overrides final method HasFinal.m(Ljava/lang/String;)V"); + output.shouldHaveExitValue(1); + } + +} diff --git a/hotspot/test/testlibrary/whitebox/sun/hotspot/WhiteBox.java b/hotspot/test/testlibrary/whitebox/sun/hotspot/WhiteBox.java index 8c817182e4c..bc38438285e 100644 --- a/hotspot/test/testlibrary/whitebox/sun/hotspot/WhiteBox.java +++ b/hotspot/test/testlibrary/whitebox/sun/hotspot/WhiteBox.java @@ -142,6 +142,8 @@ public class WhiteBox { // Memory public native void readReservedMemory(); + public native long allocateMetaspace(ClassLoader classLoader, long size); + public native void freeMetaspace(ClassLoader classLoader, long addr, long size); // force Full GC public native void fullGC(); diff --git a/jaxp/.hgtags b/jaxp/.hgtags index 0bc9cacf9a9..710410b142d 100644 --- a/jaxp/.hgtags +++ b/jaxp/.hgtags @@ -261,3 +261,7 @@ e88cecf5a21b760ff7d7761c2db6bb8c82bc9f0c jdk9-b12 a1461221b05d4620e4d7d1907e2a0282aaedf31c jdk9-b16 6f923fcbe5129eceb9617a9a18dbdd743980e785 jdk9-b17 5afa90c28742d175431be75f9098745510bd2b30 jdk9-b18 +f9c82769a6bc2b219a8f01c24afe5c91039267d7 jdk9-b19 +94fd4d9d3a75819644b21e18c8a567fd0e973eaf jdk9-b20 +7eb0ab676ea75cb1dd31c613e77008a7d8cb0af7 jdk9-b21 +82b94ff002c6e007a03bf0f364ca94b381e09135 jdk9-b22 diff --git a/jaxp/src/com/sun/org/apache/bcel/internal/classfile/JavaClass.java b/jaxp/src/com/sun/org/apache/bcel/internal/classfile/JavaClass.java index 4d28f2a92f5..db83c73b299 100644 --- a/jaxp/src/com/sun/org/apache/bcel/internal/classfile/JavaClass.java +++ b/jaxp/src/com/sun/org/apache/bcel/internal/classfile/JavaClass.java @@ -78,7 +78,6 @@ import java.util.StringTokenizer; * class file. Those interested in programatically generating classes * should see the ClassGen class. - * @version $Id: JavaClass.java,v 1.4 2007-07-19 04:34:42 ofung Exp $ * @see com.sun.org.apache.bcel.internal.generic.ClassGen * @author M. Dahm */ diff --git a/jaxp/src/com/sun/org/apache/bcel/internal/util/Class2HTML.java b/jaxp/src/com/sun/org/apache/bcel/internal/util/Class2HTML.java index 5a9e094d460..52b9df945c7 100644 --- a/jaxp/src/com/sun/org/apache/bcel/internal/util/Class2HTML.java +++ b/jaxp/src/com/sun/org/apache/bcel/internal/util/Class2HTML.java @@ -82,7 +82,6 @@ import com.sun.org.apache.bcel.internal.Constants; * method in the Method's frame will jump to the appropiate method in * the Code frame. * - * @version $Id: Class2HTML.java,v 1.3 2007-07-19 04:34:52 ofung Exp $ * @author M. Dahm */ public class Class2HTML implements Constants diff --git a/jaxp/src/com/sun/org/apache/bcel/internal/util/ClassPath.java b/jaxp/src/com/sun/org/apache/bcel/internal/util/ClassPath.java index 0cd5021ddb1..ac4745ea97f 100644 --- a/jaxp/src/com/sun/org/apache/bcel/internal/util/ClassPath.java +++ b/jaxp/src/com/sun/org/apache/bcel/internal/util/ClassPath.java @@ -66,7 +66,6 @@ import java.io.*; * Responsible for loading (class) files from the CLASSPATH. Inspired by * sun.tools.ClassPath. * - * @version $Id: ClassPath.java,v 1.4 2007-07-19 04:34:52 ofung Exp $ * @author M. Dahm */ public class ClassPath implements Serializable { diff --git a/jaxp/src/com/sun/org/apache/bcel/internal/util/JavaWrapper.java b/jaxp/src/com/sun/org/apache/bcel/internal/util/JavaWrapper.java index 1540f6d5c8b..d264b047ba1 100644 --- a/jaxp/src/com/sun/org/apache/bcel/internal/util/JavaWrapper.java +++ b/jaxp/src/com/sun/org/apache/bcel/internal/util/JavaWrapper.java @@ -72,7 +72,6 @@ import java.lang.reflect.*; *
java com.sun.org.apache.bcel.internal.util.JavaWrapper -Dbcel.classloader=foo.MyLoader <real.class.name> [arguments]
*

* - * @version $Id: JavaWrapper.java,v 1.3 2007-07-19 04:34:52 ofung Exp $ * @author M. Dahm * @see ClassLoader */ diff --git a/jaxp/src/com/sun/org/apache/xalan/internal/XalanConstants.java b/jaxp/src/com/sun/org/apache/xalan/internal/XalanConstants.java index 095a6e74b96..9b3b0fa46cd 100644 --- a/jaxp/src/com/sun/org/apache/xalan/internal/XalanConstants.java +++ b/jaxp/src/com/sun/org/apache/xalan/internal/XalanConstants.java @@ -32,7 +32,6 @@ import com.sun.org.apache.xalan.internal.utils.SecuritySupport; * * @author Huizhe Wang, Oracle * - * @version $Id: Constants.java,v 1.14 2011-06-07 04:39:40 joehw Exp $ */ public final class XalanConstants { diff --git a/jaxp/src/com/sun/org/apache/xalan/internal/utils/ObjectFactory.java b/jaxp/src/com/sun/org/apache/xalan/internal/utils/ObjectFactory.java index 034d8eec84b..7d5d104501d 100644 --- a/jaxp/src/com/sun/org/apache/xalan/internal/utils/ObjectFactory.java +++ b/jaxp/src/com/sun/org/apache/xalan/internal/utils/ObjectFactory.java @@ -32,7 +32,6 @@ package com.sun.org.apache.xalan.internal.utils; * class and modified to be used as a general utility for creating objects * dynamically. * - * @version $Id: ObjectFactory.java,v 1.11 2010-11-01 04:34:25 joehw Exp $ */ public class ObjectFactory { diff --git a/jaxp/src/com/sun/org/apache/xalan/internal/xslt/EnvironmentCheck.java b/jaxp/src/com/sun/org/apache/xalan/internal/xslt/EnvironmentCheck.java index 928da3e9e9d..a6b99891be4 100644 --- a/jaxp/src/com/sun/org/apache/xalan/internal/xslt/EnvironmentCheck.java +++ b/jaxp/src/com/sun/org/apache/xalan/internal/xslt/EnvironmentCheck.java @@ -92,7 +92,6 @@ import org.w3c.dom.Node; * of thing but in a much simpler manner.

* * @author Shane_Curcuru@us.ibm.com - * @version $Id: EnvironmentCheck.java,v 1.10 2010-11-01 04:34:13 joehw Exp $ */ public class EnvironmentCheck { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/dom/AttrImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/dom/AttrImpl.java index 352fba6a18c..873f7be9842 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/dom/AttrImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/dom/AttrImpl.java @@ -109,7 +109,6 @@ import org.w3c.dom.Text; * @author Arnaud Le Hors, IBM * @author Joe Kesselman, IBM * @author Andy Clark, IBM - * @version $Id: AttrImpl.java,v 1.5 2008/06/10 00:59:32 joehw Exp $ * @since PR-DOM-Level-1-19980818. * */ diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/dom/AttrNSImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/dom/AttrNSImpl.java index 7defc559d01..34de50dccde 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/dom/AttrNSImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/dom/AttrNSImpl.java @@ -37,7 +37,6 @@ import org.w3c.dom.DOMException; * @author Arnaud Le Hors, IBM * @author Andy Clark, IBM * @author Ralf Pfeiffer, IBM - * @version $Id: AttrNSImpl.java,v 1.7 2010-11-01 04:39:37 joehw Exp $ */ public class AttrNSImpl extends AttrImpl { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/dom/AttributeMap.java b/jaxp/src/com/sun/org/apache/xerces/internal/dom/AttributeMap.java index 8d2d054fccc..5f7f4e17340 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/dom/AttributeMap.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/dom/AttributeMap.java @@ -40,7 +40,6 @@ import org.w3c.dom.Node; * * @xerces.internal * - * @version $Id: AttributeMap.java,v 1.7 2010-11-01 04:39:37 joehw Exp $ */ public class AttributeMap extends NamedNodeMapImpl { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/dom/CoreDOMImplementationImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/dom/CoreDOMImplementationImpl.java index f20775e3f7a..45b91dc9aa2 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/dom/CoreDOMImplementationImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/dom/CoreDOMImplementationImpl.java @@ -52,7 +52,6 @@ import org.w3c.dom.ls.LSSerializer; * * @xerces.internal * - * @version $Id: CoreDOMImplementationImpl.java,v 1.6 2010-11-01 04:39:37 joehw Exp $ * @since PR-DOM-Level-1-19980818. */ public class CoreDOMImplementationImpl diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/dom/CoreDocumentImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/dom/CoreDocumentImpl.java index 46cbc349ff4..2fb6f8b225d 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/dom/CoreDocumentImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/dom/CoreDocumentImpl.java @@ -79,7 +79,6 @@ import org.w3c.dom.ls.LSSerializer; * @author Joe Kesselman, IBM * @author Andy Clark, IBM * @author Ralf Pfeiffer, IBM - * @version $Id: CoreDocumentImpl.java,v 1.9 2010-11-01 04:39:37 joehw Exp $ * @since PR-DOM-Level-1-19980818. */ diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/dom/DOMConfigurationImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/dom/DOMConfigurationImpl.java index 1e8dcd98817..189abdff259 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/dom/DOMConfigurationImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/dom/DOMConfigurationImpl.java @@ -68,7 +68,6 @@ import org.w3c.dom.ls.LSResourceResolver; * * @author Elena Litani, IBM * @author Neeraj Bajaj, Sun Microsystems. - * @version $Id: DOMConfigurationImpl.java,v 1.9 2010-11-01 04:39:37 joehw Exp $ */ public class DOMConfigurationImpl extends ParserConfigurationSettings implements XMLParserConfiguration, DOMConfiguration { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/dom/DOMMessageFormatter.java b/jaxp/src/com/sun/org/apache/xerces/internal/dom/DOMMessageFormatter.java index f7d131fdb9b..1d30c9e76b4 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/dom/DOMMessageFormatter.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/dom/DOMMessageFormatter.java @@ -31,7 +31,6 @@ import java.util.ResourceBundle; * @xerces.internal * * @author Sandy Gao, IBM - * @version $Id: DOMMessageFormatter.java,v 1.6 2010-11-01 04:39:38 joehw Exp $ */ public class DOMMessageFormatter { public static final String DOM_DOMAIN = "http://www.w3.org/dom/DOMTR"; diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/dom/DOMNormalizer.java b/jaxp/src/com/sun/org/apache/xerces/internal/dom/DOMNormalizer.java index 3758f399230..651bd741432 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/dom/DOMNormalizer.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/dom/DOMNormalizer.java @@ -94,7 +94,6 @@ import org.w3c.dom.Text; * * @author Elena Litani, IBM * @author Neeraj Bajaj, Sun Microsystems, inc. - * @version $Id: DOMNormalizer.java,v 1.9 2010-11-01 04:39:38 joehw Exp $ */ public class DOMNormalizer implements XMLDocumentHandler { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/dom/DeferredDocumentImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/dom/DeferredDocumentImpl.java index 92c03b0baad..8f133b8799a 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/dom/DeferredDocumentImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/dom/DeferredDocumentImpl.java @@ -40,7 +40,6 @@ import org.w3c.dom.Node; * * @xerces.internal * - * @version $Id: DeferredDocumentImpl.java,v 1.11 2010-11-01 04:39:38 joehw Exp $ * @since PR-DOM-Level-1-19980818. */ public class DeferredDocumentImpl diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/dom/DocumentImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/dom/DocumentImpl.java index 4cc06483c56..55d43c6df90 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/dom/DocumentImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/dom/DocumentImpl.java @@ -76,7 +76,6 @@ import org.w3c.dom.traversal.TreeWalker; * @author Joe Kesselman, IBM * @author Andy Clark, IBM * @author Ralf Pfeiffer, IBM - * @version $Id: DocumentImpl.java,v 1.6 2010/07/20 20:25:24 joehw Exp $ * @since PR-DOM-Level-1-19980818. */ public class DocumentImpl diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/dom/ElementNSImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/dom/ElementNSImpl.java index 35757db0911..042835e7ce6 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/dom/ElementNSImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/dom/ElementNSImpl.java @@ -42,7 +42,6 @@ import org.w3c.dom.DOMException; * * @author Elena litani, IBM * @author Neeraj Bajaj, Sun Microsystems - * @version $Id: ElementNSImpl.java,v 1.7 2010-11-01 04:39:39 joehw Exp $ */ public class ElementNSImpl extends ElementImpl { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/dom/NamedNodeMapImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/dom/NamedNodeMapImpl.java index fcf40479703..f3e0c942758 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/dom/NamedNodeMapImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/dom/NamedNodeMapImpl.java @@ -56,7 +56,6 @@ import org.w3c.dom.Node; * * @xerces.internal * - * @version $Id: NamedNodeMapImpl.java,v 1.8 2010-11-01 04:39:39 joehw Exp $ * @since PR-DOM-Level-1-19980818. */ public class NamedNodeMapImpl diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/dom/NodeListCache.java b/jaxp/src/com/sun/org/apache/xerces/internal/dom/NodeListCache.java index e0923ce9960..585c41e6364 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/dom/NodeListCache.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/dom/NodeListCache.java @@ -30,7 +30,6 @@ import java.io.Serializable; * * @author Arnaud Le Hors, IBM * - * @version $Id: NodeListCache.java,v 1.6 2010/07/20 20:25:25 joehw Exp $ */ class NodeListCache implements Serializable { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/dom/PSVIElementNSImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/dom/PSVIElementNSImpl.java index 7b26a9ad96c..272a7c93a18 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/dom/PSVIElementNSImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/dom/PSVIElementNSImpl.java @@ -35,7 +35,6 @@ import com.sun.org.apache.xerces.internal.xs.*; * * @author Sandy Gao, IBM * - * @version $Id: PSVIElementNSImpl.java,v 1.6 2010/08/20 18:51:54 joehw Exp $ */ public class PSVIElementNSImpl extends ElementNSImpl implements ElementPSVI { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/dom/ParentNode.java b/jaxp/src/com/sun/org/apache/xerces/internal/dom/ParentNode.java index 7725c4c530d..3481afe1f6a 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/dom/ParentNode.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/dom/ParentNode.java @@ -68,7 +68,6 @@ import org.w3c.dom.UserDataHandler; * @author Arnaud Le Hors, IBM * @author Joe Kesselman, IBM * @author Andy Clark, IBM - * @version $Id: ParentNode.java,v 1.6 2009/07/21 20:30:28 joehw Exp $ */ public abstract class ParentNode extends ChildNode { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/Constants.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/Constants.java index 4eab0fadfe9..147a3ab43a6 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/Constants.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/Constants.java @@ -31,7 +31,6 @@ import java.util.NoSuchElementException; * * @author Andy Clark, IBM * - * @version $Id: Constants.java,v 1.14 2010-11-01 04:39:40 joehw Exp $ */ public final class Constants { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/Version.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/Version.java index ac62db7dc26..41a2b620b5c 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/Version.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/Version.java @@ -64,7 +64,6 @@ package com.sun.org.apache.xerces.internal.impl; /** * This class defines the version number of the parser. * - * @version $Id: Version.java,v 1.4 2010-11-01 04:39:40 joehw Exp $ */ public class Version { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XML11DocumentScannerImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XML11DocumentScannerImpl.java index dda470ae873..cf5f3b9059b 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XML11DocumentScannerImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XML11DocumentScannerImpl.java @@ -96,7 +96,6 @@ import com.sun.org.apache.xerces.internal.xni.XNIException; * @author Arnaud Le Hors, IBM * @author Eric Ye, IBM * - * @version $Id: XML11DocumentScannerImpl.java,v 1.5 2010/08/04 20:59:09 joehw Exp $ */ public class XML11DocumentScannerImpl extends XMLDocumentScannerImpl { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XML11EntityScanner.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XML11EntityScanner.java index 518c09ab7f6..130c6227511 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XML11EntityScanner.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XML11EntityScanner.java @@ -77,7 +77,6 @@ import java.io.IOException; * * @author Michael Glavassevich, IBM * @author Neil Graham, IBM - * @version $Id: XML11EntityScanner.java,v 1.5 2010-11-01 04:39:40 joehw Exp $ */ public class XML11EntityScanner diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XML11NSDocumentScannerImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XML11NSDocumentScannerImpl.java index 7a826dfcc97..7d6b3cbd043 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XML11NSDocumentScannerImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XML11NSDocumentScannerImpl.java @@ -108,7 +108,6 @@ import javax.xml.stream.events.XMLEvent; * @author Elena Litani, IBM * @author Michael Glavassevich, IBM * @author Sunitha Reddy, Sun Microsystems - * @version $Id: XML11NSDocumentScannerImpl.java,v 1.6 2010-11-01 04:39:40 joehw Exp $ */ public class XML11NSDocumentScannerImpl extends XML11DocumentScannerImpl { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLDTDScannerImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLDTDScannerImpl.java index d2ede948ac1..74db88ca6cd 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLDTDScannerImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLDTDScannerImpl.java @@ -69,7 +69,6 @@ import com.sun.xml.internal.stream.Entity; * @author Glenn Marcy, IBM * @author Eric Ye, IBM * - * @version $Id: XMLDTDScannerImpl.java,v 1.8 2010-11-01 04:39:41 joehw Exp $ */ public class XMLDTDScannerImpl extends XMLScanner diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java index 01468284cd1..fc8b5098a57 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java @@ -78,7 +78,6 @@ import javax.xml.stream.events.XMLEvent; * @author Arnaud Le Hors, IBM * @author Eric Ye, IBM * @author Sunitha Reddy, SUN Microsystems - * @version $Id: XMLDocumentFragmentScannerImpl.java,v 1.19 2010-11-02 19:54:55 joehw Exp $ * */ public class XMLDocumentFragmentScannerImpl diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLDocumentScannerImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLDocumentScannerImpl.java index c2d58bd4070..d191de9ba89 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLDocumentScannerImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLDocumentScannerImpl.java @@ -65,7 +65,6 @@ import javax.xml.stream.events.XMLEvent; * Refer to the table in unit-test javax.xml.stream.XMLStreamReaderTest.SupportDTD for changes * related to property SupportDTD. * @author Joe Wang, Sun Microsystems - * @version $Id: XMLDocumentScannerImpl.java,v 1.17 2010-11-01 04:39:41 joehw Exp $ */ public class XMLDocumentScannerImpl extends XMLDocumentFragmentScannerImpl{ diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java index 988fd6f9c60..7a70b3abece 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java @@ -83,7 +83,6 @@ import java.util.StringTokenizer; * @author K.Venugopal SUN Microsystems * @author Neeraj Bajaj SUN Microsystems * @author Sunitha Reddy SUN Microsystems - * @version $Id: XMLEntityManager.java,v 1.17 2010-11-01 04:39:41 joehw Exp $ */ public class XMLEntityManager implements XMLComponent, XMLEntityResolver { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLErrorReporter.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLErrorReporter.java index 8d0ed6d76fd..e6ce89d3816 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLErrorReporter.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLErrorReporter.java @@ -111,7 +111,6 @@ import org.xml.sax.ErrorHandler; * @author Eric Ye, IBM * @author Andy Clark, IBM * - * @version $Id: XMLErrorReporter.java,v 1.5 2010-11-01 04:39:41 joehw Exp $ */ public class XMLErrorReporter implements XMLComponent { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLNSDocumentScannerImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLNSDocumentScannerImpl.java index 66b8179b97b..36d72ac51df 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLNSDocumentScannerImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLNSDocumentScannerImpl.java @@ -58,7 +58,6 @@ import javax.xml.stream.events.XMLEvent; * @author Neeraj Bajaj, Sun Microsystems * @author Venugopal Rao K, Sun Microsystems * @author Elena Litani, IBM - * @version $Id: XMLNSDocumentScannerImpl.java,v 1.11 2010-11-01 04:39:41 joehw Exp $ */ public class XMLNSDocumentScannerImpl extends XMLDocumentScannerImpl { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLNamespaceBinder.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLNamespaceBinder.java index 13c27bc8fed..33a18a84444 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLNamespaceBinder.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLNamespaceBinder.java @@ -97,7 +97,6 @@ import com.sun.org.apache.xerces.internal.xni.parser.XMLDocumentSource; * * @author Andy Clark, IBM * - * @version $Id: XMLNamespaceBinder.java,v 1.4 2010-11-01 04:39:41 joehw Exp $ */ public class XMLNamespaceBinder implements XMLComponent, XMLDocumentFilter { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLScanner.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLScanner.java index 0cb44b2c0c0..28fbc69270e 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLScanner.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLScanner.java @@ -69,7 +69,6 @@ import com.sun.xml.internal.stream.Entity; * @author Eric Ye, IBM * @author K.Venugopal SUN Microsystems * @author Sunitha Reddy, SUN Microsystems - * @version $Id: XMLScanner.java,v 1.12 2010-11-01 04:39:41 joehw Exp $ */ public abstract class XMLScanner implements XMLComponent { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/BalancedDTDGrammar.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/BalancedDTDGrammar.java index 0b09e34ffc1..c144a2490b6 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/BalancedDTDGrammar.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/BalancedDTDGrammar.java @@ -32,7 +32,6 @@ import com.sun.org.apache.xerces.internal.xni.XNIException; * @xerces.internal * * @author Michael Glavassevich, IBM - * @version $Id: BalancedDTDGrammar.java,v 1.1 2010/08/11 07:18:38 joehw Exp $ */ final class BalancedDTDGrammar extends DTDGrammar { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/DTDGrammar.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/DTDGrammar.java index 71a9231f71b..f0478f45fb8 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/DTDGrammar.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/DTDGrammar.java @@ -101,7 +101,6 @@ import com.sun.org.apache.xerces.internal.xni.parser.XMLDTDSource; * @author Andy Clark, IBM * @author Neil Graham, IBM * - * @version $Id: DTDGrammar.java,v 1.4 2010/08/11 07:18:37 joehw Exp $ */ public class DTDGrammar implements XMLDTDHandler, XMLDTDContentModelHandler, EntityState, Grammar { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/XMLDTDDescription.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/XMLDTDDescription.java index b9e48e9225e..90a55affe91 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/XMLDTDDescription.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/XMLDTDDescription.java @@ -75,7 +75,6 @@ import com.sun.org.apache.xerces.internal.util.XMLResourceIdentifierImpl; * @xerces.internal * * @author Neil Graham, IBM - * @version $Id: XMLDTDDescription.java,v 1.4 2010/08/11 07:18:38 joehw Exp $ */ public class XMLDTDDescription extends XMLResourceIdentifierImpl implements com.sun.org.apache.xerces.internal.xni.grammars.XMLDTDDescription { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/XMLDTDLoader.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/XMLDTDLoader.java index ea343942ea5..eea1b94613f 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/XMLDTDLoader.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/XMLDTDLoader.java @@ -108,7 +108,6 @@ import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource; * @author Neil Graham, IBM * @author Michael Glavassevich, IBM * - * @version $Id: XMLDTDLoader.java,v 1.6 2010-11-01 04:39:42 joehw Exp $ */ public class XMLDTDLoader extends XMLDTDProcessor diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/XMLDTDProcessor.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/XMLDTDProcessor.java index 45e1b31e0bc..85bdb7f74c5 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/XMLDTDProcessor.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/XMLDTDProcessor.java @@ -113,7 +113,6 @@ import com.sun.org.apache.xerces.internal.xni.parser.XMLDTDSource; * * @author Neil Graham, IBM * - * @version $Id: XMLDTDProcessor.java,v 1.5 2010-11-01 04:39:42 joehw Exp $ */ public class XMLDTDProcessor implements XMLComponent, XMLDTDFilter, XMLDTDContentModelFilter { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/XMLDTDValidator.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/XMLDTDValidator.java index 05308782e62..01c8c54f7a7 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/XMLDTDValidator.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/XMLDTDValidator.java @@ -83,7 +83,6 @@ import com.sun.org.apache.xerces.internal.xni.parser.XMLDocumentSource; * @author Jeffrey Rodriguez IBM * @author Neil Graham, IBM * - * @version $Id: XMLDTDValidator.java,v 1.8 2010-11-01 04:39:42 joehw Exp $ */ public class XMLDTDValidator implements XMLComponent, XMLDocumentFilter, XMLDTDValidatorFilter, RevalidationHandler { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/models/DFAContentModel.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/models/DFAContentModel.java index 9a4e0f5c122..008bd6ff8fe 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/models/DFAContentModel.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/models/DFAContentModel.java @@ -68,7 +68,6 @@ import com.sun.org.apache.xerces.internal.xni.QName; /** - * @version $Id: DFAContentModel.java,v 1.4 2010/08/06 23:49:43 joehw Exp $ * DFAContentModel is the derivative of ContentModel that does * all of the non-trivial element content validation. This class does * the conversion from the regular expression to the DFA that @@ -82,7 +81,6 @@ import com.sun.org.apache.xerces.internal.xni.QName; * * @xerces.internal * - * @version $Id: DFAContentModel.java,v 1.4 2010/08/06 23:49:43 joehw Exp $ */ public class DFAContentModel implements ContentModelValidator { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/DTDDVFactory.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/DTDDVFactory.java index 15afa2e1407..fd7426f7551 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/DTDDVFactory.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/DTDDVFactory.java @@ -32,7 +32,6 @@ import com.sun.org.apache.xerces.internal.utils.ObjectFactory; * * @author Sandy Gao, IBM * - * @version $Id: DTDDVFactory.java,v 1.6 2010-11-01 04:39:43 joehw Exp $ */ public abstract class DTDDVFactory { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/DatatypeException.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/DatatypeException.java index f38b1d3797f..363b26844f3 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/DatatypeException.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/DatatypeException.java @@ -35,7 +35,6 @@ import java.util.MissingResourceException; * * @author Sandy Gao, IBM * - * @version $Id: DatatypeException.java,v 1.6 2010-11-01 04:39:43 joehw Exp $ */ public class DatatypeException extends Exception { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/SchemaDVFactory.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/SchemaDVFactory.java index 902d9d3fdea..47646f2dad2 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/SchemaDVFactory.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/SchemaDVFactory.java @@ -40,7 +40,6 @@ import com.sun.org.apache.xerces.internal.utils.ObjectFactory; * * @author Sandy Gao, IBM * - * @version $Id: SchemaDVFactory.java,v 1.6 2010-11-01 04:39:43 joehw Exp $ */ public abstract class SchemaDVFactory { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/ValidationContext.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/ValidationContext.java index 6ff4d66031e..da8d550a84a 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/ValidationContext.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/ValidationContext.java @@ -29,7 +29,6 @@ import java.util.Locale; * @xerces.internal * * @author Sandy Gao, IBM - * @version $Id: ValidationContext.java,v 1.6 2010/07/23 02:09:29 joehw Exp $ */ public interface ValidationContext { // whether to validate against facets diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/util/ByteListImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/util/ByteListImpl.java index 984fb2ab404..3357593489d 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/util/ByteListImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/util/ByteListImpl.java @@ -31,7 +31,6 @@ import com.sun.org.apache.xerces.internal.xs.datatypes.ByteList; * * @author Ankit Pasricha, IBM * - * @version $Id: ByteListImpl.java,v 1.7 2010-11-01 04:39:46 joehw Exp $ */ public class ByteListImpl extends AbstractList implements ByteList { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/AbstractDateTimeDV.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/AbstractDateTimeDV.java index d9d6587379b..64242a5cf95 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/AbstractDateTimeDV.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/AbstractDateTimeDV.java @@ -47,7 +47,6 @@ import com.sun.org.apache.xerces.internal.xs.datatypes.XSDateTime; * @author Len Berman * @author Gopal Sharma, SUN Microsystems Inc. * - * @version $Id: AbstractDateTimeDV.java,v 1.7 2010-11-01 04:39:46 joehw Exp $ */ public abstract class AbstractDateTimeDV extends TypeValidator { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/Base64BinaryDV.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/Base64BinaryDV.java index fcfa039df43..47185b1725d 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/Base64BinaryDV.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/Base64BinaryDV.java @@ -33,7 +33,6 @@ import com.sun.org.apache.xerces.internal.impl.dv.util.ByteListImpl; * @author Neeraj Bajaj, Sun Microsystems, inc. * @author Sandy Gao, IBM * - * @version $Id: Base64BinaryDV.java,v 1.7 2010-11-01 04:39:46 joehw Exp $ */ public class Base64BinaryDV extends TypeValidator { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/BaseDVFactory.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/BaseDVFactory.java index 198f3aba046..715b0ee040c 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/BaseDVFactory.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/BaseDVFactory.java @@ -35,7 +35,6 @@ import com.sun.org.apache.xerces.internal.xs.XSObjectList; * @author Neeraj Bajaj, Sun Microsystems, inc. * @author Sandy Gao, IBM * - * @version $Id: BaseDVFactory.java,v 1.7 2010-11-01 04:39:46 joehw Exp $ */ public class BaseDVFactory extends SchemaDVFactory { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/BaseSchemaDVFactory.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/BaseSchemaDVFactory.java index da30a8f5fed..3cc03f0b449 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/BaseSchemaDVFactory.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/BaseSchemaDVFactory.java @@ -38,7 +38,6 @@ import com.sun.org.apache.xerces.internal.xs.XSObjectList; * @author Sandy Gao, IBM * @author Khaled Noaman, IBM * - * @version $Id: BaseSchemaDVFactory.java,v 1.2 2010-10-26 23:01:03 joehw Exp $ */ public abstract class BaseSchemaDVFactory extends SchemaDVFactory { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DateDV.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DateDV.java index 01b0eabcf6d..d302e22fd1a 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DateDV.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DateDV.java @@ -34,7 +34,6 @@ import com.sun.org.apache.xerces.internal.impl.dv.ValidationContext; * @author Elena Litani * @author Gopal Sharma, SUN Microsystems Inc. * - * @version $Id: DateDV.java,v 1.7 2010-11-01 04:39:46 joehw Exp $ */ public class DateDV extends DateTimeDV { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DateTimeDV.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DateTimeDV.java index 6b2011d974d..2a19f8cec9f 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DateTimeDV.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DateTimeDV.java @@ -36,7 +36,6 @@ import com.sun.org.apache.xerces.internal.impl.dv.ValidationContext; * @author Elena Litani * @author Gopal Sharma, SUN Microsystem Inc. * - * @version $Id: DateTimeDV.java,v 1.7 2010-11-01 04:39:46 joehw Exp $ */ public class DateTimeDV extends AbstractDateTimeDV { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DayDV.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DayDV.java index 1e501f01be4..d0e6ce6021e 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DayDV.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DayDV.java @@ -33,7 +33,6 @@ import com.sun.org.apache.xerces.internal.impl.dv.ValidationContext; * * @author Elena Litani * @author Gopal Sharma, SUN Microsystem Inc. - * @version $Id: DayDV.java,v 1.7 2010-11-01 04:39:46 joehw Exp $ */ public class DayDV extends AbstractDateTimeDV { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DayTimeDurationDV.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DayTimeDurationDV.java index dd16f196cd3..8488503acee 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DayTimeDurationDV.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DayTimeDurationDV.java @@ -35,7 +35,6 @@ import com.sun.org.apache.xerces.internal.impl.dv.ValidationContext; * * @author Ankit Pasricha, IBM * - * @version $Id: DayTimeDurationDV.java,v 1.6 2010-11-01 04:39:46 joehw Exp $ */ class DayTimeDurationDV extends DurationDV { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DoubleDV.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DoubleDV.java index e884d0d62d6..a25d6d7243e 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DoubleDV.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DoubleDV.java @@ -32,7 +32,6 @@ import com.sun.org.apache.xerces.internal.xs.datatypes.XSDouble; * @author Neeraj Bajaj, Sun Microsystems, inc. * @author Sandy Gao, IBM * - * @version $Id: DoubleDV.java,v 1.7 2010-11-01 04:39:46 joehw Exp $ */ public class DoubleDV extends TypeValidator { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DurationDV.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DurationDV.java index 1ec86d0ae6d..9ad95cc77b4 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DurationDV.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DurationDV.java @@ -36,7 +36,6 @@ import com.sun.org.apache.xerces.internal.impl.dv.ValidationContext; * * @author Elena Litani * @author Gopal Sharma, SUN Microsystem Inc. - * @version $Id: DurationDV.java,v 1.7 2010-11-01 04:39:47 joehw Exp $ */ public class DurationDV extends AbstractDateTimeDV { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/ExtendedSchemaDVFactoryImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/ExtendedSchemaDVFactoryImpl.java index fa7e79e42c8..13d166a8f53 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/ExtendedSchemaDVFactoryImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/ExtendedSchemaDVFactoryImpl.java @@ -32,7 +32,6 @@ import com.sun.org.apache.xerces.internal.util.SymbolHash; * * @author Khaled Noaman, IBM * - * @version $Id: ExtendedSchemaDVFactoryImpl.java,v 1.2 2010-10-26 23:01:03 joehw Exp $ */ public class ExtendedSchemaDVFactoryImpl extends BaseSchemaDVFactory { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/FloatDV.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/FloatDV.java index 9ff0ecfccd9..f2478233564 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/FloatDV.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/FloatDV.java @@ -32,7 +32,6 @@ import com.sun.org.apache.xerces.internal.xs.datatypes.XSFloat; * @author Neeraj Bajaj, Sun Microsystems, inc. * @author Sandy Gao, IBM * - * @version $Id: FloatDV.java,v 1.7 2010-11-01 04:39:47 joehw Exp $ */ public class FloatDV extends TypeValidator { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/HexBinaryDV.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/HexBinaryDV.java index 2b872263637..99bc19709dc 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/HexBinaryDV.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/HexBinaryDV.java @@ -33,7 +33,6 @@ import com.sun.org.apache.xerces.internal.impl.dv.util.HexBin; * @author Neeraj Bajaj, Sun Microsystems, inc. * @author Sandy Gao, IBM * - * @version $Id: HexBinaryDV.java,v 1.7 2010-11-01 04:39:47 joehw Exp $ */ public class HexBinaryDV extends TypeValidator { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/ListDV.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/ListDV.java index ca074323d37..07d49b0988c 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/ListDV.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/ListDV.java @@ -34,7 +34,6 @@ import com.sun.org.apache.xerces.internal.xs.datatypes.ObjectList; * @author Neeraj Bajaj, Sun Microsystems, inc. * @author Sandy Gao, IBM * - * @version $Id: ListDV.java,v 1.7 2010-11-01 04:39:47 joehw Exp $ */ public class ListDV extends TypeValidator{ diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/MonthDV.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/MonthDV.java index ea57736397f..175c5ebf2d9 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/MonthDV.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/MonthDV.java @@ -34,7 +34,6 @@ import com.sun.org.apache.xerces.internal.impl.dv.ValidationContext; * @author Elena Litani * @author Gopal Sharma, SUN Microsystem Inc. * - * @version $Id: MonthDV.java,v 1.8 2010-11-01 04:39:47 joehw Exp $ */ public class MonthDV extends AbstractDateTimeDV { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/MonthDayDV.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/MonthDayDV.java index 4b4dc118ada..0edc0006ad7 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/MonthDayDV.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/MonthDayDV.java @@ -34,7 +34,6 @@ import com.sun.org.apache.xerces.internal.impl.dv.ValidationContext; * @author Elena Litani * @author Gopal Sharma, SUN Microsystem Inc. * - * @version $Id: MonthDayDV.java,v 1.7 2010-11-01 04:39:47 joehw Exp $ */ public class MonthDayDV extends AbstractDateTimeDV { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/SchemaDVFactoryImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/SchemaDVFactoryImpl.java index 3e0570b51aa..5bb8a4350ed 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/SchemaDVFactoryImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/SchemaDVFactoryImpl.java @@ -32,7 +32,6 @@ import com.sun.org.apache.xerces.internal.util.SymbolHash; * @author Neeraj Bajaj, Sun Microsystems, inc. * @author Sandy Gao, IBM * - * @version $Id: SchemaDVFactoryImpl.java,v 1.7 2010-11-01 04:39:47 joehw Exp $ */ public class SchemaDVFactoryImpl extends BaseSchemaDVFactory { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/TimeDV.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/TimeDV.java index c9bbae21174..4c7bb4dd46d 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/TimeDV.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/TimeDV.java @@ -34,7 +34,6 @@ import com.sun.org.apache.xerces.internal.impl.dv.ValidationContext; * @author Elena Litani * @author Gopal Sharma, SUN Microsystem Inc. * - * @version $Id: TimeDV.java,v 1.7 2010-11-01 04:39:47 joehw Exp $ */ public class TimeDV extends AbstractDateTimeDV { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/XSSimpleTypeDecl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/XSSimpleTypeDecl.java index c9c913464e6..fa4a495a571 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/XSSimpleTypeDecl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/XSSimpleTypeDecl.java @@ -60,7 +60,6 @@ import org.w3c.dom.TypeInfo; * @author Sandy Gao, IBM * @author Neeraj Bajaj, Sun Microsystems, inc. * - * @version $Id: XSSimpleTypeDecl.java 3029 2011-04-24 17:50:18Z joehw $ */ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/XSSimpleTypeDelegate.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/XSSimpleTypeDelegate.java index 1b683db3457..318bc69299e 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/XSSimpleTypeDelegate.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/XSSimpleTypeDelegate.java @@ -39,7 +39,6 @@ import com.sun.org.apache.xerces.internal.xs.XSTypeDefinition; * * @xerces.internal * - * @version $Id: XSSimpleTypeDelegate.java,v 1.3 2010-11-01 04:39:47 joehw Exp $ */ public class XSSimpleTypeDelegate implements XSSimpleType { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/YearDV.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/YearDV.java index d069c401a0f..02c5058f55c 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/YearDV.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/YearDV.java @@ -34,7 +34,6 @@ import com.sun.org.apache.xerces.internal.impl.dv.ValidationContext; * @author Elena Litani * @author Gopal Sharma, SUN Microsystem Inc. * - * @version $Id: YearDV.java,v 1.7 2010-11-01 04:39:47 joehw Exp $ */ public class YearDV extends AbstractDateTimeDV { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/YearMonthDV.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/YearMonthDV.java index 6b96deb1ded..b9fde68ca18 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/YearMonthDV.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/YearMonthDV.java @@ -34,7 +34,6 @@ import com.sun.org.apache.xerces.internal.impl.dv.ValidationContext; * @author Elena Litani * @author Gopal Sharma, SUN Microsystem Inc. * - * @version $Id: YearMonthDV.java,v 1.7 2010-11-01 04:39:47 joehw Exp $ */ public class YearMonthDV extends AbstractDateTimeDV{ diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/YearMonthDurationDV.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/YearMonthDurationDV.java index 4723a65cf32..c11413097ec 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/YearMonthDurationDV.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/YearMonthDurationDV.java @@ -34,7 +34,6 @@ import com.sun.org.apache.xerces.internal.impl.dv.ValidationContext; * * @author Ankit Pasricha, IBM * - * @version $Id: YearMonthDurationDV.java,v 1.6 2010-11-01 04:39:47 joehw Exp $ */ class YearMonthDurationDV extends DurationDV { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter.java index adb8c44ab2e..0f7ed95d5a8 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter.java @@ -33,7 +33,6 @@ import java.util.ResourceBundle; * @xerces.internal * * @author Eric Ye, IBM - * @version $Id: XMLMessageFormatter.java 3094 2012-03-21 05:50:01Z joehw $ * */ public class XMLMessageFormatter implements MessageFormatter { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_de.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_de.java index 1f9d2816165..24c5e41d4d7 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_de.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_de.java @@ -35,7 +35,6 @@ import com.sun.org.apache.xerces.internal.utils.SecuritySupport; * @xerces.internal * * @author Eric Ye, IBM - * @version $Id: XMLMessageFormatter_de.java 3094 2012-03-21 05:50:01Z joehw $ * */ public class XMLMessageFormatter_de implements MessageFormatter { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_es.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_es.java index 164a2513a9e..5dab448b1fb 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_es.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_es.java @@ -35,7 +35,6 @@ import com.sun.org.apache.xerces.internal.utils.SecuritySupport; * @xerces.internal * * @author Eric Ye, IBM - * @version $Id: XMLMessageFormatter_es.java 3094 2012-03-21 05:50:01Z joehw $ * */ public class XMLMessageFormatter_es implements MessageFormatter { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_fr.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_fr.java index e4e41292716..1b4974a2e8c 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_fr.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_fr.java @@ -35,7 +35,6 @@ import com.sun.org.apache.xerces.internal.utils.SecuritySupport; * @xerces.internal * * @author Eric Ye, IBM - * @version $Id: XMLMessageFormatter_fr.java 3094 2012-03-21 05:50:01Z joehw $ * */ public class XMLMessageFormatter_fr implements MessageFormatter { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_it.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_it.java index e2dd5132d21..66d1b90951c 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_it.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_it.java @@ -35,7 +35,6 @@ import com.sun.org.apache.xerces.internal.utils.SecuritySupport; * @xerces.internal * * @author Eric Ye, IBM - * @version $Id: XMLMessageFormatter_it.java 3094 2012-03-21 05:50:01Z joehw $ * */ public class XMLMessageFormatter_it implements MessageFormatter { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_ja.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_ja.java index b3fb8563e67..14363761574 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_ja.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_ja.java @@ -35,7 +35,6 @@ import com.sun.org.apache.xerces.internal.utils.SecuritySupport; * @xerces.internal * * @author Eric Ye, IBM - * @version $Id: XMLMessageFormatter_ja.java 3094 2012-03-21 05:50:01Z joehw $ * */ public class XMLMessageFormatter_ja implements MessageFormatter { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_ko.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_ko.java index 3de7757c5bc..a042bdd9afe 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_ko.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_ko.java @@ -35,7 +35,6 @@ import com.sun.org.apache.xerces.internal.utils.SecuritySupport; * @xerces.internal * * @author Eric Ye, IBM - * @version $Id: XMLMessageFormatter_ko.java 3094 2012-03-21 05:50:01Z joehw $ * */ public class XMLMessageFormatter_ko implements MessageFormatter { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_pt_BR.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_pt_BR.java index 59b3d1d30a7..053445dc06a 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_pt_BR.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_pt_BR.java @@ -35,7 +35,6 @@ import com.sun.org.apache.xerces.internal.utils.SecuritySupport; * @xerces.internal * * @author Eric Ye, IBM - * @version $Id: XMLMessageFormatter_pt_BR.java 3094 2012-03-21 05:50:01Z joehw $ * */ public class XMLMessageFormatter_pt_BR implements MessageFormatter { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_sv.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_sv.java index 00217ae4f7b..bb4d9531d38 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_sv.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_sv.java @@ -35,7 +35,6 @@ import com.sun.org.apache.xerces.internal.utils.SecuritySupport; * @xerces.internal * * @author Eric Ye, IBM - * @version $Id: XMLMessageFormatter_sv.java 3094 2012-03-21 05:50:01Z joehw $ * */ public class XMLMessageFormatter_sv implements MessageFormatter { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_zh_CN.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_zh_CN.java index 4cfa9686da0..13f6be55cb6 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_zh_CN.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_zh_CN.java @@ -35,7 +35,6 @@ import com.sun.org.apache.xerces.internal.utils.SecuritySupport; * @xerces.internal * * @author Eric Ye, IBM - * @version $Id: XMLMessageFormatter_zh_CN.java 3094 2012-03-21 05:50:01Z joehw $ * */ public class XMLMessageFormatter_zh_CN implements MessageFormatter { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_zh_TW.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_zh_TW.java index 4f34fa2adc5..1965d571783 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_zh_TW.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_zh_TW.java @@ -35,7 +35,6 @@ import com.sun.org.apache.xerces.internal.utils.SecuritySupport; * @xerces.internal * * @author Eric Ye, IBM - * @version $Id: XMLMessageFormatter_zh_TW.java 3094 2012-03-21 05:50:01Z joehw $ * */ public class XMLMessageFormatter_zh_TW implements MessageFormatter { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/validation/ValidationState.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/validation/ValidationState.java index a04c57dcef7..686e2b1c916 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/validation/ValidationState.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/validation/ValidationState.java @@ -34,7 +34,6 @@ import java.util.Locale; * @xerces.internal * * @author Elena Litani, IBM - * @version $Id: ValidationState.java,v 1.7 2010-11-01 04:39:53 joehw Exp $ */ public class ValidationState implements ValidationContext { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xpath/regex/CaseInsensitiveMap.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xpath/regex/CaseInsensitiveMap.java index 202f239feaf..3f5da982fa4 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xpath/regex/CaseInsensitiveMap.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xpath/regex/CaseInsensitiveMap.java @@ -22,7 +22,6 @@ package com.sun.org.apache.xerces.internal.impl.xpath.regex; /** - * @version $Id: CaseInsensitiveMap.java,v 1.1 2010/07/27 06:29:27 joehw Exp $ */ public class CaseInsensitiveMap { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xpath/regex/ParserForXMLSchema.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xpath/regex/ParserForXMLSchema.java index 22e2a710c9b..aa18a901dac 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xpath/regex/ParserForXMLSchema.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xpath/regex/ParserForXMLSchema.java @@ -29,7 +29,6 @@ import java.util.Locale; * @xerces.internal * * @author TAMURA Kent <kent@trl.ibm.co.jp> - * @version $Id: ParserForXMLSchema.java,v 1.9 2010-11-12 18:09:45 joehw Exp $ */ class ParserForXMLSchema extends RegexParser { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xpath/regex/RegexParser.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xpath/regex/RegexParser.java index ed1cda9ba3e..5435fc799d9 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xpath/regex/RegexParser.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xpath/regex/RegexParser.java @@ -31,7 +31,6 @@ import java.util.Vector; * * @xerces.internal * - * @version $Id: RegexParser.java,v 1.8 2010-11-01 04:39:54 joehw Exp $ */ class RegexParser { static final int T_CHAR = 0; diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xpath/regex/RegularExpression.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xpath/regex/RegularExpression.java index fa488d64ad2..0a996b27c10 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xpath/regex/RegularExpression.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xpath/regex/RegularExpression.java @@ -486,7 +486,6 @@ import com.sun.org.apache.xerces.internal.util.IntStack; * @xerces.internal * * @author TAMURA Kent <kent@trl.ibm.co.jp> - * @version $Id: RegularExpression.java,v 1.9 2010/07/27 05:02:34 joehw Exp $ */ public class RegularExpression implements java.io.Serializable { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xpath/regex/Token.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xpath/regex/Token.java index a395e47fdc4..5221b6e8612 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xpath/regex/Token.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xpath/regex/Token.java @@ -28,7 +28,6 @@ import java.util.Hashtable; * * @xerces.internal * - * @version $Id: Token.java,v 1.7 2010/07/27 05:02:34 joehw Exp $ */ class Token implements java.io.Serializable { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/SchemaGrammar.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/SchemaGrammar.java index ea450035ffd..06ec54dd9d2 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/SchemaGrammar.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/SchemaGrammar.java @@ -75,7 +75,6 @@ import org.xml.sax.SAXException; * @author Sandy Gao, IBM * @author Elena Litani, IBM * - * @version $Id: SchemaGrammar.java,v 1.7 2010-11-01 04:39:55 joehw Exp $ */ public class SchemaGrammar implements XSGrammar, XSNamespaceItem { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/SubstitutionGroupHandler.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/SubstitutionGroupHandler.java index 1fbe4c74cda..f2d4e745af4 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/SubstitutionGroupHandler.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/SubstitutionGroupHandler.java @@ -35,7 +35,6 @@ import java.util.Vector; * * @author Sandy Gao, IBM * - * @version $Id: SubstitutionGroupHandler.java,v 1.6 2010-11-01 04:39:55 joehw Exp $ */ public class SubstitutionGroupHandler { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaLoader.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaLoader.java index d37a0300ed8..63123391ca3 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaLoader.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaLoader.java @@ -98,7 +98,6 @@ import org.xml.sax.InputSource; * @xerces.internal * * @author Neil Graham, IBM - * @version $Id: XMLSchemaLoader.java,v 1.10 2010-11-01 04:39:55 joehw Exp $ */ public class XMLSchemaLoader implements XMLGrammarLoader, XMLComponent, diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaValidator.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaValidator.java index f7fc09a6d00..fd03b7a8f75 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaValidator.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaValidator.java @@ -107,7 +107,6 @@ import com.sun.org.apache.xerces.internal.parsers.XMLParser; * @author Elena Litani IBM * @author Andy Clark IBM * @author Neeraj Bajaj, Sun Microsystems, inc. - * @version $Id: XMLSchemaValidator.java,v 1.16 2010-11-01 04:39:55 joehw Exp $ */ public class XMLSchemaValidator implements XMLComponent, XMLDocumentFilter, FieldActivator, RevalidationHandler { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSAttributeDecl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSAttributeDecl.java index 183c6f22f63..7542c684f69 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSAttributeDecl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSAttributeDecl.java @@ -41,7 +41,6 @@ import com.sun.org.apache.xerces.internal.xs.XSSimpleTypeDefinition; * * @author Elena Litani, IBM * @author Sandy Gao, IBM - * @version $Id: XSAttributeDecl.java,v 1.7 2010-11-01 04:39:55 joehw Exp $ */ public class XSAttributeDecl implements XSAttributeDeclaration { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSAttributeGroupDecl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSAttributeGroupDecl.java index 8e907051eee..fda0899f9da 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSAttributeGroupDecl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSAttributeGroupDecl.java @@ -39,7 +39,6 @@ import com.sun.org.apache.xerces.internal.xs.XSWildcard; * @author Sandy Gao, IBM * @author Rahul Srivastava, Sun Microsystems Inc. * - * @version $Id: XSAttributeGroupDecl.java,v 1.7 2010-11-01 04:39:55 joehw Exp $ */ public class XSAttributeGroupDecl implements XSAttributeGroupDefinition { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSAttributeUseImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSAttributeUseImpl.java index 174c2852a92..42e64e3c87a 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSAttributeUseImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSAttributeUseImpl.java @@ -36,7 +36,6 @@ import com.sun.org.apache.xerces.internal.xs.XSObjectList; * @xerces.internal * * @author Sandy Gao, IBM - * @version $Id: XSAttributeUseImpl.java,v 1.7 2010-11-01 04:39:55 joehw Exp $ */ public class XSAttributeUseImpl implements XSAttributeUse { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSComplexTypeDecl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSComplexTypeDecl.java index 79f250028b4..3096988cb2e 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSComplexTypeDecl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSComplexTypeDecl.java @@ -36,7 +36,6 @@ import org.w3c.dom.TypeInfo; * * @author Elena Litani, IBM * @author Sandy Gao, IBM - * @version $Id: XSComplexTypeDecl.java,v 1.8 2010-11-01 04:39:55 joehw Exp $ */ public class XSComplexTypeDecl implements XSComplexTypeDefinition, TypeInfo { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSConstraints.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSConstraints.java index c56ad0d1b57..3b5e28c2d77 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSConstraints.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSConstraints.java @@ -45,7 +45,6 @@ import com.sun.org.apache.xerces.internal.xs.XSTypeDefinition; * * @author Sandy Gao, IBM * - * @version $Id: XSConstraints.java,v 1.7 2010-11-01 04:39:55 joehw Exp $ */ public class XSConstraints { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSDDescription.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSDDescription.java index c35baa8667a..545388002e7 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSDDescription.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSDDescription.java @@ -34,7 +34,6 @@ import com.sun.org.apache.xerces.internal.xni.grammars.XMLSchemaDescription; * @author Neil Graham, IBM * @author Neeraj Bajaj, SUN Microsystems. * - * @version $Id: XSDDescription.java,v 1.6 2010-11-01 04:39:55 joehw Exp $ */ public class XSDDescription extends XMLResourceIdentifierImpl implements XMLSchemaDescription { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSDeclarationPool.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSDeclarationPool.java index 5578da2a44b..604f50da504 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSDeclarationPool.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSDeclarationPool.java @@ -33,7 +33,6 @@ import com.sun.org.apache.xerces.internal.impl.dv.xs.XSSimpleTypeDecl; * @xerces.internal * * @author Elena Litani, IBM - * @version $Id: XSDeclarationPool.java,v 1.7 2010-11-01 04:39:55 joehw Exp $ */ public final class XSDeclarationPool { /** Chunk shift (8). */ diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSElementDecl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSElementDecl.java index 190daa779b0..70d5347e5c2 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSElementDecl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSElementDecl.java @@ -43,7 +43,6 @@ import com.sun.org.apache.xerces.internal.xs.XSTypeDefinition; * * @author Elena Litani, IBM * @author Sandy Gao, IBM - * @version $Id: XSElementDecl.java,v 1.7 2010-11-01 04:39:55 joehw Exp $ */ public class XSElementDecl implements XSElementDeclaration { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSGrammarBucket.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSGrammarBucket.java index 6d88c5fdd00..456b78ba721 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSGrammarBucket.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSGrammarBucket.java @@ -31,7 +31,6 @@ import java.util.Vector; * @xerces.internal * * @author Sandy Gao, IBM - * @version $Id: XSGrammarBucket.java,v 1.7 2010-11-01 04:39:55 joehw Exp $ */ public class XSGrammarBucket { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSGroupDecl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSGroupDecl.java index a710e53b621..3c51b0c5004 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSGroupDecl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSGroupDecl.java @@ -36,7 +36,6 @@ import com.sun.org.apache.xerces.internal.xs.XSObjectList; * @xerces.internal * * @author Sandy Gao, IBM - * @version $Id: XSGroupDecl.java,v 1.7 2010-11-01 04:39:55 joehw Exp $ */ public class XSGroupDecl implements XSModelGroupDefinition { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSLoaderImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSLoaderImpl.java index 136d69e2dbb..48fa9c38448 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSLoaderImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSLoaderImpl.java @@ -45,7 +45,6 @@ import org.w3c.dom.ls.LSInput; * * @author Michael Glavassevich, IBM * - * @version $Id: XSLoaderImpl.java,v 1.7 2010-11-01 04:39:55 joehw Exp $ */ public final class XSLoaderImpl implements XSLoader, DOMConfiguration { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSMessageFormatter.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSMessageFormatter.java index 0a51a3c6b8f..236b7962373 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSMessageFormatter.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSMessageFormatter.java @@ -34,7 +34,6 @@ import java.util.ResourceBundle; * @xerces.internal * * @author Elena Litani, IBM - * @version $Id: XSMessageFormatter.java,v 1.6 2010-11-01 04:39:55 joehw Exp $ */ public class XSMessageFormatter implements MessageFormatter { /** diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSModelGroupImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSModelGroupImpl.java index 4414003319c..8f63830c7a6 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSModelGroupImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSModelGroupImpl.java @@ -34,7 +34,6 @@ import com.sun.org.apache.xerces.internal.xs.XSObjectList; * * @author Sandy Gao, IBM * - * @version $Id: XSModelGroupImpl.java,v 1.7 2010-11-01 04:39:55 joehw Exp $ */ public class XSModelGroupImpl implements XSModelGroup { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSModelImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSModelImpl.java index bded2950e0b..01201a766ea 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSModelImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSModelImpl.java @@ -57,7 +57,6 @@ import com.sun.org.apache.xerces.internal.xs.XSTypeDefinition; * * @author Sandy Gao, IBM * - * @version $Id: XSModelImpl.java,v 1.7 2010-11-01 04:39:55 joehw Exp $ */ public final class XSModelImpl extends AbstractList implements XSModel, XSNamespaceItemList { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSNotationDecl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSNotationDecl.java index 94505f9969d..c34f16b8f88 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSNotationDecl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSNotationDecl.java @@ -34,7 +34,6 @@ import com.sun.org.apache.xerces.internal.xs.XSObjectList; * @xerces.internal * * @author Rahul Srivastava, Sun Microsystems Inc. - * @version $Id: XSNotationDecl.java,v 1.7 2010-11-01 04:39:55 joehw Exp $ */ public class XSNotationDecl implements XSNotationDeclaration { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSParticleDecl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSParticleDecl.java index 468f652cbc9..cb2ba9a5066 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSParticleDecl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSParticleDecl.java @@ -34,7 +34,6 @@ import com.sun.org.apache.xerces.internal.xs.XSTerm; * * @author Sandy Gao, IBM * - * @version $Id: XSParticleDecl.java,v 1.7 2010-11-01 04:39:55 joehw Exp $ */ public class XSParticleDecl implements XSParticle { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSWildcardDecl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSWildcardDecl.java index ac3a00eac6c..b56db22ba14 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSWildcardDecl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSWildcardDecl.java @@ -38,7 +38,6 @@ import com.sun.org.apache.xerces.internal.xs.XSObjectList; * @author Sandy Gao, IBM * @author Rahul Srivastava, Sun Microsystems Inc. * - * @version $Id: XSWildcardDecl.java,v 1.7 2010-11-01 04:39:55 joehw Exp $ */ public class XSWildcardDecl implements XSWildcard { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/identity/Field.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/identity/Field.java index ca968f8d41e..c00e802e6d4 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/identity/Field.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/identity/Field.java @@ -35,7 +35,6 @@ import com.sun.org.apache.xerces.internal.xs.XSTypeDefinition; * @xerces.internal * * @author Andy Clark, IBM - * @version $Id: Field.java,v 1.6 2010-11-01 04:39:57 joehw Exp $ */ public class Field { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/identity/Selector.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/identity/Selector.java index f36e5ee3ab3..283e6c1f153 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/identity/Selector.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/identity/Selector.java @@ -35,7 +35,6 @@ import com.sun.org.apache.xerces.internal.xs.XSTypeDefinition; * @xerces.internal * * @author Andy Clark, IBM - * @version $Id: Selector.java,v 1.7 2010-11-01 04:39:57 joehw Exp $ */ public class Selector { @@ -106,7 +105,6 @@ public class Selector { * Schema identity constraint selector XPath expression. * * @author Andy Clark, IBM - * @version $Id: Selector.java,v 1.7 2010-11-01 04:39:57 joehw Exp $ */ public static class XPath extends com.sun.org.apache.xerces.internal.impl.xpath.XPath { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/models/CMBuilder.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/models/CMBuilder.java index ca8815458d4..e03ca553540 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/models/CMBuilder.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/models/CMBuilder.java @@ -36,7 +36,6 @@ import com.sun.org.apache.xerces.internal.impl.xs.XSParticleDecl; * @author Elena Litani, IBM * @author Sandy Gao, IBM * - * @version $Id: CMBuilder.java,v 1.11 2010/08/06 23:49:43 joehw Exp $ */ public class CMBuilder { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/models/CMNodeFactory.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/models/CMNodeFactory.java index 6aa06b8828d..8962280abbb 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/models/CMNodeFactory.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/models/CMNodeFactory.java @@ -35,7 +35,6 @@ import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException; * * @author Neeraj Bajaj * - * @version $Id: CMNodeFactory.java,v 1.7 2010-11-01 04:39:58 joehw Exp $ */ public class CMNodeFactory { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/models/XSAllCM.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/models/XSAllCM.java index f2cf0a7b7c1..d3060915341 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/models/XSAllCM.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/models/XSAllCM.java @@ -35,7 +35,6 @@ import java.util.ArrayList; * @xerces.internal * * @author Pavani Mukthipudi, Sun Microsystems Inc. - * @version $Id: XSAllCM.java,v 1.10 2010-11-01 04:39:58 joehw Exp $ */ public class XSAllCM implements XSCMValidator { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/models/XSCMRepeatingLeaf.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/models/XSCMRepeatingLeaf.java index 46788962e8e..dd7c1184986 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/models/XSCMRepeatingLeaf.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/models/XSCMRepeatingLeaf.java @@ -27,7 +27,6 @@ package com.sun.org.apache.xerces.internal.impl.xs.models; * @xerces.internal * * @author Michael Glavassevich, IBM - * @version $Id: XSCMRepeatingLeaf.java,v 1.1 2010/08/06 23:49:43 joehw Exp $ */ public final class XSCMRepeatingLeaf extends XSCMLeaf { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/models/XSCMValidator.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/models/XSCMValidator.java index 341d88bcef0..d387ac52261 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/models/XSCMValidator.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/models/XSCMValidator.java @@ -34,7 +34,6 @@ import java.util.ArrayList; * * @author Sandy Gao, IBM * @author Elena Litani, IBM - * @version $Id: XSCMValidator.java,v 1.6 2009/07/28 15:18:12 spericas Exp $ */ public interface XSCMValidator { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/models/XSDFACM.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/models/XSDFACM.java index e4b5ee280eb..997ca17cb95 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/models/XSDFACM.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/models/XSDFACM.java @@ -45,7 +45,6 @@ import java.util.HashMap; * @xerces.internal * * @author Neil Graham, IBM - * @version $Id: XSDFACM.java,v 1.9 2010/08/06 23:49:43 joehw Exp $ */ public class XSDFACM implements XSCMValidator { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/models/XSEmptyCM.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/models/XSEmptyCM.java index 673211fb196..bf730d692c9 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/models/XSEmptyCM.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/models/XSEmptyCM.java @@ -37,7 +37,6 @@ import java.util.ArrayList; * * @author Elena Litani, Lisa Martin * @author IBM - * @version $Id: XSEmptyCM.java,v 1.7 2009/07/28 15:18:11 spericas Exp $ */ public class XSEmptyCM implements XSCMValidator { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/opti/AttrImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/opti/AttrImpl.java index 331fc2692bf..89c70ebc0fa 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/opti/AttrImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/opti/AttrImpl.java @@ -73,7 +73,6 @@ import org.w3c.dom.TypeInfo; * * @author Rahul Srivastava, Sun Microsystems Inc. * - * @version $Id: AttrImpl.java,v 1.5 2010-11-01 04:40:01 joehw Exp $ */ public class AttrImpl extends NodeImpl implements Attr { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/opti/ElementImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/opti/ElementImpl.java index 24eebf7e8dc..28a6bd678b2 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/opti/ElementImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/opti/ElementImpl.java @@ -31,7 +31,6 @@ import org.w3c.dom.Node; * @author Rahul Srivastava, Sun Microsystems Inc. * @author Sandy Gao, IBM * - * @version $Id: ElementImpl.java,v 1.7 2010-11-01 04:40:01 joehw Exp $ */ public class ElementImpl extends DefaultElement { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/opti/SchemaDOM.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/opti/SchemaDOM.java index 48d6f1280ea..52ed98f24d9 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/opti/SchemaDOM.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/opti/SchemaDOM.java @@ -40,7 +40,6 @@ import org.w3c.dom.Node; * @author Rahul Srivastava, Sun Microsystems Inc. * @author Sandy Gao, IBM * - * @version $Id: SchemaDOM.java,v 1.7 2010-11-01 04:40:01 joehw Exp $ */ public class SchemaDOM extends DefaultDocument { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/opti/SchemaDOMImplementation.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/opti/SchemaDOMImplementation.java index 105e6367cfb..eb422a2354a 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/opti/SchemaDOMImplementation.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/opti/SchemaDOMImplementation.java @@ -28,7 +28,6 @@ import org.w3c.dom.DocumentType; /** * @xerces.internal * - * @version $Id: SchemaDOMImplementation.java,v 1.2 2010-10-26 23:01:18 joehw Exp $ */ final class SchemaDOMImplementation implements DOMImplementation { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/opti/SchemaDOMParser.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/opti/SchemaDOMParser.java index be28c8c836c..b8e1d54959e 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/opti/SchemaDOMParser.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/opti/SchemaDOMParser.java @@ -46,7 +46,6 @@ import org.w3c.dom.Document; * @author Rahul Srivastava, Sun Microsystems Inc. * @author Sandy Gao, IBM * - * @version $Id: SchemaDOMParser.java,v 1.8 2010-11-01 04:40:01 joehw Exp $ */ public class SchemaDOMParser extends DefaultXMLDocumentHandler { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/opti/SchemaParsingConfig.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/opti/SchemaParsingConfig.java index a9b251e91f1..5c9afc2c25e 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/opti/SchemaParsingConfig.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/opti/SchemaParsingConfig.java @@ -57,7 +57,6 @@ import com.sun.org.apache.xerces.internal.xni.parser.XMLPullParserConfiguration; * * @author Rahul Srivastava, Sun Microsystems Inc. * - * @version $Id: SchemaParsingConfig.java,v 1.8 2010-11-01 04:40:01 joehw Exp $ */ public class SchemaParsingConfig extends BasicParserConfiguration implements XMLPullParserConfiguration { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/StAXSchemaParser.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/StAXSchemaParser.java index 3d7e3afdded..84f04e2e53f 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/StAXSchemaParser.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/StAXSchemaParser.java @@ -54,7 +54,6 @@ import org.w3c.dom.Document; * * @xerces.internal * - * @version $Id: StAXSchemaParser.java,v 1.2 2010-10-26 23:01:12 joehw Exp $ */ final class StAXSchemaParser { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSAttributeChecker.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSAttributeChecker.java index f9eea6a4dc4..1a3a41476d3 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSAttributeChecker.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSAttributeChecker.java @@ -69,7 +69,6 @@ import org.w3c.dom.Element; * @xerces.internal * * @author Sandy Gao, IBM - * @version $Id: XSAttributeChecker.java,v 1.12 2010-11-01 04:40:02 joehw Exp $ */ public class XSAttributeChecker { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAbstractIDConstraintTraverser.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAbstractIDConstraintTraverser.java index c6455231eeb..af38b2f73f6 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAbstractIDConstraintTraverser.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAbstractIDConstraintTraverser.java @@ -36,7 +36,6 @@ import org.w3c.dom.Element; * * @xerces.internal * - * @version $Id: XSDAbstractIDConstraintTraverser.java,v 1.7 2010-11-01 04:40:02 joehw Exp $ */ class XSDAbstractIDConstraintTraverser extends XSDAbstractTraverser { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAbstractParticleTraverser.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAbstractParticleTraverser.java index 364a94a850a..0a0569a1fc2 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAbstractParticleTraverser.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAbstractParticleTraverser.java @@ -37,7 +37,6 @@ import org.w3c.dom.Element; * * @author Elena Litani, IBM * @author Sandy Gao, IBM - * @version $Id: XSDAbstractParticleTraverser.java,v 1.7 2010-11-01 04:40:02 joehw Exp $ */ abstract class XSDAbstractParticleTraverser extends XSDAbstractTraverser { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAbstractTraverser.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAbstractTraverser.java index a5e97f08b25..7af4c66754d 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAbstractTraverser.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAbstractTraverser.java @@ -58,7 +58,6 @@ import org.w3c.dom.Element; * @author Rahul Srivastava, Sun Microsystems Inc. * @author Neeraj Bajaj, Sun Microsystems Inc. * - * @version $Id: XSDAbstractTraverser.java,v 1.8 2010-11-01 04:40:02 joehw Exp $ */ abstract class XSDAbstractTraverser { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAttributeGroupTraverser.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAttributeGroupTraverser.java index 0e126704d0b..14d15309ea9 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAttributeGroupTraverser.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAttributeGroupTraverser.java @@ -46,7 +46,6 @@ import org.w3c.dom.Element; * @author Rahul Srivastava, Sun Microsystems Inc. * @author Sandy Gao, IBM * - * @version $Id: XSDAttributeGroupTraverser.java,v 1.7 2010-11-01 04:40:02 joehw Exp $ */ class XSDAttributeGroupTraverser extends XSDAbstractTraverser { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAttributeTraverser.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAttributeTraverser.java index 0aa0b32ec33..6174a7b5ec3 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAttributeTraverser.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAttributeTraverser.java @@ -59,7 +59,6 @@ import org.w3c.dom.Element; * * @author Sandy Gao, IBM * @author Neeraj Bajaj, Sun Microsystems, inc. - * @version $Id: XSDAttributeTraverser.java,v 1.7 2010-11-01 04:40:02 joehw Exp $ */ class XSDAttributeTraverser extends XSDAbstractTraverser { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDComplexTypeTraverser.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDComplexTypeTraverser.java index cfc98b834b8..b786158ac7c 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDComplexTypeTraverser.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDComplexTypeTraverser.java @@ -62,7 +62,6 @@ import org.w3c.dom.Element; * * @xerces.internal * - * @version $Id: XSDComplexTypeTraverser.java,v 1.8 2010-11-01 04:40:02 joehw Exp $ */ class XSDComplexTypeTraverser extends XSDAbstractParticleTraverser { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDElementTraverser.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDElementTraverser.java index 0d480580d6a..e0e4c464c21 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDElementTraverser.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDElementTraverser.java @@ -69,7 +69,6 @@ import org.w3c.dom.Element; * * @author Sandy Gao, IBM * - * @version $Id: XSDElementTraverser.java,v 1.9 2010-11-01 04:40:02 joehw Exp $ */ class XSDElementTraverser extends XSDAbstractTraverser { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDGroupTraverser.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDGroupTraverser.java index 915f482ddbe..99e2ec99319 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDGroupTraverser.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDGroupTraverser.java @@ -47,7 +47,6 @@ import org.w3c.dom.Element; * @author Rahul Srivastava, Sun Microsystems Inc. * @author Elena Litani, IBM * @author Lisa Martin, IBM - * @version $Id: XSDGroupTraverser.java,v 1.7 2010-11-01 04:40:02 joehw Exp $ */ class XSDGroupTraverser extends XSDAbstractParticleTraverser { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDHandler.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDHandler.java index d6a6e948f65..bf6defa6ca7 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDHandler.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDHandler.java @@ -131,7 +131,6 @@ import org.xml.sax.helpers.XMLReaderFactory; * @author Neil Graham, IBM * @author Pavani Mukthipudi, Sun Microsystems * - * @version $Id: XSDHandler.java,v 1.9 2010-11-01 04:40:02 joehw Exp $ */ public class XSDHandler { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDKeyrefTraverser.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDKeyrefTraverser.java index 07d160e2998..7d590acf55f 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDKeyrefTraverser.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDKeyrefTraverser.java @@ -35,7 +35,6 @@ import org.w3c.dom.Element; * @xerces.internal * * @author Neil Graham, IBM - * @version $Id: XSDKeyrefTraverser.java,v 1.7 2010-11-01 04:40:02 joehw Exp $ */ class XSDKeyrefTraverser extends XSDAbstractIDConstraintTraverser { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDNotationTraverser.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDNotationTraverser.java index 846c9b94326..27acd055d2f 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDNotationTraverser.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDNotationTraverser.java @@ -45,7 +45,6 @@ import org.w3c.dom.Element; * * @author Rahul Srivastava, Sun Microsystems Inc. * @author Elena Litani, IBM - * @version $Id: XSDNotationTraverser.java,v 1.7 2010-11-01 04:40:02 joehw Exp $ */ class XSDNotationTraverser extends XSDAbstractTraverser { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDSimpleTypeTraverser.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDSimpleTypeTraverser.java index 355881edc84..1564227b1f5 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDSimpleTypeTraverser.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDSimpleTypeTraverser.java @@ -78,7 +78,6 @@ import org.w3c.dom.Element; * @author Neeraj Bajaj, Sun Microsystems, Inc. * @author Sandy Gao, IBM * - * @version $Id: XSDSimpleTypeTraverser.java,v 1.7 2010-11-01 04:40:02 joehw Exp $ */ class XSDSimpleTypeTraverser extends XSDAbstractTraverser { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDUniqueOrKeyTraverser.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDUniqueOrKeyTraverser.java index 054dd9deb04..2e36be5745e 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDUniqueOrKeyTraverser.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDUniqueOrKeyTraverser.java @@ -35,7 +35,6 @@ import org.w3c.dom.Element; * @xerces.internal * * @author Neil Graham, IBM - * @version $Id: XSDUniqueOrKeyTraverser.java,v 1.7 2010-11-01 04:40:02 joehw Exp $ */ class XSDUniqueOrKeyTraverser extends XSDAbstractIDConstraintTraverser { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDWildcardTraverser.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDWildcardTraverser.java index 60bfb54d88d..c368b74ccfd 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDWildcardTraverser.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDWildcardTraverser.java @@ -57,7 +57,6 @@ import org.w3c.dom.Element; * @author Rahul Srivastava, Sun Microsystems Inc. * @author Sandy Gao, IBM * - * @version $Id: XSDWildcardTraverser.java,v 1.7 2010-11-01 04:40:02 joehw Exp $ */ class XSDWildcardTraverser extends XSDAbstractTraverser { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDocumentInfo.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDocumentInfo.java index b75639f16a4..b941ea90236 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDocumentInfo.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDocumentInfo.java @@ -43,7 +43,6 @@ import org.w3c.dom.NamedNodeMap; * @xerces.internal * * @author Neil Graham, IBM - * @version $Id: XSDocumentInfo.java,v 1.5 2007/10/15 22:27:48 spericas Exp $ */ class XSDocumentInfo { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/LSInputListImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/LSInputListImpl.java index c8a93293e05..4f3bb757ed1 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/LSInputListImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/LSInputListImpl.java @@ -34,7 +34,6 @@ import org.w3c.dom.ls.LSInput; * * @author Michael Glavassevich, IBM * - * @version $Id: LSInputListImpl.java,v 1.2 2010-10-26 23:01:04 joehw Exp $ */ public final class LSInputListImpl extends AbstractList implements LSInputList { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/ObjectListImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/ObjectListImpl.java index 9f0a1964cdb..1d29360a05d 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/ObjectListImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/ObjectListImpl.java @@ -31,7 +31,6 @@ import com.sun.org.apache.xerces.internal.xs.datatypes.ObjectList; * * @xerces.internal * - * @version $Id: ObjectListImpl.java,v 1.2 2010-10-26 23:01:04 joehw Exp $ */ public final class ObjectListImpl extends AbstractList implements ObjectList { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/ShortListImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/ShortListImpl.java index 9a3ba385747..9dc0641ef26 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/ShortListImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/ShortListImpl.java @@ -32,7 +32,6 @@ import com.sun.org.apache.xerces.internal.xs.XSException; * * @author Sandy Gao, IBM * - * @version $Id: ShortListImpl.java,v 1.7 2010-11-01 04:40:06 joehw Exp $ */ public final class ShortListImpl extends AbstractList implements ShortList { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/StringListImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/StringListImpl.java index 5f22628b4f7..cf3d46a494e 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/StringListImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/StringListImpl.java @@ -33,7 +33,6 @@ import com.sun.org.apache.xerces.internal.xs.StringList; * * @author Sandy Gao, IBM * - * @version $Id: StringListImpl.java,v 1.7 2010-11-01 04:40:06 joehw Exp $ */ public final class StringListImpl extends AbstractList implements StringList { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/XSGrammarPool.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/XSGrammarPool.java index 3f83e8373ff..a3f0bc71a37 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/XSGrammarPool.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/XSGrammarPool.java @@ -36,7 +36,6 @@ import com.sun.org.apache.xerces.internal.xs.XSModel; * * @xerces.internal * - * @version $Id: XSGrammarPool.java,v 1.7 2010-11-01 04:40:06 joehw Exp $ */ public class XSGrammarPool extends XMLGrammarPoolImpl { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/XSInputSource.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/XSInputSource.java index 4ca114bbedc..393393c08a0 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/XSInputSource.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/XSInputSource.java @@ -29,7 +29,6 @@ import com.sun.org.apache.xerces.internal.xs.XSObject; /** * @xerces.internal * - * @version $Id: XSInputSource.java,v 1.2 2010-10-26 23:01:05 joehw Exp $ */ public final class XSInputSource extends XMLInputSource { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/XSNamedMap4Types.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/XSNamedMap4Types.java index 63f6f475564..a2c6b29df41 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/XSNamedMap4Types.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/XSNamedMap4Types.java @@ -32,7 +32,6 @@ import com.sun.org.apache.xerces.internal.xs.XSTypeDefinition; * * @author Sandy Gao, IBM * - * @version $Id: XSNamedMap4Types.java,v 1.7 2010-11-01 04:40:06 joehw Exp $ */ public final class XSNamedMap4Types extends XSNamedMapImpl { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/XSNamedMapImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/XSNamedMapImpl.java index 17406566405..b15f1ed47b3 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/XSNamedMapImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/XSNamedMapImpl.java @@ -41,7 +41,6 @@ import com.sun.org.apache.xerces.internal.xs.XSObject; * * @author Sandy Gao, IBM * - * @version $Id: XSNamedMapImpl.java,v 1.7 2010-11-01 04:40:06 joehw Exp $ */ public class XSNamedMapImpl extends AbstractMap implements XSNamedMap { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/XSObjectListImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/XSObjectListImpl.java index b5e0de2d52a..7c5b4f7c40f 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/XSObjectListImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/XSObjectListImpl.java @@ -36,7 +36,6 @@ import com.sun.org.apache.xerces.internal.xs.XSObjectList; * * @author Sandy Gao, IBM * - * @version $Id: XSObjectListImpl.java,v 1.7 2010-11-01 04:40:06 joehw Exp $ */ public class XSObjectListImpl extends AbstractList implements XSObjectList { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderFactoryImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderFactoryImpl.java index aea63c2eb16..2899ab8dd92 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderFactoryImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderFactoryImpl.java @@ -37,7 +37,6 @@ import org.xml.sax.SAXNotSupportedException; /** * @author Rajiv Mordani * @author Edwin Goei - * @version $Id: DocumentBuilderFactoryImpl.java,v 1.8 2010-11-01 04:40:06 joehw Exp $ */ public class DocumentBuilderFactoryImpl extends DocumentBuilderFactory { /** These are DocumentBuilderFactory attributes not DOM attributes */ diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderImpl.java index 51f22d713b1..a1d9b1ffb2b 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderImpl.java @@ -58,7 +58,6 @@ import org.xml.sax.SAXNotSupportedException; /** * @author Rajiv Mordani * @author Edwin Goei - * @version $Id: DocumentBuilderImpl.java,v 1.8 2010-11-01 04:40:06 joehw Exp $ */ public class DocumentBuilderImpl extends DocumentBuilder implements JAXPConstants diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/SAXParserFactoryImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/SAXParserFactoryImpl.java index ae9d99509d9..50c5f3db11d 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/SAXParserFactoryImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/SAXParserFactoryImpl.java @@ -43,7 +43,6 @@ import com.sun.org.apache.xerces.internal.util.SAXMessageFormatter; * @author Rajiv Mordani * @author Edwin Goei * - * @version $Id: SAXParserFactoryImpl.java,v 1.9 2010-11-01 04:40:06 joehw Exp $ */ public class SAXParserFactoryImpl extends SAXParserFactory { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/SAXParserImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/SAXParserImpl.java index 6cc3e9a4678..315b2000ccf 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/SAXParserImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/SAXParserImpl.java @@ -63,7 +63,6 @@ import org.xml.sax.helpers.DefaultHandler; * @author Rajiv Mordani * @author Edwin Goei * - * @version $Id: SAXParserImpl.java,v 1.7 2010-11-01 04:40:06 joehw Exp $ */ public class SAXParserImpl extends javax.xml.parsers.SAXParser implements JAXPConstants, PSVIProvider { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/SchemaValidatorConfiguration.java b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/SchemaValidatorConfiguration.java index 9ef80be7742..f919ec08a81 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/SchemaValidatorConfiguration.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/SchemaValidatorConfiguration.java @@ -34,7 +34,6 @@ import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException; /** *

Parser configuration for Xerces' XMLSchemaValidator.

* - * @version $Id: SchemaValidatorConfiguration.java,v 1.5 2010-11-01 04:40:06 joehw Exp $ */ final class SchemaValidatorConfiguration implements XMLComponentManager { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/UnparsedEntityHandler.java b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/UnparsedEntityHandler.java index 5714da3be57..8129066eb3d 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/UnparsedEntityHandler.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/UnparsedEntityHandler.java @@ -39,7 +39,6 @@ import com.sun.org.apache.xerces.internal.xni.parser.XMLDTDSource; * Events are forwarded to the registered XMLDTDHandler without modification.

* * @author Michael Glavassevich, IBM - * @version $Id: UnparsedEntityHandler.java,v 1.6 2010-11-01 04:40:07 joehw Exp $ */ final class UnparsedEntityHandler implements XMLDTDFilter, EntityState { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/datatype/DatatypeFactoryImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/datatype/DatatypeFactoryImpl.java index 59497a48f5e..aa993a299c5 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/datatype/DatatypeFactoryImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/datatype/DatatypeFactoryImpl.java @@ -58,7 +58,6 @@ import javax.xml.datatype.XMLGregorianCalendar; * * @author Joseph Fialli * @author Jeff Suttor - * @version $Id: DatatypeFactoryImpl.java,v 1.6 2010/05/19 05:02:55 joehw Exp $ */ public class DatatypeFactoryImpl extends DatatypeFactory { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/datatype/DurationDayTimeImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/datatype/DurationDayTimeImpl.java index 9e5cafda554..83de0154ba6 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/datatype/DurationDayTimeImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/datatype/DurationDayTimeImpl.java @@ -46,7 +46,6 @@ import javax.xml.datatype.DatatypeConstants; * * @author Vikram Aroskar * @author Joe Wang - * @version $Revision: 1.2 $, $Date: 2010/05/19 23:20:06 $ * @see XMLGregorianCalendar#add(Duration) */ diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/datatype/DurationImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/datatype/DurationImpl.java index da5de3e1ff5..b8724a70a34 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/datatype/DurationImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/datatype/DurationImpl.java @@ -21,6 +21,7 @@ package com.sun.org.apache.xerces.internal.jaxp.datatype; +import com.sun.org.apache.xerces.internal.util.DatatypeMessageFormatter; import java.io.IOException; import java.io.ObjectStreamException; import java.io.Serializable; @@ -30,13 +31,10 @@ import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.TimeZone; - import javax.xml.datatype.DatatypeConstants; import javax.xml.datatype.Duration; import javax.xml.datatype.XMLGregorianCalendar; -import com.sun.org.apache.xerces.internal.util.DatatypeMessageFormatter; - /** *

Immutable representation of a time span as defined in * the W3C XML Schema 1.0 specification.

@@ -99,7 +97,6 @@ import com.sun.org.apache.xerces.internal.util.DatatypeMessageFormatter; * * @author Kohsuke Kawaguchi * @author Joseph Fialli - * @version $Revision: 1.8 $, $Date: 2010/05/19 23:20:06 $ * @see XMLGregorianCalendar#add(Duration) */ @@ -120,28 +117,23 @@ class DurationImpl DatatypeConstants.SECONDS }; - /** - *

Internal array of value Field ids.

- */ - private static final int[] FIELD_IDS = { - DatatypeConstants.YEARS.getId(), - DatatypeConstants.MONTHS.getId(), - DatatypeConstants.DAYS.getId(), - DatatypeConstants.HOURS.getId(), - DatatypeConstants.MINUTES.getId(), - DatatypeConstants.SECONDS.getId() - }; /** * TimeZone for GMT. */ private static final TimeZone GMT = TimeZone.getTimeZone("GMT"); - /** + /** *

BigDecimal value of 0.

*/ private static final BigDecimal ZERO = BigDecimal.valueOf(0); + /** + * BigInteger value of Integer's max value.

+ */ + private static final BigInteger MaxIntAsBigInt = + BigInteger.valueOf((long) Integer.MAX_VALUE); + /** *

Indicates the sign. -1, 0 or 1 if the duration is negative, * zero, or positive.

@@ -195,12 +187,12 @@ class DurationImpl return signum; } - /** - * TODO: Javadoc - * @param isPositive Sign. - * - * @return 1 if positive, else -1. - */ + /** + * Determine the sign of the duration. + * + * @param isPositive Sign. + * @return 1 if positive, -1 negative, or 0 if all fields are zero. + */ protected int calcSignum(boolean isPositive) { if ((years == null || years.signum() == 0) && (months == null || months.signum() == 0) @@ -694,209 +686,71 @@ class DurationImpl XMLGregorianCalendarImpl.parse("1903-07-01T00:00:00Z") }; - /** - *

Partial order relation comparison with this Duration instance.

- * - *

Comparison result must be in accordance with - * W3C XML Schema 1.0 Part 2, Section 3.2.7.6.2, - * Order relation on duration.

- * - *

Return:

- *
    - *
  • {@link DatatypeConstants#LESSER} if this Duration is shorter than duration parameter
  • - *
  • {@link DatatypeConstants#EQUAL} if this Duration is equal to duration parameter
  • - *
  • {@link DatatypeConstants#GREATER} if this Duration is longer than duration parameter
  • - *
  • {@link DatatypeConstants#INDETERMINATE} if a conclusive partial order relation cannot be determined
  • - *
- * - * @param duration to compare - * - * @return the relationship between this Durationand duration parameter as - * {@link DatatypeConstants#LESSER}, {@link DatatypeConstants#EQUAL}, {@link DatatypeConstants#GREATER} - * or {@link DatatypeConstants#INDETERMINATE}. - * - * @throws UnsupportedOperationException If the underlying implementation - * cannot reasonably process the request, e.g. W3C XML Schema allows for - * arbitrarily large/small/precise values, the request may be beyond the - * implementations capability. - * @throws NullPointerException if duration is null. - * - * @see #isShorterThan(Duration) - * @see #isLongerThan(Duration) - */ + /** + *

Partial order relation comparison with this Duration instance.

+ * + *

Comparison result must be in accordance with + * W3C XML Schema 1.0 Part 2, Section 3.2.7.6.2, + * Order relation on duration.

+ * + *

Return:

+ *
    + *
  • {@link DatatypeConstants#LESSER} if this Duration is shorter than duration parameter
  • + *
  • {@link DatatypeConstants#EQUAL} if this Duration is equal to duration parameter
  • + *
  • {@link DatatypeConstants#GREATER} if this Duration is longer than duration parameter
  • + *
  • {@link DatatypeConstants#INDETERMINATE} if a conclusive partial order relation cannot be determined
  • + *
+ * + * @param duration to compare + * + * @return the relationship between this Durationand duration parameter as + * {@link DatatypeConstants#LESSER}, {@link DatatypeConstants#EQUAL}, {@link DatatypeConstants#GREATER} + * or {@link DatatypeConstants#INDETERMINATE}. + * + * @throws UnsupportedOperationException If the underlying implementation + * cannot reasonably process the request, e.g. W3C XML Schema allows for + * arbitrarily large/small/precise values, the request may be beyond the + * implementations capability. + * @throws NullPointerException if duration is null. + * + * @see #isShorterThan(Duration) + * @see #isLongerThan(Duration) + */ public int compare(Duration rhs) { + /** check if any field in the Durations is too large for the operation + * that uses XMLGregorianCalendar for comparison + */ + for (DatatypeConstants.Field field : FIELDS) { + checkMaxValue(getField(field), field); + checkMaxValue(rhs.getField(field), field); + } - BigInteger maxintAsBigInteger = BigInteger.valueOf(Integer.MAX_VALUE); + return compareDates(this, rhs); + } - // check for fields that are too large in this Duration - if (years != null && years.compareTo(maxintAsBigInteger) == 1) { + /** + * Check if a field exceeds the maximum value + * @param field the value of a field + * @param fieldType type of the field, e.g. year, month, day, hour, minute or second. + */ + private void checkMaxValue(Number field, DatatypeConstants.Field fieldType) { + BigInteger fieldValue = null; + if (fieldType != DatatypeConstants.SECONDS) { + fieldValue = (BigInteger) field; + } else { + BigDecimal rhsSecondsAsBigDecimal = (BigDecimal) field; + if ( rhsSecondsAsBigDecimal != null ) { + fieldValue = rhsSecondsAsBigDecimal.toBigInteger(); + } + } + + if (fieldValue != null && fieldValue.compareTo(MaxIntAsBigInt) == 1) { throw new UnsupportedOperationException( - DatatypeMessageFormatter.formatMessage(null, "TooLarge", - new Object[]{this.getClass().getName() + "#compare(Duration duration)" + DatatypeConstants.YEARS.toString(), years.toString()}) - //this.getClass().getName() + "#compare(Duration duration)" - //+ " years too large to be supported by this implementation " - //+ years.toString() - ); + DatatypeMessageFormatter.formatMessage(null, "TooLarge", + new Object[]{this.getClass().getName() + "#compare(Duration duration)" + + fieldType, field.toString()}) + ); } - if (months != null && months.compareTo(maxintAsBigInteger) == 1) { - throw new UnsupportedOperationException( - DatatypeMessageFormatter.formatMessage(null, "TooLarge", - new Object[]{this.getClass().getName() + "#compare(Duration duration)" + DatatypeConstants.MONTHS.toString(), months.toString()}) - - //this.getClass().getName() + "#compare(Duration duration)" - //+ " months too large to be supported by this implementation " - //+ months.toString() - ); - } - if (days != null && days.compareTo(maxintAsBigInteger) == 1) { - throw new UnsupportedOperationException( - DatatypeMessageFormatter.formatMessage(null, "TooLarge", - new Object[]{this.getClass().getName() + "#compare(Duration duration)" + DatatypeConstants.DAYS.toString(), days.toString()}) - - //this.getClass().getName() + "#compare(Duration duration)" - //+ " days too large to be supported by this implementation " - //+ days.toString() - ); - } - if (hours != null && hours.compareTo(maxintAsBigInteger) == 1) { - throw new UnsupportedOperationException( - DatatypeMessageFormatter.formatMessage(null, "TooLarge", - new Object[]{this.getClass().getName() + "#compare(Duration duration)" + DatatypeConstants.HOURS.toString(), hours.toString()}) - - //this.getClass().getName() + "#compare(Duration duration)" - //+ " hours too large to be supported by this implementation " - //+ hours.toString() - ); - } - if (minutes != null && minutes.compareTo(maxintAsBigInteger) == 1) { - throw new UnsupportedOperationException( - DatatypeMessageFormatter.formatMessage(null, "TooLarge", - new Object[]{this.getClass().getName() + "#compare(Duration duration)" + DatatypeConstants.MINUTES.toString(), minutes.toString()}) - - //this.getClass().getName() + "#compare(Duration duration)" - //+ " minutes too large to be supported by this implementation " - //+ minutes.toString() - ); - } - if (seconds != null && seconds.toBigInteger().compareTo(maxintAsBigInteger) == 1) { - throw new UnsupportedOperationException( - DatatypeMessageFormatter.formatMessage(null, "TooLarge", - new Object[]{this.getClass().getName() + "#compare(Duration duration)" + DatatypeConstants.SECONDS.toString(), toString(seconds)}) - - //this.getClass().getName() + "#compare(Duration duration)" - //+ " seconds too large to be supported by this implementation " - //+ seconds.toString() - ); - } - - // check for fields that are too large in rhs Duration - BigInteger rhsYears = (BigInteger) rhs.getField(DatatypeConstants.YEARS); - if (rhsYears != null && rhsYears.compareTo(maxintAsBigInteger) == 1) { - throw new UnsupportedOperationException( - DatatypeMessageFormatter.formatMessage(null, "TooLarge", - new Object[]{this.getClass().getName() + "#compare(Duration duration)" + DatatypeConstants.YEARS.toString(), rhsYears.toString()}) - - //this.getClass().getName() + "#compare(Duration duration)" - //+ " years too large to be supported by this implementation " - //+ rhsYears.toString() - ); - } - BigInteger rhsMonths = (BigInteger) rhs.getField(DatatypeConstants.MONTHS); - if (rhsMonths != null && rhsMonths.compareTo(maxintAsBigInteger) == 1) { - throw new UnsupportedOperationException( - DatatypeMessageFormatter.formatMessage(null, "TooLarge", - new Object[]{this.getClass().getName() + "#compare(Duration duration)" + DatatypeConstants.MONTHS.toString(), rhsMonths.toString()}) - - //this.getClass().getName() + "#compare(Duration duration)" - //+ " months too large to be supported by this implementation " - //+ rhsMonths.toString() - ); - } - BigInteger rhsDays = (BigInteger) rhs.getField(DatatypeConstants.DAYS); - if (rhsDays != null && rhsDays.compareTo(maxintAsBigInteger) == 1) { - throw new UnsupportedOperationException( - DatatypeMessageFormatter.formatMessage(null, "TooLarge", - new Object[]{this.getClass().getName() + "#compare(Duration duration)" + DatatypeConstants.DAYS.toString(), rhsDays.toString()}) - - //this.getClass().getName() + "#compare(Duration duration)" - //+ " days too large to be supported by this implementation " - //+ rhsDays.toString() - ); - } - BigInteger rhsHours = (BigInteger) rhs.getField(DatatypeConstants.HOURS); - if (rhsHours != null && rhsHours.compareTo(maxintAsBigInteger) == 1) { - throw new UnsupportedOperationException( - DatatypeMessageFormatter.formatMessage(null, "TooLarge", - new Object[]{this.getClass().getName() + "#compare(Duration duration)" + DatatypeConstants.HOURS.toString(), rhsHours.toString()}) - - //this.getClass().getName() + "#compare(Duration duration)" - //+ " hours too large to be supported by this implementation " - //+ rhsHours.toString() - ); - } - BigInteger rhsMinutes = (BigInteger) rhs.getField(DatatypeConstants.MINUTES); - if (rhsMinutes != null && rhsMinutes.compareTo(maxintAsBigInteger) == 1) { - throw new UnsupportedOperationException( - DatatypeMessageFormatter.formatMessage(null, "TooLarge", - new Object[]{this.getClass().getName() + "#compare(Duration duration)" + DatatypeConstants.MINUTES.toString(), rhsMinutes.toString()}) - - //this.getClass().getName() + "#compare(Duration duration)" - //+ " minutes too large to be supported by this implementation " - //+ rhsMinutes.toString() - ); - } - BigDecimal rhsSecondsAsBigDecimal = (BigDecimal) rhs.getField(DatatypeConstants.SECONDS); - BigInteger rhsSeconds = null; - if ( rhsSecondsAsBigDecimal != null ) { - rhsSeconds = rhsSecondsAsBigDecimal.toBigInteger(); - } - if (rhsSeconds != null && rhsSeconds.compareTo(maxintAsBigInteger) == 1) { - throw new UnsupportedOperationException( - DatatypeMessageFormatter.formatMessage(null, "TooLarge", - new Object[]{this.getClass().getName() + "#compare(Duration duration)" + DatatypeConstants.SECONDS.toString(), rhsSeconds.toString()}) - - //this.getClass().getName() + "#compare(Duration duration)" - //+ " seconds too large to be supported by this implementation " - //+ rhsSeconds.toString() - ); - } - - // turn this Duration into a GregorianCalendar - GregorianCalendar lhsCalendar = new GregorianCalendar( - 1970, - 1, - 1, - 0, - 0, - 0); - lhsCalendar.add(GregorianCalendar.YEAR, getYears() * getSign()); - lhsCalendar.add(GregorianCalendar.MONTH, getMonths() * getSign()); - lhsCalendar.add(GregorianCalendar.DAY_OF_YEAR, getDays() * getSign()); - lhsCalendar.add(GregorianCalendar.HOUR_OF_DAY, getHours() * getSign()); - lhsCalendar.add(GregorianCalendar.MINUTE, getMinutes() * getSign()); - lhsCalendar.add(GregorianCalendar.SECOND, getSeconds() * getSign()); - - // turn compare Duration into a GregorianCalendar - GregorianCalendar rhsCalendar = new GregorianCalendar( - 1970, - 1, - 1, - 0, - 0, - 0); - rhsCalendar.add(GregorianCalendar.YEAR, rhs.getYears() * rhs.getSign()); - rhsCalendar.add(GregorianCalendar.MONTH, rhs.getMonths() * rhs.getSign()); - rhsCalendar.add(GregorianCalendar.DAY_OF_YEAR, rhs.getDays() * rhs.getSign()); - rhsCalendar.add(GregorianCalendar.HOUR_OF_DAY, rhs.getHours() * rhs.getSign()); - rhsCalendar.add(GregorianCalendar.MINUTE, rhs.getMinutes() * rhs.getSign()); - rhsCalendar.add(GregorianCalendar.SECOND, rhs.getSeconds() * rhs.getSign()); - - - if (lhsCalendar.equals(rhsCalendar)) { - return DatatypeConstants.EQUAL; - } - - return compareDates(this, rhs); } /** diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/datatype/DurationYearMonthImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/datatype/DurationYearMonthImpl.java index abf8c53075f..c4b41b8021b 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/datatype/DurationYearMonthImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/datatype/DurationYearMonthImpl.java @@ -42,7 +42,6 @@ import javax.xml.datatype.DatatypeConstants; * * @author Vikram Aroskar * @author Joe Wang - * @version $Revision: 1.1 $, $Date: 2010/05/19 05:02:55 $ * @see XMLGregorianCalendar#add(Duration) */ diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/datatype/XMLGregorianCalendarImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/datatype/XMLGregorianCalendarImpl.java index 6c629e95184..9026a6f5f61 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/datatype/XMLGregorianCalendarImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/datatype/XMLGregorianCalendarImpl.java @@ -188,7 +188,6 @@ import com.sun.org.apache.xerces.internal.utils.SecuritySupport; * @author Kohsuke Kawaguchi * @author Joseph Fialli * @author Sunitha Reddy - * @version $Revision: 1.14 $, $Date: 2010-11-10 07:41:41 $ * @see javax.xml.datatype.Duration * @since 1.5 */ diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/AbstractXMLSchema.java b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/AbstractXMLSchema.java index 25e13a7a5ce..2d06bc0555a 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/AbstractXMLSchema.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/AbstractXMLSchema.java @@ -30,7 +30,6 @@ import javax.xml.validation.ValidatorHandler; *

Abstract implementation of Schema for W3C XML Schemas.

* * @author Michael Glavassevich, IBM - * @version $Id: AbstractXMLSchema.java,v 1.6 2010-11-01 04:40:07 joehw Exp $ */ abstract class AbstractXMLSchema extends Schema implements XSGrammarPoolContainer { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/DOMValidatorHelper.java b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/DOMValidatorHelper.java index 4c69e70c0e4..fe006533b1d 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/DOMValidatorHelper.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/DOMValidatorHelper.java @@ -63,7 +63,6 @@ import org.xml.sax.SAXException; *

A validator helper for DOMSources.

* * @author Michael Glavassevich, IBM - * @version $Id: DOMValidatorHelper.java,v 1.9 2010-11-01 04:40:08 joehw Exp $ */ final class DOMValidatorHelper implements ValidatorHelper, EntityState { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/EmptyXMLSchema.java b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/EmptyXMLSchema.java index eca00e81d11..ba50c5175b8 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/EmptyXMLSchema.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/EmptyXMLSchema.java @@ -29,7 +29,6 @@ import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool; * which contains no schema components.

* * @author Michael Glavassevich, IBM - * @version $Id: EmptyXMLSchema.java,v 1.6 2010-11-01 04:40:08 joehw Exp $ */ final class EmptyXMLSchema extends AbstractXMLSchema implements XMLGrammarPool { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/JAXPValidationMessageFormatter.java b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/JAXPValidationMessageFormatter.java index 5c510533c98..8c50c4d477b 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/JAXPValidationMessageFormatter.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/JAXPValidationMessageFormatter.java @@ -29,7 +29,6 @@ import java.util.ResourceBundle; *

Used to format JAXP Validation API error messages using a specified locale.

* * @author Michael Glavassevich, IBM - * @version $Id: JAXPValidationMessageFormatter.java,v 1.5 2010-11-01 04:40:08 joehw Exp $ */ final class JAXPValidationMessageFormatter { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/StreamValidatorHelper.java b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/StreamValidatorHelper.java index d6c04fd984a..9e9f5aefc15 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/StreamValidatorHelper.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/StreamValidatorHelper.java @@ -48,7 +48,6 @@ import org.xml.sax.SAXException; * * @author Michael Glavassevich, IBM * @author Sunitha Reddy - * @version $Id: StreamValidatorHelper.java,v 1.7 2010-11-01 04:40:08 joehw Exp $ */ final class StreamValidatorHelper implements ValidatorHelper { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/ValidatorHandlerImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/ValidatorHandlerImpl.java index fc652af221a..1b6dd4053c1 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/ValidatorHandlerImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/ValidatorHandlerImpl.java @@ -94,7 +94,6 @@ import org.xml.sax.ext.EntityResolver2; * @author Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com) * @author Michael Glavassevich, IBM * - * @version $Id: ValidatorHandlerImpl.java,v 1.10 2010-11-01 04:40:08 joehw Exp $ */ final class ValidatorHandlerImpl extends ValidatorHandler implements DTDHandler, EntityState, PSVIProvider, ValidatorHelper, XMLDocumentHandler { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/ValidatorImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/ValidatorImpl.java index f0d18dda6f2..acf5df06994 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/ValidatorImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/ValidatorImpl.java @@ -51,7 +51,6 @@ import org.xml.sax.SAXNotSupportedException; * @author Kohsuke Kawaguchi * @author Michael Glavassevich, IBM * @author Sunitha Reddy - * @version $Id: ValidatorImpl.java,v 1.10 2010-11-01 04:40:08 joehw Exp $ */ final class ValidatorImpl extends Validator implements PSVIProvider { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java index f2dadd0fc4a..0bdd28d826f 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java @@ -65,7 +65,6 @@ import org.xml.sax.SAXParseException; * {@link SchemaFactory} for XML Schema. * * @author Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com) - * @version $Id: XMLSchemaFactory.java,v 1.11 2010-11-01 04:40:08 joehw Exp $ */ public final class XMLSchemaFactory extends SchemaFactory { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaValidatorComponentManager.java b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaValidatorComponentManager.java index dcbbabd4d4a..58a74191cf0 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaValidatorComponentManager.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaValidatorComponentManager.java @@ -55,7 +55,6 @@ import org.xml.sax.ErrorHandler; *

An implementation of XMLComponentManager for a schema validator.

* * @author Michael Glavassevich, IBM - * @version $Id: XMLSchemaValidatorComponentManager.java,v 1.9 2010-11-01 04:40:08 joehw Exp $ */ final class XMLSchemaValidatorComponentManager extends ParserConfigurationSettings implements XMLComponentManager { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/XSGrammarPoolContainer.java b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/XSGrammarPoolContainer.java index 79ef5593b06..431a0f21f01 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/XSGrammarPoolContainer.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/XSGrammarPoolContainer.java @@ -26,7 +26,6 @@ import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool; *

A container for grammar pools which only contain schema grammars.

* * @author Michael Glavassevich, IBM - * @version $Id: XSGrammarPoolContainer.java,v 1.6 2010-11-01 04:40:08 joehw Exp $ */ public interface XSGrammarPoolContainer { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/AbstractDOMParser.java b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/AbstractDOMParser.java index 88ea9518646..5e6c5773fba 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/AbstractDOMParser.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/AbstractDOMParser.java @@ -85,7 +85,6 @@ import org.xml.sax.SAXException; * @author Andy Clark, IBM * @author Elena Litani, IBM * - * @version $Id: AbstractDOMParser.java,v 1.10 2010-11-01 04:40:09 joehw Exp $ */ public class AbstractDOMParser extends AbstractXMLDocumentParser { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/AbstractSAXParser.java b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/AbstractSAXParser.java index eea7057417b..881020f0409 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/AbstractSAXParser.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/AbstractSAXParser.java @@ -77,7 +77,6 @@ import org.xml.sax.helpers.LocatorImpl; * @author Arnaud Le Hors, IBM * @author Andy Clark, IBM * - * @version $Id: AbstractSAXParser.java,v 1.6 2010-11-01 04:40:09 joehw Exp $ */ public abstract class AbstractSAXParser extends AbstractXMLDocumentParser diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/BasicParserConfiguration.java b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/BasicParserConfiguration.java index 3b352961618..c41f27d5a3f 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/BasicParserConfiguration.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/BasicParserConfiguration.java @@ -94,7 +94,6 @@ import com.sun.org.apache.xerces.internal.xni.parser.XMLParserConfiguration; * @author Arnaud Le Hors, IBM * @author Andy Clark, IBM * - * @version $Id: BasicParserConfiguration.java,v 1.6 2010-11-01 04:40:09 joehw Exp $ */ public abstract class BasicParserConfiguration extends ParserConfigurationSettings diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/DOMParser.java b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/DOMParser.java index f2020efda4b..05814b26396 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/DOMParser.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/DOMParser.java @@ -58,7 +58,6 @@ import org.xml.sax.helpers.LocatorImpl; * @author Arnaud Le Hors, IBM * @author Andy Clark, IBM * - * @version $Id: DOMParser.java,v 1.7 2010-11-01 04:40:09 joehw Exp $ */ public class DOMParser extends AbstractDOMParser { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/DOMParserImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/DOMParserImpl.java index 614c826047e..0053d984291 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/DOMParserImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/DOMParserImpl.java @@ -79,7 +79,6 @@ import org.xml.sax.SAXException; * @author Pavani Mukthipudi, Sun Microsystems Inc. * @author Elena Litani, IBM * @author Rahul Srivastava, Sun Microsystems Inc. - * @version $Id: DOMParserImpl.java,v 1.8 2010-11-01 04:40:09 joehw Exp $ */ diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/DTDConfiguration.java b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/DTDConfiguration.java index 0f37f7c375e..ce27b8b1c72 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/DTDConfiguration.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/DTDConfiguration.java @@ -87,7 +87,6 @@ import com.sun.org.apache.xerces.internal.xni.parser.XMLPullParserConfiguration; * @author Andy Clark, IBM * @author Neil Graham, IBM * - * @version $Id: DTDConfiguration.java,v 1.7 2010-11-01 04:40:09 joehw Exp $ */ public class DTDConfiguration extends BasicParserConfiguration diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/NonValidatingConfiguration.java b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/NonValidatingConfiguration.java index 469780136cd..834fdbf487a 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/NonValidatingConfiguration.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/NonValidatingConfiguration.java @@ -59,7 +59,6 @@ import com.sun.org.apache.xerces.internal.xni.parser.XMLPullParserConfiguration; * include the replacement text of internal entities, and supply default attribute values". * * @author Elena Litani, IBM - * @version $Id: NonValidatingConfiguration.java,v 1.7 2010-11-01 04:40:09 joehw Exp $ */ public class NonValidatingConfiguration extends BasicParserConfiguration diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/SAXParser.java b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/SAXParser.java index 48b8a1ed538..811d957686e 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/SAXParser.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/SAXParser.java @@ -37,7 +37,6 @@ import org.xml.sax.SAXNotSupportedException; * @author Arnaud Le Hors, IBM * @author Andy Clark, IBM * - * @version $Id: SAXParser.java,v 1.7 2010-11-01 04:40:09 joehw Exp $ */ public class SAXParser extends AbstractSAXParser { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/SecurityConfiguration.java b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/SecurityConfiguration.java index 65c85d164ca..7eba8746e59 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/SecurityConfiguration.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/SecurityConfiguration.java @@ -44,7 +44,6 @@ import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager; * * @author Neil Graham, IBM * - * @version $Id: SecurityConfiguration.java,v 1.6 2010-11-01 04:40:09 joehw Exp $ */ public class SecurityConfiguration extends XIncludeAwareParserConfiguration { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/StandardParserConfiguration.java b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/StandardParserConfiguration.java index 7caad5bc25a..5ac09f8f866 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/StandardParserConfiguration.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/StandardParserConfiguration.java @@ -64,7 +64,6 @@ import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException; * @author Arnaud Le Hors, IBM * @author Andy Clark, IBM * - * @version $Id: StandardParserConfiguration.java,v 1.7 2010-11-01 04:40:10 joehw Exp $ */ public class StandardParserConfiguration extends DTDConfiguration { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XIncludeAwareParserConfiguration.java b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XIncludeAwareParserConfiguration.java index 5b795e5357b..9ef0b52222c 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XIncludeAwareParserConfiguration.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XIncludeAwareParserConfiguration.java @@ -39,7 +39,6 @@ import com.sun.org.apache.xerces.internal.xni.parser.XMLDocumentSource; * * @author Michael Glavassevich, IBM * - * @version $Id: XIncludeAwareParserConfiguration.java,v 1.5 2010-11-01 04:40:10 joehw Exp $ */ public class XIncludeAwareParserConfiguration extends XML11Configuration { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XML11Configuration.java b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XML11Configuration.java index bbcbceed10e..c0283f74e3c 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XML11Configuration.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XML11Configuration.java @@ -78,7 +78,6 @@ import com.sun.org.apache.xerces.internal.xni.parser.XMLPullParserConfiguration; * @author Neil Graham, IBM * @author Michael Glavassevich, IBM * - * @version $Id: XML11Configuration.java,v 1.9 2010-11-01 04:40:10 joehw Exp $ */ public class XML11Configuration extends ParserConfigurationSettings implements XMLPullParserConfiguration, XML11Configurable { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XML11DTDConfiguration.java b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XML11DTDConfiguration.java index 3dfa85e5bd5..f7591ae608e 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XML11DTDConfiguration.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XML11DTDConfiguration.java @@ -103,7 +103,6 @@ import com.sun.org.apache.xerces.internal.xni.parser.XMLPullParserConfiguration; * @author Michael Glavassevich, IBM * @author John Kim, IBM * - * @version $Id: XML11DTDConfiguration.java,v 1.5 2010-11-01 04:40:10 joehw Exp $ */ public class XML11DTDConfiguration extends ParserConfigurationSettings implements XMLPullParserConfiguration, XML11Configurable { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XML11NonValidatingConfiguration.java b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XML11NonValidatingConfiguration.java index 43f873013e7..36a284239f3 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XML11NonValidatingConfiguration.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XML11NonValidatingConfiguration.java @@ -74,7 +74,6 @@ import com.sun.org.apache.xerces.internal.xni.parser.XMLPullParserConfiguration; * @author John Kim, IBM * @author Michael Glavassevich, IBM * - * @version $Id: XML11NonValidatingConfiguration.java,v 1.5 2010-11-01 04:40:10 joehw Exp $ */ public class XML11NonValidatingConfiguration extends ParserConfigurationSettings implements XMLPullParserConfiguration, XML11Configurable { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XMLDocumentParser.java b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XMLDocumentParser.java index 8a89e98f297..eba49fbad92 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XMLDocumentParser.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XMLDocumentParser.java @@ -33,7 +33,6 @@ import com.sun.org.apache.xerces.internal.xni.parser.XMLParserConfiguration; * @author Arnaud Le Hors, IBM * @author Andy Clark, IBM * - * @version $Id: XMLDocumentParser.java,v 1.6 2010-11-01 04:40:10 joehw Exp $ */ public class XMLDocumentParser extends AbstractXMLDocumentParser { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XMLGrammarCachingConfiguration.java b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XMLGrammarCachingConfiguration.java index 897b7542fde..4e1181a122f 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XMLGrammarCachingConfiguration.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XMLGrammarCachingConfiguration.java @@ -62,7 +62,6 @@ import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource; * * @author Neil Graham, IBM * - * @version $Id: XMLGrammarCachingConfiguration.java,v 1.6 2010-11-01 04:40:10 joehw Exp $ */ public class XMLGrammarCachingConfiguration extends XIncludeAwareParserConfiguration { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XMLGrammarParser.java b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XMLGrammarParser.java index 7d88781e679..1089493f2eb 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XMLGrammarParser.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XMLGrammarParser.java @@ -25,7 +25,6 @@ import com.sun.org.apache.xerces.internal.impl.dv.DTDDVFactory; import com.sun.org.apache.xerces.internal.util.SymbolTable; /** - * @version $Id: XMLGrammarParser.java,v 1.6 2010-11-01 04:40:10 joehw Exp $ */ public abstract class XMLGrammarParser extends XMLParser { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XMLGrammarPreparser.java b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XMLGrammarPreparser.java index 6690922da71..71063cc204f 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XMLGrammarPreparser.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XMLGrammarPreparser.java @@ -49,7 +49,6 @@ import com.sun.org.apache.xerces.internal.utils.ObjectFactory; * * @author Neil Graham, IBM * - * @version $Id: XMLGrammarPreparser.java,v 1.7 2010-11-01 04:40:10 joehw Exp $ */ public class XMLGrammarPreparser { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XMLParser.java b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XMLParser.java index 970cc51cd26..fe7801fcbb3 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XMLParser.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XMLParser.java @@ -49,7 +49,6 @@ import org.xml.sax.SAXNotRecognizedException; * @author Arnaud Le Hors, IBM * @author Andy Clark, IBM * - * @version $Id: XMLParser.java,v 1.5 2007/07/20 14:11:21 spericas Exp $ */ public abstract class XMLParser { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/util/DOMUtil.java b/jaxp/src/com/sun/org/apache/xerces/internal/util/DOMUtil.java index da13e8fd1a9..4a00810f106 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/util/DOMUtil.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/util/DOMUtil.java @@ -42,7 +42,6 @@ import org.w3c.dom.ls.LSException; * (such as a DTM), we should easily be able to convert our schema * parsing to utilize it. * - * @version $Id: DOMUtil.java,v 1.7 2010-11-01 04:40:14 joehw Exp $ */ public class DOMUtil { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/util/DatatypeMessageFormatter.java b/jaxp/src/com/sun/org/apache/xerces/internal/util/DatatypeMessageFormatter.java index b964a8fbfd8..500769db59a 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/util/DatatypeMessageFormatter.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/util/DatatypeMessageFormatter.java @@ -29,7 +29,6 @@ import java.util.ResourceBundle; *

Used to format JAXP 1.3 Datatype API error messages using a specified locale.

* * @author Neeraj Bajaj, Sun Microsystems - * @version $Id: DatatypeMessageFormatter.java,v 1.6 2010-11-01 04:40:14 joehw Exp $ */ public class DatatypeMessageFormatter { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/util/EncodingMap.java b/jaxp/src/com/sun/org/apache/xerces/internal/util/EncodingMap.java index 8b083a3ba46..8c4748966c4 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/util/EncodingMap.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/util/EncodingMap.java @@ -470,7 +470,6 @@ import java.util.Hashtable; * @author TAMURA Kent, IBM * @author Andy Clark, IBM * - * @version $Id$ */ public class EncodingMap { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/util/JAXPNamespaceContextWrapper.java b/jaxp/src/com/sun/org/apache/xerces/internal/util/JAXPNamespaceContextWrapper.java index cdf62d01ab9..b14922c9154 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/util/JAXPNamespaceContextWrapper.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/util/JAXPNamespaceContextWrapper.java @@ -37,7 +37,6 @@ import com.sun.org.apache.xerces.internal.xni.NamespaceContext; * * @author Michael Glavassevich, IBM * - * @version $Id: JAXPNamespaceContextWrapper.java,v 1.2 2010-10-26 23:01:13 joehw Exp $ */ public final class JAXPNamespaceContextWrapper implements NamespaceContext { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/util/ParserConfigurationSettings.java b/jaxp/src/com/sun/org/apache/xerces/internal/util/ParserConfigurationSettings.java index a13d8154c96..17281841704 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/util/ParserConfigurationSettings.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/util/ParserConfigurationSettings.java @@ -43,7 +43,6 @@ import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException; * * @author Andy Clark, IBM * - * @version $Id: ParserConfigurationSettings.java,v 1.6 2010-11-01 04:40:14 joehw Exp $ */ public class ParserConfigurationSettings implements XMLComponentManager { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/util/SAXMessageFormatter.java b/jaxp/src/com/sun/org/apache/xerces/internal/util/SAXMessageFormatter.java index 29648a629f9..5c87f4ba497 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/util/SAXMessageFormatter.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/util/SAXMessageFormatter.java @@ -29,7 +29,6 @@ import java.util.ResourceBundle; * * @author Michael Glavassevich, IBM * - * @version $Id: SAXMessageFormatter.java,v 1.6 2010-11-01 04:40:14 joehw Exp $ */ public class SAXMessageFormatter { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/util/StAXInputSource.java b/jaxp/src/com/sun/org/apache/xerces/internal/util/StAXInputSource.java index 24def72fa7b..6cc9aa6cb48 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/util/StAXInputSource.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/util/StAXInputSource.java @@ -30,7 +30,6 @@ import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource; /** *

An XMLInputSource analogue to javax.xml.transform.stax.StAXSource.

* - * @version $Id: StAXInputSource.java,v 1.2 2010-10-26 23:01:17 joehw Exp $ */ public final class StAXInputSource extends XMLInputSource { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/util/StAXLocationWrapper.java b/jaxp/src/com/sun/org/apache/xerces/internal/util/StAXLocationWrapper.java index 566533d1582..22b806295ac 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/util/StAXLocationWrapper.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/util/StAXLocationWrapper.java @@ -32,7 +32,6 @@ import com.sun.org.apache.xerces.internal.xni.XMLLocator; * * @author Michael Glavassevich, IBM * - * @version $Id: StAXLocationWrapper.java,v 1.2 2010-10-26 23:01:13 joehw Exp $ */ public final class StAXLocationWrapper implements XMLLocator { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/util/SymbolHash.java b/jaxp/src/com/sun/org/apache/xerces/internal/util/SymbolHash.java index dee8383ea4a..ae0aacb723b 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/util/SymbolHash.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/util/SymbolHash.java @@ -28,7 +28,6 @@ package com.sun.org.apache.xerces.internal.util; * The hash code uses the same algorithm as SymbolTable class. * * @author Elena Litani - * @version $Id: SymbolHash.java,v 1.7 2010-11-01 04:40:14 joehw Exp $ */ public class SymbolHash { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/util/XML11Char.java b/jaxp/src/com/sun/org/apache/xerces/internal/util/XML11Char.java index d19518e6afa..8c9e3412e7d 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/util/XML11Char.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/util/XML11Char.java @@ -41,7 +41,6 @@ import java.util.Arrays; * @author Neil Graham, IBM * @author Michael Glavassevich, IBM * - * @version $Id: XML11Char.java,v 1.7 2010-11-01 04:40:15 joehw Exp $ */ public class XML11Char { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/util/XMLAttributesImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/util/XMLAttributesImpl.java index a3b879f2fbc..55717373866 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/util/XMLAttributesImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/util/XMLAttributesImpl.java @@ -83,7 +83,6 @@ import com.sun.org.apache.xerces.internal.xni.XMLString; * @author Elena Litani, IBM * @author Michael Glavassevich, IBM * - * @version $Id: XMLAttributesImpl.java,v 1.7 2010/05/07 20:13:09 joehw Exp $ */ public class XMLAttributesImpl implements XMLAttributes, XMLBufferListener { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/util/XMLChar.java b/jaxp/src/com/sun/org/apache/xerces/internal/util/XMLChar.java index 731b31a70ab..b649c34efa8 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/util/XMLChar.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/util/XMLChar.java @@ -44,7 +44,6 @@ import java.util.Arrays; * @author Michael Glavassevich, IBM * @author Rahul Srivastava, Sun Microsystems Inc. * - * @version $Id: XMLChar.java,v 1.7 2010-11-01 04:40:15 joehw Exp $ */ public class XMLChar { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/utils/ObjectFactory.java b/jaxp/src/com/sun/org/apache/xerces/internal/utils/ObjectFactory.java index 2e4ceeae001..0ec5ad520a3 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/utils/ObjectFactory.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/utils/ObjectFactory.java @@ -32,7 +32,6 @@ package com.sun.org.apache.xerces.internal.utils; * when bundled as part of the JDK. *

* - * @version $Id: ObjectFactory.java,v 1.6 2010/04/23 01:44:34 joehw Exp $ */ public final class ObjectFactory { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/xinclude/XIncludeHandler.java b/jaxp/src/com/sun/org/apache/xerces/internal/xinclude/XIncludeHandler.java index a060f99e091..016a6168873 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/xinclude/XIncludeHandler.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/xinclude/XIncludeHandler.java @@ -115,7 +115,6 @@ import java.util.Objects; * @author Peter McCracken, IBM * @author Michael Glavassevich, IBM * - * @version $Id: XIncludeHandler.java,v 1.7 2010-11-01 04:40:18 joehw Exp $ * * @see XIncludeNamespaceSupport */ diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/xinclude/XIncludeMessageFormatter.java b/jaxp/src/com/sun/org/apache/xerces/internal/xinclude/XIncludeMessageFormatter.java index 0275615e2fc..4420e29934d 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/xinclude/XIncludeMessageFormatter.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/xinclude/XIncludeMessageFormatter.java @@ -32,7 +32,6 @@ import java.util.ResourceBundle; * * @author Peter McCracken, IBM * - * @version $Id: XIncludeMessageFormatter.java,v 1.7 2010-11-01 04:40:18 joehw Exp $ */ public class XIncludeMessageFormatter implements MessageFormatter { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/xni/QName.java b/jaxp/src/com/sun/org/apache/xerces/internal/xni/QName.java index 5c47b7a53be..d6d5ce6a63d 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/xni/QName.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/xni/QName.java @@ -77,7 +77,6 @@ package com.sun.org.apache.xerces.internal.xni; * == were used to compare strings * @author Joe Wang, Oracle * - * @version $Id: QName.java,v 1.6 2010/03/18 19:32:31 joehw Exp $ */ public class QName implements Cloneable { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/xni/XNIException.java b/jaxp/src/com/sun/org/apache/xerces/internal/xni/XNIException.java index 4247551e5eb..98b9d40abad 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/xni/XNIException.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/xni/XNIException.java @@ -32,7 +32,6 @@ package com.sun.org.apache.xerces.internal.xni; * * @author Andy Clark, IBM * - * @version $Id: XNIException.java,v 1.6 2010-11-01 04:40:19 joehw Exp $ */ public class XNIException extends RuntimeException { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/xni/parser/XMLComponentManager.java b/jaxp/src/com/sun/org/apache/xerces/internal/xni/parser/XMLComponentManager.java index 80faa6a6d02..1ea05c6babd 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/xni/parser/XMLComponentManager.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/xni/parser/XMLComponentManager.java @@ -36,7 +36,6 @@ import com.sun.org.apache.xerces.internal.util.PropertyState; * * @author Andy Clark, IBM * - * @version $Id: XMLComponentManager.java,v 1.6 2010-11-01 04:40:22 joehw Exp $ */ public interface XMLComponentManager { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/xni/parser/XMLConfigurationException.java b/jaxp/src/com/sun/org/apache/xerces/internal/xni/parser/XMLConfigurationException.java index b1cd779c483..3f1280d1fb8 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/xni/parser/XMLConfigurationException.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/xni/parser/XMLConfigurationException.java @@ -30,7 +30,6 @@ import com.sun.org.apache.xerces.internal.xni.XNIException; * * @author Andy Clark, IBM * - * @version $Id: XMLConfigurationException.java,v 1.7 2010-11-01 04:40:22 joehw Exp $ */ public class XMLConfigurationException extends XNIException { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/xpointer/ElementSchemePointer.java b/jaxp/src/com/sun/org/apache/xerces/internal/xpointer/ElementSchemePointer.java index 5f44b08289f..33bf6b880e7 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/xpointer/ElementSchemePointer.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/xpointer/ElementSchemePointer.java @@ -38,7 +38,6 @@ import com.sun.org.apache.xerces.internal.xni.parser.XMLErrorHandler; * * @xerces.internal * - * @version $Id: ElementSchemePointer.java,v 1.4 2009/06/11 23:51:50 joehw Exp $ */ final class ElementSchemePointer implements XPointerPart { @@ -498,7 +497,6 @@ final class ElementSchemePointer implements XPointerPart { * @xerces.internal * * @author Neil Delima, IBM - * @version $Id: ElementSchemePointer.java,v 1.4 2009/06/11 23:51:50 joehw Exp $ * */ private final class Tokens { @@ -656,7 +654,6 @@ final class ElementSchemePointer implements XPointerPart { * * @xerces.internal * - * @version $Id: ElementSchemePointer.java,v 1.4 2009/06/11 23:51:50 joehw Exp $ */ private class Scanner { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/xpointer/XPointerMessageFormatter.java b/jaxp/src/com/sun/org/apache/xerces/internal/xpointer/XPointerMessageFormatter.java index 36ee4811039..12603a8d722 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/xpointer/XPointerMessageFormatter.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/xpointer/XPointerMessageFormatter.java @@ -34,7 +34,6 @@ import com.sun.org.apache.xerces.internal.utils.SecuritySupport; * * @xerces.internal * - * @version $Id: XPointerMessageFormatter.java,v 1.5 2010-11-01 04:40:26 joehw Exp $ */ final class XPointerMessageFormatter implements MessageFormatter { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/xs/datatypes/ByteList.java b/jaxp/src/com/sun/org/apache/xerces/internal/xs/datatypes/ByteList.java index a1138401296..c1d1edefd03 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/xs/datatypes/ByteList.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/xs/datatypes/ByteList.java @@ -29,7 +29,6 @@ import com.sun.org.apache.xerces.internal.xs.XSException; * * @author Ankit Pasricha, IBM * - * @version $Id: ByteList.java,v 1.7 2010-11-01 04:40:31 joehw Exp $ */ public interface ByteList extends List { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/xs/datatypes/ObjectList.java b/jaxp/src/com/sun/org/apache/xerces/internal/xs/datatypes/ObjectList.java index c47853f8ea5..141fb0a7b26 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/xs/datatypes/ObjectList.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/xs/datatypes/ObjectList.java @@ -27,7 +27,6 @@ import java.util.List; * * @author Ankit Pasricha, IBM * - * @version $Id: ObjectList.java,v 1.7 2010-11-01 04:40:31 joehw Exp $ */ public interface ObjectList extends List { diff --git a/jaxp/src/com/sun/org/apache/xml/internal/resolver/readers/DOMCatalogReader.java b/jaxp/src/com/sun/org/apache/xml/internal/resolver/readers/DOMCatalogReader.java index c5740cb1c66..bd14b28ae39 100644 --- a/jaxp/src/com/sun/org/apache/xml/internal/resolver/readers/DOMCatalogReader.java +++ b/jaxp/src/com/sun/org/apache/xml/internal/resolver/readers/DOMCatalogReader.java @@ -57,7 +57,6 @@ import sun.reflect.misc.ReflectUtil; *

The selection of CatalogParsers is made on the basis of the QName * of the root element of the document.

* - *

This class requires the Java API for XML Parsing.

* * @see Catalog * @see CatalogReader diff --git a/jaxp/src/com/sun/org/apache/xml/internal/serialize/DOMSerializerImpl.java b/jaxp/src/com/sun/org/apache/xml/internal/serialize/DOMSerializerImpl.java index c9b36c5b07a..eae65068d82 100644 --- a/jaxp/src/com/sun/org/apache/xml/internal/serialize/DOMSerializerImpl.java +++ b/jaxp/src/com/sun/org/apache/xml/internal/serialize/DOMSerializerImpl.java @@ -72,7 +72,6 @@ import org.w3c.dom.ls.LSSerializerFilter; * @author Gopal Sharma, Sun Microsystems * @author Arun Yadav, Sun Microsystems * @author Sunitha Reddy, Sun Microsystems - * @version $Id: DOMSerializerImpl.java,v 1.11 2010-11-01 04:40:36 joehw Exp $ */ public class DOMSerializerImpl implements LSSerializer, DOMConfiguration { diff --git a/jaxp/src/com/sun/org/apache/xml/internal/serialize/EncodingInfo.java b/jaxp/src/com/sun/org/apache/xml/internal/serialize/EncodingInfo.java index 9c21756f8b3..252483fc53d 100644 --- a/jaxp/src/com/sun/org/apache/xml/internal/serialize/EncodingInfo.java +++ b/jaxp/src/com/sun/org/apache/xml/internal/serialize/EncodingInfo.java @@ -29,7 +29,6 @@ import com.sun.org.apache.xerces.internal.util.EncodingMap; /** * This class represents an encoding. * - * @version $Id: EncodingInfo.java,v 1.6 2007/10/18 03:39:08 joehw Exp $ */ public class EncodingInfo { diff --git a/jaxp/src/com/sun/org/apache/xml/internal/serialize/SerializerFactory.java b/jaxp/src/com/sun/org/apache/xml/internal/serialize/SerializerFactory.java index 25da0c6517a..2150e31a0b5 100644 --- a/jaxp/src/com/sun/org/apache/xml/internal/serialize/SerializerFactory.java +++ b/jaxp/src/com/sun/org/apache/xml/internal/serialize/SerializerFactory.java @@ -32,7 +32,6 @@ import java.util.StringTokenizer; /** * * - * @version $Revision: 1.6 $ $Date: 2010-11-01 04:40:36 $ * @author Scott Boag * @author Assaf Arkin */ diff --git a/jaxp/src/com/sun/org/apache/xml/internal/serializer/Encodings.java b/jaxp/src/com/sun/org/apache/xml/internal/serializer/Encodings.java index d4d95ff8cf2..80eb8a5d969 100644 --- a/jaxp/src/com/sun/org/apache/xml/internal/serializer/Encodings.java +++ b/jaxp/src/com/sun/org/apache/xml/internal/serializer/Encodings.java @@ -50,7 +50,6 @@ import com.sun.org.apache.xalan.internal.utils.SecuritySupport; * to override encoding names and provide the last printable character * for each encoding. * - * @version $Revision: 1.11 $ $Date: 2010-11-01 04:34:44 $ * @author Assaf Arkin */ diff --git a/jaxp/src/com/sun/org/apache/xpath/internal/jaxp/XPathExpressionImpl.java b/jaxp/src/com/sun/org/apache/xpath/internal/jaxp/XPathExpressionImpl.java index 925ce9c1234..dc64401eda6 100644 --- a/jaxp/src/com/sun/org/apache/xpath/internal/jaxp/XPathExpressionImpl.java +++ b/jaxp/src/com/sun/org/apache/xpath/internal/jaxp/XPathExpressionImpl.java @@ -52,7 +52,6 @@ import org.xml.sax.InputSource; /** * The XPathExpression interface encapsulates a (compiled) XPath expression. * - * @version $Revision: 1.10 $ * @author Ramesh Mandava */ public class XPathExpressionImpl implements javax.xml.xpath.XPathExpression{ diff --git a/jaxp/src/com/sun/org/apache/xpath/internal/jaxp/XPathFactoryImpl.java b/jaxp/src/com/sun/org/apache/xpath/internal/jaxp/XPathFactoryImpl.java index b050af44674..c649306da4b 100644 --- a/jaxp/src/com/sun/org/apache/xpath/internal/jaxp/XPathFactoryImpl.java +++ b/jaxp/src/com/sun/org/apache/xpath/internal/jaxp/XPathFactoryImpl.java @@ -36,7 +36,6 @@ import javax.xml.xpath.XPathVariableResolver; /** * The XPathFactory builds XPaths. * - * @version $Revision: 1.11 $ * @author Ramesh Mandava */ public class XPathFactoryImpl extends XPathFactory { diff --git a/jaxp/src/com/sun/org/apache/xpath/internal/jaxp/XPathImpl.java b/jaxp/src/com/sun/org/apache/xpath/internal/jaxp/XPathImpl.java index af82f378917..ebd6b2c712f 100644 --- a/jaxp/src/com/sun/org/apache/xpath/internal/jaxp/XPathImpl.java +++ b/jaxp/src/com/sun/org/apache/xpath/internal/jaxp/XPathImpl.java @@ -54,7 +54,6 @@ import java.io.IOException; * of an XPath expression. * * - * @version $Revision: 1.10 $ * @author Ramesh Mandava */ public class XPathImpl implements javax.xml.xpath.XPath { diff --git a/jaxp/src/javax/xml/XMLConstants.java b/jaxp/src/javax/xml/XMLConstants.java index 8e805ec03da..70b8bdfa812 100644 --- a/jaxp/src/javax/xml/XMLConstants.java +++ b/jaxp/src/javax/xml/XMLConstants.java @@ -29,7 +29,6 @@ package javax.xml; *

Utility class to contain basic XML values as constants.

* * @author Jeff Suttor - * @version $Revision: 1.8 $, $Date: 2010/05/25 16:19:45 $ * @see Extensible Markup Language (XML) 1.1 * @see Extensible Markup Language (XML) 1.0 (Second Edition) * @see XML 1.0 Second Edition Specification Errata diff --git a/jaxp/src/javax/xml/datatype/DatatypeFactory.java b/jaxp/src/javax/xml/datatype/DatatypeFactory.java index 8138f98de1d..0a96c5760ef 100644 --- a/jaxp/src/javax/xml/datatype/DatatypeFactory.java +++ b/jaxp/src/javax/xml/datatype/DatatypeFactory.java @@ -72,7 +72,6 @@ import java.util.regex.Pattern; * @author Jeff Suttor * @author Neeraj Bajaj * - * @version $Revision: 1.13 $, $Date: 2010/03/11 23:10:53 $ * @since 1.5 */ public abstract class DatatypeFactory { diff --git a/jaxp/src/javax/xml/datatype/package.html b/jaxp/src/javax/xml/datatype/package.html index af81454af96..de065acc664 100644 --- a/jaxp/src/javax/xml/datatype/package.html +++ b/jaxp/src/javax/xml/datatype/package.html @@ -31,7 +31,6 @@ questions. javax.xml.xpath - diff --git a/jaxp/src/javax/xml/namespace/QName.java b/jaxp/src/javax/xml/namespace/QName.java index 994b2a3816c..4792f772337 100644 --- a/jaxp/src/javax/xml/namespace/QName.java +++ b/jaxp/src/javax/xml/namespace/QName.java @@ -62,7 +62,6 @@ import javax.xml.XMLConstants; *

QName is immutable.

* * @author Jeff Suttor - * @version $Revision: 1.8 $, $Date: 2010/03/18 03:06:17 $ * @see * XML Schema Part2: Datatypes specification * @see diff --git a/jaxp/src/javax/xml/parsers/DocumentBuilder.java b/jaxp/src/javax/xml/parsers/DocumentBuilder.java index 33c325d11af..95530bcdf73 100644 --- a/jaxp/src/javax/xml/parsers/DocumentBuilder.java +++ b/jaxp/src/javax/xml/parsers/DocumentBuilder.java @@ -57,6 +57,7 @@ import org.xml.sax.SAXException; * communicate with the application using these existing APIs. * * @author Jeff Suttor + * @since 1.4 */ public abstract class DocumentBuilder { diff --git a/jaxp/src/javax/xml/parsers/DocumentBuilderFactory.java b/jaxp/src/javax/xml/parsers/DocumentBuilderFactory.java index ed77da8a73f..0625b850986 100644 --- a/jaxp/src/javax/xml/parsers/DocumentBuilderFactory.java +++ b/jaxp/src/javax/xml/parsers/DocumentBuilderFactory.java @@ -34,8 +34,7 @@ import javax.xml.validation.Schema; * @author Jeff Suttor * @author Neeraj Bajaj * - * @version $Revision: 1.9 $, $Date: 2010/05/25 16:19:44 $ - + * @since 1.4 */ public abstract class DocumentBuilderFactory { @@ -440,6 +439,7 @@ public abstract class DocumentBuilderFactory { * @throws ParserConfigurationException if this DocumentBuilderFactory or the DocumentBuilders * it creates cannot support this feature. * @throws NullPointerException If the name parameter is null. + * @since 1.5 */ public abstract void setFeature(String name, boolean value) throws ParserConfigurationException; @@ -461,6 +461,7 @@ public abstract class DocumentBuilderFactory { * * @throws ParserConfigurationException if this DocumentBuilderFactory * or the DocumentBuilders it creates cannot support this feature. + * @since 1.5 */ public abstract boolean getFeature(String name) throws ParserConfigurationException; diff --git a/jaxp/src/javax/xml/parsers/FactoryConfigurationError.java b/jaxp/src/javax/xml/parsers/FactoryConfigurationError.java index be008262124..0dc01a91aa9 100644 --- a/jaxp/src/javax/xml/parsers/FactoryConfigurationError.java +++ b/jaxp/src/javax/xml/parsers/FactoryConfigurationError.java @@ -32,7 +32,7 @@ package javax.xml.parsers; * or instantiated. * * @author Jeff Suttor - * @version $Revision: 1.7 $, $Date: 2010-11-01 04:36:09 $ + * @since 1.4 */ public class FactoryConfigurationError extends Error { diff --git a/jaxp/src/javax/xml/parsers/ParserConfigurationException.java b/jaxp/src/javax/xml/parsers/ParserConfigurationException.java index ed9ecfc03d2..587d4175784 100644 --- a/jaxp/src/javax/xml/parsers/ParserConfigurationException.java +++ b/jaxp/src/javax/xml/parsers/ParserConfigurationException.java @@ -29,6 +29,7 @@ package javax.xml.parsers; * Indicates a serious configuration error. * * @author Jeff Suttor + * @since 1.4 */ public class ParserConfigurationException extends Exception { diff --git a/jaxp/src/javax/xml/parsers/SAXParser.java b/jaxp/src/javax/xml/parsers/SAXParser.java index 8a58bee232a..9be9381f59e 100644 --- a/jaxp/src/javax/xml/parsers/SAXParser.java +++ b/jaxp/src/javax/xml/parsers/SAXParser.java @@ -75,6 +75,7 @@ import org.xml.sax.helpers.DefaultHandler; * this revised class. * * @author Jeff Suttor + * @since 1.4 */ public abstract class SAXParser { diff --git a/jaxp/src/javax/xml/parsers/SAXParserFactory.java b/jaxp/src/javax/xml/parsers/SAXParserFactory.java index b0a3bb67f8e..7de367e702e 100644 --- a/jaxp/src/javax/xml/parsers/SAXParserFactory.java +++ b/jaxp/src/javax/xml/parsers/SAXParserFactory.java @@ -37,8 +37,7 @@ import org.xml.sax.SAXNotSupportedException; * @author Jeff Suttor * @author Neeraj Bajaj * - * @version $Revision: 1.9 $, $Date: 2010/05/25 16:19:44 $ - * + * @since 1.4 */ public abstract class SAXParserFactory { diff --git a/jaxp/src/javax/xml/transform/ErrorListener.java b/jaxp/src/javax/xml/transform/ErrorListener.java index b81e6119605..5d8d82c3662 100644 --- a/jaxp/src/javax/xml/transform/ErrorListener.java +++ b/jaxp/src/javax/xml/transform/ErrorListener.java @@ -49,6 +49,8 @@ package javax.xml.transform; * *

Transformers may use this mechanism to report XML parsing * errors as well as transformation errors.

+ * + * @since 1.4 */ public interface ErrorListener { diff --git a/jaxp/src/javax/xml/transform/OutputKeys.java b/jaxp/src/javax/xml/transform/OutputKeys.java index 3c0fc35e049..ac1a0213239 100644 --- a/jaxp/src/javax/xml/transform/OutputKeys.java +++ b/jaxp/src/javax/xml/transform/OutputKeys.java @@ -33,6 +33,7 @@ package javax.xml.transform; * * @see * section 16 of the XSL Transformations (XSLT) W3C Recommendation + * @since 1.4 */ public class OutputKeys { diff --git a/jaxp/src/javax/xml/transform/Result.java b/jaxp/src/javax/xml/transform/Result.java index 47472852707..fb5a42ee923 100644 --- a/jaxp/src/javax/xml/transform/Result.java +++ b/jaxp/src/javax/xml/transform/Result.java @@ -30,6 +30,7 @@ package javax.xml.transform; * needed to build a transformation result tree.

* * @author Jeff Suttor + * @since 1.4 */ public interface Result { diff --git a/jaxp/src/javax/xml/transform/Source.java b/jaxp/src/javax/xml/transform/Source.java index 3af6969d09f..fe3d7111439 100644 --- a/jaxp/src/javax/xml/transform/Source.java +++ b/jaxp/src/javax/xml/transform/Source.java @@ -28,6 +28,8 @@ package javax.xml.transform; /** * An object that implements this interface contains the information * needed to act as source input (XML source or transformation instructions). + * + * @since 1.4 */ public interface Source { diff --git a/jaxp/src/javax/xml/transform/SourceLocator.java b/jaxp/src/javax/xml/transform/SourceLocator.java index 475e6546392..e5cd840f686 100644 --- a/jaxp/src/javax/xml/transform/SourceLocator.java +++ b/jaxp/src/javax/xml/transform/SourceLocator.java @@ -28,6 +28,8 @@ package javax.xml.transform; /** * This interface is primarily for the purposes of reporting where * an error occurred in the XML source or transformation instructions. + * + * @since 1.4 */ public interface SourceLocator { diff --git a/jaxp/src/javax/xml/transform/Templates.java b/jaxp/src/javax/xml/transform/Templates.java index 9952368e7bc..9e3871800fe 100644 --- a/jaxp/src/javax/xml/transform/Templates.java +++ b/jaxp/src/javax/xml/transform/Templates.java @@ -37,6 +37,8 @@ import java.util.Properties; *

Templates must be threadsafe for a given instance * over multiple threads running concurrently, and may * be used multiple times in a given session.

+ * + * @since 1.4 */ public interface Templates { diff --git a/jaxp/src/javax/xml/transform/Transformer.java b/jaxp/src/javax/xml/transform/Transformer.java index 783e87a73fb..96292803f2e 100644 --- a/jaxp/src/javax/xml/transform/Transformer.java +++ b/jaxp/src/javax/xml/transform/Transformer.java @@ -45,6 +45,7 @@ import java.util.Properties; * output properties are preserved across transformations.

* * @author Jeff Suttor + * @since 1.4 */ public abstract class Transformer { diff --git a/jaxp/src/javax/xml/transform/TransformerConfigurationException.java b/jaxp/src/javax/xml/transform/TransformerConfigurationException.java index 7e24ac808b7..a81fde2989c 100644 --- a/jaxp/src/javax/xml/transform/TransformerConfigurationException.java +++ b/jaxp/src/javax/xml/transform/TransformerConfigurationException.java @@ -27,6 +27,8 @@ package javax.xml.transform; /** * Indicates a serious configuration error. + * + * @since 1.4 */ public class TransformerConfigurationException extends TransformerException { diff --git a/jaxp/src/javax/xml/transform/TransformerException.java b/jaxp/src/javax/xml/transform/TransformerException.java index 0985ebb0594..dfd48246e27 100644 --- a/jaxp/src/javax/xml/transform/TransformerException.java +++ b/jaxp/src/javax/xml/transform/TransformerException.java @@ -31,6 +31,8 @@ import java.lang.reflect.InvocationTargetException; /** * This class specifies an exceptional condition that occured * during the transformation process. + * + * @since 1.4 */ public class TransformerException extends Exception { diff --git a/jaxp/src/javax/xml/transform/TransformerFactoryConfigurationError.java b/jaxp/src/javax/xml/transform/TransformerFactoryConfigurationError.java index b8ac36cd58a..3eda99138af 100644 --- a/jaxp/src/javax/xml/transform/TransformerFactoryConfigurationError.java +++ b/jaxp/src/javax/xml/transform/TransformerFactoryConfigurationError.java @@ -30,6 +30,8 @@ package javax.xml.transform; * exists. This error will typically be thrown when the class of a * transformation factory specified in the system properties cannot be found * or instantiated. + * + * @since 1.4 */ public class TransformerFactoryConfigurationError extends Error { private static final long serialVersionUID = -6527718720676281516L; diff --git a/jaxp/src/javax/xml/transform/URIResolver.java b/jaxp/src/javax/xml/transform/URIResolver.java index a4ea4c052ad..d8a3ac090a2 100644 --- a/jaxp/src/javax/xml/transform/URIResolver.java +++ b/jaxp/src/javax/xml/transform/URIResolver.java @@ -28,6 +28,8 @@ package javax.xml.transform; /** *

An object that implements this interface that can be called by the processor * to turn a URI used in document(), xsl:import, or xsl:include into a Source object. + * + * @since 1.4 */ public interface URIResolver { diff --git a/jaxp/src/javax/xml/transform/dom/DOMLocator.java b/jaxp/src/javax/xml/transform/dom/DOMLocator.java index 13a7446148f..a68c031b72b 100644 --- a/jaxp/src/javax/xml/transform/dom/DOMLocator.java +++ b/jaxp/src/javax/xml/transform/dom/DOMLocator.java @@ -37,6 +37,8 @@ import org.w3c.dom.Node; * object returned by an exception. A {@link javax.xml.transform.Transformer} * may use this object for purposes other than error reporting, for instance, * to indicate the source node that originated a result node. + * + * @since 1.4 */ public interface DOMLocator extends SourceLocator { diff --git a/jaxp/src/javax/xml/transform/dom/DOMResult.java b/jaxp/src/javax/xml/transform/dom/DOMResult.java index c7adfc4ef40..67ec2418740 100644 --- a/jaxp/src/javax/xml/transform/dom/DOMResult.java +++ b/jaxp/src/javax/xml/transform/dom/DOMResult.java @@ -35,6 +35,7 @@ import org.w3c.dom.Node; * which may be retrieved with {@link #getNode()}.

* * @author Jeff Suttor + * @since 1.4 */ public class DOMResult implements Result { diff --git a/jaxp/src/javax/xml/transform/dom/DOMSource.java b/jaxp/src/javax/xml/transform/dom/DOMSource.java index 83e64fd471b..dc4e93e07f1 100644 --- a/jaxp/src/javax/xml/transform/dom/DOMSource.java +++ b/jaxp/src/javax/xml/transform/dom/DOMSource.java @@ -40,6 +40,7 @@ import org.w3c.dom.Node; * * @author Jeff Suttor * @see Document Object Model (DOM) Level 2 Specification + * @since 1.4 */ public class DOMSource implements Source { diff --git a/jaxp/src/javax/xml/transform/sax/SAXResult.java b/jaxp/src/javax/xml/transform/sax/SAXResult.java index b0158b3dcdc..bc88d6bd206 100644 --- a/jaxp/src/javax/xml/transform/sax/SAXResult.java +++ b/jaxp/src/javax/xml/transform/sax/SAXResult.java @@ -34,6 +34,7 @@ import org.xml.sax.ext.LexicalHandler; *

Acts as an holder for a transformation Result.

* * @author Jeff Suttor + * @since 1.4 */ public class SAXResult implements Result { diff --git a/jaxp/src/javax/xml/transform/sax/SAXSource.java b/jaxp/src/javax/xml/transform/sax/SAXSource.java index 52315646cf3..0d573780e56 100644 --- a/jaxp/src/javax/xml/transform/sax/SAXSource.java +++ b/jaxp/src/javax/xml/transform/sax/SAXSource.java @@ -41,6 +41,7 @@ import org.xml.sax.XMLReader; * {@link javax.xml.parsers.SAXParserFactory#setNamespaceAware(boolean awareness)} method.

* * @author Jeff Suttor + * @since 1.4 */ public class SAXSource implements Source { diff --git a/jaxp/src/javax/xml/transform/sax/SAXTransformerFactory.java b/jaxp/src/javax/xml/transform/sax/SAXTransformerFactory.java index 777e0bf2420..cb419e20c37 100644 --- a/jaxp/src/javax/xml/transform/sax/SAXTransformerFactory.java +++ b/jaxp/src/javax/xml/transform/sax/SAXTransformerFactory.java @@ -39,6 +39,8 @@ import org.xml.sax.XMLFilter; * for an XMLReader used during a transformation, it should use a URIResolver * to return the SAXSource which provides (with getXMLReader) a reference to * the XMLReader.

+ * + * @since 1.4 */ public abstract class SAXTransformerFactory extends TransformerFactory { diff --git a/jaxp/src/javax/xml/transform/sax/TemplatesHandler.java b/jaxp/src/javax/xml/transform/sax/TemplatesHandler.java index 34b5ba2bec4..b2efea5d88c 100644 --- a/jaxp/src/javax/xml/transform/sax/TemplatesHandler.java +++ b/jaxp/src/javax/xml/transform/sax/TemplatesHandler.java @@ -34,6 +34,8 @@ import org.xml.sax.ContentHandler; * parse events (parsing transformation instructions) into a Templates object. * *

Note that TemplatesHandler does not need to implement LexicalHandler.

+ * + * @since 1.4 */ public interface TemplatesHandler extends ContentHandler { diff --git a/jaxp/src/javax/xml/transform/sax/TransformerHandler.java b/jaxp/src/javax/xml/transform/sax/TransformerHandler.java index 8bced5e8649..3c15367f892 100644 --- a/jaxp/src/javax/xml/transform/sax/TransformerHandler.java +++ b/jaxp/src/javax/xml/transform/sax/TransformerHandler.java @@ -36,6 +36,8 @@ import org.xml.sax.ext.LexicalHandler; * A TransformerHandler * listens for SAX ContentHandler parse events and transforms * them to a Result. + * + * @since 1.4 */ public interface TransformerHandler extends ContentHandler, LexicalHandler, DTDHandler { diff --git a/jaxp/src/javax/xml/transform/stream/StreamResult.java b/jaxp/src/javax/xml/transform/stream/StreamResult.java index 39df253fa12..57db8665801 100644 --- a/jaxp/src/javax/xml/transform/stream/StreamResult.java +++ b/jaxp/src/javax/xml/transform/stream/StreamResult.java @@ -37,6 +37,7 @@ import java.net.MalformedURLException; * which may be XML, plain Text, HTML, or some other form of markup.

* * @author Jeff Suttor + * @since 1.4 */ public class StreamResult implements Result { diff --git a/jaxp/src/javax/xml/transform/stream/StreamSource.java b/jaxp/src/javax/xml/transform/stream/StreamSource.java index ad41b9d303d..7627d5e3b55 100644 --- a/jaxp/src/javax/xml/transform/stream/StreamSource.java +++ b/jaxp/src/javax/xml/transform/stream/StreamSource.java @@ -39,6 +39,7 @@ import javax.xml.transform.Source; * StreamSource instances may only be used once.

* * @author Jeff Suttor + * @since 1.4 */ public class StreamSource implements Source { diff --git a/jaxp/src/javax/xml/validation/SchemaFactoryFinder.java b/jaxp/src/javax/xml/validation/SchemaFactoryFinder.java index 907e67a66fa..16b84f636bd 100644 --- a/jaxp/src/javax/xml/validation/SchemaFactoryFinder.java +++ b/jaxp/src/javax/xml/validation/SchemaFactoryFinder.java @@ -40,7 +40,6 @@ import java.util.ServiceLoader; * Implementation of {@link SchemaFactory#newInstance(String)}. * * @author Kohsuke Kawaguchi - * @version $Revision: 1.8 $, $Date: 2010-11-01 04:36:13 $ * @since 1.5 */ class SchemaFactoryFinder { diff --git a/jaxp/src/javax/xml/xpath/XPathFactoryFinder.java b/jaxp/src/javax/xml/xpath/XPathFactoryFinder.java index f99ddc8a0c2..bceeda854e8 100644 --- a/jaxp/src/javax/xml/xpath/XPathFactoryFinder.java +++ b/jaxp/src/javax/xml/xpath/XPathFactoryFinder.java @@ -40,7 +40,6 @@ import java.util.ServiceLoader; * Implementation of {@link XPathFactory#newInstance(String)}. * * @author Kohsuke Kawaguchi - * @version $Revision: 1.7 $, $Date: 2010-11-01 04:36:14 $ * @since 1.5 */ class XPathFactoryFinder { diff --git a/jaxp/src/javax/xml/xpath/package.html b/jaxp/src/javax/xml/xpath/package.html index 6f49222a255..82415a2d407 100644 --- a/jaxp/src/javax/xml/xpath/package.html +++ b/jaxp/src/javax/xml/xpath/package.html @@ -32,7 +32,6 @@ questions. - diff --git a/jaxp/src/org/w3c/dom/Attr.java b/jaxp/src/org/w3c/dom/Attr.java index 8231a54156a..8db99e9a6a1 100644 --- a/jaxp/src/org/w3c/dom/Attr.java +++ b/jaxp/src/org/w3c/dom/Attr.java @@ -239,7 +239,7 @@ public interface Attr extends Node { /** * The Element node this attribute is attached to or * null if this attribute is not in use. - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public Element getOwnerElement(); @@ -249,7 +249,7 @@ public interface Attr extends Node { * after loading the document or invoking * Document.normalizeDocument(), schemaTypeInfo * may not be reliable if the node was moved. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public TypeInfo getSchemaTypeInfo(); @@ -297,7 +297,7 @@ public interface Attr extends Node { * reevaluated in accordance to the schema used. As a consequence, if * the Attr.schemaTypeInfo attribute contains an ID type, * isId will always return true. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public boolean isId(); diff --git a/jaxp/src/org/w3c/dom/DOMConfiguration.java b/jaxp/src/org/w3c/dom/DOMConfiguration.java index 4a3e66b020c..320ca42b592 100644 --- a/jaxp/src/org/w3c/dom/DOMConfiguration.java +++ b/jaxp/src/org/w3c/dom/DOMConfiguration.java @@ -383,7 +383,7 @@ package org.w3c.dom; * set, Document.normalizeDocument() will invoke the resource * resolver instead of using Document.documentURI. *

See also the Document Object Model (DOM) Level 3 Core Specification. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public interface DOMConfiguration { /** diff --git a/jaxp/src/org/w3c/dom/DOMError.java b/jaxp/src/org/w3c/dom/DOMError.java index 15821c865d4..c0a00cd5c3c 100644 --- a/jaxp/src/org/w3c/dom/DOMError.java +++ b/jaxp/src/org/w3c/dom/DOMError.java @@ -44,7 +44,7 @@ package org.w3c.dom; /** * DOMError is an interface that describes an error. *

See also the Document Object Model (DOM) Level 3 Core Specification. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public interface DOMError { // ErrorSeverity diff --git a/jaxp/src/org/w3c/dom/DOMErrorHandler.java b/jaxp/src/org/w3c/dom/DOMErrorHandler.java index 1de0cb9387e..82e9988deff 100644 --- a/jaxp/src/org/w3c/dom/DOMErrorHandler.java +++ b/jaxp/src/org/w3c/dom/DOMErrorHandler.java @@ -53,7 +53,7 @@ package org.w3c.dom; *

The application that is using the DOM implementation is expected to * implement this interface. *

See also the Document Object Model (DOM) Level 3 Core Specification. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public interface DOMErrorHandler { /** diff --git a/jaxp/src/org/w3c/dom/DOMException.java b/jaxp/src/org/w3c/dom/DOMException.java index b351b7b7362..679c6a7c363 100644 --- a/jaxp/src/org/w3c/dom/DOMException.java +++ b/jaxp/src/org/w3c/dom/DOMException.java @@ -116,29 +116,29 @@ public class DOMException extends RuntimeException { /** * If an attempt is made to use an object that is not, or is no longer, * usable. - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public static final short INVALID_STATE_ERR = 11; /** * If an invalid or illegal string is specified. - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public static final short SYNTAX_ERR = 12; /** * If an attempt is made to modify the type of the underlying object. - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public static final short INVALID_MODIFICATION_ERR = 13; /** * If an attempt is made to create or change an object in a way which is * incorrect with regard to namespaces. - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public static final short NAMESPACE_ERR = 14; /** * If a parameter or an operation is not supported by the underlying * object. - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public static final short INVALID_ACCESS_ERR = 15; /** @@ -147,13 +147,13 @@ public class DOMException extends RuntimeException { * with respect to "partial validity", this exception would be raised * and the operation would not be done. This code is used in [DOM Level 3 Validation] * . Refer to this specification for further information. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public static final short VALIDATION_ERR = 16; /** * If the type of an object is incompatible with the expected type of the * parameter associated to the object. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public static final short TYPE_MISMATCH_ERR = 17; diff --git a/jaxp/src/org/w3c/dom/DOMImplementation.java b/jaxp/src/org/w3c/dom/DOMImplementation.java index acf79fe9313..2bcd5f7d39c 100644 --- a/jaxp/src/org/w3c/dom/DOMImplementation.java +++ b/jaxp/src/org/w3c/dom/DOMImplementation.java @@ -77,7 +77,7 @@ public interface DOMImplementation { *
NOT_SUPPORTED_ERR: May be raised if the implementation does not * support the feature "XML" and the language exposed through the * Document does not support XML Namespaces (such as [HTML 4.01]). - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public DocumentType createDocumentType(String qualifiedName, String publicId, @@ -129,7 +129,7 @@ public interface DOMImplementation { *
NOT_SUPPORTED_ERR: May be raised if the implementation does not * support the feature "XML" and the language exposed through the * Document does not support XML Namespaces (such as [HTML 4.01]). - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public Document createDocument(String namespaceURI, String qualifiedName, @@ -157,7 +157,7 @@ public interface DOMImplementation { * return results inconsistent with the primary core * DOMImplementation such as hasFeature, * getFeature, etc. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public Object getFeature(String feature, String version); diff --git a/jaxp/src/org/w3c/dom/DOMImplementationList.java b/jaxp/src/org/w3c/dom/DOMImplementationList.java index d7712f2e3f0..1fb2caa9b7d 100644 --- a/jaxp/src/org/w3c/dom/DOMImplementationList.java +++ b/jaxp/src/org/w3c/dom/DOMImplementationList.java @@ -48,7 +48,7 @@ package org.w3c.dom; * DOMImplementationList are accessible via an integral index, * starting from 0. *

See also the Document Object Model (DOM) Level 3 Core Specification. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public interface DOMImplementationList { /** diff --git a/jaxp/src/org/w3c/dom/DOMImplementationSource.java b/jaxp/src/org/w3c/dom/DOMImplementationSource.java index 41aa1ab01b0..317c4ba6600 100644 --- a/jaxp/src/org/w3c/dom/DOMImplementationSource.java +++ b/jaxp/src/org/w3c/dom/DOMImplementationSource.java @@ -49,7 +49,7 @@ package org.w3c.dom; * listed in the binding-specific list of available sources so that its * DOMImplementation objects are made available. *

See also the Document Object Model (DOM) Level 3 Core Specification. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public interface DOMImplementationSource { /** diff --git a/jaxp/src/org/w3c/dom/DOMLocator.java b/jaxp/src/org/w3c/dom/DOMLocator.java index 9104976a56a..ece7db191b0 100644 --- a/jaxp/src/org/w3c/dom/DOMLocator.java +++ b/jaxp/src/org/w3c/dom/DOMLocator.java @@ -45,7 +45,7 @@ package org.w3c.dom; * DOMLocator is an interface that describes a location (e.g. * where an error occurred). *

See also the Document Object Model (DOM) Level 3 Core Specification. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public interface DOMLocator { /** diff --git a/jaxp/src/org/w3c/dom/DOMStringList.java b/jaxp/src/org/w3c/dom/DOMStringList.java index 670bdd0e04e..50d045b9d81 100644 --- a/jaxp/src/org/w3c/dom/DOMStringList.java +++ b/jaxp/src/org/w3c/dom/DOMStringList.java @@ -48,7 +48,7 @@ package org.w3c.dom; * DOMStringList are accessible via an integral index, starting * from 0. *

See also the Document Object Model (DOM) Level 3 Core Specification. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public interface DOMStringList { /** diff --git a/jaxp/src/org/w3c/dom/Document.java b/jaxp/src/org/w3c/dom/Document.java index 5e489ac98c4..ab2d6e4f17e 100644 --- a/jaxp/src/org/w3c/dom/Document.java +++ b/jaxp/src/org/w3c/dom/Document.java @@ -73,7 +73,7 @@ public interface Document extends Node { * changing it afterwards is very unlikely to result in a change of the * features supported. * - * @since DOM Level 3 + * @since 1.4, DOM Level 3 */ public DocumentType getDoctype(); @@ -337,7 +337,7 @@ public interface Document extends Node { * Document.xmlVersion attribute. This may happen when * importing an XML 1.1 [XML 1.1] element * into an XML 1.0 document, for instance. - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public Node importNode(Node importedNode, boolean deep) @@ -401,7 +401,7 @@ public interface Document extends Node { *
NOT_SUPPORTED_ERR: Always thrown if the current document does not * support the "XML" feature, since namespaces were * defined by XML. - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public Element createElementNS(String namespaceURI, String qualifiedName) @@ -470,7 +470,7 @@ public interface Document extends Node { *
NOT_SUPPORTED_ERR: Always thrown if the current document does not * support the "XML" feature, since namespaces were * defined by XML. - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public Attr createAttributeNS(String namespaceURI, String qualifiedName) @@ -485,7 +485,7 @@ public interface Document extends Node { * special value "*" matches all local names. * @return A new NodeList object containing all the matched * Elements. - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public NodeList getElementsByTagNameNS(String namespaceURI, String localName); @@ -501,7 +501,7 @@ public interface Document extends Node { * ID unless so defined. * @param elementId The unique id value for an element. * @return The matching element or null if there is none. - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public Element getElementById(String elementId); @@ -509,7 +509,7 @@ public interface Document extends Node { * An attribute specifying the encoding used for this document at the time * of the parsing. This is null when it is not known, such * as when the Document was created in memory. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public String getInputEncoding(); @@ -517,7 +517,7 @@ public interface Document extends Node { * An attribute specifying, as part of the XML declaration, the encoding of this document. This is null when * unspecified or when it is not known, such as when the * Document was created in memory. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public String getXmlEncoding(); @@ -529,7 +529,7 @@ public interface Document extends Node { * Document.normalizeDocument() with the "validate" * parameter to verify if the value matches the validity * constraint for standalone document declaration as defined in [XML 1.0]. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public boolean getXmlStandalone(); /** @@ -543,7 +543,7 @@ public interface Document extends Node { * @exception DOMException * NOT_SUPPORTED_ERR: Raised if this document does not support the * "XML" feature. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public void setXmlStandalone(boolean xmlStandalone) throws DOMException; @@ -570,7 +570,7 @@ public interface Document extends Node { * objects supporting a version of the "XMLVersion" feature must not * raise a NOT_SUPPORTED_ERR exception for the same version * number when using Document.xmlVersion. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public String getXmlVersion(); /** @@ -599,7 +599,7 @@ public interface Document extends Node { * NOT_SUPPORTED_ERR: Raised if the version is set to a value that is * not supported by this Document or if this document * does not support the "XML" feature. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public void setXmlVersion(String xmlVersion) throws DOMException; @@ -612,7 +612,7 @@ public interface Document extends Node { * errors while using Document.normalizeDocument(). In case * of error, the behavior is undefined. This attribute is * true by default. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public boolean getStrictErrorChecking(); /** @@ -623,7 +623,7 @@ public interface Document extends Node { * errors while using Document.normalizeDocument(). In case * of error, the behavior is undefined. This attribute is * true by default. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public void setStrictErrorChecking(boolean strictErrorChecking); @@ -638,7 +638,7 @@ public interface Document extends Node { * "HTML" [DOM Level 2 HTML] * , the href attribute of the HTML BASE element takes precedence over * this attribute when computing Node.baseURI. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public String getDocumentURI(); /** @@ -652,7 +652,7 @@ public interface Document extends Node { * "HTML" [DOM Level 2 HTML] * , the href attribute of the HTML BASE element takes precedence over * this attribute when computing Node.baseURI. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public void setDocumentURI(String documentURI); @@ -723,7 +723,7 @@ public interface Document extends Node { * DOCUMENT, DOCUMENT_TYPE. *
NO_MODIFICATION_ALLOWED_ERR: Raised when the source node is * readonly. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public Node adoptNode(Node source) throws DOMException; @@ -731,7 +731,7 @@ public interface Document extends Node { /** * The configuration used when Document.normalizeDocument() * is invoked. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public DOMConfiguration getDomConfig(); @@ -765,7 +765,7 @@ public interface Document extends Node { * " parameter. Note this method might also report fatal errors ( * DOMError.SEVERITY_FATAL_ERROR) if an implementation * cannot recover from an error. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public void normalizeDocument(); @@ -834,7 +834,7 @@ public interface Document extends Node { * . Also raised, when the node being renamed is an attribute, if the * qualifiedName, or its prefix, is "xmlns" and the * namespaceURI is different from "http://www.w3.org/2000/xmlns/". - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public Node renameNode(Node n, String namespaceURI, diff --git a/jaxp/src/org/w3c/dom/DocumentType.java b/jaxp/src/org/w3c/dom/DocumentType.java index 3b687e3a1e4..b28bea811b6 100644 --- a/jaxp/src/org/w3c/dom/DocumentType.java +++ b/jaxp/src/org/w3c/dom/DocumentType.java @@ -87,14 +87,14 @@ public interface DocumentType extends Node { /** * The public identifier of the external subset. - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public String getPublicId(); /** * The system identifier of the external subset. This may be an absolute * URI or not. - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public String getSystemId(); @@ -105,7 +105,7 @@ public interface DocumentType extends Node { * information is available to the implementation. This may vary * depending on various parameters, including the XML processor used to * build the document. - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public String getInternalSubset(); diff --git a/jaxp/src/org/w3c/dom/Element.java b/jaxp/src/org/w3c/dom/Element.java index 195c71f7a95..ab5087d2c52 100644 --- a/jaxp/src/org/w3c/dom/Element.java +++ b/jaxp/src/org/w3c/dom/Element.java @@ -203,7 +203,7 @@ public interface Element extends Node { * NOT_SUPPORTED_ERR: May be raised if the implementation does not * support the feature "XML" and the language exposed * through the Document does not support XML Namespaces (such as [HTML 4.01]). - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public String getAttributeNS(String namespaceURI, String localName) @@ -249,7 +249,7 @@ public interface Element extends Node { *
NOT_SUPPORTED_ERR: May be raised if the implementation does not * support the feature "XML" and the language exposed * through the Document does not support XML Namespaces (such as [HTML 4.01]). - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public void setAttributeNS(String namespaceURI, String qualifiedName, @@ -278,7 +278,7 @@ public interface Element extends Node { *
NOT_SUPPORTED_ERR: May be raised if the implementation does not * support the feature "XML" and the language exposed * through the Document does not support XML Namespaces (such as [HTML 4.01]). - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public void removeAttributeNS(String namespaceURI, String localName) @@ -299,7 +299,7 @@ public interface Element extends Node { * NOT_SUPPORTED_ERR: May be raised if the implementation does not * support the feature "XML" and the language exposed * through the Document does not support XML Namespaces (such as [HTML 4.01]). - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public Attr getAttributeNodeNS(String namespaceURI, String localName) @@ -329,7 +329,7 @@ public interface Element extends Node { *
NOT_SUPPORTED_ERR: May be raised if the implementation does not * support the feature "XML" and the language exposed * through the Document does not support XML Namespaces (such as [HTML 4.01]). - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public Attr setAttributeNodeNS(Attr newAttr) throws DOMException; @@ -348,7 +348,7 @@ public interface Element extends Node { * NOT_SUPPORTED_ERR: May be raised if the implementation does not * support the feature "XML" and the language exposed * through the Document does not support XML Namespaces (such as [HTML 4.01]). - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public NodeList getElementsByTagNameNS(String namespaceURI, String localName) @@ -362,7 +362,7 @@ public interface Element extends Node { * @return true if an attribute with the given name is * specified on this element or has a default value, false * otherwise. - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public boolean hasAttribute(String name); @@ -383,7 +383,7 @@ public interface Element extends Node { * NOT_SUPPORTED_ERR: May be raised if the implementation does not * support the feature "XML" and the language exposed * through the Document does not support XML Namespaces (such as [HTML 4.01]). - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public boolean hasAttributeNS(String namespaceURI, String localName) @@ -391,7 +391,7 @@ public interface Element extends Node { /** * The type information associated with this element. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public TypeInfo getSchemaTypeInfo(); @@ -413,7 +413,7 @@ public interface Element extends Node { * NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. *
NOT_FOUND_ERR: Raised if the specified node is not an attribute * of this element. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public void setIdAttribute(String name, boolean isId) @@ -436,7 +436,7 @@ public interface Element extends Node { * NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. *
NOT_FOUND_ERR: Raised if the specified node is not an attribute * of this element. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public void setIdAttributeNS(String namespaceURI, String localName, @@ -459,7 +459,7 @@ public interface Element extends Node { * NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. *
NOT_FOUND_ERR: Raised if the specified node is not an attribute * of this element. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public void setIdAttributeNode(Attr idAttr, boolean isId) diff --git a/jaxp/src/org/w3c/dom/Entity.java b/jaxp/src/org/w3c/dom/Entity.java index 2242fe1449e..c4e3b8930c7 100644 --- a/jaxp/src/org/w3c/dom/Entity.java +++ b/jaxp/src/org/w3c/dom/Entity.java @@ -96,7 +96,7 @@ public interface Entity extends Node { * of parsing, when it is an external parsed entity. This is * null if it an entity from the internal subset or if it * is not known. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public String getInputEncoding(); @@ -104,7 +104,7 @@ public interface Entity extends Node { * An attribute specifying, as part of the text declaration, the encoding * of this entity, when it is an external parsed entity. This is * null otherwise. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public String getXmlEncoding(); @@ -112,7 +112,7 @@ public interface Entity extends Node { * An attribute specifying, as part of the text declaration, the version * number of this entity, when it is an external parsed entity. This is * null otherwise. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public String getXmlVersion(); diff --git a/jaxp/src/org/w3c/dom/NameList.java b/jaxp/src/org/w3c/dom/NameList.java index 01cfe10c9c0..92ee1814087 100644 --- a/jaxp/src/org/w3c/dom/NameList.java +++ b/jaxp/src/org/w3c/dom/NameList.java @@ -48,7 +48,7 @@ package org.w3c.dom; * implemented. The items in the NameList are accessible via an * integral index, starting from 0. *

See also the Document Object Model (DOM) Level 3 Core Specification. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public interface NameList { /** diff --git a/jaxp/src/org/w3c/dom/NamedNodeMap.java b/jaxp/src/org/w3c/dom/NamedNodeMap.java index 00466c16bda..c9d3084f151 100644 --- a/jaxp/src/org/w3c/dom/NamedNodeMap.java +++ b/jaxp/src/org/w3c/dom/NamedNodeMap.java @@ -141,7 +141,7 @@ public interface NamedNodeMap { * NOT_SUPPORTED_ERR: May be raised if the implementation does not * support the feature "XML" and the language exposed through the * Document does not support XML Namespaces (such as [HTML 4.01]). - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public Node getNamedItemNS(String namespaceURI, String localName) @@ -177,7 +177,7 @@ public interface NamedNodeMap { *
NOT_SUPPORTED_ERR: May be raised if the implementation does not * support the feature "XML" and the language exposed through the * Document does not support XML Namespaces (such as [HTML 4.01]). - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public Node setNamedItemNS(Node arg) throws DOMException; @@ -203,7 +203,7 @@ public interface NamedNodeMap { *
NOT_SUPPORTED_ERR: May be raised if the implementation does not * support the feature "XML" and the language exposed through the * Document does not support XML Namespaces (such as [HTML 4.01]). - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public Node removeNamedItemNS(String namespaceURI, String localName) diff --git a/jaxp/src/org/w3c/dom/Node.java b/jaxp/src/org/w3c/dom/Node.java index 68404b95ebb..a62ad94d91e 100644 --- a/jaxp/src/org/w3c/dom/Node.java +++ b/jaxp/src/org/w3c/dom/Node.java @@ -299,7 +299,7 @@ public interface Node { * which is not used with any Document yet, this is * null. * - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public Document getOwnerDocument(); @@ -335,7 +335,7 @@ public interface Node { * support the insertion of a DocumentType or * Element node. * - * @since DOM Level 3 + * @since 1.4, DOM Level 3 */ public Node insertBefore(Node newChild, Node refChild) @@ -373,7 +373,7 @@ public interface Node { * support the replacement of the DocumentType child or * Element child. * - * @since DOM Level 3 + * @since 1.4, DOM Level 3 */ public Node replaceChild(Node newChild, Node oldChild) @@ -393,7 +393,7 @@ public interface Node { * support the removal of the DocumentType child or the * Element child. * - * @since DOM Level 3 + * @since 1.4, DOM Level 3 */ public Node removeChild(Node oldChild) throws DOMException; @@ -422,7 +422,7 @@ public interface Node { * if the DOM implementation doesn't support the removal of the * DocumentType child or Element child. * - * @since DOM Level 3 + * @since 1.4, DOM Level 3 */ public Node appendChild(Node newChild) throws DOMException; @@ -491,7 +491,7 @@ public interface Node { * sufficient, since XPointers do not differentiate between * Text nodes and CDATASection nodes. * - * @since DOM Level 3 + * @since 1.4, DOM Level 3 */ public void normalize(); @@ -503,7 +503,7 @@ public interface Node { * @return Returns true if the specified feature is * supported on this node, false otherwise. * - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public boolean isSupported(String feature, String version); @@ -523,7 +523,7 @@ public interface Node { * attached to. If an attribute is not explicitly given a namespace, it * simply has no namespace. * - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public String getNamespaceURI(); @@ -547,7 +547,7 @@ public interface Node { * method, such as createElement from the * Document interface, this is always null. * - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public String getPrefix(); /** @@ -584,7 +584,7 @@ public interface Node { * this node is "xmlns" [XML Namespaces] * . * - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public void setPrefix(String prefix) throws DOMException; @@ -596,7 +596,7 @@ public interface Node { * method, such as Document.createElement(), this is always * null. * - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public String getLocalName(); @@ -605,7 +605,7 @@ public interface Node { * @return Returns true if this node has any attributes, * false otherwise. * - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public boolean hasAttributes(); @@ -619,7 +619,7 @@ public interface Node { * documentURI attribute from the Document * interface otherwise. * - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public String getBaseURI(); @@ -666,7 +666,7 @@ public interface Node { * implementations that do not coordinate to return consistent * implementation-specific results. * - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public short compareDocumentPosition(Node other) throws DOMException; @@ -717,7 +717,7 @@ public interface Node { * fit in a DOMString variable on the implementation * platform. * - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public String getTextContent() throws DOMException; @@ -765,7 +765,7 @@ public interface Node { * @exception DOMException * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly. * - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public void setTextContent(String textContent) throws DOMException; @@ -783,7 +783,7 @@ public interface Node { * @return Returns true if the nodes are the same, * false otherwise. * - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public boolean isSameNode(Node other); @@ -798,7 +798,7 @@ public interface Node { * associated to the namespace prefix, the returned namespace prefix * is implementation dependent. * - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public String lookupPrefix(String namespaceURI); @@ -810,7 +810,7 @@ public interface Node { * namespaceURI is the default namespace, * false otherwise. * - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public boolean isDefaultNamespace(String namespaceURI); @@ -824,7 +824,7 @@ public interface Node { * @return Returns the associated namespace URI or null if * none is found. * - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public String lookupNamespaceURI(String prefix); @@ -890,7 +890,7 @@ public interface Node { * @return Returns true if the nodes are equal, * false otherwise. * - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public boolean isEqualNode(Node arg); @@ -915,7 +915,7 @@ public interface Node { * with the primary core Node such as attributes, * childNodes, etc. * - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public Object getFeature(String feature, String version); @@ -932,7 +932,7 @@ public interface Node { * @return Returns the DOMUserData previously associated to * the given key on this node, or null if there was none. * - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public Object setUserData(String key, Object data, @@ -946,7 +946,7 @@ public interface Node { * @return Returns the DOMUserData associated to the given * key on this node, or null if there was none. * - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public Object getUserData(String key); diff --git a/jaxp/src/org/w3c/dom/Text.java b/jaxp/src/org/w3c/dom/Text.java index f54d0ee8681..c603dac3ead 100644 --- a/jaxp/src/org/w3c/dom/Text.java +++ b/jaxp/src/org/w3c/dom/Text.java @@ -93,7 +93,7 @@ public interface Text extends CharacterData { * determined to contain whitespace in element content during the load * of the document or if validation occurs while using * Document.normalizeDocument(). - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public boolean isElementContentWhitespace(); @@ -121,7 +121,7 @@ public interface Text extends CharacterData { * * Figure: barTextNode.wholeText value is "barfoo" * - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public String getWholeText(); @@ -179,7 +179,7 @@ public interface Text extends CharacterData { * @exception DOMException * NO_MODIFICATION_ALLOWED_ERR: Raised if one of the Text * nodes being replaced is readonly. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public Text replaceWholeText(String content) throws DOMException; diff --git a/jaxp/src/org/w3c/dom/TypeInfo.java b/jaxp/src/org/w3c/dom/TypeInfo.java index 044ede0bccb..a67f1c3e8dc 100644 --- a/jaxp/src/org/w3c/dom/TypeInfo.java +++ b/jaxp/src/org/w3c/dom/TypeInfo.java @@ -118,7 +118,7 @@ package org.w3c.dom; * and therefore should define how to represent their type systems using * TypeInfo. *

See also the Document Object Model (DOM) Level 3 Core Specification. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public interface TypeInfo { /** diff --git a/jaxp/src/org/w3c/dom/UserDataHandler.java b/jaxp/src/org/w3c/dom/UserDataHandler.java index a4ec6e89832..e6595abfc1f 100644 --- a/jaxp/src/org/w3c/dom/UserDataHandler.java +++ b/jaxp/src/org/w3c/dom/UserDataHandler.java @@ -49,7 +49,7 @@ package org.w3c.dom; * implement various behaviors regarding the data it associates to the DOM * nodes. This interface defines that handler. *

See also the Document Object Model (DOM) Level 3 Core Specification. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public interface UserDataHandler { // OperationType diff --git a/jaxp/src/org/w3c/dom/bootstrap/DOMImplementationRegistry.java b/jaxp/src/org/w3c/dom/bootstrap/DOMImplementationRegistry.java index cfeeeea4907..48fda761e1e 100644 --- a/jaxp/src/org/w3c/dom/bootstrap/DOMImplementationRegistry.java +++ b/jaxp/src/org/w3c/dom/bootstrap/DOMImplementationRegistry.java @@ -79,7 +79,7 @@ import java.security.PrivilegedAction; * * @see DOMImplementation * @see DOMImplementationSource - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public final class DOMImplementationRegistry { /** diff --git a/jaxp/src/org/w3c/dom/events/DocumentEvent.java b/jaxp/src/org/w3c/dom/events/DocumentEvent.java index cdbbb367f43..2a5f62f10fd 100644 --- a/jaxp/src/org/w3c/dom/events/DocumentEvent.java +++ b/jaxp/src/org/w3c/dom/events/DocumentEvent.java @@ -50,7 +50,7 @@ import org.w3c.dom.DOMException; * implemented on the same object which implements the Document * interface in an implementation which supports the Event model. *

See also the Document Object Model (DOM) Level 2 Events Specification. - * @since DOM Level 2 + * @since 1.5, DOM Level 2 */ public interface DocumentEvent { /** diff --git a/jaxp/src/org/w3c/dom/events/Event.java b/jaxp/src/org/w3c/dom/events/Event.java index b1351e9b8dd..efa68650104 100644 --- a/jaxp/src/org/w3c/dom/events/Event.java +++ b/jaxp/src/org/w3c/dom/events/Event.java @@ -51,7 +51,7 @@ package org.w3c.dom.events; * type of event they accompany. These derived interfaces are also * implemented by the object passed to the event listener. *

See also the Document Object Model (DOM) Level 2 Events Specification. - * @since DOM Level 2 + * @since 1.5, DOM Level 2 */ public interface Event { // PhaseType diff --git a/jaxp/src/org/w3c/dom/events/EventException.java b/jaxp/src/org/w3c/dom/events/EventException.java index 6273f64063a..1d646b4f63c 100644 --- a/jaxp/src/org/w3c/dom/events/EventException.java +++ b/jaxp/src/org/w3c/dom/events/EventException.java @@ -45,7 +45,7 @@ package org.w3c.dom.events; * Event operations may throw an EventException as specified in * their method descriptions. *

See also the Document Object Model (DOM) Level 2 Events Specification. - * @since DOM Level 2 + * @since 1.5, DOM Level 2 */ public class EventException extends RuntimeException { public EventException(short code, String message) { diff --git a/jaxp/src/org/w3c/dom/events/EventListener.java b/jaxp/src/org/w3c/dom/events/EventListener.java index 2adfe58f647..a11dec1ef86 100644 --- a/jaxp/src/org/w3c/dom/events/EventListener.java +++ b/jaxp/src/org/w3c/dom/events/EventListener.java @@ -54,7 +54,7 @@ package org.w3c.dom.events; * the user wishes the same EventListeners to be added to the * newly created copy the user must add them manually. *

See also the Document Object Model (DOM) Level 2 Events Specification. - * @since DOM Level 2 + * @since 1.5, DOM Level 2 */ public interface EventListener { /** diff --git a/jaxp/src/org/w3c/dom/events/EventTarget.java b/jaxp/src/org/w3c/dom/events/EventTarget.java index 46ac1f62266..3fd5aefa458 100644 --- a/jaxp/src/org/w3c/dom/events/EventTarget.java +++ b/jaxp/src/org/w3c/dom/events/EventTarget.java @@ -50,7 +50,7 @@ package org.w3c.dom.events; * EventListeners on an EventTarget and dispatch * of events to that EventTarget. *

See also the Document Object Model (DOM) Level 2 Events Specification. - * @since DOM Level 2 + * @since 1.5, DOM Level 2 */ public interface EventTarget { /** diff --git a/jaxp/src/org/w3c/dom/events/MouseEvent.java b/jaxp/src/org/w3c/dom/events/MouseEvent.java index dee4cda5b5c..7a21af99b05 100644 --- a/jaxp/src/org/w3c/dom/events/MouseEvent.java +++ b/jaxp/src/org/w3c/dom/events/MouseEvent.java @@ -58,7 +58,7 @@ import org.w3c.dom.views.AbstractView; * bubbling to obtain notification of mouse events which occur within its * descendent elements. *

See also the Document Object Model (DOM) Level 2 Events Specification. - * @since DOM Level 2 + * @since 1.5, DOM Level 2 */ public interface MouseEvent extends UIEvent { /** diff --git a/jaxp/src/org/w3c/dom/events/MutationEvent.java b/jaxp/src/org/w3c/dom/events/MutationEvent.java index a520b6f0a5c..1dc5c815991 100644 --- a/jaxp/src/org/w3c/dom/events/MutationEvent.java +++ b/jaxp/src/org/w3c/dom/events/MutationEvent.java @@ -47,7 +47,7 @@ import org.w3c.dom.Node; * The MutationEvent interface provides specific contextual * information associated with Mutation events. *

See also the Document Object Model (DOM) Level 2 Events Specification. - * @since DOM Level 2 + * @since 1.5, DOM Level 2 */ public interface MutationEvent extends Event { // attrChangeType diff --git a/jaxp/src/org/w3c/dom/events/UIEvent.java b/jaxp/src/org/w3c/dom/events/UIEvent.java index 0931c5ff874..01192194ced 100644 --- a/jaxp/src/org/w3c/dom/events/UIEvent.java +++ b/jaxp/src/org/w3c/dom/events/UIEvent.java @@ -47,7 +47,7 @@ import org.w3c.dom.views.AbstractView; * The UIEvent interface provides specific contextual information * associated with User Interface events. *

See also the Document Object Model (DOM) Level 2 Events Specification. - * @since DOM Level 2 + * @since 1.5, DOM Level 2 */ public interface UIEvent extends Event { /** diff --git a/jaxp/src/org/w3c/dom/ls/DOMImplementationLS.java b/jaxp/src/org/w3c/dom/ls/DOMImplementationLS.java index c876dafcd6b..13b863e7536 100644 --- a/jaxp/src/org/w3c/dom/ls/DOMImplementationLS.java +++ b/jaxp/src/org/w3c/dom/ls/DOMImplementationLS.java @@ -57,6 +57,8 @@ import org.w3c.dom.DOMException; * "3.0" (respectively). *

See also the Document Object Model (DOM) Level 3 Load and Save Specification. + * + * @since 1.5 */ public interface DOMImplementationLS { // DOMImplementationLSMode diff --git a/jaxp/src/org/w3c/dom/ls/LSException.java b/jaxp/src/org/w3c/dom/ls/LSException.java index f23d38a0a9c..fad53bafc1d 100644 --- a/jaxp/src/org/w3c/dom/ls/LSException.java +++ b/jaxp/src/org/w3c/dom/ls/LSException.java @@ -54,6 +54,8 @@ package org.w3c.dom.ls; * implementation dependent. *

See also the Document Object Model (DOM) Level 3 Load and Save Specification. + * + * @since 1.5 */ public class LSException extends RuntimeException { public LSException(short code, String message) { diff --git a/jaxp/src/org/w3c/dom/ls/LSInput.java b/jaxp/src/org/w3c/dom/ls/LSInput.java index a9b08c17bf1..f6f69b986cb 100644 --- a/jaxp/src/org/w3c/dom/ls/LSInput.java +++ b/jaxp/src/org/w3c/dom/ls/LSInput.java @@ -82,6 +82,8 @@ package org.w3c.dom.ls; * modify the copies, if necessary). *

See also the Document Object Model (DOM) Level 3 Load and Save Specification. + * + * @since 1.5 */ public interface LSInput { /** diff --git a/jaxp/src/org/w3c/dom/ls/LSLoadEvent.java b/jaxp/src/org/w3c/dom/ls/LSLoadEvent.java index 5c9b7671e75..a4f938d0c89 100644 --- a/jaxp/src/org/w3c/dom/ls/LSLoadEvent.java +++ b/jaxp/src/org/w3c/dom/ls/LSLoadEvent.java @@ -49,6 +49,8 @@ import org.w3c.dom.events.Event; * of a document load. *

See also the Document Object Model (DOM) Level 3 Load and Save Specification. + * + * @since 1.5 */ public interface LSLoadEvent extends Event { /** diff --git a/jaxp/src/org/w3c/dom/ls/LSOutput.java b/jaxp/src/org/w3c/dom/ls/LSOutput.java index c6ace48cf3e..b69f8d8f367 100644 --- a/jaxp/src/org/w3c/dom/ls/LSOutput.java +++ b/jaxp/src/org/w3c/dom/ls/LSOutput.java @@ -74,6 +74,8 @@ package org.w3c.dom.ls; * modify the copies, if necessary). *

See also the Document Object Model (DOM) Level 3 Load and Save Specification. + * + * @since 1.5 */ public interface LSOutput { /** diff --git a/jaxp/src/org/w3c/dom/ls/LSParser.java b/jaxp/src/org/w3c/dom/ls/LSParser.java index 72d7db2f89c..0ddbd49ddfb 100644 --- a/jaxp/src/org/w3c/dom/ls/LSParser.java +++ b/jaxp/src/org/w3c/dom/ls/LSParser.java @@ -166,6 +166,8 @@ import org.w3c.dom.DOMException; * permission denied,...), XML well-formedness errors, and so on. *

See also the Document Object Model (DOM) Level 3 Load and Save Specification. + * + * @since 1.5 */ public interface LSParser { /** diff --git a/jaxp/src/org/w3c/dom/ls/LSParserFilter.java b/jaxp/src/org/w3c/dom/ls/LSParserFilter.java index 0638c382dd4..96797bbb3cf 100644 --- a/jaxp/src/org/w3c/dom/ls/LSParserFilter.java +++ b/jaxp/src/org/w3c/dom/ls/LSParserFilter.java @@ -73,6 +73,8 @@ import org.w3c.dom.Element; * throwing exceptions from a filter is DOM implementation dependent. *

See also the Document Object Model (DOM) Level 3 Load and Save Specification. + * + * @since 1.5 */ public interface LSParserFilter { // Constants returned by startElement and acceptNode diff --git a/jaxp/src/org/w3c/dom/ls/LSProgressEvent.java b/jaxp/src/org/w3c/dom/ls/LSProgressEvent.java index 25a76a6a469..6e1b5653ef7 100644 --- a/jaxp/src/org/w3c/dom/ls/LSProgressEvent.java +++ b/jaxp/src/org/w3c/dom/ls/LSProgressEvent.java @@ -53,6 +53,8 @@ import org.w3c.dom.events.Event; * input dependent. *

See also the Document Object Model (DOM) Level 3 Load and Save Specification. + * + * @since 1.5 */ public interface LSProgressEvent extends Event { /** diff --git a/jaxp/src/org/w3c/dom/ls/LSResourceResolver.java b/jaxp/src/org/w3c/dom/ls/LSResourceResolver.java index bcb57be01e1..2361c2dd5eb 100644 --- a/jaxp/src/org/w3c/dom/ls/LSResourceResolver.java +++ b/jaxp/src/org/w3c/dom/ls/LSResourceResolver.java @@ -63,6 +63,8 @@ package org.w3c.dom.ls; * interface. *

See also the Document Object Model (DOM) Level 3 Load and Save Specification. + * + * @since 1.5 */ public interface LSResourceResolver { /** diff --git a/jaxp/src/org/w3c/dom/ls/LSSerializer.java b/jaxp/src/org/w3c/dom/ls/LSSerializer.java index 6553f2112eb..05b003a15a7 100644 --- a/jaxp/src/org/w3c/dom/ls/LSSerializer.java +++ b/jaxp/src/org/w3c/dom/ls/LSSerializer.java @@ -204,6 +204,8 @@ import org.w3c.dom.DOMException; * permission denied,...) and so on. *

See also the Document Object Model (DOM) Level 3 Load and Save Specification. + * + * @since 1.5 */ public interface LSSerializer { /** diff --git a/jaxp/src/org/w3c/dom/ls/LSSerializerFilter.java b/jaxp/src/org/w3c/dom/ls/LSSerializerFilter.java index bc8e7241799..1263473c753 100644 --- a/jaxp/src/org/w3c/dom/ls/LSSerializerFilter.java +++ b/jaxp/src/org/w3c/dom/ls/LSSerializerFilter.java @@ -70,6 +70,8 @@ import org.w3c.dom.traversal.NodeFilter; * document. *

See also the Document Object Model (DOM) Level 3 Load and Save Specification. + * + * @since 1.5 */ public interface LSSerializerFilter extends NodeFilter { /** diff --git a/jaxp/src/org/w3c/dom/package.html b/jaxp/src/org/w3c/dom/package.html index def37a39016..a95de6c6ea7 100644 --- a/jaxp/src/org/w3c/dom/package.html +++ b/jaxp/src/org/w3c/dom/package.html @@ -3,13 +3,11 @@ org.w3c.dom package -Provides the interfaces for the Document Object Model (DOM) which is a -component API of the Java API for XML -Processing. The Document Object Model Level 2 Core API allows programs -to dynamically access and update the content and structure of documents. -See the specification -for more information. +Provides the interfaces for the Document Object Model (DOM). Supports the +Document Object Model Level 2 Core APIi, +Document Object Model (DOM) Level 3 Core, +and Document Object Model (DOM) Level 3 Load and Save. -@since JDK1.4 +@since 1.4 diff --git a/jaxp/src/org/w3c/dom/views/AbstractView.java b/jaxp/src/org/w3c/dom/views/AbstractView.java index 52195717f70..4f23df62974 100644 --- a/jaxp/src/org/w3c/dom/views/AbstractView.java +++ b/jaxp/src/org/w3c/dom/views/AbstractView.java @@ -44,7 +44,7 @@ package org.w3c.dom.views; /** * A base interface that all views shall derive from. *

See also the Document Object Model (DOM) Level 2 Views Specification. - * @since DOM Level 2 + * @since 1.8, DOM Level 2 */ public interface AbstractView { /** diff --git a/jaxp/src/org/w3c/dom/views/DocumentView.java b/jaxp/src/org/w3c/dom/views/DocumentView.java index 38793a49634..8716d797079 100644 --- a/jaxp/src/org/w3c/dom/views/DocumentView.java +++ b/jaxp/src/org/w3c/dom/views/DocumentView.java @@ -47,7 +47,7 @@ package org.w3c.dom.views; * Views. It provides an attribute to retrieve the default view of a * document. *

See also the Document Object Model (DOM) Level 2 Views Specification. - * @since DOM Level 2 + * @since 1.8, DOM Level 2 */ public interface DocumentView { /** diff --git a/jaxp/src/org/xml/sax/AttributeList.java b/jaxp/src/org/xml/sax/AttributeList.java index 07ee3dd42ae..877155409c5 100644 --- a/jaxp/src/org/xml/sax/AttributeList.java +++ b/jaxp/src/org/xml/sax/AttributeList.java @@ -88,7 +88,7 @@ package org.xml.sax; * @deprecated This interface has been replaced by the SAX2 * {@link org.xml.sax.Attributes Attributes} * interface, which includes Namespace support. - * @since SAX 1.0 + * @since 1.4, SAX 1.0 * @author David Megginson * @see org.xml.sax.DocumentHandler#startElement startElement * @see org.xml.sax.helpers.AttributeListImpl AttributeListImpl diff --git a/jaxp/src/org/xml/sax/Attributes.java b/jaxp/src/org/xml/sax/Attributes.java index 0202aa457ff..15ad0aa5fe7 100644 --- a/jaxp/src/org/xml/sax/Attributes.java +++ b/jaxp/src/org/xml/sax/Attributes.java @@ -85,7 +85,7 @@ package org.xml.sax; *

The order of attributes in the list is unspecified, and will * vary from implementation to implementation.

* - * @since SAX 2.0 + * @since 1.4, SAX 2.0 * @author David Megginson * @see org.xml.sax.helpers.AttributesImpl * @see org.xml.sax.ext.DeclHandler#attributeDecl diff --git a/jaxp/src/org/xml/sax/ContentHandler.java b/jaxp/src/org/xml/sax/ContentHandler.java index 99d8f5a3f3d..7189ee7c847 100644 --- a/jaxp/src/org/xml/sax/ContentHandler.java +++ b/jaxp/src/org/xml/sax/ContentHandler.java @@ -73,7 +73,7 @@ package org.xml.sax; * anyway, so the user should consider this a feature rather than a * bug.

* - * @since SAX 2.0 + * @since 1.4, SAX 2.0 * @author David Megginson * @see org.xml.sax.XMLReader * @see org.xml.sax.DTDHandler diff --git a/jaxp/src/org/xml/sax/DTDHandler.java b/jaxp/src/org/xml/sax/DTDHandler.java index 6d43ecdb9d9..29978308963 100644 --- a/jaxp/src/org/xml/sax/DTDHandler.java +++ b/jaxp/src/org/xml/sax/DTDHandler.java @@ -67,7 +67,7 @@ package org.xml.sax; * obtained through this interface to find the entity and/or * notation corresponding with the attribute value.

* - * @since SAX 1.0 + * @since 1.4, SAX 1.0 * @author David Megginson * @see org.xml.sax.XMLReader#setDTDHandler */ diff --git a/jaxp/src/org/xml/sax/DocumentHandler.java b/jaxp/src/org/xml/sax/DocumentHandler.java index ffe4d2a3571..0c8b93b85b2 100644 --- a/jaxp/src/org/xml/sax/DocumentHandler.java +++ b/jaxp/src/org/xml/sax/DocumentHandler.java @@ -62,7 +62,7 @@ package org.xml.sax; * @deprecated This interface has been replaced by the SAX2 * {@link org.xml.sax.ContentHandler ContentHandler} * interface, which includes Namespace support. - * @since SAX 1.0 + * @since 1.4, SAX 1.0 * @author David Megginson * @see org.xml.sax.Parser#setDocumentHandler * @see org.xml.sax.Locator diff --git a/jaxp/src/org/xml/sax/EntityResolver.java b/jaxp/src/org/xml/sax/EntityResolver.java index 6f8c5013bf9..ecd3368de12 100644 --- a/jaxp/src/org/xml/sax/EntityResolver.java +++ b/jaxp/src/org/xml/sax/EntityResolver.java @@ -85,7 +85,7 @@ import java.io.IOException; * identifiers to local URIs or to look up replacements in a catalog * (possibly by using the public identifier).

* - * @since SAX 1.0 + * @since 1.4, SAX 1.0 * @author David Megginson * @see org.xml.sax.XMLReader#setEntityResolver * @see org.xml.sax.InputSource diff --git a/jaxp/src/org/xml/sax/ErrorHandler.java b/jaxp/src/org/xml/sax/ErrorHandler.java index 11833823106..40a2394de45 100644 --- a/jaxp/src/org/xml/sax/ErrorHandler.java +++ b/jaxp/src/org/xml/sax/ErrorHandler.java @@ -65,7 +65,7 @@ package org.xml.sax; * For example, {@link XMLReader#parse XMLReader.parse()} would throw * an IOException for errors accessing entities or the document.

* - * @since SAX 1.0 + * @since 1.4, SAX 1.0 * @author David Megginson * @see org.xml.sax.XMLReader#setErrorHandler * @see org.xml.sax.SAXParseException diff --git a/jaxp/src/org/xml/sax/HandlerBase.java b/jaxp/src/org/xml/sax/HandlerBase.java index db2e646f6a0..cbbcf029aa0 100644 --- a/jaxp/src/org/xml/sax/HandlerBase.java +++ b/jaxp/src/org/xml/sax/HandlerBase.java @@ -59,7 +59,7 @@ package org.xml.sax; * interface. It has been replaced by the SAX2 * {@link org.xml.sax.helpers.DefaultHandler DefaultHandler} * class. - * @since SAX 1.0 + * @since 1.4, SAX 1.0 * @author David Megginson * @see org.xml.sax.EntityResolver * @see org.xml.sax.DTDHandler diff --git a/jaxp/src/org/xml/sax/InputSource.java b/jaxp/src/org/xml/sax/InputSource.java index 4f47f9ea6eb..9498da395c7 100644 --- a/jaxp/src/org/xml/sax/InputSource.java +++ b/jaxp/src/org/xml/sax/InputSource.java @@ -74,7 +74,7 @@ import java.io.InputStream; * so applications should not attempt to re-use such streams after they * have been handed to a parser.

* - * @since SAX 1.0 + * @since 1.4, SAX 1.0 * @author David Megginson * @see org.xml.sax.XMLReader#parse(org.xml.sax.InputSource) * @see org.xml.sax.EntityResolver#resolveEntity diff --git a/jaxp/src/org/xml/sax/Locator.java b/jaxp/src/org/xml/sax/Locator.java index 868168dbfe8..fc3a9487871 100644 --- a/jaxp/src/org/xml/sax/Locator.java +++ b/jaxp/src/org/xml/sax/Locator.java @@ -62,7 +62,7 @@ package org.xml.sax; * event, the application should assume that a locator is not * available.

* - * @since SAX 1.0 + * @since 1.4, SAX 1.0 * @author David Megginson * @see org.xml.sax.ContentHandler#setDocumentLocator */ diff --git a/jaxp/src/org/xml/sax/Parser.java b/jaxp/src/org/xml/sax/Parser.java index 61bfbc74fa5..099df32951b 100644 --- a/jaxp/src/org/xml/sax/Parser.java +++ b/jaxp/src/org/xml/sax/Parser.java @@ -64,7 +64,7 @@ import java.util.Locale; * @deprecated This interface has been replaced by the SAX2 * {@link org.xml.sax.XMLReader XMLReader} * interface, which includes Namespace support. - * @since SAX 1.0 + * @since 1.4, SAX 1.0 * @author David Megginson * @see org.xml.sax.EntityResolver * @see org.xml.sax.DTDHandler diff --git a/jaxp/src/org/xml/sax/SAXException.java b/jaxp/src/org/xml/sax/SAXException.java index 65b25cc381a..0352ebbe858 100644 --- a/jaxp/src/org/xml/sax/SAXException.java +++ b/jaxp/src/org/xml/sax/SAXException.java @@ -54,7 +54,7 @@ package org.xml.sax; * specific location in an XML document, it should use the * {@link org.xml.sax.SAXParseException SAXParseException} subclass.

* - * @since SAX 1.0 + * @since 1.4, SAX 1.0 * @author David Megginson * @version 2.0.1 (sax2r2) * @see org.xml.sax.SAXParseException diff --git a/jaxp/src/org/xml/sax/SAXNotRecognizedException.java b/jaxp/src/org/xml/sax/SAXNotRecognizedException.java index f963e01bed2..66bffe07487 100644 --- a/jaxp/src/org/xml/sax/SAXNotRecognizedException.java +++ b/jaxp/src/org/xml/sax/SAXNotRecognizedException.java @@ -46,7 +46,7 @@ package org.xml.sax; * unrecognized feature or property identifier; SAX applications and * extensions may use this class for other, similar purposes.

* - * @since SAX 2.0 + * @since 1.4, SAX 2.0 * @author David Megginson * @see org.xml.sax.SAXNotSupportedException */ diff --git a/jaxp/src/org/xml/sax/SAXNotSupportedException.java b/jaxp/src/org/xml/sax/SAXNotSupportedException.java index d31f49e7ae6..e1c728ff7ea 100644 --- a/jaxp/src/org/xml/sax/SAXNotSupportedException.java +++ b/jaxp/src/org/xml/sax/SAXNotSupportedException.java @@ -46,7 +46,7 @@ package org.xml.sax; * operation (setting a state or value). Other SAX2 applications and * extensions may use this class for similar purposes.

* - * @since SAX 2.0 + * @since 1.4, SAX 2.0 * @author David Megginson * @see org.xml.sax.SAXNotRecognizedException */ diff --git a/jaxp/src/org/xml/sax/SAXParseException.java b/jaxp/src/org/xml/sax/SAXParseException.java index 38f37ff47c6..8036dd914da 100644 --- a/jaxp/src/org/xml/sax/SAXParseException.java +++ b/jaxp/src/org/xml/sax/SAXParseException.java @@ -52,7 +52,7 @@ package org.xml.sax; *

Since this exception is a subclass of {@link org.xml.sax.SAXException * SAXException}, it inherits the ability to wrap another exception.

* - * @since SAX 1.0 + * @since 1.4, SAX 1.0 * @author David Megginson * @version 2.0.1 (sax2r2) * @see org.xml.sax.SAXException diff --git a/jaxp/src/org/xml/sax/XMLFilter.java b/jaxp/src/org/xml/sax/XMLFilter.java index f88cff1965c..eda292e0f6b 100644 --- a/jaxp/src/org/xml/sax/XMLFilter.java +++ b/jaxp/src/org/xml/sax/XMLFilter.java @@ -53,7 +53,7 @@ package org.xml.sax; * {@link org.xml.sax.ContentHandler ContentHandler} and {@link org.xml.sax.ErrorHandler * ErrorHandler} events automatically.

* - * @since SAX 2.0 + * @since 1.4, SAX 2.0 * @author David Megginson * @see org.xml.sax.helpers.XMLFilterImpl */ diff --git a/jaxp/src/org/xml/sax/XMLReader.java b/jaxp/src/org/xml/sax/XMLReader.java index 93b73420a4c..0f2b9cbae8a 100644 --- a/jaxp/src/org/xml/sax/XMLReader.java +++ b/jaxp/src/org/xml/sax/XMLReader.java @@ -75,7 +75,7 @@ import java.io.IOException; *

There are adapters available to convert a SAX1 Parser to * a SAX2 XMLReader and vice-versa.

* - * @since SAX 2.0 + * @since 1.4, SAX 2.0 * @author David Megginson * @see org.xml.sax.XMLFilter * @see org.xml.sax.helpers.ParserAdapter diff --git a/jaxp/src/org/xml/sax/ext/Attributes2.java b/jaxp/src/org/xml/sax/ext/Attributes2.java index 4c7023df48e..d8715595aea 100644 --- a/jaxp/src/org/xml/sax/ext/Attributes2.java +++ b/jaxp/src/org/xml/sax/ext/Attributes2.java @@ -57,7 +57,7 @@ import org.xml.sax.Attributes; * must have been declared. *

* - * @since SAX 2.0 (extensions 1.1 alpha) + * @since 1.5, SAX 2.0 (extensions 1.1 alpha) * @author David Brownell */ public interface Attributes2 extends Attributes diff --git a/jaxp/src/org/xml/sax/ext/Attributes2Impl.java b/jaxp/src/org/xml/sax/ext/Attributes2Impl.java index aabb0b9fd25..42b85cae2ab 100644 --- a/jaxp/src/org/xml/sax/ext/Attributes2Impl.java +++ b/jaxp/src/org/xml/sax/ext/Attributes2Impl.java @@ -56,7 +56,7 @@ import org.xml.sax.helpers.AttributesImpl; * its declared flag to match. *

* - * @since SAX 2.0 (extensions 1.1 alpha) + * @since 1.5, SAX 2.0 (extensions 1.1 alpha) * @author David Brownell */ public class Attributes2Impl extends AttributesImpl implements Attributes2 diff --git a/jaxp/src/org/xml/sax/ext/DeclHandler.java b/jaxp/src/org/xml/sax/ext/DeclHandler.java index b2c72c5621e..f2f46c197d2 100644 --- a/jaxp/src/org/xml/sax/ext/DeclHandler.java +++ b/jaxp/src/org/xml/sax/ext/DeclHandler.java @@ -66,7 +66,7 @@ import org.xml.sax.SAXException; * {@link org.xml.sax.SAXNotRecognizedException SAXNotRecognizedException} * when you attempt to register the handler.

* - * @since SAX 2.0 (extensions 1.0) + * @since 1.4, SAX 2.0 (extensions 1.0) * @author David Megginson */ public interface DeclHandler diff --git a/jaxp/src/org/xml/sax/ext/DefaultHandler2.java b/jaxp/src/org/xml/sax/ext/DefaultHandler2.java index cb7a91a4ca3..6b5ed26dfd3 100644 --- a/jaxp/src/org/xml/sax/ext/DefaultHandler2.java +++ b/jaxp/src/org/xml/sax/ext/DefaultHandler2.java @@ -55,7 +55,7 @@ import org.xml.sax.helpers.DefaultHandler; * ContentHandler.startElement() call might be passed a * {@link Attributes2} object. * - * @since SAX 2.0 (extensions 1.1 alpha) + * @since 1.5, SAX 2.0 (extensions 1.1 alpha) * @author David Brownell */ public class DefaultHandler2 extends DefaultHandler diff --git a/jaxp/src/org/xml/sax/ext/EntityResolver2.java b/jaxp/src/org/xml/sax/ext/EntityResolver2.java index dbd1242a9d7..178adf08aa7 100644 --- a/jaxp/src/org/xml/sax/ext/EntityResolver2.java +++ b/jaxp/src/org/xml/sax/ext/EntityResolver2.java @@ -80,7 +80,7 @@ import org.xml.sax.SAXException; * * @see org.xml.sax.XMLReader#setEntityResolver * - * @since SAX 2.0 (extensions 1.1 alpha) + * @since 1.5, SAX 2.0 (extensions 1.1 alpha) * @author David Brownell */ public interface EntityResolver2 extends EntityResolver diff --git a/jaxp/src/org/xml/sax/ext/LexicalHandler.java b/jaxp/src/org/xml/sax/ext/LexicalHandler.java index dcceceeef17..094ca73d7ae 100644 --- a/jaxp/src/org/xml/sax/ext/LexicalHandler.java +++ b/jaxp/src/org/xml/sax/ext/LexicalHandler.java @@ -62,7 +62,7 @@ import org.xml.sax.SAXException; * {@link org.xml.sax.SAXNotRecognizedException SAXNotRecognizedException} * when you attempt to register the handler.

* - * @since SAX 2.0 (extensions 1.0) + * @since 1.4, SAX 2.0 (extensions 1.0) * @author David Megginson */ public interface LexicalHandler diff --git a/jaxp/src/org/xml/sax/ext/Locator2.java b/jaxp/src/org/xml/sax/ext/Locator2.java index c651a6e17cc..684b0c7ce5c 100644 --- a/jaxp/src/org/xml/sax/ext/Locator2.java +++ b/jaxp/src/org/xml/sax/ext/Locator2.java @@ -51,7 +51,7 @@ import org.xml.sax.Locator; *

XMLReader implementations are not required to support this * information, and it is not part of core-only SAX2 distributions.

* - * @since SAX 2.0 (extensions 1.1 alpha) + * @since 1.5, SAX 2.0 (extensions 1.1 alpha) * @author David Brownell */ public interface Locator2 extends Locator diff --git a/jaxp/src/org/xml/sax/ext/Locator2Impl.java b/jaxp/src/org/xml/sax/ext/Locator2Impl.java index d47b27e67b3..abb52cf4427 100644 --- a/jaxp/src/org/xml/sax/ext/Locator2Impl.java +++ b/jaxp/src/org/xml/sax/ext/Locator2Impl.java @@ -45,7 +45,7 @@ import org.xml.sax.helpers.LocatorImpl; * *

This is not part of core-only SAX2 distributions.

* - * @since SAX 2.0.2 + * @since 1.5, SAX 2.0.2 * @author David Brownell */ public class Locator2Impl extends LocatorImpl implements Locator2 diff --git a/jaxp/src/org/xml/sax/helpers/AttributeListImpl.java b/jaxp/src/org/xml/sax/helpers/AttributeListImpl.java index 93c111e95a5..41d9310f6e5 100644 --- a/jaxp/src/org/xml/sax/helpers/AttributeListImpl.java +++ b/jaxp/src/org/xml/sax/helpers/AttributeListImpl.java @@ -82,7 +82,7 @@ import java.util.Vector; * which is implemented in the * {@link org.xml.sax.helpers.AttributesImpl * AttributesImpl} helper class. - * @since SAX 1.0 + * @since 1.4, SAX 1.0 * @author David Megginson * @see org.xml.sax.AttributeList * @see org.xml.sax.DocumentHandler#startElement diff --git a/jaxp/src/org/xml/sax/helpers/AttributesImpl.java b/jaxp/src/org/xml/sax/helpers/AttributesImpl.java index fc5e9533146..d6fcc4f90ec 100644 --- a/jaxp/src/org/xml/sax/helpers/AttributesImpl.java +++ b/jaxp/src/org/xml/sax/helpers/AttributesImpl.java @@ -64,7 +64,7 @@ import org.xml.sax.Attributes; * AttributeList} interface, it also includes a much more efficient * implementation using a single array rather than a set of Vectors.

* - * @since SAX 2.0 + * @since 1.4, SAX 2.0 * @author David Megginson */ public class AttributesImpl implements Attributes diff --git a/jaxp/src/org/xml/sax/helpers/DefaultHandler.java b/jaxp/src/org/xml/sax/helpers/DefaultHandler.java index 4ae6b1d498a..00632f984b4 100644 --- a/jaxp/src/org/xml/sax/helpers/DefaultHandler.java +++ b/jaxp/src/org/xml/sax/helpers/DefaultHandler.java @@ -73,7 +73,7 @@ import org.xml.sax.SAXParseException; *

This class replaces the deprecated SAX1 * {@link org.xml.sax.HandlerBase HandlerBase} class.

* - * @since SAX 2.0 + * @since 1.4, SAX 2.0 * @author David Megginson, * @see org.xml.sax.EntityResolver * @see org.xml.sax.DTDHandler diff --git a/jaxp/src/org/xml/sax/helpers/LocatorImpl.java b/jaxp/src/org/xml/sax/helpers/LocatorImpl.java index f4c538b3aea..4b0a6e282fe 100644 --- a/jaxp/src/org/xml/sax/helpers/LocatorImpl.java +++ b/jaxp/src/org/xml/sax/helpers/LocatorImpl.java @@ -69,7 +69,7 @@ import org.xml.sax.Locator; * is more efficient to provide location information only when * requested, rather than constantly updating a Locator object.

* - * @since SAX 1.0 + * @since 1.4, SAX 1.0 * @author David Megginson * @see org.xml.sax.Locator Locator */ diff --git a/jaxp/src/org/xml/sax/helpers/NamespaceSupport.java b/jaxp/src/org/xml/sax/helpers/NamespaceSupport.java index 13cf74e855f..90e8c2824e7 100644 --- a/jaxp/src/org/xml/sax/helpers/NamespaceSupport.java +++ b/jaxp/src/org/xml/sax/helpers/NamespaceSupport.java @@ -90,7 +90,7 @@ import java.util.Vector; * Applications must track namespace information themselves if they * want to use namespace information. * - * @since SAX 2.0 + * @since 1.4, SAX 2.0 * @author David Megginson */ public class NamespaceSupport @@ -126,7 +126,7 @@ public class NamespaceSupport * xmlns and xmlns:* attributes, which are used to * declare namespaces.

* - * @since SAX 2.1alpha + * @since 1.5, SAX 2.1alpha * @see #setNamespaceDeclUris * @see #isNamespaceDeclUris */ @@ -497,7 +497,7 @@ public class NamespaceSupport * by {@link #processName processName()}. This may only be * changed before any contexts have been pushed. * - * @since SAX 2.1alpha + * @since 1.5, SAX 2.1alpha * * @exception IllegalStateException when attempting to set this * after any context has been pushed. @@ -521,7 +521,7 @@ public class NamespaceSupport * Returns true if namespace declaration attributes are placed into * a namespace. This behavior is not the default. * - * @since SAX 2.1alpha + * @since 1.5, SAX 2.1alpha */ public boolean isNamespaceDeclUris () { return namespaceDeclUris; } diff --git a/jaxp/src/org/xml/sax/helpers/ParserAdapter.java b/jaxp/src/org/xml/sax/helpers/ParserAdapter.java index 62e76c720ef..3c69e5c9aae 100644 --- a/jaxp/src/org/xml/sax/helpers/ParserAdapter.java +++ b/jaxp/src/org/xml/sax/helpers/ParserAdapter.java @@ -72,7 +72,7 @@ import org.xml.sax.SAXNotSupportedException; *

This adapter does not test for duplicate Namespace-qualified * attribute names.

* - * @since SAX 2.0 + * @since 1.4, SAX 2.0 * @author David Megginson * @version 2.0.1 (sax2r2) * @see org.xml.sax.helpers.XMLReaderAdapter diff --git a/jaxp/src/org/xml/sax/helpers/ParserFactory.java b/jaxp/src/org/xml/sax/helpers/ParserFactory.java index 03983123897..efbefe01509 100644 --- a/jaxp/src/org/xml/sax/helpers/ParserFactory.java +++ b/jaxp/src/org/xml/sax/helpers/ParserFactory.java @@ -61,7 +61,7 @@ import org.xml.sax.Parser; * @deprecated This class works with the deprecated * {@link org.xml.sax.Parser Parser} * interface. - * @since SAX 1.0 + * @since 1.4, SAX 1.0 * @author David Megginson * @version 2.0.1 (sax2r2) */ diff --git a/jaxp/src/org/xml/sax/helpers/XMLFilterImpl.java b/jaxp/src/org/xml/sax/helpers/XMLFilterImpl.java index 1e55672eaba..d103190cca5 100644 --- a/jaxp/src/org/xml/sax/helpers/XMLFilterImpl.java +++ b/jaxp/src/org/xml/sax/helpers/XMLFilterImpl.java @@ -65,7 +65,7 @@ import org.xml.sax.SAXNotRecognizedException; * specific methods to modify the event stream or the configuration * requests as they pass through.

* - * @since SAX 2.0 + * @since 1.4, SAX 2.0 * @author David Megginson * @see org.xml.sax.XMLFilter * @see org.xml.sax.XMLReader diff --git a/jaxp/src/org/xml/sax/helpers/XMLReaderAdapter.java b/jaxp/src/org/xml/sax/helpers/XMLReaderAdapter.java index 394633fb1e3..8256d976761 100644 --- a/jaxp/src/org/xml/sax/helpers/XMLReaderAdapter.java +++ b/jaxp/src/org/xml/sax/helpers/XMLReaderAdapter.java @@ -68,7 +68,7 @@ import org.xml.sax.SAXNotSupportedException; * supports a false value for the http://xml.org/sax/features/namespaces * property, that will also be used to improve efficiency.

* - * @since SAX 2.0 + * @since 1.4, SAX 2.0 * @author David Megginson * @see org.xml.sax.Parser * @see org.xml.sax.XMLReader diff --git a/jaxp/src/org/xml/sax/helpers/XMLReaderFactory.java b/jaxp/src/org/xml/sax/helpers/XMLReaderFactory.java index 27ce1c1afd5..f8d27363331 100644 --- a/jaxp/src/org/xml/sax/helpers/XMLReaderFactory.java +++ b/jaxp/src/org/xml/sax/helpers/XMLReaderFactory.java @@ -67,7 +67,7 @@ import org.xml.sax.SAXException; * nothing bound its class name to org.xml.sax.driver so * those configuration mechanisms would see it.

* - * @since SAX 2.0 + * @since 1.4, SAX 2.0 * @author David Megginson, David Brownell * @version 2.0.1 (sax2r2) */ diff --git a/jaxws/.hgtags b/jaxws/.hgtags index a2cf881e532..3b605e0b08b 100644 --- a/jaxws/.hgtags +++ b/jaxws/.hgtags @@ -264,3 +264,7 @@ e9780330017a6b464a385356d77e5136f9de8d09 jdk9-b15 1e1a3b2215b7551d88e89d1ca8c1e1ebe3d3c0ab jdk9-b16 6b159e727dac283f424b7d19f5be3ddd9f85acf5 jdk9-b17 275f2385aed80c84297840638d58656366350c58 jdk9-b18 +7f922a73e8a2c6ce42634238090fce7c6d599541 jdk9-b19 +6a9f8ff45c04a172df446a418c586da6a86564d5 jdk9-b20 +4a099451fd7e17b6cc4772fe9547907576a45b6f jdk9-b21 +7f5e5902cde75fd9335c52f469491f061fe0239e jdk9-b22 diff --git a/jaxws/src/share/jaxws_classes/com/sun/istack/internal/ByteArrayDataSource.java b/jaxws/src/share/jaxws_classes/com/sun/istack/internal/ByteArrayDataSource.java index 7f22adedf59..cf8ea6427f7 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/istack/internal/ByteArrayDataSource.java +++ b/jaxws/src/share/jaxws_classes/com/sun/istack/internal/ByteArrayDataSource.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 @@ -41,9 +41,19 @@ public final class ByteArrayDataSource implements DataSource { private final byte[] buf; private final int len; + /** + * @param buf input buffer - the byte array isn't being copied; used directly + * @param contentType + */ public ByteArrayDataSource(byte[] buf, String contentType) { this(buf,buf.length,contentType); } + + /** + * @param buf input buffer - the byte array isn't being copied; used directly + * @param length + * @param contentType + */ public ByteArrayDataSource(byte[] buf, int length, String contentType) { this.buf = buf; this.len = length; diff --git a/jaxws/src/share/jaxws_classes/com/sun/istack/internal/XMLStreamReaderToContentHandler.java b/jaxws/src/share/jaxws_classes/com/sun/istack/internal/XMLStreamReaderToContentHandler.java index 2be23a5e1e6..1d8485e2548 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/istack/internal/XMLStreamReaderToContentHandler.java +++ b/jaxws/src/share/jaxws_classes/com/sun/istack/internal/XMLStreamReaderToContentHandler.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 @@ -91,7 +91,7 @@ public class XMLStreamReaderToContentHandler { this.saxHandler = saxCore; this.eagerQuit = eagerQuit; this.fragment = fragment; - this.inscopeNamespaces = inscopeNamespaces; + this.inscopeNamespaces = inscopeNamespaces.clone(); assert inscopeNamespaces.length%2 == 0; } diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle.properties b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle.properties index dccb9d28c58..4cca2e5f744 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle.properties +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle.properties @@ -30,10 +30,10 @@ BASEDIR_DOESNT_EXIST = \ Non-existent directory: {0} VERSION = \ - schemagen 2.2.9-b140218.1920 + schemagen 2.2.11-b140528.1207 FULLVERSION = \ - schemagen full version "2.2.9-b140218.1920" + schemagen full version "2.2.11-b140528.1207" USAGE = \ Usage: schemagen [-options ...] \n\ diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_de.properties b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_de.properties index 5a4be779856..7b1a1a4a1c0 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_de.properties +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_de.properties @@ -27,8 +27,8 @@ UNEXPECTED_NGCC_TOKEN = Nicht erkanntes {0} in Zeile {1} Spalte {2} BASEDIR_DOESNT_EXIST = Nicht vorhandenes Verzeichnis: {0} -VERSION = schemagen 2.2.9-b140218.1920 +VERSION = schemagen 2.2.11-b140528.1207 -FULLVERSION = schemagen vollst\u00E4ndige Version "2.2.9-b140218.1920" +FULLVERSION = schemagen vollst\u00E4ndige Version "2.2.11-b140528.1207" USAGE = Verwendung: schemagen [-options ...] \nOptionen: \n\\ \\ \\ \\ -d : Gibt an, wo die von Prozessor und javac generierten Klassendateien gespeichert werden sollen\n\\ \\ \\ \\ -cp : Gibt an, wo die vom Benutzer angegebenen Dateien gespeichert sind\n\\ \\ \\ \\ -classpath : Gibt an, wo die vom Benutzer angegebenen Dateien gespeichert sind\n\\ \\ \\ \\ -encoding : Gibt die Codierung f\u00FCr die Annotationsverarbeitung/den javac-Aufruf an \n\\ \\ \\ \\ -episode : Generiert Episodendatei f\u00FCr separate Kompilierung\n\\ \\ \\ \\ -version : Zeigt Versionsinformation an\n\\ \\ \\ \\ -fullversion : Zeigt vollst\u00E4ndige Versionsinformationen an\n\\ \\ \\ \\ -help : Zeigt diese Verwendungsmeldung an diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_es.properties b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_es.properties index 938fbb767c6..33eb90a5fe9 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_es.properties +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_es.properties @@ -27,8 +27,8 @@ UNEXPECTED_NGCC_TOKEN = Aparece un {0} inesperado en la l\u00EDnea {1} y la colu BASEDIR_DOESNT_EXIST = Directorio no existente: {0} -VERSION = schemagen 2.2.9-b140218.1920 +VERSION = schemagen 2.2.11-b140528.1207 -FULLVERSION = versi\u00F3n completa de schemagen "2.2.9-b140218.1920" +FULLVERSION = versi\u00F3n completa de schemagen "2.2.11-b140528.1207" USAGE = Sintaxis: schemagen [-options ...] \nOpciones: \n\\ \\ \\ \\ -d : especifique d\u00F3nde se colocan los archivos de clase generados por javac y el procesador\n\\ \\ \\ \\ -cp : especifique d\u00F3nde se encuentran los archivos especificados por el usuario\n\\ \\ \\ \\ -encoding : especifique la codificaci\u00F3n que se va a utilizar para el procesamiento de anotaciones/llamada de javac\n\\ \\ \\ \\ -episode : genera un archivo de episodio para una compilaci\u00F3n diferente\n\\ \\ \\ \\ -version : muestra la informaci\u00F3n de la versi\u00F3n\n\\ \\ \\ \\ -fullversion : muestra la informaci\u00F3n completa de la versi\u00F3n\n\\ \\ \\ \\ -help : muestra este mensaje de sintaxis diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_fr.properties b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_fr.properties index 183fdfdcb8d..b3f02685312 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_fr.properties +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_fr.properties @@ -27,8 +27,8 @@ UNEXPECTED_NGCC_TOKEN = Un \u00E9l\u00E9ment {0} inattendu appara\u00EEt \u00E0 BASEDIR_DOESNT_EXIST = R\u00E9pertoire {0} inexistant -VERSION = schemagen 2.2.9-b140218.1920 +VERSION = schemagen 2.2.11-b140528.1207 -FULLVERSION = version compl\u00E8te de schemagen "2.2.9-b140218.1920" +FULLVERSION = version compl\u00E8te de schemagen "2.2.11-b140528.1207" USAGE = Syntaxe : schemagen [-options ...] \nOptions : \n\ \ \ \ -d : indiquez o\u00F9 placer les fichiers de classe g\u00E9n\u00E9r\u00E9s par le processeur et le compilateur javac\n\ \ \ \ -cp : indiquez o\u00F9 trouver les fichiers sp\u00E9cifi\u00E9s par l'utilisateur\n\ \ \ \ -classpath : indiquez o\u00F9 trouver les fichiers sp\u00E9cifi\u00E9s par l'utilisateur\n\ \ \ \ -encoding : indiquez l'encodage \u00E0 utiliser pour l'appel de javac/traitement de l'annotation \n\ \ \ \ -episode : g\u00E9n\u00E9rez un fichier d'\u00E9pisode pour la compilation s\u00E9par\u00E9e\n\ \ \ \ -version : affichez les informations de version\n\ \ \ \ -fullversion : affichez les informations compl\u00E8tes de version\n\ \ \ \ -help : affichez ce message de syntaxe diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_it.properties b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_it.properties index 9275c115286..bd0029a195d 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_it.properties +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_it.properties @@ -27,8 +27,8 @@ UNEXPECTED_NGCC_TOKEN = {0} imprevisto visualizzato sulla riga {1} colonna {2} BASEDIR_DOESNT_EXIST = Directory non esistente: {0} -VERSION = schemagen 2.2.9-b140218.1920 +VERSION = schemagen 2.2.11-b140528.1207 -FULLVERSION = versione completa schemagen "2.2.9-b140218.1920" +FULLVERSION = versione completa schemagen "2.2.11-b140528.1207" USAGE = Uso: schemagen [-options ...] \nOpzioni: \n\ \ \ \ -d : specifica dove posizionare il processore e i file della classe generata javac\n\ \ \ \ -cp : specifica dove trovare i file specificati dall'utente\n\ \ \ \ -classpath : specifica dove trovare i file specificati dall'utente\n\ \ \ \ -encoding : specifica la codifica da usare per l'elaborazione dell'annotazione/richiamo javac \n\ \ \ \ -episode : genera il file di episodio per la compilazione separata\n\ \ \ \ -version : visualizza le informazioni sulla versione\n\ \ \ \ -fullversion : visualizza le informazioni sulla versione completa\n\ \ \ \ -help : visualizza questo messaggio sull'uso diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_ja.properties b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_ja.properties index f55d2632a9e..a8aa8a74252 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_ja.properties +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_ja.properties @@ -27,8 +27,8 @@ UNEXPECTED_NGCC_TOKEN = \u4E88\u671F\u3057\u306A\u3044{0}\u304C\u884C{1}\u3001\u BASEDIR_DOESNT_EXIST = \u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u304C\u5B58\u5728\u3057\u307E\u305B\u3093: {0} -VERSION = schemagen 2.2.9-b140218.1920 +VERSION = schemagen 2.2.11-b140528.1207 -FULLVERSION = schemagen\u30D5\u30EB\u30FB\u30D0\u30FC\u30B8\u30E7\u30F3"2.2.9-b140218.1920" +FULLVERSION = schemagen\u30D5\u30EB\u30FB\u30D0\u30FC\u30B8\u30E7\u30F3"2.2.11-b140528.1207" USAGE = \u4F7F\u7528\u65B9\u6CD5: schemagen [-options ...] \n\u30AA\u30D7\u30B7\u30E7\u30F3: \n\ \ \ \ -d : \u30D7\u30ED\u30BB\u30C3\u30B5\u304A\u3088\u3073javac\u304C\u751F\u6210\u3057\u305F\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u7F6E\u304F\u4F4D\u7F6E\u3092\u6307\u5B9A\u3057\u307E\u3059\n\ \ \ \ -cp : \u30E6\u30FC\u30B6\u30FC\u304C\u6307\u5B9A\u3057\u305F\u30D5\u30A1\u30A4\u30EB\u3092\u691C\u7D22\u3059\u308B\u4F4D\u7F6E\u3092\u6307\u5B9A\u3057\u307E\u3059\n\ \ \ \ -classpath : \u30E6\u30FC\u30B6\u30FC\u304C\u6307\u5B9A\u3057\u305F\u30D5\u30A1\u30A4\u30EB\u3092\u691C\u7D22\u3059\u308B\u4F4D\u7F6E\u3092\u6307\u5B9A\u3057\u307E\u3059\n\ \ \ \ -encoding : \u6CE8\u91C8\u51E6\u7406/javac\u547C\u51FA\u3057\u306B\u4F7F\u7528\u3059\u308B\u30A8\u30F3\u30B3\u30FC\u30C7\u30A3\u30F3\u30B0\u3092\u6307\u5B9A\u3057\u307E\u3059\n\ \ \ \ -episode : \u30B3\u30F3\u30D1\u30A4\u30EB\u3054\u3068\u306B\u30A8\u30D4\u30BD\u30FC\u30C9\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u751F\u6210\u3057\u307E\u3059\n\ \ \ \ -version : \u30D0\u30FC\u30B8\u30E7\u30F3\u60C5\u5831\u3092\u8868\u793A\u3057\u307E\u3059\n\ \ \ \ -fullversion : \u30D5\u30EB\u30FB\u30D0\u30FC\u30B8\u30E7\u30F3\u60C5\u5831\u3092\u8868\u793A\u3057\u307E\u3059\n\ \ \ \ -help : \u3053\u306E\u4F7F\u7528\u4F8B\u30E1\u30C3\u30BB\u30FC\u30B8\u3092\u8868\u793A\u3057\u307E\u3059 diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_ko.properties b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_ko.properties index 0070635d69d..9af99916c29 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_ko.properties +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_ko.properties @@ -27,8 +27,8 @@ UNEXPECTED_NGCC_TOKEN = \uC608\uC0C1\uCE58 \uC54A\uC740 {0}\uC774(\uAC00) {1}\uD BASEDIR_DOESNT_EXIST = \uC874\uC7AC\uD558\uC9C0 \uC54A\uB294 \uB514\uB809\uD1A0\uB9AC: {0} -VERSION = schemagen 2.2.9-b140218.1920 +VERSION = schemagen 2.2.11-b140528.1207 -FULLVERSION = schemagen \uC815\uC2DD \uBC84\uC804 "2.2.9-b140218.1920" +FULLVERSION = schemagen \uC815\uC2DD \uBC84\uC804 "2.2.11-b140528.1207" USAGE = \uC0AC\uC6A9\uBC95: schemagen [-options ...] \n\uC635\uC158: \n\ \ \ \ -d : \uD504\uB85C\uC138\uC11C \uBC0F javac\uC5D0\uC11C \uC0DD\uC131\uD55C \uD074\uB798\uC2A4 \uD30C\uC77C\uC744 \uBC30\uCE58\uD560 \uC704\uCE58\uB97C \uC9C0\uC815\uD569\uB2C8\uB2E4.\n\ \ \ \ -cp : \uC0AC\uC6A9\uC790\uAC00 \uC9C0\uC815\uD55C \uD30C\uC77C\uC744 \uCC3E\uC744 \uC704\uCE58\uB97C \uC9C0\uC815\uD569\uB2C8\uB2E4.\n\ \ \ \ -classpath : \uC0AC\uC6A9\uC790\uAC00 \uC9C0\uC815\uD55C \uD30C\uC77C\uC744 \uCC3E\uC744 \uC704\uCE58\uB97C \uC9C0\uC815\uD569\uB2C8\uB2E4.\n\ \ \ \ -encoding : \uC8FC\uC11D \uCC98\uB9AC/javac \uD638\uCD9C\uC5D0 \uC0AC\uC6A9\uD560 \uC778\uCF54\uB529\uC744 \uC9C0\uC815\uD569\uB2C8\uB2E4. \n\ \ \ \ -episode : \uBCC4\uB3C4 \uCEF4\uD30C\uC77C\uC744 \uC704\uD574 episode \uD30C\uC77C\uC744 \uC0DD\uC131\uD569\uB2C8\uB2E4.\n\ \ \ \ -version : \uBC84\uC804 \uC815\uBCF4\uB97C \uD45C\uC2DC\uD569\uB2C8\uB2E4.\n\ \ \ \ -fullversion : \uC815\uC2DD \uBC84\uC804 \uC815\uBCF4\uB97C \uD45C\uC2DC\uD569\uB2C8\uB2E4.\n\ \ \ \ -help : \uC774 \uC0AC\uC6A9\uBC95 \uBA54\uC2DC\uC9C0\uB97C \uD45C\uC2DC\uD569\uB2C8\uB2E4. diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_pt_BR.properties b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_pt_BR.properties index 3ef7960b487..8e711c63fc3 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_pt_BR.properties +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_pt_BR.properties @@ -27,8 +27,8 @@ UNEXPECTED_NGCC_TOKEN = {0} inesperado aparece na linha {1} coluna {2} BASEDIR_DOESNT_EXIST = Diret\u00F3rio n\u00E3o existente: {0} -VERSION = gera\u00E7\u00E3o do esquema 2.2.9-b140218.1920 +VERSION = gera\u00E7\u00E3o do esquema 2.2.11-b140528.1207 -FULLVERSION = vers\u00E3o completa da gera\u00E7\u00E3o do esquema "2.2.9-b140218.1920" +FULLVERSION = vers\u00E3o completa da gera\u00E7\u00E3o do esquema "2.2.11-b140528.1207" USAGE = Uso: gera\u00E7\u00E3o do esquema [-options ...] \nOp\u00E7\u00F5es: \n\\ \\ \\ \\ -d : especificar onde colocar o processador e os arquivos da classe gerados por javac\n\\ \\ \\ \\ -cp : especificar onde localizar arquivos especificados pelo usu\u00E1rio\n\\ \\ \\ \\ -classpath : especificar onde localizar os arquivos especificados pelo usu\u00E1rio\n\\ \\ \\ \\ -encoding : especificar codifica\u00E7\u00E3o a ser usada para processamento de anota\u00E7\u00E3o/chamada javac \n\\ \\ \\ \\ -episode : gerar arquivo do epis\u00F3dio para compila\u00E7\u00E3o separada\n\\ \\ \\ \\ -version : exibir informa\u00E7\u00F5es da vers\u00E3o\n\\ \\ \\ \\ -fullversion : exibir informa\u00E7\u00F5es da vers\u00E3o completa\n\\ \\ \\ \\ -help : exibir esta mensagem de uso diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_zh_CN.properties b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_zh_CN.properties index d800201019c..b4ca2ef4543 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_zh_CN.properties +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_zh_CN.properties @@ -27,8 +27,8 @@ UNEXPECTED_NGCC_TOKEN = \u5728\u7B2C {1} \u884C, \u7B2C {2} \u5217\u51FA\u73B0\u BASEDIR_DOESNT_EXIST = \u4E0D\u5B58\u5728\u7684\u76EE\u5F55: {0} -VERSION = schemagen 2.2.9-b140218.1920 +VERSION = schemagen 2.2.11-b140528.1207 -FULLVERSION = schemagen \u5B8C\u6574\u7248\u672C "2.2.9-b140218.1920" +FULLVERSION = schemagen \u5B8C\u6574\u7248\u672C "2.2.11-b140528.1207" USAGE = \u7528\u6CD5: schemagen [-options ...] \n\u9009\u9879: \n\ \ \ \ -d : \u6307\u5B9A\u653E\u7F6E\u5904\u7406\u7A0B\u5E8F\u548C javac \u751F\u6210\u7684\u7C7B\u6587\u4EF6\u7684\u4F4D\u7F6E\n\ \ \ \ -cp : \u6307\u5B9A\u67E5\u627E\u7528\u6237\u6307\u5B9A\u6587\u4EF6\u7684\u4F4D\u7F6E\n\ \ \ \ -classpath : \u6307\u5B9A\u67E5\u627E\u7528\u6237\u6307\u5B9A\u6587\u4EF6\u7684\u4F4D\u7F6E\n\ \ \ \ -encoding : \u6307\u5B9A\u7528\u4E8E\u6CE8\u91CA\u5904\u7406/javac \u8C03\u7528\u7684\u7F16\u7801\n\ \ \ \ -episode : \u751F\u6210\u7247\u6BB5\u6587\u4EF6\u4EE5\u4F9B\u5355\u72EC\u7F16\u8BD1\n\ \ \ \ -version : \u663E\u793A\u7248\u672C\u4FE1\u606F\n\ \ \ \ -fullversion : \u663E\u793A\u5B8C\u6574\u7684\u7248\u672C\u4FE1\u606F\n\ \ \ \ -help : \u663E\u793A\u6B64\u7528\u6CD5\u6D88\u606F diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_zh_TW.properties b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_zh_TW.properties index 6976c6faf3c..c39f1295219 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_zh_TW.properties +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_zh_TW.properties @@ -27,8 +27,8 @@ UNEXPECTED_NGCC_TOKEN = \u672A\u9810\u671F\u7684 {0} \u986F\u793A\u65BC\u884C {1 BASEDIR_DOESNT_EXIST = \u4E0D\u5B58\u5728\u7684\u76EE\u9304: {0} -VERSION = schemagen 2.2.9-b140218.1920 +VERSION = schemagen 2.2.11-b140528.1207 -FULLVERSION = schemagen \u5B8C\u6574\u7248\u672C "2.2.9-b140218.1920" +FULLVERSION = schemagen \u5B8C\u6574\u7248\u672C "2.2.11-b140528.1207" USAGE = \u7528\u6CD5: schemagen [-options ...] \n\u9078\u9805: \n\\ \\ \\ \\ -d : \u6307\u5B9A\u8655\u7406\u5668\u4EE5\u53CA javac \u7522\u751F\u7684\u985E\u5225\u6A94\u6848\u653E\u7F6E\u4F4D\u7F6E\n\\ \\ \\ \\ -cp : \u6307\u5B9A\u8981\u5C0B\u627E\u4F7F\u7528\u8005\u6307\u5B9A\u6A94\u6848\u7684\u4F4D\u7F6E\n\\ \\ \\ \\ -classpath : \u6307\u5B9A\u8981\u5C0B\u627E\u4F7F\u7528\u8005\u6307\u5B9A\u6A94\u6848\u7684\u4F4D\u7F6E\n\\ \\ \\ \\ -encoding : \u6307\u5B9A\u8981\u7528\u65BC\u8A3B\u89E3\u8655\u7406/javac \u547C\u53EB\u7684\u7DE8\u78BC \n\\ \\ \\ \\ -episode : \u7522\u751F\u7368\u7ACB\u7DE8\u8B6F\u7684\u4E8B\u4EF6 (episode) \u6A94\u6848\n\\ \\ \\ \\ -version : \u986F\u793A\u7248\u672C\u8CC7\u8A0A\n\\ \\ \\ \\ -fullversion : \u986F\u793A\u5B8C\u6574\u7248\u672C\u8CC7\u8A0A\n\\ \\ \\ \\ -help : \u986F\u793A\u6B64\u7528\u6CD5\u8A0A\u606F diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/ws/version.properties b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/ws/version.properties index 188bd319f70..1d11f65b66a 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/ws/version.properties +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/ws/version.properties @@ -23,7 +23,7 @@ # questions. # -build-id=2.2.10-b140228.1436 -build-version=JAX-WS RI 2.2.10-b140228.1436 -major-version=2.2.10 -svn-revision=e1d4708e8a2aee1ae9d38313452e14ce4b67851a +build-id=2.2.11-b140602.1731 +build-version=JAX-WS RI 2.2.11-b140602.1731 +major-version=2.2.11 +svn-revision=a684014c13b34abb8b9613e106f44f59abea206f diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/Driver.java b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/Driver.java index 5056d39d677..f913964061b 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/Driver.java +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/Driver.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,8 @@ import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintStream; +import java.security.AccessController; +import java.security.PrivilegedAction; import java.util.Iterator; import com.sun.codemodel.internal.CodeWriter; @@ -64,14 +66,12 @@ import org.xml.sax.SAXParseException; */ public class Driver { + private static final String SYSTEM_PROXY_PROPERTY = "java.net.useSystemProxies"; + public static void main(final String[] args) throws Exception { // use the platform default proxy if available. // see sun.net.spi.DefaultProxySelector for details. - try { - System.setProperty("java.net.useSystemProxies","true"); - } catch (SecurityException e) { - // failing to set this property isn't fatal - } + setupProxies(); if( Util.getSystemProperty(Driver.class,"noThreadSwap")!=null ) _main(args); // for the ease of debugging @@ -103,6 +103,27 @@ public class Driver { } } + /** + * Set useSystemProxies if needed + */ + private static void setupProxies() { + Object setProperty = AccessController.doPrivileged(new PrivilegedAction() { + @Override + public Object run() { + return System.getProperty(SYSTEM_PROXY_PROPERTY); + } + }); + if (setProperty == null) { + AccessController.doPrivileged(new PrivilegedAction() { + @Override + public Void run() { + System.setProperty(SYSTEM_PROXY_PROPERTY, "true"); + return null; + } + }); + } + } + private static void _main( String[] args ) throws Exception { try { System.exit(run( args, System.out, System.out )); diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle.properties b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle.properties index 6ebbffea7dc..b8d84282b0a 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle.properties +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle.properties @@ -171,20 +171,20 @@ Driver.CompilingSchema = \ Driver.FailedToGenerateCode = \ Failed to produce code. -# DO NOT localize the 2.2.9-b140218.1920 string - it is a token for an mvn +# DO NOT localize the 2.2.11-b140528.1207 string - it is a token for an mvn Driver.FilePrologComment = \ - This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.9-b140218.1920 \n\ + This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11-b140528.1207 \n\ See http://java.sun.com/xml/jaxb \n\ Any modifications to this file will be lost upon recompilation of the source schema. \n\ Generated on: {0} \n Driver.Version = \ - xjc 2.2.9-b140218.1920 + xjc 2.2.11-b140528.1207 Driver.FullVersion = \ - xjc full version "2.2.9-b140218.1920" + xjc full version "2.2.11-b140528.1207" -Driver.BuildID = 2.2.9-b140218.1920 +Driver.BuildID = 2.2.11-b140528.1207 # for JDK integration - include version in source zip jaxb.jdk.version=@@JAXB_JDK_VERSION@@ diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_de.properties b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_de.properties index 51d70085075..4da4e04ba3e 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_de.properties +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_de.properties @@ -96,14 +96,14 @@ Driver.CompilingSchema = Ein Schema wird kompiliert ... Driver.FailedToGenerateCode = Code konnte nicht erzeugt werden. -# DO NOT localize the 2.2.9-b140218.1920 string - it is a token for an mvn -Driver.FilePrologComment = Diese Datei wurde mit der JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.9-b140218.1920 generiert \nSiehe http://java.sun.com/xml/jaxb \n\u00c4nderungen an dieser Datei gehen bei einer Neukompilierung des Quellschemas verloren. \nGeneriert: {0} \n +# DO NOT localize the 2.2.11-b140528.1207 string - it is a token for an mvn +Driver.FilePrologComment = Diese Datei wurde mit der JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11-b140528.1207 generiert \nSiehe http://java.sun.com/xml/jaxb \n\u00c4nderungen an dieser Datei gehen bei einer Neukompilierung des Quellschemas verloren. \nGeneriert: {0} \n -Driver.Version = xjc 2.2.9-b140218.1920 +Driver.Version = xjc 2.2.11-b140528.1207 -Driver.FullVersion = xjc vollst\u00E4ndige Version "2.2.9-b140218.1920" +Driver.FullVersion = xjc vollst\u00E4ndige Version "2.2.11-b140528.1207" -Driver.BuildID = 2.2.9-b140218.1920 +Driver.BuildID = 2.2.11-b140528.1207 # for JDK integration - include version in source zip jaxb.jdk.version=@@JAXB_JDK_VERSION@@ diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_es.properties b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_es.properties index acdbffd5ad1..67232a962ab 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_es.properties +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_es.properties @@ -96,14 +96,14 @@ Driver.CompilingSchema = Compilando un esquema... Driver.FailedToGenerateCode = Fallo al producir c\u00f3digo. -# DO NOT localize the 2.2.9-b140218.1920 string - it is a token for an mvn -Driver.FilePrologComment = Este archivo ha sido generado por la arquitectura JavaTM para la implantaci\u00f3n de la referencia de enlace (JAXB) XML v2.2.9-b140218.1920 \nVisite http://java.sun.com/xml/jaxb \nTodas las modificaciones realizadas en este archivo se perder\u00e1n si se vuelve a compilar el esquema de origen. \nGenerado el: {0} \n +# DO NOT localize the 2.2.11-b140528.1207 string - it is a token for an mvn +Driver.FilePrologComment = Este archivo ha sido generado por la arquitectura JavaTM para la implantaci\u00f3n de la referencia de enlace (JAXB) XML v2.2.11-b140528.1207 \nVisite http://java.sun.com/xml/jaxb \nTodas las modificaciones realizadas en este archivo se perder\u00e1n si se vuelve a compilar el esquema de origen. \nGenerado el: {0} \n -Driver.Version = xjc 2.2.9-b140218.1920 +Driver.Version = xjc 2.2.11-b140528.1207 -Driver.FullVersion = versi\u00F3n completa de xjc "2.2.9-b140218.1920" +Driver.FullVersion = versi\u00F3n completa de xjc "2.2.11-b140528.1207" -Driver.BuildID = 2.2.9-b140218.1920 +Driver.BuildID = 2.2.11-b140528.1207 # for JDK integration - include version in source zip jaxb.jdk.version=@@JAXB_JDK_VERSION@@ diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_fr.properties b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_fr.properties index 76aec21fd2d..6c53d943abe 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_fr.properties +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_fr.properties @@ -96,14 +96,14 @@ Driver.CompilingSchema = compilation d'un sch\u00e9ma... Driver.FailedToGenerateCode = Echec de la production du code. -# DO NOT localize the 2.2.9-b140218.1920 string - it is a token for an mvn -Driver.FilePrologComment = Ce fichier a \u00e9t\u00e9 g\u00e9n\u00e9r\u00e9 par l''impl\u00e9mentation de r\u00e9f\u00e9rence JavaTM Architecture for XML Binding (JAXB), v2.2.9-b140218.1920 \nVoir http://java.sun.com/xml/jaxb \nToute modification apport\u00e9e \u00e0 ce fichier sera perdue lors de la recompilation du sch\u00e9ma source. \nG\u00e9n\u00e9r\u00e9 le : {0} \n +# DO NOT localize the 2.2.11-b140528.1207 string - it is a token for an mvn +Driver.FilePrologComment = Ce fichier a \u00e9t\u00e9 g\u00e9n\u00e9r\u00e9 par l''impl\u00e9mentation de r\u00e9f\u00e9rence JavaTM Architecture for XML Binding (JAXB), v2.2.11-b140528.1207 \nVoir http://java.sun.com/xml/jaxb \nToute modification apport\u00e9e \u00e0 ce fichier sera perdue lors de la recompilation du sch\u00e9ma source. \nG\u00e9n\u00e9r\u00e9 le : {0} \n -Driver.Version = xjc 2.2.9-b140218.1920 +Driver.Version = xjc 2.2.11-b140528.1207 -Driver.FullVersion = version compl\u00E8te xjc "2.2.9-b140218.1920" +Driver.FullVersion = version compl\u00E8te xjc "2.2.11-b140528.1207" -Driver.BuildID = 2.2.9-b140218.1920 +Driver.BuildID = 2.2.11-b140528.1207 # for JDK integration - include version in source zip jaxb.jdk.version=@@JAXB_JDK_VERSION@@ diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_it.properties b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_it.properties index 9a9a5332e5c..5496cc310e2 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_it.properties +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_it.properties @@ -96,14 +96,14 @@ Driver.CompilingSchema = compilazione di uno schema in corso... Driver.FailedToGenerateCode = Produzione del codice non riuscita. -# DO NOT localize the 2.2.9-b140218.1920 string - it is a token for an mvn -Driver.FilePrologComment = Questo file \u00e8 stato generato dall''architettura JavaTM per XML Binding (JAXB) Reference Implementation, v2.2.9-b140218.1920 \nVedere http://java.sun.com/xml/jaxb \nQualsiasi modifica a questo file andr\u00e0 persa durante la ricompilazione dello schema di origine. \nGenerato il: {0} \n +# DO NOT localize the 2.2.11-b140528.1207 string - it is a token for an mvn +Driver.FilePrologComment = Questo file \u00e8 stato generato dall''architettura JavaTM per XML Binding (JAXB) Reference Implementation, v2.2.11-b140528.1207 \nVedere http://java.sun.com/xml/jaxb \nQualsiasi modifica a questo file andr\u00e0 persa durante la ricompilazione dello schema di origine. \nGenerato il: {0} \n -Driver.Version = xjc 2.2.9-b140218.1920 +Driver.Version = xjc 2.2.11-b140528.1207 -Driver.FullVersion = versione completa xjc "2.2.9-b140218.1920" +Driver.FullVersion = versione completa xjc "2.2.11-b140528.1207" -Driver.BuildID = 2.2.9-b140218.1920 +Driver.BuildID = 2.2.11-b140528.1207 # for JDK integration - include version in source zip jaxb.jdk.version=@@JAXB_JDK_VERSION@@ diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_ja.properties b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_ja.properties index 8fc9f7b12fd..6bbc0ee7937 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_ja.properties +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_ja.properties @@ -96,14 +96,14 @@ Driver.CompilingSchema = \u30b9\u30ad\u30fc\u30de\u306e\u30b3\u30f3\u30d1\u30a4\ Driver.FailedToGenerateCode = \u30b3\u30fc\u30c9\u306e\u751f\u6210\u306b\u5931\u6557\u3057\u307e\u3057\u305f\u3002 -# DO NOT localize the 2.2.9-b140218.1920 string - it is a token for an mvn -Driver.FilePrologComment = \u3053\u306e\u30d5\u30a1\u30a4\u30eb\u306f\u3001JavaTM Architecture for XML Binding(JAXB) Reference Implementation\u3001v2.2.9-b140218.1920\u306b\u3088\u3063\u3066\u751f\u6210\u3055\u308c\u307e\u3057\u305f \nhttp://java.sun.com/xml/jaxb\u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044 \n\u30bd\u30fc\u30b9\u30fb\u30b9\u30ad\u30fc\u30de\u306e\u518d\u30b3\u30f3\u30d1\u30a4\u30eb\u6642\u306b\u3053\u306e\u30d5\u30a1\u30a4\u30eb\u306e\u5909\u66f4\u306f\u5931\u308f\u308c\u307e\u3059\u3002 \n\u751f\u6210\u65e5: {0} \n +# DO NOT localize the 2.2.11-b140528.1207 string - it is a token for an mvn +Driver.FilePrologComment = \u3053\u306e\u30d5\u30a1\u30a4\u30eb\u306f\u3001JavaTM Architecture for XML Binding(JAXB) Reference Implementation\u3001v2.2.11-b140528.1207\u306b\u3088\u3063\u3066\u751f\u6210\u3055\u308c\u307e\u3057\u305f \nhttp://java.sun.com/xml/jaxb\u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044 \n\u30bd\u30fc\u30b9\u30fb\u30b9\u30ad\u30fc\u30de\u306e\u518d\u30b3\u30f3\u30d1\u30a4\u30eb\u6642\u306b\u3053\u306e\u30d5\u30a1\u30a4\u30eb\u306e\u5909\u66f4\u306f\u5931\u308f\u308c\u307e\u3059\u3002 \n\u751f\u6210\u65e5: {0} \n -Driver.Version = xjc 2.2.9-b140218.1920 +Driver.Version = xjc 2.2.11-b140528.1207 -Driver.FullVersion = xjc\u30D5\u30EB\u30FB\u30D0\u30FC\u30B8\u30E7\u30F3"2.2.9-b140218.1920" +Driver.FullVersion = xjc\u30D5\u30EB\u30FB\u30D0\u30FC\u30B8\u30E7\u30F3"2.2.11-b140528.1207" -Driver.BuildID = 2.2.9-b140218.1920 +Driver.BuildID = 2.2.11-b140528.1207 # for JDK integration - include version in source zip jaxb.jdk.version=@@JAXB_JDK_VERSION@@ diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_ko.properties b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_ko.properties index 7a34340441a..06820b7ba72 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_ko.properties +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_ko.properties @@ -96,14 +96,14 @@ Driver.CompilingSchema = \uc2a4\ud0a4\ub9c8\ub97c \ucef4\ud30c\uc77c\ud558\ub294 Driver.FailedToGenerateCode = \ucf54\ub4dc \uc0dd\uc131\uc744 \uc2e4\ud328\ud588\uc2b5\ub2c8\ub2e4. -# DO NOT localize the 2.2.9-b140218.1920 string - it is a token for an mvn -Driver.FilePrologComment = \uc774 \ud30c\uc77c\uc740 JAXB(JavaTM Architecture for XML Binding) \ucc38\uc870 \uad6c\ud604 2.2.9-b140218.1920 \ubc84\uc804\uc744 \ud1b5\ud574 \uc0dd\uc131\ub418\uc5c8\uc2b5\ub2c8\ub2e4. \nhttp://java.sun.com/xml/jaxb\ub97c \ucc38\uc870\ud558\uc2ed\uc2dc\uc624. \n\uc774 \ud30c\uc77c\uc744 \uc218\uc815\ud558\uba74 \uc18c\uc2a4 \uc2a4\ud0a4\ub9c8\ub97c \uc7ac\ucef4\ud30c\uc77c\ud560 \ub54c \uc218\uc815 \uc0ac\ud56d\uc774 \uc190\uc2e4\ub429\ub2c8\ub2e4. \n\uc0dd\uc131 \ub0a0\uc9dc: {0} \n +# DO NOT localize the 2.2.11-b140528.1207 string - it is a token for an mvn +Driver.FilePrologComment = \uc774 \ud30c\uc77c\uc740 JAXB(JavaTM Architecture for XML Binding) \ucc38\uc870 \uad6c\ud604 2.2.11-b140528.1207 \ubc84\uc804\uc744 \ud1b5\ud574 \uc0dd\uc131\ub418\uc5c8\uc2b5\ub2c8\ub2e4. \nhttp://java.sun.com/xml/jaxb\ub97c \ucc38\uc870\ud558\uc2ed\uc2dc\uc624. \n\uc774 \ud30c\uc77c\uc744 \uc218\uc815\ud558\uba74 \uc18c\uc2a4 \uc2a4\ud0a4\ub9c8\ub97c \uc7ac\ucef4\ud30c\uc77c\ud560 \ub54c \uc218\uc815 \uc0ac\ud56d\uc774 \uc190\uc2e4\ub429\ub2c8\ub2e4. \n\uc0dd\uc131 \ub0a0\uc9dc: {0} \n -Driver.Version = XJC 2.2.9-b140218.1920 +Driver.Version = XJC 2.2.11-b140528.1207 -Driver.FullVersion = XJC \uC815\uC2DD \uBC84\uC804 "2.2.9-b140218.1920" +Driver.FullVersion = XJC \uC815\uC2DD \uBC84\uC804 "2.2.11-b140528.1207" -Driver.BuildID = 2.2.9-b140218.1920 +Driver.BuildID = 2.2.11-b140528.1207 # for JDK integration - include version in source zip jaxb.jdk.version=@@JAXB_JDK_VERSION@@ diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_pt_BR.properties b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_pt_BR.properties index 3f422db793f..91ebf60b28c 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_pt_BR.properties +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_pt_BR.properties @@ -96,14 +96,14 @@ Driver.CompilingSchema = compilando um esquema... Driver.FailedToGenerateCode = Falha ao produzir o c\u00f3digo. -# DO NOT localize the 2.2.9-b140218.1920 string - it is a token for an mvn -Driver.FilePrologComment = Este arquivo foi gerado pela Arquitetura JavaTM para Implementa\u00e7\u00e3o de Refer\u00eancia (JAXB) de Bind XML, v2.2.9-b140218.1920 \nConsulte http://java.sun.com/xml/jaxb \nTodas as modifica\u00e7\u00f5es neste arquivo ser\u00e3o perdidas ap\u00f3s a recompila\u00e7\u00e3o do esquema de origem. \nGerado em: {0} \n +# DO NOT localize the 2.2.11-b140528.1207 string - it is a token for an mvn +Driver.FilePrologComment = Este arquivo foi gerado pela Arquitetura JavaTM para Implementa\u00e7\u00e3o de Refer\u00eancia (JAXB) de Bind XML, v2.2.11-b140528.1207 \nConsulte http://java.sun.com/xml/jaxb \nTodas as modifica\u00e7\u00f5es neste arquivo ser\u00e3o perdidas ap\u00f3s a recompila\u00e7\u00e3o do esquema de origem. \nGerado em: {0} \n -Driver.Version = xjc 2.2.9-b140218.1920 +Driver.Version = xjc 2.2.11-b140528.1207 -Driver.FullVersion = vers\u00E3o completa de xjc "2.2.9-b140218.1920" +Driver.FullVersion = vers\u00E3o completa de xjc "2.2.11-b140528.1207" -Driver.BuildID = 2.2.9-b140218.1920 +Driver.BuildID = 2.2.11-b140528.1207 # for JDK integration - include version in source zip jaxb.jdk.version=@@JAXB_JDK_VERSION@@ diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_zh_CN.properties b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_zh_CN.properties index 4a858e47f17..cea171b5208 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_zh_CN.properties +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_zh_CN.properties @@ -96,14 +96,14 @@ Driver.CompilingSchema = \u6b63\u5728\u7f16\u8bd1\u6a21\u5f0f... Driver.FailedToGenerateCode = \u65e0\u6cd5\u751f\u6210\u4ee3\u7801\u3002 -# DO NOT localize the 2.2.9-b140218.1920 string - it is a token for an mvn -Driver.FilePrologComment = \u6b64\u6587\u4ef6\u662f\u7531 JavaTM Architecture for XML Binding (JAXB) \u5f15\u7528\u5b9e\u73b0 v2.2.9-b140218.1920 \u751f\u6210\u7684\n\u8bf7\u8bbf\u95ee http://java.sun.com/xml/jaxb \n\u5728\u91cd\u65b0\u7f16\u8bd1\u6e90\u6a21\u5f0f\u65f6, \u5bf9\u6b64\u6587\u4ef6\u7684\u6240\u6709\u4fee\u6539\u90fd\u5c06\u4e22\u5931\u3002\n\u751f\u6210\u65f6\u95f4: {0} \n +# DO NOT localize the 2.2.11-b140528.1207 string - it is a token for an mvn +Driver.FilePrologComment = \u6b64\u6587\u4ef6\u662f\u7531 JavaTM Architecture for XML Binding (JAXB) \u5f15\u7528\u5b9e\u73b0 v2.2.11-b140528.1207 \u751f\u6210\u7684\n\u8bf7\u8bbf\u95ee http://java.sun.com/xml/jaxb \n\u5728\u91cd\u65b0\u7f16\u8bd1\u6e90\u6a21\u5f0f\u65f6, \u5bf9\u6b64\u6587\u4ef6\u7684\u6240\u6709\u4fee\u6539\u90fd\u5c06\u4e22\u5931\u3002\n\u751f\u6210\u65f6\u95f4: {0} \n -Driver.Version = xjc 2.2.9-b140218.1920 +Driver.Version = xjc 2.2.11-b140528.1207 -Driver.FullVersion = xjc \u5B8C\u6574\u7248\u672C "2.2.9-b140218.1920" +Driver.FullVersion = xjc \u5B8C\u6574\u7248\u672C "2.2.11-b140528.1207" -Driver.BuildID = 2.2.9-b140218.1920 +Driver.BuildID = 2.2.11-b140528.1207 # for JDK integration - include version in source zip jaxb.jdk.version=@@JAXB_JDK_VERSION@@ diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_zh_TW.properties b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_zh_TW.properties index add02eb0f7b..99a89597e66 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_zh_TW.properties +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_zh_TW.properties @@ -96,14 +96,14 @@ Driver.CompilingSchema = \u6b63\u5728\u7de8\u8b6f\u7db1\u8981... Driver.FailedToGenerateCode = \u7121\u6cd5\u7522\u751f\u7a0b\u5f0f\u78bc. -# DO NOT localize the 2.2.9-b140218.1920 string - it is a token for an mvn -Driver.FilePrologComment = \u6b64\u6a94\u6848\u662f\u7531 JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.9-b140218.1920 \u6240\u7522\u751f \n\u8acb\u53c3\u95b1 http://java.sun.com/xml/jaxb \n\u4e00\u65e6\u91cd\u65b0\u7de8\u8b6f\u4f86\u6e90\u7db1\u8981, \u5c0d\u6b64\u6a94\u6848\u6240\u505a\u7684\u4efb\u4f55\u4fee\u6539\u90fd\u5c07\u6703\u907a\u5931. \n\u7522\u751f\u6642\u9593: {0} \n +# DO NOT localize the 2.2.11-b140528.1207 string - it is a token for an mvn +Driver.FilePrologComment = \u6b64\u6a94\u6848\u662f\u7531 JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11-b140528.1207 \u6240\u7522\u751f \n\u8acb\u53c3\u95b1 http://java.sun.com/xml/jaxb \n\u4e00\u65e6\u91cd\u65b0\u7de8\u8b6f\u4f86\u6e90\u7db1\u8981, \u5c0d\u6b64\u6a94\u6848\u6240\u505a\u7684\u4efb\u4f55\u4fee\u6539\u90fd\u5c07\u6703\u907a\u5931. \n\u7522\u751f\u6642\u9593: {0} \n -Driver.Version = xjc 2.2.9-b140218.1920 +Driver.Version = xjc 2.2.11-b140528.1207 -Driver.FullVersion = xjc \u5B8C\u6574\u7248\u672C "2.2.9-b140218.1920" +Driver.FullVersion = xjc \u5B8C\u6574\u7248\u672C "2.2.11-b140528.1207" -Driver.BuildID = 2.2.9-b140218.1920 +Driver.BuildID = 2.2.11-b140528.1207 # for JDK integration - include version in source zip jaxb.jdk.version=@@JAXB_JDK_VERSION@@ diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/Options.java b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/Options.java index 19fd50c1d43..fefa33f9830 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/Options.java +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/Options.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 @@ -773,7 +773,10 @@ public class Options */ public void addCatalog(File catalogFile) throws IOException { if(entityResolver==null) { - CatalogManager.getStaticManager().setIgnoreMissingProperties(true); + final CatalogManager staticManager = CatalogManager.getStaticManager(); + // hack to force initialization so catalog manager system properties take effect + staticManager.getVerbosity(); + staticManager.setIgnoreMissingProperties(true); entityResolver = new CatalogResolver(true); } ((CatalogResolver)entityResolver).getCatalog().parseCatalog(catalogFile.getPath()); diff --git a/jdk/make/mapfiles/libnpt/mapfile-vers b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/Messages_de.properties similarity index 85% rename from jdk/make/mapfiles/libnpt/mapfile-vers rename to jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/Messages_de.properties index d6c03e4a907..9523686e8db 100644 --- a/jdk/make/mapfiles/libnpt/mapfile-vers +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/Messages_de.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2004, 2013, 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 @@ -23,12 +23,4 @@ # questions. # -# Define public interface. - -SUNWprivate_1.1 { - global: - nptInitialize; - nptTerminate; - local: - *; -}; +FAILED_TO_INITIALE_DATATYPE_FACTORY = JAXP 1.3 DatatypeFactory-Klasse konnte nicht initialisiert werden. diff --git a/jdk/src/macosx/native/jobjc/TODOS b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/Messages_es.properties similarity index 86% rename from jdk/src/macosx/native/jobjc/TODOS rename to jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/Messages_es.properties index 16abea13760..85a98f44ffe 100644 --- a/jdk/src/macosx/native/jobjc/TODOS +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/Messages_es.properties @@ -1,6 +1,5 @@ -#!/bin/bash # -# Copyright (c) 2011, 2012, 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 @@ -23,5 +22,5 @@ # or visit www.oracle.com if you need additional information or have any # questions. # -# -egrep "(TODO|FIXME|XXX|HACK)" -r src + +FAILED_TO_INITIALE_DATATYPE_FACTORY = Fallo al inicializar la clase DatatypeFactory de JAXP 1.3. diff --git a/jdk/src/macosx/native/jobjc/runjava b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/Messages_fr.properties similarity index 76% rename from jdk/src/macosx/native/jobjc/runjava rename to jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/Messages_fr.properties index a6e91547e7d..02a1449e04a 100644 --- a/jdk/src/macosx/native/jobjc/runjava +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/Messages_fr.properties @@ -1,6 +1,5 @@ -#!/bin/bash # -# Copyright (c) 2011, 2012, 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 @@ -23,5 +22,5 @@ # or visit www.oracle.com if you need additional information or have any # questions. # -# -java -ea -classpath "lib/junit-4.4.jar:build/JObjC.build/Debug/bin/core:build/JObjC.build/Debug/bin/generator:build/JObjC.build/Debug/bin/additions:build/JObjC.build/Debug/bin/test:build/JObjC.build/Debug/bin/generated" -Djava.library.path=build/Debug $@ + +FAILED_TO_INITIALE_DATATYPE_FACTORY = Echec de l'initialisation de la classe JAXP 1.3 DatatypeFactory. diff --git a/jdk/src/macosx/native/jobjc/extract_classes.pl b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/Messages_it.properties similarity index 71% rename from jdk/src/macosx/native/jobjc/extract_classes.pl rename to jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/Messages_it.properties index b0950db4699..9eb8e699de9 100644 --- a/jdk/src/macosx/native/jobjc/extract_classes.pl +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/Messages_it.properties @@ -1,6 +1,5 @@ -#!/usr/bin/perl # -# Copyright (c) 2011, 2012, 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 @@ -22,18 +21,6 @@ # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA # or visit www.oracle.com if you need additional information or have any # questions. -## +# -$file_dir = $ARGV[0]; -@file_list = qx("/usr/bin/find" "$file_dir"); - -foreach $file (@file_list) { - if ($file =~ s/\.class//) { - if ($file !~ s/\$[0-9]//) { - $file =~ s/$file_dir\///g; - $file =~ s/\//\./g; - chomp($file); - print "$file,"; - } - } -} +FAILED_TO_INITIALE_DATATYPE_FACTORY = Inizializzazione della classe DatatypeFactory di JAXP 1.3 non riuscita. diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/Messages_ja.properties b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/Messages_ja.properties new file mode 100644 index 00000000000..9c7eb0b9bbc --- /dev/null +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/Messages_ja.properties @@ -0,0 +1,26 @@ +# +# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +FAILED_TO_INITIALE_DATATYPE_FACTORY = JAXP 1.3 DatatypeFactory\u30AF\u30E9\u30B9\u306E\u521D\u671F\u5316\u306B\u5931\u6557\u3057\u307E\u3057\u305F\u3002 diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/Messages_ko.properties b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/Messages_ko.properties new file mode 100644 index 00000000000..1d722552bf4 --- /dev/null +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/Messages_ko.properties @@ -0,0 +1,26 @@ +# +# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +FAILED_TO_INITIALE_DATATYPE_FACTORY = JAXP 1.3 DatatypeFactory \uD074\uB798\uC2A4 \uCD08\uAE30\uD654\uB97C \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4. diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/Messages_pt_BR.properties b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/Messages_pt_BR.properties new file mode 100644 index 00000000000..b43879e6761 --- /dev/null +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/Messages_pt_BR.properties @@ -0,0 +1,26 @@ +# +# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +FAILED_TO_INITIALE_DATATYPE_FACTORY = Falha ao inicializar a classe DatatypeFactory de JAXP 1.3. diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/Messages_zh_CN.properties b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/Messages_zh_CN.properties new file mode 100644 index 00000000000..18b3d6e76bc --- /dev/null +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/Messages_zh_CN.properties @@ -0,0 +1,26 @@ +# +# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +FAILED_TO_INITIALE_DATATYPE_FACTORY = \u65E0\u6CD5\u521D\u59CB\u5316 JAXP 1.3 DatatypeFactory \u7C7B\u3002 diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/Messages_zh_TW.properties b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/Messages_zh_TW.properties new file mode 100644 index 00000000000..709925f8b26 --- /dev/null +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/Messages_zh_TW.properties @@ -0,0 +1,26 @@ +# +# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +FAILED_TO_INITIALE_DATATYPE_FACTORY = \u7121\u6CD5\u8D77\u59CB JAXP 1.3 DatatypeFactory \u985E\u5225. diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/Messages.properties b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/Messages.properties index 83dc005fdac..09f2d7f899c 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/Messages.properties +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/Messages.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 1997, 2012, 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 @@ -90,9 +90,6 @@ PROPERTY_ORDER_CONTAINS_UNUSED_ENTRY = \ INVALID_XML_ENUM_VALUE = \ "{0}" is not a valid value for {1}. -FAILED_TO_INITIALE_DATATYPE_FACTORY = \ - Failed to initialize JAXP 1.3 DatatypeFactory class. - NO_IMAGE_WRITER = \ No javax.imageio.ImageWriter is available for the specified MIME type "{0}" diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/Messages_de.properties b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/Messages_de.properties index 5e009b9c07d..ae903996644 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/Messages_de.properties +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/Messages_de.properties @@ -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 @@ -69,8 +69,6 @@ PROPERTY_ORDER_CONTAINS_UNUSED_ENTRY = Eigenschaft {0} ist in @XmlType.propOrder # {1} - (local) type name e.g.: '#foo' is not a valid value for 'NCName' INVALID_XML_ENUM_VALUE = "{0}" ist kein g\u00FCltiger Wert f\u00FCr {1}. -FAILED_TO_INITIALE_DATATYPE_FACTORY = JAXP 1.3 DatatypeFactory-Klasse konnte nicht initialisiert werden. - NO_IMAGE_WRITER = Es ist kein javax.imageio.ImageWriter f\u00FCr den angegebenen MIME-Typ "{0}" verf\u00FCgbar ILLEGAL_MIME_TYPE = "{0}" ist kein g\u00FCltiger MIME-Typ: {1} diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/Messages_es.properties b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/Messages_es.properties index 40be270a949..d1f8c1da25a 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/Messages_es.properties +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/Messages_es.properties @@ -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 @@ -69,8 +69,6 @@ PROPERTY_ORDER_CONTAINS_UNUSED_ENTRY = La propiedad {0} aparece en @XmlType.prop # {1} - (local) type name e.g.: '#foo' is not a valid value for 'NCName' INVALID_XML_ENUM_VALUE = "{0}" no es un valor v\u00E1lido para {1}. -FAILED_TO_INITIALE_DATATYPE_FACTORY = Fallo al inicializar la clase DatatypeFactory de JAXP 1.3. - NO_IMAGE_WRITER = No hay disponible ning\u00FAn javax.imageio.ImageWriter para el tipo MIME especificado "{0}" ILLEGAL_MIME_TYPE = "{0}" no es un tipo MIME v\u00E1lido: {1} diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/Messages_fr.properties b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/Messages_fr.properties index 7a536fac08e..427d92b439a 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/Messages_fr.properties +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/Messages_fr.properties @@ -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 @@ -69,8 +69,6 @@ PROPERTY_ORDER_CONTAINS_UNUSED_ENTRY = La propri\u00E9t\u00E9 {0} appara\u00EEt # {1} - (local) type name e.g.: '#foo' is not a valid value for 'NCName' INVALID_XML_ENUM_VALUE = "{0}" n''est pas une valeur valide pour {1}. -FAILED_TO_INITIALE_DATATYPE_FACTORY = Echec de l'initialisation de la classe JAXP 1.3 DatatypeFactory. - NO_IMAGE_WRITER = Aucune classe javax.imageio.ImageWriter n''est disponible pour le type MIME "{0}" indiqu\u00E9 ILLEGAL_MIME_TYPE = "{0}" n''est pas un type MIME valide : {1} diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/Messages_it.properties b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/Messages_it.properties index c1846095802..ca7d1285c9e 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/Messages_it.properties +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/Messages_it.properties @@ -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 @@ -69,8 +69,6 @@ PROPERTY_ORDER_CONTAINS_UNUSED_ENTRY = La propriet\u00E0 {0} viene visualizzata # {1} - (local) type name e.g.: '#foo' is not a valid value for 'NCName' INVALID_XML_ENUM_VALUE = "{0}" non \u00E8 un valore valido per {1}. -FAILED_TO_INITIALE_DATATYPE_FACTORY = Inizializzazione della classe DatatypeFactory di JAXP 1.3 non riuscita. - NO_IMAGE_WRITER = Nessun javax.imageio.ImageWriter disponibile per il tipo MIME specificato "{0}" ILLEGAL_MIME_TYPE = "{0}" non \u00E8 un tipo MIME valido: {1} diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/Messages_ja.properties b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/Messages_ja.properties index e34856a4957..32e8e54ce80 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/Messages_ja.properties +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/Messages_ja.properties @@ -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 @@ -69,8 +69,6 @@ PROPERTY_ORDER_CONTAINS_UNUSED_ENTRY = \u30D7\u30ED\u30D1\u30C6\u30A3{0}\u304C@X # {1} - (local) type name e.g.: '#foo' is not a valid value for 'NCName' INVALID_XML_ENUM_VALUE = "{0}"\u306F{1}\u306B\u5BFE\u3059\u308B\u6709\u52B9\u306A\u5024\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002 -FAILED_TO_INITIALE_DATATYPE_FACTORY = JAXP 1.3 DatatypeFactory\u30AF\u30E9\u30B9\u306E\u521D\u671F\u5316\u306B\u5931\u6557\u3057\u307E\u3057\u305F\u3002 - NO_IMAGE_WRITER = \u6307\u5B9A\u3057\u305FMIME \u30BF\u30A4\u30D7"{0}"\u306B\u4F7F\u7528\u3067\u304D\u308Bjavax.imageio.ImageWriter\u304C\u3042\u308A\u307E\u305B\u3093 ILLEGAL_MIME_TYPE = "{0}"\u306F\u6709\u52B9\u306AMIME\u30BF\u30A4\u30D7\u3067\u306F\u3042\u308A\u307E\u305B\u3093: {1} diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/Messages_ko.properties b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/Messages_ko.properties index f2ee93ca3de..7c799709a5e 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/Messages_ko.properties +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/Messages_ko.properties @@ -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 @@ -69,8 +69,6 @@ PROPERTY_ORDER_CONTAINS_UNUSED_ENTRY = {0} \uC18D\uC131\uC774 @XmlType.propOrder # {1} - (local) type name e.g.: '#foo' is not a valid value for 'NCName' INVALID_XML_ENUM_VALUE = "{0}"\uC740(\uB294) {1}\uC5D0 \uB300\uD574 \uC801\uD569\uD55C \uAC12\uC774 \uC544\uB2D9\uB2C8\uB2E4. -FAILED_TO_INITIALE_DATATYPE_FACTORY = JAXP 1.3 DatatypeFactory \uD074\uB798\uC2A4 \uCD08\uAE30\uD654\uB97C \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4. - NO_IMAGE_WRITER = \uC9C0\uC815\uB41C MIME \uC720\uD615 "{0}"\uC5D0 \uC0AC\uC6A9 \uAC00\uB2A5\uD55C javax.imageio.ImageWriter\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4. ILLEGAL_MIME_TYPE = "{0}"\uC740(\uB294) \uC801\uD569\uD55C MIME \uC720\uD615\uC774 \uC544\uB2D8: {1} diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/Messages_pt_BR.properties b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/Messages_pt_BR.properties index 0692fadc4e9..eca18663ca6 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/Messages_pt_BR.properties +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/Messages_pt_BR.properties @@ -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 @@ -69,8 +69,6 @@ PROPERTY_ORDER_CONTAINS_UNUSED_ENTRY = A propriedade {0} aparece na @XmlType.pro # {1} - (local) type name e.g.: '#foo' is not a valid value for 'NCName' INVALID_XML_ENUM_VALUE = "{0}" n\u00E3o \u00E9 um valor v\u00E1lido para {1}. -FAILED_TO_INITIALE_DATATYPE_FACTORY = Falha ao inicializar a classe DatatypeFactory de JAXP 1.3. - NO_IMAGE_WRITER = Nenhum javax.imageio.ImageWriter dispon\u00EDvel para o tipo MIME "{0}" especificado ILLEGAL_MIME_TYPE = "{0}" n\u00E3o \u00E9 um tipo MIME v\u00E1lido: {1} diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/Messages_zh_CN.properties b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/Messages_zh_CN.properties index 0fef32c9016..487673bcd85 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/Messages_zh_CN.properties +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/Messages_zh_CN.properties @@ -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 @@ -69,8 +69,6 @@ PROPERTY_ORDER_CONTAINS_UNUSED_ENTRY = \u5C5E\u6027{0}\u51FA\u73B0\u5728 @XmlTyp # {1} - (local) type name e.g.: '#foo' is not a valid value for 'NCName' INVALID_XML_ENUM_VALUE = "{0}" \u4E0D\u662F{1}\u7684\u6709\u6548\u503C\u3002 -FAILED_TO_INITIALE_DATATYPE_FACTORY = \u65E0\u6CD5\u521D\u59CB\u5316 JAXP 1.3 DatatypeFactory \u7C7B\u3002 - NO_IMAGE_WRITER = \u6307\u5B9A MIME \u7C7B\u578B "{0}" \u6CA1\u6709\u53EF\u7528\u7684 javax.imageio.ImageWriter ILLEGAL_MIME_TYPE = "{0}" \u4E0D\u662F\u6709\u6548\u7684 MIME \u7C7B\u578B: {1} diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/Messages_zh_TW.properties b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/Messages_zh_TW.properties index 34d8d155433..5526808d060 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/Messages_zh_TW.properties +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/Messages_zh_TW.properties @@ -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 @@ -69,8 +69,6 @@ PROPERTY_ORDER_CONTAINS_UNUSED_ENTRY = \u7279\u6027 {0} \u986F\u793A\u65BC @XmlT # {1} - (local) type name e.g.: '#foo' is not a valid value for 'NCName' INVALID_XML_ENUM_VALUE = "{0}" \u4E0D\u662F {1} \u7684\u6709\u6548\u503C. -FAILED_TO_INITIALE_DATATYPE_FACTORY = \u7121\u6CD5\u8D77\u59CB JAXP 1.3 DatatypeFactory \u985E\u5225. - NO_IMAGE_WRITER = \u6307\u5B9A\u7684 MIME \u985E\u578B "{0}" \u6C92\u6709\u53EF\u7528\u7684 javax.imageio.ImageWriter ILLEGAL_MIME_TYPE = "{0}" \u4E0D\u662F\u6709\u6548\u7684 MIME \u985E\u578B: {1} diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/RuntimeBuiltinLeafInfoImpl.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/RuntimeBuiltinLeafInfoImpl.java index 9447c51048e..76f139df591 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/RuntimeBuiltinLeafInfoImpl.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/RuntimeBuiltinLeafInfoImpl.java @@ -43,6 +43,8 @@ import java.net.MalformedURLException; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; +import java.security.AccessController; +import java.security.PrivilegedAction; import java.util.ArrayList; import java.util.Calendar; import java.util.Collections; @@ -950,7 +952,13 @@ public abstract class RuntimeBuiltinLeafInfoImpl extends BuiltinLeafInfoImpl< m.put(DatatypeConstants.DATETIME, "%Y-%M-%DT%h:%m:%s"+ "%z"); m.put(DatatypeConstants.DATE, "%Y-%M-%D" +"%z"); m.put(DatatypeConstants.TIME, "%h:%m:%s"+ "%z"); - if (System.getProperty(USE_OLD_GMONTH_MAPPING) == null) { + final String oldGmonthMappingProperty = AccessController.doPrivileged(new PrivilegedAction() { + @Override + public String run() { + return System.getProperty(USE_OLD_GMONTH_MAPPING); + } + }); + if (oldGmonthMappingProperty == null) { m.put(DatatypeConstants.GMONTH, "--%M%z"); // E2-12 Error. http://www.w3.org/2001/05/xmlschema-errata#e2-12 } else { // backw. compatibility if (logger.isLoggable(Level.FINE)) { diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/ArrayBeanInfoImpl.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/ArrayBeanInfoImpl.java index a5e4061671e..4cef4ddecc0 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/ArrayBeanInfoImpl.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/ArrayBeanInfoImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, 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 @@ -79,19 +79,19 @@ final class ArrayBeanInfoImpl extends JaxBeanInfo { @Override public void startElement(UnmarshallingContext.State state, TagName ea) { - state.target = new ArrayList(); + state.setTarget(new ArrayList()); } @Override public void leaveElement(UnmarshallingContext.State state, TagName ea) { - state.target = toArray((List)state.target); + state.setTarget(toArray((List)state.getTarget())); } @Override public void childElement(UnmarshallingContext.State state, TagName ea) throws SAXException { if(ea.matches("","item")) { - state.loader = itemLoader; - state.receiver = this; + state.setLoader(itemLoader); + state.setReceiver(this); } else { super.childElement(state,ea); } @@ -103,9 +103,9 @@ final class ArrayBeanInfoImpl extends JaxBeanInfo { } public void receive(UnmarshallingContext.State state, Object o) { - ((List)state.target).add(o); + ((List)state.getTarget()).add(o); } - }; + } protected Object toArray( List list ) { int len = list.size(); diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/ElementBeanInfoImpl.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/ElementBeanInfoImpl.java index 8fbffd76e30..58bcbdf5964 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/ElementBeanInfoImpl.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/ElementBeanInfoImpl.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 @@ -208,8 +208,8 @@ public final class ElementBeanInfoImpl extends JaxBeanInfo { @Override public final void startElement(UnmarshallingContext.State state, TagName ea) throws SAXException { - state.loader = core; - state.intercepter = this; + state.setLoader(core); + state.setIntercepter(this); // TODO: make sure there aren't too many duplicate of this code // create the object to unmarshal @@ -231,21 +231,21 @@ public final class ElementBeanInfoImpl extends JaxBeanInfo { fireBeforeUnmarshal(ElementBeanInfoImpl.this, child, state); context.recordOuterPeer(child); - UnmarshallingContext.State p = state.prev; - p.backup = p.target; - p.target = child; + UnmarshallingContext.State p = state.getPrev(); + p.setBackup(p.getTarget()); + p.setTarget(child); core.startElement(state,ea); } public Object intercept(UnmarshallingContext.State state, Object o) throws SAXException { - JAXBElement e = (JAXBElement)state.target; - state.target = state.backup; - state.backup = null; + JAXBElement e = (JAXBElement)state.getTarget(); + state.setTarget(state.getBackup()); + state.setBackup(null); - if (state.nil) { + if (state.isNil()) { e.setNil(true); - state.nil = false; + state.setNil(false); } if(o!=null) diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/Messages.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/Messages.java index d6b76551dfc..adaa9c8b339 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/Messages.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/Messages.java @@ -58,7 +58,6 @@ enum Messages { FAILED_TO_GENERATE_SCHEMA, // 0 args ERROR_PROCESSING_SCHEMA, // 0 args ILLEGAL_CONTENT, // 2 args - FAILED_TO_INITIALE_DATATYPE_FACTORY, // 2 args ; private static final ResourceBundle rb = ResourceBundle.getBundle(Messages.class.getName()); diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/ValueListBeanInfoImpl.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/ValueListBeanInfoImpl.java index ffd41edbd6b..4ce089736e7 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/ValueListBeanInfoImpl.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/ValueListBeanInfoImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, 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 @@ -90,7 +90,7 @@ final class ValueListBeanInfoImpl extends JaxBeanInfo { idx = p; } - state.target = toArray(r); + state.setTarget(toArray(r)); } }; diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/property/ArrayERProperty.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/property/ArrayERProperty.java index dfc7745d9bb..aaa286ee0d3 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/property/ArrayERProperty.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/property/ArrayERProperty.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, 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 @@ -98,7 +98,7 @@ abstract class ArrayERProperty extends ArrayProperty extends ArrayProperty extends PropertyImpl public void startElement(UnmarshallingContext.State state, TagName ea) throws SAXException { // create or obtain the Map object try { - BeanT target = (BeanT) state.prev.target; + BeanT target = (BeanT) state.getPrev().getTarget(); ValueT mapValue = acc.get(target); if(mapValue == null) mapValue = ClassFactory.create(mapImplClass); @@ -156,11 +156,11 @@ final class SingleMapNodeProperty extends PropertyImpl Stack.push(this.target, target); Stack.push(map, mapValue); - state.target = mapValue; + state.setTarget(mapValue); } catch (AccessorException e) { // recover from error by setting a dummy Map that receives and discards the values handleGenericException(e,true); - state.target = new HashMap(); + state.setTarget(new HashMap()); } } @@ -177,7 +177,7 @@ final class SingleMapNodeProperty extends PropertyImpl @Override public void childElement(UnmarshallingContext.State state, TagName ea) throws SAXException { if(ea.matches(entryTag)) { - state.loader = entryLoader; + state.setLoader(entryLoader); } else { super.childElement(state,ea); } @@ -197,26 +197,26 @@ final class SingleMapNodeProperty extends PropertyImpl private final Loader entryLoader = new Loader(false) { @Override public void startElement(UnmarshallingContext.State state, TagName ea) { - state.target = new Object[2]; // this is inefficient + state.setTarget(new Object[2]); // this is inefficient } @Override public void leaveElement(UnmarshallingContext.State state, TagName ea) { - Object[] keyValue = (Object[])state.target; - Map map = (Map) state.prev.target; + Object[] keyValue = (Object[])state.getTarget(); + Map map = (Map) state.getPrev().getTarget(); map.put(keyValue[0],keyValue[1]); } @Override public void childElement(UnmarshallingContext.State state, TagName ea) throws SAXException { if(ea.matches(keyTag)) { - state.loader = keyLoader; - state.receiver = keyReceiver; + state.setLoader(keyLoader); + state.setReceiver(keyReceiver); return; } if(ea.matches(valueTag)) { - state.loader = valueLoader; - state.receiver = valueReceiver; + state.setLoader(valueLoader); + state.setReceiver(valueReceiver); return; } super.childElement(state,ea); @@ -234,7 +234,7 @@ final class SingleMapNodeProperty extends PropertyImpl this.index = index; } public void receive(UnmarshallingContext.State state, Object o) { - ((Object[])state.target)[index] = o; + ((Object[])state.getTarget())[index] = o; } } diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/Accessor.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/Accessor.java index 623a3fea43b..7923cab28d7 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/Accessor.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/Accessor.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 @@ -148,7 +148,7 @@ public abstract class Accessor implements Receiver { public void receive(UnmarshallingContext.State state, Object o) throws SAXException { try { - set((BeanT) state.target, (ValueT) o); + set((BeanT) state.getTarget(), (ValueT) o); } catch (AccessorException e) { Loader.handleGenericException(e, true); } catch (IllegalAccessError iae) { diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/DefaultValueLoaderDecorator.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/DefaultValueLoaderDecorator.java index 194ca4366db..bfa62502dcf 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/DefaultValueLoaderDecorator.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/DefaultValueLoaderDecorator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, 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 @@ -44,10 +44,10 @@ public final class DefaultValueLoaderDecorator extends Loader { @Override public void startElement(UnmarshallingContext.State state, TagName ea) throws SAXException { // install the default value, but don't override the one given by the parent loader - if(state.elementDefaultValue==null) - state.elementDefaultValue = defaultValue; + if(state.getElementDefaultValue() == null) + state.setElementDefaultValue(defaultValue); - state.loader = l; + state.setLoader(l); l.startElement(state,ea); } } diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/Discarder.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/Discarder.java index 5720782ac39..931bec71636 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/Discarder.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/Discarder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, 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 @@ -44,8 +44,8 @@ public final class Discarder extends Loader { @Override public void childElement(UnmarshallingContext.State state, TagName ea) { - state.target = null; + state.setTarget(null); // registering this allows the discarder to process the whole subtree. - state.loader = this; + state.setLoader(this); } } diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/DomLoader.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/DomLoader.java index 26b97cc10c1..30c8d755f9e 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/DomLoader.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/DomLoader.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 @@ -99,10 +99,10 @@ public class DomLoader extends Loader { @Override public void startElement(UnmarshallingContext.State state, TagName ea) throws SAXException { UnmarshallingContext context = state.getContext(); - if (state.target == null) - state.target = new State(context); + if (state.getTarget() == null) + state.setTarget(new State(context)); - State s = (State) state.target; + State s = (State) state.getTarget(); try { s.declarePrefixes(context, context.getNewlyDeclaredPrefixes()); s.handler.startElement(ea.uri, ea.local, ea.getQname(), ea.atts); @@ -114,10 +114,10 @@ public class DomLoader extends Loader { @Override public void childElement(UnmarshallingContext.State state, TagName ea) throws SAXException { - state.loader = this; - State s = (State) state.prev.target; + state.setLoader(this); + State s = (State) state.getPrev().getTarget(); s.depth++; - state.target = s; + state.setTarget(s); } @Override @@ -125,7 +125,7 @@ public class DomLoader extends Loader { if(text.length()==0) return; // there's no point in creating an empty Text node in DOM. try { - State s = (State) state.target; + State s = (State) state.getTarget(); s.handler.characters(text.toString().toCharArray(),0,text.length()); } catch( SAXException e ) { state.getContext().handleError(e); @@ -135,7 +135,7 @@ public class DomLoader extends Loader { @Override public void leaveElement(UnmarshallingContext.State state, TagName ea) throws SAXException { - State s = (State) state.target; + State s = (State) state.getTarget(); UnmarshallingContext context = state.getContext(); try { @@ -157,7 +157,7 @@ public class DomLoader extends Loader { } // we are done - state.target = s.getElement(); + state.setTarget(s.getElement()); } } diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/LeafPropertyLoader.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/LeafPropertyLoader.java index 1b36b154723..300f5f336b1 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/LeafPropertyLoader.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/LeafPropertyLoader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, 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 @@ public class LeafPropertyLoader extends Loader { public void text(UnmarshallingContext.State state, CharSequence text) throws SAXException { try { - xacc.parse(state.prev.target,text); + xacc.parse(state.getPrev().getTarget(), text); } catch (AccessorException e) { handleGenericException(e,true); } catch (RuntimeException e) { diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/LeafPropertyXsiLoader.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/LeafPropertyXsiLoader.java index 1dc632ff807..5c13bf341fc 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/LeafPropertyXsiLoader.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/LeafPropertyXsiLoader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, 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 @@ -55,9 +55,9 @@ public final class LeafPropertyXsiLoader extends Loader { @Override public void startElement(UnmarshallingContext.State state, TagName ea) throws SAXException { - state.loader = selectLoader(state, ea); - - state.loader.startElement(state, ea); + final Loader loader = selectLoader(state, ea); + state.setLoader(loader); + loader.startElement(state, ea); } protected Loader selectLoader(UnmarshallingContext.State state, TagName ea) throws SAXException { diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/Loader.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/Loader.java index dfb8639e947..f3d6c8599a1 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/Loader.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/Loader.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 @@ -88,8 +88,8 @@ public abstract class Loader { public void childElement(UnmarshallingContext.State state, TagName ea) throws SAXException { // notify the error, then recover by ignoring the whole element. reportUnexpectedChildElement(ea, true); - state.loader = Discarder.INSTANCE; - state.receiver = null; + state.setLoader(Discarder.INSTANCE); + state.setReceiver(null); } @SuppressWarnings({"StringEquality"}) @@ -195,10 +195,10 @@ public abstract class Loader { UnmarshallingContext context = state.getContext(); Unmarshaller.Listener listener = context.parent.getListener(); if(beanInfo.hasBeforeUnmarshalMethod()) { - beanInfo.invokeBeforeUnmarshalMethod(context.parent, child, state.prev.target); + beanInfo.invokeBeforeUnmarshalMethod(context.parent, child, state.getPrev().getTarget()); } if(listener!=null) { - listener.beforeUnmarshal(child, state.prev.target); + listener.beforeUnmarshal(child, state.getPrev().getTarget()); } } } @@ -215,10 +215,10 @@ public abstract class Loader { UnmarshallingContext context = state.getContext(); Unmarshaller.Listener listener = context.parent.getListener(); if(beanInfo.hasAfterUnmarshalMethod()) { - beanInfo.invokeAfterUnmarshalMethod(context.parent, child, state.target); + beanInfo.invokeAfterUnmarshalMethod(context.parent, child, state.getTarget()); } if(listener!=null) - listener.afterUnmarshal(child, state.target); + listener.afterUnmarshal(child, state.getTarget()); } } diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/ProxyLoader.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/ProxyLoader.java index b61f61890e9..67adf61e7e5 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/ProxyLoader.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/ProxyLoader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, 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 @@ -41,7 +41,7 @@ public abstract class ProxyLoader extends Loader { @Override public final void startElement(UnmarshallingContext.State state, TagName ea) throws SAXException { Loader loader = selectLoader(state,ea); - state.loader = loader; + state.setLoader(loader); loader.startElement(state,ea); } diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/SAXConnector.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/SAXConnector.java index 44998166542..a7e9abc694a 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/SAXConnector.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/SAXConnector.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 @@ -144,17 +144,7 @@ public final class SAXConnector implements UnmarshallerHandler { if( qname==null || qname.length()==0 ) qname=local; - - boolean ignorable = true; - StructureLoader sl; - - // not null only if element content is processed (StructureLoader is used) - // ugly - if((sl = this.context.getStructureLoader()) != null) { - ignorable = ((ClassBeanInfoImpl)sl.getBeanInfo()).hasElementOnlyContentModel(); - } - - processText(ignorable); + processText(!context.getCurrentState().isMixed()); tagName.uri = uri; tagName.local = local; @@ -204,7 +194,7 @@ public final class SAXConnector implements UnmarshallerHandler { } private void processText( boolean ignorable ) throws SAXException { - if( predictor.expectText() && (!ignorable || !WhiteSpaceProcessor.isWhiteSpace(buffer))) + if (predictor.expectText() && (!ignorable || !WhiteSpaceProcessor.isWhiteSpace(buffer))) next.text(buffer); buffer.setLength(0); } diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/Scope.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/Scope.java index 12afd120c4a..bfd98e9b8d0 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/Scope.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/Scope.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, 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 @@ -97,7 +97,7 @@ public final class Scope { public void add( Accessor acc, Lister lister, ItemT value) throws SAXException{ try { if(!hasStarted()) { - this.bean = (BeanT)context.getCurrentState().target; + this.bean = (BeanT)context.getCurrentState().getTarget(); this.acc = acc; this.lister = lister; this.pack = lister.startPacking(bean,acc); @@ -121,7 +121,7 @@ public final class Scope { public void start( Accessor acc, Lister lister) throws SAXException{ try { if(!hasStarted()) { - this.bean = (BeanT)context.getCurrentState().target; + this.bean = (BeanT)context.getCurrentState().getTarget(); this.acc = acc; this.lister = lister; this.pack = lister.startPacking(bean,acc); diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/StructureLoader.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/StructureLoader.java index 694e7275b12..0d4fa2647db 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/StructureLoader.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/StructureLoader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, 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 @@ -172,7 +172,7 @@ public final class StructureLoader extends Loader { context.recordInnerPeer(child); - state.target = child; + state.setTarget(child); fireBeforeUnmarshal(beanInfo, child, state); @@ -197,7 +197,7 @@ public final class StructureLoader extends Loader { String qname = atts.getQName(i); if(atts.getURI(i).equals(WellKnownNamespace.XML_SCHEMA_INSTANCE)) continue; // xsi:* attributes are meant to be processed by us, not by user apps. - Object o = state.target; + Object o = state.getTarget(); Map map = attCatchAll.get(o); if(map==null) { // TODO: use ClassFactory.inferImplClass(sig,knownImplClasses) @@ -250,8 +250,8 @@ public final class StructureLoader extends Loader { } } - state.loader = child.loader; - state.receiver = child.receiver; + state.setLoader(child.loader); + state.setReceiver(child.receiver); } @Override @@ -273,7 +273,7 @@ public final class StructureLoader extends Loader { @Override public void leaveElement(UnmarshallingContext.State state, TagName ea) throws SAXException { state.getContext().endScope(frameSize); - fireAfterUnmarshal(beanInfo, state.target, state.prev); + fireAfterUnmarshal(beanInfo, state.getTarget(), state.getPrev()); } private static final QNameMap EMPTY = new QNameMap(); diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/TextLoader.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/TextLoader.java index 9a81412997a..a482ae6afb9 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/TextLoader.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/TextLoader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, 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 @@ -51,7 +51,7 @@ public class TextLoader extends Loader { public void text(UnmarshallingContext.State state, CharSequence text) throws SAXException { try { - state.target = xducer.parse(text); + state.setTarget(xducer.parse(text)); } catch (AccessorException e) { handleGenericException(e,true); } catch (RuntimeException e) { diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/UnmarshallingContext.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/UnmarshallingContext.java index 35519196193..cfd16e60340 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/UnmarshallingContext.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/UnmarshallingContext.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 @@ -198,20 +198,19 @@ public final class UnmarshallingContext extends Coordinator /** * Loader that owns this element. */ - public Loader loader; + private Loader loader; /** * Once {@link #loader} is completed, this receiver * receives the result. */ - public Receiver receiver; - - public Intercepter intercepter; + private Receiver receiver; + private Intercepter intercepter; /** * Object being unmarshalled by this {@link #loader}. */ - public Object target; + private Object target; /** * Hack for making JAXBElement unmarshalling work. @@ -240,7 +239,7 @@ public final class UnmarshallingContext extends Coordinator * @see ElementBeanInfoImpl.IntercepterLoader#startElement(State, TagName) * @see ElementBeanInfoImpl.IntercepterLoader#intercept(State, Object) */ - public Object backup; + private Object backup; /** * Number of {@link UnmarshallingContext#nsBind}s declared thus far. @@ -256,17 +255,22 @@ public final class UnmarshallingContext extends Coordinator * or by a child {@link Loader} when * {@link Loader#startElement(State, TagName)} is called. */ - public String elementDefaultValue; + private String elementDefaultValue; /** * {@link State} for the parent element * * {@link State} objects form a doubly linked list. */ - public State prev; + private State prev; private State next; - public boolean nil = false; + private boolean nil = false; + + /** + * specifies that we are working with mixed content + */ + private boolean mixed = false; /** * Gets the context. @@ -280,6 +284,8 @@ public final class UnmarshallingContext extends Coordinator this.prev = prev; if (prev!=null) { prev.next = this; + if (prev.mixed) // parent is in mixed mode + this.mixed = true; } } @@ -289,7 +295,7 @@ public final class UnmarshallingContext extends Coordinator } if (next==null) { assert current == this; - allocateMoreStates(); + next = new State(this); } nil = false; State n = next; @@ -304,11 +310,71 @@ public final class UnmarshallingContext extends Coordinator assert prev!=null; loader = null; nil = false; + mixed = false; receiver = null; intercepter = null; elementDefaultValue = null; target = null; current = prev; + next = null; + } + + public boolean isMixed() { + return mixed; + } + + public Object getTarget() { + return target; + } + + public void setLoader(Loader loader) { + if (loader instanceof StructureLoader) // set mixed mode + mixed = !((StructureLoader)loader).getBeanInfo().hasElementOnlyContentModel(); + this.loader = loader; + } + + public void setReceiver(Receiver receiver) { + this.receiver = receiver; + } + + public State getPrev() { + return prev; + } + + public void setIntercepter(Intercepter intercepter) { + this.intercepter = intercepter; + } + + public void setBackup(Object backup) { + this.backup = backup; + } + + public void setTarget(Object target) { + this.target = target; + } + + public Object getBackup() { + return backup; + } + + public boolean isNil() { + return nil; + } + + public void setNil(boolean nil) { + this.nil = nil; + } + + public Loader getLoader() { + return loader; + } + + public String getElementDefaultValue() { + return elementDefaultValue; + } + + public void setElementDefaultValue(String elementDefaultValue) { + this.elementDefaultValue = elementDefaultValue; } } @@ -348,7 +414,6 @@ public final class UnmarshallingContext extends Coordinator this.parent = _parent; this.assoc = assoc; this.root = this.current = new State(null); - allocateMoreStates(); } public void reset(InfosetScanner scanner,boolean isInplaceMode, JaxBeanInfo expectedType, IDResolver idResolver) { @@ -395,23 +460,6 @@ public final class UnmarshallingContext extends Coordinator return null; } - /** - * Allocates a few more {@link State}s. - * - * Allocating multiple {@link State}s at once allows those objects - * to be allocated near each other, which reduces the working set - * of CPU. It improves the chance the relevant data is in the cache. - */ - private void allocateMoreStates() { - // this method should be used only when we run out of a state. - assert current.next==null; - - State s = current; - for (int i=0; i<8; i++) { - s = new State(s); - } - } - public void clearStates() { State last = current; while (last.next != null) last = last.next; @@ -515,16 +563,15 @@ public final class UnmarshallingContext extends Coordinator @Override public void text(CharSequence pcdata) throws SAXException { - State cur = current; pushCoordinator(); try { - if(cur.elementDefaultValue!=null) { - if(pcdata.length()==0) { + if (current.elementDefaultValue != null) { + if (pcdata.length() == 0) { // send the default value into the unmarshaller instead - pcdata = cur.elementDefaultValue; + pcdata = current.elementDefaultValue; } } - cur.loader.text(cur,pcdata); + current.loader.text(current, pcdata); } finally { popCoordinator(); } diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/ValuePropertyLoader.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/ValuePropertyLoader.java index af152fa50e3..1bc81f0dff1 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/ValuePropertyLoader.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/ValuePropertyLoader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, 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 @@ -49,18 +49,17 @@ public class ValuePropertyLoader extends Loader { public void text(UnmarshallingContext.State state, CharSequence text) throws SAXException { try { - xacc.parse(state.target,text); + xacc.parse(state.getTarget(),text); } catch (AccessorException e) { handleGenericException(e,true); } catch (RuntimeException e) { - if(state.prev != null) { - if(state.prev.target instanceof JAXBElement) { - ; // do nothing - issue 601 - don't report exceptions like - // NumberFormatException when unmarshalling "nillable" element - // (I suppose JAXBElement indicates this - } else { + if(state.getPrev() != null) { + if (!(state.getPrev().getTarget() instanceof JAXBElement)) handleParseConversionException(state,e); - } + // else + // do nothing - issue 601 - don't report exceptions like + // NumberFormatException when unmarshalling "nillable" element + // (I suppose JAXBElement indicates this } else { handleParseConversionException(state,e); } diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/XsiNilLoader.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/XsiNilLoader.java index 5dbababbee8..c01acf3481a 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/XsiNilLoader.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/XsiNilLoader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, 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 @@ -62,7 +62,7 @@ public class XsiNilLoader extends ProxyLoader { onNil(state); boolean hasOtherAttributes = (ea.atts.getLength() - 1) > 0; // see issues 6759703 and 565 - need to preserve attributes even if the element is nil; only when the type is stored in JAXBElement - if (!(hasOtherAttributes && (state.prev.target instanceof JAXBElement))) { + if (!(hasOtherAttributes && (state.getPrev().getTarget() instanceof JAXBElement))) { return Discarder.INSTANCE; } } @@ -96,8 +96,8 @@ public class XsiNilLoader extends ProxyLoader { @Override protected void onNil(UnmarshallingContext.State state) throws SAXException { try { - acc.set(state.prev.target,null); - state.prev.nil = true; + acc.set(state.getPrev().getTarget(),null); + state.getPrev().setNil(true); } catch (AccessorException e) { handleGenericException(e,true); } @@ -113,7 +113,7 @@ public class XsiNilLoader extends ProxyLoader { @Override protected void onNil(UnmarshallingContext.State state) { // let the receiver add this to the lister - state.target = null; + state.setTarget(null); } } } diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/XsiTypeLoader.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/XsiTypeLoader.java index ab03b5cc053..654f1940ff7 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/XsiTypeLoader.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/XsiTypeLoader.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 @@ -61,7 +61,7 @@ public class XsiTypeLoader extends Loader { beanInfo = defaultBeanInfo; Loader loader = beanInfo.getLoader(null,false); - state.loader = loader; + state.setLoader(loader); loader.startElement(state,ea); } diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/AttachmentPartImpl.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/AttachmentPartImpl.java index ead4533885d..ada4a7de7be 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/AttachmentPartImpl.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/AttachmentPartImpl.java @@ -358,7 +358,7 @@ public class AttachmentPartImpl extends AttachmentPart { bos.close(); try { if (decoded != null) - decoded.close(); + decoded.close(); } catch (IOException ex) { throw new SOAPException(ex); } @@ -582,8 +582,7 @@ public class AttachmentPartImpl extends AttachmentPart { mailMap.addMailcap("text/xml;;x-java-content-handler=com.sun.xml.internal.messaging.saaj.soap.XmlDataContentHandler"); mailMap.addMailcap("application/xml;;x-java-content-handler=com.sun.xml.internal.messaging.saaj.soap.XmlDataContentHandler"); mailMap.addMailcap("application/fastinfoset;;x-java-content-handler=com.sun.xml.internal.messaging.saaj.soap.FastInfosetDataContentHandler"); - // this handler seems to be not used according VCS history ... - // mailMap.addMailcap("multipart/*;;x-java-content-handler=com.sun.xml.internal.messaging.saaj.soap.MultipartDataContentHandler"); + //mailMap.addMailcap("multipart/*;;x-java-content-handler=com.sun.xml.internal.messaging.saaj.soap.MultipartDataContentHandler"); mailMap.addMailcap("image/*;;x-java-content-handler=com.sun.xml.internal.messaging.saaj.soap.ImageDataContentHandler"); mailMap.addMailcap("text/plain;;x-java-content-handler=com.sun.xml.internal.messaging.saaj.soap.StringDataContentHandler"); } diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/EnvelopeFactory.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/EnvelopeFactory.java index 58d14861e40..6663b36b109 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/EnvelopeFactory.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/EnvelopeFactory.java @@ -25,6 +25,7 @@ package com.sun.xml.internal.messaging.saaj.soap; +import com.sun.xml.internal.messaging.saaj.LazyEnvelopeSource; import com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl; import com.sun.xml.internal.messaging.saaj.util.JAXMStreamSource; import com.sun.xml.internal.messaging.saaj.util.LogDomainConstants; @@ -45,10 +46,6 @@ import javax.xml.transform.dom.DOMResult; import javax.xml.transform.sax.SAXSource; import javax.xml.transform.stax.StAXSource; import javax.xml.transform.stream.StreamSource; - -import com.sun.xml.internal.messaging.saaj.LazyEnvelopeSource; -import com.sun.xml.internal.messaging.saaj.util.transform.EfficientStreamingTransformer; - import java.util.logging.Logger; /** @@ -58,8 +55,8 @@ import java.util.logging.Logger; public class EnvelopeFactory { protected static final Logger - log = Logger.getLogger(LogDomainConstants.SOAP_DOMAIN, - "com.sun.xml.internal.messaging.saaj.soap.LocalStrings"); + log = Logger.getLogger(LogDomainConstants.SOAP_DOMAIN, + "com.sun.xml.internal.messaging.saaj.soap.LocalStrings"); private static ContextClassloaderLocal parserPool = new ContextClassloaderLocal() { @@ -72,16 +69,16 @@ public class EnvelopeFactory { public static Envelope createEnvelope(Source src, SOAPPartImpl soapPart) throws SOAPException { - if (src instanceof JAXMStreamSource) { - try { - if (!SOAPPartImpl.lazyContentLength) { - ((JAXMStreamSource) src).reset(); + if (src instanceof JAXMStreamSource) { + try { + if (!SOAPPartImpl.lazyContentLength) { + ((JAXMStreamSource) src).reset(); + } + } catch (java.io.IOException ioe) { + log.severe("SAAJ0515.source.reset.exception"); + throw new SOAPExceptionImpl(ioe); } - } catch (java.io.IOException ioe) { - log.severe("SAAJ0515.source.reset.exception"); - throw new SOAPExceptionImpl(ioe); } - } if (src instanceof LazyEnvelopeSource) { return lazy((LazyEnvelopeSource)src, soapPart); } @@ -93,7 +90,7 @@ public class EnvelopeFactory { } private static Envelope lazy(LazyEnvelopeSource src, SOAPPartImpl soapPart) throws SOAPException { - try { + try { StaxBridge staxBridge = new StaxLazySourceBridge(src, soapPart); staxBridge.bridgeEnvelopeAndHeaders(); Envelope env = (Envelope) soapPart.getEnvelope(); @@ -144,11 +141,11 @@ public class EnvelopeFactory { } catch (Exception e) { log.severe("SAAJ0601.util.newSAXParser.exception"); throw new SOAPExceptionImpl( - "Couldn't get a SAX parser while constructing a envelope", - e); + "Couldn't get a SAX parser while constructing a envelope", + e); } InputSource is = SAXSource.sourceToInputSource(src); - if (is.getEncoding() == null && soapPart.getSourceCharsetEncoding() != null) { + if (is.getEncoding()== null && soapPart.getSourceCharsetEncoding() != null) { is.setEncoding(soapPart.getSourceCharsetEncoding()); } XMLReader rejectFilter; @@ -157,15 +154,15 @@ public class EnvelopeFactory { } catch (Exception ex) { log.severe("SAAJ0510.soap.cannot.create.envelope"); throw new SOAPExceptionImpl( - "Unable to create envelope from given source: ", - ex); + "Unable to create envelope from given source: ", + ex); } src = new SAXSource(rejectFilter, is); } try { Transformer transformer = - EfficientStreamingTransformer.newTransformer(); + EfficientStreamingTransformer.newTransformer(); DOMResult result = new DOMResult(soapPart); transformer.transform(src, result); @@ -177,8 +174,8 @@ public class EnvelopeFactory { } log.severe("SAAJ0511.soap.cannot.create.envelope"); throw new SOAPExceptionImpl( - "Unable to create envelope from given source: ", - ex); + "Unable to create envelope from given source: ", + ex); } finally { if (saxParser != null) { parserPool.get().returnParser(saxParser); diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/util/stax/SaajStaxWriter.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/util/stax/SaajStaxWriter.java index 7deaf4417a4..acfedab8ac4 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/util/stax/SaajStaxWriter.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/util/stax/SaajStaxWriter.java @@ -55,8 +55,6 @@ public class SaajStaxWriter implements XMLStreamWriter { static final protected String Body = "Body"; static final protected String xmlns = "xmlns"; - private boolean isHeaderSeen = false; - public SaajStaxWriter(final SOAPMessage msg, String uri) throws SOAPException { soap = msg; this.envURI = uri; @@ -93,7 +91,6 @@ public class SaajStaxWriter implements XMLStreamWriter { fixPrefix(prefix); return; } else if (Header.equals(ln)) { - isHeaderSeen = true; currentElement = soap.getSOAPHeader(); fixPrefix(prefix); return; @@ -144,21 +141,6 @@ public class SaajStaxWriter implements XMLStreamWriter { @Override public void writeEndDocument() throws XMLStreamException { - try { - if (!isHeaderSeen) { - SOAPElement header = soap.getSOAPHeader(); - if (header != null) { - String prefixAtHeader = header.getPrefix(); - SOAPElement env = getEnvelope(); - header.detachNode(); - if (prefixAtHeader != null && !prefixAtHeader.equals(env.getPrefix())) { - env.removeNamespaceDeclaration(prefixAtHeader); - } - } - } - } catch (SOAPException e) { - throw new XMLStreamException(e); - } } @Override diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/api/message/Packet.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/api/message/Packet.java index 1bc4ca6b974..34c905ebfde 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/api/message/Packet.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/api/message/Packet.java @@ -1388,7 +1388,12 @@ public final class Packet public ContentType getInternalContentType() { Message msg = getInternalMessage(); if (msg instanceof MessageWritable) { - return ((MessageWritable)msg).getContentType(); + MessageWritable mw = (MessageWritable) msg; + + //bug 18121499 fix + mw.setMTOMConfiguration(mtomFeature); + + return mw.getContentType(); } return contentType; } diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/api/message/saaj/SaajStaxWriter.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/api/message/saaj/SaajStaxWriter.java index 886d4d22822..9b743e20c59 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/api/message/saaj/SaajStaxWriter.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/api/message/saaj/SaajStaxWriter.java @@ -55,8 +55,6 @@ public class SaajStaxWriter implements XMLStreamWriter { static final protected String Body = "Body"; static final protected String xmlns = "xmlns"; - private boolean isHeaderSeen = false; - public SaajStaxWriter(final SOAPMessage msg, String uri) throws SOAPException { soap = msg; this.envURI = uri; @@ -93,7 +91,6 @@ public class SaajStaxWriter implements XMLStreamWriter { fixPrefix(prefix); return; } else if (Header.equals(ln)) { - isHeaderSeen = true; currentElement = soap.getSOAPHeader(); fixPrefix(prefix); return; @@ -144,21 +141,6 @@ public class SaajStaxWriter implements XMLStreamWriter { @Override public void writeEndDocument() throws XMLStreamException { - try { - if (!isHeaderSeen) { - SOAPElement header = soap.getSOAPHeader(); - if (header != null) { - String prefixAtHeader = header.getPrefix(); - SOAPElement env = getEnvelope(); - header.detachNode(); - if (prefixAtHeader != null && !prefixAtHeader.equals(env.getPrefix())) { - env.removeNamespaceDeclaration(prefixAtHeader); - } - } - } - } catch (SOAPException e) { - throw new XMLStreamException(e); - } } @Override diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/binding/WebServiceFeatureList.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/binding/WebServiceFeatureList.java index 32bf6832777..5676c478272 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/binding/WebServiceFeatureList.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/binding/WebServiceFeatureList.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 @@ -58,6 +58,7 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Constructor; import java.util.*; +import java.util.logging.Level; import java.util.logging.Logger; /** @@ -272,7 +273,7 @@ public final class WebServiceFeatureList extends AbstractMap 0) { payloadIndex = 0; payloadReader = children[payloadIndex]; diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/WebServiceRef.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/WebServiceRef.java index c43bdfe32da..fe01112906c 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/WebServiceRef.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/WebServiceRef.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2012, 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 @@ -123,7 +123,7 @@ public @interface WebServiceRef { String mappedName() default ""; /** - * The service class, alwiays a type extending + * The service class, always a type extending * javax.xml.ws.Service. This element MUST be specified * whenever the type of the reference is a service endpoint interface. */ diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/spi/Provider.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/spi/Provider.java index ffe77639097..f881048ed20 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/spi/Provider.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/spi/Provider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2012, 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 @@ -29,7 +29,7 @@ import java.net.URL; import java.util.List; import java.util.Iterator; import java.util.Map; -import java.lang.reflect.Method; +import java.util.ServiceLoader; import javax.xml.namespace.QName; import javax.xml.ws.*; import javax.xml.ws.wsaddressing.W3CEndpointReference; @@ -50,8 +50,7 @@ public abstract class Provider { * name of a Provider implementation * class. */ - static public final String JAXWSPROVIDER_PROPERTY - = "javax.xml.ws.spi.Provider"; + static public final String JAXWSPROVIDER_PROPERTY = "javax.xml.ws.spi.Provider"; /** * A constant representing the name of the default @@ -61,29 +60,6 @@ public abstract class Provider { static final String DEFAULT_JAXWSPROVIDER = "com.sun"+".xml.internal.ws.spi.ProviderImpl"; - /** - * Take advantage of Java SE 6's java.util.ServiceLoader API. - * Using reflection so that there is no compile-time dependency on SE 6. - */ - static private final Method loadMethod; - static private final Method iteratorMethod; - static { - Method tLoadMethod = null; - Method tIteratorMethod = null; - try { - Class clazz = Class.forName("java.util.ServiceLoader"); - tLoadMethod = clazz.getMethod("load", Class.class); - tIteratorMethod = clazz.getMethod("iterator"); - } catch(ClassNotFoundException ce) { - // Running on Java SE 5 - } catch(NoSuchMethodException ne) { - // Shouldn't happen - } - loadMethod = tLoadMethod; - iteratorMethod = tIteratorMethod; - } - - /** * Creates a new instance of Provider */ @@ -146,25 +122,16 @@ public abstract class Provider { } } - private static Provider getProviderUsingServiceLoader() { - if (loadMethod != null) { - Object loader; - try { - loader = loadMethod.invoke(null, Provider.class); - } catch (Exception e) { - throw new WebServiceException("Cannot invoke java.util.ServiceLoader#load()", e); - } - - Iterator it; - try { - it = (Iterator)iteratorMethod.invoke(loader); - } catch(Exception e) { - throw new WebServiceException("Cannot invoke java.util.ServiceLoader#iterator()", e); - } - return it.hasNext() ? it.next() : null; + ServiceLoader sl; + Iterator it; + try { + sl = ServiceLoader.load(Provider.class); + it = (Iterator)sl.iterator(); + } catch (Exception e) { + throw new WebServiceException("Cannot invoke java.util.ServiceLoader#iterator()", e); } - return null; + return ((it != null) && it.hasNext()) ? it.next() : null; } /** diff --git a/jdk/.hgtags b/jdk/.hgtags index 6f8633b7e61..bfebe8ade06 100644 --- a/jdk/.hgtags +++ b/jdk/.hgtags @@ -261,3 +261,7 @@ c7c8002d02721e02131d104549ebeb8b379fb8d2 jdk9-b13 ab7d2c565b0de5bee1361d282d4029371327fc9e jdk9-b16 fd8e675f141b9bdb2f46d1ae8251f4ee3a895d64 jdk9-b17 6ad17b31f0d30593392b1e8695b9709dbbd7fb70 jdk9-b18 +27561aede285c25a3e9ed8bf8918234ad3bb81e3 jdk9-b19 +f87c5be90e01a7ffb47947108eb3e0b0b1920880 jdk9-b20 +2df45ac1bf491278f38c12e0dfbeebadb6c54c8c jdk9-b21 +85bcf0f99edc08873614afbe5a5563e13ce13c83 jdk9-b22 diff --git a/jdk/THIRD_PARTY_README b/jdk/THIRD_PARTY_README index a93b35b994c..767609febcb 100644 --- a/jdk/THIRD_PARTY_README +++ b/jdk/THIRD_PARTY_README @@ -1471,7 +1471,7 @@ source code repository. It is licensed under Mozilla Public License (MPL), version 2.0. The NSS libraries are supplied in executable form, built from unmodified -NSS source code labeled with the "NSS_3.13.1_RTM" release tag. +NSS source code labeled with the "NSS_3_16_RTM" HG tag. The NSS source code is available in the OpenJDK source code repository at: jdk/test/sun/security/pkcs11/nss/src diff --git a/jdk/make/CompileDemos.gmk b/jdk/make/CompileDemos.gmk index 6f80d632c49..2cdf72211e0 100644 --- a/jdk/make/CompileDemos.gmk +++ b/jdk/make/CompileDemos.gmk @@ -1,6 +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 @@ -320,7 +319,6 @@ ifeq ($(OPENJDK_TARGET_OS), aix) endif $(eval $(call SetupJVMTIDemo,hprof, java_crw_demo, \ - -I$(JDK_TOPDIR)/src/share/npt -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/npt \ $(BUILD_LIBHPROF_AIX_EXTRA_CFLAGS), C, \ -ldl, ws2_32.lib winmm.lib, -lsocket -lnsl, -lpthread, $(BUILD_LIBHPROF_AIX_EXTRA_SRC))) diff --git a/jdk/make/CopyFiles.gmk b/jdk/make/CopyFiles.gmk index c1fa0d4062b..acab2541256 100644 --- a/jdk/make/CopyFiles.gmk +++ b/jdk/make/CopyFiles.gmk @@ -373,7 +373,14 @@ ifeq ($(OPENJDK_TARGET_OS), windows) POLICY_SRC_LIST += $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS)/lib/security/java.policy endif ifndef OPENJDK - ifneq (, $(filter $(OPENJDK_TARGET_OS), windows solaris)) + ifeq ($(OPENJDK_TARGET_OS), windows) + ifeq ($(OPENJDK_TARGET_CPU_BITS), 32) + POLICY_SRC_LIST += $(JDK_TOPDIR)/src/closed/$(OPENJDK_TARGET_OS)/lib/security/java.policy-win32 + else + POLICY_SRC_LIST += $(JDK_TOPDIR)/src/closed/$(OPENJDK_TARGET_OS)/lib/security/java.policy-win64 + endif + endif + ifeq ($(OPENJDK_TARGET_OS), solaris) POLICY_SRC_LIST += $(JDK_TOPDIR)/src/closed/$(OPENJDK_TARGET_OS)/lib/security/java.policy endif endif @@ -400,16 +407,11 @@ COPY_FILES += $(CACERTS_DST) ########################################################################################## -BLACKLISTED_CERTS_SRC := $(JDK_TOPDIR)/src/share/lib/security/blacklisted.certs -BLACKLISTED_CERTS_DST := $(JDK_OUTPUTDIR)/lib/security/blacklisted.certs - ifndef OPENJDK BLACKLIST_SRC := $(JDK_TOPDIR)/src/closed/share/lib/security/blacklist BLACKLIST_DST := $(JDK_OUTPUTDIR)/lib/security/blacklist - BLACKLISTED_CERTS_SRC += $(wildcard $(JDK_TOPDIR)/src/closed/share/lib/security/blacklisted.certs) - TRUSTEDLIBS_SRC := $(JDK_TOPDIR)/src/closed/share/lib/security/trusted.libraries TRUSTEDLIBS_DST := $(JDK_OUTPUTDIR)/lib/security/trusted.libraries @@ -425,20 +427,6 @@ ifndef OPENJDK endif -$(BLACKLISTED_CERTS_DST): $(BLACKLISTED_CERTS_SRC) - $(MKDIR) -p $(@D) - $(CAT) $^ | $(SED) '/^$$/d' | $(SORT) | $(UNIQ) > $@.tmp - $(GREP) -i Algorithm $@.tmp > $@ - if [ `$(SED) -n -e "$$=" $@` != 1 ]; then \ - $(ECHO) "Different algorithms defined in $^"; \ - $(RM) $@ $@.tmp; \ - false; \ - fi - $(GREP) -iv Algorithm $@.tmp >> $@ - $(RM) $@.tmp - -COPY_FILES += $(BLACKLISTED_CERTS_DST) - ########################################################################################## ifndef OPENJDK diff --git a/jdk/make/CreateJars.gmk b/jdk/make/CreateJars.gmk index 9d79394539c..f1c5178d7c8 100644 --- a/jdk/make/CreateJars.gmk +++ b/jdk/make/CreateJars.gmk @@ -676,15 +676,6 @@ endif ########################################################################################## -# -# This is an empty jar (only contains manifest) and fits poorly into framework... -# create simple rule instead -# -$(IMAGES_OUTPUTDIR)/lib/management-agent.jar: $(JDK_TOPDIR)/src/share/classes/sun/management/manifest - $(JAR) cfm $@ $< - -########################################################################################## - # This file is imported from hotspot in Import.gmk. Copying it into images/lib so that # all jars can be found in one place when creating images in Images.gmk. It needs to be # done here so that clean targets can be simple and accurate. diff --git a/jdk/make/GenerateData.gmk b/jdk/make/GenerateData.gmk index 28faec4826a..8228f917800 100644 --- a/jdk/make/GenerateData.gmk +++ b/jdk/make/GenerateData.gmk @@ -50,6 +50,9 @@ GENDATA += $(GENDATA_TZDB) include gendata/GendataHtml32dtd.gmk GENDATA += $(GENDATA_HTML32DTD) +include gendata/GendataBlacklistedCerts.gmk +GENDATA += $(GENDATA_BLACKLISTED_CERTS) + ########################################################################################## GENDATA_UNINAME := $(JDK_OUTPUTDIR)/classes/java/lang/uniName.dat @@ -62,7 +65,7 @@ GENDATA += $(GENDATA_UNINAME) ########################################################################################## -GENDATA_CURDATA := $(JDK_OUTPUTDIR)/lib/currency.data +GENDATA_CURDATA := $(JDK_OUTPUTDIR)/classes/java/util/currency.data $(GENDATA_CURDATA): $(JDK_TOPDIR)/make/data/currency/CurrencyData.properties $(BUILD_TOOLS) $(MKDIR) -p $(@D) diff --git a/jdk/make/Setup.gmk b/jdk/make/Setup.gmk index 123a03e2c17..485c3b72b13 100644 --- a/jdk/make/Setup.gmk +++ b/jdk/make/Setup.gmk @@ -27,7 +27,7 @@ DISABLE_WARNINGS := -Xlint:all,-deprecation,-unchecked,-rawtypes,-cast,-serial,- # To build with all warnings enabled, do the following: # make JAVAC_WARNINGS="-Xlint:all -Xmaxwarns 10000" -JAVAC_WARNINGS := -Xlint:-unchecked,-deprecation,-overrides,auxiliaryclass,cast,classfile,dep-ann,divzero,empty,fallthrough,overloads,serial,static,try,varargs -Werror +JAVAC_WARNINGS := -Xlint:all,-deprecation,-rawtypes,-unchecked -Werror # Any java code executed during a JDK build to build other parts of the JDK must be # executed by the bootstrap JDK (probably with -Xbootclasspath/p: ) and for this diff --git a/jdk/make/Tools.gmk b/jdk/make/Tools.gmk index d223f4afa62..0f781909490 100644 --- a/jdk/make/Tools.gmk +++ b/jdk/make/Tools.gmk @@ -87,6 +87,9 @@ TOOL_HASHER = $(JAVA_SMALL) -cp $(JDK_OUTPUTDIR)/btclasses \ TOOL_TZDB = $(JAVA_SMALL) -cp $(JDK_OUTPUTDIR)/btclasses \ build.tools.tzdb.TzdbZoneRulesCompiler +TOOL_BLACKLISTED_CERTS = $(JAVA_SMALL) -cp $(JDK_OUTPUTDIR)/btclasses \ + build.tools.blacklistedcertsconverter.BlacklistedCertsConverter + # 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. diff --git a/jdk/src/share/lib/security/blacklisted.certs.pem b/jdk/make/data/blacklistedcertsconverter/blacklisted.certs.pem similarity index 99% rename from jdk/src/share/lib/security/blacklisted.certs.pem rename to jdk/make/data/blacklistedcertsconverter/blacklisted.certs.pem index f44a6985352..db1c077ccb0 100644 --- a/jdk/src/share/lib/security/blacklisted.certs.pem +++ b/jdk/make/data/blacklistedcertsconverter/blacklisted.certs.pem @@ -1,3 +1,9 @@ +#! java BlacklistedCertsConverter SHA-256 + +# The line above must be the first line of the blacklisted.certs.pem +# file inside src/share/lib/security/. It will be ignored if added in +# src/closed/share/lib/security/blacklisted.certs.pem. + // Subject: CN=Digisign Server ID (Enrich), // OU=457608-K, // O=Digicert Sdn. Bhd., diff --git a/jdk/src/macosx/native/jobjc/run-and-write-if-okay b/jdk/make/gendata/GendataBlacklistedCerts.gmk similarity index 63% rename from jdk/src/macosx/native/jobjc/run-and-write-if-okay rename to jdk/make/gendata/GendataBlacklistedCerts.gmk index 8d0bb690276..ab62ca69ef9 100644 --- a/jdk/src/macosx/native/jobjc/run-and-write-if-okay +++ b/jdk/make/gendata/GendataBlacklistedCerts.gmk @@ -1,6 +1,5 @@ -#!/usr/bin/env ruby # -# Copyright (c) 2011, 2012, 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 @@ -23,26 +22,15 @@ # or visit www.oracle.com if you need additional information or have any # questions. # -# -if ARGV.length < 2 - puts <&1`. If it returns successfully, it writes the output to OUTPATH. -This script will return successfully unless writing the output fails. -EOF - exit -end +GENDATA_BLACKLISTED_CERTS_SRC := $(JDK_TOPDIR)/make/data/blacklistedcertsconverter/blacklisted.certs.pem +GENDATA_BLACKLISTED_CERTS := $(JDK_OUTPUTDIR)/lib/security/blacklisted.certs -EXECPATH = ARGV[0] -OUTPATH = ARGV[1] - -output = `#{EXECPATH}` -puts output - -if $?.to_i == 0 - puts "Writing output of #{EXECPATH} to #{OUTPATH}" - File.open(OUTPATH, 'w') {|f| f.write(output) } -else - puts "#{EXECPATH} failed to run trial. Ignoring." -end +ifndef OPENJDK + GENDATA_BLACKLISTED_CERTS_SRC += $(wildcard $(JDK_TOPDIR)/make/closed/data/blacklistedcertsconverter/blacklisted.certs.pem) +endif + +$(GENDATA_BLACKLISTED_CERTS): $(BUILD_TOOLS) $(GENDATA_BLACKLISTED_CERTS_SRC) + $(ECHO) "Generating blacklisted certs" + $(MKDIR) -p $(@D) + ($(CAT) $(GENDATA_BLACKLISTED_CERTS_SRC) | $(TOOL_BLACKLISTED_CERTS) > $@) || exit 1 diff --git a/jdk/make/lib/Awt2dLibraries.gmk b/jdk/make/lib/Awt2dLibraries.gmk index a689e52f03a..1d44b22ea83 100644 --- a/jdk/make/lib/Awt2dLibraries.gmk +++ b/jdk/make/lib/Awt2dLibraries.gmk @@ -319,7 +319,6 @@ endif ifeq ($(OPENJDK_TARGET_OS), macosx) LIBAWT_FILES += awt_LoadLibrary.c - LIBAWT_CFLAGS += -F/System/Library/Frameworks/JavaVM.framework/Frameworks endif ifeq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU_ARCH), solaris-sparc) @@ -484,7 +483,6 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBAWT, \ LDFLAGS_SUFFIX_macosx := -lmlib_image -ljvm $(LIBM) \ -framework Cocoa \ -framework OpenGL \ - -F/System/Library/Frameworks/JavaVM.framework/Frameworks \ -framework JavaNativeFoundation \ -framework JavaRuntimeSupport \ -framework ApplicationServices \ @@ -709,21 +707,24 @@ $(BUILD_LIBLCMS): $(BUILD_LIBAWT) ########################################################################################## +BUILD_LIBJAVAJPEG_DIR := $(JDK_TOPDIR)/src/share/native/sun/awt/image/jpeg + ifdef OPENJDK - BUILD_LIBJPEG_MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libjpeg/mapfile-vers + BUILD_LIBJAVAJPEG_MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libjpeg/mapfile-vers else - BUILD_LIBJPEG_MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libjpeg/mapfile-vers-closed - BUILD_LIBJPEG_CLOSED_SRC := $(JDK_TOPDIR)/src/closed/share/native/sun/awt/image/jpeg - BUILD_LIBJPEG_CLOSED_INCLUDES := -I$(BUILD_LIBJPEG_CLOSED_SRC) + BUILD_LIBJAVAJPEG_MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libjpeg/mapfile-vers-closed + BUILD_LIBJAVAJPEG_CLOSED_SRC := $(JDK_TOPDIR)/src/closed/share/native/sun/awt/image/jpeg + BUILD_LIBJAVAJPEG_CLOSED_INCLUDES := -I$(BUILD_LIBJAVAJPEG_CLOSED_SRC) endif -BUILD_LIBJPEG_REORDER := +BUILD_LIBJAVAJPEG_REORDER := ifeq ($(OPENJDK_TARGET_OS), solaris) ifneq ($(OPENJDK_TARGET_CPU), x86_64) - BUILD_LIBJPEG_REORDER := $(JDK_TOPDIR)/make/mapfiles/libjpeg/reorder-$(OPENJDK_TARGET_CPU) + BUILD_LIBJAVAJPEG_REORDER := $(JDK_TOPDIR)/make/mapfiles/libjpeg/reorder-$(OPENJDK_TARGET_CPU) endif endif + # Suppress gcc warnings like "variable might be clobbered by 'longjmp' # or 'vfork'": this warning indicates that some variable is placed to # a register by optimized compiler and it's value might be lost on longjmp(). @@ -735,37 +736,50 @@ endif # $(shell $(EXPR) $(CC_MAJORVER) \> 4 \| \ # \( $(CC_MAJORVER) = 4 \& $(CC_MINORVER) \>= 3 \) ) # ifeq ($(CC_43_OR_NEWER), 1) -# BUILD_LIBJPEG_CFLAGS_linux += -Wno-clobbered +# BUILD_LIBJAVAJPEG_CFLAGS_linux += -Wno-clobbered # endif #endif -$(eval $(call SetupNativeCompilation,BUILD_LIBJPEG, \ - LIBRARY := jpeg, \ +ifeq ($(USE_EXTERNAL_LIBJPEG), true) + LIBJPEG_LIBS := -ljpeg + BUILD_LIBJAVAJPEG_INCLUDE_FILES := \ + imageIOJPEG.c \ + jpegdecoder.c + BUILD_LIBJAVAJPEG_HEADERS := +else + LIBJPEG_LIBS := + BUILD_LIBJAVAJPEG_INCLUDE_FILES := + BUILD_LIBJAVAJPEG_HEADERS := -I$(BUILD_LIBJAVAJPEG_DIR) +endif + +$(eval $(call SetupNativeCompilation,BUILD_LIBJAVAJPEG, \ + LIBRARY := javajpeg, \ OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \ - SRC := $(BUILD_LIBJPEG_CLOSED_SRC) \ - $(JDK_TOPDIR)/src/share/native/sun/awt/image/jpeg, \ + SRC := $(BUILD_LIBJAVAJPEG_CLOSED_SRC) \ + $(BUILD_LIBJAVAJPEG_DIR), \ + INCLUDE_FILES := $(BUILD_LIBJAVAJPEG_INCLUDE_FILES), \ LANG := C, \ OPTIMIZATION := HIGHEST, \ CFLAGS := $(CFLAGS_JDKLIB) \ - $(BUILD_LIBJPEG_CLOSED_INCLUDES) \ - -I$(JDK_TOPDIR)/src/share/native/sun/awt/image/jpeg, \ - MAPFILE := $(BUILD_LIBJPEG_MAPFILE), \ - LDFLAGS := $(LDFLAGS_JDKLIB) \ + $(BUILD_LIBJAVAJPEG_CLOSED_INCLUDES) \ + $(BUILD_LIBJAVAJPEG_HEADERS), \ + MAPFILE := $(BUILD_LIBJAVAJPEG_MAPFILE), \ + LDFLAGS := $(LDFLAGS_JDKLIB) $(LIBJPEG_LIBS) \ $(call SET_SHARED_LIBRARY_ORIGIN), \ LDFLAGS_windows := $(WIN_JAVA_LIB) jvm.lib, \ LDFLAGS_SUFFIX := $(LDFLAGS_JDKLIB_SUFFIX), \ VERSIONINFO_RESOURCE := $(JDK_TOPDIR)/src/windows/resource/version.rc, \ RC_FLAGS := $(RC_FLAGS) \ - -D "JDK_FNAME=jpeg.dll" \ - -D "JDK_INTERNAL_NAME=jpeg" \ + -D "JDK_FNAME=javajpeg.dll" \ + -D "JDK_INTERNAL_NAME=javajpeg" \ -D "JDK_FTYPE=0x2L", \ - REORDER := $(BUILD_LIBJPEG_REORDER), \ + REORDER := $(BUILD_LIBJAVAJPEG_REORDER), \ OBJECT_DIR := $(JDK_OUTPUTDIR)/objs/libjpeg, \ DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES))) -$(BUILD_LIBJPEG): $(BUILD_LIBJAVA) +$(BUILD_LIBJAVAJPEG): $(BUILD_LIBJAVA) -BUILD_LIBRARIES += $(BUILD_LIBJPEG) +BUILD_LIBRARIES += $(BUILD_LIBJAVAJPEG) ########################################################################################## @@ -1130,12 +1144,6 @@ ifeq ($(BUILD_HEADLESS), true) -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/jdga \ $(foreach dir, $(LIBAWT_HEADLESS_DIRS), -I$(dir)) - ifeq ($(OPENJDK_TARGET_OS), macosx) - LIBAWT_HEADLESS_CFLAGS += \ - -F/System/Library/Frameworks/JavaVM.framework/Frameworks \ - -F/System/Library/Frameworks/ApplicationServices.framework/Frameworks - endif - LIBAWT_HEADLESS_FILES := \ awt_Font.c \ HeadlessToolkit.c \ @@ -1213,6 +1221,13 @@ ifndef BUILD_HEADLESS_ONLY GIFLIB_CFLAGS := -I$(JDK_TOPDIR)/src/share/native/sun/awt/giflib endif + ifeq ($(USE_EXTERNAL_LIBJPEG), true) + LIBJPEG_LDFLAGS := -ljpeg + else + LIBSPLASHSCREEN_DIRS += $(JDK_TOPDIR)/src/share/native/sun/awt/image/jpeg + LIBJPEG_CFLAGS := -I$(JDK_TOPDIR)/src/share/native/sun/awt/image/jpeg + endif + ifeq ($(USE_EXTERNAL_LIBPNG), false) LIBSPLASHSCREEN_DIRS += $(JDK_TOPDIR)/src/share/native/sun/awt/libpng LIBPNG_CFLAGS := -I$(JDK_TOPDIR)/src/share/native/sun/awt/libpng @@ -1229,8 +1244,7 @@ ifndef BUILD_HEADLESS_ONLY ifeq ($(OPENJDK_TARGET_OS), macosx) LIBSPLASHSCREEN_CFLAGS := -I$(JDK_TOPDIR)/src/macosx/native/sun/awt/splashscreen \ - $(LIBSPLASHSCREEN_CFLAGS) \ - -F/System/Library/Frameworks/JavaVM.framework/Frameworks + $(LIBSPLASHSCREEN_CFLAGS) LIBSPLASHSCREEN_CFLAGS += -DWITH_MACOSX LIBSPLASHSCREEN_CFLAGS += -I$(JDK_TOPDIR)/src/macosx/native/sun/osxapp @@ -1260,7 +1274,6 @@ ifndef BUILD_HEADLESS_ONLY -framework ApplicationServices \ -framework Foundation \ -framework Cocoa \ - -F/System/Library/Frameworks/JavaVM.framework/Frameworks \ -framework JavaNativeFoundation else ifeq ($(OPENJDK_TARGET_OS), windows) LIBSPLASHSCREEN_LDFLAGS_SUFFIX += kernel32.lib user32.lib gdi32.lib delayimp.lib -DELAYLOAD:user32.dll @@ -1276,12 +1289,12 @@ ifndef BUILD_HEADLESS_ONLY LANG := C, \ OPTIMIZATION := LOW, \ CFLAGS := $(LIBSPLASHSCREEN_CFLAGS) $(CFLAGS_JDKLIB) \ - $(GIFLIB_CFLAGS) $(PNG_CFLAGS), \ + $(GIFLIB_CFLAGS) $(LIBJPEG_CFLAGS) $(PNG_CFLAGS), \ MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libsplashscreen/mapfile-vers, \ LDFLAGS := $(LDFLAGS_JDKLIB) \ $(call SET_SHARED_LIBRARY_ORIGIN), \ LDFLAGS_SUFFIX := $(LIBSPLASHSCREEN_LDFLAGS_SUFFIX) $(LIBZ) \ - $(GIFLIB_LDFLAGS) $(PNG_LIBS), \ + $(GIFLIB_LDFLAGS) $(LIBJPEG_LDFLAGS) $(PNG_LIBS), \ LDFLAGS_SUFFIX_solaris := -lc, \ VERSIONINFO_RESOURCE := $(JDK_TOPDIR)/src/windows/resource/version.rc, \ RC_FLAGS := $(RC_FLAGS) \ @@ -1445,9 +1458,7 @@ ifeq ($(OPENJDK_TARGET_OS), macosx) -I$(JDK_TOPDIR)/src/share/native/sun/awt/image/cvutils \ -I$(JDK_TOPDIR)/src/share/native/sun/java2d/loops \ -I$(JDK_TOPDIR)/src/share/native/sun/java2d/pipe \ - -I$(JDK_TOPDIR)/src/share/native/sun/awt/debug \ - -F/System/Library/Frameworks/JavaVM.framework/Frameworks \ - -F/System/Library/Frameworks/ApplicationServices.framework/Frameworks, \ + -I$(JDK_TOPDIR)/src/share/native/sun/awt/debug, \ LDFLAGS := $(LDFLAGS_JDKLIB) \ $(call SET_SHARED_LIBRARY_ORIGIN), \ LDFLAGS_SUFFIX_macosx := -lawt -lmlib_image -losxapp -ljvm $(LIBM) \ @@ -1458,7 +1469,6 @@ ifeq ($(OPENJDK_TARGET_OS), macosx) -framework Cocoa \ -framework Security \ -framework ExceptionHandling \ - -F/System/Library/Frameworks/JavaVM.framework/Frameworks \ -framework JavaNativeFoundation \ -framework JavaRuntimeSupport \ -framework OpenGL \ @@ -1491,8 +1501,7 @@ ifeq ($(OPENJDK_TARGET_OS), macosx) CFLAGS := $(CFLAGS_JDKLIB) \ -I$(JDK_TOPDIR)/src/macosx/native/com/apple/laf \ -I$(JDK_TOPDIR)/src/macosx/native/sun/osxapp \ - -I$(JDK_TOPDIR)/src/macosx/native/sun/awt \ - -F/System/Library/Frameworks/JavaVM.framework/Frameworks, \ + -I$(JDK_TOPDIR)/src/macosx/native/sun/awt, \ LDFLAGS := $(LDFLAGS_JDKLIB) \ $(call SET_SHARED_LIBRARY_ORIGIN) \ -Xlinker -rpath -Xlinker @loader_path, \ @@ -1500,7 +1509,6 @@ ifeq ($(OPENJDK_TARGET_OS), macosx) -framework Cocoa \ -framework Carbon \ -framework ApplicationServices \ - -F/System/Library/Frameworks/JavaVM.framework/Frameworks \ -framework JavaNativeFoundation \ -framework JavaRuntimeSupport \ -ljava -ljvm, \ diff --git a/jdk/make/lib/CoreLibraries.gmk b/jdk/make/lib/CoreLibraries.gmk index 66ef38ec94f..871e95a0dff 100644 --- a/jdk/make/lib/CoreLibraries.gmk +++ b/jdk/make/lib/CoreLibraries.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 @@ -306,7 +306,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBPREFS, \ LDFLAGS_SUFFIX_solaris := -ljvm -ljava -lc, \ LDFLAGS_SUFFIX_aix := -ljvm -ljava, \ LDFLAGS_SUFFIX_windows := advapi32.lib jvm.lib $(WIN_JAVA_LIB), \ - LDFLAGS_SUFFIX_macosx := -ljvm -framework CoreFoundation, \ + LDFLAGS_SUFFIX_macosx := -ljvm -framework CoreFoundation -framework Foundation, \ VERSIONINFO_RESOURCE := $(JDK_TOPDIR)/src/windows/resource/version.rc, \ RC_FLAGS := $(RC_FLAGS) \ -D "JDK_FNAME=prefs.dll" \ @@ -526,30 +526,3 @@ else ifeq ($(OPENJDK_TARGET_OS), aix) BUILD_LIBRARIES += $(JDK_OUTPUTDIR)/objs/libjli_static.a endif - -########################################################################################## - -$(eval $(call SetupNativeCompilation,BUILD_LIBNPT, \ - LIBRARY := npt, \ - OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \ - SRC := $(JDK_TOPDIR)/src/share/npt $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/npt, \ - LANG := C, \ - OPTIMIZATION := LOW, \ - CFLAGS := $(CFLAGS_JDKLIB) \ - -I$(JDK_TOPDIR)/src/share/npt \ - -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/npt, \ - MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libnpt/mapfile-vers, \ - LDFLAGS := $(LDFLAGS_JDKLIB) \ - $(call SET_SHARED_LIBRARY_ORIGIN), \ - LDFLAGS_macosx := -liconv, \ - LDFLAGS_SUFFIX_windows := -export:nptInitialize -export:nptTerminate, \ - LDFLAGS_SUFFIX_solaris := -lc, \ - VERSIONINFO_RESOURCE := $(JDK_TOPDIR)/src/windows/resource/version.rc, \ - RC_FLAGS := $(RC_FLAGS) \ - -D "JDK_FNAME=npt.dll" \ - -D "JDK_INTERNAL_NAME=npt" \ - -D "JDK_FTYPE=0x2L", \ - OBJECT_DIR := $(JDK_OUTPUTDIR)/objs/libnpt, \ - DEBUG_SYMBOLS := true)) - -BUILD_LIBRARIES += $(BUILD_LIBNPT) diff --git a/jdk/make/lib/PlatformLibraries.gmk b/jdk/make/lib/PlatformLibraries.gmk index e78a9833dd5..e3fc71c4bf9 100644 --- a/jdk/make/lib/PlatformLibraries.gmk +++ b/jdk/make/lib/PlatformLibraries.gmk @@ -32,14 +32,11 @@ ifeq ($(OPENJDK_TARGET_OS), macosx) LANG := C, \ OPTIMIZATION := LOW, \ CFLAGS := $(CFLAGS_JDKLIB) \ - -I$(JDK_TOPDIR)/src/macosx/native/apple/applescript \ - -F/System/Library/Frameworks/JavaVM.framework/Frameworks \ - -F/System/Library/Frameworks/ApplicationServices.framework/Frameworks, \ + -I$(JDK_TOPDIR)/src/macosx/native/apple/applescript, \ LDFLAGS := $(LDFLAGS_JDKLIB) \ $(call SET_SHARED_LIBRARY_ORIGIN), \ LDFLAGS_SUFFIX := -framework Cocoa \ -framework Carbon \ - -F/System/Library/Frameworks/JavaVM.framework/Frameworks \ -framework JavaNativeFoundation \ $(LDFLAGS_JDKLIB_SUFFIX), \ OBJECT_DIR := $(JDK_OUTPUTDIR)/objs/libAppleScriptEngine, \ @@ -63,9 +60,7 @@ ifeq ($(OPENJDK_TARGET_OS), macosx) OPTIMIZATION := LOW, \ CFLAGS := $(CFLAGS_JDKLIB) \ -I$(JDK_TOPDIR)/src/macosx/native/sun/osxapp \ - -I$(JDK_OUTPUTDIR)/gensrc_headers_icons \ - -F/System/Library/Frameworks/JavaVM.framework/Frameworks \ - -F/System/Library/Frameworks/ApplicationServices.framework/Frameworks, \ + -I$(JDK_OUTPUTDIR)/gensrc_headers_icons, \ LDFLAGS := $(LDFLAGS_JDKLIB) \ $(call SET_SHARED_LIBRARY_ORIGIN), \ LDFLAGS_SUFFIX_macosx := \ @@ -76,7 +71,6 @@ ifeq ($(OPENJDK_TARGET_OS), macosx) -framework Cocoa \ -framework Security \ -framework ExceptionHandling \ - -F/System/Library/Frameworks/JavaVM.framework/Frameworks \ -framework JavaNativeFoundation \ -framework JavaRuntimeSupport \ -framework OpenGL \ @@ -107,16 +101,13 @@ ifeq ($(OPENJDK_TARGET_OS), macosx) OPTIMIZATION := LOW, \ CFLAGS := $(CFLAGS_JDKLIB) \ $(foreach dir, $(LIBOSX_DIRS), -I$(dir)) \ - -I$(JDK_TOPDIR)/src/macosx/native/sun/osxapp \ - -F/System/Library/Frameworks/JavaVM.framework/Frameworks \ - -F/System/Library/Frameworks/ApplicationServices.framework/Frameworks, \ + -I$(JDK_TOPDIR)/src/macosx/native/sun/osxapp, \ LDFLAGS := $(LDFLAGS_JDKLIB) \ $(call SET_SHARED_LIBRARY_ORIGIN), \ LDFLAGS_SUFFIX_macosx := \ -losxapp \ -framework Cocoa \ -framework ApplicationServices \ - -F/System/Library/Frameworks/JavaVM.framework/Frameworks \ -framework JavaNativeFoundation \ -framework JavaRuntimeSupport \ -framework Security \ diff --git a/jdk/make/lib/SecurityLibraries.gmk b/jdk/make/lib/SecurityLibraries.gmk index 66c55b8264d..eeb062a30da 100644 --- a/jdk/make/lib/SecurityLibraries.gmk +++ b/jdk/make/lib/SecurityLibraries.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 @@ -130,7 +130,7 @@ ifneq ($(BUILD_CRYPTO), no) BUILD_LIBKRB5_NAME := osxkrb5 BUILD_LIBKRB5_SRC := $(JDK_TOPDIR)/src/share/native/sun/security/krb5 \ $(JDK_TOPDIR)/src/macosx/native/sun/security/krb5 - BUILD_LIBKRB5_LIBS := -F/System/Library/Frameworks/JavaVM.framework/Frameworks \ + BUILD_LIBKRB5_LIBS := \ -framework JavaNativeFoundation \ -framework Cocoa \ -framework SystemConfiguration \ @@ -147,7 +147,6 @@ ifneq ($(BUILD_CRYPTO), no) CFLAGS := $(CFLAGS_JDKLIB) \ -I$(JDK_TOPDIR)/src/share/native/sun/security/krb5, \ CFLAGS_windows := -I$(JDK_TOPDIR)/src/windows/native/sun/security/krb5, \ - CFLAGS_macosx := -F/System/Library/Frameworks/JavaVM.framework/Frameworks, \ LDFLAGS := $(LDFLAGS_JDKLIB) \ $(call SET_SHARED_LIBRARY_ORIGIN), \ LDFLAGS_SUFFIX := $(BUILD_LIBKRB5_LIBS), \ diff --git a/jdk/make/lib/ServiceabilityLibraries.gmk b/jdk/make/lib/ServiceabilityLibraries.gmk index 550a3e722da..a39a2815904 100644 --- a/jdk/make/lib/ServiceabilityLibraries.gmk +++ b/jdk/make/lib/ServiceabilityLibraries.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 @@ -147,8 +147,6 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJDWP, \ CFLAGS := $(CFLAGS_JDKLIB) $(CFLAGS_WARNINGS_ARE_ERRORS) -DJDWP_LOGGING \ -I$(JDK_TOPDIR)/src/share/transport/export \ -I$(JDK_TOPDIR)/src/share/back/export \ - -I$(JDK_TOPDIR)/src/share/npt \ - -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/npt \ -I$(JDK_TOPDIR)/src/share/back \ -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/back \ -I$(JDK_OUTPUTDIR)/gensrc_jdwp_headers, \ @@ -158,6 +156,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJDWP, \ LDFLAGS_SUFFIX_linux := $(LIBDL), \ LDFLAGS_SUFFIX_solaris := $(LIBDL) -lc, \ LDFLAGS_SUFFIX_windows := $(LDFLAGS_JDKLIB_SUFFIX), \ + LDFLAGS_SUFFIX_macosx := -liconv, \ VERSIONINFO_RESOURCE := $(JDK_TOPDIR)/src/windows/resource/version.rc, \ RC_FLAGS := $(RC_FLAGS) \ -D "JDK_FNAME=jdwp.dll" \ @@ -340,8 +339,6 @@ BUILD_LIBRARIES += $(BUILD_LIBMANAGEMENT) BUILD_LIBHPROF_SRC := $(JDK_TOPDIR)/src/share/demo/jvmti/hprof $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/demo/jvmti/hprof BUILD_LIBHPROF_CFLAGS := -I$(JDK_TOPDIR)/src/share/demo/jvmti/hprof \ - -I$(JDK_TOPDIR)/src/share/npt \ - -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/npt \ -I$(JDK_TOPDIR)/src/share/demo/jvmti/java_crw_demo ifeq ($(OPENJDK_TARGET_OS), aix) diff --git a/jdk/make/mapfiles/libawt/mapfile-vers b/jdk/make/mapfiles/libawt/mapfile-vers index b1c6a39ec1e..636c255c6c6 100644 --- a/jdk/make/mapfiles/libawt/mapfile-vers +++ b/jdk/make/mapfiles/libawt/mapfile-vers @@ -155,6 +155,7 @@ SUNWprivate_1.1 { g_CMpDataID; colorValueID; mul8table; + div8table; jvm; # ProcessPath entry points and data diff --git a/jdk/make/profile-includes.txt b/jdk/make/profile-includes.txt index f2ae4c1b31c..17728a7f3d9 100644 --- a/jdk/make/profile-includes.txt +++ b/jdk/make/profile-includes.txt @@ -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 @@ -56,7 +56,6 @@ PROFILE_1_JRE_LIB_FILES := \ $(OPENJDK_TARGET_CPU_LEGACY_LIB)/server/Xusage.txt \ calendars.properties \ classlist \ - currency.data \ ext/localedata.jar \ ext/meta-index \ ext/sunec.jar \ @@ -127,12 +126,9 @@ PROFILE_3_JRE_LIB_FILES := \ $(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)jsdt.diz \ $(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)management$(SHARED_LIBRARY_SUFFIX) \ $(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)management.diz \ - $(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)npt$(SHARED_LIBRARY_SUFFIX) \ - $(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)npt.diz \ $(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)prefs$(SHARED_LIBRARY_SUFFIX) \ $(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)sctp$(SHARED_LIBRARY_SUFFIX) \ jvm.hprof.txt \ - management-agent.jar \ management/jmxremote.access \ management/jmxremote.password.template \ management/management.properties \ @@ -140,8 +136,7 @@ PROFILE_3_JRE_LIB_FILES := \ PROFILE_3_JRE_OTHER_FILES := -PROFILE_3_JRE_JAR_FILES := \ - management-agent.jar +PROFILE_3_JRE_JAR_FILES := FULL_JRE_BIN_FILES := \ diff --git a/jdk/src/share/lib/security/BlacklistedCertsConverter.java b/jdk/make/src/classes/build/tools/blacklistedcertsconverter/BlacklistedCertsConverter.java similarity index 56% rename from jdk/src/share/lib/security/BlacklistedCertsConverter.java rename to jdk/make/src/classes/build/tools/blacklistedcertsconverter/BlacklistedCertsConverter.java index 65a88f00a2e..9f8ce873c57 100644 --- a/jdk/src/share/lib/security/BlacklistedCertsConverter.java +++ b/jdk/make/src/classes/build/tools/blacklistedcertsconverter/BlacklistedCertsConverter.java @@ -21,37 +21,65 @@ * questions. */ +package build.tools.blacklistedcertsconverter; + import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; import java.security.cert.Certificate; -import java.security.cert.CertificateEncodingException; import java.security.cert.CertificateFactory; import java.security.cert.X509Certificate; import java.util.Collection; +import java.util.Set; +import java.util.TreeSet; + /** - * This is the tool to convert blacklisted.certs.pem to blacklisted.certs. - * Every time a new blacklisted certs is added, please append the PEM format - * to the end of blacklisted.certs.pem (with proper comments) and then use - * this tool to generate an updated blacklisted.certs. Make sure to include - * changes to both in a changeset. + * Converts blacklisted.certs.pem from System.in to blacklisted.certs in + * System.out. The input must start with a #! line including the fingerprint + * algorithm. The output is sorted and unique. */ public class BlacklistedCertsConverter { + public static void main(String[] args) throws Exception { - if (args.length == 0) { - System.out.println("Usage: java BlacklistedCertsConverter SHA-256" + - " < blacklisted.certs.pem > blacklisted.certs"); - System.exit(1); + + byte[] pattern = "#! java BlacklistedCertsConverter ".getBytes(); + String mdAlg = ""; + + for (int i=0; ; i++) { + int n = System.in.read(); + if (n < 0) { + throw new Exception("Unexpected EOF"); + } + if (i < pattern.length) { + if (n != pattern[i]) { + throw new Exception("The first line must start with \"" + + new String(pattern) + "\""); + } + } else if (i < pattern.length + 100) { + if (n < 32) { + break; + } else { + mdAlg = mdAlg + String.format("%c", n); + } + } } - String mdAlg = args[0]; + + mdAlg = mdAlg.trim(); + System.out.println("Algorithm=" + mdAlg); + CertificateFactory cf = CertificateFactory.getInstance("X.509"); Collection certs = cf.generateCertificates(System.in); - System.out.println("Algorithm=" + mdAlg); + + // Output sorted so that it's easy to locate an entry. + Set fingerprints = new TreeSet<>(); for (Certificate cert: certs) { - System.out.println( + fingerprints.add( getCertificateFingerPrint(mdAlg, (X509Certificate)cert)); } + + for (String s: fingerprints) { + System.out.println(s); + } } /** @@ -69,21 +97,15 @@ public class BlacklistedCertsConverter { /** * Gets the requested finger print of the certificate. */ - private static String getCertificateFingerPrint(String mdAlg, - X509Certificate cert) { - String fingerPrint = ""; - try { - byte[] encCertInfo = cert.getEncoded(); - MessageDigest md = MessageDigest.getInstance(mdAlg); - byte[] digest = md.digest(encCertInfo); - StringBuffer buf = new StringBuffer(); - for (int i = 0; i < digest.length; i++) { - byte2hex(digest[i], buf); - } - fingerPrint = buf.toString(); - } catch (NoSuchAlgorithmException | CertificateEncodingException e) { - // ignored + private static String getCertificateFingerPrint( + String mdAlg, X509Certificate cert) throws Exception { + byte[] encCertInfo = cert.getEncoded(); + MessageDigest md = MessageDigest.getInstance(mdAlg); + byte[] digest = md.digest(encCertInfo); + StringBuffer buf = new StringBuffer(); + for (int i = 0; i < digest.length; i++) { + byte2hex(digest[i], buf); } - return fingerPrint; + return buf.toString(); } } diff --git a/jdk/make/src/classes/build/tools/buildmetaindex/BuildMetaIndex.java b/jdk/make/src/classes/build/tools/buildmetaindex/BuildMetaIndex.java index 631d437c39c..c39ee6fabc2 100644 --- a/jdk/make/src/classes/build/tools/buildmetaindex/BuildMetaIndex.java +++ b/jdk/make/src/classes/build/tools/buildmetaindex/BuildMetaIndex.java @@ -53,7 +53,6 @@ sun/ com/sun/net/ javax/ com/sun/security/ -# management-agent.jar ! rt.jar org/w3c/ com/sun/image/ diff --git a/jdk/make/src/classes/build/tools/generatenimbus/PainterGenerator.java b/jdk/make/src/classes/build/tools/generatenimbus/PainterGenerator.java index 07b016d75ff..265ab3c9e65 100644 --- a/jdk/make/src/classes/build/tools/generatenimbus/PainterGenerator.java +++ b/jdk/make/src/classes/build/tools/generatenimbus/PainterGenerator.java @@ -57,6 +57,9 @@ import java.util.Map; * @author Jasper Potts */ public class PainterGenerator { + + private static final boolean debug = false; + //a handful of counters, incremented whenever the associated object type is encounted. //These counters form the basis of the field and method suffixes. //These are all 1 based, because I felt like it :-) @@ -384,16 +387,24 @@ public class PainterGenerator { } if (Float.isNaN(r)) { - System.err.println("[Error] Encountered NaN: encode(" + x + ", " + a + ", " + b + ", " + w + ")"); + if (debug) { + System.err.println("[Error] Encountered NaN: encode(" + x + ", " + a + ", " + b + ", " + w + ")"); + } return 0; } else if (Float.isInfinite(r)) { - System.err.println("[Error] Encountered Infinity: encode(" + x + ", " + a + ", " + b + ", " + w + ")"); + if (debug) { + System.err.println("[Error] Encountered Infinity: encode(" + x + ", " + a + ", " + b + ", " + w + ")"); + } return 0; } else if (r < 0) { - System.err.println("[Error] encoded value was less than 0: encode(" + x + ", " + a + ", " + b + ", " + w + ")"); + if (debug) { + System.err.println("[Error] encoded value was less than 0: encode(" + x + ", " + a + ", " + b + ", " + w + ")"); + } return 0; } else if (r > 3) { - System.err.println("[Error] encoded value was greater than 3: encode(" + x + ", " + a + ", " + b + ", " + w + ")"); + if (debug) { + System.err.println("[Error] encoded value was greater than 3: encode(" + x + ", " + a + ", " + b + ", " + w + ")"); + } return 3; } else { return r; diff --git a/jdk/make/src/classes/build/tools/tzdb/ChronoField.java b/jdk/make/src/classes/build/tools/tzdb/ChronoField.java deleted file mode 100644 index 7ce34bbfae2..00000000000 --- a/jdk/make/src/classes/build/tools/tzdb/ChronoField.java +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * Copyright (c) 2012, Stephen Colebourne & Michael Nascimento Santos - * - * 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 JSR-310 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. - */ - -package build.tools.tzdb; - -/** - * A standard set of date/time fields. - * - * @since 1.8 - */ -enum ChronoField { - - /** - * The second-of-minute. - *

- * This counts the second within the minute, from 0 to 59. - * This field has the same meaning for all calendar systems. - */ - SECOND_OF_MINUTE("SecondOfMinute", 0, 59), - - /** - * The second-of-day. - *

- * This counts the second within the day, from 0 to (24 * 60 * 60) - 1. - * This field has the same meaning for all calendar systems. - */ - SECOND_OF_DAY("SecondOfDay", 0, 86400 - 1), - - /** - * The minute-of-hour. - *

- * This counts the minute within the hour, from 0 to 59. - * This field has the same meaning for all calendar systems. - */ - MINUTE_OF_HOUR("MinuteOfHour", 0, 59), - - /** - * The hour-of-day. - *

- * This counts the hour within the day, from 0 to 23. - * This is the hour that would be observed on a standard 24-hour digital clock. - * This field has the same meaning for all calendar systems. - */ - HOUR_OF_DAY("HourOfDay", 0, 23), - - - /** - * The day-of-month. - *

- * This represents the concept of the day within the month. - * In the default ISO calendar system, this has values from 1 to 31 in most months. - * April, June, September, November have days from 1 to 30, while February has days - * from 1 to 28, or 29 in a leap year. - *

- * Non-ISO calendar systems should implement this field using the most recognized - * day-of-month values for users of the calendar system. - * Normally, this is a count of days from 1 to the length of the month. - */ - DAY_OF_MONTH("DayOfMonth", 1, 31), - - /** - * The month-of-year, such as March. - *

- * This represents the concept of the month within the year. - * In the default ISO calendar system, this has values from January (1) to December (12). - *

- * Non-ISO calendar systems should implement this field using the most recognized - * month-of-year values for users of the calendar system. - * Normally, this is a count of months starting from 1. - */ - MONTH_OF_YEAR("MonthOfYear", 1, 12), - - /** - * The proleptic year, such as 2012. - *

- * This represents the concept of the year, counting sequentially and using negative numbers. - * The proleptic year is not interpreted in terms of the era. - * See {@link #YEAR_OF_ERA} for an example showing the mapping from proleptic year to year-of-era. - *

- * The standard mental model for a date is based on three concepts - year, month and day. - * These map onto the {@code YEAR}, {@code MONTH_OF_YEAR} and {@code DAY_OF_MONTH} fields. - * Note that there is no reference to eras. - * The full model for a date requires four concepts - era, year, month and day. These map onto - * the {@code ERA}, {@code YEAR_OF_ERA}, {@code MONTH_OF_YEAR} and {@code DAY_OF_MONTH} fields. - * Whether this field or {@code YEAR_OF_ERA} is used depends on which mental model is being used. - * See {@link ChronoLocalDate} for more discussion on this topic. - *

- * Non-ISO calendar systems should implement this field as follows. - * If the calendar system has only two eras, before and after a fixed date, then the - * proleptic-year value must be the same as the year-of-era value for the later era, - * and increasingly negative for the earlier era. - * If the calendar system has more than two eras, then the proleptic-year value may be - * defined with any appropriate value, although defining it to be the same as ISO may be - * the best option. - */ - YEAR("Year", -999_999_999, 999_999_999); - - private final String name; - private final int min; - private final int max; - - private ChronoField(String name, int min, int max) { - this.name = name; - this.min= min; - this.max= max; - } - - /** - * Checks that the specified value is valid for this field. - *

- * - * @param value the value to check - * @return the value that was passed in - */ - public int checkValidValue(int value) { - if (value >= min && value <= max) { - return value; - } - throw new DateTimeException("Invalid value for " + name + " value: " + value); - } - - public String toString() { - return name; - } - -} diff --git a/jdk/make/src/classes/build/tools/tzdb/DateTimeException.java b/jdk/make/src/classes/build/tools/tzdb/DateTimeException.java deleted file mode 100644 index 2b7674df3ff..00000000000 --- a/jdk/make/src/classes/build/tools/tzdb/DateTimeException.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. 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 file is available under and governed by the GNU General Public - * License version 2 only, as published by the Free Software Foundation. - * However, the following notice accompanied the original version of this - * file: - * - * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos - * - * 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 JSR-310 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. - */ -package build.tools.tzdb; - -/** - * Exception used to indicate a problem while calculating a date-time. - *

- * This exception is used to indicate problems with creating, querying - * and manipulating date-time objects. - * - * @since 1.8 - */ -class DateTimeException extends RuntimeException { - - /** - * Serialization version. - */ - private static final long serialVersionUID = -1632418723876261839L; - - /** - * Constructs a new date-time exception with the specified message. - * - * @param message the message to use for this exception, may be null - */ - public DateTimeException(String message) { - super(message); - } - - /** - * Constructs a new date-time exception with the specified message and cause. - * - * @param message the message to use for this exception, may be null - * @param cause the cause of the exception, may be null - */ - public DateTimeException(String message, Throwable cause) { - super(message, cause); - } - -} diff --git a/jdk/make/src/classes/build/tools/tzdb/LocalDate.java b/jdk/make/src/classes/build/tools/tzdb/LocalDate.java deleted file mode 100644 index fedab6d3156..00000000000 --- a/jdk/make/src/classes/build/tools/tzdb/LocalDate.java +++ /dev/null @@ -1,363 +0,0 @@ -/* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This file is available under and governed by the GNU General Public - * License version 2 only, as published by the Free Software Foundation. - * However, the following notice accompanied the original version of this - * file: - * - * Copyright (c) 2007-2012, Stephen Colebourne & Michael Nascimento Santos - * - * 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 JSR-310 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. - */ -package build.tools.tzdb; - -import static build.tools.tzdb.Utils.*; -import static build.tools.tzdb.LocalTime.SECONDS_PER_DAY; -import static build.tools.tzdb.ChronoField.DAY_OF_MONTH; -import static build.tools.tzdb.ChronoField.MONTH_OF_YEAR; -import static build.tools.tzdb.ChronoField.YEAR; - -import java.util.Objects; - -/** - * A date without a time-zone in the ISO-8601 calendar system, - * such as {@code 2007-12-03}. - * - * @since 1.8 - */ -final class LocalDate { - - /** - * The minimum supported {@code LocalDate}, '-999999999-01-01'. - * This could be used by an application as a "far past" date. - */ - public static final LocalDate MIN = new LocalDate(YEAR_MIN_VALUE, 1, 1); - /** - * The maximum supported {@code LocalDate}, '+999999999-12-31'. - * This could be used by an application as a "far future" date. - */ - public static final LocalDate MAX = new LocalDate(YEAR_MAX_VALUE, 12, 31); - - /** - * The number of days in a 400 year cycle. - */ - private static final int DAYS_PER_CYCLE = 146097; - /** - * The number of days from year zero to year 1970. - * There are five 400 year cycles from year zero to 2000. - * There are 7 leap years from 1970 to 2000. - */ - static final long DAYS_0000_TO_1970 = (DAYS_PER_CYCLE * 5L) - (30L * 365L + 7L); - - /** - * The year. - */ - private final int year; - /** - * The month-of-year. - */ - private final short month; - /** - * The day-of-month. - */ - private final short day; - - /** - * Obtains an instance of {@code LocalDate} from a year, month and day. - *

- * The day must be valid for the year and month, otherwise an exception will be thrown. - * - * @param year the year to represent, from MIN_YEAR to MAX_YEAR - * @param month the month-of-year to represent, from 1 (January) to 12 (December) - * @param dayOfMonth the day-of-month to represent, from 1 to 31 - * @return the local date, not null - * @throws DateTimeException if the value of any field is out of range - * @throws DateTimeException if the day-of-month is invalid for the month-year - */ - public static LocalDate of(int year, int month, int dayOfMonth) { - YEAR.checkValidValue(year); - MONTH_OF_YEAR.checkValidValue(month); - DAY_OF_MONTH.checkValidValue(dayOfMonth); - if (dayOfMonth > 28 && dayOfMonth > lengthOfMonth(month, isLeapYear(year))) { - if (dayOfMonth == 29) { - throw new DateTimeException("Invalid date 'February 29' as '" + year + "' is not a leap year"); - } else { - throw new DateTimeException("Invalid date '" + month + " " + dayOfMonth + "'"); - } - } - return new LocalDate(year, month, dayOfMonth); - } - - /** - * Constructor, previously validated. - * - * @param year the year to represent, from MIN_YEAR to MAX_YEAR - * @param month the month-of-year to represent, not null - * @param dayOfMonth the day-of-month to represent, valid for year-month, from 1 to 31 - */ - private LocalDate(int year, int month, int dayOfMonth) { - this.year = year; - this.month = (short) month; - this.day = (short) dayOfMonth; - } - - /** - * Gets the year field. - *

- * This method returns the primitive {@code int} value for the year. - *

- * The year returned by this method is proleptic as per {@code get(YEAR)}. - * To obtain the year-of-era, use {@code get(YEAR_OF_ERA}. - * - * @return the year, from MIN_YEAR to MAX_YEAR - */ - public int getYear() { - return year; - } - - /** - * Gets the month-of-year field as an int from 1 to 12. - * - * @return the month-of-year - */ - public int getMonth() { - return month; - } - - /** - * Gets the day-of-month field. - *

- * This method returns the primitive {@code int} value for the day-of-month. - * - * @return the day-of-month, from 1 to 31 - */ - public int getDayOfMonth() { - return day; - } - - /** - * Gets the day-of-week field, which is an int from 1 to 7. - * - * @return the day-of-week - */ - public int getDayOfWeek() { - return (int)floorMod(toEpochDay() + 3, 7) + 1; - } - - /** - * Returns a copy of this {@code LocalDate} with the specified number of days added. - *

- * This method adds the specified amount to the days field incrementing the - * month and year fields as necessary to ensure the result remains valid. - * The result is only invalid if the maximum/minimum year is exceeded. - *

- * For example, 2008-12-31 plus one day would result in 2009-01-01. - *

- * This instance is immutable and unaffected by this method call. - * - * @param daysToAdd the days to add, may be negative - * @return a {@code LocalDate} based on this date with the days added, not null - * @throws DateTimeException if the result exceeds the supported date range - */ - public LocalDate plusDays(long daysToAdd) { - if (daysToAdd == 0) { - return this; - } - long mjDay = addExact(toEpochDay(), daysToAdd); - return LocalDate.ofEpochDay(mjDay); - } - - /** - * Returns a copy of this {@code LocalDate} with the specified number of days subtracted. - *

- * This method subtracts the specified amount from the days field decrementing the - * month and year fields as necessary to ensure the result remains valid. - * The result is only invalid if the maximum/minimum year is exceeded. - *

- * For example, 2009-01-01 minus one day would result in 2008-12-31. - *

- * This instance is immutable and unaffected by this method call. - * - * @param daysToSubtract the days to subtract, may be negative - * @return a {@code LocalDate} based on this date with the days subtracted, not null - * @throws DateTimeException if the result exceeds the supported date range - */ - public LocalDate minusDays(long daysToSubtract) { - return (daysToSubtract == Long.MIN_VALUE ? plusDays(Long.MAX_VALUE).plusDays(1) : plusDays(-daysToSubtract)); - } - - /** - * Obtains an instance of {@code LocalDate} from the epoch day count. - *

- * The Epoch Day count is a simple incrementing count of days - * where day 0 is 1970-01-01. Negative numbers represent earlier days. - * - * @param epochDay the Epoch Day to convert, based on the epoch 1970-01-01 - * @return the local date, not null - * @throws DateTimeException if the epoch days exceeds the supported date range - */ - public static LocalDate ofEpochDay(long epochDay) { - long zeroDay = epochDay + DAYS_0000_TO_1970; - // find the march-based year - zeroDay -= 60; // adjust to 0000-03-01 so leap day is at end of four year cycle - long adjust = 0; - if (zeroDay < 0) { - // adjust negative years to positive for calculation - long adjustCycles = (zeroDay + 1) / DAYS_PER_CYCLE - 1; - adjust = adjustCycles * 400; - zeroDay += -adjustCycles * DAYS_PER_CYCLE; - } - long yearEst = (400 * zeroDay + 591) / DAYS_PER_CYCLE; - long doyEst = zeroDay - (365 * yearEst + yearEst / 4 - yearEst / 100 + yearEst / 400); - if (doyEst < 0) { - // fix estimate - yearEst--; - doyEst = zeroDay - (365 * yearEst + yearEst / 4 - yearEst / 100 + yearEst / 400); - } - yearEst += adjust; // reset any negative year - int marchDoy0 = (int) doyEst; - - // convert march-based values back to january-based - int marchMonth0 = (marchDoy0 * 5 + 2) / 153; - int month = (marchMonth0 + 2) % 12 + 1; - int dom = marchDoy0 - (marchMonth0 * 306 + 5) / 10 + 1; - yearEst += marchMonth0 / 10; - - // check year now we are certain it is correct - int year = YEAR.checkValidValue((int)yearEst); - return new LocalDate(year, month, dom); - } - - public long toEpochDay() { - long y = year; - long m = month; - long total = 0; - total += 365 * y; - if (y >= 0) { - total += (y + 3) / 4 - (y + 99) / 100 + (y + 399) / 400; - } else { - total -= y / -4 - y / -100 + y / -400; - } - total += ((367 * m - 362) / 12); - total += day - 1; - if (m > 2) { - total--; - if (isLeapYear(year) == false) { - total--; - } - } - return total - DAYS_0000_TO_1970; - } - - /** - * Compares this date to another date. - *

- * The comparison is primarily based on the date, from earliest to latest. - * It is "consistent with equals", as defined by {@link Comparable}. - *

- * If all the dates being compared are instances of {@code LocalDate}, - * then the comparison will be entirely based on the date. - * If some dates being compared are in different chronologies, then the - * chronology is also considered, see {@link java.time.temporal.ChronoLocalDate#compareTo}. - * - * @param other the other date to compare to, not null - * @return the comparator value, negative if less, positive if greater - */ - public int compareTo(LocalDate otherDate) { - int cmp = (year - otherDate.year); - if (cmp == 0) { - cmp = (month - otherDate.month); - if (cmp == 0) { - cmp = (day - otherDate.day); - } - } - return cmp; - } - - /** - * Checks if this date is equal to another date. - *

- * Compares this {@code LocalDate} with another ensuring that the date is the same. - *

- * Only objects of type {@code LocalDate} are compared, other types return false. - * To compare the dates of two {@code TemporalAccessor} instances, including dates - * in two different chronologies, use {@link ChronoField#EPOCH_DAY} as a comparator. - * - * @param obj the object to check, null returns false - * @return true if this is equal to the other date - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof LocalDate) { - return compareTo((LocalDate) obj) == 0; - } - return false; - } - - /** - * A hash code for this date. - * - * @return a suitable hash code - */ - @Override - public int hashCode() { - int yearValue = year; - int monthValue = month; - int dayValue = day; - return (yearValue & 0xFFFFF800) ^ ((yearValue << 11) + (monthValue << 6) + (dayValue)); - } - -} diff --git a/jdk/make/src/classes/build/tools/tzdb/LocalDateTime.java b/jdk/make/src/classes/build/tools/tzdb/LocalDateTime.java deleted file mode 100644 index ced37b72613..00000000000 --- a/jdk/make/src/classes/build/tools/tzdb/LocalDateTime.java +++ /dev/null @@ -1,427 +0,0 @@ -/* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This file is available under and governed by the GNU General Public - * License version 2 only, as published by the Free Software Foundation. - * However, the following notice accompanied the original version of this - * file: - * - * Copyright (c) 2007-2012, Stephen Colebourne & Michael Nascimento Santos - * - * 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 JSR-310 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. - */ -package build.tools.tzdb; - -import static build.tools.tzdb.Utils.*; -import static build.tools.tzdb.LocalTime.HOURS_PER_DAY; -import static build.tools.tzdb.LocalTime.MICROS_PER_DAY; -import static build.tools.tzdb.LocalTime.MILLIS_PER_DAY; -import static build.tools.tzdb.LocalTime.MINUTES_PER_DAY; -import static build.tools.tzdb.LocalTime.SECONDS_PER_DAY; -import static build.tools.tzdb.LocalTime.SECONDS_PER_MINUTE; -import static build.tools.tzdb.LocalTime.SECONDS_PER_HOUR; - -import java.util.Objects; - -/** - * A date-time without a time-zone in the ISO-8601 calendar system, - * such as {@code 2007-12-03T10:15:30}. - * - * @since 1.8 - */ -final class LocalDateTime { - - /** - * The minimum supported {@code LocalDateTime}, '-999999999-01-01T00:00:00'. - * This is the local date-time of midnight at the start of the minimum date. - * This combines {@link LocalDate#MIN} and {@link LocalTime#MIN}. - * This could be used by an application as a "far past" date-time. - */ - public static final LocalDateTime MIN = LocalDateTime.of(LocalDate.MIN, LocalTime.MIN); - /** - * The maximum supported {@code LocalDateTime}, '+999999999-12-31T23:59:59.999999999'. - * This is the local date-time just before midnight at the end of the maximum date. - * This combines {@link LocalDate#MAX} and {@link LocalTime#MAX}. - * This could be used by an application as a "far future" date-time. - */ - public static final LocalDateTime MAX = LocalDateTime.of(LocalDate.MAX, LocalTime.MAX); - - /** - * The date part. - */ - private final LocalDate date; - /** - * The time part. - */ - private final LocalTime time; - - /** - * Obtains an instance of {@code LocalDateTime} from year, month, - * day, hour and minute, setting the second and nanosecond to zero. - *

- * The day must be valid for the year and month, otherwise an exception will be thrown. - * The second and nanosecond fields will be set to zero. - * - * @param year the year to represent, from MIN_YEAR to MAX_YEAR - * @param month the month-of-year to represent, from 1 (January) to 12 (December) - * @param dayOfMonth the day-of-month to represent, from 1 to 31 - * @param hour the hour-of-day to represent, from 0 to 23 - * @param minute the minute-of-hour to represent, from 0 to 59 - * @return the local date-time, not null - * @throws DateTimeException if the value of any field is out of range - * @throws DateTimeException if the day-of-month is invalid for the month-year - */ - public static LocalDateTime of(int year, int month, int dayOfMonth, int hour, int minute) { - LocalDate date = LocalDate.of(year, month, dayOfMonth); - LocalTime time = LocalTime.of(hour, minute); - return new LocalDateTime(date, time); - } - - /** - * Obtains an instance of {@code LocalDateTime} from a date and time. - * - * @param date the local date, not null - * @param time the local time, not null - * @return the local date-time, not null - */ - public static LocalDateTime of(LocalDate date, LocalTime time) { - Objects.requireNonNull(date, "date"); - Objects.requireNonNull(time, "time"); - return new LocalDateTime(date, time); - } - - /** - * Obtains an instance of {@code LocalDateTime} using seconds from the - * epoch of 1970-01-01T00:00:00Z. - *

- * This allows the {@link ChronoField#INSTANT_SECONDS epoch-second} field - * to be converted to a local date-time. This is primarily intended for - * low-level conversions rather than general application usage. - * - * @param epochSecond the number of seconds from the epoch of 1970-01-01T00:00:00Z - * @param nanoOfSecond the nanosecond within the second, from 0 to 999,999,999 - * @param offset the zone offset, not null - * @return the local date-time, not null - * @throws DateTimeException if the result exceeds the supported range - */ - public static LocalDateTime ofEpochSecond(long epochSecond, int nanoOfSecond, ZoneOffset offset) { - Objects.requireNonNull(offset, "offset"); - long localSecond = epochSecond + offset.getTotalSeconds(); // overflow caught later - long localEpochDay = floorDiv(localSecond, SECONDS_PER_DAY); - int secsOfDay = (int)floorMod(localSecond, SECONDS_PER_DAY); - LocalDate date = LocalDate.ofEpochDay(localEpochDay); - LocalTime time = LocalTime.ofSecondOfDay(secsOfDay); // ignore nano - return new LocalDateTime(date, time); - } - - /** - * Constructor. - * - * @param date the date part of the date-time, validated not null - * @param time the time part of the date-time, validated not null - */ - private LocalDateTime(LocalDate date, LocalTime time) { - this.date = date; - this.time = time; - } - - /** - * Returns a copy of this date-time with the new date and time, checking - * to see if a new object is in fact required. - * - * @param newDate the date of the new date-time, not null - * @param newTime the time of the new date-time, not null - * @return the date-time, not null - */ - private LocalDateTime with(LocalDate newDate, LocalTime newTime) { - if (date == newDate && time == newTime) { - return this; - } - return new LocalDateTime(newDate, newTime); - } - - /** - * Gets the {@code LocalDate} part of this date-time. - *

- * This returns a {@code LocalDate} with the same year, month and day - * as this date-time. - * - * @return the date part of this date-time, not null - */ - public LocalDate getDate() { - return date; - } - - /** - * Gets the year field. - *

- * This method returns the primitive {@code int} value for the year. - *

- * The year returned by this method is proleptic as per {@code get(YEAR)}. - * To obtain the year-of-era, use {@code get(YEAR_OF_ERA}. - * - * @return the year, from MIN_YEAR to MAX_YEAR - */ - public int getYear() { - return date.getYear(); - } - - /** - * Gets the month-of-year field as an int from 1 to 12. - * - * @return the month-of-year - */ - public int getMonth() { - return date.getMonth(); - } - - /** - * Gets the day-of-month field. - *

- * This method returns the primitive {@code int} value for the day-of-month. - * - * @return the day-of-month, from 1 to 31 - */ - public int getDayOfMonth() { - return date.getDayOfMonth(); - } - - /** - * Gets the day-of-week field, which is an integer from 1 to 7. - * - * @return the day-of-week, from 1 to 7 - */ - public int getDayOfWeek() { - return date.getDayOfWeek(); - } - - /** - * Gets the {@code LocalTime} part of this date-time. - *

- * This returns a {@code LocalTime} with the same hour, minute, second and - * nanosecond as this date-time. - * - * @return the time part of this date-time, not null - */ - public LocalTime getTime() { - return time; - } - - /** - * Gets the hour-of-day field. - * - * @return the hour-of-day, from 0 to 23 - */ - public int getHour() { - return time.getHour(); - } - - /** - * Gets the minute-of-hour field. - * - * @return the minute-of-hour, from 0 to 59 - */ - public int getMinute() { - return time.getMinute(); - } - - /** - * Gets the second-of-minute field. - * - * @return the second-of-minute, from 0 to 59 - */ - public int getSecond() { - return time.getSecond(); - } - - /** - * Converts this date-time to the number of seconds from the epoch - * of 1970-01-01T00:00:00Z. - *

- * This combines this local date-time and the specified offset to calculate the - * epoch-second value, which is the number of elapsed seconds from 1970-01-01T00:00:00Z. - * Instants on the time-line after the epoch are positive, earlier are negative. - *

- * This default implementation calculates from the epoch-day of the date and the - * second-of-day of the time. - * - * @param offset the offset to use for the conversion, not null - * @return the number of seconds from the epoch of 1970-01-01T00:00:00Z - */ - public long toEpochSecond(ZoneOffset offset) { - Objects.requireNonNull(offset, "offset"); - long epochDay = getDate().toEpochDay(); - long secs = epochDay * 86400 + getTime().toSecondOfDay(); - secs -= offset.getTotalSeconds(); - return secs; - } - - /** - * Returns a copy of this {@code LocalDateTime} with the specified period in days added. - *

- * This method adds the specified amount to the days field incrementing the - * month and year fields as necessary to ensure the result remains valid. - * The result is only invalid if the maximum/minimum year is exceeded. - *

- * For example, 2008-12-31 plus one day would result in 2009-01-01. - *

- * This instance is immutable and unaffected by this method call. - * - * @param days the days to add, may be negative - * @return a {@code LocalDateTime} based on this date-time with the days added, not null - * @throws DateTimeException if the result exceeds the supported date range - */ - public LocalDateTime plusDays(long days) { - LocalDate newDate = date.plusDays(days); - return with(newDate, time); - } - - /** - * Returns a copy of this {@code LocalDateTime} with the specified period in seconds added. - *

- * This instance is immutable and unaffected by this method call. - * - * @param seconds the seconds to add, may be negative - * @return a {@code LocalDateTime} based on this date-time with the seconds added, not null - * @throws DateTimeException if the result exceeds the supported date range - */ - public LocalDateTime plusSeconds(long seconds) { - return plusWithOverflow(date, 0, 0, seconds, 1); - } - - /** - * Returns a copy of this {@code LocalDateTime} with the specified period added. - *

- * This instance is immutable and unaffected by this method call. - * - * @param newDate the new date to base the calculation on, not null - * @param hours the hours to add, may be negative - * @param minutes the minutes to add, may be negative - * @param seconds the seconds to add, may be negative - * @param nanos the nanos to add, may be negative - * @param sign the sign to determine add or subtract - * @return the combined result, not null - */ - private LocalDateTime plusWithOverflow(LocalDate newDate, long hours, long minutes, long seconds, int sign) { - if ((hours | minutes | seconds) == 0) { - return with(newDate, time); - } - long totDays = seconds / SECONDS_PER_DAY + // max/24*60*60 - minutes / MINUTES_PER_DAY + // max/24*60 - hours / HOURS_PER_DAY; // max/24 - totDays *= sign; // total max*0.4237... - long totSecs = (seconds % SECONDS_PER_DAY) + - (minutes % MINUTES_PER_DAY) * SECONDS_PER_MINUTE + - (hours % HOURS_PER_DAY) * SECONDS_PER_HOUR; - long curSoD = time.toSecondOfDay(); - totSecs = totSecs * sign + curSoD; // total 432000000000000 - totDays += floorDiv(totSecs, SECONDS_PER_DAY); - - int newSoD = (int)floorMod(totSecs, SECONDS_PER_DAY); - LocalTime newTime = (newSoD == curSoD ? time : LocalTime.ofSecondOfDay(newSoD)); - return with(newDate.plusDays(totDays), newTime); - } - - /** - * Compares this date-time to another date-time. - *

- * The comparison is primarily based on the date-time, from earliest to latest. - * It is "consistent with equals", as defined by {@link Comparable}. - *

- * If all the date-times being compared are instances of {@code LocalDateTime}, - * then the comparison will be entirely based on the date-time. - * If some dates being compared are in different chronologies, then the - * chronology is also considered, see {@link ChronoLocalDateTime#compareTo}. - * - * @param other the other date-time to compare to, not null - * @return the comparator value, negative if less, positive if greater - */ - public int compareTo(LocalDateTime other) { - int cmp = date.compareTo(other.getDate()); - if (cmp == 0) { - cmp = time.compareTo(other.getTime()); - } - return cmp; - } - - /** - * Checks if this date-time is equal to another date-time. - *

- * Compares this {@code LocalDateTime} with another ensuring that the date-time is the same. - * Only objects of type {@code LocalDateTime} are compared, other types return false. - * - * @param obj the object to check, null returns false - * @return true if this is equal to the other date-time - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof LocalDateTime) { - LocalDateTime other = (LocalDateTime) obj; - return date.equals(other.date) && time.equals(other.time); - } - return false; - } - - /** - * A hash code for this date-time. - * - * @return a suitable hash code - */ - @Override - public int hashCode() { - return date.hashCode() ^ time.hashCode(); - } - -} diff --git a/jdk/make/src/classes/build/tools/tzdb/LocalTime.java b/jdk/make/src/classes/build/tools/tzdb/LocalTime.java deleted file mode 100644 index 0fc31868944..00000000000 --- a/jdk/make/src/classes/build/tools/tzdb/LocalTime.java +++ /dev/null @@ -1,388 +0,0 @@ -/* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This file is available under and governed by the GNU General Public - * License version 2 only, as published by the Free Software Foundation. - * However, the following notice accompanied the original version of this - * file: - * - * Copyright (c) 2007-2012, Stephen Colebourne & Michael Nascimento Santos - * - * 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 JSR-310 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. - */ -package build.tools.tzdb; - -import static build.tools.tzdb.ChronoField.HOUR_OF_DAY; -import static build.tools.tzdb.ChronoField.MINUTE_OF_HOUR; -import static build.tools.tzdb.ChronoField.SECOND_OF_MINUTE; -import static build.tools.tzdb.ChronoField.SECOND_OF_DAY; - -import java.util.Objects; - -/** - * A time without time-zone in the ISO-8601 calendar system, - * such as {@code 10:15:30}. - * - */ -final class LocalTime { - - /** - * The minimum supported {@code LocalTime}, '00:00'. - * This is the time of midnight at the start of the day. - */ - public static final LocalTime MIN; - /** - * The minimum supported {@code LocalTime}, '23:59:59.999999999'. - * This is the time just before midnight at the end of the day. - */ - public static final LocalTime MAX; - /** - * The time of midnight at the start of the day, '00:00'. - */ - public static final LocalTime MIDNIGHT; - /** - * The time of noon in the middle of the day, '12:00'. - */ - public static final LocalTime NOON; - /** - * Constants for the local time of each hour. - */ - private static final LocalTime[] HOURS = new LocalTime[24]; - static { - for (int i = 0; i < HOURS.length; i++) { - HOURS[i] = new LocalTime(i, 0, 0); - } - MIDNIGHT = HOURS[0]; - NOON = HOURS[12]; - MIN = HOURS[0]; - MAX = new LocalTime(23, 59, 59); - } - - /** - * Hours per day. - */ - static final int HOURS_PER_DAY = 24; - /** - * Minutes per hour. - */ - static final int MINUTES_PER_HOUR = 60; - /** - * Minutes per day. - */ - static final int MINUTES_PER_DAY = MINUTES_PER_HOUR * HOURS_PER_DAY; - /** - * Seconds per minute. - */ - static final int SECONDS_PER_MINUTE = 60; - /** - * Seconds per hour. - */ - static final int SECONDS_PER_HOUR = SECONDS_PER_MINUTE * MINUTES_PER_HOUR; - /** - * Seconds per day. - */ - static final int SECONDS_PER_DAY = SECONDS_PER_HOUR * HOURS_PER_DAY; - /** - * Milliseconds per day. - */ - static final long MILLIS_PER_DAY = SECONDS_PER_DAY * 1000L; - /** - * Microseconds per day. - */ - static final long MICROS_PER_DAY = SECONDS_PER_DAY * 1000_000L; - - /** - * The hour. - */ - private final byte hour; - /** - * The minute. - */ - private final byte minute; - /** - * The second. - */ - private final byte second; - - /** - * Obtains an instance of {@code LocalTime} from an hour and minute. - *

- * The second and nanosecond fields will be set to zero by this factory method. - *

- * This factory may return a cached value, but applications must not rely on this. - * - * @param hour the hour-of-day to represent, from 0 to 23 - * @param minute the minute-of-hour to represent, from 0 to 59 - * @return the local time, not null - * @throws DateTimeException if the value of any field is out of range - */ - public static LocalTime of(int hour, int minute) { - HOUR_OF_DAY.checkValidValue(hour); - if (minute == 0) { - return HOURS[hour]; // for performance - } - MINUTE_OF_HOUR.checkValidValue(minute); - return new LocalTime(hour, minute, 0); - } - - /** - * Obtains an instance of {@code LocalTime} from an hour, minute and second. - *

- * The nanosecond field will be set to zero by this factory method. - *

- * This factory may return a cached value, but applications must not rely on this. - * - * @param hour the hour-of-day to represent, from 0 to 23 - * @param minute the minute-of-hour to represent, from 0 to 59 - * @param second the second-of-minute to represent, from 0 to 59 - * @return the local time, not null - * @throws DateTimeException if the value of any field is out of range - */ - public static LocalTime of(int hour, int minute, int second) { - HOUR_OF_DAY.checkValidValue(hour); - if ((minute | second) == 0) { - return HOURS[hour]; // for performance - } - MINUTE_OF_HOUR.checkValidValue(minute); - SECOND_OF_MINUTE.checkValidValue(second); - return new LocalTime(hour, minute, second); - } - - /** - * Obtains an instance of {@code LocalTime} from a second-of-day value. - *

- * This factory may return a cached value, but applications must not rely on this. - * - * @param secondOfDay the second-of-day, from {@code 0} to {@code 24 * 60 * 60 - 1} - * @return the local time, not null - * @throws DateTimeException if the second-of-day value is invalid - */ - public static LocalTime ofSecondOfDay(int secondOfDay) { - SECOND_OF_DAY.checkValidValue(secondOfDay); - int hours = secondOfDay / SECONDS_PER_HOUR; - secondOfDay -= hours * SECONDS_PER_HOUR; - int minutes = secondOfDay / SECONDS_PER_MINUTE; - secondOfDay -= minutes * SECONDS_PER_MINUTE; - return create(hours, minutes, secondOfDay); - } - - - /** - * Creates a local time from the hour, minute, second and nanosecond fields. - *

- * This factory may return a cached value, but applications must not rely on this. - * - * @param hour the hour-of-day to represent, validated from 0 to 23 - * @param minute the minute-of-hour to represent, validated from 0 to 59 - * @param second the second-of-minute to represent, validated from 0 to 59 - * @return the local time, not null - */ - private static LocalTime create(int hour, int minute, int second) { - if ((minute | second) == 0) { - return HOURS[hour]; - } - return new LocalTime(hour, minute, second); - } - - /** - * Constructor, previously validated. - * - * @param hour the hour-of-day to represent, validated from 0 to 23 - * @param minute the minute-of-hour to represent, validated from 0 to 59 - * @param second the second-of-minute to represent, validated from 0 to 59 - */ - private LocalTime(int hour, int minute, int second) { - this.hour = (byte) hour; - this.minute = (byte) minute; - this.second = (byte) second; - } - - /** - * Gets the hour-of-day field. - * - * @return the hour-of-day, from 0 to 23 - */ - public int getHour() { - return hour; - } - - /** - * Gets the minute-of-hour field. - * - * @return the minute-of-hour, from 0 to 59 - */ - public int getMinute() { - return minute; - } - - /** - * Gets the second-of-minute field. - * - * @return the second-of-minute, from 0 to 59 - */ - public int getSecond() { - return second; - } - - /** - * Returns a copy of this {@code LocalTime} with the specified period in seconds added. - *

- * This adds the specified number of seconds to this time, returning a new time. - * The calculation wraps around midnight. - *

- * This instance is immutable and unaffected by this method call. - * - * @param secondstoAdd the seconds to add, may be negative - * @return a {@code LocalTime} based on this time with the seconds added, not null - */ - public LocalTime plusSeconds(long secondstoAdd) { - if (secondstoAdd == 0) { - return this; - } - int sofd = hour * SECONDS_PER_HOUR + - minute * SECONDS_PER_MINUTE + second; - int newSofd = ((int) (secondstoAdd % SECONDS_PER_DAY) + sofd + SECONDS_PER_DAY) % SECONDS_PER_DAY; - if (sofd == newSofd) { - return this; - } - int newHour = newSofd / SECONDS_PER_HOUR; - int newMinute = (newSofd / SECONDS_PER_MINUTE) % MINUTES_PER_HOUR; - int newSecond = newSofd % SECONDS_PER_MINUTE; - return create(newHour, newMinute, newSecond); - } - - /** - * Returns a copy of this {@code LocalTime} with the specified period in seconds subtracted. - *

- * This subtracts the specified number of seconds from this time, returning a new time. - * The calculation wraps around midnight. - *

- * This instance is immutable and unaffected by this method call. - * - * @param secondsToSubtract the seconds to subtract, may be negative - * @return a {@code LocalTime} based on this time with the seconds subtracted, not null - */ - public LocalTime minusSeconds(long secondsToSubtract) { - return plusSeconds(-(secondsToSubtract % SECONDS_PER_DAY)); - } - - /** - * Extracts the time as seconds of day, - * from {@code 0} to {@code 24 * 60 * 60 - 1}. - * - * @return the second-of-day equivalent to this time - */ - public int toSecondOfDay() { - int total = hour * SECONDS_PER_HOUR; - total += minute * SECONDS_PER_MINUTE; - total += second; - return total; - } - - /** - * Compares this {@code LocalTime} to another time. - *

- * The comparison is based on the time-line position of the local times within a day. - * It is "consistent with equals", as defined by {@link Comparable}. - * - * @param other the other time to compare to, not null - * @return the comparator value, negative if less, positive if greater - * @throws NullPointerException if {@code other} is null - */ - public int compareTo(LocalTime other) { - int cmp = Integer.compare(hour, other.hour); - if (cmp == 0) { - cmp = Integer.compare(minute, other.minute); - if (cmp == 0) { - cmp = Integer.compare(second, other.second); - } - } - return cmp; - } - - /** - * Checks if this time is equal to another time. - *

- * The comparison is based on the time-line position of the time within a day. - *

- * Only objects of type {@code LocalTime} are compared, other types return false. - * To compare the date of two {@code TemporalAccessor} instances, use - * {@link ChronoField#NANO_OF_DAY} as a comparator. - * - * @param obj the object to check, null returns false - * @return true if this is equal to the other time - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof LocalTime) { - LocalTime other = (LocalTime) obj; - return hour == other.hour && minute == other.minute && - second == other.second; - } - return false; - } - - /** - * A hash code for this time. - * - * @return a suitable hash code - */ - @Override - public int hashCode() { - long sod = toSecondOfDay(); - return (int) (sod ^ (sod >>> 32)); - } - -} diff --git a/jdk/make/src/classes/build/tools/tzdb/TimeDefinition.java b/jdk/make/src/classes/build/tools/tzdb/TimeDefinition.java deleted file mode 100644 index 8a5853db3d7..00000000000 --- a/jdk/make/src/classes/build/tools/tzdb/TimeDefinition.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This file is available under and governed by the GNU General Public - * License version 2 only, as published by the Free Software Foundation. - * However, the following notice accompanied the original version of this - * file: - * - * Copyright (c) 2009-2012, Stephen Colebourne & Michael Nascimento Santos - * - * 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 JSR-310 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. - */ -package build.tools.tzdb; - -import java.util.Objects; - -/** - * A definition of the way a local time can be converted to the actual - * transition date-time. - *

- * Time zone rules are expressed in one of three ways: - *

    - *
  • Relative to UTC
  • - *
  • Relative to the standard offset in force
  • - *
  • Relative to the wall offset (what you would see on a clock on the wall)
  • - *

- */ -public enum TimeDefinition { - /** The local date-time is expressed in terms of the UTC offset. */ - UTC, - /** The local date-time is expressed in terms of the wall offset. */ - WALL, - /** The local date-time is expressed in terms of the standard offset. */ - STANDARD; - - /** - * Converts the specified local date-time to the local date-time actually - * seen on a wall clock. - *

- * This method converts using the type of this enum. - * The output is defined relative to the 'before' offset of the transition. - *

- * The UTC type uses the UTC offset. - * The STANDARD type uses the standard offset. - * The WALL type returns the input date-time. - * The result is intended for use with the wall-offset. - * - * @param dateTime the local date-time, not null - * @param standardOffset the standard offset, not null - * @param wallOffset the wall offset, not null - * @return the date-time relative to the wall/before offset, not null - */ - public LocalDateTime createDateTime(LocalDateTime dateTime, ZoneOffset standardOffset, ZoneOffset wallOffset) { - switch (this) { - case UTC: { - int difference = wallOffset.getTotalSeconds() - ZoneOffset.UTC.getTotalSeconds(); - return dateTime.plusSeconds(difference); - } - case STANDARD: { - int difference = wallOffset.getTotalSeconds() - standardOffset.getTotalSeconds(); - return dateTime.plusSeconds(difference); - } - default: // WALL - return dateTime; - } - } - -} diff --git a/jdk/make/src/classes/build/tools/tzdb/TzdbZoneRulesCompiler.java b/jdk/make/src/classes/build/tools/tzdb/TzdbZoneRulesCompiler.java index 9f1204ca7fe..8cbdd0d44ff 100644 --- a/jdk/make/src/classes/build/tools/tzdb/TzdbZoneRulesCompiler.java +++ b/jdk/make/src/classes/build/tools/tzdb/TzdbZoneRulesCompiler.java @@ -56,8 +56,6 @@ */ package build.tools.tzdb; -import static build.tools.tzdb.Utils.*; - import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; import java.nio.charset.StandardCharsets; @@ -179,15 +177,41 @@ public final class TzdbZoneRulesCompiler { System.exit(1); System.err.println("Source directory does not contain file: VERSION"); } + + // load source files printVerbose("Compiling TZDB version " + version); - // parse source files - for (Path file : srcFiles) { - printVerbose("Parsing file: " + file); - parseFile(file); - } + TzdbZoneRulesProvider provider = new TzdbZoneRulesProvider(srcFiles); + // build zone rules printVerbose("Building rules"); - buildZoneRules(); + + // Build the rules, zones and links into real zones. + SortedMap builtZones = new TreeMap<>(); + + // build zones + for (String zoneId : provider.getZoneIds()) { + printVerbose("Building zone " + zoneId); + builtZones.put(zoneId, provider.getZoneRules(zoneId)); + } + + // build aliases + Map links = provider.getAliasMap(); + for (String aliasId : links.keySet()) { + String realId = links.get(aliasId); + printVerbose("Linking alias " + aliasId + " to " + realId); + ZoneRules realRules = builtZones.get(realId); + if (realRules == null) { + realId = links.get(realId); // try again (handle alias liked to alias) + printVerbose("Relinking alias " + aliasId + " to " + realId); + realRules = builtZones.get(realId); + if (realRules == null) { + throw new IllegalArgumentException("Alias '" + aliasId + "' links to invalid zone '" + realId); + } + links.put(aliasId, realId); + } + builtZones.put(aliasId, realRules); + } + // output to file printVerbose("Outputting tzdb file: " + dstFile); outputFile(dstFile, version, builtZones, links); @@ -269,361 +293,13 @@ public final class TzdbZoneRulesCompiler { } } - private static final Pattern YEAR = Pattern.compile("(?i)(?min)|(?max)|(?only)|(?[0-9]+)"); - private static final Pattern MONTH = Pattern.compile("(?i)(jan)|(feb)|(mar)|(apr)|(may)|(jun)|(jul)|(aug)|(sep)|(oct)|(nov)|(dec)"); - private static final Matcher DOW = Pattern.compile("(?i)(mon)|(tue)|(wed)|(thu)|(fri)|(sat)|(sun)").matcher(""); - private static final Matcher TIME = Pattern.compile("(?-)?+(?[0-9]{1,2})(:(?[0-5][0-9]))?+(:(?[0-5][0-9]))?+").matcher(""); - - /** The TZDB rules. */ - private final Map> rules = new HashMap<>(); - - /** The TZDB zones. */ - private final Map> zones = new HashMap<>(); - - /** The TZDB links. */ - private final Map links = new HashMap<>(); - - /** The built zones. */ - private final SortedMap builtZones = new TreeMap<>(); - /** Whether to output verbose messages. */ private boolean verbose; /** * private contructor */ - private TzdbZoneRulesCompiler() { - } - - /** - * Parses a source file. - * - * @param file the file being read, not null - * @throws Exception if an error occurs - */ - private void parseFile(Path file) throws Exception { - int lineNumber = 1; - String line = null; - try { - List lines = Files.readAllLines(file, StandardCharsets.ISO_8859_1); - List openZone = null; - for (; lineNumber < lines.size(); lineNumber++) { - line = lines.get(lineNumber); - int index = line.indexOf('#'); // remove comments (doesn't handle # in quotes) - if (index >= 0) { - line = line.substring(0, index); - } - if (line.trim().length() == 0) { // ignore blank lines - continue; - } - Scanner s = new Scanner(line); - if (openZone != null && Character.isWhitespace(line.charAt(0)) && s.hasNext()) { - if (parseZoneLine(s, openZone)) { - openZone = null; - } - } else { - if (s.hasNext()) { - String first = s.next(); - if (first.equals("Zone")) { - openZone = new ArrayList<>(); - try { - zones.put(s.next(), openZone); - if (parseZoneLine(s, openZone)) { - openZone = null; - } - } catch (NoSuchElementException x) { - printVerbose("Invalid Zone line in file: " + file + ", line: " + line); - throw new IllegalArgumentException("Invalid Zone line"); - } - } else { - openZone = null; - if (first.equals("Rule")) { - try { - parseRuleLine(s); - } catch (NoSuchElementException x) { - printVerbose("Invalid Rule line in file: " + file + ", line: " + line); - throw new IllegalArgumentException("Invalid Rule line"); - } - } else if (first.equals("Link")) { - try { - String realId = s.next(); - String aliasId = s.next(); - links.put(aliasId, realId); - } catch (NoSuchElementException x) { - printVerbose("Invalid Link line in file: " + file + ", line: " + line); - throw new IllegalArgumentException("Invalid Link line"); - } - - } else { - throw new IllegalArgumentException("Unknown line"); - } - } - } - } - } - } catch (Exception ex) { - throw new Exception("Failed while parsing file '" + file + "' on line " + lineNumber + " '" + line + "'", ex); - } - } - - /** - * Parses a Rule line. - * - * @param s the line scanner, not null - */ - private void parseRuleLine(Scanner s) { - TZDBRule rule = new TZDBRule(); - String name = s.next(); - if (rules.containsKey(name) == false) { - rules.put(name, new ArrayList()); - } - rules.get(name).add(rule); - rule.startYear = parseYear(s, 0); - rule.endYear = parseYear(s, rule.startYear); - if (rule.startYear > rule.endYear) { - throw new IllegalArgumentException("Year order invalid: " + rule.startYear + " > " + rule.endYear); - } - parseOptional(s.next()); // type is unused - parseMonthDayTime(s, rule); - rule.savingsAmount = parsePeriod(s.next()); - rule.text = parseOptional(s.next()); - } - - /** - * Parses a Zone line. - * - * @param s the line scanner, not null - * @return true if the zone is complete - */ - private boolean parseZoneLine(Scanner s, List zoneList) { - TZDBZone zone = new TZDBZone(); - zoneList.add(zone); - zone.standardOffset = parseOffset(s.next()); - String savingsRule = parseOptional(s.next()); - if (savingsRule == null) { - zone.fixedSavingsSecs = 0; - zone.savingsRule = null; - } else { - try { - zone.fixedSavingsSecs = parsePeriod(savingsRule); - zone.savingsRule = null; - } catch (Exception ex) { - zone.fixedSavingsSecs = null; - zone.savingsRule = savingsRule; - } - } - zone.text = s.next(); - if (s.hasNext()) { - zone.year = Integer.parseInt(s.next()); - if (s.hasNext()) { - parseMonthDayTime(s, zone); - } - return false; - } else { - return true; - } - } - - /** - * Parses a Rule line. - * - * @param s the line scanner, not null - * @param mdt the object to parse into, not null - */ - private void parseMonthDayTime(Scanner s, TZDBMonthDayTime mdt) { - mdt.month = parseMonth(s); - if (s.hasNext()) { - String dayRule = s.next(); - if (dayRule.startsWith("last")) { - mdt.dayOfMonth = -1; - mdt.dayOfWeek = parseDayOfWeek(dayRule.substring(4)); - mdt.adjustForwards = false; - } else { - int index = dayRule.indexOf(">="); - if (index > 0) { - mdt.dayOfWeek = parseDayOfWeek(dayRule.substring(0, index)); - dayRule = dayRule.substring(index + 2); - } else { - index = dayRule.indexOf("<="); - if (index > 0) { - mdt.dayOfWeek = parseDayOfWeek(dayRule.substring(0, index)); - mdt.adjustForwards = false; - dayRule = dayRule.substring(index + 2); - } - } - mdt.dayOfMonth = Integer.parseInt(dayRule); - } - if (s.hasNext()) { - String timeStr = s.next(); - int secsOfDay = parseSecs(timeStr); - if (secsOfDay == 86400) { - mdt.endOfDay = true; - secsOfDay = 0; - } - LocalTime time = LocalTime.ofSecondOfDay(secsOfDay); - mdt.time = time; - mdt.timeDefinition = parseTimeDefinition(timeStr.charAt(timeStr.length() - 1)); - } - } - } - - private int parseYear(Scanner s, int defaultYear) { - if (s.hasNext(YEAR)) { - s.next(YEAR); - MatchResult mr = s.match(); - if (mr.group(1) != null) { - return 1900; // systemv has min - } else if (mr.group(2) != null) { - return YEAR_MAX_VALUE; - } else if (mr.group(3) != null) { - return defaultYear; - } - return Integer.parseInt(mr.group(4)); - /* - if (mr.group("min") != null) { - //return YEAR_MIN_VALUE; - return 1900; // systemv has min - } else if (mr.group("max") != null) { - return YEAR_MAX_VALUE; - } else if (mr.group("only") != null) { - return defaultYear; - } - return Integer.parseInt(mr.group("year")); - */ - } - throw new IllegalArgumentException("Unknown year: " + s.next()); - } - - private int parseMonth(Scanner s) { - if (s.hasNext(MONTH)) { - s.next(MONTH); - for (int moy = 1; moy < 13; moy++) { - if (s.match().group(moy) != null) { - return moy; - } - } - } - throw new IllegalArgumentException("Unknown month: " + s.next()); - } - - private int parseDayOfWeek(String str) { - if (DOW.reset(str).matches()) { - for (int dow = 1; dow < 8; dow++) { - if (DOW.group(dow) != null) { - return dow; - } - } - } - throw new IllegalArgumentException("Unknown day-of-week: " + str); - } - - private String parseOptional(String str) { - return str.equals("-") ? null : str; - } - - private int parseSecs(String str) { - if (str.equals("-")) { - return 0; - } - try { - if (TIME.reset(str).find()) { - int secs = Integer.parseInt(TIME.group("hour")) * 60 * 60; - if (TIME.group("minute") != null) { - secs += Integer.parseInt(TIME.group("minute")) * 60; - } - if (TIME.group("second") != null) { - secs += Integer.parseInt(TIME.group("second")); - } - if (TIME.group("neg") != null) { - secs = -secs; - } - return secs; - } - } catch (NumberFormatException x) {} - throw new IllegalArgumentException(str); - } - - private ZoneOffset parseOffset(String str) { - int secs = parseSecs(str); - return ZoneOffset.ofTotalSeconds(secs); - } - - private int parsePeriod(String str) { - return parseSecs(str); - } - - private TimeDefinition parseTimeDefinition(char c) { - switch (c) { - case 's': - case 'S': - // standard time - return TimeDefinition.STANDARD; - case 'u': - case 'U': - case 'g': - case 'G': - case 'z': - case 'Z': - // UTC - return TimeDefinition.UTC; - case 'w': - case 'W': - default: - // wall time - return TimeDefinition.WALL; - } - } - - /** - * Build the rules, zones and links into real zones. - * - * @throws Exception if an error occurs - */ - private void buildZoneRules() throws Exception { - // build zones - for (String zoneId : zones.keySet()) { - printVerbose("Building zone " + zoneId); - List tzdbZones = zones.get(zoneId); - ZoneRulesBuilder bld = new ZoneRulesBuilder(); - for (TZDBZone tzdbZone : tzdbZones) { - bld = tzdbZone.addToBuilder(bld, rules); - } - builtZones.put(zoneId, bld.toRules(zoneId)); - } - - // build aliases - for (String aliasId : links.keySet()) { - String realId = links.get(aliasId); - printVerbose("Linking alias " + aliasId + " to " + realId); - ZoneRules realRules = builtZones.get(realId); - if (realRules == null) { - realId = links.get(realId); // try again (handle alias liked to alias) - printVerbose("Relinking alias " + aliasId + " to " + realId); - realRules = builtZones.get(realId); - if (realRules == null) { - throw new IllegalArgumentException("Alias '" + aliasId + "' links to invalid zone '" + realId); - } - links.put(aliasId, realId); - } - builtZones.put(aliasId, realRules); - } - // remove UTC and GMT - // builtZones.remove("UTC"); - // builtZones.remove("GMT"); - // builtZones.remove("GMT0"); - builtZones.remove("GMT+0"); - builtZones.remove("GMT-0"); - links.remove("GMT+0"); - links.remove("GMT-0"); - // remove ROC, which is not supported in j.u.tz - builtZones.remove("ROC"); - links.remove("ROC"); - // remove EST, HST and MST. They are supported via - // the short-id mapping - builtZones.remove("EST"); - builtZones.remove("HST"); - builtZones.remove("MST"); - } + private TzdbZoneRulesCompiler() {} /** * Prints a verbose message. @@ -635,109 +311,4 @@ public final class TzdbZoneRulesCompiler { System.out.println(message); } } - - /** - * Class representing a month-day-time in the TZDB file. - */ - abstract class TZDBMonthDayTime { - /** The month of the cutover. */ - int month = 1; - /** The day-of-month of the cutover. */ - int dayOfMonth = 1; - /** Whether to adjust forwards. */ - boolean adjustForwards = true; - /** The day-of-week of the cutover. */ - int dayOfWeek = -1; - /** The time of the cutover. */ - LocalTime time = LocalTime.MIDNIGHT; - /** Whether this is midnight end of day. */ - boolean endOfDay; - /** The time of the cutover. */ - TimeDefinition timeDefinition = TimeDefinition.WALL; - void adjustToFowards(int year) { - if (adjustForwards == false && dayOfMonth > 0) { - LocalDate adjustedDate = LocalDate.of(year, month, dayOfMonth).minusDays(6); - dayOfMonth = adjustedDate.getDayOfMonth(); - month = adjustedDate.getMonth(); - adjustForwards = true; - } - } - } - - /** - * Class representing a rule line in the TZDB file. - */ - final class TZDBRule extends TZDBMonthDayTime { - /** The start year. */ - int startYear; - /** The end year. */ - int endYear; - /** The amount of savings. */ - int savingsAmount; - /** The text name of the zone. */ - String text; - - void addToBuilder(ZoneRulesBuilder bld) { - adjustToFowards(2004); // irrelevant, treat as leap year - bld.addRuleToWindow(startYear, endYear, month, dayOfMonth, dayOfWeek, time, endOfDay, timeDefinition, savingsAmount); - } - } - - /** - * Class representing a linked set of zone lines in the TZDB file. - */ - final class TZDBZone extends TZDBMonthDayTime { - /** The standard offset. */ - ZoneOffset standardOffset; - /** The fixed savings amount. */ - Integer fixedSavingsSecs; - /** The savings rule. */ - String savingsRule; - /** The text name of the zone. */ - String text; - /** The year of the cutover. */ - int year = YEAR_MAX_VALUE; - - ZoneRulesBuilder addToBuilder(ZoneRulesBuilder bld, Map> rules) { - if (year != YEAR_MAX_VALUE) { - bld.addWindow(standardOffset, toDateTime(year), timeDefinition); - } else { - bld.addWindowForever(standardOffset); - } - if (fixedSavingsSecs != null) { - bld.setFixedSavingsToWindow(fixedSavingsSecs); - } else { - List tzdbRules = rules.get(savingsRule); - if (tzdbRules == null) { - throw new IllegalArgumentException("Rule not found: " + savingsRule); - } - for (TZDBRule tzdbRule : tzdbRules) { - tzdbRule.addToBuilder(bld); - } - } - return bld; - } - - private LocalDateTime toDateTime(int year) { - adjustToFowards(year); - LocalDate date; - if (dayOfMonth == -1) { - dayOfMonth = lengthOfMonth(month, isLeapYear(year)); - date = LocalDate.of(year, month, dayOfMonth); - if (dayOfWeek != -1) { - date = previousOrSame(date, dayOfWeek); - } - } else { - date = LocalDate.of(year, month, dayOfMonth); - if (dayOfWeek != -1) { - date = nextOrSame(date, dayOfWeek); - } - } - LocalDateTime ldt = LocalDateTime.of(date, time); - if (endOfDay) { - ldt = ldt.plusDays(1); - } - return ldt; - } - } } diff --git a/jdk/make/src/classes/build/tools/tzdb/TzdbZoneRulesProvider.java b/jdk/make/src/classes/build/tools/tzdb/TzdbZoneRulesProvider.java new file mode 100644 index 00000000000..220de9276c7 --- /dev/null +++ b/jdk/make/src/classes/build/tools/tzdb/TzdbZoneRulesProvider.java @@ -0,0 +1,843 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + + +package build.tools.tzdb; + +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.NavigableMap; +import java.util.Objects; +import java.util.Set; +import java.util.TreeMap; +import java.util.TreeSet; +import java.util.concurrent.ConcurrentHashMap; +import java.time.*; +import java.time.Year; +import java.time.chrono.IsoChronology; +import java.time.temporal.TemporalAdjusters; +import java.time.zone.ZoneOffsetTransition; +import java.time.zone.ZoneOffsetTransitionRule; +import java.time.zone.ZoneOffsetTransitionRule.TimeDefinition; +import java.time.zone.ZoneRulesException; + +/** + * Compile and build time-zone rules from IANA timezone data + * + * @author Xueming Shen + * @author Stephen Colebourne + * @author Michael Nascimento Santos + * + * @since 1.9 + */ + +class TzdbZoneRulesProvider { + + /** + * Creates an instance. + * + * @throws ZoneRulesException if unable to load + */ + public TzdbZoneRulesProvider(List files) { + try { + load(files); + } catch (Exception ex) { + throw new ZoneRulesException("Unable to load TZDB time-zone rules", ex); + } + } + + public Set getZoneIds() { + return new TreeSet(regionIds); + } + + public Map getAliasMap() { + return links; + } + + public ZoneRules getZoneRules(String zoneId) { + Object obj = zones.get(zoneId); + if (obj == null) { + String zoneId0 = zoneId; + if (links.containsKey(zoneId)) { + zoneId = links.get(zoneId); + obj = zones.get(zoneId); + } + if (obj == null) { + throw new ZoneRulesException("Unknown time-zone ID: " + zoneId0); + } + } + if (obj instanceof ZoneRules) { + return (ZoneRules)obj; + } + try { + ZoneRules zrules = buildRules(zoneId, (List)obj); + zones.put(zoneId, zrules); + return zrules; + } catch (Exception ex) { + throw new ZoneRulesException( + "Invalid binary time-zone data: TZDB:" + zoneId, ex); + } + } + + ////////////////////////////////////////////////////////////////////// + + /** + * All the regions that are available. + */ + private List regionIds = new ArrayList<>(600); + + /** + * Zone region to rules mapping + */ + private final Map zones = new ConcurrentHashMap<>(); + + /** + * compatibility list + */ + private static HashSet excludedZones; + static { + // (1) exclude EST, HST and MST. They are supported + // via the short-id mapping + // (2) remove UTC and GMT + // (3) remove ROC, which is not supported in j.u.tz + excludedZones = new HashSet<>(10); + excludedZones.add("EST"); + excludedZones.add("HST"); + excludedZones.add("MST"); + excludedZones.add("GMT+0"); + excludedZones.add("GMT-0"); + excludedZones.add("ROC"); + } + + private Map links = new HashMap<>(150); + private Map> rules = new HashMap<>(500); + + private void load(List files) throws IOException { + + for (Path file : files) { + List openZone = null; + try { + for (String line : Files.readAllLines(file, StandardCharsets.ISO_8859_1)) { + if (line.length() == 0 || line.charAt(0) == '#') { + continue; + } + //StringIterator itr = new StringIterator(line); + String[] tokens = split(line); + if (openZone != null && // continuing zone line + Character.isWhitespace(line.charAt(0)) && + tokens.length > 0) { + ZoneLine zLine = new ZoneLine(); + openZone.add(zLine); + if (zLine.parse(tokens, 0)) { + openZone = null; + } + continue; + } + if (line.startsWith("Zone")) { // parse Zone line + String name = tokens[1]; + if (excludedZones.contains(name)){ + continue; + } + if (zones.containsKey(name)) { + throw new IllegalArgumentException( + "Duplicated zone name in file: " + name + + ", line: [" + line + "]"); + } + openZone = new ArrayList<>(10); + zones.put(name, openZone); + regionIds.add(name); + ZoneLine zLine = new ZoneLine(); + openZone.add(zLine); + if (zLine.parse(tokens, 2)) { + openZone = null; + } + } else if (line.startsWith("Rule")) { // parse Rule line + String name = tokens[1]; + if (!rules.containsKey(name)) { + rules.put(name, new ArrayList(10)); + } + rules.get(name).add(new RuleLine().parse(tokens)); + } else if (line.startsWith("Link")) { // parse link line + if (tokens.length >= 3) { + String realId = tokens[1]; + String aliasId = tokens[2]; + if (excludedZones.contains(aliasId)){ + continue; + } + links.put(aliasId, realId); + regionIds.add(aliasId); + } else { + throw new IllegalArgumentException( + "Invalid Link line in file" + + file + ", line: [" + line + "]"); + } + } else { + // skip unknown line + } + } + + } catch (Exception ex) { + throw new RuntimeException("Failed while processing file [" + file + + "]", ex); + } + } + } + + private String[] split(String str) { + int off = 0; + int end = str.length(); + ArrayList list = new ArrayList<>(10); + while (off < end) { + char c = str.charAt(off); + if (c == '\t' || c == ' ') { + off++; + continue; + } + if (c == '#') { // comment + break; + } + int start = off; + while (off < end) { + c = str.charAt(off); + if (c == ' ' || c == '\t') { + break; + } + off++; + } + if (start != off) { + list.add(str.substring(start, off)); + } + } + return list.toArray(new String[list.size()]); + } + + /** + * Class representing a month-day-time in the TZDB file. + */ + private static abstract class MonthDayTime { + /** The month of the cutover. */ + Month month = Month.JANUARY; + + /** The day-of-month of the cutover. */ + int dayOfMonth = 1; + + /** Whether to adjust forwards. */ + boolean adjustForwards = true; + + /** The day-of-week of the cutover. */ + DayOfWeek dayOfWeek; + + /** The time of the cutover, in second of day */ + int secsOfDay = 0; + + /** Whether this is midnight end of day. */ + boolean endOfDay; + /** The time of the cutover. */ + + TimeDefinition timeDefinition = TimeDefinition.WALL; + + void adjustToForwards(int year) { + if (adjustForwards == false && dayOfMonth > 0) { + // weekDay<=monthDay case, don't have it in tzdb data for now + LocalDate adjustedDate = LocalDate.of(year, month, dayOfMonth).minusDays(6); + dayOfMonth = adjustedDate.getDayOfMonth(); + month = adjustedDate.getMonth(); + adjustForwards = true; + } + } + + LocalDateTime toDateTime(int year) { + LocalDate date; + if (dayOfMonth < 0) { + int monthLen = month.length(IsoChronology.INSTANCE.isLeapYear(year)); + date = LocalDate.of(year, month, monthLen + 1 + dayOfMonth); + if (dayOfWeek != null) { + date = date.with(TemporalAdjusters.previousOrSame(dayOfWeek)); + } + } else { + date = LocalDate.of(year, month, dayOfMonth); + if (dayOfWeek != null) { + date = date.with(TemporalAdjusters.nextOrSame(dayOfWeek)); + } + } + if (endOfDay) { + date = date.plusDays(1); + } + return LocalDateTime.of(date, LocalTime.ofSecondOfDay(secsOfDay)); + } + + /** + * Parses the MonthDaytime segment of a tzdb line. + */ + private void parse(String[] tokens, int off) { + month = parseMonth(tokens[off++]); + if (off < tokens.length) { + String dayRule = tokens[off++]; + if (dayRule.startsWith("last")) { + dayOfMonth = -1; + dayOfWeek = parseDayOfWeek(dayRule.substring(4)); + adjustForwards = false; + } else { + int index = dayRule.indexOf(">="); + if (index > 0) { + dayOfWeek = parseDayOfWeek(dayRule.substring(0, index)); + dayRule = dayRule.substring(index + 2); + } else { + index = dayRule.indexOf("<="); + if (index > 0) { + dayOfWeek = parseDayOfWeek(dayRule.substring(0, index)); + adjustForwards = false; + dayRule = dayRule.substring(index + 2); + } + } + dayOfMonth = Integer.parseInt(dayRule); + if (dayOfMonth < -28 || dayOfMonth > 31 || dayOfMonth == 0) { + throw new IllegalArgumentException( + "Day of month indicator must be between -28 and 31 inclusive excluding zero"); + } + } + if (off < tokens.length) { + String timeStr = tokens[off++]; + secsOfDay = parseSecs(timeStr); + if (secsOfDay == 86400) { + // time must be midnight when end of day flag is true + endOfDay = true; + secsOfDay = 0; + } + timeDefinition = parseTimeDefinition(timeStr.charAt(timeStr.length() - 1)); + } + } + } + + int parseYear(String year, int defaultYear) { + switch (year.toLowerCase()) { + case "min": return 1900; + case "max": return Year.MAX_VALUE; + case "only": return defaultYear; + } + return Integer.parseInt(year); + } + + Month parseMonth(String mon) { + switch (mon) { + case "Jan": return Month.JANUARY; + case "Feb": return Month.FEBRUARY; + case "Mar": return Month.MARCH; + case "Apr": return Month.APRIL; + case "May": return Month.MAY; + case "Jun": return Month.JUNE; + case "Jul": return Month.JULY; + case "Aug": return Month.AUGUST; + case "Sep": return Month.SEPTEMBER; + case "Oct": return Month.OCTOBER; + case "Nov": return Month.NOVEMBER; + case "Dec": return Month.DECEMBER; + } + throw new IllegalArgumentException("Unknown month: " + mon); + } + + DayOfWeek parseDayOfWeek(String dow) { + switch (dow) { + case "Mon": return DayOfWeek.MONDAY; + case "Tue": return DayOfWeek.TUESDAY; + case "Wed": return DayOfWeek.WEDNESDAY; + case "Thu": return DayOfWeek.THURSDAY; + case "Fri": return DayOfWeek.FRIDAY; + case "Sat": return DayOfWeek.SATURDAY; + case "Sun": return DayOfWeek.SUNDAY; + } + throw new IllegalArgumentException("Unknown day-of-week: " + dow); + } + + String parseOptional(String str) { + return str.equals("-") ? null : str; + } + + static final boolean isDigit(char c) { + return c >= '0' && c <= '9'; + } + + private int parseSecs(String time) { + if (time.equals("-")) { + return 0; + } + // faster hack + int secs = 0; + int sign = 1; + int off = 0; + int len = time.length(); + if (off < len && time.charAt(off) == '-') { + sign = -1; + off++; + } + char c0, c1; + if (off < len && isDigit(c0 = time.charAt(off++))) { + int hour = c0 - '0'; + if (off < len && isDigit(c1 = time.charAt(off))) { + hour = hour * 10 + c1 - '0'; + off++; + } + secs = hour * 60 * 60; + if (off < len && time.charAt(off++) == ':') { + if (off + 1 < len && + isDigit(c0 = time.charAt(off++)) && + isDigit(c1 = time.charAt(off++))) { + // minutes + secs += ((c0 - '0') * 10 + c1 - '0') * 60; + if (off < len && time.charAt(off++) == ':') { + if (off + 1 < len && + isDigit(c0 = time.charAt(off++)) && + isDigit(c1 = time.charAt(off++))) { + // seconds + secs += ((c0 - '0') * 10 + c1 - '0'); + } + } + } + + } + return secs * sign; + } + throw new IllegalArgumentException("[" + time + "]"); + } + + int parseOffset(String str) { + int secs = parseSecs(str); + if (Math.abs(secs) > 18 * 60 * 60) { + throw new IllegalArgumentException( + "Zone offset not in valid range: -18:00 to +18:00"); + } + return secs; + } + + int parsePeriod(String str) { + return parseSecs(str); + } + + TimeDefinition parseTimeDefinition(char c) { + switch (c) { + case 's': + case 'S': + // standard time + return TimeDefinition.STANDARD; + case 'u': + case 'U': + case 'g': + case 'G': + case 'z': + case 'Z': + // UTC + return TimeDefinition.UTC; + case 'w': + case 'W': + default: + // wall time + return TimeDefinition.WALL; + } + } + } + + /** + * Class representing a rule line in the TZDB file. + */ + private static class RuleLine extends MonthDayTime { + /** The start year. */ + int startYear; + + /** The end year. */ + int endYear; + + /** The amount of savings, in seconds. */ + int savingsAmount; + + /** The text name of the zone. */ + String text; + + /** + * Converts this to a transition rule. + * + * @param standardOffset the active standard offset, not null + * @param savingsBeforeSecs the active savings before the transition in seconds + * @return the transition, not null + */ + ZoneOffsetTransitionRule toTransitionRule(ZoneOffset stdOffset, int savingsBefore) { + // rule shared by different zones, so don't change it + Month month = this.month; + int dayOfMonth = this.dayOfMonth; + DayOfWeek dayOfWeek = this.dayOfWeek; + boolean endOfDay = this.endOfDay; + + // optimize stored format + if (dayOfMonth < 0) { + if (month != Month.FEBRUARY) { // not Month.FEBRUARY + dayOfMonth = month.maxLength() - 6; + } + } + if (endOfDay && dayOfMonth > 0 && + (dayOfMonth == 28 && month == Month.FEBRUARY) == false) { + LocalDate date = LocalDate.of(2004, month, dayOfMonth).plusDays(1); // leap-year + month = date.getMonth(); + dayOfMonth = date.getDayOfMonth(); + if (dayOfWeek != null) { + dayOfWeek = dayOfWeek.plus(1); + } + endOfDay = false; + } + // build rule + return ZoneOffsetTransitionRule.of( + //month, dayOfMonth, dayOfWeek, time, endOfDay, timeDefinition, + month, dayOfMonth, dayOfWeek, + LocalTime.ofSecondOfDay(secsOfDay), endOfDay, timeDefinition, + stdOffset, + ZoneOffset.ofTotalSeconds(stdOffset.getTotalSeconds() + savingsBefore), + ZoneOffset.ofTotalSeconds(stdOffset.getTotalSeconds() + savingsAmount)); + } + + RuleLine parse(String[] tokens) { + startYear = parseYear(tokens[2], 0); + endYear = parseYear(tokens[3], startYear); + if (startYear > endYear) { + throw new IllegalArgumentException( + "Invalid line/Year order invalid:" + startYear + " > " + endYear); + } + //parseOptional(s.next()); // type is unused + super.parse(tokens, 5); // monthdaytime parsing + savingsAmount = parsePeriod(tokens[8]); + //rule.text = parseOptional(s.next()); + return this; + } + } + + /** + * Class representing a linked set of zone lines in the TZDB file. + */ + private static class ZoneLine extends MonthDayTime { + /** The standard offset. */ + int stdOffsetSecs; + + /** The fixed savings amount. */ + int fixedSavingsSecs = 0; + + /** The savings rule. */ + String savingsRule; + + /** The text name of the zone. */ + String text; + + /** The cutover year */ + int year = Year.MAX_VALUE; + + /** The cutover date time */ + LocalDateTime ldt; + + /** The cutover date/time in epoch seconds/UTC */ + long ldtSecs = Long.MIN_VALUE; + + LocalDateTime toDateTime() { + if (ldt == null) { + ldt = toDateTime(year); + } + return ldt; + } + + /** + * Creates the date-time epoch second in the wall offset for the local + * date-time at the end of the window. + * + * @param savingsSecs the amount of savings in use in seconds + * @return the created date-time epoch second in the wall offset, not null + */ + long toDateTimeEpochSecond(int savingsSecs) { + if (ldtSecs == Long.MIN_VALUE) { + ldtSecs = toDateTime().toEpochSecond(ZoneOffset.UTC); + } + switch(timeDefinition) { + case UTC: return ldtSecs; + case STANDARD: return ldtSecs - stdOffsetSecs; + default: return ldtSecs - (stdOffsetSecs + savingsSecs); // WALL + } + } + + boolean parse(String[] tokens, int off) { + stdOffsetSecs = parseOffset(tokens[off++]); + savingsRule = parseOptional(tokens[off++]); + if (savingsRule != null && savingsRule.length() > 0 && + (savingsRule.charAt(0) == '-' || isDigit(savingsRule.charAt(0)))) { + try { + fixedSavingsSecs = parsePeriod(savingsRule); + savingsRule = null; + } catch (Exception ex) { + fixedSavingsSecs = 0; + } + } + text = tokens[off++]; + if (off < tokens.length) { + year = Integer.parseInt(tokens[off++]); + if (off < tokens.length) { + super.parse(tokens, off); // MonthDayTime + } + return false; + } else { + return true; + } + } + } + + /** + * Class representing a rule line in the TZDB file for a particular year. + */ + private static class TransRule implements Comparable + { + private int year; + private RuleLine rule; + + /** The trans date/time */ + private LocalDateTime ldt; + + /** The trans date/time in epoch seconds (assume UTC) */ + long ldtSecs; + + TransRule(int year, RuleLine rule) { + this.year = year; + this.rule = rule; + this.ldt = rule.toDateTime(year); + this.ldtSecs = ldt.toEpochSecond(ZoneOffset.UTC); + } + + ZoneOffsetTransition toTransition(ZoneOffset standardOffset, int savingsBeforeSecs) { + // copy of code in ZoneOffsetTransitionRule to avoid infinite loop + ZoneOffset wallOffset = ZoneOffset.ofTotalSeconds( + standardOffset.getTotalSeconds() + savingsBeforeSecs); + ZoneOffset offsetAfter = ZoneOffset.ofTotalSeconds( + standardOffset.getTotalSeconds() + rule.savingsAmount); + LocalDateTime dt = rule.timeDefinition + .createDateTime(ldt, standardOffset, wallOffset); + return ZoneOffsetTransition.of(dt, wallOffset, offsetAfter); + } + + long toEpochSecond(ZoneOffset stdOffset, int savingsBeforeSecs) { + switch(rule.timeDefinition) { + case UTC: return ldtSecs; + case STANDARD: return ldtSecs - stdOffset.getTotalSeconds(); + default: return ldtSecs - (stdOffset.getTotalSeconds() + savingsBeforeSecs); // WALL + } + } + + /** + * Tests if this a real transition with the active savings in seconds + * + * @param savingsBefore the active savings in seconds + * @return true, if savings changes + */ + boolean isTransition(int savingsBefore) { + return rule.savingsAmount != savingsBefore; + } + + public int compareTo(TransRule other) { + return (ldtSecs < other.ldtSecs)? -1 : ((ldtSecs == other.ldtSecs) ? 0 : 1); + } + } + + private ZoneRules buildRules(String zoneId, List zones) { + if (zones.isEmpty()) { + throw new IllegalStateException("No available zone window"); + } + final List standardTransitionList = new ArrayList<>(4); + final List transitionList = new ArrayList<>(256); + final List lastTransitionRuleList = new ArrayList<>(2); + + final ZoneLine zone0 = zones.get(0); + // initialize the standard offset, wallOffset and savings for loop + + //ZoneOffset stdOffset = zone0.standardOffset; + ZoneOffset stdOffset = ZoneOffset.ofTotalSeconds(zone0.stdOffsetSecs); + + int savings = zone0.fixedSavingsSecs; + ZoneOffset wallOffset = ZoneOffset.ofTotalSeconds(stdOffset.getTotalSeconds() + savings); + + // start ldt of each zone window + LocalDateTime zoneStart = LocalDateTime.MIN; + + // first stanard offset + ZoneOffset firstStdOffset = stdOffset; + // first wall offset + ZoneOffset firstWallOffset = wallOffset; + + for (ZoneLine zone : zones) { + // check if standard offset changed, update it if yes + ZoneOffset stdOffsetPrev = stdOffset; // for effectiveSavings check + if (zone.stdOffsetSecs != stdOffset.getTotalSeconds()) { + ZoneOffset stdOffsetNew = ZoneOffset.ofTotalSeconds(zone.stdOffsetSecs); + standardTransitionList.add( + ZoneOffsetTransition.of( + LocalDateTime.ofEpochSecond(zoneStart.toEpochSecond(wallOffset), + 0, + stdOffset), + stdOffset, + stdOffsetNew)); + stdOffset = stdOffsetNew; + } + + LocalDateTime zoneEnd; + if (zone.year == Year.MAX_VALUE) { + zoneEnd = LocalDateTime.MAX; + } else { + zoneEnd = zone.toDateTime(); + } + if (zoneEnd.compareTo(zoneStart) < 0) { + throw new IllegalStateException("Windows must be in date-time order: " + + zoneEnd + " < " + zoneStart); + } + // calculate effective savings at the start of the window + List trules = null; + List lastRules = null; + + int effectiveSavings = zone.fixedSavingsSecs; + if (zone.savingsRule != null) { + List tzdbRules = rules.get(zone.savingsRule); + if (tzdbRules == null) { + throw new IllegalArgumentException(" not found: " + + zone.savingsRule); + } + trules = new ArrayList<>(256); + lastRules = new ArrayList<>(2); + int lastRulesStartYear = Year.MIN_VALUE; + + // merge the rules to transitions + for (RuleLine rule : tzdbRules) { + if (rule.startYear > zoneEnd.getYear()) { + // rules will not be used for this zone entry + continue; + } + rule.adjustToForwards(2004); // irrelevant, treat as leap year + + int startYear = rule.startYear; + int endYear = rule.endYear; + if (zoneEnd.equals(LocalDateTime.MAX)) { + if (endYear == Year.MAX_VALUE) { + endYear = startYear; + lastRules.add(new TransRule(endYear, rule)); + lastRulesStartYear = Math.max(startYear, lastRulesStartYear); + } + } else { + if (endYear == Year.MAX_VALUE) { + //endYear = zoneEnd.getYear(); + endYear = zone.year; + } + } + int year = startYear; + while (year <= endYear) { + trules.add(new TransRule(year, rule)); + year++; + } + } + + // last rules, fill the gap years between different last rules + if (zoneEnd.equals(LocalDateTime.MAX)) { + lastRulesStartYear = Math.max(lastRulesStartYear, zoneStart.getYear()) + 1; + for (TransRule rule : lastRules) { + if (rule.year <= lastRulesStartYear) { + int year = rule.year; + while (year <= lastRulesStartYear) { + trules.add(new TransRule(year, rule.rule)); + year++; + } + rule.year = lastRulesStartYear; + rule.ldt = rule.rule.toDateTime(year); + rule.ldtSecs = rule.ldt.toEpochSecond(ZoneOffset.UTC); + } + } + Collections.sort(lastRules); + } + // sort the merged rules + Collections.sort(trules); + + effectiveSavings = 0; + for (TransRule rule : trules) { + if (rule.toEpochSecond(stdOffsetPrev, savings) > + zoneStart.toEpochSecond(wallOffset)) { + // previous savings amount found, which could be the + // savings amount at the instant that the window starts + // (hence isAfter) + break; + } + effectiveSavings = rule.rule.savingsAmount; + } + } + // check if the start of the window represents a transition + ZoneOffset effectiveWallOffset = + ZoneOffset.ofTotalSeconds(stdOffset.getTotalSeconds() + effectiveSavings); + + if (!wallOffset.equals(effectiveWallOffset)) { + transitionList.add(ZoneOffsetTransition.of(zoneStart, + wallOffset, + effectiveWallOffset)); + } + savings = effectiveSavings; + // apply rules within the window + if (trules != null) { + long zoneStartEpochSecs = zoneStart.toEpochSecond(wallOffset); + for (TransRule trule : trules) { + if (trule.isTransition(savings)) { + long epochSecs = trule.toEpochSecond(stdOffset, savings); + if (epochSecs < zoneStartEpochSecs || + epochSecs >= zone.toDateTimeEpochSecond(savings)) { + continue; + } + transitionList.add(trule.toTransition(stdOffset, savings)); + savings = trule.rule.savingsAmount; + } + } + } + if (lastRules != null) { + for (TransRule trule : lastRules) { + lastTransitionRuleList.add(trule.rule.toTransitionRule(stdOffset, savings)); + savings = trule.rule.savingsAmount; + } + } + + // finally we can calculate the true end of the window, passing it to the next window + wallOffset = ZoneOffset.ofTotalSeconds(stdOffset.getTotalSeconds() + savings); + zoneStart = LocalDateTime.ofEpochSecond(zone.toDateTimeEpochSecond(savings), + 0, + wallOffset); + } + return new ZoneRules(firstStdOffset, + firstWallOffset, + standardTransitionList, + transitionList, + lastTransitionRuleList); + } + +} diff --git a/jdk/make/src/classes/build/tools/tzdb/Utils.java b/jdk/make/src/classes/build/tools/tzdb/Utils.java deleted file mode 100644 index d129dd3bc7f..00000000000 --- a/jdk/make/src/classes/build/tools/tzdb/Utils.java +++ /dev/null @@ -1,176 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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. - */ - -/* - * Copyright (c) 2009-2012, Stephen Colebourne & Michael Nascimento Santos - * - * 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 JSR-310 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. - */ -package build.tools.tzdb; - -import java.util.Objects; - -class Utils { - - // Returns the largest (closest to positive infinity) - public static long floorDiv(long x, long y) { - long r = x / y; - // if the signs are different and modulo not zero, round down - if ((x ^ y) < 0 && (r * y != x)) { - r--; - } - return r; - } - - // Returns the floor modulus of the {@code long} arguments. - public static long floorMod(long x, long y) { - return x - floorDiv(x, y) * y; - } - - // Returns the sum of its arguments, - public static long addExact(long x, long y) { - long r = x + y; - // HD 2-12 Overflow iff both arguments have the opposite sign of the result - if (((x ^ r) & (y ^ r)) < 0) { - throw new ArithmeticException("long overflow"); - } - return r; - } - - // Year - - // Returns true if the specified year is a leap year. - public static boolean isLeapYear(int year) { - return ((year & 3) == 0) && ((year % 100) != 0 || (year % 400) == 0); - } - - // The minimum supported year, '-999,999,999'. - public static final int YEAR_MIN_VALUE = -999_999_999; - - // The maximum supported year, '+999,999,999'. - public static final int YEAR_MAX_VALUE = 999_999_999; - - - // Gets the length of the specified month in days. - public static int lengthOfMonth(int month, boolean leapYear) { - switch (month) { - case 2: //FEBRUARY: - return (leapYear ? 29 : 28); - case 4: //APRIL: - case 6: //JUNE: - case 9: //SEPTEMBER: - case 11: //NOVEMBER: - return 30; - default: - return 31; - } - } - - // Gets the maximum length of the specified month in days. - public static int maxLengthOfMonth(int month) { - switch (month) { - case 2: //FEBRUARY: - return 29; - case 4: //APRIL: - case 6: //JUNE: - case 9: //SEPTEMBER: - case 11: //NOVEMBER: - return 30; - default: - return 31; - } - } - - // DayOfWeek - - // Returns the day-of-week that is the specified number of days after - // this one, from 1 to 7 for Monday to Sunday. - public static int plusDayOfWeek(int dow, long days) { - int amount = (int) (days % 7); - return (dow - 1 + (amount + 7)) % 7 + 1; - } - - // Returns the day-of-week that is the specified number of days before - // this one, from 1 to 7 for Monday to Sunday. - public static int minusDayOfWeek(int dow, long days) { - return plusDayOfWeek(dow, -(days % 7)); - } - - // Adjusts the date to the first occurrence of the specified day-of-week - // before the date being adjusted unless it is already on that day in - // which case the same object is returned. - public static LocalDate previousOrSame(LocalDate date, int dayOfWeek) { - return adjust(date, dayOfWeek, 1); - } - - // Adjusts the date to the first occurrence of the specified day-of-week - // after the date being adjusted unless it is already on that day in - // which case the same object is returned. - public static LocalDate nextOrSame(LocalDate date, int dayOfWeek) { - return adjust(date, dayOfWeek, 0); - } - - // Implementation of next, previous or current day-of-week. - // @param relative whether the current date is a valid answer - private static final LocalDate adjust(LocalDate date, int dow, int relative) { - int calDow = date.getDayOfWeek(); - if (relative < 2 && calDow == dow) { - return date; - } - if ((relative & 1) == 0) { - int daysDiff = calDow - dow; - return date.plusDays(daysDiff >= 0 ? 7 - daysDiff : -daysDiff); - } else { - int daysDiff = dow - calDow; - return date.minusDays(daysDiff >= 0 ? 7 - daysDiff : -daysDiff); - } - } - -} diff --git a/jdk/make/src/classes/build/tools/tzdb/ZoneOffset.java b/jdk/make/src/classes/build/tools/tzdb/ZoneOffset.java deleted file mode 100644 index 4f95fb3dd59..00000000000 --- a/jdk/make/src/classes/build/tools/tzdb/ZoneOffset.java +++ /dev/null @@ -1,474 +0,0 @@ -/* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This file is available under and governed by the GNU General Public - * License version 2 only, as published by the Free Software Foundation. - * However, the following notice accompanied the original version of this - * file: - * - * Copyright (c) 2007-2012, Stephen Colebourne & Michael Nascimento Santos - * - * 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 JSR-310 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. - */ -package build.tools.tzdb; - -import java.util.Objects; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; - -/** - * A time-zone offset from Greenwich/UTC, such as {@code +02:00}. - *

- * A time-zone offset is the period of time that a time-zone differs from Greenwich/UTC. - * This is usually a fixed number of hours and minutes. - * - * @since 1.8 - */ -final class ZoneOffset implements Comparable { - - /** Cache of time-zone offset by offset in seconds. */ - private static final ConcurrentMap SECONDS_CACHE = new ConcurrentHashMap<>(16, 0.75f, 4); - /** Cache of time-zone offset by ID. */ - private static final ConcurrentMap ID_CACHE = new ConcurrentHashMap<>(16, 0.75f, 4); - - /** - * The number of seconds per hour. - */ - private static final int SECONDS_PER_HOUR = 60 * 60; - /** - * The number of seconds per minute. - */ - private static final int SECONDS_PER_MINUTE = 60; - /** - * The number of minutes per hour. - */ - private static final int MINUTES_PER_HOUR = 60; - /** - * The abs maximum seconds. - */ - private static final int MAX_SECONDS = 18 * SECONDS_PER_HOUR; - /** - * Serialization version. - */ - private static final long serialVersionUID = 2357656521762053153L; - - /** - * The time-zone offset for UTC, with an ID of 'Z'. - */ - public static final ZoneOffset UTC = ZoneOffset.ofTotalSeconds(0); - /** - * Constant for the maximum supported offset. - */ - public static final ZoneOffset MIN = ZoneOffset.ofTotalSeconds(-MAX_SECONDS); - /** - * Constant for the maximum supported offset. - */ - public static final ZoneOffset MAX = ZoneOffset.ofTotalSeconds(MAX_SECONDS); - - /** - * The total offset in seconds. - */ - private final int totalSeconds; - /** - * The string form of the time-zone offset. - */ - private final transient String id; - - //----------------------------------------------------------------------- - /** - * Obtains an instance of {@code ZoneOffset} using the ID. - *

- * This method parses the string ID of a {@code ZoneOffset} to - * return an instance. The parsing accepts all the formats generated by - * {@link #getId()}, plus some additional formats: - *

    - *
  • {@code Z} - for UTC - *
  • {@code +h} - *
  • {@code +hh} - *
  • {@code +hh:mm} - *
  • {@code -hh:mm} - *
  • {@code +hhmm} - *
  • {@code -hhmm} - *
  • {@code +hh:mm:ss} - *
  • {@code -hh:mm:ss} - *
  • {@code +hhmmss} - *
  • {@code -hhmmss} - *

- * Note that ± means either the plus or minus symbol. - *

- * The ID of the returned offset will be normalized to one of the formats - * described by {@link #getId()}. - *

- * The maximum supported range is from +18:00 to -18:00 inclusive. - * - * @param offsetId the offset ID, not null - * @return the zone-offset, not null - * @throws DateTimeException if the offset ID is invalid - */ - @SuppressWarnings("fallthrough") - public static ZoneOffset of(String offsetId) { - Objects.requireNonNull(offsetId, "offsetId"); - // "Z" is always in the cache - ZoneOffset offset = ID_CACHE.get(offsetId); - if (offset != null) { - return offset; - } - - // parse - +h, +hh, +hhmm, +hh:mm, +hhmmss, +hh:mm:ss - final int hours, minutes, seconds; - switch (offsetId.length()) { - case 2: - offsetId = offsetId.charAt(0) + "0" + offsetId.charAt(1); // fallthru - case 3: - hours = parseNumber(offsetId, 1, false); - minutes = 0; - seconds = 0; - break; - case 5: - hours = parseNumber(offsetId, 1, false); - minutes = parseNumber(offsetId, 3, false); - seconds = 0; - break; - case 6: - hours = parseNumber(offsetId, 1, false); - minutes = parseNumber(offsetId, 4, true); - seconds = 0; - break; - case 7: - hours = parseNumber(offsetId, 1, false); - minutes = parseNumber(offsetId, 3, false); - seconds = parseNumber(offsetId, 5, false); - break; - case 9: - hours = parseNumber(offsetId, 1, false); - minutes = parseNumber(offsetId, 4, true); - seconds = parseNumber(offsetId, 7, true); - break; - default: - throw new DateTimeException("Zone offset ID '" + offsetId + "' is invalid"); - } - char first = offsetId.charAt(0); - if (first != '+' && first != '-') { - throw new DateTimeException("Zone offset ID '" + offsetId + "' is invalid: Plus/minus not found when expected"); - } - if (first == '-') { - return ofHoursMinutesSeconds(-hours, -minutes, -seconds); - } else { - return ofHoursMinutesSeconds(hours, minutes, seconds); - } - } - - /** - * Parse a two digit zero-prefixed number. - * - * @param offsetId the offset ID, not null - * @param pos the position to parse, valid - * @param precededByColon should this number be prefixed by a precededByColon - * @return the parsed number, from 0 to 99 - */ - private static int parseNumber(CharSequence offsetId, int pos, boolean precededByColon) { - if (precededByColon && offsetId.charAt(pos - 1) != ':') { - throw new DateTimeException("Zone offset ID '" + offsetId + "' is invalid: Colon not found when expected"); - } - char ch1 = offsetId.charAt(pos); - char ch2 = offsetId.charAt(pos + 1); - if (ch1 < '0' || ch1 > '9' || ch2 < '0' || ch2 > '9') { - throw new DateTimeException("Zone offset ID '" + offsetId + "' is invalid: Non numeric characters found"); - } - return (ch1 - 48) * 10 + (ch2 - 48); - } - - //----------------------------------------------------------------------- - /** - * Obtains an instance of {@code ZoneOffset} using an offset in hours. - * - * @param hours the time-zone offset in hours, from -18 to +18 - * @return the zone-offset, not null - * @throws DateTimeException if the offset is not in the required range - */ - public static ZoneOffset ofHours(int hours) { - return ofHoursMinutesSeconds(hours, 0, 0); - } - - /** - * Obtains an instance of {@code ZoneOffset} using an offset in - * hours and minutes. - *

- * The sign of the hours and minutes components must match. - * Thus, if the hours is negative, the minutes must be negative or zero. - * If the hours is zero, the minutes may be positive, negative or zero. - * - * @param hours the time-zone offset in hours, from -18 to +18 - * @param minutes the time-zone offset in minutes, from 0 to ±59, sign matches hours - * @return the zone-offset, not null - * @throws DateTimeException if the offset is not in the required range - */ - public static ZoneOffset ofHoursMinutes(int hours, int minutes) { - return ofHoursMinutesSeconds(hours, minutes, 0); - } - - /** - * Obtains an instance of {@code ZoneOffset} using an offset in - * hours, minutes and seconds. - *

- * The sign of the hours, minutes and seconds components must match. - * Thus, if the hours is negative, the minutes and seconds must be negative or zero. - * - * @param hours the time-zone offset in hours, from -18 to +18 - * @param minutes the time-zone offset in minutes, from 0 to ±59, sign matches hours and seconds - * @param seconds the time-zone offset in seconds, from 0 to ±59, sign matches hours and minutes - * @return the zone-offset, not null - * @throws DateTimeException if the offset is not in the required range - */ - public static ZoneOffset ofHoursMinutesSeconds(int hours, int minutes, int seconds) { - validate(hours, minutes, seconds); - int totalSeconds = totalSeconds(hours, minutes, seconds); - return ofTotalSeconds(totalSeconds); - } - - /** - * Validates the offset fields. - * - * @param hours the time-zone offset in hours, from -18 to +18 - * @param minutes the time-zone offset in minutes, from 0 to ±59 - * @param seconds the time-zone offset in seconds, from 0 to ±59 - * @throws DateTimeException if the offset is not in the required range - */ - private static void validate(int hours, int minutes, int seconds) { - if (hours < -18 || hours > 18) { - throw new DateTimeException("Zone offset hours not in valid range: value " + hours + - " is not in the range -18 to 18"); - } - if (hours > 0) { - if (minutes < 0 || seconds < 0) { - throw new DateTimeException("Zone offset minutes and seconds must be positive because hours is positive"); - } - } else if (hours < 0) { - if (minutes > 0 || seconds > 0) { - throw new DateTimeException("Zone offset minutes and seconds must be negative because hours is negative"); - } - } else if ((minutes > 0 && seconds < 0) || (minutes < 0 && seconds > 0)) { - throw new DateTimeException("Zone offset minutes and seconds must have the same sign"); - } - if (Math.abs(minutes) > 59) { - throw new DateTimeException("Zone offset minutes not in valid range: abs(value) " + - Math.abs(minutes) + " is not in the range 0 to 59"); - } - if (Math.abs(seconds) > 59) { - throw new DateTimeException("Zone offset seconds not in valid range: abs(value) " + - Math.abs(seconds) + " is not in the range 0 to 59"); - } - if (Math.abs(hours) == 18 && (Math.abs(minutes) > 0 || Math.abs(seconds) > 0)) { - throw new DateTimeException("Zone offset not in valid range: -18:00 to +18:00"); - } - } - - /** - * Calculates the total offset in seconds. - * - * @param hours the time-zone offset in hours, from -18 to +18 - * @param minutes the time-zone offset in minutes, from 0 to ±59, sign matches hours and seconds - * @param seconds the time-zone offset in seconds, from 0 to ±59, sign matches hours and minutes - * @return the total in seconds - */ - private static int totalSeconds(int hours, int minutes, int seconds) { - return hours * SECONDS_PER_HOUR + minutes * SECONDS_PER_MINUTE + seconds; - } - - //----------------------------------------------------------------------- - /** - * Obtains an instance of {@code ZoneOffset} specifying the total offset in seconds - *

- * The offset must be in the range {@code -18:00} to {@code +18:00}, which corresponds to -64800 to +64800. - * - * @param totalSeconds the total time-zone offset in seconds, from -64800 to +64800 - * @return the ZoneOffset, not null - * @throws DateTimeException if the offset is not in the required range - */ - public static ZoneOffset ofTotalSeconds(int totalSeconds) { - if (Math.abs(totalSeconds) > MAX_SECONDS) { - throw new DateTimeException("Zone offset not in valid range: -18:00 to +18:00"); - } - if (totalSeconds % (15 * SECONDS_PER_MINUTE) == 0) { - Integer totalSecs = totalSeconds; - ZoneOffset result = SECONDS_CACHE.get(totalSecs); - if (result == null) { - result = new ZoneOffset(totalSeconds); - SECONDS_CACHE.putIfAbsent(totalSecs, result); - result = SECONDS_CACHE.get(totalSecs); - ID_CACHE.putIfAbsent(result.getId(), result); - } - return result; - } else { - return new ZoneOffset(totalSeconds); - } - } - - /** - * Constructor. - * - * @param totalSeconds the total time-zone offset in seconds, from -64800 to +64800 - */ - private ZoneOffset(int totalSeconds) { - super(); - this.totalSeconds = totalSeconds; - id = buildId(totalSeconds); - } - - private static String buildId(int totalSeconds) { - if (totalSeconds == 0) { - return "Z"; - } else { - int absTotalSeconds = Math.abs(totalSeconds); - StringBuilder buf = new StringBuilder(); - int absHours = absTotalSeconds / SECONDS_PER_HOUR; - int absMinutes = (absTotalSeconds / SECONDS_PER_MINUTE) % MINUTES_PER_HOUR; - buf.append(totalSeconds < 0 ? "-" : "+") - .append(absHours < 10 ? "0" : "").append(absHours) - .append(absMinutes < 10 ? ":0" : ":").append(absMinutes); - int absSeconds = absTotalSeconds % SECONDS_PER_MINUTE; - if (absSeconds != 0) { - buf.append(absSeconds < 10 ? ":0" : ":").append(absSeconds); - } - return buf.toString(); - } - } - - /** - * Gets the total zone offset in seconds. - *

- * This is the primary way to access the offset amount. - * It returns the total of the hours, minutes and seconds fields as a - * single offset that can be added to a time. - * - * @return the total zone offset amount in seconds - */ - public int getTotalSeconds() { - return totalSeconds; - } - - /** - * Gets the normalized zone offset ID. - *

- * The ID is minor variation to the standard ISO-8601 formatted string - * for the offset. There are three formats: - *

    - *
  • {@code Z} - for UTC (ISO-8601) - *
  • {@code +hh:mm} or {@code -hh:mm} - if the seconds are zero (ISO-8601) - *
  • {@code +hh:mm:ss} or {@code -hh:mm:ss} - if the seconds are non-zero (not ISO-8601) - *

- * - * @return the zone offset ID, not null - */ - public String getId() { - return id; - } - - /** - * Compares this offset to another offset in descending order. - *

- * The offsets are compared in the order that they occur for the same time - * of day around the world. Thus, an offset of {@code +10:00} comes before an - * offset of {@code +09:00} and so on down to {@code -18:00}. - *

- * The comparison is "consistent with equals", as defined by {@link Comparable}. - * - * @param other the other date to compare to, not null - * @return the comparator value, negative if less, postive if greater - * @throws NullPointerException if {@code other} is null - */ - @Override - public int compareTo(ZoneOffset other) { - return other.totalSeconds - totalSeconds; - } - - /** - * Checks if this offset is equal to another offset. - *

- * The comparison is based on the amount of the offset in seconds. - * This is equivalent to a comparison by ID. - * - * @param obj the object to check, null returns false - * @return true if this is equal to the other offset - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof ZoneOffset) { - return totalSeconds == ((ZoneOffset) obj).totalSeconds; - } - return false; - } - - /** - * A hash code for this offset. - * - * @return a suitable hash code - */ - @Override - public int hashCode() { - return totalSeconds; - } - - /** - * Outputs this offset as a {@code String}, using the normalized ID. - * - * @return a string representation of this offset, not null - */ - @Override - public String toString() { - return id; - } - -} diff --git a/jdk/make/src/classes/build/tools/tzdb/ZoneOffsetTransition.java b/jdk/make/src/classes/build/tools/tzdb/ZoneOffsetTransition.java deleted file mode 100644 index 167b5f112de..00000000000 --- a/jdk/make/src/classes/build/tools/tzdb/ZoneOffsetTransition.java +++ /dev/null @@ -1,290 +0,0 @@ -/* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This file is available under and governed by the GNU General Public - * License version 2 only, as published by the Free Software Foundation. - * However, the following notice accompanied the original version of this - * file: - * - * Copyright (c) 2009-2012, Stephen Colebourne & Michael Nascimento Santos - * - * 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 JSR-310 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. - */ -package build.tools.tzdb; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Objects; - -/** - * A transition between two offsets caused by a discontinuity in the local time-line. - * - * @since 1.8 - */ -final class ZoneOffsetTransition implements Comparable { - - /** - * The local transition date-time at the transition. - */ - private final LocalDateTime transition; - /** - * The offset before transition. - */ - private final ZoneOffset offsetBefore; - /** - * The offset after transition. - */ - private final ZoneOffset offsetAfter; - - /** - * Creates an instance defining a transition between two offsets. - * - * @param transition the transition date-time with the offset before the transition, not null - * @param offsetBefore the offset before the transition, not null - * @param offsetAfter the offset at and after the transition, not null - */ - ZoneOffsetTransition(LocalDateTime transition, ZoneOffset offsetBefore, ZoneOffset offsetAfter) { - Objects.requireNonNull(transition, "transition"); - Objects.requireNonNull(offsetBefore, "offsetBefore"); - Objects.requireNonNull(offsetAfter, "offsetAfter"); - if (offsetBefore.equals(offsetAfter)) { - throw new IllegalArgumentException("Offsets must not be equal"); - } - this.transition = transition; - this.offsetBefore = offsetBefore; - this.offsetAfter = offsetAfter; - } - - /** - * Creates an instance from epoch-second and offsets. - * - * @param epochSecond the transition epoch-second - * @param offsetBefore the offset before the transition, not null - * @param offsetAfter the offset at and after the transition, not null - */ - ZoneOffsetTransition(long epochSecond, ZoneOffset offsetBefore, ZoneOffset offsetAfter) { - this.transition = LocalDateTime.ofEpochSecond(epochSecond, 0, offsetBefore); - this.offsetBefore = offsetBefore; - this.offsetAfter = offsetAfter; - } - - /** - * Gets the transition instant as an epoch second. - * - * @return the transition epoch second - */ - public long toEpochSecond() { - return transition.toEpochSecond(offsetBefore); - } - - /** - * Gets the local transition date-time, as would be expressed with the 'before' offset. - *

- * This is the date-time where the discontinuity begins expressed with the 'before' offset. - * At this instant, the 'after' offset is actually used, therefore the combination of this - * date-time and the 'before' offset will never occur. - *

- * The combination of the 'before' date-time and offset represents the same instant - * as the 'after' date-time and offset. - * - * @return the transition date-time expressed with the before offset, not null - */ - public LocalDateTime getDateTimeBefore() { - return transition; - } - - /** - * Gets the local transition date-time, as would be expressed with the 'after' offset. - *

- * This is the first date-time after the discontinuity, when the new offset applies. - *

- * The combination of the 'before' date-time and offset represents the same instant - * as the 'after' date-time and offset. - * - * @return the transition date-time expressed with the after offset, not null - */ - public LocalDateTime getDateTimeAfter() { - return transition.plusSeconds(getDurationSeconds()); - } - - /** - * Gets the offset before the transition. - *

- * This is the offset in use before the instant of the transition. - * - * @return the offset before the transition, not null - */ - public ZoneOffset getOffsetBefore() { - return offsetBefore; - } - - /** - * Gets the offset after the transition. - *

- * This is the offset in use on and after the instant of the transition. - * - * @return the offset after the transition, not null - */ - public ZoneOffset getOffsetAfter() { - return offsetAfter; - } - - /** - * Gets the duration of the transition in seconds. - * - * @return the duration in seconds - */ - private int getDurationSeconds() { - return getOffsetAfter().getTotalSeconds() - getOffsetBefore().getTotalSeconds(); - } - - /** - * Does this transition represent a gap in the local time-line. - *

- * Gaps occur where there are local date-times that simply do not not exist. - * An example would be when the offset changes from {@code +01:00} to {@code +02:00}. - * This might be described as 'the clocks will move forward one hour tonight at 1am'. - * - * @return true if this transition is a gap, false if it is an overlap - */ - public boolean isGap() { - return getOffsetAfter().getTotalSeconds() > getOffsetBefore().getTotalSeconds(); - } - - /** - * Does this transition represent a gap in the local time-line. - *

- * Overlaps occur where there are local date-times that exist twice. - * An example would be when the offset changes from {@code +02:00} to {@code +01:00}. - * This might be described as 'the clocks will move back one hour tonight at 2am'. - * - * @return true if this transition is an overlap, false if it is a gap - */ - public boolean isOverlap() { - return getOffsetAfter().getTotalSeconds() < getOffsetBefore().getTotalSeconds(); - } - - /** - * Checks if the specified offset is valid during this transition. - *

- * This checks to see if the given offset will be valid at some point in the transition. - * A gap will always return false. - * An overlap will return true if the offset is either the before or after offset. - * - * @param offset the offset to check, null returns false - * @return true if the offset is valid during the transition - */ - public boolean isValidOffset(ZoneOffset offset) { - return isGap() ? false : (getOffsetBefore().equals(offset) || getOffsetAfter().equals(offset)); - } - - /** - * Gets the valid offsets during this transition. - *

- * A gap will return an empty list, while an overlap will return both offsets. - * - * @return the list of valid offsets - */ - List getValidOffsets() { - if (isGap()) { - return Collections.emptyList(); - } - return Arrays.asList(getOffsetBefore(), getOffsetAfter()); - } - - /** - * Compares this transition to another based on the transition instant. - *

- * This compares the instants of each transition. - * The offsets are ignored, making this order inconsistent with equals. - * - * @param transition the transition to compare to, not null - * @return the comparator value, negative if less, positive if greater - */ - @Override - public int compareTo(ZoneOffsetTransition transition) { - return Long.compare(this.toEpochSecond(), transition.toEpochSecond()); - } - - /** - * Checks if this object equals another. - *

- * The entire state of the object is compared. - * - * @param other the other object to compare to, null returns false - * @return true if equal - */ - @Override - public boolean equals(Object other) { - if (other == this) { - return true; - } - if (other instanceof ZoneOffsetTransition) { - ZoneOffsetTransition d = (ZoneOffsetTransition) other; - return transition.equals(d.transition) && - offsetBefore.equals(d.offsetBefore) && offsetAfter.equals(d.offsetAfter); - } - return false; - } - - /** - * Returns a suitable hash code. - * - * @return the hash code - */ - @Override - public int hashCode() { - return transition.hashCode() ^ offsetBefore.hashCode() ^ Integer.rotateLeft(offsetAfter.hashCode(), 16); - } - -} diff --git a/jdk/make/src/classes/build/tools/tzdb/ZoneOffsetTransitionRule.java b/jdk/make/src/classes/build/tools/tzdb/ZoneOffsetTransitionRule.java deleted file mode 100644 index 783499c2163..00000000000 --- a/jdk/make/src/classes/build/tools/tzdb/ZoneOffsetTransitionRule.java +++ /dev/null @@ -1,223 +0,0 @@ -/* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This file is available under and governed by the GNU General Public - * License version 2 only, as published by the Free Software Foundation. - * However, the following notice accompanied the original version of this - * file: - * - * Copyright (c) 2009-2012, Stephen Colebourne & Michael Nascimento Santos - * - * 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 JSR-310 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. - */ -package build.tools.tzdb; - -import static build.tools.tzdb.Utils.*; -import java.util.Objects; - -/** - * A rule expressing how to create a transition. - *

- * This class allows rules for identifying future transitions to be expressed. - * A rule might be written in many forms: - *

    - *
  • the 16th March - *
  • the Sunday on or after the 16th March - *
  • the Sunday on or before the 16th March - *
  • the last Sunday in February - *

- * These different rule types can be expressed and queried. - * - *

Specification for implementors

- * This class is immutable and thread-safe. - * - * @since 1.8 - */ -final class ZoneOffsetTransitionRule { - - /** - * The month of the month-day of the first day of the cutover week. - * The actual date will be adjusted by the dowChange field. - */ - final int month; - /** - * The day-of-month of the month-day of the cutover week. - * If positive, it is the start of the week where the cutover can occur. - * If negative, it represents the end of the week where cutover can occur. - * The value is the number of days from the end of the month, such that - * {@code -1} is the last day of the month, {@code -2} is the second - * to last day, and so on. - */ - final byte dom; - /** - * The cutover day-of-week, -1 to retain the day-of-month. - */ - final int dow; - /** - * The cutover time in the 'before' offset. - */ - final LocalTime time; - /** - * Whether the cutover time is midnight at the end of day. - */ - final boolean timeEndOfDay; - /** - * The definition of how the local time should be interpreted. - */ - final TimeDefinition timeDefinition; - /** - * The standard offset at the cutover. - */ - final ZoneOffset standardOffset; - /** - * The offset before the cutover. - */ - final ZoneOffset offsetBefore; - /** - * The offset after the cutover. - */ - final ZoneOffset offsetAfter; - - /** - * Creates an instance defining the yearly rule to create transitions between two offsets. - * - * @param month the month of the month-day of the first day of the cutover week, from 1 to 12 - * @param dayOfMonthIndicator the day of the month-day of the cutover week, positive if the week is that - * day or later, negative if the week is that day or earlier, counting from the last day of the month, - * from -28 to 31 excluding 0 - * @param dayOfWeek the required day-of-week, -1 if the month-day should not be changed - * @param time the cutover time in the 'before' offset, not null - * @param timeEndOfDay whether the time is midnight at the end of day - * @param timeDefnition how to interpret the cutover - * @param standardOffset the standard offset in force at the cutover, not null - * @param offsetBefore the offset before the cutover, not null - * @param offsetAfter the offset after the cutover, not null - * @throws IllegalArgumentException if the day of month indicator is invalid - * @throws IllegalArgumentException if the end of day flag is true when the time is not midnight - */ - ZoneOffsetTransitionRule( - int month, - int dayOfMonthIndicator, - int dayOfWeek, - LocalTime time, - boolean timeEndOfDay, - TimeDefinition timeDefnition, - ZoneOffset standardOffset, - ZoneOffset offsetBefore, - ZoneOffset offsetAfter) { - Objects.requireNonNull(time, "time"); - Objects.requireNonNull(timeDefnition, "timeDefnition"); - Objects.requireNonNull(standardOffset, "standardOffset"); - Objects.requireNonNull(offsetBefore, "offsetBefore"); - Objects.requireNonNull(offsetAfter, "offsetAfter"); - if (month < 1 || month > 12) { - throw new IllegalArgumentException("month must be between 1 and 12"); - } - if (dayOfMonthIndicator < -28 || dayOfMonthIndicator > 31 || dayOfMonthIndicator == 0) { - throw new IllegalArgumentException("Day of month indicator must be between -28 and 31 inclusive excluding zero"); - } - if (timeEndOfDay && time.equals(LocalTime.MIDNIGHT) == false) { - throw new IllegalArgumentException("Time must be midnight when end of day flag is true"); - } - this.month = month; - this.dom = (byte) dayOfMonthIndicator; - this.dow = dayOfWeek; - this.time = time; - this.timeEndOfDay = timeEndOfDay; - this.timeDefinition = timeDefnition; - this.standardOffset = standardOffset; - this.offsetBefore = offsetBefore; - this.offsetAfter = offsetAfter; - } - - //----------------------------------------------------------------------- - /** - * Checks if this object equals another. - *

- * The entire state of the object is compared. - * - * @param otherRule the other object to compare to, null returns false - * @return true if equal - */ - @Override - public boolean equals(Object otherRule) { - if (otherRule == this) { - return true; - } - if (otherRule instanceof ZoneOffsetTransitionRule) { - ZoneOffsetTransitionRule other = (ZoneOffsetTransitionRule) otherRule; - return month == other.month && dom == other.dom && dow == other.dow && - timeDefinition == other.timeDefinition && - time.equals(other.time) && - timeEndOfDay == other.timeEndOfDay && - standardOffset.equals(other.standardOffset) && - offsetBefore.equals(other.offsetBefore) && - offsetAfter.equals(other.offsetAfter); - } - return false; - } - - /** - * Returns a suitable hash code. - * - * @return the hash code - */ - @Override - public int hashCode() { - int hash = ((time.toSecondOfDay() + (timeEndOfDay ? 1 : 0)) << 15) + - (month << 11) + ((dom + 32) << 5) + - ((dow == -1 ? 8 : dow) << 2) + (timeDefinition.ordinal()); - return hash ^ standardOffset.hashCode() ^ - offsetBefore.hashCode() ^ offsetAfter.hashCode(); - } - -} diff --git a/jdk/make/src/classes/build/tools/tzdb/ZoneRules.java b/jdk/make/src/classes/build/tools/tzdb/ZoneRules.java index 22c3be80c02..4d01d3ac5b6 100644 --- a/jdk/make/src/classes/build/tools/tzdb/ZoneRules.java +++ b/jdk/make/src/classes/build/tools/tzdb/ZoneRules.java @@ -64,6 +64,12 @@ package build.tools.tzdb; import java.io.DataOutput; import java.io.IOException; import java.io.ObjectOutput; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.ZoneOffset; +import java.time.zone.ZoneOffsetTransition; +import java.time.zone.ZoneOffsetTransitionRule; +import java.time.zone.ZoneOffsetTransitionRule.TimeDefinition; import java.util.Arrays; import java.util.ArrayList; import java.util.List; @@ -224,15 +230,15 @@ final class ZoneRules { * @throws IOException if an error occurs */ static void writeRule(ZoneOffsetTransitionRule rule, DataOutput out) throws IOException { - int month = rule.month; - byte dom = rule.dom; - int dow = rule.dow; - LocalTime time = rule.time; - boolean timeEndOfDay = rule.timeEndOfDay; - TimeDefinition timeDefinition = rule.timeDefinition; - ZoneOffset standardOffset = rule.standardOffset; - ZoneOffset offsetBefore = rule.offsetBefore; - ZoneOffset offsetAfter = rule.offsetAfter; + int month = rule.getMonth().getValue(); + byte dom = (byte)rule.getDayOfMonthIndicator(); + int dow = rule.getDayOfWeek().getValue(); + LocalTime time = rule.getLocalTime(); + boolean timeEndOfDay = rule.isMidnightEndOfDay(); + TimeDefinition timeDefinition = rule.getTimeDefinition(); + ZoneOffset standardOffset = rule.getStandardOffset(); + ZoneOffset offsetBefore = rule.getOffsetBefore(); + ZoneOffset offsetAfter = rule.getOffsetAfter(); int timeSecs = (timeEndOfDay ? 86400 : time.toSecondOfDay()); int stdOffset = standardOffset.getTotalSeconds(); diff --git a/jdk/make/src/classes/build/tools/tzdb/ZoneRulesBuilder.java b/jdk/make/src/classes/build/tools/tzdb/ZoneRulesBuilder.java deleted file mode 100644 index f4a437dc074..00000000000 --- a/jdk/make/src/classes/build/tools/tzdb/ZoneRulesBuilder.java +++ /dev/null @@ -1,743 +0,0 @@ -/* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This file is available under and governed by the GNU General Public - * License version 2 only, as published by the Free Software Foundation. - * However, the following notice accompanied the original version of this - * file: - * - * Copyright (c) 2009-2012, Stephen Colebourne & Michael Nascimento Santos - * - * 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 JSR-310 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. - */ -package build.tools.tzdb; - -import static build.tools.tzdb.Utils.*; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -/** - * A mutable builder used to create all the rules for a historic time-zone. - *

- * The rules of a time-zone describe how the offset changes over time. - * The rules are created by building windows on the time-line within which - * the different rules apply. The rules may be one of two kinds: - *

    - *
  • Fixed savings - A single fixed amount of savings from the standard offset will apply.
  • - *
  • Rules - A set of one or more rules describe how daylight savings changes during the window.
  • - *

- * - *

Implementation notes

- * This class is a mutable builder used to create zone instances. - * It must only be used from a single thread. - * The created instances are immutable and thread-safe. - * - * @since 1.8 - */ -public class ZoneRulesBuilder { - - /** - * The list of windows. - */ - private List windowList = new ArrayList<>(); - - //----------------------------------------------------------------------- - /** - * Constructs an instance of the builder that can be used to create zone rules. - *

- * The builder is used by adding one or more windows representing portions - * of the time-line. The standard offset from UTC/Greenwich will be constant - * within a window, although two adjacent windows can have the same standard offset. - *

- * Within each window, there can either be a - * {@link #setFixedSavingsToWindow fixed savings amount} or a - * {@link #addRuleToWindow list of rules}. - */ - public ZoneRulesBuilder() { - } - - //----------------------------------------------------------------------- - /** - * Adds a window to the builder that can be used to filter a set of rules. - *

- * This method defines and adds a window to the zone where the standard offset is specified. - * The window limits the effect of subsequent additions of transition rules - * or fixed savings. If neither rules or fixed savings are added to the window - * then the window will default to no savings. - *

- * Each window must be added sequentially, as the start instant of the window - * is derived from the until instant of the previous window. - * - * @param standardOffset the standard offset, not null - * @param until the date-time that the offset applies until, not null - * @param untilDefinition the time type for the until date-time, not null - * @return this, for chaining - * @throws IllegalStateException if the window order is invalid - */ - public ZoneRulesBuilder addWindow( - ZoneOffset standardOffset, - LocalDateTime until, - TimeDefinition untilDefinition) { - Objects.requireNonNull(standardOffset, "standardOffset"); - Objects.requireNonNull(until, "until"); - Objects.requireNonNull(untilDefinition, "untilDefinition"); - TZWindow window = new TZWindow(standardOffset, until, untilDefinition); - if (windowList.size() > 0) { - TZWindow previous = windowList.get(windowList.size() - 1); - window.validateWindowOrder(previous); - } - windowList.add(window); - return this; - } - - /** - * Adds a window that applies until the end of time to the builder that can be - * used to filter a set of rules. - *

- * This method defines and adds a window to the zone where the standard offset is specified. - * The window limits the effect of subsequent additions of transition rules - * or fixed savings. If neither rules or fixed savings are added to the window - * then the window will default to no savings. - *

- * This must be added after all other windows. - * No more windows can be added after this one. - * - * @param standardOffset the standard offset, not null - * @return this, for chaining - * @throws IllegalStateException if a forever window has already been added - */ - public ZoneRulesBuilder addWindowForever(ZoneOffset standardOffset) { - return addWindow(standardOffset, LocalDateTime.MAX, TimeDefinition.WALL); - } - - //----------------------------------------------------------------------- - /** - * Sets the previously added window to have fixed savings. - *

- * Setting a window to have fixed savings simply means that a single daylight - * savings amount applies throughout the window. The window could be small, - * such as a single summer, or large, such as a multi-year daylight savings. - *

- * A window can either have fixed savings or rules but not both. - * - * @param fixedSavingAmountSecs the amount of saving to use for the whole window, not null - * @return this, for chaining - * @throws IllegalStateException if no window has yet been added - * @throws IllegalStateException if the window already has rules - */ - public ZoneRulesBuilder setFixedSavingsToWindow(int fixedSavingAmountSecs) { - if (windowList.isEmpty()) { - throw new IllegalStateException("Must add a window before setting the fixed savings"); - } - TZWindow window = windowList.get(windowList.size() - 1); - window.setFixedSavings(fixedSavingAmountSecs); - return this; - } - - //----------------------------------------------------------------------- - /** - * Adds a single transition rule to the current window. - *

- * This adds a rule such that the offset, expressed as a daylight savings amount, - * changes at the specified date-time. - * - * @param transitionDateTime the date-time that the transition occurs as defined by timeDefintion, not null - * @param timeDefinition the definition of how to convert local to actual time, not null - * @param savingAmountSecs the amount of saving from the standard offset after the transition in seconds - * @return this, for chaining - * @throws IllegalStateException if no window has yet been added - * @throws IllegalStateException if the window already has fixed savings - * @throws IllegalStateException if the window has reached the maximum capacity of 2000 rules - */ - public ZoneRulesBuilder addRuleToWindow( - LocalDateTime transitionDateTime, - TimeDefinition timeDefinition, - int savingAmountSecs) { - Objects.requireNonNull(transitionDateTime, "transitionDateTime"); - return addRuleToWindow( - transitionDateTime.getYear(), transitionDateTime.getYear(), - transitionDateTime.getMonth(), transitionDateTime.getDayOfMonth(), - -1, transitionDateTime.getTime(), false, timeDefinition, savingAmountSecs); - } - - /** - * Adds a single transition rule to the current window. - *

- * This adds a rule such that the offset, expressed as a daylight savings amount, - * changes at the specified date-time. - * - * @param year the year of the transition, from MIN_YEAR to MAX_YEAR - * @param month the month of the transition, not null - * @param dayOfMonthIndicator the day-of-month of the transition, adjusted by dayOfWeek, - * from 1 to 31 adjusted later, or -1 to -28 adjusted earlier from the last day of the month - * @param time the time that the transition occurs as defined by timeDefintion, not null - * @param timeEndOfDay whether midnight is at the end of day - * @param timeDefinition the definition of how to convert local to actual time, not null - * @param savingAmountSecs the amount of saving from the standard offset after the transition in seconds - * @return this, for chaining - * @throws DateTimeException if a date-time field is out of range - * @throws IllegalStateException if no window has yet been added - * @throws IllegalStateException if the window already has fixed savings - * @throws IllegalStateException if the window has reached the maximum capacity of 2000 rules - */ - public ZoneRulesBuilder addRuleToWindow( - int year, - int month, - int dayOfMonthIndicator, - LocalTime time, - boolean timeEndOfDay, - TimeDefinition timeDefinition, - int savingAmountSecs) { - return addRuleToWindow(year, year, month, dayOfMonthIndicator, -1, time, timeEndOfDay, timeDefinition, savingAmountSecs); - } - - /** - * Adds a multi-year transition rule to the current window. - *

- * This adds a rule such that the offset, expressed as a daylight savings amount, - * changes at the specified date-time for each year in the range. - * - * @param startYear the start year of the rule, from MIN_YEAR to MAX_YEAR - * @param endYear the end year of the rule, from MIN_YEAR to MAX_YEAR - * @param month the month of the transition, from 1 to 12 - * @param dayOfMonthIndicator the day-of-month of the transition, adjusted by dayOfWeek, - * from 1 to 31 adjusted later, or -1 to -28 adjusted earlier from the last day of the month - * @param dayOfWeek the day-of-week to adjust to, -1 if day-of-month should not be adjusted - * @param time the time that the transition occurs as defined by timeDefintion, not null - * @param timeEndOfDay whether midnight is at the end of day - * @param timeDefinition the definition of how to convert local to actual time, not null - * @param savingAmountSecs the amount of saving from the standard offset after the transition in seconds - * @return this, for chaining - * @throws DateTimeException if a date-time field is out of range - * @throws IllegalArgumentException if the day of month indicator is invalid - * @throws IllegalArgumentException if the end of day midnight flag does not match the time - * @throws IllegalStateException if no window has yet been added - * @throws IllegalStateException if the window already has fixed savings - * @throws IllegalStateException if the window has reached the maximum capacity of 2000 rules - */ - public ZoneRulesBuilder addRuleToWindow( - int startYear, - int endYear, - int month, - int dayOfMonthIndicator, - int dayOfWeek, - LocalTime time, - boolean timeEndOfDay, - TimeDefinition timeDefinition, - int savingAmountSecs) { - Objects.requireNonNull(time, "time"); - Objects.requireNonNull(timeDefinition, "timeDefinition"); - if (dayOfMonthIndicator < -28 || dayOfMonthIndicator > 31 || dayOfMonthIndicator == 0) { - throw new IllegalArgumentException("Day of month indicator must be between -28 and 31 inclusive excluding zero"); - } - if (timeEndOfDay && time.equals(LocalTime.MIDNIGHT) == false) { - throw new IllegalArgumentException("Time must be midnight when end of day flag is true"); - } - if (windowList.isEmpty()) { - throw new IllegalStateException("Must add a window before adding a rule"); - } - TZWindow window = windowList.get(windowList.size() - 1); - window.addRule(startYear, endYear, month, dayOfMonthIndicator, dayOfWeek, time, timeEndOfDay, timeDefinition, savingAmountSecs); - return this; - } - - //----------------------------------------------------------------------- - /** - * Completes the build converting the builder to a set of time-zone rules. - *

- * Calling this method alters the state of the builder. - * Further rules should not be added to this builder once this method is called. - * - * @param zoneId the time-zone ID, not null - * @return the zone rules, not null - * @throws IllegalStateException if no windows have been added - * @throws IllegalStateException if there is only one rule defined as being forever for any given window - */ - public ZoneRules toRules(String zoneId) { - Objects.requireNonNull(zoneId, "zoneId"); - if (windowList.isEmpty()) { - throw new IllegalStateException("No windows have been added to the builder"); - } - - final List standardTransitionList = new ArrayList<>(4); - final List transitionList = new ArrayList<>(256); - final List lastTransitionRuleList = new ArrayList<>(2); - - // initialize the standard offset calculation - final TZWindow firstWindow = windowList.get(0); - ZoneOffset loopStandardOffset = firstWindow.standardOffset; - int loopSavings = 0; - if (firstWindow.fixedSavingAmountSecs != null) { - loopSavings = firstWindow.fixedSavingAmountSecs; - } - final ZoneOffset firstWallOffset = ZoneOffset.ofTotalSeconds(loopStandardOffset.getTotalSeconds() + loopSavings); - LocalDateTime loopWindowStart = LocalDateTime.of(YEAR_MIN_VALUE, 1, 1, 0, 0); - ZoneOffset loopWindowOffset = firstWallOffset; - - // build the windows and rules to interesting data - for (TZWindow window : windowList) { - // tidy the state - window.tidy(loopWindowStart.getYear()); - - // calculate effective savings at the start of the window - Integer effectiveSavings = window.fixedSavingAmountSecs; - if (effectiveSavings == null) { - // apply rules from this window together with the standard offset and - // savings from the last window to find the savings amount applicable - // at start of this window - effectiveSavings = 0; - for (TZRule rule : window.ruleList) { - if (rule.toEpochSecond(loopStandardOffset, loopSavings) > loopWindowStart.toEpochSecond(loopWindowOffset)) { - // previous savings amount found, which could be the savings amount at - // the instant that the window starts (hence isAfter) - break; - } - effectiveSavings = rule.savingAmountSecs; - } - } - - // check if standard offset changed, and update it - if (loopStandardOffset.equals(window.standardOffset) == false) { - standardTransitionList.add( - new ZoneOffsetTransition( - LocalDateTime.ofEpochSecond(loopWindowStart.toEpochSecond(loopWindowOffset), 0, loopStandardOffset), - loopStandardOffset, window.standardOffset)); - loopStandardOffset = window.standardOffset; - } - - // check if the start of the window represents a transition - ZoneOffset effectiveWallOffset = ZoneOffset.ofTotalSeconds(loopStandardOffset.getTotalSeconds() + effectiveSavings); - if (loopWindowOffset.equals(effectiveWallOffset) == false) { - transitionList.add(new ZoneOffsetTransition(loopWindowStart, loopWindowOffset, effectiveWallOffset)); - } - loopSavings = effectiveSavings; - - // apply rules within the window - for (TZRule rule : window.ruleList) { - if (rule.isTransition(loopSavings)) { - ZoneOffsetTransition trans = rule.toTransition(loopStandardOffset, loopSavings); - if (trans.toEpochSecond() < loopWindowStart.toEpochSecond(loopWindowOffset) == false && - trans.toEpochSecond() < window.createDateTimeEpochSecond(loopSavings)) { - transitionList.add(trans); - loopSavings = rule.savingAmountSecs; - } - } - } - - // calculate last rules - for (TZRule lastRule : window.lastRuleList) { - lastTransitionRuleList.add(lastRule.toTransitionRule(loopStandardOffset, loopSavings)); - loopSavings = lastRule.savingAmountSecs; - } - - // finally we can calculate the true end of the window, passing it to the next window - loopWindowOffset = window.createWallOffset(loopSavings); - loopWindowStart = LocalDateTime.ofEpochSecond( - window.createDateTimeEpochSecond(loopSavings), 0, loopWindowOffset); - } - - return new ZoneRules( - firstWindow.standardOffset, firstWallOffset, standardTransitionList, - transitionList, lastTransitionRuleList); - } - - //----------------------------------------------------------------------- - /** - * A definition of a window in the time-line. - * The window will have one standard offset and will either have a - * fixed DST savings or a set of rules. - */ - class TZWindow { - /** The standard offset during the window, not null. */ - private final ZoneOffset standardOffset; - /** The end local time, not null. */ - private final LocalDateTime windowEnd; - /** The type of the end time, not null. */ - private final TimeDefinition timeDefinition; - - /** The fixed amount of the saving to be applied during this window. */ - private Integer fixedSavingAmountSecs; - /** The rules for the current window. */ - private List ruleList = new ArrayList<>(); - /** The latest year that the last year starts at. */ - private int maxLastRuleStartYear = YEAR_MIN_VALUE; - /** The last rules. */ - private List lastRuleList = new ArrayList<>(); - - /** - * Constructor. - * - * @param standardOffset the standard offset applicable during the window, not null - * @param windowEnd the end of the window, relative to the time definition, null if forever - * @param timeDefinition the time definition for calculating the true end, not null - */ - TZWindow( - ZoneOffset standardOffset, - LocalDateTime windowEnd, - TimeDefinition timeDefinition) { - super(); - this.windowEnd = windowEnd; - this.timeDefinition = timeDefinition; - this.standardOffset = standardOffset; - } - - /** - * Sets the fixed savings amount for the window. - * - * @param fixedSavingAmount the amount of daylight saving to apply throughout the window, may be null - * @throws IllegalStateException if the window already has rules - */ - void setFixedSavings(int fixedSavingAmount) { - if (ruleList.size() > 0 || lastRuleList.size() > 0) { - throw new IllegalStateException("Window has DST rules, so cannot have fixed savings"); - } - this.fixedSavingAmountSecs = fixedSavingAmount; - } - - /** - * Adds a rule to the current window. - * - * @param startYear the start year of the rule, from MIN_YEAR to MAX_YEAR - * @param endYear the end year of the rule, from MIN_YEAR to MAX_YEAR - * @param month the month of the transition, not null - * @param dayOfMonthIndicator the day-of-month of the transition, adjusted by dayOfWeek, - * from 1 to 31 adjusted later, or -1 to -28 adjusted earlier from the last day of the month - * @param dayOfWeek the day-of-week to adjust to, null if day-of-month should not be adjusted - * @param time the time that the transition occurs as defined by timeDefintion, not null - * @param timeEndOfDay whether midnight is at the end of day - * @param timeDefinition the definition of how to convert local to actual time, not null - * @param savingAmountSecs the amount of saving from the standard offset in seconds - * @throws IllegalStateException if the window already has fixed savings - * @throws IllegalStateException if the window has reached the maximum capacity of 2000 rules - */ - void addRule( - int startYear, - int endYear, - int month, - int dayOfMonthIndicator, - int dayOfWeek, - LocalTime time, - boolean timeEndOfDay, - TimeDefinition timeDefinition, - int savingAmountSecs) { - - if (fixedSavingAmountSecs != null) { - throw new IllegalStateException("Window has a fixed DST saving, so cannot have DST rules"); - } - if (ruleList.size() >= 2000) { - throw new IllegalStateException("Window has reached the maximum number of allowed rules"); - } - boolean lastRule = false; - if (endYear == YEAR_MAX_VALUE) { - lastRule = true; - endYear = startYear; - } - int year = startYear; - while (year <= endYear) { - TZRule rule = new TZRule(year, month, dayOfMonthIndicator, dayOfWeek, time, timeEndOfDay, timeDefinition, savingAmountSecs); - if (lastRule) { - lastRuleList.add(rule); - maxLastRuleStartYear = Math.max(startYear, maxLastRuleStartYear); - } else { - ruleList.add(rule); - } - year++; - } - } - - /** - * Validates that this window is after the previous one. - * - * @param previous the previous window, not null - * @throws IllegalStateException if the window order is invalid - */ - void validateWindowOrder(TZWindow previous) { - if (windowEnd.compareTo(previous.windowEnd) < 0) { - throw new IllegalStateException("Windows must be added in date-time order: " + - windowEnd + " < " + previous.windowEnd); - } - } - - /** - * Adds rules to make the last rules all start from the same year. - * Also add one more year to avoid weird case where penultimate year has odd offset. - * - * @param windowStartYear the window start year - * @throws IllegalStateException if there is only one rule defined as being forever - */ - void tidy(int windowStartYear) { - if (lastRuleList.size() == 1) { - throw new IllegalStateException("Cannot have only one rule defined as being forever"); - } - - // handle last rules - if (windowEnd.equals(LocalDateTime.MAX)) { - // setup at least one real rule, which closes off other windows nicely - maxLastRuleStartYear = Math.max(maxLastRuleStartYear, windowStartYear) + 1; - for (TZRule lastRule : lastRuleList) { - addRule(lastRule.year, maxLastRuleStartYear, lastRule.month, lastRule.dayOfMonthIndicator, - lastRule.dayOfWeek, lastRule.time, lastRule.timeEndOfDay, lastRule.timeDefinition, lastRule.savingAmountSecs); - lastRule.year = maxLastRuleStartYear + 1; - } - if (maxLastRuleStartYear == YEAR_MAX_VALUE) { - lastRuleList.clear(); - } else { - maxLastRuleStartYear++; - } - } else { - // convert all within the endYear limit - int endYear = windowEnd.getYear(); - for (TZRule lastRule : lastRuleList) { - addRule(lastRule.year, endYear + 1, lastRule.month, lastRule.dayOfMonthIndicator, - lastRule.dayOfWeek, lastRule.time, lastRule.timeEndOfDay, lastRule.timeDefinition, lastRule.savingAmountSecs); - } - lastRuleList.clear(); - maxLastRuleStartYear = YEAR_MAX_VALUE; - } - - // ensure lists are sorted - Collections.sort(ruleList); - Collections.sort(lastRuleList); - - // default fixed savings to zero - if (ruleList.size() == 0 && fixedSavingAmountSecs == null) { - fixedSavingAmountSecs = 0; - } - } - - /** - * Checks if the window is empty. - * - * @return true if the window is only a standard offset - */ - boolean isSingleWindowStandardOffset() { - return windowEnd.equals(LocalDateTime.MAX) && timeDefinition == TimeDefinition.WALL && - fixedSavingAmountSecs == null && lastRuleList.isEmpty() && ruleList.isEmpty(); - } - - /** - * Creates the wall offset for the local date-time at the end of the window. - * - * @param savingsSecs the amount of savings in use in seconds - * @return the created date-time epoch second in the wall offset, not null - */ - ZoneOffset createWallOffset(int savingsSecs) { - return ZoneOffset.ofTotalSeconds(standardOffset.getTotalSeconds() + savingsSecs); - } - - /** - * Creates the offset date-time for the local date-time at the end of the window. - * - * @param savingsSecs the amount of savings in use in seconds - * @return the created date-time epoch second in the wall offset, not null - */ - long createDateTimeEpochSecond(int savingsSecs) { - ZoneOffset wallOffset = createWallOffset(savingsSecs); - LocalDateTime ldt = timeDefinition.createDateTime(windowEnd, standardOffset, wallOffset); - return ldt.toEpochSecond(wallOffset); - } - } - - //----------------------------------------------------------------------- - /** - * A definition of the way a local time can be converted to an offset time. - */ - class TZRule implements Comparable { - private int year; - private int month; - private int dayOfMonthIndicator; - private int dayOfWeek; - private LocalTime time; - private boolean timeEndOfDay; // Whether the local time is end of day. - private TimeDefinition timeDefinition; // The type of the time. - private int savingAmountSecs; // The amount of the saving to be applied after this point. - - /** - * Constructor. - * - * @param year the year - * @param month the month, value from 1 to 12 - * @param dayOfMonthIndicator the day-of-month of the transition, adjusted by dayOfWeek, - * from 1 to 31 adjusted later, or -1 to -28 adjusted earlier from the last day of the month - * @param dayOfWeek the day-of-week, -1 if day-of-month is exact - * @param time the time, not null - * @param timeEndOfDay whether midnight is at the end of day - * @param timeDefinition the time definition, not null - * @param savingAfterSecs the savings amount in seconds - */ - TZRule(int year, int month, int dayOfMonthIndicator, - int dayOfWeek, LocalTime time, boolean timeEndOfDay, - TimeDefinition timeDefinition, int savingAfterSecs) { - this.year = year; - this.month = month; - this.dayOfMonthIndicator = dayOfMonthIndicator; - this.dayOfWeek = dayOfWeek; - this.time = time; - this.timeEndOfDay = timeEndOfDay; - this.timeDefinition = timeDefinition; - this.savingAmountSecs = savingAfterSecs; - } - - /** - * Converts this to a transition. - * - * @param standardOffset the active standard offset, not null - * @param savingsBeforeSecs the active savings in seconds - * @return the transition, not null - */ - ZoneOffsetTransition toTransition(ZoneOffset standardOffset, int savingsBeforeSecs) { - // copy of code in ZoneOffsetTransitionRule to avoid infinite loop - LocalDate date = toLocalDate(); - LocalDateTime ldt = LocalDateTime.of(date, time); - ZoneOffset wallOffset = ZoneOffset.ofTotalSeconds(standardOffset.getTotalSeconds() + savingsBeforeSecs); - LocalDateTime dt = timeDefinition.createDateTime(ldt, standardOffset, wallOffset); - ZoneOffset offsetAfter = ZoneOffset.ofTotalSeconds(standardOffset.getTotalSeconds() + savingAmountSecs); - return new ZoneOffsetTransition(dt, wallOffset, offsetAfter); - } - - /** - * Returns the apoch second of this rules with the specified - * active standard offset and active savings - * - * @param standardOffset the active standard offset, not null - * @param savingsBeforeSecs the active savings in seconds - * @return the transition epoch second - */ - long toEpochSecond(ZoneOffset standardOffset, int savingsBeforeSecs) { - LocalDateTime ldt = LocalDateTime.of(toLocalDate(), time); - ZoneOffset wallOffset = ZoneOffset.ofTotalSeconds(standardOffset.getTotalSeconds() + savingsBeforeSecs); - return timeDefinition.createDateTime(ldt, standardOffset, wallOffset) - .toEpochSecond(wallOffset); - } - - /** - * Tests if this a real transition with the active savings in seconds - * - * @param savingsBeforeSecs the active savings in seconds - * @return true, if savings in seconds changes - */ - boolean isTransition(int savingsBeforeSecs) { - return savingAmountSecs != savingsBeforeSecs; - } - - /** - * Converts this to a transition rule. - * - * @param standardOffset the active standard offset, not null - * @param savingsBeforeSecs the active savings before the transition in seconds - * @return the transition, not null - */ - ZoneOffsetTransitionRule toTransitionRule(ZoneOffset standardOffset, int savingsBeforeSecs) { - // optimize stored format - if (dayOfMonthIndicator < 0) { - if (month != 2) { // not Month.FEBRUARY - dayOfMonthIndicator = maxLengthOfMonth(month) - 6; - } - } - if (timeEndOfDay && dayOfMonthIndicator > 0 && - (dayOfMonthIndicator == 28 && month == 2) == false) { - LocalDate date = LocalDate.of(2004, month, dayOfMonthIndicator).plusDays(1); // leap-year - month = date.getMonth(); - dayOfMonthIndicator = date.getDayOfMonth(); - if (dayOfWeek != -1) { - dayOfWeek = plusDayOfWeek(dayOfWeek, 1); - } - timeEndOfDay = false; - } - // build rule - return new ZoneOffsetTransitionRule( - month, dayOfMonthIndicator, dayOfWeek, time, timeEndOfDay, timeDefinition, - standardOffset, - ZoneOffset.ofTotalSeconds(standardOffset.getTotalSeconds() + savingsBeforeSecs), - ZoneOffset.ofTotalSeconds(standardOffset.getTotalSeconds() + savingAmountSecs)); - } - - public int compareTo(TZRule other) { - int cmp = year - other.year; - cmp = (cmp == 0 ? month - other.month : cmp); - if (cmp == 0) { - // convert to date to handle dow/domIndicator/timeEndOfDay - LocalDate thisDate = toLocalDate(); - LocalDate otherDate = other.toLocalDate(); - cmp = thisDate.compareTo(otherDate); - } - cmp = (cmp == 0 ? time.compareTo(other.time) : cmp); - return cmp; - } - - private LocalDate toLocalDate() { - LocalDate date; - if (dayOfMonthIndicator < 0) { - int monthLen = lengthOfMonth(month, isLeapYear(year)); - date = LocalDate.of(year, month, monthLen + 1 + dayOfMonthIndicator); - if (dayOfWeek != -1) { - date = previousOrSame(date, dayOfWeek); - } - } else { - date = LocalDate.of(year, month, dayOfMonthIndicator); - if (dayOfWeek != -1) { - date = nextOrSame(date, dayOfWeek); - } - } - if (timeEndOfDay) { - date = date.plusDays(1); - } - return date; - } - } - -} diff --git a/jdk/make/src/native/genconstants/ch/genSocketOptionRegistry.c b/jdk/make/src/native/genconstants/ch/genSocketOptionRegistry.c index d5ed5d7a87e..41bd5484ab7 100644 --- a/jdk/make/src/native/genconstants/ch/genSocketOptionRegistry.c +++ b/jdk/make/src/native/genconstants/ch/genSocketOptionRegistry.c @@ -110,6 +110,7 @@ int main(int argc, const char* argv[]) { emit_inet("StandardSocketOptions.IP_MULTICAST_LOOP", IPPROTO_IP, IP_MULTICAST_LOOP); #ifdef AF_INET6 + emit_inet6("StandardSocketOptions.IP_TOS", IPPROTO_IPV6, IPV6_TCLASS); emit_inet6("StandardSocketOptions.IP_MULTICAST_IF", IPPROTO_IPV6, IPV6_MULTICAST_IF); emit_inet6("StandardSocketOptions.IP_MULTICAST_TTL", IPPROTO_IPV6, IPV6_MULTICAST_HOPS); emit_inet6("StandardSocketOptions.IP_MULTICAST_LOOP", IPPROTO_IPV6, IPV6_MULTICAST_LOOP); diff --git a/jdk/src/macosx/classes/com/apple/laf/AquaComboBoxUI.java b/jdk/src/macosx/classes/com/apple/laf/AquaComboBoxUI.java index c38e108633b..75c7babb58a 100644 --- a/jdk/src/macosx/classes/com/apple/laf/AquaComboBoxUI.java +++ b/jdk/src/macosx/classes/com/apple/laf/AquaComboBoxUI.java @@ -522,15 +522,17 @@ public class AquaComboBoxUI extends BasicComboBoxUI implements Sizeable { }; @SuppressWarnings("serial") // anonymous class - private static Action hideAction = new AbstractAction() { + private final Action hideAction = new AbstractAction() { @Override public void actionPerformed(final ActionEvent e) { final JComboBox comboBox = (JComboBox)e.getSource(); + comboBox.firePopupMenuCanceled(); + comboBox.setPopupVisible(false); + } - if (comboBox.isPopupVisible()) { - comboBox.firePopupMenuCanceled(); - comboBox.setPopupVisible(false); - } + @Override + public boolean isEnabled() { + return comboBox.isPopupVisible() && super.isEnabled(); } }; diff --git a/jdk/src/macosx/classes/com/apple/laf/AquaFileSystemModel.java b/jdk/src/macosx/classes/com/apple/laf/AquaFileSystemModel.java index 37e627e8338..b0713215077 100644 --- a/jdk/src/macosx/classes/com/apple/laf/AquaFileSystemModel.java +++ b/jdk/src/macosx/classes/com/apple/laf/AquaFileSystemModel.java @@ -366,6 +366,11 @@ class AquaFileSystemModel extends AbstractTableModel implements PropertyChangeLi final SortableFile otherFile = (SortableFile)other; return otherFile.fFile.equals(fFile); } + + @Override + public int hashCode() { + return Objects.hashCode(fFile); + } } class LoadFilesThread extends Thread { diff --git a/jdk/src/macosx/classes/com/apple/laf/ScreenPopupFactory.java b/jdk/src/macosx/classes/com/apple/laf/ScreenPopupFactory.java index 1ab50a18679..bb2c0f1081b 100644 --- a/jdk/src/macosx/classes/com/apple/laf/ScreenPopupFactory.java +++ b/jdk/src/macosx/classes/com/apple/laf/ScreenPopupFactory.java @@ -29,18 +29,9 @@ import java.awt.*; import javax.swing.*; import sun.lwawt.macosx.CPlatformWindow; +import sun.swing.SwingAccessor; class ScreenPopupFactory extends PopupFactory { - static { - java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Void run() { - System.loadLibrary("osxui"); - return null; - } - }); - } - static final Float TRANSLUCENT = new Float(248f/255f); static final Float OPAQUE = new Float(1.0f); @@ -59,19 +50,13 @@ class ScreenPopupFactory extends PopupFactory { return (Window)w; } - /* - * Since we can't change the signature of PopupFactory, we have to call the - * private method getPopup(Component, Component, int, int, int) through JNI - * (see AquaLookAndFeel.m) - */ - native Popup _getHeavyWeightPopup(Component comp, Component invoker, int x, int y); - public Popup getPopup(final Component comp, final Component invoker, final int x, final int y) { if (invoker == null) throw new IllegalArgumentException("Popup.getPopup must be passed non-null contents"); final Popup popup; if (fIsActive) { - popup = _getHeavyWeightPopup(comp, invoker, x, y); + popup = SwingAccessor.getPopupFactoryAccessor() + .getHeavyWeightPopup(this, comp, invoker, x, y); } else { popup = super.getPopup(comp, invoker, x, y); } diff --git a/jdk/src/macosx/classes/sun/font/CStrike.java b/jdk/src/macosx/classes/sun/font/CStrike.java index af4f8754cfb..5296f5c87f0 100644 --- a/jdk/src/macosx/classes/sun/font/CStrike.java +++ b/jdk/src/macosx/classes/sun/font/CStrike.java @@ -415,7 +415,7 @@ public final class CStrike extends FontStrike { generalCache = new HashMap(); } - generalCache.put(new Integer(index), new Long(value)); + generalCache.put(new Integer(index), Long.valueOf(value)); } public synchronized void dispose() { diff --git a/jdk/src/macosx/classes/sun/lwawt/LWComponentPeer.java b/jdk/src/macosx/classes/sun/lwawt/LWComponentPeer.java index 354f2538012..408862f7746 100644 --- a/jdk/src/macosx/classes/sun/lwawt/LWComponentPeer.java +++ b/jdk/src/macosx/classes/sun/lwawt/LWComponentPeer.java @@ -317,6 +317,8 @@ public abstract class LWComponentPeer * subclasses to initialize specific peers properties. */ void initializeImpl() { + // note that these methods can be overridden by the user and + // can return some strange values like null. setBackground(target.getBackground()); setForeground(target.getForeground()); setFont(target.getFont()); diff --git a/jdk/src/macosx/classes/sun/lwawt/LWWindowPeer.java b/jdk/src/macosx/classes/sun/lwawt/LWWindowPeer.java index 226d8c68699..b72ef77d876 100644 --- a/jdk/src/macosx/classes/sun/lwawt/LWWindowPeer.java +++ b/jdk/src/macosx/classes/sun/lwawt/LWWindowPeer.java @@ -443,6 +443,12 @@ public class LWWindowPeer getPlatformWindow().updateIconImages(); } + @Override + public void setBackground(final Color c) { + super.setBackground(c); + updateOpaque(); + } + @Override public void setOpacity(float opacity) { getPlatformWindow().setOpacity(opacity); diff --git a/jdk/src/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java b/jdk/src/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java index dd718c0ca0b..c241aae3cc0 100644 --- a/jdk/src/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java +++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java @@ -97,7 +97,8 @@ public class CEmbeddedFrame extends EmbeddedFrame { public void handleKeyEvent(int eventType, int modifierFlags, String characters, String charsIgnoringMods, boolean isRepeat, short keyCode, boolean needsKeyTyped) { - responder.handleKeyEvent(eventType, modifierFlags, charsIgnoringMods, keyCode, needsKeyTyped, isRepeat); + responder.handleKeyEvent(eventType, modifierFlags, characters, charsIgnoringMods, + keyCode, needsKeyTyped, isRepeat); } public void handleInputEvent(String text) { diff --git a/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformLWWindow.java b/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformLWWindow.java index d7a91264328..9c2edf22742 100644 --- a/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformLWWindow.java +++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformLWWindow.java @@ -29,12 +29,18 @@ import java.awt.Font; import java.awt.FontMetrics; import java.awt.Graphics; import java.awt.GraphicsDevice; +import java.awt.GraphicsEnvironment; import java.awt.Insets; import java.awt.MenuBar; import java.awt.Point; +import java.awt.Rectangle; import java.awt.Window; +import sun.awt.CGraphicsDevice; +import sun.awt.CGraphicsEnvironment; import sun.awt.CausedFocusEvent; +import sun.awt.LightweightFrame; import sun.java2d.SurfaceData; +import sun.lwawt.LWLightweightFramePeer; import sun.lwawt.LWWindowPeer; import sun.lwawt.PlatformWindow; @@ -72,11 +78,6 @@ public class CPlatformLWWindow extends CPlatformWindow { return null; } - @Override - public GraphicsDevice getGraphicsDevice() { - return null; - } - @Override public SurfaceData getScreenSurface() { return null; @@ -199,4 +200,24 @@ public class CPlatformLWWindow extends CPlatformWindow { public long getLayerPtr() { return 0; } + + @Override + public GraphicsDevice getGraphicsDevice() { + CGraphicsEnvironment ge = (CGraphicsEnvironment)GraphicsEnvironment. + getLocalGraphicsEnvironment(); + + LWLightweightFramePeer peer = (LWLightweightFramePeer)getPeer(); + int scale = ((LightweightFrame)peer.getTarget()).getScaleFactor(); + + Rectangle bounds = ((LightweightFrame)peer.getTarget()).getHostBounds(); + for (GraphicsDevice d : ge.getScreenDevices()) { + if (d.getDefaultConfiguration().getBounds().intersects(bounds) && + ((CGraphicsDevice)d).getScaleFactor() == scale) + { + return d; + } + } + // We shouldn't be here... + return ge.getDefaultScreenDevice(); + } } diff --git a/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java b/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java index d8d1555450c..591c16d2879 100644 --- a/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java +++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java @@ -125,7 +125,7 @@ final class CPlatformResponder { /** * Handles key events. */ - void handleKeyEvent(int eventType, int modifierFlags, String chars, + void handleKeyEvent(int eventType, int modifierFlags, String chars, String charsIgnoringModifiers, short keyCode, boolean needsKeyTyped, boolean needsKeyReleased) { boolean isFlagsChangedEvent = isNpapiCallback ? (eventType == CocoaConstants.NPCocoaEventFlagsChanged) : @@ -153,7 +153,10 @@ final class CPlatformResponder { testChar = chars.charAt(0); } - int[] in = new int[] {testChar, isDeadChar ? 1 : 0, modifierFlags, keyCode}; + char testCharIgnoringModifiers = charsIgnoringModifiers != null && charsIgnoringModifiers.length() > 0 ? + charsIgnoringModifiers.charAt(0) : KeyEvent.CHAR_UNDEFINED; + + int[] in = new int[] {testCharIgnoringModifiers, isDeadChar ? 1 : 0, modifierFlags, keyCode}; int[] out = new int[3]; // [jkeyCode, jkeyLocation, deadChar] postsTyped = NSEvent.nsToJavaKeyInfo(in, out); diff --git a/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformView.java b/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformView.java index e81371b4751..3c2cd2325e4 100644 --- a/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformView.java +++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformView.java @@ -200,7 +200,7 @@ public class CPlatformView extends CFRetainedResource { } private void deliverKeyEvent(NSEvent event) { - responder.handleKeyEvent(event.getType(), event.getModifierFlags(), + responder.handleKeyEvent(event.getType(), event.getModifierFlags(), event.getCharacters(), event.getCharactersIgnoringModifiers(), event.getKeyCode(), true, false); } diff --git a/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java b/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java index edf25ddb313..534cf0dd744 100644 --- a/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java +++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java @@ -119,6 +119,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo static final int NONACTIVATING = 1 << 24; static final int IS_DIALOG = 1 << 25; static final int IS_MODAL = 1 << 26; + static final int IS_POPUP = 1 << 27; static final int _STYLE_PROP_BITMASK = DECORATED | TEXTURED | UNIFIED | UTILITY | HUD | SHEET | CLOSEABLE | MINIMIZABLE | RESIZABLE; @@ -318,6 +319,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo styleBits = SET(styleBits, TEXTURED, false); // Popups in applets don't activate applet's process styleBits = SET(styleBits, NONACTIVATING, true); + styleBits = SET(styleBits, IS_POPUP, true); } if (Window.Type.UTILITY.equals(target.getType())) { @@ -744,20 +746,22 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo @Override public void setOpaque(boolean isOpaque) { CWrapper.NSWindow.setOpaque(getNSWindowPtr(), isOpaque); - boolean isTextured = (peer == null)? false : peer.isTextured(); - if (!isOpaque && !isTextured) { - long clearColor = CWrapper.NSColor.clearColor(); - CWrapper.NSWindow.setBackgroundColor(getNSWindowPtr(), clearColor); + boolean isTextured = (peer == null) ? false : peer.isTextured(); + if (!isTextured) { + if (!isOpaque) { + CWrapper.NSWindow.setBackgroundColor(getNSWindowPtr(), 0); + } else if (peer != null) { + Color color = peer.getBackground(); + if (color != null) { + int rgb = color.getRGB(); + CWrapper.NSWindow.setBackgroundColor(getNSWindowPtr(), rgb); + } + } } //This is a temporary workaround. Looks like after 7124236 will be fixed //the correct place for invalidateShadow() is CGLayer.drawInCGLContext. - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - invalidateShadow(); - } - }); + SwingUtilities.invokeLater(this::invalidateShadow); } @Override diff --git a/jdk/src/macosx/classes/sun/lwawt/macosx/CWrapper.java b/jdk/src/macosx/classes/sun/lwawt/macosx/CWrapper.java index 8c2e9c01f2d..f0fec624d8d 100644 --- a/jdk/src/macosx/classes/sun/lwawt/macosx/CWrapper.java +++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CWrapper.java @@ -61,7 +61,14 @@ final class CWrapper { static native void setAlphaValue(long window, float alpha); static native void setOpaque(long window, boolean opaque); - static native void setBackgroundColor(long window, long color); + + /** + * Sets background color of the NSWindow. + * + * @param window the pointer of the NSWindow + * @param color the color in argb format + */ + static native void setBackgroundColor(long window, int color); static native void miniaturize(long window); static native void deminiaturize(long window); @@ -82,8 +89,4 @@ final class CWrapper { static native void setToolTip(long view, String msg); } - - static final class NSColor { - static native long clearColor(); - } } diff --git a/jdk/src/macosx/classes/sun/lwawt/macosx/NSEvent.java b/jdk/src/macosx/classes/sun/lwawt/macosx/NSEvent.java index ddb74d42b02..d30a39cdfb9 100644 --- a/jdk/src/macosx/classes/sun/lwawt/macosx/NSEvent.java +++ b/jdk/src/macosx/classes/sun/lwawt/macosx/NSEvent.java @@ -47,13 +47,15 @@ final class NSEvent { // Key event information private short keyCode; + private String characters; private String charactersIgnoringModifiers; // Called from native - NSEvent(int type, int modifierFlags, short keyCode, String charactersIgnoringModifiers) { + NSEvent(int type, int modifierFlags, short keyCode, String characters, String charactersIgnoringModifiers) { this.type = type; this.modifierFlags = modifierFlags; this.keyCode = keyCode; + this.characters = characters; this.charactersIgnoringModifiers = charactersIgnoringModifiers; } @@ -121,12 +123,16 @@ final class NSEvent { return charactersIgnoringModifiers; } + String getCharacters() { + return characters; + } + @Override public String toString() { return "NSEvent[" + getType() + " ," + getModifierFlags() + " ," + getClickCount() + " ," + getButtonNumber() + " ," + getX() + " ," + getY() + " ," + getAbsX() + " ," + getAbsY()+ " ," + getKeyCode() + " ," - + getCharactersIgnoringModifiers() + "]"; + + getCharacters() + " ," + getCharactersIgnoringModifiers() + "]"; } /* diff --git a/jdk/src/macosx/native/com/apple/laf/ScreenPopupFactory.m b/jdk/src/macosx/native/com/apple/laf/ScreenPopupFactory.m deleted file mode 100644 index 516ce45d5a0..00000000000 --- a/jdk/src/macosx/native/com/apple/laf/ScreenPopupFactory.m +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#import "com_apple_laf_ScreenPopupFactory.h" -#import - -static JNF_CLASS_CACHE(sjc_PopupFactory, "javax/swing/PopupFactory"); -static JNF_MEMBER_CACHE(jm_getPopup, sjc_PopupFactory, "getPopup", "(Ljava/awt/Component;Ljava/awt/Component;III)Ljavax/swing/Popup;"); - -/* - * Class: com_apple_laf_ScreenPopupFactory - * Method: _getHeavyWeightPopup - * Signature: (Ljava/awt/Component;Ljava/awt/Component;II)Ljavax/swing/Popup; - */ -JNIEXPORT jobject /* javax.swing.Popup */ JNICALL Java_com_apple_laf_ScreenPopupFactory__1getHeavyWeightPopup -(JNIEnv *env, jobject screenPopupFactory, jobject comp, jobject invoker, jint x, jint y) { - jobject popup; -JNF_COCOA_ENTER(env); - popup = JNFCallObjectMethod(env, screenPopupFactory, jm_getPopup, comp, invoker, x, y, 2); -JNF_COCOA_EXIT(env); - return popup; -} diff --git a/jdk/src/macosx/native/jobjc/JObjC.xcodeproj/default.pbxuser b/jdk/src/macosx/native/jobjc/JObjC.xcodeproj/default.pbxuser deleted file mode 100644 index cda3de5e2f2..00000000000 --- a/jdk/src/macosx/native/jobjc/JObjC.xcodeproj/default.pbxuser +++ /dev/null @@ -1,207 +0,0 @@ -// !$*UTF8*$! -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ -{ - 00E6828EFEC88D1A11DB9C8B /* Project object */ = { - activeBuildConfigurationName = Release; - activeExecutable = 6A9FA6570246BA6C0CC91562 /* JObjC */; - activeTarget = EB9FD8610AEECCF5008E157E /* JObjC */; - addToTargets = ( - 4CEBA78E08679EF10015D03E /* JNILib */, - ); - breakpointsGroup = 0AB3651F0B2F67B300788B6C /* XCBreakpointsBucket */; - codeSenseManager = 0AB364DB0B2F66FD00788B6C /* Code sense */; - executables = ( - 6A9FA6570246BA6C0CC91562 /* JObjC */, - ); - perUserDictionary = { - PBXConfiguration.PBXFileTableDataSource3.PBXExecutablesDataSource = { - PBXFileTableDataSourceColumnSortingDirectionKey = "-1"; - PBXFileTableDataSourceColumnSortingKey = PBXExecutablesDataSource_NameID; - PBXFileTableDataSourceColumnWidthsKey = ( - 22, - 300, - 131, - ); - PBXFileTableDataSourceColumnsKey = ( - PBXExecutablesDataSource_ActiveFlagID, - PBXExecutablesDataSource_NameID, - PBXExecutablesDataSource_CommentsID, - ); - }; - PBXConfiguration.PBXFileTableDataSource3.PBXFileTableDataSource = { - PBXFileTableDataSourceColumnSortingDirectionKey = "-1"; - PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Filename_ColumnID; - PBXFileTableDataSourceColumnWidthsKey = ( - 20, - 245, - 20, - 48, - 43, - 43, - 20, - ); - PBXFileTableDataSourceColumnsKey = ( - PBXFileDataSource_FiletypeID, - PBXFileDataSource_Filename_ColumnID, - PBXFileDataSource_Built_ColumnID, - PBXFileDataSource_ObjectSize_ColumnID, - PBXFileDataSource_Errors_ColumnID, - PBXFileDataSource_Warnings_ColumnID, - PBXFileDataSource_Target_ColumnID, - ); - }; - PBXConfiguration.PBXTargetDataSource.PBXTargetDataSource = { - PBXFileTableDataSourceColumnSortingDirectionKey = "-1"; - PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Filename_ColumnID; - PBXFileTableDataSourceColumnWidthsKey = ( - 20, - 200, - 65, - 20, - 48, - 43, - 43, - ); - PBXFileTableDataSourceColumnsKey = ( - PBXFileDataSource_FiletypeID, - PBXFileDataSource_Filename_ColumnID, - PBXTargetDataSource_PrimaryAttribute, - PBXFileDataSource_Built_ColumnID, - PBXFileDataSource_ObjectSize_ColumnID, - PBXFileDataSource_Errors_ColumnID, - PBXFileDataSource_Warnings_ColumnID, - ); - }; - }; - sourceControlManager = 0AB364DA0B2F66FD00788B6C /* Source Control */; - userBuildSettings = { - }; - }; - 0AB364DA0B2F66FD00788B6C /* Source Control */ = { - isa = PBXSourceControlManager; - fallbackIsa = XCSourceControlManager; - isSCMEnabled = 0; - scmConfiguration = { - }; - scmType = ""; - }; - 0AB364DB0B2F66FD00788B6C /* Code sense */ = { - isa = PBXCodeSenseManager; - indexTemplatePath = ""; - }; - 0AB3651F0B2F67B300788B6C /* XCBreakpointsBucket */ = { - isa = XCBreakpointsBucket; - name = "Project Breakpoints"; - objects = ( - ); - }; - 0AB365570B2F6ABB00788B6C /* JObjCdylib.c */ = { - uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {847, 783}}"; - sepNavSelRange = "{0, 0}"; - sepNavVisRect = "{{0, 0}, {847, 783}}"; - sepNavWindowFrame = "{{84, 198}, {886, 912}}"; - }; - }; - 0A3CC35E0B94BB8800F6BA26 /* java */ = { - isa = PBXFileReference; - explicitFileType = "compiled.mach-o.executable"; - name = java; - path = /usr/bin/java; - sourceTree = ""; - }; - 363028F90383184400C91562 /* Manifest */ = { - uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {847, 783}}"; - sepNavSelRange = "{0, 0}"; - sepNavVisRect = "{{0, 0}, {847, 783}}"; - sepNavWindowFrame = "{{38, 240}, {886, 912}}"; - }; - }; - 4CEBA78E08679EF10015D03E /* Dylib */ = { - activeExec = 0; - }; - 6A9FA6570246BA6C0CC91562 /* JObjC */ = { - isa = PBXExecutable; - activeArgIndex = 0; - activeArgIndices = ( - YES, - ); - argumentStrings = ( - "-cp JObjC.jar JObjC", - ); - autoAttachOnCrash = 1; - configStateDict = { - "PBXLSLaunchAction-0" = { - PBXLSLaunchAction = 0; - PBXLSLaunchStartAction = 1; - PBXLSLaunchStdioStyle = 2; - PBXLSLaunchStyle = 0; - class = PBXLSRunLaunchConfig; - displayName = "Executable Runner"; - identifier = com.apple.Xcode.launch.runConfig; - remoteHostInfo = ""; - startActionInfo = ""; - }; - "PBXLSLaunchAction-1" = { - PBXLSLaunchAction = 1; - PBXLSLaunchStartAction = 1; - PBXLSLaunchStdioStyle = 2; - PBXLSLaunchStyle = 0; - class = PBXJavaDebuggingNativeLaunchConfig; - displayName = "Java Debugger"; - identifier = com.apple.Xcode.launch.JavaDebugNativeConfig; - remoteHostInfo = ""; - startActionInfo = ""; - }; - }; - customDataFormattersEnabled = 1; - debuggerPlugin = GDBDebugging; - disassemblyDisplayState = 0; - dylibVariantSuffix = ""; - enableDebugStr = 1; - environmentEntries = ( - ); - executableSystemSymbolLevel = 0; - executableUserSymbolLevel = 0; - launchableReference = 0A3CC35E0B94BB8800F6BA26 /* java */; - libgmallocEnabled = 0; - name = JObjC; - sourceDirectories = ( - ); - startupPath = "dist"; - }; - EB9FD8610AEECCF5008E157E /* JObjC */ = { - activeExec = 0; - }; - EB9FD8720AEECD83008E157E /* build.xml */ = { - uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {847, 1260}}"; - sepNavSelRange = "{1260, 0}"; - sepNavVisRect = "{{0, 8}, {847, 783}}"; - sepNavWindowFrame = "{{752, 266}, {886, 912}}"; - }; - }; -} diff --git a/jdk/src/macosx/native/jobjc/JObjC.xcodeproj/project.pbxproj b/jdk/src/macosx/native/jobjc/JObjC.xcodeproj/project.pbxproj deleted file mode 100644 index 61cf3948d0d..00000000000 --- a/jdk/src/macosx/native/jobjc/JObjC.xcodeproj/project.pbxproj +++ /dev/null @@ -1,1397 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 44; - objects = { - -/* Begin PBXAggregateTarget section */ - 89EBD58C0C95F43D000F04A0 /* B&I */ = { - isa = PBXAggregateTarget; - buildConfigurationList = 89EBD5930C95F44E000F04A0 /* Build configuration list for PBXAggregateTarget "B&I" */; - buildPhases = ( - ); - dependencies = ( - C592D6590E12F27400D076FF /* PBXTargetDependency */, - C592D65B0E12F27600D076FF /* PBXTargetDependency */, - C592D65D0E12F27E00D076FF /* PBXTargetDependency */, - 89D7CB9C0CDC64F800472EA2 /* PBXTargetDependency */, - C592D65F0E12F28500D076FF /* PBXTargetDependency */, - C592D6610E12F28E00D076FF /* PBXTargetDependency */, - C592D6630E12F29200D076FF /* PBXTargetDependency */, - 89D7CC920CDE7A8200472EA2 /* PBXTargetDependency */, - ); - name = "B&I"; - productName = "B&I"; - }; -/* End PBXAggregateTarget section */ - -/* Begin PBXBuildFile section */ - 89D7C9F70CDB900E00472EA2 /* CIF.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9EC0CDB900E00472EA2 /* CIF.m */; }; - 89D7C9F80CDB900E00472EA2 /* Coder.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9ED0CDB900E00472EA2 /* Coder.m */; }; - 89D7C9F90CDB900E00472EA2 /* Function.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9EE0CDB900E00472EA2 /* Function.m */; }; - 89D7C9FA0CDB900E00472EA2 /* ID.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9EF0CDB900E00472EA2 /* ID.m */; }; - 89D7C9FB0CDB900E00472EA2 /* JObjCRuntime.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9F00CDB900E00472EA2 /* JObjCRuntime.m */; }; - 89D7C9FC0CDB900E00472EA2 /* MacOSXFramework.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9F10CDB900E00472EA2 /* MacOSXFramework.m */; }; - 89D7C9FD0CDB900E00472EA2 /* NativeBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = 89D7C9F20CDB900E00472EA2 /* NativeBuffer.h */; }; - 89D7C9FE0CDB900E00472EA2 /* NativeBuffer.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9F30CDB900E00472EA2 /* NativeBuffer.m */; }; - 89D7C9FF0CDB900E00472EA2 /* NativeObjectLifecycleManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9F40CDB900E00472EA2 /* NativeObjectLifecycleManager.m */; }; - 89D7CA000CDB900E00472EA2 /* NSClass.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9F50CDB900E00472EA2 /* NSClass.m */; }; - 89D7CA010CDB900E00472EA2 /* SEL.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9F60CDB900E00472EA2 /* SEL.m */; }; - 89D7CB770CDC4A6500472EA2 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 890FBACC0C6F782C00902C32 /* Foundation.framework */; }; - 89D7CB780CDC4A6500472EA2 /* JavaVM.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 890FBACA0C6F781000902C32 /* JavaVM.framework */; }; - 89D7CB790CDC4A6500472EA2 /* JavaNativeFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 896D90BB0CC2877C005625F5 /* JavaNativeFoundation.framework */; }; - 89D7CB7A0CDC4A6500472EA2 /* libffi.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 89E437680C97A7F200C756EE /* libffi.dylib */; }; - 89D7CCA40CDF9A2600472EA2 /* NativeBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = 89D7C9F20CDB900E00472EA2 /* NativeBuffer.h */; }; - 89D7CCA60CDF9A2600472EA2 /* CIF.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9EC0CDB900E00472EA2 /* CIF.m */; }; - 89D7CCA70CDF9A2600472EA2 /* Coder.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9ED0CDB900E00472EA2 /* Coder.m */; }; - 89D7CCA80CDF9A2600472EA2 /* Function.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9EE0CDB900E00472EA2 /* Function.m */; }; - 89D7CCA90CDF9A2600472EA2 /* ID.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9EF0CDB900E00472EA2 /* ID.m */; }; - 89D7CCAA0CDF9A2600472EA2 /* JObjCRuntime.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9F00CDB900E00472EA2 /* JObjCRuntime.m */; }; - 89D7CCAB0CDF9A2600472EA2 /* MacOSXFramework.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9F10CDB900E00472EA2 /* MacOSXFramework.m */; }; - 89D7CCAC0CDF9A2600472EA2 /* NativeBuffer.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9F30CDB900E00472EA2 /* NativeBuffer.m */; }; - 89D7CCAD0CDF9A2600472EA2 /* NativeObjectLifecycleManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9F40CDB900E00472EA2 /* NativeObjectLifecycleManager.m */; }; - 89D7CCAE0CDF9A2600472EA2 /* NSClass.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9F50CDB900E00472EA2 /* NSClass.m */; }; - 89D7CCAF0CDF9A2600472EA2 /* SEL.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9F60CDB900E00472EA2 /* SEL.m */; }; - 89D7CCB10CDF9A2600472EA2 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 890FBACC0C6F782C00902C32 /* Foundation.framework */; }; - 89D7CCB20CDF9A2600472EA2 /* JavaVM.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 890FBACA0C6F781000902C32 /* JavaVM.framework */; }; - 89D7CCB30CDF9A2600472EA2 /* JavaNativeFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 896D90BB0CC2877C005625F5 /* JavaNativeFoundation.framework */; }; - 89D7CCB40CDF9A2600472EA2 /* libffi.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 89E437680C97A7F200C756EE /* libffi.dylib */; }; - 89D7CCBB0CDF9AA200472EA2 /* NativeString.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7CCBA0CDF9AA200472EA2 /* NativeString.m */; }; - 89D7CCBD0CDF9AB100472EA2 /* NativeNumber.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7CCBC0CDF9AB100472EA2 /* NativeNumber.m */; }; - 89D7CCBF0CDF9AC600472EA2 /* NativeThread.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7CCBE0CDF9AC600472EA2 /* NativeThread.m */; }; - C5742F6D0E316EFA00093838 /* Subclassing.m in Sources */ = {isa = PBXBuildFile; fileRef = C5742F6B0E316EFA00093838 /* Subclassing.m */; }; - C5742F700E316F8600093838 /* Subclassing.m in Sources */ = {isa = PBXBuildFile; fileRef = C5742F6B0E316EFA00093838 /* Subclassing.m */; }; - C5D196C90DF9E43C006F9FB9 /* FFIType.m in Sources */ = {isa = PBXBuildFile; fileRef = C5D196C80DF9E43C006F9FB9 /* FFIType.m */; }; - C5D197D90DFB77C6006F9FB9 /* FFIType.m in Sources */ = {isa = PBXBuildFile; fileRef = C5D196C80DF9E43C006F9FB9 /* FFIType.m */; }; - C5E4547B0E36729F0046D3E8 /* Invoke.m in Sources */ = {isa = PBXBuildFile; fileRef = C5E454790E36729F0046D3E8 /* Invoke.m */; }; - C5E4547D0E367DAB0046D3E8 /* Invoke.m in Sources */ = {isa = PBXBuildFile; fileRef = C5E454790E36729F0046D3E8 /* Invoke.m */; }; - C5F3B23D0E39948300B771AE /* FunCallBench.m in Sources */ = {isa = PBXBuildFile; fileRef = C5F3B1370E398F8E00B771AE /* FunCallBench.m */; }; - C5F3B2620E3AB0F300B771AE /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C5F3B2610E3AB0F300B771AE /* AppKit.framework */; }; - C5F3B2640E3AB0F300B771AE /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C5F3B2630E3AB0F300B771AE /* Cocoa.framework */; }; - C5F3B2650E3AB0F300B771AE /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 890FBACC0C6F782C00902C32 /* Foundation.framework */; }; -/* End PBXBuildFile section */ - -/* Begin PBXContainerItemProxy section */ - 2CC7556013A1322100B09D1B /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00E6828EFEC88D1A11DB9C8B /* Project object */; - proxyType = 1; - remoteGlobalIDString = EB9FD8610AEECCF5008E157E; - remoteInfo = "build-core-java"; - }; - 2CC7556213A1322800B09D1B /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00E6828EFEC88D1A11DB9C8B /* Project object */; - proxyType = 1; - remoteGlobalIDString = C5F3B1530E39927900B771AE; - remoteInfo = "build-test-java"; - }; - 2CC7556413A1323700B09D1B /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00E6828EFEC88D1A11DB9C8B /* Project object */; - proxyType = 1; - remoteGlobalIDString = 89D7CA160CDBA94D00472EA2; - remoteInfo = "build-generator-java"; - }; - 2CC7556613A1324300B09D1B /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00E6828EFEC88D1A11DB9C8B /* Project object */; - proxyType = 1; - remoteGlobalIDString = 89D7CC600CDE75EC00472EA2; - remoteInfo = "build-additions-java"; - }; - 2CC7556813A1325700B09D1B /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00E6828EFEC88D1A11DB9C8B /* Project object */; - proxyType = 1; - remoteGlobalIDString = 89D7CB870CDC4ED000472EA2; - remoteInfo = "run-generator"; - }; - 2CC7556A13A132AF00B09D1B /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00E6828EFEC88D1A11DB9C8B /* Project object */; - proxyType = 1; - remoteGlobalIDString = 4CEBA78E08679EF10015D03E; - remoteInfo = "build-core-native"; - }; - 2CC7556C13A132B200B09D1B /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00E6828EFEC88D1A11DB9C8B /* Project object */; - proxyType = 1; - remoteGlobalIDString = EB9FD8610AEECCF5008E157E; - remoteInfo = "build-core-java"; - }; - 89D7CB9B0CDC64F800472EA2 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00E6828EFEC88D1A11DB9C8B /* Project object */; - proxyType = 1; - remoteGlobalIDString = 89D7CB870CDC4ED000472EA2; - remoteInfo = "run-generator"; - }; - 89D7CC910CDE7A8200472EA2 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00E6828EFEC88D1A11DB9C8B /* Project object */; - proxyType = 1; - remoteGlobalIDString = 89D7CC720CDE767500472EA2; - remoteInfo = "assemble-product-java"; - }; - C592D6580E12F27400D076FF /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00E6828EFEC88D1A11DB9C8B /* Project object */; - proxyType = 1; - remoteGlobalIDString = EB9FD8610AEECCF5008E157E; - remoteInfo = "build-core-java"; - }; - C592D65A0E12F27600D076FF /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00E6828EFEC88D1A11DB9C8B /* Project object */; - proxyType = 1; - remoteGlobalIDString = 4CEBA78E08679EF10015D03E; - remoteInfo = "build-core-native"; - }; - C592D65C0E12F27E00D076FF /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00E6828EFEC88D1A11DB9C8B /* Project object */; - proxyType = 1; - remoteGlobalIDString = 89D7CA160CDBA94D00472EA2; - remoteInfo = "build-generator-java"; - }; - C592D65E0E12F28500D076FF /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00E6828EFEC88D1A11DB9C8B /* Project object */; - proxyType = 1; - remoteGlobalIDString = 89D7CC4C0CDE4C0400472EA2; - remoteInfo = "build-generated-java"; - }; - C592D6600E12F28E00D076FF /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00E6828EFEC88D1A11DB9C8B /* Project object */; - proxyType = 1; - remoteGlobalIDString = 89D7CC600CDE75EC00472EA2; - remoteInfo = "build-additions-java"; - }; - C592D6620E12F29200D076FF /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00E6828EFEC88D1A11DB9C8B /* Project object */; - proxyType = 1; - remoteGlobalIDString = 89D7CCA20CDF9A2600472EA2; - remoteInfo = "build-additions-native"; - }; - C5D197DA0DFB77E4006F9FB9 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00E6828EFEC88D1A11DB9C8B /* Project object */; - proxyType = 1; - remoteGlobalIDString = 4CEBA78E08679EF10015D03E; - remoteInfo = "build-core-native"; - }; -/* End PBXContainerItemProxy section */ - -/* Begin PBXFileReference section */ - 0AB364E40B2F671600788B6C /* src */ = {isa = PBXFileReference; lastKnownFileType = folder; path = src; sourceTree = ""; }; - 890FBACA0C6F781000902C32 /* JavaVM.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaVM.framework; path = /System/Library/Frameworks/JavaVM.framework; sourceTree = ""; }; - 890FBACC0C6F782C00902C32 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = ""; }; - 896D90BB0CC2877C005625F5 /* JavaNativeFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaNativeFoundation.framework; path = /System/Library/Frameworks/JavaVM.framework/Versions/A/Frameworks/JavaNativeFoundation.framework; sourceTree = ""; }; - 896D91230CC2ED34005625F5 /* README.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README.txt; sourceTree = ""; }; - 89736E5F0CE819E5008C4205 /* JObjC.jar */ = {isa = PBXFileReference; lastKnownFileType = archive.jar; path = JObjC.jar; sourceTree = BUILT_PRODUCTS_DIR; }; - 89D7C9EC0CDB900E00472EA2 /* CIF.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CIF.m; sourceTree = ""; }; - 89D7C9ED0CDB900E00472EA2 /* Coder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Coder.m; sourceTree = ""; }; - 89D7C9EE0CDB900E00472EA2 /* Function.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Function.m; sourceTree = ""; }; - 89D7C9EF0CDB900E00472EA2 /* ID.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ID.m; sourceTree = ""; }; - 89D7C9F00CDB900E00472EA2 /* JObjCRuntime.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JObjCRuntime.m; sourceTree = ""; }; - 89D7C9F10CDB900E00472EA2 /* MacOSXFramework.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MacOSXFramework.m; sourceTree = ""; }; - 89D7C9F20CDB900E00472EA2 /* NativeBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NativeBuffer.h; sourceTree = ""; }; - 89D7C9F30CDB900E00472EA2 /* NativeBuffer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NativeBuffer.m; sourceTree = ""; }; - 89D7C9F40CDB900E00472EA2 /* NativeObjectLifecycleManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NativeObjectLifecycleManager.m; sourceTree = ""; }; - 89D7C9F50CDB900E00472EA2 /* NSClass.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NSClass.m; sourceTree = ""; }; - 89D7C9F60CDB900E00472EA2 /* SEL.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SEL.m; sourceTree = ""; }; - 89D7CCB80CDF9A2600472EA2 /* libJObjC.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libJObjC.dylib; sourceTree = BUILT_PRODUCTS_DIR; }; - 89D7CCBA0CDF9AA200472EA2 /* NativeString.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NativeString.m; sourceTree = ""; }; - 89D7CCBC0CDF9AB100472EA2 /* NativeNumber.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NativeNumber.m; sourceTree = ""; }; - 89D7CCBE0CDF9AC600472EA2 /* NativeThread.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NativeThread.m; sourceTree = ""; }; - 89E437680C97A7F200C756EE /* libffi.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libffi.dylib; path = /usr/lib/libffi.dylib; sourceTree = ""; }; - C5742F6B0E316EFA00093838 /* Subclassing.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Subclassing.m; sourceTree = ""; }; - C5D196C80DF9E43C006F9FB9 /* FFIType.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FFIType.m; sourceTree = ""; }; - C5E454790E36729F0046D3E8 /* Invoke.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Invoke.m; sourceTree = ""; }; - C5F3B1370E398F8E00B771AE /* FunCallBench.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FunCallBench.m; sourceTree = ""; }; - C5F3B1450E39910500B771AE /* libJObjC-tests.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = "libJObjC-tests.dylib"; sourceTree = BUILT_PRODUCTS_DIR; }; - C5F3B2610E3AB0F300B771AE /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = ""; }; - C5F3B2630E3AB0F300B771AE /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = ""; }; - EB9FD8720AEECD83008E157E /* build.xml */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.xml; path = build.xml; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 4CEBA78D08679EF10015D03E /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 89D7CB770CDC4A6500472EA2 /* Foundation.framework in Frameworks */, - 89D7CB780CDC4A6500472EA2 /* JavaVM.framework in Frameworks */, - 89D7CB790CDC4A6500472EA2 /* JavaNativeFoundation.framework in Frameworks */, - 89D7CB7A0CDC4A6500472EA2 /* libffi.dylib in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 89D7CCB00CDF9A2600472EA2 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 89D7CCB10CDF9A2600472EA2 /* Foundation.framework in Frameworks */, - 89D7CCB20CDF9A2600472EA2 /* JavaVM.framework in Frameworks */, - 89D7CCB30CDF9A2600472EA2 /* JavaNativeFoundation.framework in Frameworks */, - 89D7CCB40CDF9A2600472EA2 /* libffi.dylib in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - C5F3B1430E39910500B771AE /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - C5F3B2620E3AB0F300B771AE /* AppKit.framework in Frameworks */, - C5F3B2640E3AB0F300B771AE /* Cocoa.framework in Frameworks */, - C5F3B2650E3AB0F300B771AE /* Foundation.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 00E6828FFEC88D1A11DB9C8B = { - isa = PBXGroup; - children = ( - 896D91230CC2ED34005625F5 /* README.txt */, - EB9FD8720AEECD83008E157E /* build.xml */, - 0AB364E40B2F671600788B6C /* src */, - 89D7C9EB0CDB900E00472EA2 /* native-core */, - 89D7CA020CDB902200472EA2 /* native-additions */, - C5A9597F0E398F050057C96D /* native-tests */, - 89D7CA030CDB903000472EA2 /* products */, - 890FBAC90C6F77B700902C32 /* frameworks */, - C5F3B1450E39910500B771AE /* libJObjC-tests.dylib */, - C5F3B2610E3AB0F300B771AE /* AppKit.framework */, - C5F3B2630E3AB0F300B771AE /* Cocoa.framework */, - ); - sourceTree = ""; - }; - 890FBAC90C6F77B700902C32 /* frameworks */ = { - isa = PBXGroup; - children = ( - 890FBACC0C6F782C00902C32 /* Foundation.framework */, - 890FBACA0C6F781000902C32 /* JavaVM.framework */, - 896D90BB0CC2877C005625F5 /* JavaNativeFoundation.framework */, - 89E437680C97A7F200C756EE /* libffi.dylib */, - ); - name = frameworks; - sourceTree = ""; - }; - 89D7C9EB0CDB900E00472EA2 /* native-core */ = { - isa = PBXGroup; - children = ( - 89D7C9EC0CDB900E00472EA2 /* CIF.m */, - 89D7C9ED0CDB900E00472EA2 /* Coder.m */, - C5D196C80DF9E43C006F9FB9 /* FFIType.m */, - 89D7C9EE0CDB900E00472EA2 /* Function.m */, - 89D7C9EF0CDB900E00472EA2 /* ID.m */, - C5E454790E36729F0046D3E8 /* Invoke.m */, - 89D7C9F00CDB900E00472EA2 /* JObjCRuntime.m */, - 89D7C9F10CDB900E00472EA2 /* MacOSXFramework.m */, - 89D7C9F20CDB900E00472EA2 /* NativeBuffer.h */, - 89D7C9F30CDB900E00472EA2 /* NativeBuffer.m */, - 89D7C9F40CDB900E00472EA2 /* NativeObjectLifecycleManager.m */, - 89D7C9F50CDB900E00472EA2 /* NSClass.m */, - 89D7C9F60CDB900E00472EA2 /* SEL.m */, - C5742F6B0E316EFA00093838 /* Subclassing.m */, - ); - name = "native-core"; - path = src/core/native; - sourceTree = ""; - }; - 89D7CA020CDB902200472EA2 /* native-additions */ = { - isa = PBXGroup; - children = ( - 89D7CCBA0CDF9AA200472EA2 /* NativeString.m */, - 89D7CCBC0CDF9AB100472EA2 /* NativeNumber.m */, - 89D7CCBE0CDF9AC600472EA2 /* NativeThread.m */, - ); - name = "native-additions"; - path = "src/runtime-additions/native"; - sourceTree = ""; - }; - 89D7CA030CDB903000472EA2 /* products */ = { - isa = PBXGroup; - children = ( - 89736E5F0CE819E5008C4205 /* JObjC.jar */, - 89D7CCB80CDF9A2600472EA2 /* libJObjC.dylib */, - ); - name = products; - path = "src/runtime-additions/native"; - sourceTree = ""; - }; - C5A9597F0E398F050057C96D /* native-tests */ = { - isa = PBXGroup; - children = ( - C5F3B1370E398F8E00B771AE /* FunCallBench.m */, - ); - name = "native-tests"; - path = src/tests/native; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXHeadersBuildPhase section */ - 4CEBA78B08679EF10015D03E /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - 89D7C9FD0CDB900E00472EA2 /* NativeBuffer.h in Headers */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 89D7CCA30CDF9A2600472EA2 /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - 89D7CCA40CDF9A2600472EA2 /* NativeBuffer.h in Headers */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - C5F3B1410E39910500B771AE /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXHeadersBuildPhase section */ - -/* Begin PBXLegacyTarget section */ - 89D7CA160CDBA94D00472EA2 /* build-generator-java */ = { - isa = PBXLegacyTarget; - buildArgumentsString = "-verbose -emacs $ACTION"; - buildConfigurationList = 89D7CA1C0CDBA9B000472EA2 /* Build configuration list for PBXLegacyTarget "build-generator-java" */; - buildPhases = ( - ); - buildToolPath = /usr/bin/ant; - dependencies = ( - 2CC7556D13A132B200B09D1B /* PBXTargetDependency */, - 2CC7556B13A132AF00B09D1B /* PBXTargetDependency */, - ); - name = "build-generator-java"; - passBuildSettingsInEnvironment = 1; - productName = "generator-build-java"; - }; - 89D7CB870CDC4ED000472EA2 /* run-generator */ = { - isa = PBXLegacyTarget; - buildArgumentsString = "-verbose -emacs $ACTION"; - buildConfigurationList = 89D7CB8E0CDC4ED900472EA2 /* Build configuration list for PBXLegacyTarget "run-generator" */; - buildPhases = ( - ); - buildToolPath = /usr/bin/ant; - dependencies = ( - 2CC7556513A1323700B09D1B /* PBXTargetDependency */, - ); - name = "run-generator"; - passBuildSettingsInEnvironment = 1; - productName = "run-generator"; - }; - 89D7CC4C0CDE4C0400472EA2 /* build-generated-java */ = { - isa = PBXLegacyTarget; - buildArgumentsString = "-verbose -emacs $ACTION"; - buildConfigurationList = 89D7CC510CDE4C5200472EA2 /* Build configuration list for PBXLegacyTarget "build-generated-java" */; - buildPhases = ( - ); - buildToolPath = /usr/bin/ant; - dependencies = ( - 2CC7556913A1325700B09D1B /* PBXTargetDependency */, - ); - name = "build-generated-java"; - passBuildSettingsInEnvironment = 1; - productName = "build-generated-java"; - }; - 89D7CC600CDE75EC00472EA2 /* build-additions-java */ = { - isa = PBXLegacyTarget; - buildArgumentsString = "-verbose -emacs $ACTION"; - buildConfigurationList = 89D7CC630CDE762000472EA2 /* Build configuration list for PBXLegacyTarget "build-additions-java" */; - buildPhases = ( - ); - buildToolPath = /usr/bin/ant; - dependencies = ( - ); - name = "build-additions-java"; - passBuildSettingsInEnvironment = 1; - productName = "build-additions-java"; - }; - 89D7CC720CDE767500472EA2 /* assemble-product-java */ = { - isa = PBXLegacyTarget; - buildArgumentsString = "-verbose -emacs $ACTION"; - buildConfigurationList = 89D7CC7A0CDE76F500472EA2 /* Build configuration list for PBXLegacyTarget "assemble-product-java" */; - buildPhases = ( - ); - buildToolPath = /usr/bin/ant; - dependencies = ( - ); - name = "assemble-product-java"; - passBuildSettingsInEnvironment = 1; - productName = "package-product"; - }; - C5F3B1530E39927900B771AE /* build-test-java */ = { - isa = PBXLegacyTarget; - buildArgumentsString = "-verbose -emacs $ACTION"; - buildConfigurationList = C5F3B15B0E3992AC00B771AE /* Build configuration list for PBXLegacyTarget "build-test-java" */; - buildPhases = ( - ); - buildToolPath = /usr/bin/ant; - dependencies = ( - ); - name = "build-test-java"; - passBuildSettingsInEnvironment = 1; - productName = "build-test"; - }; - EB9FD8610AEECCF5008E157E /* build-core-java */ = { - isa = PBXLegacyTarget; - buildArgumentsString = "-verbose -emacs $ACTION"; - buildConfigurationList = EB9FD8690AEECD13008E157E /* Build configuration list for PBXLegacyTarget "build-core-java" */; - buildPhases = ( - ); - buildToolPath = /usr/bin/ant; - buildWorkingDirectory = ""; - dependencies = ( - ); - name = "build-core-java"; - passBuildSettingsInEnvironment = 1; - productName = AntJNIWrapper; - }; -/* End PBXLegacyTarget section */ - -/* Begin PBXNativeTarget section */ - 4CEBA78E08679EF10015D03E /* build-core-native */ = { - isa = PBXNativeTarget; - buildConfigurationList = 4CEBA79108679F100015D03E /* Build configuration list for PBXNativeTarget "build-core-native" */; - buildPhases = ( - 4CEBA78B08679EF10015D03E /* Headers */, - 4CEBA78C08679EF10015D03E /* Sources */, - 4CEBA78D08679EF10015D03E /* Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - 2CC7556113A1322100B09D1B /* PBXTargetDependency */, - ); - name = "build-core-native"; - productName = DylibN; - productType = "com.apple.product-type.library.dynamic"; - }; - 89D7CCA20CDF9A2600472EA2 /* build-additions-native */ = { - isa = PBXNativeTarget; - buildConfigurationList = 89D7CCB50CDF9A2600472EA2 /* Build configuration list for PBXNativeTarget "build-additions-native" */; - buildPhases = ( - 89D7CCA30CDF9A2600472EA2 /* Headers */, - 89D7CCA50CDF9A2600472EA2 /* Sources */, - 89D7CCB00CDF9A2600472EA2 /* Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - 2CC7556713A1324300B09D1B /* PBXTargetDependency */, - C5D197DB0DFB77E4006F9FB9 /* PBXTargetDependency */, - ); - name = "build-additions-native"; - productName = DylibN; - productReference = 89D7CCB80CDF9A2600472EA2 /* libJObjC.dylib */; - productType = "com.apple.product-type.library.dynamic"; - }; - C5F3B1440E39910500B771AE /* build-test-native */ = { - isa = PBXNativeTarget; - buildConfigurationList = C5F3B1480E39917500B771AE /* Build configuration list for PBXNativeTarget "build-test-native" */; - buildPhases = ( - C5F3B1410E39910500B771AE /* Headers */, - C5F3B1420E39910500B771AE /* Sources */, - C5F3B1430E39910500B771AE /* Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - 2CC7556313A1322800B09D1B /* PBXTargetDependency */, - ); - name = "build-test-native"; - productName = "build-tests-native"; - productReference = C5F3B1450E39910500B771AE /* libJObjC-tests.dylib */; - productType = "com.apple.product-type.library.dynamic"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 00E6828EFEC88D1A11DB9C8B /* Project object */ = { - isa = PBXProject; - attributes = { - LastUpgradeCheck = 0410; - }; - buildConfigurationList = 4CEBA75C08679E4D0015D03E /* Build configuration list for PBXProject "JObjC" */; - compatibilityVersion = "Xcode 3.0"; - developmentRegion = English; - hasScannedForEncodings = 1; - knownRegions = ( - English, - Japanese, - French, - German, - ); - mainGroup = 00E6828FFEC88D1A11DB9C8B; - productRefGroup = 00E6828FFEC88D1A11DB9C8B; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 89EBD58C0C95F43D000F04A0 /* B&I */, - EB9FD8610AEECCF5008E157E /* build-core-java */, - 4CEBA78E08679EF10015D03E /* build-core-native */, - 89D7CA160CDBA94D00472EA2 /* build-generator-java */, - 89D7CB870CDC4ED000472EA2 /* run-generator */, - 89D7CC4C0CDE4C0400472EA2 /* build-generated-java */, - 89D7CC600CDE75EC00472EA2 /* build-additions-java */, - 89D7CCA20CDF9A2600472EA2 /* build-additions-native */, - 89D7CC720CDE767500472EA2 /* assemble-product-java */, - C5F3B1530E39927900B771AE /* build-test-java */, - C5F3B1440E39910500B771AE /* build-test-native */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXSourcesBuildPhase section */ - 4CEBA78C08679EF10015D03E /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - C5E4547B0E36729F0046D3E8 /* Invoke.m in Sources */, - C5742F6D0E316EFA00093838 /* Subclassing.m in Sources */, - 89D7C9F70CDB900E00472EA2 /* CIF.m in Sources */, - 89D7C9F80CDB900E00472EA2 /* Coder.m in Sources */, - 89D7C9F90CDB900E00472EA2 /* Function.m in Sources */, - 89D7C9FA0CDB900E00472EA2 /* ID.m in Sources */, - 89D7C9FB0CDB900E00472EA2 /* JObjCRuntime.m in Sources */, - 89D7C9FC0CDB900E00472EA2 /* MacOSXFramework.m in Sources */, - 89D7C9FE0CDB900E00472EA2 /* NativeBuffer.m in Sources */, - 89D7C9FF0CDB900E00472EA2 /* NativeObjectLifecycleManager.m in Sources */, - 89D7CA000CDB900E00472EA2 /* NSClass.m in Sources */, - 89D7CA010CDB900E00472EA2 /* SEL.m in Sources */, - C5D196C90DF9E43C006F9FB9 /* FFIType.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 89D7CCA50CDF9A2600472EA2 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - C5E4547D0E367DAB0046D3E8 /* Invoke.m in Sources */, - C5742F700E316F8600093838 /* Subclassing.m in Sources */, - 89D7CCA60CDF9A2600472EA2 /* CIF.m in Sources */, - 89D7CCA70CDF9A2600472EA2 /* Coder.m in Sources */, - 89D7CCA80CDF9A2600472EA2 /* Function.m in Sources */, - 89D7CCA90CDF9A2600472EA2 /* ID.m in Sources */, - 89D7CCAA0CDF9A2600472EA2 /* JObjCRuntime.m in Sources */, - 89D7CCAB0CDF9A2600472EA2 /* MacOSXFramework.m in Sources */, - 89D7CCAC0CDF9A2600472EA2 /* NativeBuffer.m in Sources */, - 89D7CCAD0CDF9A2600472EA2 /* NativeObjectLifecycleManager.m in Sources */, - 89D7CCAE0CDF9A2600472EA2 /* NSClass.m in Sources */, - 89D7CCAF0CDF9A2600472EA2 /* SEL.m in Sources */, - 89D7CCBB0CDF9AA200472EA2 /* NativeString.m in Sources */, - 89D7CCBD0CDF9AB100472EA2 /* NativeNumber.m in Sources */, - 89D7CCBF0CDF9AC600472EA2 /* NativeThread.m in Sources */, - C5D197D90DFB77C6006F9FB9 /* FFIType.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - C5F3B1420E39910500B771AE /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - C5F3B23D0E39948300B771AE /* FunCallBench.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin PBXTargetDependency section */ - 2CC7556113A1322100B09D1B /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = EB9FD8610AEECCF5008E157E /* build-core-java */; - targetProxy = 2CC7556013A1322100B09D1B /* PBXContainerItemProxy */; - }; - 2CC7556313A1322800B09D1B /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = C5F3B1530E39927900B771AE /* build-test-java */; - targetProxy = 2CC7556213A1322800B09D1B /* PBXContainerItemProxy */; - }; - 2CC7556513A1323700B09D1B /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 89D7CA160CDBA94D00472EA2 /* build-generator-java */; - targetProxy = 2CC7556413A1323700B09D1B /* PBXContainerItemProxy */; - }; - 2CC7556713A1324300B09D1B /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 89D7CC600CDE75EC00472EA2 /* build-additions-java */; - targetProxy = 2CC7556613A1324300B09D1B /* PBXContainerItemProxy */; - }; - 2CC7556913A1325700B09D1B /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 89D7CB870CDC4ED000472EA2 /* run-generator */; - targetProxy = 2CC7556813A1325700B09D1B /* PBXContainerItemProxy */; - }; - 2CC7556B13A132AF00B09D1B /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 4CEBA78E08679EF10015D03E /* build-core-native */; - targetProxy = 2CC7556A13A132AF00B09D1B /* PBXContainerItemProxy */; - }; - 2CC7556D13A132B200B09D1B /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = EB9FD8610AEECCF5008E157E /* build-core-java */; - targetProxy = 2CC7556C13A132B200B09D1B /* PBXContainerItemProxy */; - }; - 89D7CB9C0CDC64F800472EA2 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 89D7CB870CDC4ED000472EA2 /* run-generator */; - targetProxy = 89D7CB9B0CDC64F800472EA2 /* PBXContainerItemProxy */; - }; - 89D7CC920CDE7A8200472EA2 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 89D7CC720CDE767500472EA2 /* assemble-product-java */; - targetProxy = 89D7CC910CDE7A8200472EA2 /* PBXContainerItemProxy */; - }; - C592D6590E12F27400D076FF /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = EB9FD8610AEECCF5008E157E /* build-core-java */; - targetProxy = C592D6580E12F27400D076FF /* PBXContainerItemProxy */; - }; - C592D65B0E12F27600D076FF /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 4CEBA78E08679EF10015D03E /* build-core-native */; - targetProxy = C592D65A0E12F27600D076FF /* PBXContainerItemProxy */; - }; - C592D65D0E12F27E00D076FF /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 89D7CA160CDBA94D00472EA2 /* build-generator-java */; - targetProxy = C592D65C0E12F27E00D076FF /* PBXContainerItemProxy */; - }; - C592D65F0E12F28500D076FF /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 89D7CC4C0CDE4C0400472EA2 /* build-generated-java */; - targetProxy = C592D65E0E12F28500D076FF /* PBXContainerItemProxy */; - }; - C592D6610E12F28E00D076FF /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 89D7CC600CDE75EC00472EA2 /* build-additions-java */; - targetProxy = C592D6600E12F28E00D076FF /* PBXContainerItemProxy */; - }; - C592D6630E12F29200D076FF /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 89D7CCA20CDF9A2600472EA2 /* build-additions-native */; - targetProxy = C592D6620E12F29200D076FF /* PBXContainerItemProxy */; - }; - C5D197DB0DFB77E4006F9FB9 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 4CEBA78E08679EF10015D03E /* build-core-native */; - targetProxy = C5D197DA0DFB77E4006F9FB9 /* PBXContainerItemProxy */; - }; -/* End PBXTargetDependency section */ - -/* Begin XCBuildConfiguration section */ - 4CEBA75D08679E4D0015D03E /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = ( - "$(NATIVE_ARCH_32_BIT)", - "$(NATIVE_ARCH_64_BIT)", - ); - GCC_ENABLE_OBJC_GC = supported; - SYMROOT = build; - }; - name = Debug; - }; - 4CEBA75E08679E4D0015D03E /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - GCC_ENABLE_OBJC_GC = supported; - INSTALL_PATH = /System/Library/Java/Extensions; - }; - name = Release; - }; - 4CEBA79208679F100015D03E /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = ( - "$(NATIVE_ARCH_32_BIT)", - "$(NATIVE_ARCH_64_BIT)", - ); - COPY_PHASE_STRIP = NO; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - EXECUTABLE_EXTENSION = dylib; - EXECUTABLE_PREFIX = lib; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_2)", - ); - FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/JavaVM.framework/Versions/A/Frameworks\""; - FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_2 = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/JavaVM.framework/Versions/A/Frameworks\""; - GCC_GENERATE_DEBUGGING_SYMBOLS = YES; - GCC_MODEL_TUNING = G5; - GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; - GCC_TREAT_NONCONFORMANT_CODE_ERRORS_AS_WARNINGS = YES; - GCC_TREAT_WARNINGS_AS_ERRORS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_MISSING_NEWLINE = YES; - GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES; - GCC_WARN_CHECK_SWITCH_STATEMENTS = YES; - GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS = YES; - GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES; - GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; - GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; - GCC_WARN_MISSING_PARENTHESES = YES; - GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; - GCC_WARN_PEDANTIC = NO; - GCC_WARN_PROTOTYPE_CONVERSION = NO; - GCC_WARN_SHADOW = YES; - GCC_WARN_SIGN_COMPARE = YES; - GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES; - GCC_WARN_UNKNOWN_PRAGMAS = YES; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - HEADER_SEARCH_PATHS = ( - "$(HEADER_SEARCH_PATHS_QUOTED_FOR_TARGET_1)", - /System/Library/Frameworks/JavaVM.framework/Versions/A/Headers, - ); - HEADER_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(PROJECT_TEMP_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/src/jni_headers/core\" \"$(OBJROOT)/src/jni_headers/core\""; - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "$(LIBRARY_SEARCH_PATHS_QUOTED_1)", - ); - LIBRARY_SEARCH_PATHS_QUOTED_1 = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/JavaVM.framework/Versions/1.5.0/Libraries\""; - LIBRARY_STYLE = DYNAMIC; - MACH_O_TYPE = mh_dylib; - OTHER_LDFLAGS = ""; - OTHER_REZFLAGS = ""; - PRODUCT_NAME = JObjC; - SECTORDER_FLAGS = ""; - VALID_ARCHS = "ppc7400 ppc970 i386 x86_64 ppc"; - WARNING_CFLAGS = ( - "-Wmost", - "-Wno-four-char-constants", - "-Wno-unknown-pragmas", - "-Wformat", - "-Wformat-security", - "-Wcast-align", - "-Wwrite-strings", - "-Wuninitialized", - "-Wshadow", - "-Wshorten-64-to-32", - "-Wsign-compare", - "-Wpointer-arith", - "-Wall", - ); - ZERO_LINK = NO; - }; - name = Debug; - }; - 4CEBA79308679F100015D03E /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = ( - i386, - ppc, - x86_64, - ); - COPY_PHASE_STRIP = YES; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - EXECUTABLE_EXTENSION = dylib; - EXECUTABLE_PREFIX = lib; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_2)", - ); - FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/JavaVM.framework/Versions/A/Frameworks\""; - FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_2 = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/JavaVM.framework/Versions/A/Frameworks\""; - GCC_GENERATE_DEBUGGING_SYMBOLS = NO; - GCC_MODEL_TUNING = G5; - GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; - GCC_TREAT_NONCONFORMANT_CODE_ERRORS_AS_WARNINGS = YES; - GCC_TREAT_WARNINGS_AS_ERRORS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_MISSING_NEWLINE = YES; - GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES; - GCC_WARN_CHECK_SWITCH_STATEMENTS = YES; - GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS = YES; - GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES; - GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; - GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; - GCC_WARN_MISSING_PARENTHESES = YES; - GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; - GCC_WARN_PEDANTIC = NO; - GCC_WARN_PROTOTYPE_CONVERSION = NO; - GCC_WARN_SHADOW = YES; - GCC_WARN_SIGN_COMPARE = YES; - GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES; - GCC_WARN_UNKNOWN_PRAGMAS = YES; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - HEADER_SEARCH_PATHS = ( - "$(HEADER_SEARCH_PATHS_QUOTED_FOR_TARGET_1)", - /System/Library/Frameworks/JavaVM.framework/Versions/A/Headers, - ); - HEADER_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(PROJECT_TEMP_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/src/jni_headers/core\" \"$(OBJROOT)/src/jni_headers/core\""; - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_1)", - ); - LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/JavaVM.framework/Versions/1.5.0/Libraries\""; - LIBRARY_STYLE = DYNAMIC; - MACH_O_TYPE = mh_dylib; - OTHER_LDFLAGS = ""; - OTHER_REZFLAGS = ""; - PRODUCT_NAME = JObjC; - SECTORDER_FLAGS = ""; - VALID_ARCHS = "ppc7400 ppc970 i386 x86_64 ppc"; - WARNING_CFLAGS = ( - "-Wmost", - "-Wno-four-char-constants", - "-Wno-unknown-pragmas", - "-Wformat", - "-Wformat-security", - "-Wcast-align", - "-Wwrite-strings", - "-Wuninitialized", - "-Wshadow", - "-Wshorten-64-to-32", - "-Wsign-compare", - "-Wpointer-arith", - "-Wall", - ); - ZERO_LINK = NO; - }; - name = Release; - }; - 89D7CA170CDBA94D00472EA2 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = NO; - GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; - PRODUCT_NAME = "build-generator"; - }; - name = Debug; - }; - 89D7CA180CDBA94D00472EA2 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - PRODUCT_NAME = "build-generator"; - ZERO_LINK = NO; - }; - name = Release; - }; - 89D7CB880CDC4ED000472EA2 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = NO; - GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = "\U00010"; - PRODUCT_NAME = "run-generator"; - }; - name = Debug; - }; - 89D7CB890CDC4ED000472EA2 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - PRODUCT_NAME = "run-generator"; - ZERO_LINK = NO; - }; - name = Release; - }; - 89D7CC4D0CDE4C0400472EA2 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = NO; - GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; - PRODUCT_NAME = "build-generated"; - }; - name = Debug; - }; - 89D7CC4E0CDE4C0400472EA2 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - PRODUCT_NAME = "build-generated"; - ZERO_LINK = NO; - }; - name = Release; - }; - 89D7CC610CDE75EC00472EA2 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = NO; - GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; - PRODUCT_NAME = "build-additions"; - }; - name = Debug; - }; - 89D7CC620CDE75EC00472EA2 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - PRODUCT_NAME = "build-additions"; - ZERO_LINK = NO; - }; - name = Release; - }; - 89D7CC730CDE767500472EA2 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = NO; - GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; - PRODUCT_NAME = "assemble-product"; - }; - name = Debug; - }; - 89D7CC740CDE767500472EA2 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - PRODUCT_NAME = "assemble-product"; - ZERO_LINK = NO; - }; - name = Release; - }; - 89D7CCB60CDF9A2600472EA2 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = ( - "$(NATIVE_ARCH_32_BIT)", - "$(NATIVE_ARCH_64_BIT)", - ); - COPY_PHASE_STRIP = NO; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - EXECUTABLE_EXTENSION = dylib; - EXECUTABLE_PREFIX = lib; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_2)", - ); - FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/JavaVM.framework/Versions/A/Frameworks\""; - FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_2 = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/JavaVM.framework/Versions/A/Frameworks\""; - GCC_GENERATE_DEBUGGING_SYMBOLS = YES; - GCC_MODEL_TUNING = G5; - GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; - GCC_TREAT_NONCONFORMANT_CODE_ERRORS_AS_WARNINGS = YES; - GCC_TREAT_WARNINGS_AS_ERRORS = NO; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_MISSING_NEWLINE = YES; - GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES; - GCC_WARN_CHECK_SWITCH_STATEMENTS = YES; - GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS = YES; - GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES; - GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; - GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; - GCC_WARN_MISSING_PARENTHESES = YES; - GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; - GCC_WARN_PEDANTIC = NO; - GCC_WARN_PROTOTYPE_CONVERSION = NO; - GCC_WARN_SHADOW = YES; - GCC_WARN_SIGN_COMPARE = YES; - GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES; - GCC_WARN_UNKNOWN_PRAGMAS = YES; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - HEADER_SEARCH_PATHS = ( - "$(HEADER_SEARCH_PATHS_QUOTED_FOR_TARGET_1)", - "$(HEADER_SEARCH_PATHS_QUOTED_FOR_TARGET_2)", - /System/Library/Frameworks/JavaVM.framework/Versions/A/Headers, - ); - HEADER_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(PROJECT_TEMP_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/src/jni_headers/core\" \"$(OBJROOT)/src/jni_headers/core\""; - HEADER_SEARCH_PATHS_QUOTED_FOR_TARGET_2 = "\"$(PROJECT_TEMP_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/src/jni_headers/additions\" \"$(OBJROOT)/src/jni_headers/additions\""; - INSTALL_PATH = /usr/local/lib; - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "$(LIBRARY_SEARCH_PATHS_QUOTED_1)", - ); - LIBRARY_SEARCH_PATHS_QUOTED_1 = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/JavaVM.framework/Versions/1.5.0/Libraries\""; - LIBRARY_STYLE = DYNAMIC; - MACH_O_TYPE = mh_dylib; - OTHER_LDFLAGS = ""; - OTHER_REZFLAGS = ""; - PRODUCT_NAME = JObjC; - SECTORDER_FLAGS = ""; - VALID_ARCHS = "ppc7400 ppc970 i386 x86_64 ppc"; - WARNING_CFLAGS = ( - "-Wmost", - "-Wno-four-char-constants", - "-Wno-unknown-pragmas", - "-Wformat", - "-Wformat-security", - "-Wcast-align", - "-Wwrite-strings", - "-Wuninitialized", - "-Wshadow", - "-Wshorten-64-to-32", - "-Wsign-compare", - "-Wpointer-arith", - "-Wall", - ); - ZERO_LINK = NO; - }; - name = Debug; - }; - 89D7CCB70CDF9A2600472EA2 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = ( - x86_64, - ppc, - i386, - ); - COPY_PHASE_STRIP = YES; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - EXECUTABLE_EXTENSION = dylib; - EXECUTABLE_PREFIX = lib; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_2)", - ); - FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/JavaVM.framework/Versions/A/Frameworks\""; - FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_2 = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/JavaVM.framework/Versions/A/Frameworks\""; - GCC_GENERATE_DEBUGGING_SYMBOLS = NO; - GCC_MODEL_TUNING = G5; - GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; - GCC_TREAT_NONCONFORMANT_CODE_ERRORS_AS_WARNINGS = YES; - GCC_TREAT_WARNINGS_AS_ERRORS = NO; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_MISSING_NEWLINE = YES; - GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES; - GCC_WARN_CHECK_SWITCH_STATEMENTS = YES; - GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS = YES; - GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES; - GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; - GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; - GCC_WARN_MISSING_PARENTHESES = YES; - GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; - GCC_WARN_PEDANTIC = NO; - GCC_WARN_PROTOTYPE_CONVERSION = NO; - GCC_WARN_SHADOW = YES; - GCC_WARN_SIGN_COMPARE = YES; - GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES; - GCC_WARN_UNKNOWN_PRAGMAS = YES; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - HEADER_SEARCH_PATHS = ( - "$(HEADER_SEARCH_PATHS_QUOTED_FOR_TARGET_1)", - "$(HEADER_SEARCH_PATHS_QUOTED_FOR_TARGET_2)", - /System/Library/Frameworks/JavaVM.framework/Versions/A/Headers, - ); - HEADER_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(PROJECT_TEMP_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/src/jni_headers/core\" \"$(OBJROOT)/src/jni_headers/core\""; - HEADER_SEARCH_PATHS_QUOTED_FOR_TARGET_2 = "\"$(PROJECT_TEMP_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/src/jni_headers/additions\" \"$(OBJROOT)/src/jni_headers/additions\""; - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_1)", - ); - LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/JavaVM.framework/Versions/1.5.0/Libraries\""; - LIBRARY_STYLE = DYNAMIC; - MACH_O_TYPE = mh_dylib; - OTHER_LDFLAGS = ""; - OTHER_REZFLAGS = ""; - PRODUCT_NAME = JObjC; - SECTORDER_FLAGS = ""; - VALID_ARCHS = "ppc7400 ppc970 i386 x86_64 ppc"; - WARNING_CFLAGS = ( - "-Wmost", - "-Wno-four-char-constants", - "-Wno-unknown-pragmas", - "-Wformat", - "-Wformat-security", - "-Wcast-align", - "-Wwrite-strings", - "-Wuninitialized", - "-Wshadow", - "-Wshorten-64-to-32", - "-Wsign-compare", - "-Wpointer-arith", - "-Wall", - ); - ZERO_LINK = NO; - }; - name = Release; - }; - 89EBD58D0C95F43D000F04A0 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = NO; - GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; - PRODUCT_NAME = "B&I"; - }; - name = Debug; - }; - 89EBD58E0C95F43D000F04A0 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - PRODUCT_NAME = "B&I"; - ZERO_LINK = NO; - }; - name = Release; - }; - C5F3B1460E39910500B771AE /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = YES; - ARCHS = ( - x86_64, - i386, - ppc, - ); - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = dwarf; - EXECUTABLE_EXTENSION = dylib; - EXECUTABLE_PREFIX = lib; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_2)", - ); - FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/JavaVM.framework/Versions/A/Frameworks\""; - FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_2 = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/JavaVM.framework/Versions/A/Frameworks\""; - GCC_DYNAMIC_NO_PIC = NO; - GCC_MODEL_TUNING = G5; - GCC_OPTIMIZATION_LEVEL = 0; - HEADER_SEARCH_PATHS = ( - "$(HEADER_SEARCH_PATHS_QUOTED_FOR_TARGET_1)", - "$(HEADER_SEARCH_PATHS_QUOTED_FOR_TARGET_2)", - /System/Library/Frameworks/JavaVM.framework/Versions/A/Headers, - "\"$(PROJECT_TEMP_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/src/jni_headers/core\"", - "\"$(OBJROOT)/src/jni_headers/core\"", - "\"$(PROJECT_TEMP_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/src/jni_headers/additions\"", - "\"$(OBJROOT)/src/jni_headers/additions\"", - "\"$(PROJECT_TEMP_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/src/jni_headers/test\"", - "\"$(OBJROOT)/src/jni_headers/test\"", - ); - INSTALL_PATH = /usr/local/lib; - LIBRARY_STYLE = DYNAMIC; - MACH_O_TYPE = mh_dylib; - PRODUCT_NAME = "JObjC-tests"; - SKIP_INSTALL = YES; - }; - name = Debug; - }; - C5F3B1470E39910500B771AE /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = YES; - ARCHS = ( - x86_64, - i386, - ppc, - ); - COPY_PHASE_STRIP = YES; - DEBUG_INFORMATION_FORMAT = dwarf; - EXECUTABLE_EXTENSION = dylib; - EXECUTABLE_PREFIX = lib; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_2)", - ); - FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/JavaVM.framework/Versions/A/Frameworks\""; - FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_2 = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/JavaVM.framework/Versions/A/Frameworks\""; - GCC_MODEL_TUNING = G5; - HEADER_SEARCH_PATHS = ( - "$(HEADER_SEARCH_PATHS_QUOTED_FOR_TARGET_1)", - "$(HEADER_SEARCH_PATHS_QUOTED_FOR_TARGET_2)", - /System/Library/Frameworks/JavaVM.framework/Versions/A/Headers, - "\"$(PROJECT_TEMP_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/src/jni_headers/core\"", - "\"$(OBJROOT)/src/jni_headers/core\"", - "\"$(PROJECT_TEMP_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/src/jni_headers/additions\"", - "\"$(OBJROOT)/src/jni_headers/additions\"", - "\"$(PROJECT_TEMP_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/src/jni_headers/test\"", - "\"$(OBJROOT)/src/jni_headers/test\"", - ); - INSTALL_PATH = /usr/local/lib; - LIBRARY_STYLE = DYNAMIC; - MACH_O_TYPE = mh_dylib; - PRODUCT_NAME = "JObjC-tests"; - SKIP_INSTALL = YES; - ZERO_LINK = NO; - }; - name = Release; - }; - C5F3B1540E39927A00B771AE /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = NO; - GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; - PRODUCT_NAME = "build-test"; - }; - name = Debug; - }; - C5F3B1550E39927A00B771AE /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - PRODUCT_NAME = "build-test"; - ZERO_LINK = NO; - }; - name = Release; - }; - EB9FD86A0AEECD13008E157E /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = NO; - GCC_DYNAMIC_NO_PIC = NO; - GCC_GENERATE_DEBUGGING_SYMBOLS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - PRODUCT_NAME = "build-core"; - }; - name = Debug; - }; - EB9FD86B0AEECD13008E157E /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = YES; - GCC_GENERATE_DEBUGGING_SYMBOLS = NO; - PRODUCT_NAME = "build-core"; - ZERO_LINK = NO; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 4CEBA75C08679E4D0015D03E /* Build configuration list for PBXProject "JObjC" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 4CEBA75D08679E4D0015D03E /* Debug */, - 4CEBA75E08679E4D0015D03E /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 4CEBA79108679F100015D03E /* Build configuration list for PBXNativeTarget "build-core-native" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 4CEBA79208679F100015D03E /* Debug */, - 4CEBA79308679F100015D03E /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 89D7CA1C0CDBA9B000472EA2 /* Build configuration list for PBXLegacyTarget "build-generator-java" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 89D7CA170CDBA94D00472EA2 /* Debug */, - 89D7CA180CDBA94D00472EA2 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 89D7CB8E0CDC4ED900472EA2 /* Build configuration list for PBXLegacyTarget "run-generator" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 89D7CB880CDC4ED000472EA2 /* Debug */, - 89D7CB890CDC4ED000472EA2 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 89D7CC510CDE4C5200472EA2 /* Build configuration list for PBXLegacyTarget "build-generated-java" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 89D7CC4D0CDE4C0400472EA2 /* Debug */, - 89D7CC4E0CDE4C0400472EA2 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 89D7CC630CDE762000472EA2 /* Build configuration list for PBXLegacyTarget "build-additions-java" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 89D7CC610CDE75EC00472EA2 /* Debug */, - 89D7CC620CDE75EC00472EA2 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 89D7CC7A0CDE76F500472EA2 /* Build configuration list for PBXLegacyTarget "assemble-product-java" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 89D7CC730CDE767500472EA2 /* Debug */, - 89D7CC740CDE767500472EA2 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 89D7CCB50CDF9A2600472EA2 /* Build configuration list for PBXNativeTarget "build-additions-native" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 89D7CCB60CDF9A2600472EA2 /* Debug */, - 89D7CCB70CDF9A2600472EA2 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 89EBD5930C95F44E000F04A0 /* Build configuration list for PBXAggregateTarget "B&I" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 89EBD58D0C95F43D000F04A0 /* Debug */, - 89EBD58E0C95F43D000F04A0 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - C5F3B1480E39917500B771AE /* Build configuration list for PBXNativeTarget "build-test-native" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - C5F3B1460E39910500B771AE /* Debug */, - C5F3B1470E39910500B771AE /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - C5F3B15B0E3992AC00B771AE /* Build configuration list for PBXLegacyTarget "build-test-java" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - C5F3B1540E39927A00B771AE /* Debug */, - C5F3B1550E39927A00B771AE /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - EB9FD8690AEECD13008E157E /* Build configuration list for PBXLegacyTarget "build-core-java" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - EB9FD86A0AEECD13008E157E /* Debug */, - EB9FD86B0AEECD13008E157E /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 00E6828EFEC88D1A11DB9C8B /* Project object */; -} diff --git a/jdk/src/macosx/native/jobjc/README.txt b/jdk/src/macosx/native/jobjc/README.txt deleted file mode 100644 index 3bde08a77c4..00000000000 --- a/jdk/src/macosx/native/jobjc/README.txt +++ /dev/null @@ -1,132 +0,0 @@ -#title JObjC -# -# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. Oracle designates this -# particular file as subject to the "Classpath" exception as provided -# by Oracle in the LICENSE file that accompanied this code. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -JObjC core provides a pure Java interface for calling C functions and -sending ObjC messages. Given some information, it can marshal types -automatically. - -It also parses BridgeSupport to generate Java wrappers around -Framework bundles. These wrappers rely on the core to provide access -to the C constants, enums, structs, functions, ObjC classes, etc of a -framework. - -* How to build it - -Your best option is `ant all`. There's an Xcode "B&I" target that -works for buildit. - -You'll need a recent JavaNativeFoundation, and perhaps some other -things. Everything is usually there on SnowLeopard (or Leopard after -the common ~javabuild/bin/update runs). - -The build process is quite involved. Xcode takes care of the native -parts, ant takes care of the Java parts, and there's an unholy mix of -external targets and hidden dependencies that keep Xcode and ant (and -buildit on top of that) from stepping on each other. So a warning: the -ant and Xcode targets don't have proper dependencies set up because of -this. They have some dependencies configured, but not the entire -chain. This is because of the jumping back and forth between -externals. If you run the aggregate targets (Xcode B&I, ant all, ant -test, ant bench), everything's is good. But if you manually invoke -individual targets, chances are you'll miss something. Let's go over -it all step by step: - -** ant gen-pcoder - -The PrimitiveCoder subclasses have a lot of boiler plate which -simplifies the generated MixedPrimitiveCoder classes. So instead of -maintaining it, I maintain a tiny Haskell script that spits out the -Java code. This ant target runs that script if Haskell is available on -the system. If it isn't available, this will silently fail. That's -okay, because chances are the PrimitiveCoder.java that you got from -svn is current and does not need to be updated. - -** ant build-core / Xcode build-core-java - -Build core simply builds the JObjC core java classes, and also -generates headers for the JNI for Xcode. - -** ant build-core-native / Xcode build-core-native - -Xcode builds the native core, using the headers from the Java core. It -generates libJObjC.dylib. - -** ant build-generator / Xcode build-generator-java - -ant builds the generator. - -** ant run-generator / Xcode run-generator - -ant runs the generator, using the core Java and native classes. - -What is rungen? And what's run-generator-old? run-generator-old is the -preferred way to run the generator from ant, but there's a strange bug -when running from buildit that causes run-generator-old to -freeze. Pratik was helping me debug it, inspecting the stack and -snooping dtrace probes, but we never found the reason for the -block. So I figured that maybe if I just add a layer of indirection -maybe it'll work around that. And it did. Sad but true. - -** ant build-generated / Xcode build-generated-java - -Build the generator output. - -** ant build-additions / Xcode build-additions-java - -Builds java additions. - -** ant build-additions-native / Xcode build-additions-native - -This builds a new version of libJObjC.dylib. It will rebuild -everything from the core, and include everything from additions. - -** ant assemble-product / Xcode assemble-product-java - -Create a jar, copy products to destination, etc. - -* How to test it - -The test cases also contain a Java component and a native component, -and are built similarly to the above. The benchmarks are built -together with the tests. So "ant build-test" and "ant -build-test-native" will build both the benchmarks and the test. "ant -test" will run the test. "ant bench" will run benchmarks. If you only -want to run a specific benchmark, you can pass a regexp in the -environment variable BENCH_MATCH. - - -ant test -ant bench -BENCH_MATCH=Foo ant bench - - -Test and bench reports will end up in -build/JObjC.build/Debug/test-reports/ - -* How to use it - -Include the jar in your classpath and set your java.library.path to -the directory that contains the dylib. Same thing for app bundles. diff --git a/jdk/src/macosx/native/jobjc/bridgesupport.gmk b/jdk/src/macosx/native/jobjc/bridgesupport.gmk deleted file mode 100644 index 1de9bd1d5c5..00000000000 --- a/jdk/src/macosx/native/jobjc/bridgesupport.gmk +++ /dev/null @@ -1,54 +0,0 @@ -# -# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. Oracle designates this -# particular file as subject to the "Classpath" exception as provided -# by Oracle in the LICENSE file that accompanied this code. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# makefile for generating a stable set of bridgesupport files that change timestamp -# only when the bridgesupport data actually changes - -FRAMEWORKS_DIR = /System/Library/Frameworks -GBM = /usr/bin/gen_bridge_metadata -GEN_HEADERS = $(addsuffix .headers,$(FRAMEWORKS)) -GEN_BRIDGESUPPORT = $(addsuffix .bridgesupport,$(FRAMEWORKS)) - -%.bridgesupport : %.headers $(FRAMEWORKS_DIR)/%.framework/Headers/*.h - @echo "generating bridge support for" $< - if [ -f $(FRAMEWORKS_DIR)/$(<:.headers=.framework)/Resources/BridgeSupport/$(<:.headers=Full.bridgesupport) ] ; \ - then cp $(FRAMEWORKS_DIR)/$(<:.headers=.framework)/Resources/BridgeSupport/$(<:.headers=Full.bridgesupport) $@ ; \ - else $(GBM) -F complete --framework $(<:.headers=.framework) -o $@ ; \ - fi - if cmp -s $@ $(STABLE_GEN_DIR)/$(@:.bridgesupport=Full.bridgesupport) ; \ - then : ; \ - else cp $@ $(STABLE_GEN_DIR)/$(@:.bridgesupport=Full.bridgesupport) ; \ - fi - -%.headers : $(FRAMEWORKS_DIR)/%.framework/Headers - @echo linking $< - ln -s $< $@ - -$(STABLE_GEN_DIR): - mkdir -p $(STABLE_GEN_DIR) - -$(GEN_BRIDGESUPPORT): $(GEN_HEADERS) $(STABLE_GEN_DIR) - -all: $(GEN_BRIDGESUPPORT) diff --git a/jdk/src/macosx/native/jobjc/build.xml b/jdk/src/macosx/native/jobjc/build.xml deleted file mode 100644 index 9f638840fcf..00000000000 --- a/jdk/src/macosx/native/jobjc/build.xml +++ /dev/null @@ -1,520 +0,0 @@ - - - - - - - - Nothing to do for install-headers build phase - - - - Nothing to do for install-source build phase - - - - - - - This Ant build file depends on the native Xcode project to invoke - targets by defining $PRODUCT_NAME to specify the target. - - - --- Redirecting to target "${env.PRODUCT_NAME}" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/jdk/src/macosx/native/jobjc/rungen b/jdk/src/macosx/native/jobjc/rungen deleted file mode 100644 index 17aeabea15d..00000000000 --- a/jdk/src/macosx/native/jobjc/rungen +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/env ruby -# -# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. Oracle designates this -# particular file as subject to the "Classpath" exception as provided -# by Oracle in the LICENSE file that accompanied this code. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -xcodeAction = ARGV[0] - -exit unless xcodeAction == "install" - -JOBJC_JAR = ARGV[1] -LIBPATH = ARGV[2] -OBJROOT = ARGV[3] -ARCHS = ARGV[4] -STABLE_GEN_DIR = ARGV[5] - -ourJavaHome = ENV['JAVA_HOME'] -ourJavaVersion = `java -fullversion 2>&1` -$stderr.puts "ENV['JAVA_HOME'] = #{ourJavaHome}" -$stderr.puts "java -fullversion = #{ourJavaVersion}" - -$stderr.puts "jobjc_jar = #{JOBJC_JAR}" -$stderr.puts "libpath = #{LIBPATH}" -$stderr.puts "objroot = #{OBJROOT}" -$stderr.puts "ARCHS = #{ARCHS}" -$stderr.puts "STABLE_GEN_DIR = #{STABLE_GEN_DIR}" - -jarch = if ARCHS =~ /x86_64/ then "-d64" else "-d32" end - -# compute the boot class path, but remove the JObjC jar file that may have been installed in the boot jdk - -bootclasspathcmd = "java -classpath #{OBJROOT}/bin/core:#{OBJROOT}/bin/generator com.apple.internal.jobjc.generator.BootClassPathMinus #{JOBJC_JAR}" -$stderr.puts bootclasspathcmd -bootclasspath = `#{bootclasspathcmd}` - -$stderr.puts "bootclasspath is: " -$stderr.puts bootclasspath - -# we run the generator with our newly created JObjC. The installed version (if available) has been removed from -# the boot class path, so we are building with everything newly created. -cmd = "java #{jarch} -Xms128m -Xmx512m -Djava.library.path=#{LIBPATH} -Xbootclasspath:#{bootclasspath.chomp} -classpath #{OBJROOT}/bin/core:#{OBJROOT}/bin/generator -ea com.apple.internal.jobjc.generator.Generator dst=#{OBJROOT}/src/jobjc frameworks=#{STABLE_GEN_DIR}" - -$stderr.puts cmd -puts `#{cmd} 2>&1` - -raise $?.to_i if $?.to_i != 0 diff --git a/jdk/src/macosx/native/jobjc/src/core/PrimitiveCoder.hs b/jdk/src/macosx/native/jobjc/src/core/PrimitiveCoder.hs deleted file mode 100644 index b9b0070fcb4..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/PrimitiveCoder.hs +++ /dev/null @@ -1,275 +0,0 @@ -#!/usr/bin/env runhaskell - -{- -/* - * 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. - */ --} -{- -The simplest way to get Haskell is through MacPorts: sudo port install ghc - -Otherwise, see http://www.haskell.org/ghc/ --} - -import Data.List -import Data.Maybe -import Data.Char - -data Width = W32 | W64 - deriving (Show, Eq, Bounded, Enum) - -data NType = NBOOL | Nschar | Nuchar | Nsshort | Nushort | Nsint | Nuint - | Nslong | Nulong | Nslonglong | Nulonglong | Nfloat | Ndouble - deriving (Show, Eq, Bounded, Enum) - -data JPrim = Jboolean | Jbyte | Jchar | Jshort | Jint | Jlong | Jfloat | Jdouble - deriving (Show, Eq, Bounded, Enum) - -data JClass = JBoolean | JByte | JCharacter | JShort | JInteger | JLong - | JFloat | JDouble - deriving (Show, Eq, Bounded, Enum) - -data FFIType = SINT8 | UINT8 | SINT16 | UINT16 | SINT32 | UINT32 - | SINT64 | UINT64 | FLOAT | DOUBLE - deriving (Show, Eq, Bounded, Enum) - -widths = [minBound..maxBound] :: [Width] -ntypes = [minBound..maxBound] :: [NType] -jprims = [minBound..maxBound] :: [JPrim] -jclasses = [minBound..maxBound] :: [JClass] -ffitypes = [minBound..maxBound] :: [FFIType] - --- What's the FFIType for a given Width and NType? For example: W32 NBOOL -> SINT8 -ffitype :: Width -> NType -> FFIType -ffitype _ NBOOL = SINT8 -ffitype _ Nschar = SINT8 -ffitype _ Nuchar = UINT8 -ffitype _ Nsshort = SINT16 -ffitype _ Nushort = UINT16 -ffitype _ Nsint = SINT32 -ffitype _ Nuint = UINT32 -ffitype W32 Nslong = SINT32 -ffitype W64 Nslong = SINT64 -ffitype W32 Nulong = UINT32 -ffitype W64 Nulong = UINT64 -ffitype _ Nslonglong = SINT64 -ffitype _ Nulonglong = UINT64 -ffitype _ Nfloat = FLOAT -ffitype _ Ndouble = DOUBLE - -sizeof :: FFIType -> Int -sizeof SINT8 = 1 -sizeof UINT8 = 1 -sizeof SINT16 = 2 -sizeof UINT16 = 2 -sizeof SINT32 = 4 -sizeof UINT32 = 4 -sizeof SINT64 = 8 -sizeof UINT64 = 8 -sizeof FLOAT = 4 -sizeof DOUBLE = 8 - --- What's the Obj-C encoding for a given NType? For example: unsigned char -> 'C' -encoding nt = fromJust $ lookup nt $ - [(NBOOL, 'B'), (Nschar, 'c'), (Nuchar, 'C'), (Nsshort, 's'), - (Nushort, 'S'), (Nsint, 'i'), (Nuint, 'I'), (Nslong, 'l'), - (Nulong, 'L'), (Nslonglong, 'q'), (Nulonglong, 'Q'), - (Nfloat, 'f'), (Ndouble, 'd')] - --- What's the JPrim for a given NType? For example: native signed long long -> java long -ntype2jprim nt = fromJust $ lookup nt $ - [(NBOOL, Jboolean), (Nschar, Jbyte), (Nuchar, Jbyte), - (Nsshort, Jshort), (Nushort, Jshort), (Nsint, Jint), (Nuint, Jint), - (Nslong, Jlong), (Nulong, Jlong), - (Nslonglong, Jlong), (Nulonglong, Jlong), - (Nfloat, Jfloat), (Ndouble, Jdouble)] - --- What's the JClass for a given JPrim? For example: int -> Integer -jprim2jclass jp = fromJust $ lookup jp $ - [(Jboolean, JBoolean), (Jbyte, JByte), (Jchar, JCharacter), - (Jshort, JShort), (Jint, JInteger), (Jlong, JLong), - (Jfloat, JFloat), (Jdouble, JDouble)] - --- Convert a type to something suitable for Java code. For example: Jboolean -> boolean -ntype2js nt = tail $ show nt -jclass2js t = tail $ show t -jprim2js p = tail $ show p -ffitype2js f = "FFI_" ++ (show f) - --- Capitalize the first letter of a String -capitalize [] = [] -capitalize s = [toUpper $ head s] ++ tail s - --- Given an Width and NType, return the Java code for reading said NType from memory. -popAddr :: Width -> NType -> String -popAddr _ NBOOL = "rt.unsafe.getByte(addr) != 0" -popAddr _ Nschar = "rt.unsafe.getByte(addr)" -popAddr _ Nuchar = "rt.unsafe.getByte(addr)" -popAddr W32 Nslong = "rt.unsafe.getInt(addr)" -popAddr W32 Nulong = "rt.unsafe.getInt(addr)" -popAddr _ ntype = "rt.unsafe.get" ++ (capitalize.jprim2js.ntype2jprim $ ntype) ++ "(addr)" - --- Given an Width and NType, return the Java code for writing said NType to memory. -pushAddr :: Width -> NType -> String -pushAddr _ NBOOL = "rt.unsafe.putByte(addr, (byte) (x ? 1 : 0));" -pushAddr _ Nschar = "rt.unsafe.putByte(addr, x);" -pushAddr _ Nuchar = "rt.unsafe.putByte(addr, x);" -pushAddr W32 Nslong = "rt.unsafe.putInt(addr, (int) x);" -pushAddr W32 Nulong = "rt.unsafe.putInt(addr, (int) x);" -pushAddr _ ntype = "rt.unsafe.put" ++ (capitalize jprimS) ++ "(addr, (" ++ jprimS ++ ") x);" - where jprimS = jprim2js.ntype2jprim $ ntype - --- Helpers for generating Java ternarnies and conditionals. -archExpr x32 x64 = if x32 /= x64 then retdiff else x32 - where retdiff = "(JObjCRuntime.IS64 ? (" ++ x64 ++ ") : (" ++ x32 ++ "))" - -archStmt x32 x64 = if x32 /= x64 then retdiff else x32 - where retdiff = "if(JObjCRuntime.IS64){ " ++ x64 ++ " }else{ " ++ x32 ++ " }" - --- Get a Java expression for the correct FFIType at runtime. For example: (JObjCRuntime.IS64 ? FFI_SINT64 : FFI_SINT32) -ffitypeVal nt = archExpr (ffitype2js $ ffitype W32 nt) - (ffitype2js $ ffitype W64 nt) - --- Similar to ffiTypeVal. Get the correct pop expression and push statement. -popAddrVal nt = archExpr (popAddr W32 nt) (popAddr W64 nt) -pushAddrVal nt = archStmt (pushAddr W32 nt) (pushAddr W64 nt) - --- What's the Coder class name we're using for a given NType? -coderName nt = aux nt ++ "Coder" - where - aux NBOOL = "Bool" - aux Nschar = "SChar" - aux Nuchar = "UChar" - aux Nsshort = "SShort" - aux Nushort = "UShort" - aux Nsint = "SInt" - aux Nuint = "UInt" - aux Nslong = "SLong" - aux Nulong = "ULong" - aux Nslonglong = "SLongLong" - aux Nulonglong = "ULongLong" - aux Nfloat = "Float" - aux Ndouble = "Double" - --- Operation for converting between primitives. Usually it just casts, but booleans are special. -jconvertPrims sym Jboolean Jboolean = sym -jconvertPrims sym Jboolean b = "((" ++ jprim2js b ++ ")(" ++ sym ++ " ? 1 : 0))" -jconvertPrims sym a Jboolean = "(" ++ sym ++ " != 0)" -jconvertPrims sym a b = if a == b then sym else "((" ++ jprim2js b ++ ")" ++ sym ++ ")" - -sizeofRet nt = - let ffitypes = map (\w -> ffitype w nt) widths - sizes = map sizeof ffitypes in - if (length $ nub sizes) == 1 - then "\t\treturn " ++ (show.head $ sizes) ++ ";" - else unlines [ - "\t\tswitch(w){", - (unlines $ map casestmt widths), - "\t\tdefault: return -1;", - "\t\t}"] - where - casestmt w = "\t\t\tcase " ++ (show w) ++ ": return " ++ - (show.sizeof $ ffitype w nt) ++ ";" - --- Generate a coder class for a given NType. -c2java ntype = - unlines [ - "// native " ++ ntypeS ++ " -> java " ++ jprimS, - "public static final class " ++ className ++ " extends PrimitiveCoder<" ++ jclassS ++ ">{", - "\tpublic static final " ++ className ++ " INST = new " ++ className ++ "();", - "\tpublic " ++ className ++ "(){ super("++ffitypeVal ntype++", \"" ++ [encoding ntype] ++ "\", "++jclassS++".class, "++jprimS++".class); }", - "\t// compile time", - "\t@Override public void push(JObjCRuntime rt, long addr, " ++ jprimS ++ " x){", - "\t\t" ++ pushAddrVal ntype, - "\t}", - "\t@Override public " ++ jprimS ++ " pop" ++ capitalize jprimS ++ "(JObjCRuntime rt, long addr){", - "\t\treturn " ++ popAddrVal ntype ++ ";", - "\t}", - "\t// for runtime coding", - "\t@Override public int sizeof(Width w){", - sizeofRet ntype, - "\t}", - "\t@Override public void push(JObjCRuntime rt, long addr, " ++ jclassS ++ " x){ " ++ - "push(rt, addr, (" ++ jprimS ++ ") x); }", - "\t@Override public " ++ jclassS ++ " pop(JObjCRuntime rt, long addr){ " ++ - "return pop" ++ capitalize jprimS ++ "(rt, addr); }", - "\t// proxies for mixed encoding", - makeProxyMethods ntype, - "}" - ] - where - jprim = ntype2jprim ntype - jclass = jprim2jclass jprim - jprimS = jprim2js jprim - jclassS = jclass2js jclass - ntypeS = ntype2js ntype - className = coderName ntype - --- Generate push and pop methods that convert and proxy to actual implementation. -makeProxyMethods nt = unlines $ map aux jprims - where - targetJPrim = ntype2jprim nt - targetJPrimS = jprim2js targetJPrim - aux jprim = if targetJPrim == jprim then "" else unlines [ - "\t@Override public void push(JObjCRuntime rt, long addr, " ++ jprimS ++ " x){ " ++ - "push(rt, addr, " ++ pushConversion "x" ++ "); }", - "\t@Override public " ++ jprimS ++ " pop" ++ capitalize jprimS ++ "(JObjCRuntime rt, long addr){ " ++ - "return " ++ (popConversion ("pop" ++ capitalize targetJPrimS ++ "(rt, addr)")) ++ "; }" - ] - where - jprimS = jprim2js jprim - pushConversion sym = jconvertPrims sym jprim targetJPrim - popConversion sym = jconvertPrims sym targetJPrim jprim - -main = do - putStrLn "package com.apple.jobjc;" - - putStrLn "import com.apple.jobjc.JObjCRuntime.Width;" - - putStrLn "// Auto generated by PrimitiveCoder.hs" - putStrLn "// Do not edit by hand." - - putStrLn "public abstract class PrimitiveCoder extends Coder{" - - putStrLn "\tpublic PrimitiveCoder(int ffiTypeCode, String objCEncoding, Class jclass, Class jprim){" - putStrLn "\t\tsuper(ffiTypeCode, objCEncoding, jclass, jprim);" - putStrLn "\t}" - - mapM_ (\p -> putStrLn $ unlines [makePopI p, makePushI p]) jprims - - mapM_ (putStrLn . c2java) ntypes - - putStrLn "}" - where - makePopI jprim = unlines ["\tpublic final " ++ jprim2js jprim ++ " pop" ++ (capitalize.jprim2js $ jprim) - ++ "(NativeArgumentBuffer args){\n" - ++ "\t\treturn pop" ++ (capitalize.jprim2js $ jprim) ++ "(args.runtime, args.retValPtr);\n" - ++ "\t}", - "\tpublic abstract " ++ jprim2js jprim ++ " pop" ++ (capitalize.jprim2js $ jprim) ++ "(JObjCRuntime runtime, long addr);"] - makePushI jprim = unlines ["\tpublic final void push" - ++ "(NativeArgumentBuffer args, " ++ jprim2js jprim ++ " x){\n" - ++ "\t\tpush(args.runtime, args.argValuesPtr, x);\n" - ++ "\t\targs.didPutArgValue(sizeof());\n" - ++ "\t}", - "\tpublic abstract void push(JObjCRuntime runtime, long addr, " ++ jprim2js jprim ++ " x);"] diff --git a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/CFType.java b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/CFType.java deleted file mode 100644 index 5207cf81d57..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/CFType.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - - -public class CFType extends Pointer { - protected CFType(long ptr) { super(ptr); } - protected CFType(Pointer ptr) { super(ptr.ptr); } - - protected ID getTollFreeBridge(JObjCRuntime runtime){ - return ID.getObjCObjectFor(runtime, super.ptr); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/CIF.java b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/CIF.java deleted file mode 100644 index c32d822662f..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/CIF.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - -import com.apple.jobjc.Coder.PrimitivePointerCoder; - -class CIF { - private static native int getSizeofCIF(); - private static final int SIZEOF = getSizeofCIF(); - private static native boolean prepCIF(long cifPtr, int nargs, long retFFITypePtr, long argsPtr); - - public static CIF createCIFFor(final NativeArgumentBuffer args, final Coder returnCoder, final Coder ... argCoders) { - NativeBuffer cifBuf = new NativeBuffer(SIZEOF + (argCoders.length * JObjCRuntime.PTR_LEN)); - final long argsPtr = cifBuf.bufferPtr + SIZEOF; - - { - long argsIterPtr = argsPtr; - for(final Coder coder : argCoders){ - PrimitivePointerCoder.INST.push(args.runtime, argsIterPtr, coder.getFFITypePtr()); - argsIterPtr += JObjCRuntime.PTR_LEN; - } - } - - boolean ok = prepCIF(cifBuf.bufferPtr, argCoders.length, returnCoder.getFFITypePtr(), argsPtr); - if(!ok) - throw new RuntimeException("ffi_prep_cif failed."); - - return new CIF(cifBuf, returnCoder, argCoders); - } - - final NativeBuffer cif; - // CIF needs to keep refs to the Coders, so they don't get finalized and their FFITypes freed. - final Coder returnCoder; - final Coder[] argCoders; - - private CIF(final NativeBuffer cif, Coder returnCoder, Coder... argCoders) { - this.cif = cif; - this.returnCoder = returnCoder; - this.argCoders = argCoders; - } -} diff --git a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Coder.java b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Coder.java deleted file mode 100644 index 9efc76e9c05..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Coder.java +++ /dev/null @@ -1,289 +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. - */ -package com.apple.jobjc; - -import java.io.StringWriter; -import java.lang.reflect.Method; - -import com.apple.jobjc.JObjCRuntime.Width; -import com.apple.jobjc.PrimitiveCoder.BoolCoder; -import com.apple.jobjc.PrimitiveCoder.DoubleCoder; -import com.apple.jobjc.PrimitiveCoder.FloatCoder; -import com.apple.jobjc.PrimitiveCoder.SCharCoder; -import com.apple.jobjc.PrimitiveCoder.SIntCoder; -import com.apple.jobjc.PrimitiveCoder.SLongLongCoder; -import com.apple.jobjc.PrimitiveCoder.SShortCoder; - -public abstract class Coder { - private static native long getNativeFFITypePtrForCode(final int code); - - static final int FFI_VOID = 0; - static final int FFI_PTR = FFI_VOID+1; - - static final int FFI_SINT8 = FFI_PTR+1; - static final int FFI_UINT8 = FFI_SINT8+1; - static final int FFI_SINT16 = FFI_UINT8+1; - static final int FFI_UINT16 = FFI_SINT16+1; - static final int FFI_SINT32 = FFI_UINT16+1; - static final int FFI_UINT32 = FFI_SINT32+1; - static final int FFI_SINT64 = FFI_UINT32+1; - static final int FFI_UINT64 = FFI_SINT64+1; - - static final int FFI_FLOAT = FFI_UINT64+1; - static final int FFI_DOUBLE = FFI_FLOAT+1; - static final int FFI_LONGDOUBLE = FFI_DOUBLE+1; - - private static long[] ffiCodesToFFITypePtrs; - static{ - System.loadLibrary("JObjC"); - ffiCodesToFFITypePtrs = new long[FFI_LONGDOUBLE + 1]; - for (int i = 0; i < FFI_LONGDOUBLE + 1; i++) ffiCodesToFFITypePtrs[i] = getNativeFFITypePtrForCode(i); - } - - long getFFITypePtr() { - return ffiCodesToFFITypePtrs[getTypeCode()]; - } - - // runtime coding - public abstract void push(final JObjCRuntime runtime, final long addr, final T x); - public abstract T pop(final JObjCRuntime runtime, final long addr); - - public void push(final NativeArgumentBuffer args, final T x){ - push(args.runtime, args.argValuesPtr, x); - args.didPutArgValue(sizeof()); - } - - public T pop(final NativeArgumentBuffer args){ - return pop(args.runtime, args.retValPtr); - } - - public abstract int sizeof(Width w); - final public int sizeof(){ return sizeof(JObjCRuntime.WIDTH); } - - // - - public Coder(int ffiTypeCode, String objCEncoding, Class jclass, Class jprim) { - this.ffiTypeCode = ffiTypeCode; - this.objCEncoding = objCEncoding; - this.jclass = jclass; - this.jprim = jprim; - } - - public Coder(int ffiTypeCode, String objCEncoding, Class jclass) { - this(ffiTypeCode, objCEncoding, jclass, null); - } - - private final int ffiTypeCode; - private final String objCEncoding; - private final Class jclass; - private final Class jprim; - - final int getTypeCode() { return ffiTypeCode; } - final String getObjCEncoding(){ return objCEncoding; } - public final Class getJavaClass() { return jclass; } - public final Class getJavaPrimitive() { return jprim; } - - // runtime coding - - private static Coder[] runtimeCoders; - static public Coder getCoderAtRuntimeForType(Class cls){ - if(runtimeCoders == null) runtimeCoders = new Coder[]{ - NSClassCoder.INST, IDCoder.INST, PointerCoder.INST, - DoubleCoder.INST, FloatCoder.INST, SLongLongCoder.INST, - SIntCoder.INST, SShortCoder.INST, SCharCoder.INST, BoolCoder.INST, - VoidCoder.INST - }; - - for(Coder c : runtimeCoders) - if((c.getJavaClass() != null && c.getJavaClass().isAssignableFrom(cls)) || - (c.getJavaPrimitive() != null && c.getJavaPrimitive().isAssignableFrom(cls))) - return c; - - if(Struct.class.isAssignableFrom(cls)){ - try { - Method m = cls.getDeclaredMethod("getStructCoder"); - m.setAccessible(true); - return (Coder) m.invoke(null); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - throw new RuntimeException("Could not find suitable coder for " + cls); - } - - static public Coder getCoderAtRuntime(Object inst){ - if(inst == null) return PointerCoder.INST; - if(inst instanceof Struct) return ((Struct) inst).getCoder(); - return getCoderAtRuntimeForType(inst.getClass()); - } - - // - - public static final class VoidCoder extends Coder{ - public static final VoidCoder INST = new VoidCoder(); - public VoidCoder(){ super(FFI_VOID, "v", Void.class, void.class); } - @Override public int sizeof(Width w) { return -1; } - @Override public Object pop(JObjCRuntime runtime, long addr) { throw new RuntimeException("Trying to pop a Void."); } - @Override public void push(JObjCRuntime runtime, long addr, Object x) { throw new RuntimeException("Trying to push a Void."); } - } - - public static final class UnknownCoder extends Coder { - public static final UnknownCoder INST = new UnknownCoder(); - public UnknownCoder(){ super(-1, "?", null, null); } - @Override public int sizeof(Width w) { return -1; } - @Override public void push(JObjCRuntime runtime, long addr, Object x) { throw new RuntimeException("Coder not implemented");} - @Override public Object pop(JObjCRuntime runtime, long addr) { throw new RuntimeException("Coder not implemented"); } - } - - public static final class PrimitivePointerCoder extends Coder { - public static final PrimitivePointerCoder INST = new PrimitivePointerCoder(); - public PrimitivePointerCoder(){ super(Coder.FFI_PTR, "^?", Long.class, long.class); } - @Override public int sizeof(Width w) { return JObjCRuntime.PTR_LEN; } - - public void push(JObjCRuntime runtime, long addr, long x) { - if(JObjCRuntime.IS64) - runtime.unsafe.putLong(addr, x); - else - runtime.unsafe.putInt(addr, (int) x); - } - - public void push(final JObjCRuntime runtime, final NativeArgumentBuffer argBuf, final long ptr) { - push(runtime, argBuf.argValuesPtr, ptr); - argBuf.didPutArgValue(sizeof()); - } - - public long popPtr(final JObjCRuntime runtime, final long addr) { - return JObjCRuntime.IS64 ? runtime.unsafe.getLong(addr) : runtime.unsafe.getInt(addr); - } - - public long popPtr(final JObjCRuntime runtime, final NativeArgumentBuffer argBuf) { - return popPtr(runtime, argBuf.retValPtr); - } - - @Override public Long pop(JObjCRuntime runtime, long addr) { return popPtr(runtime, addr); } - @Override public void push(JObjCRuntime runtime, long addr, Long x) { push(runtime, addr, (long) x); } - } - - public static final class PointerCoder extends Coder { - public static final PointerCoder INST = new PointerCoder(); - public PointerCoder(){ super(FFI_PTR, "^?", Pointer.class); } - @Override public int sizeof(Width w) { return PrimitivePointerCoder.INST.sizeof(w); } - - @Override public Pointer pop(JObjCRuntime runtime, long addr) { - return new Pointer(PrimitivePointerCoder.INST.popPtr(runtime, addr)); - } - @Override public void push(JObjCRuntime runtime, long addr, Pointer x) { - PrimitivePointerCoder.INST.push(runtime, addr, x == null ? 0 : x.ptr); - } - } - - public static final class SELCoder extends Coder { - public static final SELCoder INST = new SELCoder(); - public SELCoder(){ super(FFI_PTR, ":", SEL.class); } - @Override public int sizeof(Width w) { return PrimitivePointerCoder.INST.sizeof(w); } - - @Override public void push(JObjCRuntime runtime, long addr, SEL x) { - PrimitivePointerCoder.INST.push(runtime, addr, x == null ? 0 : x.selPtr); - } - @Override public SEL pop(JObjCRuntime runtime, long addr) { - return new SEL(PrimitivePointerCoder.INST.popPtr(runtime, addr)); - } - } - - public static abstract class StructCoder extends Coder { - private final FFIType ffiType; - final int sizeof; - - public StructCoder(final int sizeof, final Coder... elementCoders){ - super(-1, objCEncoding(elementCoders), null); - this.ffiType = new FFIType(elementCoders); - this.sizeof = sizeof; - } - - @Override public int sizeof(Width w) { return sizeof; } - - private static String objCEncoding(final Coder[] elementCoders) { - StringWriter str = new StringWriter(); - str.append("{?="); - for(Coder c : elementCoders) - str.append(c.getObjCEncoding()); - str.append("}"); - return str.toString(); - } - - @Override long getFFITypePtr() { return ffiType.getPtr(); } - - @Override public void push(NativeArgumentBuffer argBuf, Struct x) { - // Just point to the instance on the heap instead of copying it onto the arg buf. - argBuf.doPutArgPtr(x.raw.bufferPtr); - } - - @Override public void push(JObjCRuntime rt, long addr, Struct x) { - rt.unsafe.copyMemory(x.raw.bufferPtr, addr, sizeof); - } - - protected abstract Struct newInstance(JObjCRuntime runtime); - - @Override public Struct pop(final JObjCRuntime runtime, final long addr) { - Struct s = newInstance(runtime); - runtime.unsafe.copyMemory(addr, s.raw.bufferPtr, sizeof); - return s; - } - } - - public static final class IDCoder extends Coder{ - public static final IDCoder INST = new IDCoder(); - public IDCoder(){ super(FFI_PTR, "@", ID.class); } - @Override public int sizeof(Width w) { return PrimitivePointerCoder.INST.sizeof(w); } - - public T newID(final JObjCRuntime runtime, final long objPtr) { - return (T) ID.getObjCObjectFor(runtime, objPtr); - } - - @Override public ID pop(final JObjCRuntime runtime, final long addr) { - return newID(runtime, PrimitivePointerCoder.INST.popPtr(runtime, addr)); - } - - @Override public void push(final JObjCRuntime runtime, final long addr, final ID x) { - PointerCoder.INST.push(runtime, addr, x); - } - } - - public static final class NSClassCoder extends Coder{ - public static final NSClassCoder INST = new NSClassCoder(); - public NSClassCoder(){ super(FFI_PTR, "#", NSClass.class); } - @Override public int sizeof(Width w) { return PrimitivePointerCoder.INST.sizeof(w); } - - @Override public NSClass pop(JObjCRuntime runtime, long addr) { - final long clsPtr = PrimitivePointerCoder.INST.popPtr(runtime, addr); - if (clsPtr == 0) return null; - return NSClass.getObjCClassFor(runtime, clsPtr); - } - @Override public void push(JObjCRuntime runtime, long addr, NSClass x) { - PointerCoder.INST.push(runtime, addr, x); - } - } -} diff --git a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/FFIType.java b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/FFIType.java deleted file mode 100644 index dcff0035587..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/FFIType.java +++ /dev/null @@ -1,57 +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. - */ -package com.apple.jobjc; - -import com.apple.jobjc.Coder.PrimitivePointerCoder; - - -class FFIType{ - private static native void makeFFIType(long ffi_type_buf, long elements_buf); - private static native int getFFITypeSizeof(); - private static int FFI_TYPE_SIZEOF = getFFITypeSizeof(); - final NativeBuffer ffi_type; - final NativeBuffer elements; - final Coder[] elementCoders; - - public FFIType(final Coder... elementCoders){ - final JObjCRuntime runtime = JObjCRuntime.inst(); - this.elementCoders = elementCoders; - this.ffi_type = new NativeBuffer(FFI_TYPE_SIZEOF); - this.elements = new NativeBuffer(JObjCRuntime.PTR_LEN * (elementCoders.length + 1)); - - long elIterPtr = elements.bufferPtr; - for(Coder c : elementCoders){ - PrimitivePointerCoder.INST.push(runtime, elIterPtr, c.getFFITypePtr()); - elIterPtr += PrimitivePointerCoder.INST.sizeof(); - } - PrimitivePointerCoder.INST.push(runtime, elIterPtr, 0); - - makeFFIType(ffi_type.bufferPtr, elements.bufferPtr); - } - - public long getPtr(){ - return ffi_type.bufferPtr; - } -} diff --git a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Function.java b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Function.java deleted file mode 100644 index 413d8fafe76..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Function.java +++ /dev/null @@ -1,60 +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. - */ -package com.apple.jobjc; - - -public class Function { - private static native long getFxnPtrForFunctionName(final String functionName); - private static native long getFxnPtrForFunctionNameAndLib(final long libPtr, final String functionName); - - final long fxnPtr; - - Function(final long fxnPtr) { - this.fxnPtr = fxnPtr; - } - - public Function(final String name) { - this(getFxnPtr(name)); - } - - public Function(final MacOSXFramework framework, final String name) { - this(getFxnPtr(name, framework)); - } - - static long getFxnPtr(final String name){ - long fxnPtr = getFxnPtrForFunctionName(name); - if(fxnPtr == 0) throw new RuntimeException("Function pointer for " + name + " not found in runtime."); - return fxnPtr; - } - - static long getFxnPtr(final String name, final MacOSXFramework framework){ - long fxnPtr = 0; - for(int i = 0; fxnPtr == 0 && i < framework.nativeLibPtrs.length; i++){ - fxnPtr = getFxnPtrForFunctionNameAndLib(framework.nativeLibPtrs[i], name); - if(fxnPtr != 0) return fxnPtr; - } - throw new RuntimeException("Function pointer for " + name + " not found in framework " + framework + "."); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/ID.java b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/ID.java deleted file mode 100644 index aa202cf0943..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/ID.java +++ /dev/null @@ -1,163 +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. - */ -package com.apple.jobjc; - -import java.lang.ref.WeakReference; -import java.lang.reflect.Constructor; -import java.util.LinkedHashMap; -import java.util.Map; - - -public class ID extends Pointer{ - static native String getNativeDescription(final long objPtr); - - final JObjCRuntime runtime; - - static final Class[] CTOR_ARGS = { long.class, JObjCRuntime.class }; - protected ID(final long objPtr, final JObjCRuntime runtime) { - super(objPtr); - runtime.assertOK(); - this.runtime = runtime; - } - - protected ID(final ID obj, final JObjCRuntime runtime) { - this(obj.ptr, runtime); - } - - @Override protected NativeObjectLifecycleManager getNativeObjectLifecycleManager() { - return NativeObjectLifecycleManager.CFRetainRelease.INST; - } - - protected final JObjCRuntime getRuntime() { return runtime; } - - @Override public String toString(){ - String s = super.toString(); - return s + " (ObjC: " + ptr + " / " + Long.toHexString(ptr) + ")"; - } - - // - - public static T getInstance(final long ptr, final JObjCRuntime runtime){ - return (T) getObjCObjectFor(runtime, ptr); - } - - static T getObjCObjectFor(final JObjCRuntime runtime, final long objPtr){ - if (objPtr == 0) return null; - - final WeakReference cachedObj = objectCache.get().get(objPtr); - if(cachedObj != null && cachedObj.get() != null) return (T) cachedObj.get(); - - final long clsPtr = NSClass.getClass(objPtr); - - final T newObj = (T) (runtime.subclassing.isUserClass(clsPtr) ? - Subclassing.getJObjectFromIVar(objPtr) - : createNewObjCObjectFor(runtime, objPtr, clsPtr)); - - objectCache.get().put(objPtr, new WeakReference(newObj)); - return newObj; - } - - static T createNewObjCObjectFor(final JObjCRuntime runtime, final long objPtr, final long clsPtr) { - final Constructor ctor = getConstructorForClassPtr(runtime, clsPtr); - return (T) createNewObjCObjectForConstructor(ctor, objPtr, runtime); - } - - @SuppressWarnings("unchecked") - static Constructor getConstructorForClassPtr(final JObjCRuntime runtime, final long clazzPtr){ - final Constructor cachedCtor = (Constructor) constructorCache.get().get(clazzPtr); - if(cachedCtor != null) return cachedCtor; - - final Class clazz = getClassForClassPtr(runtime, clazzPtr); - Constructor ctor; - try { - ctor = clazz.getDeclaredConstructor(CTOR_ARGS); - } catch (SecurityException e) { - throw new RuntimeException(e); - } catch (NoSuchMethodException e) { - throw new RuntimeException(e); - } - ctor.setAccessible(true); - constructorCache.get().put(clazzPtr, (Constructor) ctor); - return ctor; - } - - @SuppressWarnings("unchecked") - static Class getClassForClassPtr(final JObjCRuntime runtime, final long clazzPtr){ - final String className = NSClass.getClassNameOfClass(clazzPtr); - final Class clazz = (Class) runtime.getClassForNativeClassName(className); - if(clazz == null){ - final long superClazzPtr = NSClass.getSuperClassOfClass(clazzPtr); - if(superClazzPtr != 0) - return getClassForClassPtr(runtime, superClazzPtr); - } - return clazz; - } - - static T createNewObjCObjectForConstructor(final Constructor ctor, final long objPtr, final JObjCRuntime runtime) { - try { - final T newInstance = (T) ctor.newInstance(new Object[] { Long.valueOf(objPtr), runtime }); - objectCache.get().put(objPtr, new WeakReference(newInstance)); - return newInstance; - } catch (final Exception e) { - throw new RuntimeException(e); - } - } - - static T createNewObjCObjectForClass(final Class clazz, final long objPtr, final JObjCRuntime runtime) { - try { - final Constructor constructor = clazz.getDeclaredConstructor(CTOR_ARGS); - constructor.setAccessible(true); - return (T) createNewObjCObjectForConstructor(constructor, objPtr, runtime); - } catch (final Exception e) { - throw new RuntimeException(e); - } - } - - // - - static final ThreadLocal> constructorCache = new ThreadLocal>(){ - @Override protected LinkedHashMap initialValue(){ - final int MAX_ENTRIES = 1000; - final float LOAD_FACTOR = 0.75f; - return new LinkedHashMap((int) (MAX_ENTRIES/LOAD_FACTOR), LOAD_FACTOR, true) { - @Override protected boolean removeEldestEntry(Map.Entry eldest) { - return size() > MAX_ENTRIES; - } - }; - } - }; - - static final ThreadLocal> objectCache = new ThreadLocal>(){ - @Override protected LinkedHashMap initialValue(){ - final int MAX_ENTRIES = 1000; - final float LOAD_FACTOR = 0.75f; - return new LinkedHashMap((int) (MAX_ENTRIES/LOAD_FACTOR), LOAD_FACTOR, true) { - @Override protected boolean removeEldestEntry(Map.Entry eldest) { - return size() > MAX_ENTRIES || eldest.getValue().get() == null; - } - }; - } - }; -} diff --git a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Invoke.java b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Invoke.java deleted file mode 100644 index 48ffc98663f..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Invoke.java +++ /dev/null @@ -1,224 +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. - */ -package com.apple.jobjc; - -import com.apple.jobjc.Coder.IDCoder; -import com.apple.jobjc.Coder.NSClassCoder; -import com.apple.jobjc.Coder.PrimitivePointerCoder; -import com.apple.jobjc.Coder.SELCoder; -import com.apple.jobjc.Coder.StructCoder; - - -public abstract class Invoke { - public abstract void invoke(NativeArgumentBuffer argBuf); - public abstract void invoke(NativeArgumentBuffer buffer, Struct retvalStruct); - - // - - public static final class FunCall extends Invoke{ - static native void invoke(long cifPtr, long fxnPtr, long retValPtr, long argsPtr); - - final long fxnPtr; - final CIF cif; - - FunCall(long fxnPtr, CIF cif) { - this.fxnPtr = fxnPtr; - this.cif = cif; - } - - public FunCall(final JObjCRuntime runtime, final String name, final Coder returnCoder, final Coder ... argCoders) { - this(Function.getFxnPtr(name), CIF.createCIFFor(runtime.getThreadLocalState(), returnCoder, argCoders)); - } - - public FunCall(final MacOSXFramework framework, final String name, final Coder returnCoder, final Coder ... argCoders) { - this(Function.getFxnPtr(name, framework), CIF.createCIFFor(framework.getRuntime().getThreadLocalState(), returnCoder, argCoders)); - } - - public void init(final NativeArgumentBuffer argBuf) { - argBuf.reset(); - } - - @Override public void invoke(final NativeArgumentBuffer argBuf) { - invoke(argBuf, argBuf.retValPtr); - } - - @Override public void invoke(final NativeArgumentBuffer buffer, final Struct retvalStruct) { - invoke(buffer, retvalStruct.raw.bufferPtr); - } - - void invoke(final NativeArgumentBuffer argBuf, final long retValPtr) { - invoke(cif.cif.bufferPtr, fxnPtr, retValPtr, argBuf.buffer.bufferPtr); - } - } - - public static final class MsgSend extends Invoke{ - static{ System.load("/usr/lib/libobjc.dylib"); } - - private static final long OBJC_MSG_SEND_FXN_PTR = new Function("objc_msgSend").fxnPtr; - private static final long OBJC_MSG_SEND_FPRET_FXN_PTR = new Function("objc_msgSend_fpret").fxnPtr; - private static final long OBJC_MSG_SEND_STRET_FXN_PTR = new Function("objc_msgSend_stret").fxnPtr; - - final FunCall funCall; - final long selPtr; - - public MsgSend(final JObjCRuntime runtime, final String name, final Coder returnCoder, final Coder ... argCoders) { - this.funCall = new FunCall(getMsgSendFxnPtr(returnCoder), - CIF.createCIFFor(runtime.getThreadLocalState(), returnCoder, getSelCoders(argCoders))); - this.selPtr = SEL.getSelectorPtr(name); - } - - public void init(final NativeArgumentBuffer nativeBuffer, final ID obj) { - funCall.init(nativeBuffer); - IDCoder.INST.push(nativeBuffer, obj); - PrimitivePointerCoder.INST.push(nativeBuffer.runtime, nativeBuffer, selPtr); - } - - @Override public void invoke(final NativeArgumentBuffer argBuf) { - funCall.invoke(argBuf); - } - - @Override public void invoke(final NativeArgumentBuffer buffer, final Struct retvalStruct) { - funCall.invoke(buffer, retvalStruct); - } - - // support - - static Coder[] getSelCoders(final Coder[] argCoders) { - final Coder[] selArgCoders = new Coder[argCoders.length + 2]; - selArgCoders[0] = IDCoder.INST; - selArgCoders[1] = SELCoder.INST; - for (int i = 0; i < argCoders.length; i++) - selArgCoders[i + 2] = argCoders[i]; - return selArgCoders; - } - - static long getMsgSendFxnPtr(final Coder returnCoder) { - if(returnCoder instanceof StructCoder){ - StructCoder scoder = (StructCoder) returnCoder; - - switch(JObjCRuntime.ARCH){ - case ppc: - return OBJC_MSG_SEND_STRET_FXN_PTR; - case i386: - switch(scoder.sizeof){ - case 1: case 2: case 4: case 8: - return OBJC_MSG_SEND_FXN_PTR; - } - return OBJC_MSG_SEND_STRET_FXN_PTR; - case x86_64: - if(scoder.sizeof > 16) - return OBJC_MSG_SEND_STRET_FXN_PTR; - else - return OBJC_MSG_SEND_FXN_PTR; - default: - throw new RuntimeException(); - } - } - - final int typeCode = returnCoder.getTypeCode(); - - switch(JObjCRuntime.ARCH){ - case ppc: - return OBJC_MSG_SEND_FXN_PTR; - case i386: - switch(typeCode) { - case Coder.FFI_FLOAT: case Coder.FFI_DOUBLE: case Coder.FFI_LONGDOUBLE: - return OBJC_MSG_SEND_FPRET_FXN_PTR; - } - return OBJC_MSG_SEND_FXN_PTR; - case x86_64: - if(typeCode == Coder.FFI_LONGDOUBLE) - return OBJC_MSG_SEND_FPRET_FXN_PTR; - return OBJC_MSG_SEND_FXN_PTR; - default: - throw new RuntimeException(); - } - } - } - - public static final class MsgSendSuper extends Invoke{ - static{ System.load("/usr/lib/libobjc.dylib"); } - - private static final long OBJC_MSG_SEND_SUPER_FXN_PTR = new Function("objc_msgSendSuper").fxnPtr; - private static final long OBJC_MSG_SEND_SUPER_STRET_FXN_PTR = new Function("objc_msgSendSuper_stret").fxnPtr; - - final FunCall funCall; - final long selPtr; - - public MsgSendSuper(final JObjCRuntime runtime, final String name, final Coder returnCoder, final Coder ... argCoders) { - this.funCall = new FunCall(getMsgSendSuperFxnPtr(returnCoder), - CIF.createCIFFor(runtime.getThreadLocalState(), returnCoder, getSuperSelCoders(argCoders))); - this.selPtr = SEL.getSelectorPtr(name); - } - - public void init(final NativeArgumentBuffer argBuf, final ID obj, final NSClass cls) { - funCall.init(argBuf); - - // Instead of mallocing a struct, or keeping another thread local, - // let's write objc_super out to the argbuf, and then point an argument - // to the data. - - final long valPtr = argBuf.argValuesPtr; - final int ptrLen = JObjCRuntime.PTR_LEN; - - IDCoder .INST.push(argBuf.runtime, valPtr, obj); - NSClassCoder.INST.push(argBuf.runtime, valPtr + ptrLen, cls); - argBuf.argValuesPtr += ptrLen + ptrLen; - - PrimitivePointerCoder.INST.push(argBuf.runtime, argBuf, valPtr); - PrimitivePointerCoder.INST.push(argBuf.runtime, argBuf, selPtr); - } - - @Override public void invoke(final NativeArgumentBuffer argBuf) { - funCall.invoke(argBuf); - } - - @Override public void invoke(final NativeArgumentBuffer buffer, final Struct retvalStruct) { - funCall.invoke(buffer, retvalStruct); - } - - // - - private final static StructCoder objc_super_coder = new StructCoder(JObjCRuntime.PTR_LEN*2, IDCoder.INST, NSClassCoder.INST){ - @Override protected Struct newInstance(JObjCRuntime runtime) { return null; }}; - - static Coder[] getSuperSelCoders(final Coder[] argCoders) { - final Coder[] selArgCoders = new Coder[argCoders.length + 2]; - selArgCoders[0] = objc_super_coder; - selArgCoders[1] = SELCoder.INST; - for (int i = 0; i < argCoders.length; i++) - selArgCoders[i + 2] = argCoders[i]; - return selArgCoders; - } - - static long getMsgSendSuperFxnPtr(final Coder returnCoder){ - long normal = MsgSend.getMsgSendFxnPtr(returnCoder); - if(normal == MsgSend.OBJC_MSG_SEND_STRET_FXN_PTR) - return OBJC_MSG_SEND_SUPER_STRET_FXN_PTR; - else - return OBJC_MSG_SEND_SUPER_FXN_PTR; - } - } -} diff --git a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/JObjCRuntime.java b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/JObjCRuntime.java deleted file mode 100644 index 5bc01bc4e97..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/JObjCRuntime.java +++ /dev/null @@ -1,139 +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. - */ -package com.apple.jobjc; - -import java.lang.reflect.Field; -import java.nio.ByteOrder; -import java.util.ArrayList; -import java.util.List; - -import sun.misc.Unsafe; - - -public final class JObjCRuntime { - static { System.loadLibrary("JObjC"); } - - public static enum Arch{ ppc, i386, x86_64 }; - public static enum Width{ W32, W64 }; - - public static final Arch ARCH = getArch(); - public static final Width WIDTH = getWidth(); - - private static Arch getArch(){ - String arch = System.getProperty("os.arch"); - if("ppc".equals(arch)) return Arch.ppc; - if("i386".equals(arch)) return Arch.i386; - if("x86_64".equals(arch)) return Arch.x86_64; - if("amd64".equals(arch)) return Arch.x86_64; - if("universal".equals(arch)) return Arch.x86_64; - throw new RuntimeException("Did not recognize os.arch system property: '" + arch + "'"); - } - - private static Width getWidth(){ - String width = System.getProperty("sun.arch.data.model"); - if("32".equals(width)) return Width.W32; - if("64".equals(width)) return Width.W64; - throw new RuntimeException("Did not recognize sun.arch.data.model system property: '" + width + "'"); - } - - public static final boolean IS32 = System.getProperty("sun.arch.data.model").equals("32"); - public static final boolean IS64 = System.getProperty("sun.arch.data.model").equals("64"); - public static final int PTR_LEN = IS64 ? 8 : 4; - public static final boolean IS_BIG_ENDIAN = ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN; - static final boolean DEBUG = Boolean.parseBoolean(System.getProperty("JObjC.debug")); - - static void checkPermission(){ - final SecurityManager security = System.getSecurityManager(); - if (security != null) security.checkPermission(new RuntimePermission("canProcessApplicationEvents")); - } - - public final void assertOK(){ - if(this != instance) - throw new SecurityException("runtime"); - } - - private JObjCRuntime(){} - - private static JObjCRuntime instance; - static JObjCRuntime inst() { - if (instance == null) instance = new JObjCRuntime(); - return instance; - } - - public static JObjCRuntime getInstance() { - checkPermission(); - return inst(); - } - - public final NativeArgumentBuffer getThreadLocalState() { - return NativeArgumentBuffer.getThreadLocalBuffer(this); - } - - final Unsafe unsafe = getUnsafe(); - final Subclassing subclassing = new Subclassing(this); - final List registeredPackages = new ArrayList(); - - @SuppressWarnings("unchecked") - Class getClassForNativeClassName(final String className) { - for (final String pkg : registeredPackages) { - try { - final Class clazz = Class.forName(pkg + "." + className); - if (clazz != null) return (Class)clazz; - } catch (final ClassNotFoundException e) { } - } - - return null; - } - - private final static Unsafe getUnsafe() { - Unsafe inst = null; - try { - Field f = Unsafe.class.getDeclaredField("theUnsafe"); - f.setAccessible(true); - inst = (Unsafe) f.get(null); - if(inst == null) throw new NullPointerException("Unsafe.theUnsafe == null"); - } catch (Exception e) { - throw new RuntimeException("Unable to get instance of Unsafe.", e); - } - return inst; - } - - public void registerPackage(final String pkg) { - registeredPackages.add(pkg); - } - - /** - * Register a subclass of NSObject to allow the native side to send - * messages which in turn call java methods declared on the class. - * If a native class by the same name already exists, registerClass - * will simply return without doing anything. - * - * For a usage example, see the SubclassingTest. - */ - public boolean registerUserClass(Class clazz, Class clazzClazz) { - return subclassing.registerUserClass(clazz, clazzClazz); - } - -} diff --git a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/MacOSXFramework.java b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/MacOSXFramework.java deleted file mode 100644 index bd776688f7d..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/MacOSXFramework.java +++ /dev/null @@ -1,74 +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. - */ -package com.apple.jobjc; - - - -public class MacOSXFramework { - private static native long retainFramework(final String frameworkName); - private static native void releaseFramework(final long frameworkPtr); - private static native void getConstant(final long frameworkPtr, String symbol, final long bufferPtr, final int size); - - private final JObjCRuntime runtime; - protected final long[] nativeLibPtrs; - - final long getFrameworkPtr() { return nativeLibPtrs.length > 0 ? nativeLibPtrs[0] : 0; } - - private static long[] createFrameworkPtrsFromPaths(final String[] frameworkLibPaths) { - final long[] libPtrs = new long[frameworkLibPaths.length]; - for(int i = 0; i < libPtrs.length; i++){ - libPtrs[i] = retainFramework(frameworkLibPaths[i]); - if(libPtrs[i] == 0) throw new RuntimeException("Could not open library at " + frameworkLibPaths[i]); - } - return libPtrs; - } - - protected MacOSXFramework(final JObjCRuntime runtime, final String[] nativeLibPaths) { - runtime.assertOK(); - this.runtime = runtime; - this.nativeLibPtrs = createFrameworkPtrsFromPaths(nativeLibPaths); - } - - @Override protected final synchronized void finalize() throws Throwable { - for(long lib : nativeLibPtrs) - if(lib != 0) releaseFramework(lib); - } - - protected final JObjCRuntime getRuntime(){ return runtime; } - - protected void getConstant(final String symbol, final long retValPtr, final int size){ - assert size >= 0; - assert retValPtr != 0; - getConstant(getFrameworkPtr(), symbol, retValPtr, size); - } - - protected void getConstant(final String symbol, final NativeArgumentBuffer out, final int size){ - getConstant(symbol, out.retValPtr, size); - } - - protected void getConstant(final String symbol, final Struct out, final int size){ - getConstant(symbol, out.raw.bufferPtr, size); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NSClass.java b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NSClass.java deleted file mode 100644 index dfda99acf35..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NSClass.java +++ /dev/null @@ -1,117 +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. - */ -package com.apple.jobjc; - -import java.lang.ref.WeakReference; -import java.lang.reflect.Constructor; - - -public class NSClass extends ID { - public static class NSClassNotFoundException extends RuntimeException{ - public NSClassNotFoundException(String m){ super(m); } - public NSClassNotFoundException(String m, Throwable cause){ super(m, cause); } - } - - static native long getNativeClassByName(String name); - static native long getSuperClassOfClass(long classPtr); - static native String getClassNameOfClass(long classPtr); - static native long getClass(long objPtr); - - public NSClass(final long ptr, final JObjCRuntime runtime) { - super(ptr, runtime); - } - - public NSClass(final String name, final JObjCRuntime runtime) { - this(getNativeClassByName(name), runtime); - if(ptr == 0) throw new NSClassNotFoundException("NSClass pointer is 0. Found no class named " + name); - } - - protected NSClass(final JObjCRuntime runtime){ - super(0, runtime); - final String sn = getClass().getSimpleName(); - final String name = sn.substring(0, sn.lastIndexOf("Class")); - ptr = getNativeClassByName(name); - if(ptr == 0) throw new NSClassNotFoundException("NSClass pointer is 0. Found no class named " + name); - } - - NSClass getSuperClass() { - return new NSClass(getSuperClassOfClass(ptr), runtime); - } - - String getClassName() { return getClassNameOfClass(ptr); } - - @Override protected NativeObjectLifecycleManager getNativeObjectLifecycleManager() { - return NativeObjectLifecycleManager.Nothing.INST; - } - - @Override public boolean equals(Object o){ - return (o instanceof NSClass) && (this.ptr == ((NSClass) o).ptr); - } - - // - - static T getObjCClassFor(final JObjCRuntime runtime, final long clsPtr){ - if (clsPtr == 0) return null; - - final WeakReference cachedObj = objectCache.get().get(clsPtr); - if(cachedObj != null && cachedObj.get() != null) return (T) cachedObj.get(); - - final T newObj = (T) createNewObjCClassFor(runtime, clsPtr); - objectCache.get().put(clsPtr, new WeakReference(newObj)); - return newObj; - } - - static T createNewObjCClassFor(final JObjCRuntime runtime, final long clsPtr) { - final Constructor ctor = getNSClassConstructorForClassPtr(runtime, clsPtr); - return (T) createNewObjCObjectForConstructor(ctor, clsPtr, runtime); - } - - @SuppressWarnings("unchecked") - static Constructor getNSClassConstructorForClassPtr(final JObjCRuntime runtime, final long clazzPtr){ - final Class clazz = getNSClassForClassPtr(runtime, clazzPtr); - Constructor ctor; - try { - ctor = clazz.getDeclaredConstructor(CTOR_ARGS); - } catch (SecurityException e) { - throw new RuntimeException(e); - } catch (NoSuchMethodException e) { - throw new RuntimeException(e); - } - ctor.setAccessible(true); - return ctor; - } - - @SuppressWarnings("unchecked") - static Class getNSClassForClassPtr(final JObjCRuntime runtime, final long clazzPtr){ - final String className = NSClass.getClassNameOfClass(clazzPtr); - final Class clazz = (Class) runtime.getClassForNativeClassName(className + "Class"); - if(clazz == null){ - final long superClazzPtr = NSClass.getSuperClassOfClass(clazzPtr); - if(superClazzPtr != 0) - return getNSClassForClassPtr(runtime, superClazzPtr); - } - return clazz; - } -} diff --git a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NativeArgumentBuffer.java b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NativeArgumentBuffer.java deleted file mode 100644 index 7f8949a2b40..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NativeArgumentBuffer.java +++ /dev/null @@ -1,112 +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. - */ -package com.apple.jobjc; - -import java.nio.ByteOrder; - -import com.apple.jobjc.Coder.PrimitivePointerCoder; - - -public final class NativeArgumentBuffer{ - private static final ThreadLocal threadLocal = new ThreadLocal(); - - static NativeArgumentBuffer getThreadLocalBuffer(final JObjCRuntime runtime) { - runtime.assertOK(); - final NativeArgumentBuffer alreadyCreated = threadLocal.get(); - if (alreadyCreated != null) return alreadyCreated; - - final NativeArgumentBuffer newThreadLocalState = new NativeArgumentBuffer(runtime); - threadLocal.set(newThreadLocalState); - return newThreadLocalState; - } - - final JObjCRuntime runtime; - - final NativeBuffer buffer; - - long argPtrsPtr; - long argValuesPtr; - final long retValPtr; - - private static final int MAX_ARGS = 512; - private static final int BUF_SIZE = MAX_ARGS * 8 * 2; - private static final int ARG_VALS_OFFSET = BUF_SIZE/2; - - private NativeArgumentBuffer(final JObjCRuntime runtime) { - runtime.assertOK(); - this.runtime = runtime; - this.buffer = new NativeBuffer(BUF_SIZE); - this.buffer.buffer.order(ByteOrder.nativeOrder()); - - reset(); - this.retValPtr = buffer.bufferPtr; - } - - - // Call before each new call - public void reset() { - argPtrsPtr = buffer.bufferPtr; - argValuesPtr = buffer.bufferPtr + ARG_VALS_OFFSET; - assert buffer.ptrInBounds(argValuesPtr); - } - - // Push a pointer to a block of memory - public void doPutArgPtr(long ptr) { - assert buffer.ptrInBounds(argPtrsPtr); - PrimitivePointerCoder.INST.push(runtime, argPtrsPtr, ptr); - argPtrsPtr += JObjCRuntime.PTR_LEN; - } - - // Call this after having written a value of size `sizeof` to `argValuesPtr`. - public void didPutArgValue(int sizeof) { - assert buffer.ptrInBounds(argValuesPtr); - doPutArgPtr(argValuesPtr); - argValuesPtr += sizeof; - } - - - @Override public String toString() { - final StringBuilder builder = new StringBuilder(); - final long bptr = buffer.bufferPtr; - - for(long i = bptr; i < bptr + ARG_VALS_OFFSET; i += JObjCRuntime.PTR_LEN){ - if(argPtrsPtr == i) - builder.append("*"); - builder.append(PrimitivePointerCoder.INST.popPtr(JObjCRuntime.inst(), i)); - builder.append(" "); - } - - builder.append("\n"); - - for(long i = bptr + ARG_VALS_OFFSET; i < bptr + BUF_SIZE; i += JObjCRuntime.PTR_LEN){ - if(argValuesPtr == i) - builder.append("*"); - builder.append(PrimitivePointerCoder.INST.popPtr(JObjCRuntime.inst(), i)); - builder.append(" "); - } - - return builder.toString(); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NativeBuffer.java b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NativeBuffer.java deleted file mode 100644 index 8630971c206..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NativeBuffer.java +++ /dev/null @@ -1,109 +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. - */ -package com.apple.jobjc; - -import java.nio.ByteBuffer; -import java.nio.ByteOrder; - - -/** - * A wrapper around a direct ByteBuffer and its native pointer. For documentation, @see java.nio.ByteBuffer - */ -public class NativeBuffer { - static native long getPtrOfBuffer(final ByteBuffer byteBuffer); - - public final ByteBuffer buffer; - public final long bufferPtr; - - public NativeBuffer(final int capacity){ - this(ByteBuffer.allocateDirect(capacity)); - } - - /** - * Wrap a ByteBuffer and set the ByteOrder to nativeOrder. - */ - public NativeBuffer(ByteBuffer buffer){ - this.buffer = buffer; - this.bufferPtr = getPtrOfBuffer(buffer); - assert buffer != null; - assert bufferPtr != 0; - this.buffer.order(ByteOrder.nativeOrder()); - } - - public byte get() { return buffer.get(); } - public char getChar() { return buffer.getChar(); } - public double getDouble() { return buffer.getDouble(); } - public float getFloat() { return buffer.getFloat(); } - public int getInt() { return buffer.getInt(); } - public long getLong() { return buffer.getLong(); } - public short getShort() { return buffer.getShort(); } - public NativeBuffer put(byte b) { buffer.put(b); return this; } - public NativeBuffer put(NativeBuffer src) { buffer.put(src.buffer); return this; } - public NativeBuffer putChar(char c) { buffer.putChar(c); return this; } - public NativeBuffer putDouble(double d) { buffer.putDouble(d); return this; } - public NativeBuffer putFloat(float f) { buffer.putFloat(f); return this; } - public NativeBuffer putInt(int i) { buffer.putInt(i); return this; } - public NativeBuffer putLong(long l) { buffer.putLong(l); return this; } - public NativeBuffer putShort(short s) { buffer.putShort(s); return this; } - - public int capacity() { return buffer.capacity(); } - public int position() { return buffer.position(); } - public NativeBuffer position(int newPosition) { buffer.position(newPosition); return this; } - public NativeBuffer rewind(){ buffer.rewind(); return this; } - - public int limit() { return buffer.limit(); } - public NativeBuffer limit(final int sizeof) { buffer.limit(sizeof); return this; } - - public int remaining() { return buffer.remaining(); } - - public NativeBuffer slice(){ return new NativeBuffer(buffer.slice()); } - - @Override public String toString() { - final StringBuilder builder = new StringBuilder(); - - for(int i = 0; i < limit(); i += JObjCRuntime.PTR_LEN){ - if(position() == i) - builder.append("*"); - if(JObjCRuntime.IS32) - builder.append(buffer.getInt(i)); - else - builder.append(buffer.getLong(i)); - builder.append(" "); - } - - return builder.toString(); - } - - public long positionPtr() { - return bufferPtr + position(); - } - - /** - * bufferPtr <= ptr && ptr < bufferPtr + capacity(); - */ - public boolean ptrInBounds(final long ptr){ - return bufferPtr <= ptr && ptr < bufferPtr + capacity(); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NativeObjectLifecycleManager.java b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NativeObjectLifecycleManager.java deleted file mode 100644 index 993be3337fe..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NativeObjectLifecycleManager.java +++ /dev/null @@ -1,55 +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. - */ -package com.apple.jobjc; - - -public abstract class NativeObjectLifecycleManager { - private static native void retainNativeObject(final long ptr); - private static native void releaseNativeObject(final long ptr); - private static native void freeNativeObject(final long ptr); - - abstract void begin(final long ptr); - abstract void end(final long ptr); - boolean shouldPreRetain() { return false; } - - public static class CFRetainRelease extends NativeObjectLifecycleManager { - public static final NativeObjectLifecycleManager INST = new CFRetainRelease(); - @Override void begin(final long ptr) { retainNativeObject(ptr); } - @Override void end(final long ptr) { releaseNativeObject(ptr); } - @Override boolean shouldPreRetain() { return true; } - } - - public static class Free extends NativeObjectLifecycleManager { - public static final NativeObjectLifecycleManager INST = new Free(); - @Override void begin(final long ptr) { } - @Override void end(final long ptr) { freeNativeObject(ptr); } - } - - public static class Nothing extends NativeObjectLifecycleManager { - public static final NativeObjectLifecycleManager INST = new Nothing(); - @Override void begin(final long ptr) { } - @Override void end(final long ptr) { } - } -} diff --git a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Pointer.java b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Pointer.java deleted file mode 100644 index d5b83b93930..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Pointer.java +++ /dev/null @@ -1,57 +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. - */ -package com.apple.jobjc; - - -public class Pointer implements Comparable>{ - long ptr; - - protected Pointer(final long ptr) { - this.ptr = ptr; - getNativeObjectLifecycleManager().begin(ptr); - } - - @Override protected final synchronized void finalize() throws Throwable { - long pptr = ptr; - ptr = 0; - if (pptr != 0) getNativeObjectLifecycleManager().end(pptr); - } - - protected NativeObjectLifecycleManager getNativeObjectLifecycleManager() { - return NativeObjectLifecycleManager.Nothing.INST; - } - - @Override public boolean equals(Object o) { - return o instanceof Pointer && ptr == ((Pointer) o).ptr; - } - - @Override public int hashCode() { return (int)(ptr^(ptr>>>32)); } - - public int compareTo(Pointer o) { - if(this==o || ptr==o.ptr) return 0; - if(ptr < o.ptr) return -1; - return 1; - } -} diff --git a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/PrimitiveCoder.java b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/PrimitiveCoder.java deleted file mode 100644 index eab34a7e6af..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/PrimitiveCoder.java +++ /dev/null @@ -1,700 +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. - */ -package com.apple.jobjc; -import com.apple.jobjc.JObjCRuntime.Width; -// Auto generated by PrimitiveCoder.hs -// Do not edit by hand. -public abstract class PrimitiveCoder extends Coder{ - public PrimitiveCoder(int ffiTypeCode, String objCEncoding, Class jclass, Class jprim){ - super(ffiTypeCode, objCEncoding, jclass, jprim); - } - public final boolean popBoolean(NativeArgumentBuffer args){ - return popBoolean(args.runtime, args.retValPtr); - } - public abstract boolean popBoolean(JObjCRuntime runtime, long addr); - - public final void push(NativeArgumentBuffer args, boolean x){ - push(args.runtime, args.argValuesPtr, x); - args.didPutArgValue(sizeof()); - } - public abstract void push(JObjCRuntime runtime, long addr, boolean x); - - - public final byte popByte(NativeArgumentBuffer args){ - return popByte(args.runtime, args.retValPtr); - } - public abstract byte popByte(JObjCRuntime runtime, long addr); - - public final void push(NativeArgumentBuffer args, byte x){ - push(args.runtime, args.argValuesPtr, x); - args.didPutArgValue(sizeof()); - } - public abstract void push(JObjCRuntime runtime, long addr, byte x); - - - public final char popChar(NativeArgumentBuffer args){ - return popChar(args.runtime, args.retValPtr); - } - public abstract char popChar(JObjCRuntime runtime, long addr); - - public final void push(NativeArgumentBuffer args, char x){ - push(args.runtime, args.argValuesPtr, x); - args.didPutArgValue(sizeof()); - } - public abstract void push(JObjCRuntime runtime, long addr, char x); - - - public final short popShort(NativeArgumentBuffer args){ - return popShort(args.runtime, args.retValPtr); - } - public abstract short popShort(JObjCRuntime runtime, long addr); - - public final void push(NativeArgumentBuffer args, short x){ - push(args.runtime, args.argValuesPtr, x); - args.didPutArgValue(sizeof()); - } - public abstract void push(JObjCRuntime runtime, long addr, short x); - - - public final int popInt(NativeArgumentBuffer args){ - return popInt(args.runtime, args.retValPtr); - } - public abstract int popInt(JObjCRuntime runtime, long addr); - - public final void push(NativeArgumentBuffer args, int x){ - push(args.runtime, args.argValuesPtr, x); - args.didPutArgValue(sizeof()); - } - public abstract void push(JObjCRuntime runtime, long addr, int x); - - - public final long popLong(NativeArgumentBuffer args){ - return popLong(args.runtime, args.retValPtr); - } - public abstract long popLong(JObjCRuntime runtime, long addr); - - public final void push(NativeArgumentBuffer args, long x){ - push(args.runtime, args.argValuesPtr, x); - args.didPutArgValue(sizeof()); - } - public abstract void push(JObjCRuntime runtime, long addr, long x); - - - public final float popFloat(NativeArgumentBuffer args){ - return popFloat(args.runtime, args.retValPtr); - } - public abstract float popFloat(JObjCRuntime runtime, long addr); - - public final void push(NativeArgumentBuffer args, float x){ - push(args.runtime, args.argValuesPtr, x); - args.didPutArgValue(sizeof()); - } - public abstract void push(JObjCRuntime runtime, long addr, float x); - - - public final double popDouble(NativeArgumentBuffer args){ - return popDouble(args.runtime, args.retValPtr); - } - public abstract double popDouble(JObjCRuntime runtime, long addr); - - public final void push(NativeArgumentBuffer args, double x){ - push(args.runtime, args.argValuesPtr, x); - args.didPutArgValue(sizeof()); - } - public abstract void push(JObjCRuntime runtime, long addr, double x); - - -// native BOOL -> java boolean -public static final class BoolCoder extends PrimitiveCoder{ - public static final BoolCoder INST = new BoolCoder(); - public BoolCoder(){ super(FFI_SINT8, "B", Boolean.class, boolean.class); } - // compile time - @Override public void push(JObjCRuntime rt, long addr, boolean x){ - rt.unsafe.putByte(addr, (byte) (x ? 1 : 0)); - } - @Override public boolean popBoolean(JObjCRuntime rt, long addr){ - return rt.unsafe.getByte(addr) != 0; - } - // for runtime coding - @Override public int sizeof(Width w){ - return 1; - } - @Override public void push(JObjCRuntime rt, long addr, Boolean x){ push(rt, addr, (boolean) x); } - @Override public Boolean pop(JObjCRuntime rt, long addr){ return popBoolean(rt, addr); } - // proxies for mixed encoding - - @Override public void push(JObjCRuntime rt, long addr, byte x){ push(rt, addr, (x != 0)); } - @Override public byte popByte(JObjCRuntime rt, long addr){ return ((byte)(popBoolean(rt, addr) ? 1 : 0)); } - - @Override public void push(JObjCRuntime rt, long addr, char x){ push(rt, addr, (x != 0)); } - @Override public char popChar(JObjCRuntime rt, long addr){ return ((char)(popBoolean(rt, addr) ? 1 : 0)); } - - @Override public void push(JObjCRuntime rt, long addr, short x){ push(rt, addr, (x != 0)); } - @Override public short popShort(JObjCRuntime rt, long addr){ return ((short)(popBoolean(rt, addr) ? 1 : 0)); } - - @Override public void push(JObjCRuntime rt, long addr, int x){ push(rt, addr, (x != 0)); } - @Override public int popInt(JObjCRuntime rt, long addr){ return ((int)(popBoolean(rt, addr) ? 1 : 0)); } - - @Override public void push(JObjCRuntime rt, long addr, long x){ push(rt, addr, (x != 0)); } - @Override public long popLong(JObjCRuntime rt, long addr){ return ((long)(popBoolean(rt, addr) ? 1 : 0)); } - - @Override public void push(JObjCRuntime rt, long addr, float x){ push(rt, addr, (x != 0)); } - @Override public float popFloat(JObjCRuntime rt, long addr){ return ((float)(popBoolean(rt, addr) ? 1 : 0)); } - - @Override public void push(JObjCRuntime rt, long addr, double x){ push(rt, addr, (x != 0)); } - @Override public double popDouble(JObjCRuntime rt, long addr){ return ((double)(popBoolean(rt, addr) ? 1 : 0)); } - - -} - -// native schar -> java byte -public static final class SCharCoder extends PrimitiveCoder{ - public static final SCharCoder INST = new SCharCoder(); - public SCharCoder(){ super(FFI_SINT8, "c", Byte.class, byte.class); } - // compile time - @Override public void push(JObjCRuntime rt, long addr, byte x){ - rt.unsafe.putByte(addr, x); - } - @Override public byte popByte(JObjCRuntime rt, long addr){ - return rt.unsafe.getByte(addr); - } - // for runtime coding - @Override public int sizeof(Width w){ - return 1; - } - @Override public void push(JObjCRuntime rt, long addr, Byte x){ push(rt, addr, (byte) x); } - @Override public Byte pop(JObjCRuntime rt, long addr){ return popByte(rt, addr); } - // proxies for mixed encoding - @Override public void push(JObjCRuntime rt, long addr, boolean x){ push(rt, addr, ((byte)(x ? 1 : 0))); } - @Override public boolean popBoolean(JObjCRuntime rt, long addr){ return (popByte(rt, addr) != 0); } - - - @Override public void push(JObjCRuntime rt, long addr, char x){ push(rt, addr, ((byte)x)); } - @Override public char popChar(JObjCRuntime rt, long addr){ return ((char)popByte(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, short x){ push(rt, addr, ((byte)x)); } - @Override public short popShort(JObjCRuntime rt, long addr){ return ((short)popByte(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, int x){ push(rt, addr, ((byte)x)); } - @Override public int popInt(JObjCRuntime rt, long addr){ return ((int)popByte(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, long x){ push(rt, addr, ((byte)x)); } - @Override public long popLong(JObjCRuntime rt, long addr){ return ((long)popByte(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, float x){ push(rt, addr, ((byte)x)); } - @Override public float popFloat(JObjCRuntime rt, long addr){ return ((float)popByte(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, double x){ push(rt, addr, ((byte)x)); } - @Override public double popDouble(JObjCRuntime rt, long addr){ return ((double)popByte(rt, addr)); } - - -} - -// native uchar -> java byte -public static final class UCharCoder extends PrimitiveCoder{ - public static final UCharCoder INST = new UCharCoder(); - public UCharCoder(){ super(FFI_UINT8, "C", Byte.class, byte.class); } - // compile time - @Override public void push(JObjCRuntime rt, long addr, byte x){ - rt.unsafe.putByte(addr, x); - } - @Override public byte popByte(JObjCRuntime rt, long addr){ - return rt.unsafe.getByte(addr); - } - // for runtime coding - @Override public int sizeof(Width w){ - return 1; - } - @Override public void push(JObjCRuntime rt, long addr, Byte x){ push(rt, addr, (byte) x); } - @Override public Byte pop(JObjCRuntime rt, long addr){ return popByte(rt, addr); } - // proxies for mixed encoding - @Override public void push(JObjCRuntime rt, long addr, boolean x){ push(rt, addr, ((byte)(x ? 1 : 0))); } - @Override public boolean popBoolean(JObjCRuntime rt, long addr){ return (popByte(rt, addr) != 0); } - - - @Override public void push(JObjCRuntime rt, long addr, char x){ push(rt, addr, ((byte)x)); } - @Override public char popChar(JObjCRuntime rt, long addr){ return ((char)popByte(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, short x){ push(rt, addr, ((byte)x)); } - @Override public short popShort(JObjCRuntime rt, long addr){ return ((short)popByte(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, int x){ push(rt, addr, ((byte)x)); } - @Override public int popInt(JObjCRuntime rt, long addr){ return ((int)popByte(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, long x){ push(rt, addr, ((byte)x)); } - @Override public long popLong(JObjCRuntime rt, long addr){ return ((long)popByte(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, float x){ push(rt, addr, ((byte)x)); } - @Override public float popFloat(JObjCRuntime rt, long addr){ return ((float)popByte(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, double x){ push(rt, addr, ((byte)x)); } - @Override public double popDouble(JObjCRuntime rt, long addr){ return ((double)popByte(rt, addr)); } - - -} - -// native sshort -> java short -public static final class SShortCoder extends PrimitiveCoder{ - public static final SShortCoder INST = new SShortCoder(); - public SShortCoder(){ super(FFI_SINT16, "s", Short.class, short.class); } - // compile time - @Override public void push(JObjCRuntime rt, long addr, short x){ - rt.unsafe.putShort(addr, (short) x); - } - @Override public short popShort(JObjCRuntime rt, long addr){ - return rt.unsafe.getShort(addr); - } - // for runtime coding - @Override public int sizeof(Width w){ - return 2; - } - @Override public void push(JObjCRuntime rt, long addr, Short x){ push(rt, addr, (short) x); } - @Override public Short pop(JObjCRuntime rt, long addr){ return popShort(rt, addr); } - // proxies for mixed encoding - @Override public void push(JObjCRuntime rt, long addr, boolean x){ push(rt, addr, ((short)(x ? 1 : 0))); } - @Override public boolean popBoolean(JObjCRuntime rt, long addr){ return (popShort(rt, addr) != 0); } - - @Override public void push(JObjCRuntime rt, long addr, byte x){ push(rt, addr, ((short)x)); } - @Override public byte popByte(JObjCRuntime rt, long addr){ return ((byte)popShort(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, char x){ push(rt, addr, ((short)x)); } - @Override public char popChar(JObjCRuntime rt, long addr){ return ((char)popShort(rt, addr)); } - - - @Override public void push(JObjCRuntime rt, long addr, int x){ push(rt, addr, ((short)x)); } - @Override public int popInt(JObjCRuntime rt, long addr){ return ((int)popShort(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, long x){ push(rt, addr, ((short)x)); } - @Override public long popLong(JObjCRuntime rt, long addr){ return ((long)popShort(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, float x){ push(rt, addr, ((short)x)); } - @Override public float popFloat(JObjCRuntime rt, long addr){ return ((float)popShort(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, double x){ push(rt, addr, ((short)x)); } - @Override public double popDouble(JObjCRuntime rt, long addr){ return ((double)popShort(rt, addr)); } - - -} - -// native ushort -> java short -public static final class UShortCoder extends PrimitiveCoder{ - public static final UShortCoder INST = new UShortCoder(); - public UShortCoder(){ super(FFI_UINT16, "S", Short.class, short.class); } - // compile time - @Override public void push(JObjCRuntime rt, long addr, short x){ - rt.unsafe.putShort(addr, (short) x); - } - @Override public short popShort(JObjCRuntime rt, long addr){ - return rt.unsafe.getShort(addr); - } - // for runtime coding - @Override public int sizeof(Width w){ - return 2; - } - @Override public void push(JObjCRuntime rt, long addr, Short x){ push(rt, addr, (short) x); } - @Override public Short pop(JObjCRuntime rt, long addr){ return popShort(rt, addr); } - // proxies for mixed encoding - @Override public void push(JObjCRuntime rt, long addr, boolean x){ push(rt, addr, ((short)(x ? 1 : 0))); } - @Override public boolean popBoolean(JObjCRuntime rt, long addr){ return (popShort(rt, addr) != 0); } - - @Override public void push(JObjCRuntime rt, long addr, byte x){ push(rt, addr, ((short)x)); } - @Override public byte popByte(JObjCRuntime rt, long addr){ return ((byte)popShort(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, char x){ push(rt, addr, ((short)x)); } - @Override public char popChar(JObjCRuntime rt, long addr){ return ((char)popShort(rt, addr)); } - - - @Override public void push(JObjCRuntime rt, long addr, int x){ push(rt, addr, ((short)x)); } - @Override public int popInt(JObjCRuntime rt, long addr){ return ((int)popShort(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, long x){ push(rt, addr, ((short)x)); } - @Override public long popLong(JObjCRuntime rt, long addr){ return ((long)popShort(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, float x){ push(rt, addr, ((short)x)); } - @Override public float popFloat(JObjCRuntime rt, long addr){ return ((float)popShort(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, double x){ push(rt, addr, ((short)x)); } - @Override public double popDouble(JObjCRuntime rt, long addr){ return ((double)popShort(rt, addr)); } - - -} - -// native sint -> java int -public static final class SIntCoder extends PrimitiveCoder{ - public static final SIntCoder INST = new SIntCoder(); - public SIntCoder(){ super(FFI_SINT32, "i", Integer.class, int.class); } - // compile time - @Override public void push(JObjCRuntime rt, long addr, int x){ - rt.unsafe.putInt(addr, (int) x); - } - @Override public int popInt(JObjCRuntime rt, long addr){ - return rt.unsafe.getInt(addr); - } - // for runtime coding - @Override public int sizeof(Width w){ - return 4; - } - @Override public void push(JObjCRuntime rt, long addr, Integer x){ push(rt, addr, (int) x); } - @Override public Integer pop(JObjCRuntime rt, long addr){ return popInt(rt, addr); } - // proxies for mixed encoding - @Override public void push(JObjCRuntime rt, long addr, boolean x){ push(rt, addr, ((int)(x ? 1 : 0))); } - @Override public boolean popBoolean(JObjCRuntime rt, long addr){ return (popInt(rt, addr) != 0); } - - @Override public void push(JObjCRuntime rt, long addr, byte x){ push(rt, addr, ((int)x)); } - @Override public byte popByte(JObjCRuntime rt, long addr){ return ((byte)popInt(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, char x){ push(rt, addr, ((int)x)); } - @Override public char popChar(JObjCRuntime rt, long addr){ return ((char)popInt(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, short x){ push(rt, addr, ((int)x)); } - @Override public short popShort(JObjCRuntime rt, long addr){ return ((short)popInt(rt, addr)); } - - - @Override public void push(JObjCRuntime rt, long addr, long x){ push(rt, addr, ((int)x)); } - @Override public long popLong(JObjCRuntime rt, long addr){ return ((long)popInt(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, float x){ push(rt, addr, ((int)x)); } - @Override public float popFloat(JObjCRuntime rt, long addr){ return ((float)popInt(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, double x){ push(rt, addr, ((int)x)); } - @Override public double popDouble(JObjCRuntime rt, long addr){ return ((double)popInt(rt, addr)); } - - -} - -// native uint -> java int -public static final class UIntCoder extends PrimitiveCoder{ - public static final UIntCoder INST = new UIntCoder(); - public UIntCoder(){ super(FFI_UINT32, "I", Integer.class, int.class); } - // compile time - @Override public void push(JObjCRuntime rt, long addr, int x){ - rt.unsafe.putInt(addr, (int) x); - } - @Override public int popInt(JObjCRuntime rt, long addr){ - return rt.unsafe.getInt(addr); - } - // for runtime coding - @Override public int sizeof(Width w){ - return 4; - } - @Override public void push(JObjCRuntime rt, long addr, Integer x){ push(rt, addr, (int) x); } - @Override public Integer pop(JObjCRuntime rt, long addr){ return popInt(rt, addr); } - // proxies for mixed encoding - @Override public void push(JObjCRuntime rt, long addr, boolean x){ push(rt, addr, ((int)(x ? 1 : 0))); } - @Override public boolean popBoolean(JObjCRuntime rt, long addr){ return (popInt(rt, addr) != 0); } - - @Override public void push(JObjCRuntime rt, long addr, byte x){ push(rt, addr, ((int)x)); } - @Override public byte popByte(JObjCRuntime rt, long addr){ return ((byte)popInt(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, char x){ push(rt, addr, ((int)x)); } - @Override public char popChar(JObjCRuntime rt, long addr){ return ((char)popInt(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, short x){ push(rt, addr, ((int)x)); } - @Override public short popShort(JObjCRuntime rt, long addr){ return ((short)popInt(rt, addr)); } - - - @Override public void push(JObjCRuntime rt, long addr, long x){ push(rt, addr, ((int)x)); } - @Override public long popLong(JObjCRuntime rt, long addr){ return ((long)popInt(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, float x){ push(rt, addr, ((int)x)); } - @Override public float popFloat(JObjCRuntime rt, long addr){ return ((float)popInt(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, double x){ push(rt, addr, ((int)x)); } - @Override public double popDouble(JObjCRuntime rt, long addr){ return ((double)popInt(rt, addr)); } - - -} - -// native slong -> java long -public static final class SLongCoder extends PrimitiveCoder{ - public static final SLongCoder INST = new SLongCoder(); - public SLongCoder(){ super((JObjCRuntime.IS64 ? (FFI_SINT64) : (FFI_SINT32)), "l", Long.class, long.class); } - // compile time - @Override public void push(JObjCRuntime rt, long addr, long x){ - if(JObjCRuntime.IS64){ rt.unsafe.putLong(addr, (long) x); }else{ rt.unsafe.putInt(addr, (int) x); } - } - @Override public long popLong(JObjCRuntime rt, long addr){ - return (JObjCRuntime.IS64 ? (rt.unsafe.getLong(addr)) : (rt.unsafe.getInt(addr))); - } - // for runtime coding - @Override public int sizeof(Width w){ - switch(w){ - case W32: return 4; - case W64: return 8; - - default: return -1; - } - - } - @Override public void push(JObjCRuntime rt, long addr, Long x){ push(rt, addr, (long) x); } - @Override public Long pop(JObjCRuntime rt, long addr){ return popLong(rt, addr); } - // proxies for mixed encoding - @Override public void push(JObjCRuntime rt, long addr, boolean x){ push(rt, addr, ((long)(x ? 1 : 0))); } - @Override public boolean popBoolean(JObjCRuntime rt, long addr){ return (popLong(rt, addr) != 0); } - - @Override public void push(JObjCRuntime rt, long addr, byte x){ push(rt, addr, ((long)x)); } - @Override public byte popByte(JObjCRuntime rt, long addr){ return ((byte)popLong(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, char x){ push(rt, addr, ((long)x)); } - @Override public char popChar(JObjCRuntime rt, long addr){ return ((char)popLong(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, short x){ push(rt, addr, ((long)x)); } - @Override public short popShort(JObjCRuntime rt, long addr){ return ((short)popLong(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, int x){ push(rt, addr, ((long)x)); } - @Override public int popInt(JObjCRuntime rt, long addr){ return ((int)popLong(rt, addr)); } - - - @Override public void push(JObjCRuntime rt, long addr, float x){ push(rt, addr, ((long)x)); } - @Override public float popFloat(JObjCRuntime rt, long addr){ return ((float)popLong(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, double x){ push(rt, addr, ((long)x)); } - @Override public double popDouble(JObjCRuntime rt, long addr){ return ((double)popLong(rt, addr)); } - - -} - -// native ulong -> java long -public static final class ULongCoder extends PrimitiveCoder{ - public static final ULongCoder INST = new ULongCoder(); - public ULongCoder(){ super((JObjCRuntime.IS64 ? (FFI_UINT64) : (FFI_UINT32)), "L", Long.class, long.class); } - // compile time - @Override public void push(JObjCRuntime rt, long addr, long x){ - if(JObjCRuntime.IS64){ rt.unsafe.putLong(addr, (long) x); }else{ rt.unsafe.putInt(addr, (int) x); } - } - @Override public long popLong(JObjCRuntime rt, long addr){ - return (JObjCRuntime.IS64 ? (rt.unsafe.getLong(addr)) : (rt.unsafe.getInt(addr))); - } - // for runtime coding - @Override public int sizeof(Width w){ - switch(w){ - case W32: return 4; - case W64: return 8; - - default: return -1; - } - - } - @Override public void push(JObjCRuntime rt, long addr, Long x){ push(rt, addr, (long) x); } - @Override public Long pop(JObjCRuntime rt, long addr){ return popLong(rt, addr); } - // proxies for mixed encoding - @Override public void push(JObjCRuntime rt, long addr, boolean x){ push(rt, addr, ((long)(x ? 1 : 0))); } - @Override public boolean popBoolean(JObjCRuntime rt, long addr){ return (popLong(rt, addr) != 0); } - - @Override public void push(JObjCRuntime rt, long addr, byte x){ push(rt, addr, ((long)x)); } - @Override public byte popByte(JObjCRuntime rt, long addr){ return ((byte)popLong(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, char x){ push(rt, addr, ((long)x)); } - @Override public char popChar(JObjCRuntime rt, long addr){ return ((char)popLong(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, short x){ push(rt, addr, ((long)x)); } - @Override public short popShort(JObjCRuntime rt, long addr){ return ((short)popLong(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, int x){ push(rt, addr, ((long)x)); } - @Override public int popInt(JObjCRuntime rt, long addr){ return ((int)popLong(rt, addr)); } - - - @Override public void push(JObjCRuntime rt, long addr, float x){ push(rt, addr, ((long)x)); } - @Override public float popFloat(JObjCRuntime rt, long addr){ return ((float)popLong(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, double x){ push(rt, addr, ((long)x)); } - @Override public double popDouble(JObjCRuntime rt, long addr){ return ((double)popLong(rt, addr)); } - - -} - -// native slonglong -> java long -public static final class SLongLongCoder extends PrimitiveCoder{ - public static final SLongLongCoder INST = new SLongLongCoder(); - public SLongLongCoder(){ super(FFI_SINT64, "q", Long.class, long.class); } - // compile time - @Override public void push(JObjCRuntime rt, long addr, long x){ - rt.unsafe.putLong(addr, (long) x); - } - @Override public long popLong(JObjCRuntime rt, long addr){ - return rt.unsafe.getLong(addr); - } - // for runtime coding - @Override public int sizeof(Width w){ - return 8; - } - @Override public void push(JObjCRuntime rt, long addr, Long x){ push(rt, addr, (long) x); } - @Override public Long pop(JObjCRuntime rt, long addr){ return popLong(rt, addr); } - // proxies for mixed encoding - @Override public void push(JObjCRuntime rt, long addr, boolean x){ push(rt, addr, ((long)(x ? 1 : 0))); } - @Override public boolean popBoolean(JObjCRuntime rt, long addr){ return (popLong(rt, addr) != 0); } - - @Override public void push(JObjCRuntime rt, long addr, byte x){ push(rt, addr, ((long)x)); } - @Override public byte popByte(JObjCRuntime rt, long addr){ return ((byte)popLong(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, char x){ push(rt, addr, ((long)x)); } - @Override public char popChar(JObjCRuntime rt, long addr){ return ((char)popLong(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, short x){ push(rt, addr, ((long)x)); } - @Override public short popShort(JObjCRuntime rt, long addr){ return ((short)popLong(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, int x){ push(rt, addr, ((long)x)); } - @Override public int popInt(JObjCRuntime rt, long addr){ return ((int)popLong(rt, addr)); } - - - @Override public void push(JObjCRuntime rt, long addr, float x){ push(rt, addr, ((long)x)); } - @Override public float popFloat(JObjCRuntime rt, long addr){ return ((float)popLong(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, double x){ push(rt, addr, ((long)x)); } - @Override public double popDouble(JObjCRuntime rt, long addr){ return ((double)popLong(rt, addr)); } - - -} - -// native ulonglong -> java long -public static final class ULongLongCoder extends PrimitiveCoder{ - public static final ULongLongCoder INST = new ULongLongCoder(); - public ULongLongCoder(){ super(FFI_UINT64, "Q", Long.class, long.class); } - // compile time - @Override public void push(JObjCRuntime rt, long addr, long x){ - rt.unsafe.putLong(addr, (long) x); - } - @Override public long popLong(JObjCRuntime rt, long addr){ - return rt.unsafe.getLong(addr); - } - // for runtime coding - @Override public int sizeof(Width w){ - return 8; - } - @Override public void push(JObjCRuntime rt, long addr, Long x){ push(rt, addr, (long) x); } - @Override public Long pop(JObjCRuntime rt, long addr){ return popLong(rt, addr); } - // proxies for mixed encoding - @Override public void push(JObjCRuntime rt, long addr, boolean x){ push(rt, addr, ((long)(x ? 1 : 0))); } - @Override public boolean popBoolean(JObjCRuntime rt, long addr){ return (popLong(rt, addr) != 0); } - - @Override public void push(JObjCRuntime rt, long addr, byte x){ push(rt, addr, ((long)x)); } - @Override public byte popByte(JObjCRuntime rt, long addr){ return ((byte)popLong(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, char x){ push(rt, addr, ((long)x)); } - @Override public char popChar(JObjCRuntime rt, long addr){ return ((char)popLong(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, short x){ push(rt, addr, ((long)x)); } - @Override public short popShort(JObjCRuntime rt, long addr){ return ((short)popLong(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, int x){ push(rt, addr, ((long)x)); } - @Override public int popInt(JObjCRuntime rt, long addr){ return ((int)popLong(rt, addr)); } - - - @Override public void push(JObjCRuntime rt, long addr, float x){ push(rt, addr, ((long)x)); } - @Override public float popFloat(JObjCRuntime rt, long addr){ return ((float)popLong(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, double x){ push(rt, addr, ((long)x)); } - @Override public double popDouble(JObjCRuntime rt, long addr){ return ((double)popLong(rt, addr)); } - - -} - -// native float -> java float -public static final class FloatCoder extends PrimitiveCoder{ - public static final FloatCoder INST = new FloatCoder(); - public FloatCoder(){ super(FFI_FLOAT, "f", Float.class, float.class); } - // compile time - @Override public void push(JObjCRuntime rt, long addr, float x){ - rt.unsafe.putFloat(addr, (float) x); - } - @Override public float popFloat(JObjCRuntime rt, long addr){ - return rt.unsafe.getFloat(addr); - } - // for runtime coding - @Override public int sizeof(Width w){ - return 4; - } - @Override public void push(JObjCRuntime rt, long addr, Float x){ push(rt, addr, (float) x); } - @Override public Float pop(JObjCRuntime rt, long addr){ return popFloat(rt, addr); } - // proxies for mixed encoding - @Override public void push(JObjCRuntime rt, long addr, boolean x){ push(rt, addr, ((float)(x ? 1 : 0))); } - @Override public boolean popBoolean(JObjCRuntime rt, long addr){ return (popFloat(rt, addr) != 0); } - - @Override public void push(JObjCRuntime rt, long addr, byte x){ push(rt, addr, ((float)x)); } - @Override public byte popByte(JObjCRuntime rt, long addr){ return ((byte)popFloat(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, char x){ push(rt, addr, ((float)x)); } - @Override public char popChar(JObjCRuntime rt, long addr){ return ((char)popFloat(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, short x){ push(rt, addr, ((float)x)); } - @Override public short popShort(JObjCRuntime rt, long addr){ return ((short)popFloat(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, int x){ push(rt, addr, ((float)x)); } - @Override public int popInt(JObjCRuntime rt, long addr){ return ((int)popFloat(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, long x){ push(rt, addr, ((float)x)); } - @Override public long popLong(JObjCRuntime rt, long addr){ return ((long)popFloat(rt, addr)); } - - - @Override public void push(JObjCRuntime rt, long addr, double x){ push(rt, addr, ((float)x)); } - @Override public double popDouble(JObjCRuntime rt, long addr){ return ((double)popFloat(rt, addr)); } - - -} - -// native double -> java double -public static final class DoubleCoder extends PrimitiveCoder{ - public static final DoubleCoder INST = new DoubleCoder(); - public DoubleCoder(){ super(FFI_DOUBLE, "d", Double.class, double.class); } - // compile time - @Override public void push(JObjCRuntime rt, long addr, double x){ - rt.unsafe.putDouble(addr, (double) x); - } - @Override public double popDouble(JObjCRuntime rt, long addr){ - return rt.unsafe.getDouble(addr); - } - // for runtime coding - @Override public int sizeof(Width w){ - return 8; - } - @Override public void push(JObjCRuntime rt, long addr, Double x){ push(rt, addr, (double) x); } - @Override public Double pop(JObjCRuntime rt, long addr){ return popDouble(rt, addr); } - // proxies for mixed encoding - @Override public void push(JObjCRuntime rt, long addr, boolean x){ push(rt, addr, ((double)(x ? 1 : 0))); } - @Override public boolean popBoolean(JObjCRuntime rt, long addr){ return (popDouble(rt, addr) != 0); } - - @Override public void push(JObjCRuntime rt, long addr, byte x){ push(rt, addr, ((double)x)); } - @Override public byte popByte(JObjCRuntime rt, long addr){ return ((byte)popDouble(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, char x){ push(rt, addr, ((double)x)); } - @Override public char popChar(JObjCRuntime rt, long addr){ return ((char)popDouble(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, short x){ push(rt, addr, ((double)x)); } - @Override public short popShort(JObjCRuntime rt, long addr){ return ((short)popDouble(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, int x){ push(rt, addr, ((double)x)); } - @Override public int popInt(JObjCRuntime rt, long addr){ return ((int)popDouble(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, long x){ push(rt, addr, ((double)x)); } - @Override public long popLong(JObjCRuntime rt, long addr){ return ((long)popDouble(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, float x){ push(rt, addr, ((double)x)); } - @Override public float popFloat(JObjCRuntime rt, long addr){ return ((float)popDouble(rt, addr)); } - - - -} - -} diff --git a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/SEL.java b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/SEL.java deleted file mode 100644 index 7e085f8d54d..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/SEL.java +++ /dev/null @@ -1,62 +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. - */ -package com.apple.jobjc; - - -public class SEL { - static native long getSelectorPtr(String selectorName); - static native String getSelectorName(long ptr); - - final long selPtr; - - SEL(long ptr) { - this.selPtr = ptr; - } - - public SEL(final String name) { - this(getSelectorPtr(name)); - } - - @Override public String toString(){ - return ((int)selPtr) + " / " + selPtr + " : " + getSelectorName(selPtr); - } - - /** - * Converts something like "performSelectorOnMainThread_withObject_wait" - * to "performSelectorOnMainThread:withObject:wait:" - */ - public static String selectorName(String jMethodName, boolean hasArgs){ - String b = jMethodName.replaceAll("_", ":"); - return hasArgs ? b + ":" : b; - } - - public static String jMethodName(String selectorName){ - return selectorName.replaceAll(":", "_").replaceAll("_$", ""); - } - - public static boolean validName(String selectorName){ - return selectorName.matches("^[a-zA-Z_][a-zA-Z0-9_:]*$"); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Struct.java b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Struct.java deleted file mode 100644 index b14e84dcaca..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Struct.java +++ /dev/null @@ -1,56 +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. - */ -package com.apple.jobjc; - - -/** - * A struct is malloced on the C heap and accessed in Java through a ByteBuffer. - */ -public abstract class Struct{ - protected final NativeBuffer raw; - private final JObjCRuntime runtime; - protected final JObjCRuntime getRuntime(){ return runtime; } - - /** - * Create a brand new struct from nothing. - */ - protected Struct(final JObjCRuntime runtime, final int SIZEOF){ - this(runtime, new NativeBuffer(SIZEOF), SIZEOF); - } - - /** - * Create a struct by taking ownership of an existing buffer. - * Used for struct fields of type struct. For example, the origin and size fields - * in NSRect would be initialized with this constructor. - */ - protected Struct(final JObjCRuntime runtime, final NativeBuffer buffer, final int SIZEOF){ - if(runtime == null) throw new NullPointerException("runtime"); - this.runtime = runtime; - this.raw = buffer; - this.raw.limit(SIZEOF); - } - - abstract public Coder getCoder(); -} diff --git a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Subclassing.java b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Subclassing.java deleted file mode 100644 index c0e72b13e33..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Subclassing.java +++ /dev/null @@ -1,167 +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. - */ -package com.apple.jobjc; - -import java.io.StringWriter; -import java.lang.reflect.Method; -import java.util.HashSet; -import java.util.Set; - -import com.apple.jobjc.Coder.PrimitivePointerCoder; -import com.apple.jobjc.Coder.VoidCoder; -import com.apple.jobjc.Invoke.MsgSend; - - -final class Subclassing { - static native long allocateClassPair(long superClass, String name); - static native boolean addIVarForJObj(long clazz); - static native boolean patchAlloc(long classPtr); - static native boolean addMethod(long cls, String name, Method jMethod, CIF cif, long cifPtr, String objCEncodedType); - static native void registerClassPair(long clazz); - - static native T getJObjectFromIVar(long objPtr); - static native void initJObjectToIVar(long objPtr, ID object); - - final Set registeredUserSubclasses = new HashSet(); - final JObjCRuntime runtime; - - Subclassing(JObjCRuntime runtime){ - this.runtime = runtime; - } - - boolean registerUserClass(final Class clazz, final Class clazzClazz) { - final String nativeClassName = clazz.getSimpleName(); - // Is it already registered? - if(0 != NSClass.getNativeClassByName(nativeClassName)) - return false; - - if(clazz.isAnonymousClass()) - throw new RuntimeException("JObjC cannot register anonymous classes."); - - // Verify superclass - long superClass = NSClass.getNativeClassByName(clazz.getSuperclass().getSimpleName()); - if(0 == superClass) - throw new RuntimeException(clazz.getSuperclass() + ", the superclass of " + clazz + ", must be a registered class."); - - runtime.registerPackage(clazz.getPackage().getName()); - - // Create class - long classPtr = Subclassing.allocateClassPair(superClass, nativeClassName); - if(classPtr == 0) throw new RuntimeException("objc_allocateClassPair returned 0."); - - // Add ivar to hold jobject - boolean addedI = Subclassing.addIVarForJObj(classPtr); - if(!addedI) throw new RuntimeException("class_addIvar returned false."); - - // Verify constructor - try { - clazz.getConstructor(ID.CTOR_ARGS); - } catch (Exception e) { - throw new RuntimeException("Could not access required constructor: " + ID.CTOR_ARGS, e); - } - - // Patch alloc to create corresponding jobject on invoke - patchAlloc(classPtr); - - // Add methods - Set takenSelNames = new HashSet(); - for(Method method : clazz.getDeclaredMethods()){ - // No overloading - String selName = SEL.selectorName(method.getName(), method.getParameterTypes().length > 0); - if(takenSelNames.contains(selName)) - throw new RuntimeException("Obj-C does not allow method overloading. The Objective-C selector '" - + selName + "' appears more than once in class " + clazz.getCanonicalName() + " / " + nativeClassName + "."); - - method.setAccessible(true); - - // Divine CIF - Coder returnCoder = Coder.getCoderAtRuntimeForType(method.getReturnType()); - Class[] paramTypes = method.getParameterTypes(); - Coder[] argCoders = new Coder[paramTypes.length]; - for(int i = 0; i < paramTypes.length; i++) - argCoders[i] = Coder.getCoderAtRuntimeForType(paramTypes[i]); - - CIF cif = new MsgSend(runtime, selName, returnCoder, argCoders).funCall.cif; - - // .. and objc encoding - StringWriter encType = new StringWriter(); - encType.append(returnCoder.getObjCEncoding()); - encType.append("@:"); - for(int i = 0; i < argCoders.length; i++) - encType.append(argCoders[i].getObjCEncoding()); - - // Add it! - boolean addedM = Subclassing.addMethod(classPtr, selName, method, cif, cif.cif.bufferPtr, encType.toString()); - if(!addedM) throw new RuntimeException("Failed to add method."); - takenSelNames.add(selName); - } - - // Seal it - Subclassing.registerClassPair(classPtr); - registeredUserSubclasses.add(classPtr); - - return true; - } - - boolean isUserClass(long clsPtr) { - return registeredUserSubclasses.contains(clsPtr); - } - - // Called from JNI - - private static void initJObject(final long objPtr){ -// System.err.println("initJObject " + objPtr + " / " + Long.toHexString(objPtr)); - ID newObj = ID.createNewObjCObjectFor(JObjCRuntime.inst(), objPtr, NSClass.getClass(objPtr)); -// System.err.println("... " + newObj); - initJObjectToIVar(objPtr, newObj); - } - - private static void invokeFromJNI(ID obj, Method method, CIF cif, long result, long args){ - assert obj != null; - assert obj.getClass().equals(method.getDeclaringClass()) : - obj.getClass().toString() + " != " + method.getDeclaringClass().toString(); - - final int argCount = method.getParameterTypes().length; - - // The first two args & coders are for objc id and sel. Skip them. - final Object[] argObjects = new Object[argCount]; - for(int i = 0; i < argCount; i++){ - final long argAddrAddr = args + ((i+2) * JObjCRuntime.PTR_LEN); - final long argAddr = PrimitivePointerCoder.INST.popPtr(obj.runtime, argAddrAddr); - argObjects[i] = cif.argCoders[i + 2].pop(obj.runtime, argAddr); - } - - Object retVal; - try { - retVal = method.invoke(obj, argObjects); - } catch (Exception e) { - e.printStackTrace(); - throw new RuntimeException(e); - } - - if(!(cif.returnCoder instanceof VoidCoder)) - cif.returnCoder.push(obj.runtime, result, retVal); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/core/native/CIF.m b/jdk/src/macosx/native/jobjc/src/core/native/CIF.m deleted file mode 100644 index 7aa4dd542a5..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/native/CIF.m +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "com_apple_jobjc_CIF.h" - -#define MACOSX -#include -#include - -#include "NativeBuffer.h" - -JNIEXPORT jint JNICALL Java_com_apple_jobjc_CIF_getSizeofCIF -(JNIEnv *env, jclass clazz) -{ - return (jint) sizeof(ffi_cif); -} - -JNIEXPORT jboolean JNICALL Java_com_apple_jobjc_CIF_prepCIF -(JNIEnv *env, jclass clazz, jlong jCIFPtr, jint jNargs, jlong jRetTypePtr, jlong jArgsPtr) -{ - ffi_cif *cif = jlong_to_ptr(jCIFPtr); - unsigned int nargs = jNargs; - ffi_type *rtype = jlong_to_ptr(jRetTypePtr); - ffi_type **atypes = jlong_to_ptr(jArgsPtr); - -// NSLog(@"rtype->(size: %d, alignment: %d, type: %d)", rtype->size, rtype->alignment, rtype->type); - return (jboolean) (FFI_OK == ffi_prep_cif(cif, FFI_DEFAULT_ABI, nargs, rtype, atypes)); -} diff --git a/jdk/src/macosx/native/jobjc/src/core/native/Coder.m b/jdk/src/macosx/native/jobjc/src/core/native/Coder.m deleted file mode 100644 index af3553949bf..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/native/Coder.m +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "com_apple_jobjc_Coder.h" - -#include -#define MACOSX -#include -#include - -/* - * Class: com_apple_jobjc_Coder - * Method: getNativeFFITypeCodeForCode - * Signature: (I)J - */ -JNIEXPORT jlong JNICALL Java_com_apple_jobjc_Coder_getNativeFFITypePtrForCode -(JNIEnv *env, jclass clazz, jint code) -{ - switch ((long)code) { - case com_apple_jobjc_Coder_FFI_VOID: return ptr_to_jlong(&ffi_type_void); - case com_apple_jobjc_Coder_FFI_PTR: return ptr_to_jlong(&ffi_type_pointer); - case com_apple_jobjc_Coder_FFI_SINT8: return ptr_to_jlong(&ffi_type_sint8); - case com_apple_jobjc_Coder_FFI_UINT8: return ptr_to_jlong(&ffi_type_uint8); - case com_apple_jobjc_Coder_FFI_SINT16: return ptr_to_jlong(&ffi_type_sint16); - case com_apple_jobjc_Coder_FFI_UINT16: return ptr_to_jlong(&ffi_type_uint16); - case com_apple_jobjc_Coder_FFI_SINT32: return ptr_to_jlong(&ffi_type_sint32); - case com_apple_jobjc_Coder_FFI_UINT32: return ptr_to_jlong(&ffi_type_uint32); - case com_apple_jobjc_Coder_FFI_SINT64: return ptr_to_jlong(&ffi_type_sint64); - case com_apple_jobjc_Coder_FFI_UINT64: return ptr_to_jlong(&ffi_type_uint64); - case com_apple_jobjc_Coder_FFI_FLOAT: return ptr_to_jlong(&ffi_type_float); - case com_apple_jobjc_Coder_FFI_DOUBLE: return ptr_to_jlong(&ffi_type_double); - case com_apple_jobjc_Coder_FFI_LONGDOUBLE: return ptr_to_jlong(&ffi_type_longdouble); - } - - return ptr_to_jlong(NULL); -} diff --git a/jdk/src/macosx/native/jobjc/src/core/native/FFIType.m b/jdk/src/macosx/native/jobjc/src/core/native/FFIType.m deleted file mode 100644 index 731397e1a01..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/native/FFIType.m +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -#include -#include - -#include "com_apple_jobjc_FFIType.h" - -JNIEXPORT void JNICALL Java_com_apple_jobjc_FFIType_makeFFIType -(JNIEnv *env, jclass clazz, jlong ffi_type_jlong, jlong ffi_type_elements_jlong) -{ - ffi_type *type = jlong_to_ptr(ffi_type_jlong); - type->elements = jlong_to_ptr(ffi_type_elements_jlong); - type->type = FFI_TYPE_STRUCT; - type->size = type->alignment = 0; -} - -JNIEXPORT jint JNICALL Java_com_apple_jobjc_FFIType_getFFITypeSizeof -(JNIEnv *env, jclass clazz) -{ - return (jint) sizeof(ffi_type); -} diff --git a/jdk/src/macosx/native/jobjc/src/core/native/Function.m b/jdk/src/macosx/native/jobjc/src/core/native/Function.m deleted file mode 100644 index 9060a0fd158..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/native/Function.m +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "com_apple_jobjc_Function.h" - -#define MACOSX -#include -#include - -JNIEXPORT jlong JNICALL Java_com_apple_jobjc_Function_getFxnPtrForFunctionName -(JNIEnv *env, jclass clazz, jstring fxnName) -{ - const char *functionName = (*env)->GetStringUTFChars(env, fxnName, NULL); - void *fxnPtr = dlsym(RTLD_SELF, functionName); - (*env)->ReleaseStringUTFChars(env, fxnName, functionName); - return ptr_to_jlong(fxnPtr); -} - -JNIEXPORT jlong JNICALL Java_com_apple_jobjc_Function_getFxnPtrForFunctionNameAndLib -(JNIEnv *env, jclass clazz, jlong frameworkPtr, jstring fxnName) -{ - void *frameworkHandle = jlong_to_ptr(frameworkPtr); - - const char *functionName = (*env)->GetStringUTFChars(env, fxnName, NULL); - void *fxnPtr = dlsym(frameworkHandle, functionName); - (*env)->ReleaseStringUTFChars(env, fxnName, functionName); - - return ptr_to_jlong(fxnPtr); -} diff --git a/jdk/src/macosx/native/jobjc/src/core/native/ID.m b/jdk/src/macosx/native/jobjc/src/core/native/ID.m deleted file mode 100644 index 2e40a03fad2..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/native/ID.m +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "com_apple_jobjc_ID.h" - -#include - -#include -#include - -/* - * Class: com_apple_jobjc_ID - * Method: getNativeDescription - * Signature: (J)Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL Java_com_apple_jobjc_ID_getNativeDescription -(JNIEnv *env, jclass clazz, jlong objPtr) -{ - jstring ret = NULL; - -JNF_COCOA_ENTER(env); - - NSString *desc = [((id)jlong_to_ptr(objPtr)) description]; - ret = JNFNSToJavaString(env, desc); - -JNF_COCOA_EXIT(env); - - return ret; -} diff --git a/jdk/src/macosx/native/jobjc/src/core/native/Invoke.m b/jdk/src/macosx/native/jobjc/src/core/native/Invoke.m deleted file mode 100644 index 28a11d92d80..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/native/Invoke.m +++ /dev/null @@ -1,40 +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. - */ - -#include "com_apple_jobjc_Invoke_FunCall.h" -#include -#include -#include - -JNIEXPORT void JNICALL Java_com_apple_jobjc_Invoke_00024FunCall_invoke -(JNIEnv *env, jclass clazz, jlong cifPtr, jlong fxnPtr, jlong retValPtr, jlong argsPtr) -{ - ffi_cif *cif = jlong_to_ptr(cifPtr); - void *fxn = jlong_to_ptr(fxnPtr); - void *retVal = jlong_to_ptr(retValPtr); - void **args = jlong_to_ptr(argsPtr); - - ffi_call(cif, fxn, retVal, args); -} diff --git a/jdk/src/macosx/native/jobjc/src/core/native/JObjCRuntime.m b/jdk/src/macosx/native/jobjc/src/core/native/JObjCRuntime.m deleted file mode 100644 index dfb5b48676a..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/native/JObjCRuntime.m +++ /dev/null @@ -1,27 +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. - */ - -#include "Cocoa/Cocoa.h" - diff --git a/jdk/src/macosx/native/jobjc/src/core/native/MacOSXFramework.m b/jdk/src/macosx/native/jobjc/src/core/native/MacOSXFramework.m deleted file mode 100644 index 4609d79fdcd..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/native/MacOSXFramework.m +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "com_apple_jobjc_MacOSXFramework.h" - -#include -#include - -/* - * Class: com_apple_jobjc_MacOSXFramework - * Method: retainFramework - * Signature: (Ljava/lang/String;)J - */ -JNIEXPORT jlong JNICALL Java_com_apple_jobjc_MacOSXFramework_retainFramework -(JNIEnv *env, jclass clazz, jstring frameworkName) -{ - if (frameworkName == NULL) return ptr_to_jlong(NULL); - const char *frameworkNameCStr = (*env)->GetStringUTFChars(env, frameworkName, JNI_FALSE); - const void *library = dlopen(frameworkNameCStr, RTLD_LOCAL); - (*env)->ReleaseStringUTFChars(env, frameworkName, frameworkNameCStr); - return ptr_to_jlong(library); -} - -/* - * Class: com_apple_jobjc_MacOSXFramework - * Method: releaseFramework - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_com_apple_jobjc_MacOSXFramework_releaseFramework -(JNIEnv *env, jclass clazz, jlong frameworkPtr) -{ - dlclose(jlong_to_ptr(frameworkPtr)); -} - -JNIEXPORT void JNICALL Java_com_apple_jobjc_MacOSXFramework_getConstant -(JNIEnv *env, jclass clazz, jlong frameworkPtr, jstring constSymbol, jlong retBuffer, jint size) -{ - const char *symbol = (*env)->GetStringUTFChars(env, constSymbol, JNI_FALSE); - void *handle = frameworkPtr ? jlong_to_ptr(frameworkPtr) : RTLD_DEFAULT; - void *data = dlsym(handle, symbol); - (*env)->ReleaseStringUTFChars(env, constSymbol, symbol); - - if(!data) - (*env)->ThrowNew(env, (*env)->FindClass(env, "java/lang/RuntimeException"), dlerror()); - else - memcpy(jlong_to_ptr(retBuffer), data, (size_t) size); -} diff --git a/jdk/src/macosx/native/jobjc/src/core/native/NSClass.m b/jdk/src/macosx/native/jobjc/src/core/native/NSClass.m deleted file mode 100644 index 8ae15e3a368..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/native/NSClass.m +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "com_apple_jobjc_NSClass.h" -#include - -#include - -/* - * Class: com_apple_jobjc_NSClass - * Method: getNativeClassByName - * Signature: (JLjava/lang/String;)J - */ -JNIEXPORT jlong JNICALL Java_com_apple_jobjc_NSClass_getNativeClassByName -(JNIEnv *env, jclass clazz, jstring className) -{ - if (className == NULL) return ptr_to_jlong(NULL); - const char *classNameCStr = (*env)->GetStringUTFChars(env, className, JNI_FALSE); - const id obj = objc_getClass(classNameCStr); - (*env)->ReleaseStringUTFChars(env, className, classNameCStr); - - if (obj == nil) return ptr_to_jlong(NULL); - return ptr_to_jlong(obj); -} - -/* - * Class: com_apple_jobjc_NSClass - * Method: getSuperClass - * Signature: (J)J - */ -JNIEXPORT jlong JNICALL Java_com_apple_jobjc_NSClass_getSuperClassOfClass -(JNIEnv *env, jclass clazz, jlong clazzPtr) -{ - if (clazzPtr == 0L) return ptr_to_jlong(NULL); - const Class objClazz = (Class)jlong_to_ptr(clazzPtr); - return ptr_to_jlong(class_getSuperclass(objClazz)); -} - -/* - * Class: com_apple_jobjc_NSClass - * Method: getClassName - * Signature: (J)Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL Java_com_apple_jobjc_NSClass_getClassNameOfClass -(JNIEnv *env, jclass clazz, jlong clazzPtr) -{ - const char *clazzName = (char *)class_getName((Class)jlong_to_ptr(clazzPtr)); - return (*env)->NewStringUTF(env, clazzName); -} - -JNIEXPORT jlong JNICALL Java_com_apple_jobjc_NSClass_getClass -(JNIEnv *env, jclass clazz, jlong objPtr) -{ - id obj = (id)jlong_to_ptr(objPtr); - return ptr_to_jlong(object_getClass(obj)); -} diff --git a/jdk/src/macosx/native/jobjc/src/core/native/NativeBuffer.h b/jdk/src/macosx/native/jobjc/src/core/native/NativeBuffer.h deleted file mode 100644 index 0fafa6ef3a8..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/native/NativeBuffer.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * NativeBuffer.h - * Copyright 2007 Apple Inc. All rights reserved. - * - */ - -#define BUFFER_AT(buffer, offset) (((UInt8 *)buffer) + offset) -#define GET_VALUE(type, buffer, offset) (*((type *)BUFFER_AT(buffer, offset))) -#define PUT_VALUE(type, buffer, offset, value) (*((type *)BUFFER_AT(buffer, offset)) = value) - -#define GET_INT_AT(buffer, offset) GET_VALUE(jint, buffer, offset) -#define GET_LONG_AT(buffer, offset) GET_VALUE(jlong, buffer, offset) - -#define PUT_INT_AT(buffer, offset, value) PUT_VALUE(jint, buffer, offset, value) -#define PUT_LONG_AT(buffer, offset, value) PUT_VALUE(jlong, buffer, offset, value) diff --git a/jdk/src/macosx/native/jobjc/src/core/native/NativeBuffer.m b/jdk/src/macosx/native/jobjc/src/core/native/NativeBuffer.m deleted file mode 100644 index 8f7b9b0fe01..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/native/NativeBuffer.m +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "com_apple_jobjc_NativeBuffer.h" - -#define MACOSX -#include -#include - -JNIEXPORT jlong JNICALL Java_com_apple_jobjc_NativeBuffer_getPtrOfBuffer -(JNIEnv *env, jclass clazz, jobject buffer) -{ - if (buffer == NULL) return ptr_to_jlong(0); - return ptr_to_jlong((*env)->GetDirectBufferAddress(env, buffer)); -} diff --git a/jdk/src/macosx/native/jobjc/src/core/native/NativeObjectLifecycleManager.m b/jdk/src/macosx/native/jobjc/src/core/native/NativeObjectLifecycleManager.m deleted file mode 100644 index 012f83a1d6a..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/native/NativeObjectLifecycleManager.m +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "com_apple_jobjc_NativeObjectLifecycleManager.h" - -#include - - -/* - * Class: com_apple_jobjc_NativeObjectLifecycleManager - * Method: retainNativeObject - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_com_apple_jobjc_NativeObjectLifecycleManager_retainNativeObject -(JNIEnv *env, jclass clazz, jlong ptr) -{ - if (ptr == 0L) return; - CFRetain(jlong_to_ptr(ptr)); -} - -/* - * Class: com_apple_jobjc_NativeObjectLifecycleManager - * Method: releaseNativeObject - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_com_apple_jobjc_NativeObjectLifecycleManager_releaseNativeObject -(JNIEnv *env, jclass clazz, jlong ptr) -{ - if (ptr == 0L) return; - CFRelease(jlong_to_ptr(ptr)); -} - -/* - * Class: com_apple_jobjc_NativeObjectLifecycleManager - * Method: freeNativeObject - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_com_apple_jobjc_NativeObjectLifecycleManager_freeNativeObject -(JNIEnv *env, jclass clazz, jlong ptr) -{ - if (ptr == 0L) return; - free(jlong_to_ptr(ptr)); -} diff --git a/jdk/src/macosx/native/jobjc/src/core/native/SEL.m b/jdk/src/macosx/native/jobjc/src/core/native/SEL.m deleted file mode 100644 index dc39ed10132..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/native/SEL.m +++ /dev/null @@ -1,44 +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. - */ - -#include "com_apple_jobjc_SEL.h" - -#include -#include - -JNIEXPORT jlong JNICALL Java_com_apple_jobjc_SEL_getSelectorPtr -(JNIEnv *env, jclass jclazz, jstring selName) -{ - const char *selNameAsChars = (*env)->GetStringUTFChars(env, selName, JNI_FALSE); - const SEL sel = sel_registerName(selNameAsChars); - (*env)->ReleaseStringUTFChars(env, selName, selNameAsChars); - return ptr_to_jlong((void*)sel); -} - -JNIEXPORT jstring JNICALL Java_com_apple_jobjc_SEL_getSelectorName -(JNIEnv *env, jclass jclazz, jlong selPtr) -{ - return (*env)->NewStringUTF(env, sel_getName(jlong_to_ptr(selPtr))); -} diff --git a/jdk/src/macosx/native/jobjc/src/core/native/Subclassing.m b/jdk/src/macosx/native/jobjc/src/core/native/Subclassing.m deleted file mode 100644 index 0e9d4651db8..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/native/Subclassing.m +++ /dev/null @@ -1,301 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "com_apple_jobjc_Subclassing.h" - -#include -#include -#include - -#include -#include - -#include -#include - -#include - -// Subclassing of Obj-C classes in Java -// -// See: -// - Objective-C Runtime documentation -// - man ffi_prep_closure -// - Subclassing.java - - -#pragma mark Accessing object in IVar - -#define JOBJ_IVAR_NAME "jObjWrapper" -static jobject getJObjectFromIVar(id obj); - -jobject getJObjectFromIVar(id obj) -{ - JNFJObjectWrapper *wrapper = NULL; - object_getInstanceVariable(obj, JOBJ_IVAR_NAME, (void**) &wrapper); - return wrapper ? [wrapper jObject] : NULL; -} - -JNIEXPORT jobject JNICALL Java_com_apple_jobjc_Subclassing_getJObjectFromIVar -(JNIEnv *env, jclass jClass, jlong jPtr) -{ - id obj = (id) jlong_to_ptr(jPtr); - if(obj == NULL){ - (*env)->ThrowNew(env, (*env)->FindClass(env, - "java/lang/NullPointerException"), "obj"); - return NULL; - } - - JNFJObjectWrapper *wrapper; - - if(!object_getInstanceVariable(obj, JOBJ_IVAR_NAME, (void**) &wrapper)){ - NSLog(@"IVar '%s' not found. obj: %@", JOBJ_IVAR_NAME, obj); - (*env)->ThrowNew(env, (*env)->FindClass(env, "java/lang/RuntimeException"), - "Could not find instance variable that holds Java object."); - return NULL; - } - - return wrapper ? [wrapper jObject] : NULL; -} - -JNIEXPORT void JNICALL Java_com_apple_jobjc_Subclassing_initJObjectToIVar -(JNIEnv *env, jclass jClass, jlong jPtr, jobject jObject) -{ - id obj = (id) jlong_to_ptr(jPtr); - JNFJObjectWrapper *wrapper = [[JNFJObjectWrapper alloc] - initWithJObject:jObject withEnv:env]; - [wrapper retain]; - - if(!object_setInstanceVariable(obj, JOBJ_IVAR_NAME, wrapper)){ - NSLog(@"IVar '%s' not found. obj: %@", JOBJ_IVAR_NAME, obj); - (*env)->ThrowNew(env, (*env)->FindClass(env, "java/lang/RuntimeException"), - "Could not find instance variable that holds Java object."); - return; - } -} - -#pragma mark Registering class - -JNIEXPORT jlong JNICALL Java_com_apple_jobjc_Subclassing_allocateClassPair -(JNIEnv *env, jclass clazz, jlong jSuperClass, jstring jName) -{ - const Class superClass = (Class)jlong_to_ptr(jSuperClass); - assert(superClass); - - const char *name = (*env)->GetStringUTFChars(env, jName, JNI_FALSE); - const Class newClass = objc_allocateClassPair(superClass, name, 0); - (*env)->ReleaseStringUTFChars(env, jName, name); - - return ptr_to_jlong(newClass); -} - -JNIEXPORT jboolean JNICALL Java_com_apple_jobjc_Subclassing_addIVarForJObj -(JNIEnv *env, jclass clazz, jlong jSynthClass) -{ - return class_addIvar( - jlong_to_ptr(jSynthClass), - JOBJ_IVAR_NAME, - sizeof(id), - (uint8_t)log2((double)sizeof(id)), - "@"); -} - -JNIEXPORT void JNICALL Java_com_apple_jobjc_Subclassing_registerClassPair -(JNIEnv *env, jclass clazz, jlong jClass) -{ - Class c = jlong_to_ptr(jClass); -// NSLog(@"Registering class pair %p / %s", c, class_getName(c)); - objc_registerClassPair(c); -} - - -#pragma mark Patching +alloc - -static id patchedAllocIMP(id obj, SEL sel); -static void addJavaInstance(id obj); - -JNIEXPORT jboolean JNICALL Java_com_apple_jobjc_Subclassing_patchAlloc -(JNIEnv *env, jclass clazz, jlong jNativeClass) -{ - Class metaClass = object_getClass(jlong_to_ptr(jNativeClass)); - return class_addMethod(metaClass, - sel_registerName("alloc"), - (IMP) patchedAllocIMP, - "@@:"); -} - -static id patchedAllocIMP(id cls, SEL sel){ - id inst = class_createInstance(cls, 0); - addJavaInstance(inst); - return inst; -} - -static void addJavaInstance(id obj){ -// NSLog(@"addJavaInstance %p", obj); -// NSLog(@"... calling up to Java"); - - static JNF_CLASS_CACHE(jc_Subclassing, "com/apple/jobjc/Subclassing"); - static JNF_STATIC_MEMBER_CACHE(jm_Subclassing_initJObject, - jc_Subclassing, - "initJObject", - "(J)V"); - - JNFThreadContext threadWasAttached = JNFThreadDetachOnThreadDeath; - JNIEnv *env = JNFObtainEnv(&threadWasAttached); - JNFCallStaticVoidMethod(env, jm_Subclassing_initJObject, - ptr_to_jlong(obj)); - - JNFReleaseEnv(env, &threadWasAttached); -} - - -#pragma mark Adding methods - -static ffi_closure *make_closure(ffi_cif *cif, void *user_data); -static void sel_closure_call(ffi_cif* cif, void* result, void** args, void* user_data); - -typedef struct closure_data_t{ - JNFJObjectWrapper *jMethod; - JNFJObjectWrapper *jCIF; -} closure_data_t; - -static ffi_closure *make_closure(ffi_cif *cif, void *user_data){ - // Allocate a page to hold the closure with read and write permissions. - ffi_closure *closure; - if ((closure = mmap(NULL, sizeof(ffi_closure), PROT_READ | PROT_WRITE, - MAP_ANON | MAP_PRIVATE, -1, (off_t) 0)) == (void*)-1) - { - fprintf(stderr, "mmap failed with errno: %d", errno); - return NULL; - } - - // Prepare the ffi_closure structure. - ffi_status status; - if ((status = ffi_prep_closure(closure, cif, sel_closure_call, (void *)user_data)) != FFI_OK) - { - fprintf(stderr, "ffi_prep_closure failed with ffi_status: %d", status); - munmap(closure, sizeof(ffi_closure)); - return NULL; - } - - // Ensure that the closure will execute on all architectures. - if (mprotect(closure, sizeof(closure), PROT_READ | PROT_EXEC) == -1) - { - fprintf(stderr, "mprotect failed with errno: %d", errno); - munmap(closure, sizeof(ffi_closure)); - return NULL; - } - return closure; -} - -JNIEXPORT jboolean JNICALL Java_com_apple_jobjc_Subclassing_addMethod -(JNIEnv *env, jclass clazz, jlong jClass, jstring jSelName, jobject jMethod, - jobject jCIF, jlong jCIFPtr, jstring jObjCEncodedType) -{ - ffi_cif *cif = jlong_to_ptr(jCIFPtr); - - closure_data_t *user_data = malloc(sizeof(closure_data_t)); - user_data->jMethod = [[JNFJObjectWrapper alloc] initWithJObject:jMethod withEnv:env]; - user_data->jCIF = [[JNFJObjectWrapper alloc] initWithJObject:jCIF withEnv:env]; - - ffi_closure *closure;; - if(!(closure = make_closure(cif, user_data))){ - [user_data->jMethod release]; - [user_data->jCIF release]; - free(user_data); - return NO; - } - - const Class objcClass = (Class)jlong_to_ptr(jClass); - - const char *selName = (*env)->GetStringUTFChars(env, jSelName, JNI_FALSE); - const char *objCEncodedType = (*env)->GetStringUTFChars(env, jObjCEncodedType, JNI_FALSE); - -// NSLog(@"Adding method '%s' :: '%s' to '%s' / %p", -// selName, -// objCEncodedType, -// class_getName(objcClass), -// objcClass); - - BOOL ret = class_addMethod(objcClass, sel_registerName(selName), (IMP) closure, objCEncodedType); - - (*env)->ReleaseStringUTFChars(env, jSelName, selName); - (*env)->ReleaseStringUTFChars(env, jObjCEncodedType, objCEncodedType); - - if(!ret){ - NSLog(@"class_addMethod failed"); - munmap(closure, sizeof(ffi_closure)); - [user_data->jMethod release]; - [user_data->jCIF release]; - free(user_data); - return NO; - } - - return ret; -} - -static void sel_closure_call(ffi_cif* cif, void* result, void** args, void* user_data) -{ - id obj = *(id*) args[0]; -// SEL sel = *(SEL*) args[1]; - -// NSLog(@"Subclassing: sel_closure_call: %p %p", obj, sel); -// NSLog(@"Subclassing: sel_closure_call: obj class: %@ sel name: %s", object_getClass(obj), sel_getName(sel)); - - jobject jObj = getJObjectFromIVar(obj); - - if(!jObj){ - addJavaInstance(obj); - jObj = getJObjectFromIVar(obj); - } - - closure_data_t *jmeta = user_data; - jobject jMethod = [jmeta->jMethod jObject]; - jobject jCIF = [jmeta->jCIF jObject]; - - JNFThreadContext threadWasAttached = JNFThreadDetachOnThreadDeath; - JNIEnv *env = JNFObtainEnv(&threadWasAttached); - - if((*env)->ExceptionOccurred(env)) goto bail; - - static JNF_CLASS_CACHE(jc, "com/apple/jobjc/Subclassing"); - static JNF_STATIC_MEMBER_CACHE(jm_invokeFromJNI, jc, "invokeFromJNI", - "(Lcom/apple/jobjc/ID;Ljava/lang/reflect/Method;Lcom/apple/jobjc/CIF;JJ)V"); - - JNFCallStaticVoidMethod(env, jm_invokeFromJNI, - jObj, - jMethod, - jCIF, - ptr_to_jlong(result), - ptr_to_jlong(args)); - -bail: - JNFReleaseEnv(env, &threadWasAttached); - - if((*env)->ExceptionOccurred(env)){ - NSLog(@"Exception!"); - (*env)->ExceptionDescribe(env); - } - JNFReleaseEnv(env, &threadWasAttached); -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/BootClassPathMinus.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/BootClassPathMinus.java deleted file mode 100644 index efbad58a104..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/BootClassPathMinus.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator; - -public class BootClassPathMinus { - - /* - * return the default boot class path with all parts mentioned in arguments removed - */ - public static void main(String[] args) { - String bootClassPath = System.getProperty("sun.boot.class.path"); - StringBuffer newPath = new StringBuffer(bootClassPath.length()); - String[] bootClassPathParts = bootClassPath.split(java.io.File.pathSeparator, 0); - for (String part : bootClassPathParts) { - boolean found = false; - for (String minus : args) { - if (part.endsWith(minus)) { - found = true; - } - } - if (!found) { - if (newPath.length() > 0) newPath.append(java.io.File.pathSeparatorChar); - newPath.append(part); - } - } - System.out.println(newPath.toString()); - } - -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/ClassConsolidator.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/ClassConsolidator.java deleted file mode 100644 index 69a872f8dbc..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/ClassConsolidator.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import com.apple.internal.jobjc.generator.model.Category; -import com.apple.internal.jobjc.generator.model.Clazz; -import com.apple.internal.jobjc.generator.model.Framework; - -public class ClassConsolidator { - private static String[] PREFERRED_FRAMEWORKS = { "Foundation", "AppKit" }; - - static void consolidateClassesForFrameworks(final List frameworks) throws Throwable { - System.out.println("--2-- Resolving duplicate classes:"); - final Map> allClasses = new HashMap>(); - - for (final Framework framework : frameworks) { - for (final Clazz clazz : framework.classes) { - final List existingClazzList = allClasses.get(clazz.name); - if(existingClazzList != null) - existingClazzList.add(clazz); - else - allClasses.put(clazz.name, new ArrayList(Arrays.asList(clazz))); - } - } - - final Map filteredClasses = new HashMap(); - final List> dreggs = new ArrayList>(); - - final Collection> clazzLists = allClasses.values(); - for (final List clazzList : clazzLists) { - if (clazzList.size() > 1) { - // add to the list for later analysis - dreggs.add(clazzList); - continue; - } - - // if there is only one class definition, go with it! - final Clazz clazz = clazzList.get(0); - filteredClasses.put(clazz.name, clazz); - } - - // figure out which class is the real class, and convert the rest to categories - for (final List dreg : dreggs) - deriveCategoriesFrom(dreg, filteredClasses); - - // patch up the inheritance hierarchy - System.out.println("Determining super classes:"); - for (final Framework framework : frameworks) - framework.resolveSuperClasses(filteredClasses); - } - - private static void deriveCategoriesFrom(final List clazzes, final Map filteredClasses) { - final List clazzesToDerive = new ArrayList(clazzes); - - for (final String preferredFrameworkName : PREFERRED_FRAMEWORKS) { - for (final Clazz clazz : clazzesToDerive) { - if (!preferredFrameworkName.equals(clazz.parent.name)) continue; - - System.out.print("\t" + clazz.parent.name + " owns \"" + clazz.name + "\", "); - addCategoriesAndPatchClasses(clazzes, clazz); - filteredClasses.put(clazz.name, clazz); - return; - } - } - - final List frameworkNameList = new ArrayList(clazzes.size()); - for (final Clazz clazz : clazzes) frameworkNameList.add(clazz.parent.name); - throw new RuntimeException("Could not derived a preferred framework for: " + clazzes.get(0).name + ", from (" + Utils.joinWComma(frameworkNameList) + ")"); - } - - private static void addCategoriesAndPatchClasses(final List clazzes, final Clazz clazz) { - final List fwNames = new ArrayList(clazzes.size()); - - for (final Clazz cls : clazzes) { - if (cls == clazz) continue; - fwNames.add(cls.parent.name); - cls.parent.classes.remove(cls); - cls.parent.categories.add(new Category(cls, clazz)); - } - - System.out.println("creating categories in: " + Utils.joinWComma(fwNames)); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/ClassGenerator.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/ClassGenerator.java deleted file mode 100644 index 8953fa306c0..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/ClassGenerator.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator; - -import java.util.*; - -import com.apple.internal.jobjc.generator.classes.*; -import com.apple.internal.jobjc.generator.model.Framework; - -public class ClassGenerator { - public static final String JOBJC_PACKAGE = "com.apple.jobjc"; - - public static List generateClasses(final List frameworks) { - final List generatedClassFiles = new ArrayList(); - - generatedClassFiles.add(new RootJObjCClass(frameworks)); - for (final Framework f : frameworks) { - f.generateClasses(generatedClassFiles); - } - - return generatedClassFiles; - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/FileCopier.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/FileCopier.java deleted file mode 100644 index bcaf5bcb8c7..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/FileCopier.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator; - -import java.io.File; -import java.util.*; - -import com.apple.internal.jobjc.generator.classes.*; - -public class FileCopier { - public static List addSourceFilesFrom(final String srcPath) { - final List outputFileList = new ArrayList(); - - final List fileList = getFileList(srcPath); - for (final File file : fileList) { - outputFileList.add(new CopiedFile(file, ClassGenerator.JOBJC_PACKAGE, file.getName().replace("\\.java", ""))); - } - - return outputFileList; - } - - private static List getFileList(final String srcPath) { - final File srcRoot = new File(srcPath); - if (!srcRoot.exists()) throw new RuntimeException("Source root " + srcRoot + " does not exist. Nowhere to copy base runtime objects from."); - - final File targetDir = new File(srcRoot, ClassGenerator.JOBJC_PACKAGE.replaceAll("\\.", "\\/")); - if (!targetDir.exists() || !targetDir.isDirectory()) throw new RuntimeException("Base runtime object source directory " + targetDir + " does not exist. No runtime class files to copy."); - - final List fileList = new ArrayList(); - final File[] targetDirFileList = targetDir.listFiles(); - for (final File file : targetDirFileList) { - if (!file.isFile()) continue; - if (!file.getName().endsWith(".java")) continue; - fileList.add(file); - } - - return fileList; - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/FrameworkGenerator.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/FrameworkGenerator.java deleted file mode 100644 index 1f11ed9038b..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/FrameworkGenerator.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import com.apple.internal.jobjc.generator.model.Framework; -import com.apple.internal.jobjc.generator.model.Framework.FrameworkDependency; -import com.apple.internal.jobjc.generator.utils.Fp; -import com.apple.internal.jobjc.generator.utils.StructOffsetResolverBigBang; -import com.apple.jobjc.JObjCRuntime; - -public class FrameworkGenerator { - private static final String BRIDGESUPPORT_FILE_EXTENSION = "Full.bridgesupport"; - private static final String FRAMEWORK_MATCH = "^.*Full\\.bridgesupport$"; - private static final String FRAMEWORK_PRUNE = "^.*(PyObjC|/Versions|\\.lproj|/Headers|/PrivateHeaders).*$"; - - static List findFrameworkFilesIn(final File file) throws IOException{ - final List bridgeSupportFiles = Utils.find(file, FRAMEWORK_MATCH, FRAMEWORK_PRUNE); - System.out.println("found " + bridgeSupportFiles.size() + " frameworks"); - return bridgeSupportFiles; - } - - static List parseFrameworksFrom(final List bridgeSupportFiles) { - final List frameworks = new ArrayList(); - - System.out.println("Parsing XML"); - for (final File file : bridgeSupportFiles){ - Framework f = new Framework(extractFrameworkNameFrom(file), file); - try{ - f.load(); - frameworks.add(f); - System.out.println("Generator@" + JObjCRuntime.ARCH + " loaded " - + f.name + " (" + Fp.join(":", f.binaries) + ")"); - } - catch(Exception x){ - System.out.println("!! Generator@" + JObjCRuntime.ARCH + " failed to load " - + f.name + " (" + Fp.join(":", f.binaries) + "). SKIPPING"); - } - } - - System.out.println("Parsing dependencies"); - for (final Framework f : frameworks) f.parseDependencies(frameworks); - - Set alreadyWarnedDependency = new HashSet(); - for(final Framework f : frameworks) - for(final FrameworkDependency dep : f.dependencies) - if(dep.object == null && !alreadyWarnedDependency.contains(dep.name)){ - System.out.println(String.format("Warning: unresolved dependency: %1$30s -> %2$s", f.name, dep.name)); - alreadyWarnedDependency.add(dep.name); - } - if(alreadyWarnedDependency.size() > 0) - System.out.println("Unresolved dependencies lead to unresolved types."); - - Utils.topologicalSort(frameworks); - List cycle = Utils.getDependencyCycle(frameworks); - if(cycle != null) - System.out.println("Warning: cycle found in framework dependencies: " + Fp.join(" -> ", cycle)); - - System.out.println("Parsing types"); - for (final Framework f : frameworks){ - f.parseCFTypes(); - f.parseOpaques(); - } - for (final Framework f : frameworks) f.parseStructs(); - - new StructOffsetResolverBigBang().resolve(frameworks); - - System.out.println("Parsing classes"); - for (final Framework f : frameworks) f.parseClasses(); - - System.out.println("Parsing constants"); - for (final Framework f : frameworks) f.parseConstants(); - - System.out.println("Parsing functions"); - for (final Framework f : frameworks) f.parseFunctions(); - - return frameworks; - } - - private static String extractFrameworkNameFrom(final File file) { - final String fileName = file.getName(); - return fileName.substring(0, fileName.lastIndexOf(BRIDGESUPPORT_FILE_EXTENSION)); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/FunctionGenerator.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/FunctionGenerator.java deleted file mode 100644 index 37f67aa39bd..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/FunctionGenerator.java +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator; - -import java.io.PrintStream; -import java.io.StringWriter; - -import com.apple.internal.jobjc.generator.model.Arg; -import com.apple.internal.jobjc.generator.model.Function; -import com.apple.internal.jobjc.generator.model.Method; -import com.apple.internal.jobjc.generator.model.types.JType; -import com.apple.internal.jobjc.generator.utils.JavaLang.JLCall; -import com.apple.internal.jobjc.generator.utils.JavaLang.JLField; -import com.apple.internal.jobjc.generator.utils.JavaLang.JLMethod; -import com.apple.internal.jobjc.generator.utils.JavaLang.JLTertiary; -import com.apple.jobjc.Coder; -import com.apple.jobjc.Invoke; -import com.apple.jobjc.Invoke.FunCall; -import com.apple.jobjc.Invoke.MsgSend; - -public class FunctionGenerator { - private final static String VARARGS_NAME = "varargs"; - - private static String createFieldCache(final Class type, final Function fxn) { - final String identifier = makeInstanceName(fxn); - - JLField field = new JLField("private static", type.getCanonicalName(), identifier); - // It's okay to make it static, because the getter isn't static, so the only way to access it is through an instance. - JLMethod getter = new JLMethod("private final", type.getCanonicalName(), "get_" + identifier); - - JLCall createIt = new JLCall("new " + type.getCanonicalName()); - createIt.args.add(firstArg(fxn)); - createIt.args.add("\"" + fxn.name + "\""); - createIt.args.add(fxn.returnValue.type.getJType().getCoderDescriptor().getCoderInstanceName()); - for (final Arg arg : fxn.args) - createIt.args.add(arg.type.getJType().getCoderDescriptor().getCoderInstanceName()); - - getter.body.add("return " + new JLTertiary(identifier + " != null", identifier, identifier + " = " + createIt) + ";"); - - return field.toString() + getter.toString(); - } - - private static String createLocalForward(final Class type, final Function fxn) { - final String identifier = makeInstanceName(fxn); - return new JLField("final", type.getCanonicalName(), identifier, new JLCall("get_" + identifier)).toString(); - } - - private static String createLocalNew(final Class type, final Function fxn) { - final String identifier = makeInstanceName(fxn); - StringWriter out = new StringWriter(); - - out.append(String.format("%3$s[] argCoders = new %3$s[%1$d + %2$s.length];\n", fxn.args.size(), VARARGS_NAME, Coder.class.getCanonicalName())); - - for(int i = 0; i < fxn.args.size(); i++) - out.append(String.format("argCoders[%1$d] = %2$s;\n", i, fxn.args.get(0).type.getJType().getCoderDescriptor().getCoderInstanceName())); - - if(fxn.variadic){ - out.append(String.format("for(int i = %1$d; i < (%1$d + %2$s.length); i++)\n", fxn.args.size(), VARARGS_NAME)); - out.append(String.format("\targCoders[i] = %1$s.getCoderAtRuntime(%2$s[i - %3$s]);\n", Coder.class.getCanonicalName(), VARARGS_NAME, fxn.args.size())); - } - - out.append("final " + type.getCanonicalName() + " " + identifier + " = new " + type.getCanonicalName() + "(" + firstArg(fxn) + ", \"" + fxn.name + "\", " - + fxn.returnValue.type.getJType().getCoderDescriptor().getCoderInstanceName() + ", argCoders);"); - - return out.toString(); - } - - private static final String CONTEXT_NAME = "nativeBuffer"; - - public static void writeOutFunction(final PrintStream out, final Class type, final Function fxn, final String initWithObj) { - final String instName = makeInstanceName(fxn); - final JType returnJavaType = fxn.returnValue.type.getJType(); - - if(!fxn.variadic){ - out.print(createFieldCache(type, fxn)); - out.println(); - } - - JLMethod meth = new JLMethod("public", returnJavaType.getJavaReturnTypeName(), fxn.getJavaName()); - - for(Arg arg : fxn.args) - meth.args.add("final " + arg.type.getJType().getTypeNameAsParam() + " " + arg.javaName); - - if(fxn.variadic) - meth.args.add("final Object... " + VARARGS_NAME); - - if(fxn instanceof Method && ((Method)fxn).ignore){ - String suggestion = ((Method)fxn).suggestion == null ? "" : (" Suggested work-around: " + ((Method)fxn).suggestion); - meth.jdoc.add("@deprecated The framework recommends that this method be ignored. (It may be deprecated.)" + suggestion); - meth.attrs.add("@Deprecated"); - } - - // type mismatch warning - { - { - String retMsg = fxn.returnValue.type.getJType().getCoderDescriptor().mismatchMessage(); - if(retMsg != null){ - meth.jdoc.add("@deprecated Possible type mismatch: (return value) " + retMsg); - meth.attrs.add("@Deprecated"); - } - } - - for(int i = 0; i < fxn.args.size(); i++){ - final Arg arg = fxn.args.get(i); - String argMsg = arg.type.getJType().getCoderDescriptor().mismatchMessage(); - if(argMsg != null){ - meth.jdoc.add("@deprecated Possible type mismatch: (arg" + i + ": " + arg.javaName + ") " + argMsg); - meth.attrs.add("@Deprecated"); - } - } - } - - if(fxn.variadic) - meth.body.add(createLocalNew(coreType(fxn), fxn)); - else - meth.body.add(createLocalForward(coreType(fxn), fxn)); - - meth.body.add(returnJavaType.createDeclareBuffer(CONTEXT_NAME)); - meth.body.add(returnJavaType.createInit(CONTEXT_NAME, instName, initWithObj)); - - for(final Arg arg : fxn.args) - meth.body.add(arg.type.getJType().getCoderDescriptor().getPushStatementFor(CONTEXT_NAME, arg.javaName)); - - if(fxn.variadic){ - meth.body.add(String.format("for(int i = %1$d; i < (%1$d + %2$s.length); i++)", fxn.args.size(), VARARGS_NAME)); - meth.body.add(String.format("\targCoders[i].push(%1$s, %2$s[i - %3$d]);", CONTEXT_NAME, VARARGS_NAME, fxn.args.size())); - } - - meth.body.add(returnJavaType.createInvoke(CONTEXT_NAME, instName)); - meth.body.add(returnJavaType.createPop(CONTEXT_NAME)); - meth.body.add(returnJavaType.createReturn()); - - out.print(meth.toString()); - out.println(); - } - - private static Class coreType(final Function fxn){ - return fxn instanceof Method ? MsgSend.class : FunCall.class; - } - - private static String firstArg(Function fxn){ - return fxn instanceof Method ? "getRuntime()" : "this"; - } - - private static String makeInstanceName(Function fxn){ - String ext; - if(fxn instanceof Method){ - if(((Method) fxn).isClassMethod) ext = "CMetInst"; - else ext = "IMetInst"; - } - else - ext = "FxnInst"; - - return fxn.getJavaName() + "_" + ext; - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/Generator.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/Generator.java deleted file mode 100644 index f1411e83e7d..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/Generator.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator; - -import java.io.File; -import java.util.List; -import java.util.Map; - -import com.apple.internal.jobjc.generator.classes.MixedPrimitiveCoderClassFile; -import com.apple.internal.jobjc.generator.classes.OutputFile; -import com.apple.internal.jobjc.generator.model.Framework; -import com.apple.internal.jobjc.generator.model.coders.ComplexCoderDescriptor; -import com.apple.internal.jobjc.generator.model.types.Type; -import com.apple.internal.jobjc.generator.model.types.TypeCache; -import com.apple.internal.jobjc.generator.utils.Fp.Pair; - -public class Generator { - private static final String DEFAULT_FRAMEWORKS_PATH = "/System/Library/Frameworks"; - private static final String DEFAULT_OUTPUT_PATH = "/tmp/JObjC"; - - public static void main(final String...args) throws Throwable { - final Map argMap = Utils.getArgs(args); - - final String dst = get(argMap, "dst", DEFAULT_OUTPUT_PATH); - System.out.println("Cleaning up: " + dst); - final File dstLoc = new File(dst); - Utils.recDelete(dstLoc); - dstLoc.mkdirs(); - System.out.println("Outputting classes to: " + dst); - - final String frameworksPath = get(argMap, "frameworks", DEFAULT_FRAMEWORKS_PATH); - System.out.println("Searching for bridged frameworks in: " + frameworksPath); - - final List bridgeSupportFiles = FrameworkGenerator.findFrameworkFilesIn(new File(frameworksPath)); - final List frameworks = FrameworkGenerator.parseFrameworksFrom(bridgeSupportFiles); - - System.out.println("--1-- Generator: consolidateClassesForFrameworks"); - ClassConsolidator.consolidateClassesForFrameworks(frameworks); - - System.out.println("--1-- Generator: TypeCache load"); - TypeCache.inst().load(frameworks); - - System.out.println("--1-- Generator: disambiguateMethodNames"); - MethodDisambiguator.disambiguateMethodNames(); - - System.out.println("--1-- Generator: disambiguateFunctionsIn"); - MethodDisambiguator.disambiguateFunctionsIn(frameworks); - - System.out.println("--1-- Generator: generateClasses"); - final List sourceFiles = ClassGenerator.generateClasses(frameworks); - sourceFiles.add(new MixedPrimitiveCoderClassFile(ComplexCoderDescriptor.getMixedEncoders())); - - System.out.println("--1-- Generator: writing " + sourceFiles.size() + " files"); - for (final OutputFile sourceFile : sourceFiles) sourceFile.write(dstLoc); - - System.out.println("I have " + TypeCache.inst().getUnknownTypes().size() + " unresolved types."); - for (final Type type : TypeCache.inst().getUnknownTypes()) - System.out.println("[Warning] unknown type: " + type); - - for(Type type : TypeCache.inst().typesByNTypes.values()){ - if(!type.type32.getClass().equals(type.type64.getClass())){ - System.out.format("Type with differing NTypes: %1$15s: %2$s\n", type.name, new Pair(type.type32, type.type64)); - } - } - } - - private static String get(final Map defaults, final String key, final String defaultValue) { - final String value = defaults.get(key); - if (value != null) return value; - return defaultValue; - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/MethodDisambiguator.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/MethodDisambiguator.java deleted file mode 100644 index 5b8bcb2ec79..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/MethodDisambiguator.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator; - -import java.util.List; - -import com.apple.internal.jobjc.generator.model.Clazz; -import com.apple.internal.jobjc.generator.model.Framework; -import com.apple.internal.jobjc.generator.model.Function; -import com.apple.internal.jobjc.generator.model.types.TypeCache; - -public class MethodDisambiguator { - static void disambiguateMethodNames() { - // link all subclassers off their parents - for (final Clazz clazz : TypeCache.inst().getAllClasses()) { - final Clazz superClazz = clazz.superClass; - if (superClazz != null) superClazz.subClassers.add(clazz); - } - - // recursively call all subclassers, starting from NSObject on down - disambiguateMethodNamesFor(TypeCache.inst().getClassForName("NSObject")); - - // NSProxy does not appear to subclass from NSObject, but it is still a real full class...? - disambiguateMethodNamesFor(TypeCache.inst().getClassForName("NSProxy")); - } - - static void disambiguateMethodNamesFor(final Clazz clazz) { - clazz.disambiguateMethods(); - for (final Clazz subClazz : clazz.subClassers) { - disambiguateMethodNamesFor(subClazz); - } - } - - public static void disambiguateFunctionsIn(final List frameworks) { - for (final Framework framework : frameworks) { - disambiguateFunctionsInFramework(framework); - } - } - - static void disambiguateFunctionsInFramework(final Framework framework) { - for (final Function fxn : framework.functions) - fxn.disambiguateArgs(); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/RestrictedKeywords.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/RestrictedKeywords.java deleted file mode 100644 index aeaaeee548a..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/RestrictedKeywords.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator; - -import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; - -public class RestrictedKeywords { - static final String[] JAVA_KEYWORD_CONFLICTS = { - "wait", "null", "class", "new", "toString", "finalize", "boolean", "interface", "final", "static" - }; - - static final Set originalRestrictedSet = new HashSet(Arrays.asList(JAVA_KEYWORD_CONFLICTS)); - - public static Set getNewRestrictedSet() { - return new HashSet(originalRestrictedSet); - } - - public static boolean isRestricted(String s){ - return originalRestrictedSet.contains(s); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/Utils.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/Utils.java deleted file mode 100644 index 7a3459c2164..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/Utils.java +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeSet; -import java.util.regex.Pattern; - -import com.apple.internal.jobjc.generator.model.Framework; -import com.apple.internal.jobjc.generator.model.Framework.FrameworkDependency; -import com.apple.internal.jobjc.generator.utils.Fp; - -public class Utils { - public static boolean isLeopard = System.getProperty("os.version").startsWith("10.5"); - public static boolean isSnowLeopard = System.getProperty("os.version").startsWith("10.6"); - - @SuppressWarnings("unchecked") - public static List list(final Object...args) { - final ArrayList list = new ArrayList(args.length); - for (final Object arg : args) list.add(arg); - return (List)list; - } - - /** - * A small implementation of UNIX find. - * @param matchRegex Only collect paths that match this regex. - * @param pruneRegex Don't recurse down a path that matches this regex. May be null. - * @throws IOException if File.getCanonicalPath() fails. - */ - public static List find(final File startpath, final String matchRegex, final String pruneRegex) throws IOException{ - final Pattern matchPattern = Pattern.compile(matchRegex, Pattern.CASE_INSENSITIVE); - final Pattern prunePattern = pruneRegex == null ? null : Pattern.compile(pruneRegex, Pattern.CASE_INSENSITIVE); - final Set visited = new HashSet(); - final List found = new ArrayList(); - class Search{ - void search(final File path) throws IOException{ - if(prunePattern != null && prunePattern.matcher(path.getAbsolutePath()).matches()) return; - String cpath = path.getCanonicalPath(); - if(!visited.add(cpath)) return; - if(matchPattern.matcher(path.getAbsolutePath()).matches()) - found.add(path); - if(path.isDirectory()) - for(File sub : path.listFiles()) - search(sub); - } - } - new Search().search(startpath); - return found; - } - - public static String joinWComma(final List list) { return Fp.join(", ", list); } - public static String joinWComma(final Object[] list) { return Fp.join(", ", Arrays.asList(list)); } - - public static class Substituter { - String str; - - public Substituter(final String str) { - this.str = str.replaceAll("\\#", "\t").replaceAll("\\~", "\n"); - } - - public void replace(final String key, final String value) { - str = str.replaceAll("\\$" + key, value); - } - - /** - * Apply String.format first, and then pass through Substituter. - */ - public static String format(String format, Object... args){ - return new Substituter(String.format(format, args)).toString(); - } - - @Override public String toString() { - return str; - } - } - - static Map getArgs(final String...args) { - final Map argMap = new HashMap(); - for (final String arg : args) { - final String[] splitArg = arg.split("\\="); - if (splitArg.length != 2) continue; - argMap.put(splitArg[0], splitArg[1]); - } - return argMap; - } - - static void recDelete(final File file) { - if (!file.exists()) return; - if (file.isDirectory()) for (final File f : file.listFiles()) recDelete(f); - file.delete(); - } - - public static String capitalize(String s){ - if(s.length() == 0) return s; - return Character.toString(Character.toUpperCase(s.charAt(0))) + s.substring(1); - } - - /** - * Sort frameworks by dependencies. If A is a dependency of B, - * then A will come before B in the list. - */ - public static void topologicalSort(final List frameworks) { - final Set visited = new TreeSet(); - final List sorted = new ArrayList(frameworks.size()); - class Rec{ - void visit(final Framework fw){ - if(!visited.add(fw)) return; - for(FrameworkDependency dep : fw.dependencies) - if(dep.object != null) - visit(dep.object); - sorted.add(fw); - } - } - for(Framework fw : frameworks) new Rec().visit(fw); - frameworks.clear(); - frameworks.addAll(sorted); - } - - /** - * If there is a cycle it is returned. Otherwise null is returned. - */ - public static List getDependencyCycle(List frameworks) { - @SuppressWarnings("serial") - class FoundCycle extends Throwable{ - public final List cycle; - public FoundCycle(List cycle){ - this.cycle = cycle; - } - }; - class Rec{ - void visit(final Framework fw, List visited) throws FoundCycle{ - visited = new LinkedList(visited); - if(visited.contains(fw)){ - visited.add(fw); - throw new FoundCycle(visited); - } - visited.add(fw); - for(FrameworkDependency dep : fw.dependencies) - if(dep.object != null) - visit(dep.object, visited); - } - } - try{ for(Framework fw : frameworks){ new Rec().visit(fw, new LinkedList()); }} - catch(FoundCycle x){ return x.cycle; } - return null; - } - - public static String getCanonicalPath(File file) throws RuntimeException{ - try { - return file.getCanonicalPath(); - } catch (IOException e) { - throw new RuntimeException(e); - } - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/AbstractObjCClassFile.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/AbstractObjCClassFile.java deleted file mode 100644 index e3208d17167..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/AbstractObjCClassFile.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.classes; - -import com.apple.internal.jobjc.generator.model.Clazz; - -public abstract class AbstractObjCClassFile extends GeneratedClassFile { - final Clazz clazz; - - public AbstractObjCClassFile(final Clazz clazz, final String classname, final String genericArgs, final String superClass) { - super(clazz.getPackage(), classname, genericArgs, superClass); - this.clazz = clazz; - } - - public AbstractObjCClassFile(final Clazz clazz, final String classname, final String superClass) { - super(clazz.getPackage(), classname, superClass); - this.clazz = clazz; - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/CFTypeClassFile.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/CFTypeClassFile.java deleted file mode 100644 index 774cae18e6e..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/CFTypeClassFile.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.classes; - -import java.io.PrintStream; - -import com.apple.internal.jobjc.generator.model.CFType; -import com.apple.jobjc.Pointer; - -public class CFTypeClassFile extends GeneratedClassFile { - final CFType cftype; - - public CFTypeClassFile(final CFType cftype) { - super(cftype.parent.pkg, cftype.type.getJType().getJavaClassName(), com.apple.jobjc.CFType.class.getCanonicalName()); - this.cftype = cftype; - } - - @Override public void writeBeginning(PrintStream out){ - out.println("\tpublic " + className + "(" + Pointer.class.getName() + " ptr){"); - out.println("\t\tsuper(ptr);"); - out.println("\t}"); - out.println(""); - out.println("\tpublic " + className + "(long ptr){"); - out.println("\t\tsuper(ptr);"); - out.println("\t}"); - } - - @Override public void writeBody(PrintStream out){ - if(cftype.getTypeIdFunc != null){ - out.println("\tpublic static long getTypeId(){"); - out.println("\t\treturn " + RootJObjCClass.runtimeFrameworkInst(cftype.parent.name) + "." + cftype.getTypeIdFunc + "();"); - out.println("\t}"); - } - else - out.println("\t// getTypeIdFunc not found"); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/CategoryClassClassFile.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/CategoryClassClassFile.java deleted file mode 100644 index f89c24320cf..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/CategoryClassClassFile.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.classes; - -import java.io.PrintStream; -import java.util.HashSet; -import java.util.Set; - -import com.apple.internal.jobjc.generator.FunctionGenerator; -import com.apple.internal.jobjc.generator.model.Category; -import com.apple.internal.jobjc.generator.model.Method; -import com.apple.jobjc.JObjCRuntime; -import com.apple.jobjc.Invoke.MsgSend; - -public class CategoryClassClassFile extends AbstractObjCClassFile { - final Category category; - - public CategoryClassClassFile(final Category category) { - super(category.category, category.category.name + "Class", - category.category.superClass.getFullPath() + "Class"); - this.category = category; - } - - @Override public void writeBeginning(final PrintStream out) { - out.format( - "\t%1$s(%2$s runtime) {\n" + - "\t\tsuper(\"%3$s\", runtime);\n" + - "\t}\n", - className, JObjCRuntime.class.getCanonicalName(), category.category.superClass.name); - } - - @Override public void writeBody(final PrintStream out) { - Set written = new HashSet(); - for(final Method method : this.clazz.classMethods) - if(written.add(method.name)) - FunctionGenerator.writeOutFunction(out, MsgSend.class, method, "this"); - else - System.out.format("Duplicate method: %1$s %2$s -%3$s\n", clazz.parent.name, className, method.name); - } - - @Override protected boolean isFinal(){ return true; } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/CategoryClassFile.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/CategoryClassFile.java deleted file mode 100644 index c858546d092..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/CategoryClassFile.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.classes; - -import java.io.PrintStream; - -import com.apple.internal.jobjc.generator.model.Category; -import com.apple.jobjc.JObjCRuntime; - -public class CategoryClassFile extends JObjCClassFile { - private final Category category; - - public CategoryClassFile(final Category category) { - super(category.category); - this.category = category; - } - - @Override public void writeBeginning(final PrintStream out) { - String targetCls = category.category.superClass.getFullPath(); - out.format("\tpublic %1$s(final %2$s obj, final %3$s runtime) {\n" + - "\t\tsuper(obj, runtime);\n" + - "\t}\n", - className, targetCls, JObjCRuntime.class.getCanonicalName()); - super.writeBeginning(out); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/CopiedFile.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/CopiedFile.java deleted file mode 100644 index 7061b86be92..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/CopiedFile.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.classes; - -import java.io.*; - -public class CopiedFile extends OutputFile { - final File sourceFile; - - public CopiedFile(final File sourceFile, final String pkg, final String filename) { - super(pkg, filename); - this.sourceFile = sourceFile; - } - - @Override - public void write(final File parentDir) { - try { - final PrintStream out = open(parentDir); - final InputStream in = new FileInputStream(sourceFile); - - copy(in, out); - close(out); - } catch (final IOException e) { throw new RuntimeException(e); } - } - - private static void copy(final InputStream in, final PrintStream out) throws IOException { - int bit; - while (-1 != (bit = in.read())) { - out.write(bit); - } - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/FrameworkClassFile.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/FrameworkClassFile.java deleted file mode 100644 index aade30f05fe..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/FrameworkClassFile.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.classes; - -import java.io.File; -import java.io.PrintStream; -import java.util.ArrayList; -import java.util.List; -import java.util.TreeSet; - -import com.apple.internal.jobjc.generator.FunctionGenerator; -import com.apple.internal.jobjc.generator.Utils; -import com.apple.internal.jobjc.generator.model.Category; -import com.apple.internal.jobjc.generator.model.Clazz; -import com.apple.internal.jobjc.generator.model.Constant; -import com.apple.internal.jobjc.generator.model.Framework; -import com.apple.internal.jobjc.generator.model.Function; -import com.apple.internal.jobjc.generator.model.NativeEnum; -import com.apple.internal.jobjc.generator.model.StringConstant; -import com.apple.internal.jobjc.generator.model.Struct; -import com.apple.internal.jobjc.generator.model.types.JType; -import com.apple.internal.jobjc.generator.model.types.JType.JStruct; -import com.apple.internal.jobjc.generator.utils.Fp; -import com.apple.internal.jobjc.generator.utils.JavaLang; -import com.apple.internal.jobjc.generator.utils.Fp.Map1; -import com.apple.internal.jobjc.generator.utils.JavaLang.JLCall; -import com.apple.internal.jobjc.generator.utils.JavaLang.JLField; -import com.apple.internal.jobjc.generator.utils.JavaLang.JLMethod; -import com.apple.internal.jobjc.generator.utils.JavaLang.JLReturn; -import com.apple.jobjc.JObjCRuntime; -import com.apple.jobjc.MacOSXFramework; -import com.apple.jobjc.Invoke.FunCall; - -public class FrameworkClassFile extends GeneratedClassFile { - final Framework framework; - - public FrameworkClassFile(final Framework framework) { - super(framework.pkg, framework.name + "Framework", MacOSXFramework.class.getName()); - this.framework = framework; - } - - @Override public void writeBeginning(final PrintStream out) { - List binPaths = Fp.map(new Map1(){ - public String apply(File a) { return "\"" + a.getAbsolutePath() + "\""; }}, - framework.binaries); - out.println(new Utils.Substituter( - "#public " + className + "(" + JObjCRuntime.class.getName() + " runtime) {~" + - "##super(runtime, new String[]{" + Fp.join(", ", binPaths) + "});~" + - "#}~" - )); - } - - @Override public void writeBody(final PrintStream out) { - for(final Struct struct : new ArrayList(framework.structs)){ - out.println("\tpublic " + struct.name + " make" + struct.name + "(){"); - out.println("\t\treturn new " + struct.name + "(getRuntime());"); - out.println("\t}"); - out.println("\tpublic " + struct.name + " make" + struct.name + "(com.apple.jobjc.NativeBuffer base){"); - out.println("\t\treturn new " + struct.name + "(getRuntime(), base);"); - out.println("\t}"); - } - - for(final NativeEnum nenum : framework.enums){ - if(nenum.ignore){ - out.println("\t/**"); - out.println("\t * @deprecated Suggestion: " + nenum.suggestion); - out.println("\t */"); - out.println("\t@Deprecated"); - } - out.println(String.format("\tpublic final %3$s %1$s(){ return %2$s; }", - nenum.name, nenum.valueToString(), nenum.type.getJType().getJavaReturnTypeName())); - } - - for(final Constant konst : framework.constants){ - String cacheName = "_" + konst.name; - final JType jtype = konst.type.getJType(); - final String cast = jtype.getReturnTypeCast() == null ? "" : "(" + jtype.getReturnTypeCast() + ")"; - out.println(); - - out.print(new JLField("private", jtype.getJavaTypeName(), cacheName, jtype.getDefaultReturnValue())); - - JLMethod reader = new JLMethod("public final", jtype.getJavaReturnTypeName(), konst.name); - reader.body.add("if(" + cacheName + " != " + jtype.getDefaultReturnValue() + ") return " + cast + cacheName + ";"); - - String contextName = jtype instanceof JStruct ? "returnValue" : "nativeBuffer"; - - if(jtype instanceof JStruct) - reader.body.add(((JStruct)jtype).createReturnValue()); - else - reader.body.add(jtype.createDeclareBuffer(contextName)); - - reader.body.add("getConstant(\"" + konst.name + "\", " + contextName + ", " + jtype.getCoderDescriptor().getCoderInstanceName() + ".sizeof());"); - - reader.body.add(jtype.createPop(contextName)); - reader.body.add(cacheName + " = returnValue;"); - reader.body.add(jtype.createReturn()); - - out.print(reader); - } - - for(final StringConstant konst : framework.stringConstants){ - if(Fp.any(new Map1(){ public Boolean apply(Constant a) { - return a.name.equals(konst.name); - }}, new ArrayList(framework.constants))){ - System.out.println("Warning: [" + framework.name + "] String constant " + konst.name + " is already defined in constants. Skipping."); - } - else{ - out.println("\tpublic final String " + konst.name + "(){ return \"" + escapeQuotes(konst.value) + "\"; }"); - } - } - - /** - * Order classes to get stable output - */ - TreeSet sortedClasses = new TreeSet(framework.classes); - for (final Clazz clazz : sortedClasses) { - final String classClassName = clazz.name + "Class"; - out.println(JavaLang.makeSingleton("_" + classClassName, clazz.name, classClassName, "getRuntime()")); - } - - for (final Category cat : framework.categories) { - final String classClassName = cat.category.name + "Class"; - out.println(JavaLang.makeSingleton("_" + classClassName, cat.category.name, classClassName, "getRuntime()")); - - JLMethod jlm = new JLMethod("public", cat.category.name, cat.category.name, "final " + cat.category.superClass.getFullPath() + " obj"); - jlm.body.add(new JLReturn(new JLCall("new " + cat.category.name, "obj", "getRuntime()"))); - out.println(jlm); - } - - for (final Function fxn : framework.functions){ - FunctionGenerator.writeOutFunction(out, FunCall.class, fxn, null); - } - } - - private String escapeQuotes(String s){ - return s.replace("\"", "\\\""); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/GeneratedClassFile.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/GeneratedClassFile.java deleted file mode 100644 index 0098d4d442c..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/GeneratedClassFile.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.classes; - -import java.io.File; -import java.io.IOException; -import java.io.PrintStream; - -public class GeneratedClassFile extends OutputFile { - protected final String className; - protected final String genericArgs; - protected final String superClass; - - public GeneratedClassFile(final String pkg, final String classname, final String superClass) { - this(pkg, classname, null, superClass); - } - - public GeneratedClassFile(final String pkg, final String classname, final String genericArgs, final String superClass) { - super(pkg, classname + ".java"); - this.className = classname; - this.genericArgs = genericArgs; - this.superClass = superClass; - } - - @Override - public void write(final File parentDir) { - try { - final PrintStream out = open(parentDir); - out.println("package " + pkg + ";"); - out.println(); - out.print("public " + (isFinal() ? "final" : "") + " class " + className); - if(genericArgs != null) out.print("<" + genericArgs + ">"); - if (superClass != null) out.print(" extends " + superClass); - out.println(" {"); - writeBeginning(out); - writeBody(out); - writeEnd(out); - out.println("}"); - close(out); - } catch (final IOException e) { throw new RuntimeException(e); } - } - - public void writeBeginning(final PrintStream out) { - - } - - public void writeBody(final PrintStream out) { - - } - - public void writeEnd(final PrintStream out) { - - } - - protected boolean isFinal(){ return false; } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/JObjCClassClassFile.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/JObjCClassClassFile.java deleted file mode 100644 index a22bb5b5fa3..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/JObjCClassClassFile.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.classes; - -import java.io.PrintStream; -import java.util.HashSet; -import java.util.Set; - -import com.apple.internal.jobjc.generator.ClassGenerator; -import com.apple.internal.jobjc.generator.FunctionGenerator; -import com.apple.internal.jobjc.generator.model.Clazz; -import com.apple.internal.jobjc.generator.model.Method; -import com.apple.jobjc.JObjCRuntime; -import com.apple.jobjc.Invoke.MsgSend; - -public class JObjCClassClassFile extends AbstractObjCClassFile { - public JObjCClassClassFile(final Clazz clazz) { - super(clazz, clazz.name + "Class", clazz.superClass != null ? clazz.superClass.getFullPath() + "Class" : ClassGenerator.JOBJC_PACKAGE + ".NSClass<" + clazz.name + ">"); - } - - @Override public void writeBeginning(final PrintStream out) { - out.format( - "\tpublic %1$s(%2$s runtime) {\n" + - "\t\tsuper(runtime);\n" + - "\t}\n", - className, JObjCRuntime.class.getCanonicalName()); - out.format( - "\tpublic %1$s(String name, %2$s runtime) {\n" + - "\t\tsuper(name, runtime);\n" + - "\t}\n", - className, JObjCRuntime.class.getCanonicalName()); - out.format( - "\tpublic %1$s(long ptr, %2$s runtime) {\n" + - "\t\tsuper(ptr, runtime);\n" + - "\t}\n", - className, JObjCRuntime.class.getCanonicalName()); - } - - @Override public void writeBody(final PrintStream out) { - Set written = new HashSet(); - for(final Method method : this.clazz.classMethods) - if(written.add(method.name)) - FunctionGenerator.writeOutFunction(out, MsgSend.class, method, "this"); - else - System.out.format("Duplicate method: %1$s %2$s -%3$s\n", clazz.parent.name, className, method.name); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/JObjCClassFile.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/JObjCClassFile.java deleted file mode 100644 index 276c76b3a97..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/JObjCClassFile.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.classes; - -import java.io.PrintStream; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import java.util.TreeMap; - -import com.apple.internal.jobjc.generator.FunctionGenerator; -import com.apple.internal.jobjc.generator.model.Clazz; -import com.apple.internal.jobjc.generator.model.Method; -import com.apple.jobjc.JObjCRuntime; -import com.apple.jobjc.NativeObjectLifecycleManager; -import com.apple.jobjc.Invoke.MsgSend; - -public class JObjCClassFile extends AbstractObjCClassFile { - public JObjCClassFile(final Clazz clazz) { - super(clazz, clazz.name, - clazz.superClass == null ? "com.apple.jobjc.ID" - : clazz.superClass.getFullPath()); - } - - private static Map nolmForClass = - new TreeMap(); - static{ - nolmForClass.put("NSAutoreleasePool", NativeObjectLifecycleManager.Nothing.INST); - } - - @Override public void writeBeginning(final PrintStream out) { - out.format("\tpublic %1$s(final long objPtr, final %2$s runtime) {\n" + - "\t\tsuper(objPtr, runtime);\n" + - "\t}\n", - className, JObjCRuntime.class.getCanonicalName()); - - out.format("\tpublic %1$s(final %1$s obj, final %2$s runtime) {\n" + - "\t\tsuper(obj, runtime);\n" + - "\t}\n", - className, JObjCRuntime.class.getCanonicalName()); - - NativeObjectLifecycleManager nolm = nolmForClass.get(clazz.name); - if(nolm != null) - out.format("\t@Override\n"+ - "\tprotected %1$s getNativeObjectLifecycleManager() {\n" + - "\t\treturn %2$s.INST;\n" + - "\t}\n", - NativeObjectLifecycleManager.class.getCanonicalName(), nolm.getClass().getCanonicalName()); - } - - @Override public void writeBody(final PrintStream out) { - Set written = new HashSet(); - for(final Method method : this.clazz.instanceMethods) - if(written.add(method.name)) - FunctionGenerator.writeOutFunction(out, MsgSend.class, method, "this"); - else - System.out.format("Duplicate method: %1$s %2$s -%3$s\n", clazz.parent.name, className, method.name); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/MixedPrimitiveCoderClassFile.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/MixedPrimitiveCoderClassFile.java deleted file mode 100644 index ea28298bc48..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/MixedPrimitiveCoderClassFile.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.classes; - -import java.io.PrintStream; -import java.util.Collection; - -import com.apple.internal.jobjc.generator.ClassGenerator; -import com.apple.internal.jobjc.generator.model.coders.ComplexCoderDescriptor.MixedEncodingDescriptor; -import com.apple.jobjc.PrimitiveCoder; - -public class MixedPrimitiveCoderClassFile extends GeneratedClassFile { - private static final String MULTI_CODER_CLASSNAME = "MixedPrimitiveCoder"; - public static final String FULL_MULTI_CODER_CLASSNAME = ClassGenerator.JOBJC_PACKAGE + "." + MULTI_CODER_CLASSNAME; - - final Collection coderDescs; - - public MixedPrimitiveCoderClassFile(final Collection coderDescs) { - super(ClassGenerator.JOBJC_PACKAGE, MULTI_CODER_CLASSNAME, "java.lang.Object"); - this.coderDescs = coderDescs; - } - - @Override - public void writeBody(final PrintStream out) { - for (final MixedEncodingDescriptor desc : coderDescs) { - out.println("\tpublic static final " + PrimitiveCoder.class.getCanonicalName() + " " + desc.getMixedName() + " = " + desc.getDefinition() + ";"); - } - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/OpaqueClassFile.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/OpaqueClassFile.java deleted file mode 100644 index c7fa5d7f131..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/OpaqueClassFile.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.classes; - -import java.io.PrintStream; - -import com.apple.internal.jobjc.generator.model.Opaque; -import com.apple.jobjc.Pointer; - -public class OpaqueClassFile extends GeneratedClassFile { - final Opaque opaque; - - public OpaqueClassFile(final Opaque opaque) { - super(opaque.parent.pkg, opaque.type.getJType().getJavaClassName(), com.apple.jobjc.Opaque.class.getCanonicalName()); - this.opaque = opaque; - } - - @Override public void writeBeginning(PrintStream out){ - out.println("\t// " + opaque.type); - out.println("\t// " + opaque.type.getJType()); - out.println(""); - out.println("\tpublic " + className + "(" + Pointer.class.getName() + " ptr){"); - out.println("\t\tsuper(ptr);"); - out.println("\t}"); - out.println(""); - out.println("\tpublic " + className + "(long ptr){"); - out.println("\t\tsuper(ptr);"); - out.println("\t}"); - } - -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/OutputFile.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/OutputFile.java deleted file mode 100644 index 615bb24acfa..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/OutputFile.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.classes; - -import java.io.*; - -public abstract class OutputFile { - final String pkg; - final String fileName; - - public OutputFile(final String pkg, final String filename) { - this.pkg = pkg; - this.fileName = filename; - } - - public PrintStream open(final File parentDir) throws IOException { - final File pkgDir = new File(parentDir, pkg.replace('.', '/')); - pkgDir.mkdirs(); - final File classFile = new File(pkgDir, fileName); - classFile.createNewFile(); - return new PrintStream(classFile); - } - - public void close(final PrintStream out) { - out.close(); - } - - public abstract void write(final File parentDir); - - public boolean isClass(final Class clazz) { - final String pkgName = clazz.getPackage().getName(); - if (!pkgName.equals(pkg)) return false; - - return fileName.contains(clazz.getSimpleName()); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/RootJObjCClass.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/RootJObjCClass.java deleted file mode 100644 index a581d1ce2ee..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/RootJObjCClass.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.classes; - -import java.io.PrintStream; -import java.util.List; - -import com.apple.internal.jobjc.generator.ClassGenerator; -import com.apple.internal.jobjc.generator.model.Framework; -import com.apple.internal.jobjc.generator.utils.JavaLang; -import com.apple.internal.jobjc.generator.utils.JavaLang.JLCtor; -import com.apple.internal.jobjc.generator.utils.JavaLang.JLField; -import com.apple.internal.jobjc.generator.utils.JavaLang.JLMethod; -import com.apple.jobjc.JObjCRuntime; - -public class RootJObjCClass extends GeneratedClassFile { - private static final String JOBJC_CLASSNAME = "JObjC"; - public static final String FULL_JOBJC_CLASSNAME = ClassGenerator.JOBJC_PACKAGE + "." + JOBJC_CLASSNAME; - public static final String JOBJC_RUNTIME_INST = FULL_JOBJC_CLASSNAME + ".getInstance()"; - public static final String JOBJC_RUNTIME_INST_R = FULL_JOBJC_CLASSNAME + ".getInstance(getRuntime())"; - - public static final String runtimeFrameworkInst(String fwname){ - return JOBJC_RUNTIME_INST + "." + fwname + "()"; - } - - public static final String runtimeFrameworkInstR(String fwname){ - return JOBJC_RUNTIME_INST_R + "." + fwname + "()"; - } - - final List frameworks; - - public RootJObjCClass(final List frameworks) { - super(ClassGenerator.JOBJC_PACKAGE, JOBJC_CLASSNAME, "java.lang.Object"); - this.frameworks = frameworks; - } - - @Override public void writeBeginning(final PrintStream out) { - out.print(new JLField("private static", JOBJC_CLASSNAME, "instance")); - out.print(new JLField("private final", JObjCRuntime.class.getName(), "runtime")); - - JLMethod getInstR = new JLMethod("public static", JOBJC_CLASSNAME, "getInstance", "final JObjCRuntime runtime"); - getInstR.body.add("if(runtime == null) throw new NullPointerException(\"runtime\");"); - getInstR.body.add("if(instance == null) instance = new JObjC(runtime);"); - getInstR.body.add("return instance;"); - out.print(getInstR); - - JLMethod getInst = new JLMethod("public static", JOBJC_CLASSNAME, "getInstance"); - getInst.body.add("return getInstance(JObjCRuntime.getInstance());"); - out.print(getInst); - - JLCtor ctor = new JLCtor("private", JOBJC_CLASSNAME, "final JObjCRuntime runtime"); - ctor.body.add("this.runtime = runtime;"); - for (final Framework f : frameworks) - ctor.body.add("runtime.registerPackage(\"" + f.pkg + "\");"); - out.print(ctor); - } - - @Override public void writeBody(final PrintStream out) { - for (final Framework f : frameworks) - out.println(JavaLang.makeSingleton("_" + f.name, f.name, f.pkg + "." + f.name + "Framework", "runtime")); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/StructClassFile.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/StructClassFile.java deleted file mode 100644 index 597d30a5818..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/StructClassFile.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.classes; - -import java.io.PrintStream; - -import com.apple.internal.jobjc.generator.model.Struct; -import com.apple.internal.jobjc.generator.model.Struct.Field; -import com.apple.internal.jobjc.generator.model.coders.CoderDescriptor; -import com.apple.internal.jobjc.generator.model.types.JType; -import com.apple.internal.jobjc.generator.model.types.JType.JStruct; -import com.apple.internal.jobjc.generator.model.types.NType.NBitfield; -import com.apple.internal.jobjc.generator.model.types.NType.NStruct; -import com.apple.internal.jobjc.generator.utils.Fp; -import com.apple.internal.jobjc.generator.utils.Fp.Map1; -import com.apple.jobjc.JObjCRuntime; -import com.apple.jobjc.Coder.StructCoder; - -public class StructClassFile extends GeneratedClassFile { - final Struct struct; - - public StructClassFile(final Struct struct) { - super(struct.parent.pkg, struct.name, com.apple.jobjc.Struct.class.getName()); - this.struct = struct; - } - - @Override public boolean isFinal(){ return true; } - - @Override public void writeBeginning(final PrintStream out) { - out.println(); - out.println("\tpublic static int SIZEOF = " + JObjCRuntime.class.getName() + ".IS64 ? " - + ((NStruct) struct.type.type64).sizeof64() + " : " + ((NStruct) struct.type.type32).sizeof32() + ";"); - out.println(); - out.format("\tpublic final static %1$s getStructCoder(){ return coder; }\n", StructCoder.class.getCanonicalName()); - out.format("\t@Override public final %1$s getCoder(){ return coder; }\n", StructCoder.class.getCanonicalName()); - out.format("\tprivate final static %1$s coder = new %1$s(SIZEOF%2$s%3$s){\n", StructCoder.class.getCanonicalName(), - (struct.fields.size() > 0 ? ",\n\t\t" : ""), - Fp.join(",\n\t\t", Fp.map(new Map1(){ - public String apply(Field a) { - return a.type.getJType().getCoderDescriptor().getCoderInstanceName(); - }}, struct.fields))); - out.format("\t\t@Override protected %1$s newInstance(%2$s runtime){ return new %1$s(runtime); }\n", - struct.name, - JObjCRuntime.class.getCanonicalName()); - out.println("\t};"); - out.println(); - out.println("\t" + struct.name + "(final " + JObjCRuntime.class.getCanonicalName() + " runtime){"); - out.println("\t\tsuper(runtime, SIZEOF);"); - out.println("\t}"); - out.println(); - out.println("\tpublic " + struct.name + "(final " + JObjCRuntime.class.getCanonicalName() + " runtime, final com.apple.jobjc.NativeBuffer buffer) {"); - out.println("\t\tsuper(runtime, buffer, SIZEOF);"); - out.println("\t}"); - } - - @Override public void writeBody(final PrintStream out) { - for(Struct.Field field : struct.fields){ - if(field.type.type64 instanceof NStruct && field.type.type32 instanceof NStruct) - writeStructField(field, out); - else - writeField(field, out); - } - } - - private void writeField(final Struct.Field field, final PrintStream out){ - if(field.type.type32 instanceof NBitfield){ - out.format("\t// Skipping bitfield '%1$s'\n", field.name); - return; - } - String privName = field.name + "__"; - String offsetName = field.name.toUpperCase() + "_OFFSET"; - JType jtype = field.type.getJType(); - String retType = jtype.getJavaReturnTypeName(); - CoderDescriptor cdesc = jtype.getCoderDescriptor(); - out.println(); - out.println("\tprivate static final int " + offsetName + " = " + JObjCRuntime.class.getName() - + ".IS64 ? " + field.field64.offset64() + " : " + field.field32.offset32() + ";"); - - out.println("\t//" + cdesc.getClass().toString()); - out.println("\tpublic " + retType + " " + getterName(field) + "(){"); - out.println(jtype.createPopAddr("getRuntime()", "this.raw.bufferPtr + " + offsetName)); - out.println(jtype.createReturn()); - out.println("\t}"); - out.println(); - out.println("\tpublic void " + setterName(field.name) + "(final " + retType + " " + privName + "){"); - out.println("\t\t" + cdesc.getPushAddrStatementFor("getRuntime()", "this.raw.bufferPtr + " + offsetName, privName)); - out.println("\t}"); - } - - private void writeStructField(final Struct.Field field, final PrintStream out){ - if(field.type.getJType() == null || !(field.type.getJType() instanceof JStruct)){ - out.println("\t// Found bad JavaType (" + field.type.getJType() + ") for field (" + field.name + ") of type (" + field.type + ")"); - return; - } - String privName = field.name + "__"; - String offsetName = field.name.toUpperCase() + "_OFFSET"; - JStruct jstype = (JStruct) field.type.getJType(); - String retTypeName = jstype.getJavaReturnTypeName(); - out.println(); - out.println("\tprivate static final int " + offsetName + " = " + JObjCRuntime.class.getName() + ".IS64" - + " ? " + field.field64.offset64() + " : " + field.field32.offset32() + ";"); - - out.println("\tprivate " + retTypeName + " " + privName + " = null;"); - out.println("\tpublic " + retTypeName + " " + getterName(field) + "(){"); - out.println("\t\tif(null==" + privName + "){"); - out.println("\t\t\tthis.raw.position(" + offsetName + ");"); - out.println("\t\t\t" + privName + " = " + RootJObjCClass.runtimeFrameworkInstR(struct.parent.name) + ".make" + jstype.struct.name + "(this.raw.slice());"); - out.println("\t\t}"); - out.println("\t\treturn " + privName + ";"); - out.println("\t}"); - } - - private String getterName(Struct.Field field) { - if(com.apple.internal.jobjc.generator.RestrictedKeywords.isRestricted(field.name)) - return field.name + field.type.getJType().getAppendableDescription(); - return field.name; - } - - private String setterName(String name) { - return "set" + name.substring(0, 1).toUpperCase() + name.substring(1); - } - - @Override public void writeEnd(final PrintStream out) { - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Arg.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Arg.java deleted file mode 100644 index ce296352c66..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Arg.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.model; - -import org.w3c.dom.Node; - -public class Arg extends ElementWType{ - public String javaName; - - public Arg(final Node node, final Function parent) { - super(node, parent); - javaName = name; - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/CFType.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/CFType.java deleted file mode 100644 index d71eec5fe8a..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/CFType.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.model; - -import java.util.List; - -import org.w3c.dom.Node; - -import com.apple.internal.jobjc.generator.classes.CFTypeClassFile; -import com.apple.internal.jobjc.generator.classes.OutputFile; - -public class CFType extends TypeElement implements OutputFileGenerator { - public final String getTypeIdFunc; - public final String tollfree; - - public CFType(final Node node, final Framework parent) { - super(node, getAttr(node, "name"), parent); - getTypeIdFunc = getAttr(node, "gettypeid_func"); - tollfree = getAttr(node, "tollfree"); - } - - public void generateClasses(final List generatedClassFiles) { - generatedClassFiles.add(new CFTypeClassFile(this)); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Category.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Category.java deleted file mode 100644 index 8bd50646992..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Category.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.model; - -import java.util.List; - -import com.apple.internal.jobjc.generator.classes.CategoryClassClassFile; -import com.apple.internal.jobjc.generator.classes.CategoryClassFile; -import com.apple.internal.jobjc.generator.classes.OutputFile; - -public class Category implements OutputFileGenerator{ - public final Clazz category; - - public Category(Clazz fromClass, Clazz target) { - this.category = new Clazz(fromClass.name + "Category", fromClass.classMethods, fromClass.instanceMethods, target, fromClass.parent); - } - - public void generateClasses(List generatedClassFiles) { - generatedClassFiles.add(new CategoryClassFile(this)); - generatedClassFiles.add(new CategoryClassClassFile(this)); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Clazz.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Clazz.java deleted file mode 100644 index 3571974ccdb..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Clazz.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.model; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -import com.apple.internal.jobjc.generator.RestrictedKeywords; -import com.apple.internal.jobjc.generator.classes.JObjCClassClassFile; -import com.apple.internal.jobjc.generator.classes.JObjCClassFile; -import com.apple.internal.jobjc.generator.classes.OutputFile; -import com.apple.jobjc.MacOSXFramework; -import com.apple.jobjc.SuperClassExtractor; -import com.apple.jobjc.UnsafeRuntimeAccess; -import com.apple.jobjc.NSClass.NSClassNotFoundException; -import com.apple.jobjc.SEL; - -public class Clazz extends Element implements OutputFileGenerator { - private final Map instanceMethodsByName = new HashMap(); - private final Map classMethodsByName = new HashMap(); - - public final List classMethods; - public final List instanceMethods; - - public final List subClassers = new ArrayList(0); - public Clazz superClass; - - public Clazz(String name, List classMethods, List instanceMethods, Clazz superClass, Framework parent){ - super(name, parent); - this.classMethods = classMethods; - this.instanceMethods = instanceMethods; - this.superClass = superClass; - } - - public Clazz(final Node classNode, final Framework parent) { - super(classNode, parent); - this.classMethods = new ArrayList(); - this.instanceMethods = new ArrayList(); - - final NodeList methodNodes = classNode.getChildNodes(); - for (int i = 0; i < methodNodes.getLength(); i++) { - final Node node = methodNodes.item(i); - if (!"method".equals(node.getLocalName())) continue; - - final String selName = Element.getAttr(node, "selector"); - if(selName == null || !SEL.validName(selName)){ - System.err.format("Warning: Discarding method %1$s:%2$s:%3$s" - + " -- Invalid selector name. Verify.\n", - parent.name, name, selName); - continue; - } - - final Method method = new Method(node, parent); - if (method.isClassMethod) { - classMethods.add(method); - } else { - instanceMethods.add(method); - } - } - } - - public String getPackage() { - return parent.pkg; - } - - public String getFullPath(){ - return parent.pkg + "." + name; - } - - @Override - public String toString() { - return super.toString() + " " + classMethods + " " + instanceMethods; - } - - public boolean doesActuallyExist(){ - try{ - UnsafeRuntimeAccess.getNSClass(parent.load(), name); - }catch(NSClassNotFoundException x){ - return false; - } - return true; - } - - void resolveSuperClass(final MacOSXFramework nativeFramework, final Map allClasses) throws Throwable { - superClass = SuperClassExtractor.getSuperClassFor(name, nativeFramework, allClasses); - } - - public void disambiguateMethods() { - disambiguateMethods(instanceMethods, instanceMethodsByName); - disambiguateMethods(classMethods, classMethodsByName); - } - - private void disambiguateMethods(final List methods, final Map methodMap) { - final Set existingMethodNames = RestrictedKeywords.getNewRestrictedSet(); - for (final Method method : methods) { - method.disambiguateNameAndArgs(this, existingMethodNames); - methodMap.put(method.javaName, method); - } - } - - public void generateClasses(final List generatedClassFiles) { - generatedClassFiles.add(new JObjCClassClassFile(this)); - generatedClassFiles.add(new JObjCClassFile(this)); - } - - Method getParentMethodMatchingName(final String methodName) { - if(superClass == null) return null; - Method m = superClass.getMethodNamed(methodName); - if(m != null) return m; - return superClass.getParentMethodMatchingName(methodName); - } - - private Method getMethodNamed(final String methodName) { - final Method instanceMethod = instanceMethodsByName.get(methodName); - if (instanceMethod != null) return instanceMethod; - - final Method classMethod = classMethodsByName.get(methodName); - if (classMethod != null) return classMethod; - - return null; - } - - int compareTo(Clazz o) { - return toString().compareTo(o.toString()); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Constant.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Constant.java deleted file mode 100644 index b5c0b627649..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Constant.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.model; - -import org.w3c.dom.Node; - -public class Constant extends ElementWType { - public Constant(final Node node, final Framework parent) { - super(node, parent); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Element.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Element.java deleted file mode 100644 index 47fff332e6b..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Element.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.model; - -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.List; - -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -import com.apple.internal.jobjc.generator.model.types.Type; -import com.apple.internal.jobjc.generator.utils.ObjectInspector; - -/** - * Subclasses must implement ctor(Node, P) - */ -public class Element

> implements Comparable>{ - public final String name; - public final P parent; - - public Element(final String name, final P parent) { - this.name = Type.cleanName(name); - this.parent = parent; - } - - public Element(final Node node, final P parent) { - this(getAttr(node, "name"), parent); - } - - public static String getAttr(final Node node, final String key) { - final NamedNodeMap attrs = node.getAttributes(); - if (attrs == null) return null; - final Node name = attrs.getNamedItem(key); - if (name == null) return null; - return name.getNodeValue(); - } - - static

, T extends Element

> List getNodesFor(final Node parentNode, final String selection, final Class clazz, final P parent) { - Constructor ctor; - try { - ctor = clazz.getConstructor(new Class[] { Node.class, parent.getClass() }); - } catch (Exception e) { - throw new RuntimeException(e); - } - - final NodeList childNodes = parentNode.getChildNodes(); - final List nodes = new ArrayList(); - for (int i = 0; i < childNodes.getLength(); i++) { - final Node node = childNodes.item(i); - if (!selection.equals(node.getLocalName())) continue; - - T obj; - try { - obj = ctor.newInstance(new Object[] { node, parent }); - } catch (InvocationTargetException e) { - throw new RuntimeException(e.getCause()); - } catch (Exception e) { - throw new RuntimeException(e); - } - nodes.add(obj); - } - - return nodes; - } - - @Override public String toString() { - return name; - } - - public String reflectOnMySelf() { - return ObjectInspector.inspect(this); - } - - public int compareTo(Element o) { - return name.compareTo(o.name); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/ElementWType.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/ElementWType.java deleted file mode 100644 index 8bb31b9449e..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/ElementWType.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.model; - -import com.apple.internal.jobjc.generator.model.types.NType; -import org.w3c.dom.Node; - -import com.apple.internal.jobjc.generator.model.types.Type; -import com.apple.internal.jobjc.generator.utils.NTypeParser; - -/** - * An ElementWType has a type but does not necessarily represent a type. Examples are constants, enums, arguments, return values. - */ -public class ElementWType

> extends Element

{ - public final Type type; - - public ElementWType(final String name, final Type t, final P parent) { - super(name, parent); - this.type = t; - } - - public ElementWType(final Node node, final Type t, final P parent) { - super(node, parent); - this.type = t; - } - - public ElementWType(final Node node, final String declType, final P parent) { - super(node, parent); - final String type32 = getAttr(node, "type"); - final String type64 = getAttr(node, "type64"); - this.type = Type.getType(declType, - type32 == null ? NType.NUnknown.inst() : NTypeParser.parseFrom(type32), - type64 == null ? null : NTypeParser.parseFrom(type64)); - } - - public ElementWType(final Node node, final P parent){ - this(node, getAttr(node, "declared_type"), parent); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Framework.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Framework.java deleted file mode 100644 index a63be7d4106..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Framework.java +++ /dev/null @@ -1,209 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.model; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.xml.xpath.XPath; -import javax.xml.xpath.XPathConstants; -import javax.xml.xpath.XPathExpressionException; -import javax.xml.xpath.XPathFactory; - -import org.w3c.dom.Node; -import org.xml.sax.InputSource; - -import com.apple.internal.jobjc.generator.ClassGenerator; -import com.apple.internal.jobjc.generator.Utils; -import com.apple.internal.jobjc.generator.classes.FrameworkClassFile; -import com.apple.internal.jobjc.generator.classes.OutputFile; -import com.apple.internal.jobjc.generator.utils.Fp; -import com.apple.internal.jobjc.generator.utils.Fp.Map1; -import com.apple.jobjc.MacOSXFramework; -import com.apple.jobjc.UnsafeRuntimeAccess; - -public class Framework extends Element> implements OutputFileGenerator { - public final String path; - public final String pkg; - public final List binaries; - public MacOSXFramework nativeFramework; - - public MacOSXFramework load(){ - if(nativeFramework == null){ - String[] bins = new String[binaries.size()]; - for(int i = 0; i < binaries.size(); ++i) - bins[i] = Utils.getCanonicalPath(binaries.get(i)); - nativeFramework = UnsafeRuntimeAccess.getFramework(bins); - } - return nativeFramework; - } - - public File getMainFrameworkBinary(){ return binaries.get(0); } - - final Node rootNode; - - public Set classes; - public List structs; - public List cfTypes; - public List opaques; - public List constants; - public List stringConstants; - public List enums; - public List functions; - public List functionAliases; - public List informalProtocols; - public List protocols; - public List categories; - public List dependencies; - - public static class FrameworkDependency extends Element{ - final String path; - public Framework object = null; - - public FrameworkDependency(final Node node, final Framework parent) { - super(getAttr(node, "path").replaceFirst("^.*/([^/]+)\\.framework$", "$1"), parent); - this.path = getAttr(node, "path"); - } - } - - public static final XPath XPATH = XPathFactory.newInstance().newXPath(); - public Framework(final String name, final File bsFile) { - super(name, null); - try { - final File pathf = bsFile.getCanonicalFile().getParentFile().getParentFile().getParentFile(); - path = pathf.getParentFile().getParentFile().getCanonicalPath(); - } catch (IOException x) { - throw new RuntimeException(x); - } - binaries = findBinaries(path, name); - - pkg = ClassGenerator.JOBJC_PACKAGE + "." + name.toLowerCase(); - try { - rootNode = (Node)XPATH.evaluate("signatures", new InputSource(bsFile.getAbsolutePath()), XPathConstants.NODE); - } catch (final XPathExpressionException e) { throw new RuntimeException(e); } - protocols = new ArrayList(); - categories = new ArrayList(); - } - - private static List findBinaries(final String rootPath, final String name){ - List bins = new ArrayList(2); - - File mainBin = new File(rootPath, name); - if(mainBin.exists()) bins.add(mainBin); - - File bsBin = new File(rootPath, "Resources/BridgeSupport/" + name + ".dylib"); - if(bsBin.exists()) bins.add(bsBin); - - return bins; - } - - public void parseDependencies(final Collection frameworks) { - // Parse - dependencies = getNodesFor(rootNode, "depends_on", FrameworkDependency.class, this); - // Resolve - for(final FrameworkDependency dep : dependencies) - dep.object = Fp.find(new Map1(){ - public Boolean apply(Framework f) { - return f.path.equals(dep.path); - }}, frameworks); - } - - public void parseStructs() { - structs = getNodesFor(rootNode, "struct", Struct.class, this); - - // HACK BS bug #6100313 - if(Utils.isSnowLeopard && name.equals("IOBluetooth")) - structs.remove(getStructByName("BluetoothHCIRequestNotificationInfo")); - - // GLIFunctionDispatch is frequently out of sync in BS / system - if(name.equals("OpenGL")) - structs.remove(getStructByName("GLIFunctionDispatch")); - } - - public void parseCFTypes() { - cfTypes = getNodesFor(rootNode, "cftype", CFType.class, this); - } - - public void parseOpaques() { - opaques = getNodesFor(rootNode, "opaque", Opaque.class, this); - } - - public void parseConstants() { - constants = getNodesFor(rootNode, "constant", Constant.class, this); - stringConstants = getNodesFor(rootNode, "string_constant", StringConstant.class, this); - enums = getNodesFor(rootNode, "enum", NativeEnum.class, this); - } - - public void parseFunctions() { - functions = getNodesFor(rootNode, "function", Function.class, this); - functionAliases = getNodesFor(rootNode, "function_alias", FunctionAlias.class, this); - } - - public void parseClasses() { - classes = new HashSet(getNodesFor(rootNode, "class", Clazz.class, this)); - classes = Fp.filterSet(new Map1(){ - public Boolean apply(Clazz a) { - if(a.doesActuallyExist()) - return true; - else{ - System.out.println("Could not find class " + name + ":" + a.name + " in runtime. Discarding."); - return false; - } - }}, classes); - informalProtocols = getNodesFor(rootNode, "informal_protocol", InformalProtocol.class, this); - } - - public void resolveSuperClasses(final Map allClasses) throws Throwable { - load(); - for (final Clazz clazz : classes) - clazz.resolveSuperClass(nativeFramework, allClasses); - } - - public void generateClasses(final List generatedClassFiles) { - generatedClassFiles.add(new FrameworkClassFile(this)); - - final List> generatorLists = - Utils.list(new ArrayList(classes), structs, cfTypes, opaques, categories); - for (final List generators : generatorLists) { - for (final OutputFileGenerator generator : generators) - generator.generateClasses(generatedClassFiles); - } - } - - @Override public String toString() { return reflectOnMySelf(); } - - public Struct getStructByName(final String stname) { - return Fp.find(new Fp.Map1(){ - public Boolean apply(Struct a) { - return stname.equals(a.name); - }}, structs); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Function.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Function.java deleted file mode 100644 index c08d99925e9..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Function.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.model; - -import java.util.*; - -import org.w3c.dom.*; - -import com.apple.internal.jobjc.generator.RestrictedKeywords; - -public class Function extends Element { - public final boolean variadic; - public final List args; - public final ReturnValue returnValue; - - public Function(final Node node, final Framework parent) { - this(node, getAttr(node, "name"), parent); - } - - public Function(final Node node, final String name, final Framework parent) { - super(name, parent); - - this.variadic = "true".equals(getAttr(node, "variadic")); - this.args = new ArrayList(); - - ReturnValue returnValue = null; - - final NodeList children = node.getChildNodes(); - for (int i = 0; i < children.getLength(); i++) { - final Node child = children.item(i); - final String childName = child.getLocalName(); - - if ("retval".equals(childName)) { - returnValue = new ReturnValue(child, this); - } - - if ("arg".equals(childName)) { - final Arg arg = new Arg(child, this); - if (arg.name == null || "".equals(arg.name)) { - arg.javaName = "arg" + i; - } - args.add(arg); - } - } - - if (returnValue == null) returnValue = ReturnValue.VOID; - this.returnValue = returnValue; - } - - public String getJavaName(){ return name; } - - public void disambiguateArgs() { - final Set priorArgs = RestrictedKeywords.getNewRestrictedSet(); - for (int i = 0; i < args.size(); i++) { - final Arg arg = args.get(i); - if (priorArgs.contains(arg.name)) arg.javaName = arg.javaName + i; - priorArgs.add(arg.javaName); - } - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/FunctionAlias.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/FunctionAlias.java deleted file mode 100644 index 641d5b5c92d..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/FunctionAlias.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.model; - -import org.w3c.dom.Node; - -public class FunctionAlias extends Element { - public FunctionAlias(final Node node, final Framework parent) { - super(node, parent); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/InformalProtocol.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/InformalProtocol.java deleted file mode 100644 index 8213e7d1b2c..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/InformalProtocol.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.model; - -import org.w3c.dom.Node; - -public class InformalProtocol extends Element { - public InformalProtocol(final Node node, final Framework parent) { - super(node, parent); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Method.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Method.java deleted file mode 100644 index a1099078a4d..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Method.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.model; - -import java.util.Set; -import org.w3c.dom.Node; -import com.apple.jobjc.SEL; -import com.apple.internal.jobjc.generator.Utils; - -public class Method extends Function { - public final boolean isClassMethod; - - public String javaName; - - public boolean ignore; - public String suggestion; - - public Method(final Node node, final Framework fw) { - super(node, getAttr(node, "selector"), fw); - this.javaName = SEL.jMethodName(name); - this.isClassMethod = "true".equals(getAttr(node, "class_method")); - this.ignore = "true".equals(getAttr(node, "ignore")); - this.suggestion = getAttr(node, "suggestion"); - } - - @Override public String getJavaName(){ return javaName; } - - @Override public String toString() { - return returnValue + " " + super.toString() + args; - } - - public boolean returnTypeEquals(final ReturnValue returnValueIn) { - return returnValue.type.getJType().getJavaReturnTypeName().equals(returnValueIn.type.getJType().getJavaReturnTypeName()); - } - - public void disambiguateNameAndArgs(final Clazz parentClazz, final Set existingMethodNames) { - javaName = getDisambiguatedNameFor(parentClazz, javaName, existingMethodNames); - disambiguateArgs(); - } - - private String getDisambiguatedNameFor(final Clazz parentClazz, final String proposedName, final Set existingNames) { - // Does this method override a parent class method and change the return type? Example: IOBlueToothSDPUUID length - { - final Method superClassMethod = parentClazz.getParentMethodMatchingName(proposedName); - if (superClassMethod != null && !superClassMethod.returnValue.equals(returnValue)) { - final String usingReturnType = createMethodNameAppendingReturnType(proposedName); - if(existingNames.add(usingReturnType)) - return usingReturnType; - } - } - - if(existingNames.add(proposedName)) - return proposedName; - - final String usingReturnType = createMethodNameAppendingReturnType(proposedName); - if(existingNames.add(usingReturnType)) - return usingReturnType; - - throw new RuntimeException("Unable to disambiguate method: " + this); - } - - private String createMethodNameAppendingReturnType(final String proposedName) { - return proposedName + Utils.capitalize(returnValue.type.getJType().getAppendableDescription().replaceAll(".+\\.", "")); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/NativeEnum.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/NativeEnum.java deleted file mode 100644 index e6bbd9b0652..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/NativeEnum.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.model; - -import java.util.Arrays; - -import org.w3c.dom.Node; - -import com.apple.internal.jobjc.generator.model.types.Type; -import com.apple.internal.jobjc.generator.model.types.JType.JPrimitive; -import com.apple.internal.jobjc.generator.model.types.NType.NPrimitive; -import com.apple.internal.jobjc.generator.utils.Fp; -import com.apple.jobjc.JObjCRuntime; - -public class NativeEnum extends ElementWType { - public final String value, value64, le_value, be_value; - public boolean ignore; - public String suggestion; - public NativeEnum(final Node node, final Framework parent) { - super(node, typeForEnum(getAttr(node, "name"), - getAttr(node, "value"), getAttr(node, "value64"), - getAttr(node, "le_value"), getAttr(node, "be_value"), - getAttr(node, "ignore")), parent); - this.value = getAttr(node, "value"); - this.value64 = getAttr(node, "value64"); - this.le_value = getAttr(node, "le_value"); - this.be_value = getAttr(node, "be_value"); - String ignoreS = getAttr(node, "ignore"); - this.ignore = ignoreS == null ? false : Boolean.parseBoolean(ignoreS); - this.suggestion = getAttr(node, "suggestion"); - assert valueToString() != null; - } - - private static Type typeForEnum(String name, String value32, String value64, String le_value, String be_value, String ignore){ - if("true".equals(ignore)) return Type.getType(null, NPrimitive.inst('i'), null); - - NumTest[] tests = new NumTest[]{new IntTest(), new LongTest(), new FloatTest(), new DoubleTest()}; - for(NumTest t : tests) - if(t.confirm(value32, value64, le_value, be_value)) - return t.getType(); - - throw new NumberFormatException(String.format("Failed to parse type for enum: %1$s = 32: %2$s / 64: %3$s / le: %4$s / be: %5$s\n", - name, value32, value64, le_value, be_value)); - } - - public String valueToString(){ - if(ignore == true) return "0"; - JPrimitive jprim = (JPrimitive) type.getJType(); - if(le_value == null && be_value == null){ - if(value == null && value64 != null) - return value64 + jprim.getLiteralSuffix(); - else if(value != null && value64 == null) - return value + jprim.getLiteralSuffix(); - else - return String.format("(%1$s.IS64 ? %2$s%4$s : %3$s%4$s)", JObjCRuntime.class.getName(), - value64, value, jprim.getLiteralSuffix()); - } - else if(value == null && value64 == null){ - return String.format("(%1$s.IS_BIG_ENDIAN ? %2$s%4$s : %3$s%4$s)", - JObjCRuntime.class.getName(), be_value, le_value, jprim.getLiteralSuffix()); - } - - throw new RuntimeException("Unable to produce a value for enum " + name); - } - - // Used to find the best type to use for the enum. - - static abstract class NumTest{ - public boolean confirm(String... values){ - return Fp.all(new Fp.Map1(){ - public Boolean apply(String a) { - try{ return a == null || confirm(a); } - catch(Exception x){ return false; } - }}, - Arrays.asList(values)); - } - - public abstract boolean confirm(String v); - public abstract Type getType(); - } - - static class IntTest extends NumTest{ - @Override public boolean confirm(String v) { - Integer.parseInt(v); - return true; - } - - @Override public Type getType() { return Type.getType(null, NPrimitive.inst('i'), null); } - } - - static class LongTest extends NumTest{ - @Override public boolean confirm(String v) { - Long.parseLong(v); - return true; - } - - @Override public Type getType() { return Type.getType(null, NPrimitive.inst('l'), null); } - } - - static class FloatTest extends NumTest{ - @Override public boolean confirm(String v) { - return Float.parseFloat(v) == Double.parseDouble(v); - } - - @Override public Type getType() { return Type.getType(null, NPrimitive.inst('f'), null); } - } - - static class DoubleTest extends NumTest{ - @Override public boolean confirm(String v) { - double d = Double.parseDouble(v); - return !Double.isInfinite(d) && !Double.isNaN(d); - } - - @Override public Type getType() { return Type.getType(null, NPrimitive.inst('d'), null); } - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Opaque.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Opaque.java deleted file mode 100644 index 9cc4317d855..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Opaque.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.model; - -import java.util.List; - -import org.w3c.dom.Node; - -import com.apple.internal.jobjc.generator.classes.OpaqueClassFile; -import com.apple.internal.jobjc.generator.classes.OutputFile; - -public class Opaque extends TypeElement implements OutputFileGenerator { - public Opaque(final Node node, final Framework parent) { - super(node, getAttr(node, "name"), parent); - } - - public void generateClasses(final List generatedClassFiles) { - generatedClassFiles.add(new OpaqueClassFile(this)); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/OutputFileGenerator.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/OutputFileGenerator.java deleted file mode 100644 index ac4b71d4d31..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/OutputFileGenerator.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.model; - -import java.util.List; - -import com.apple.internal.jobjc.generator.classes.OutputFile; - -public interface OutputFileGenerator { - public void generateClasses(final List generatedClassFiles); -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/StringConstant.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/StringConstant.java deleted file mode 100644 index acfbc6ab4a7..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/StringConstant.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.model; - -import org.w3c.dom.Node; - -public class StringConstant extends Element { - public final String value; - - public StringConstant(final Node node, final Framework parent) { - super(node, parent); - this.value = getAttr(node, "value"); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Struct.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Struct.java deleted file mode 100644 index b583cdbf59c..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Struct.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.model; - -import java.util.List; - -import org.w3c.dom.Node; - -import com.apple.internal.jobjc.generator.classes.OutputFile; -import com.apple.internal.jobjc.generator.classes.StructClassFile; -import com.apple.internal.jobjc.generator.model.types.Type; -import com.apple.internal.jobjc.generator.model.types.NType.NField; -import com.apple.internal.jobjc.generator.model.types.NType.NStruct; -import com.apple.internal.jobjc.generator.utils.Fp; -import com.apple.internal.jobjc.generator.utils.QA; -import com.apple.internal.jobjc.generator.utils.Fp.Map2; - -/** - * A struct has the following restrictions: - * - * - type32.fields.count == type64.fields.count - * - forAll i: type32.field[i].name == type64.field[i].name - * - forAll i: type32.field[i].class == type64.field[i].class - */ -public class Struct extends TypeElement implements OutputFileGenerator { - public final List fields; - public static class Field{ - public final String name; - public final Type type; - public final NField field32, field64; - public Field(String name, NField field32, NField field64) { - QA.nonNull(name); - this.name = name; - // TODO really should have a declared_type attr. See if BS patch is possible. - this.type = Type.getType(null, field32.type, field64.type); - this.field32 = field32; - this.field64 = field64; - } - } - - public Struct(final Node node, final Framework parent) throws Throwable { - super(node, getAttr(node, "name"), parent); - NStruct nstruct32 = (NStruct) type.type32; - NStruct nstruct64 = (NStruct) type.type64; - this.fields = Fp.map2(new Map2(){ - public Field apply(NField f32, NField f64) { - assert f32.name.equals(f64.name); - return new Field(f32.name, f32, f64); - } - }, nstruct32.fields, nstruct64.fields); - } - - public void generateClasses(final List generatedClassFiles) { - generatedClassFiles.add(new StructClassFile(this)); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/coders/CoderDescriptor.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/coders/CoderDescriptor.java deleted file mode 100644 index b7a734fa975..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/coders/CoderDescriptor.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.model.coders; - -import com.apple.internal.jobjc.generator.model.types.JType.JStruct; -import com.apple.jobjc.Coder; -import com.apple.jobjc.Coder.IDCoder; -import com.apple.jobjc.Coder.NSClassCoder; -import com.apple.jobjc.Coder.PointerCoder; -import com.apple.jobjc.Coder.PrimitivePointerCoder; -import com.apple.jobjc.Coder.SELCoder; -import com.apple.jobjc.Coder.UnknownCoder; -import com.apple.jobjc.Coder.VoidCoder; - -public class CoderDescriptor { - public static final CoderDescriptor VOID_DESC = new CoderDescriptor(VoidCoder.INST, null, null); - - final Coder coder; - private final String coderInstanceName; - final String pushName; - final String popName; - - public String mismatchMessage(){ return null; } - - public CoderDescriptor(final Coder coder, final String pushName, final String popName) { - this.coder = coder; - this.coderInstanceName = coder.getClass().getCanonicalName() + ".INST"; - if (coderInstanceName == null) throw new NullPointerException(); - - this.pushName = pushName; - this.popName = popName; - } - - public CoderDescriptor(final String pushName, final String popName) { - this.coder = null; - this.coderInstanceName = null; - this.pushName = pushName; - this.popName = popName; - } - - public CoderDescriptor(final Coder coder) { this(coder, "push", "pop"); } - public CoderDescriptor(){ this("push", "pop"); } - - public String getPopStatementFor(final String contextName, final String returnValueType, final String returnValueName, final String transform) { - return "final " + returnValueType + " " + returnValueName + " = " + "(" + returnValueType + ") " + (transform == null ? "" : transform) - + "(" + getCoderInstanceName() + "." + popName + "(" + contextName + "));"; - } - - public final String getPushStatementFor(final String contextName, final String argumentName) { - return getCoderInstanceName() + "." + pushName + "(" + contextName + ", " + argumentName + ");"; - } - - public String getPopAddrStatementFor(final String runtime, final String addr, final String returnValueType, final String returnValueName, final String transform) { - return "final " + returnValueType + " " + returnValueName + " = " + "(" + returnValueType + ") " + (transform == null ? "" : transform) - + "(" + getCoderInstanceName() + "." + popName + "(" + runtime + ", " + addr + "));"; - } - - public final String getPushAddrStatementFor(final String runtime, final String addr, final String argumentName) { - return getCoderInstanceName() + "." + pushName + "(" + runtime + ", " + addr + ", " + argumentName + ");"; - } - - public String getCoderInstanceName() { return coderInstanceName; } - public Coder getCoder() { return coder; } - public String getDefaultReturnValue() { return "null"; } - - // - // Specialized - // - - static public class UnknownCoderDescriptor extends CoderDescriptor { - public static final CoderDescriptor UNKNOWN_DESC = new UnknownCoderDescriptor(); - public UnknownCoderDescriptor() { super(UnknownCoder.INST); } - } - - static public class PrimitivePointerCoderDescriptor extends CoderDescriptor { - public static final PrimitivePointerCoderDescriptor POINTER_DESC = new PrimitivePointerCoderDescriptor(); - public PrimitivePointerCoderDescriptor() { super(PrimitivePointerCoder.INST, "push", "popPtr"); } - } - - static public class PointerCoderDescriptor extends CoderDescriptor { - public static final PointerCoderDescriptor INST = new PointerCoderDescriptor(); - public PointerCoderDescriptor() { super(PointerCoder.INST); } - } - - static public class SELCoderDescriptor extends CoderDescriptor { - public static final SELCoderDescriptor INST = new SELCoderDescriptor(); - public SELCoderDescriptor() { super(SELCoder.INST); } - } - - static public class IDCoderDescriptor extends CoderDescriptor { - public static final IDCoderDescriptor INST = new IDCoderDescriptor(); - public IDCoderDescriptor() { super(IDCoder.INST); } - } - - static public class NSClassCoderDescriptor extends CoderDescriptor { - public static final NSClassCoderDescriptor INST = new NSClassCoderDescriptor(); - public NSClassCoderDescriptor() { super(NSClassCoder.INST); } - } - - static public class StructCoderDescriptor extends CoderDescriptor { - public final JStruct jstruct; - public StructCoderDescriptor(JStruct jst) { this.jstruct = jst; } - @Override public String getCoderInstanceName(){ return jstruct.getJavaTypeName() + ".getStructCoder()"; } - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/coders/ComplexCoderDescriptor.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/coders/ComplexCoderDescriptor.java deleted file mode 100644 index 929b0744ec3..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/coders/ComplexCoderDescriptor.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.model.coders; - -import java.util.HashMap; -import java.util.TreeSet; -import java.util.Map; -import java.util.Set; - -import com.apple.internal.jobjc.generator.classes.MixedPrimitiveCoderClassFile; -import com.apple.internal.jobjc.generator.model.types.NType; -import com.apple.internal.jobjc.generator.model.types.NType.NPrimitive; -import com.apple.internal.jobjc.generator.utils.Fp.Pair; -import com.apple.jobjc.JObjCRuntime; - -/** - * Used to code two primitives of different 32/64 types. - */ -public class ComplexCoderDescriptor extends CoderDescriptor { - static Map, ComplexCoderDescriptor> cache = new HashMap, ComplexCoderDescriptor>(); - static Set mixedEncodingDescriptors = new TreeSet(); - - public static Set getMixedEncoders() { return mixedEncodingDescriptors; } - - public static ComplexCoderDescriptor getCoderDescriptorFor(final NType nt32, final NType nt64) { - Pair cacheKey = new Pair(nt32, nt64); - if(cache.containsKey(cacheKey)) return cache.get(cacheKey); - - final PrimitiveCoderDescriptor desc32 = PrimitiveCoderDescriptor.getCoderDescriptorFor((NPrimitive) nt32); - final PrimitiveCoderDescriptor desc64 = PrimitiveCoderDescriptor.getCoderDescriptorFor((NPrimitive) nt64); - - final ComplexCoderDescriptor newDesc = nt32.equals(nt64) ? new ComplexCoderDescriptor(desc64) : new MixedEncodingDescriptor(desc32, desc64); - cache.put(cacheKey, newDesc); - if(newDesc instanceof MixedEncodingDescriptor) - mixedEncodingDescriptors.add((MixedEncodingDescriptor) newDesc); - - return newDesc; - } - - protected final PrimitiveCoderDescriptor desc64; - - public ComplexCoderDescriptor(final PrimitiveCoderDescriptor desc64) { - super(desc64.coder, desc64.pushName, desc64.popName); - this.desc64 = desc64; - } - - public String getName() { return desc64.javaPrimitiveClazz.getName(); } - @Override public String getDefaultReturnValue() { return desc64.defaultReturnValue; } - public String getJavaObjectClass() { return desc64.javaObjectClazz.getName(); } - public String getDefinition() { return get64CoderName(); } - public String getCoderAccessor() { return get64CoderName(); } - String get64CoderName() { return desc64.getCoderInstanceName(); } - - // ** Subclasses - // ------------- - - public static class MixedEncodingDescriptor extends ComplexCoderDescriptor implements java.lang.Comparable { - protected final PrimitiveCoderDescriptor desc32; - - public MixedEncodingDescriptor(final PrimitiveCoderDescriptor desc32, final PrimitiveCoderDescriptor desc64) { - super(desc64); - this.desc32 = desc32; - } - - @Override public String getDefinition() { return JObjCRuntime.class.getName() + ".IS64 ? " + get64CoderName() + " : " + get32CoderName(); } - @Override public String getCoderAccessor() { return MixedPrimitiveCoderClassFile.FULL_MULTI_CODER_CLASSNAME + "." + getMixedName(); } - String get32CoderName() { return desc32.getCoderInstanceName(); } - @Override public String getCoderInstanceName(){ return getCoderAccessor(); } - @Override public String toString() { return getMixedName(); } - - public String getMixedName() { - final String coder32Name = getBaseNameOfCoder(desc32.primitiveCoderName); - final String coder64Name = getBaseNameOfCoder(desc64.primitiveCoderName); - return coder32Name + coder64Name + "Coder"; - } - - static String getBaseNameOfCoder(final String coderName) { return coderName.substring(0, coderName.indexOf("Coder")); } - public int compareTo(Object _o) { MixedEncodingDescriptor o = (MixedEncodingDescriptor)_o; return getMixedName().compareTo(o.getMixedName()); } - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/coders/PrimitiveCoderDescriptor.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/coders/PrimitiveCoderDescriptor.java deleted file mode 100644 index 82684415120..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/coders/PrimitiveCoderDescriptor.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.model.coders; - -import java.util.HashMap; -import java.util.Map; - -import com.apple.internal.jobjc.generator.model.types.NType.NPrimitive; -import com.apple.jobjc.Coder; -import com.apple.jobjc.PrimitiveCoder; -import com.apple.jobjc.PrimitiveCoder.BoolCoder; -import com.apple.jobjc.PrimitiveCoder.SCharCoder; -import com.apple.jobjc.PrimitiveCoder.SIntCoder; -import com.apple.jobjc.PrimitiveCoder.SLongCoder; -import com.apple.jobjc.PrimitiveCoder.SLongLongCoder; -import com.apple.jobjc.PrimitiveCoder.SShortCoder; -import com.apple.jobjc.PrimitiveCoder.UCharCoder; -import com.apple.jobjc.PrimitiveCoder.UIntCoder; -import com.apple.jobjc.PrimitiveCoder.ULongCoder; -import com.apple.jobjc.PrimitiveCoder.ULongLongCoder; -import com.apple.jobjc.PrimitiveCoder.UShortCoder; -import com.apple.internal.jobjc.generator.Utils; - -public class PrimitiveCoderDescriptor extends CoderDescriptor { - static Map descriptors = new HashMap(); - - public static PrimitiveCoderDescriptor getCoderDescriptorFor(NPrimitive nt) { - return getCoderDescriptorFor(nt.type); - } - - public static PrimitiveCoderDescriptor getCoderDescriptorFor(char c) { - final PrimitiveCoderDescriptor desc = descriptors.get(c); - if (desc != null) return desc; - final PrimitiveCoderDescriptor newDesc = createCoderDescriptorFor(c); - descriptors.put(c, newDesc); - return newDesc; - } - - public static PrimitiveCoderDescriptor createCoderDescriptorFor(final char encoding) { - switch(encoding) { - case 'B': return new PrimitiveCoderDescriptor(BoolCoder.INST, "false"); - - case 'c': return new PrimitiveCoderDescriptor(SCharCoder.INST, "0"); - case 'C': return new PrimitiveCoderDescriptor(UCharCoder.INST, "0"); - - case 's': return new PrimitiveCoderDescriptor(SShortCoder.INST, "0"); - case 'S': return new PrimitiveCoderDescriptor(UShortCoder.INST, "0"); - - case 'i': return new PrimitiveCoderDescriptor(SIntCoder.INST, "0"); - case 'I': return new PrimitiveCoderDescriptor(UIntCoder.INST, "0"); - - case 'l': return new PrimitiveCoderDescriptor(SLongCoder.INST, "0"); - case 'L': return new PrimitiveCoderDescriptor(ULongCoder.INST, "0", "x86_64: no suitable Java primitive for unsigned long."); - case 'q': return new PrimitiveCoderDescriptor(SLongLongCoder.INST, "0"); - case 'Q': return new PrimitiveCoderDescriptor(ULongLongCoder.INST, "0", "x86_64: no suitable Java primitive for unsigned long long."); - - case 'f': return new PrimitiveCoderDescriptor(PrimitiveCoder.FloatCoder.INST, "0"); - case 'd': return new PrimitiveCoderDescriptor(PrimitiveCoder.DoubleCoder.INST, "0"); - default: throw new RuntimeException("unknown encoding: " + encoding); - } - } - - public final Class javaPrimitiveClazz; - final Class javaObjectClazz; - final String defaultReturnValue; - final String primitiveCoderName; - final String _mismatchMessage; - - public PrimitiveCoderDescriptor(final Coder coder, final String defaultRetVal) { - this(coder, defaultRetVal, null); - } - - public PrimitiveCoderDescriptor(final Coder coder, - final String defaultReturnValue, final String mismatchMessage) { - super(coder, "push", "pop" + Utils.capitalize(coder.getJavaPrimitive().getSimpleName())); - this.javaPrimitiveClazz = coder.getJavaPrimitive(); - this.javaObjectClazz = coder.getJavaClass(); - this.defaultReturnValue = defaultReturnValue; - this.primitiveCoderName = coder.getClass().getSimpleName(); - this._mismatchMessage = mismatchMessage; - } - - @Override public PrimitiveCoder getCoder(){ return (PrimitiveCoder) super.getCoder(); } - @Override public String mismatchMessage(){ return _mismatchMessage; } - @Override public String getDefaultReturnValue() { return defaultReturnValue; } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/types/JType.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/types/JType.java deleted file mode 100644 index 56e0f4b2386..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/types/JType.java +++ /dev/null @@ -1,237 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.model.types; - -import com.apple.internal.jobjc.generator.classes.RootJObjCClass; -import com.apple.internal.jobjc.generator.model.CFType; -import com.apple.internal.jobjc.generator.model.Clazz; -import com.apple.internal.jobjc.generator.model.Opaque; -import com.apple.internal.jobjc.generator.model.Struct; -import com.apple.internal.jobjc.generator.model.coders.CoderDescriptor; -import com.apple.internal.jobjc.generator.model.coders.ComplexCoderDescriptor; -import com.apple.internal.jobjc.generator.model.coders.CoderDescriptor.IDCoderDescriptor; -import com.apple.internal.jobjc.generator.model.coders.CoderDescriptor.NSClassCoderDescriptor; -import com.apple.internal.jobjc.generator.model.coders.CoderDescriptor.PointerCoderDescriptor; -import com.apple.internal.jobjc.generator.model.coders.CoderDescriptor.SELCoderDescriptor; -import com.apple.internal.jobjc.generator.model.coders.CoderDescriptor.StructCoderDescriptor; -import com.apple.internal.jobjc.generator.model.coders.CoderDescriptor.UnknownCoderDescriptor; -import com.apple.internal.jobjc.generator.model.types.NType.NPrimitive; -import com.apple.jobjc.ID; -import com.apple.jobjc.NSClass; -import com.apple.jobjc.NativeArgumentBuffer; -import com.apple.jobjc.Pointer; -import com.apple.jobjc.SEL; - -public abstract class JType { - public abstract String getJavaTypeName(); - public String getJavaClassName() { return getJavaTypeName().substring(getJavaTypeName().lastIndexOf('.') + 1); } - public String getJavaReturnTypeName() { return getJavaTypeName(); } - public String getReturnTypeCast() { return null; } - public String getTypeNameAsParam() { return getJavaTypeName(); } - - public abstract CoderDescriptor getCoderDescriptor(); - public String getDefaultReturnValue() { return "null"; } - public String getAppendableDescription() { return getJavaTypeName().substring(getJavaTypeName().lastIndexOf('.') + 1); } - - /** - * Used for primitive types (like int) that can't be used as generic arguments. This returns an appropriate Java class (like Integer). - */ - public JType getParameterizableType() { return this; } - - // - // Writer ops - // - - public String createDeclareBuffer(String contextName) { - return "final " + NativeArgumentBuffer.class.getName() + " " + contextName + " = getRuntime().getThreadLocalState();"; - } - - public String createInit(final String contextName, final String functionIdentifier, final String initWithObj) { - return functionIdentifier + ".init(" + contextName + (initWithObj != null ? ", " + initWithObj : "") + ");"; - } - - public String createInvoke(final String contextName, final String functionIdentifier) { - return functionIdentifier + ".invoke(" + contextName + ");"; - } - - public String createPop(final String contextName) { - return getCoderDescriptor().getPopStatementFor(contextName, getJavaTypeName(), "returnValue", null); - } - - public String createPopAddr(final String runtime, final String addr) { - return getCoderDescriptor().getPopAddrStatementFor(runtime, addr, getJavaTypeName(), "returnValue", null); - } - - public String createReturn() { - final String preCast = getReturnTypeCast(); - return "return " + (preCast == null ? "" : "(" + preCast + ")") + "returnValue;"; - } - - // - // Specialized - // - - static public class JUnknown extends JType { - final Type type; - protected JUnknown(final Type type) { - this.type = type; - TypeCache.inst().getUnknownTypes().add(type); - } - @Override public String getJavaTypeName() { return "Object /* " + type + " */"; } - @Override public String getAppendableDescription() { return "Unknown"; } - @Override public CoderDescriptor getCoderDescriptor() { return UnknownCoderDescriptor.UNKNOWN_DESC; } - } - - static class JVoid extends JType { - public static JVoid INST = new JVoid(); - @Override public String getJavaTypeName() { return "Void"; } - @Override public String getJavaReturnTypeName() { return "void"; } - @Override public CoderDescriptor getCoderDescriptor(){ return CoderDescriptor.VOID_DESC; } - @Override public String createPop(final String contextName){ return ""; } - @Override public String createReturn(){ return ""; } - }; - - static class JSelector extends JType { - public static JSelector INST = new JSelector(); - @Override public String getJavaTypeName() { return SEL.class.getName(); } - @Override public CoderDescriptor getCoderDescriptor() { return SELCoderDescriptor.INST; } - }; - - static class JCFType extends JType{ - final CFType cfType; - public JCFType(final CFType cfType){ this.cfType = cfType; } - @Override public String getJavaTypeName() { return cfType.parent.pkg + "." + cfType.name + "CFType"; } - @Override public CoderDescriptor getCoderDescriptor() { return PointerCoderDescriptor.INST; } - @Override public String createPop(final String contextName) { - return "\t\t" + getCoderDescriptor().getPopStatementFor(contextName, getJavaReturnTypeName(), "returnValue", "new " + getJavaTypeName()); - } - } - - static class JOpaque extends JType{ - final Opaque opaque; - public JOpaque(final Opaque opaque){ this.opaque = opaque; } - @Override public String getJavaTypeName() { return opaque.parent.pkg + "." + opaque.name + "Opaque"; } - @Override public CoderDescriptor getCoderDescriptor() { return PointerCoderDescriptor.INST; } - @Override public String createPop(final String contextName) { - return "\t\t" + getCoderDescriptor().getPopStatementFor(contextName, getJavaReturnTypeName(), "returnValue", "new " + getJavaTypeName()); - } - } - - static class JPointer extends JType { - static JType VOID_PTR = new JPointer(JVoid.INST); - - final JType subject; - protected JPointer(final JType javaType) { this.subject = javaType; } - - @Override public String getJavaTypeName() { return Pointer.class.getName() + "<" + subject.getParameterizableType().getJavaTypeName() + ">"; } - @Override public String getAppendableDescription() { return "PointerTo" + subject.getAppendableDescription(); } - @Override public CoderDescriptor getCoderDescriptor() { return PointerCoderDescriptor.INST; } - } - - static class JObject extends JType { - public static JType ID_TYPE = new JType() { - @Override public String getJavaTypeName() { return ID.class.getName(); } - @Override public String getJavaReturnTypeName() { return " T"; } - @Override public String getReturnTypeCast() { return "T"; } - @Override public CoderDescriptor getCoderDescriptor() { return IDCoderDescriptor.INST; } - }; - - final Type type; - final Clazz clazz; - - public JObject(final Type type, final Clazz clazz) { - this.type = type; - this.clazz = clazz; - } - - @Override public String getJavaTypeName() { return clazz.getFullPath();} - @Override public CoderDescriptor getCoderDescriptor() { return IDCoderDescriptor.INST; } - } - - static class JClass extends JType { - public static JClass INST = new JClass(); - @Override public String getJavaTypeName() { return NSClass.class.getName(); } - @Override public String getJavaReturnTypeName() { return " T"; } - @Override public String getTypeNameAsParam() { return super.getTypeNameAsParam(); } - @Override public String getReturnTypeCast() { return "T"; } - @Override public CoderDescriptor getCoderDescriptor() { return NSClassCoderDescriptor.INST; } - }; - - public static class JStruct extends JType { - public final Struct struct; - public JStruct(final Struct struct) { this.struct = struct; } - - @Override public String getJavaTypeName() { return struct.parent.pkg + "." + struct.name; } - @Override public String getJavaReturnTypeName() { return getJavaTypeName(); } - - StructCoderDescriptor coderDescriptor = new StructCoderDescriptor(this); - @Override public CoderDescriptor getCoderDescriptor() { return coderDescriptor; } - - public String createReturnValue() { - return "\t\t" + getJavaReturnTypeName() + " returnValue = " + RootJObjCClass.runtimeFrameworkInstR(struct.parent.name) - + ".make" + struct.name + "();"; - } - - @Override public String createInvoke(final String contextName, final String functionIdentifier) { - return createReturnValue() + "\n\t\t" + functionIdentifier + ".invoke(" + contextName + ", returnValue);"; - } - - @Override public String createPop(final String contextName){ return ""; } - } - - public static class JPrimitive extends JType { - final Type type; - final ComplexCoderDescriptor coderDescriptor; - final JType parameterizable; - - public JPrimitive(final Type type, final ComplexCoderDescriptor coderDesc) { - this.type = type; - this.coderDescriptor = coderDesc; - - this.parameterizable = new JType() { - @Override public String getJavaTypeName() { return coderDescriptor.getJavaObjectClass(); } - @Override public CoderDescriptor getCoderDescriptor() { throw new RuntimeException(); } - }; - } - - @Override public String getJavaTypeName() { return coderDescriptor.getName(); } - @Override public String getDefaultReturnValue() { return coderDescriptor.getDefaultReturnValue(); } - @Override public JType getParameterizableType() { return parameterizable; } - @Override public CoderDescriptor getCoderDescriptor() { return coderDescriptor; } - - /** - * Return the suffix placed on java literals to indicate the type. If none applies, return ' '. - */ - public char getLiteralSuffix() { - char t = ((NPrimitive)type.type64).type; - switch(t){ - case 'l': case 'L': case 'f': case 'd': return t; - case 'q': case 'Q': return 'L'; - } - return ' '; - } - } - -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/types/NType.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/types/NType.java deleted file mode 100644 index 3c6d644eece..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/types/NType.java +++ /dev/null @@ -1,280 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.model.types; - -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import com.apple.internal.jobjc.generator.Utils; -import com.apple.internal.jobjc.generator.model.coders.PrimitiveCoderDescriptor; -import com.apple.internal.jobjc.generator.utils.Fp; -import com.apple.internal.jobjc.generator.utils.NTypePrinter; -import com.apple.internal.jobjc.generator.utils.QA; -import com.apple.jobjc.JObjCRuntime.Width; - -/** - * NType (Native Type) bridges the type and type64 attributes in BridgeSupport. - * - * For example: - * - *

- *   type="c"                 // BridgeSupport attribute
- *   (NPrimitive type: 'c')   // Java object (in sexp form here, for readability)
- *
- *   type="^v"
- *   (NPointer subject: (NVoid))
- *
- *   type="{foo_t="a"c"b"b8"c"[32^v]}"
- *   (NStruct
- *     name: "foo_t"
- *     fields:
- *       (List
- *         0: (NField name:"a" type: (NPrimitive type: 'c'))
- *         1: (NField name:"b" type: (NBitfield size: 8))
- *         2: (NField name:"c" type:
- *              (NArray size: 32
- *                      type: (NPointer subject: (NVoid))))))
- * 
- */ -public abstract class NType implements Comparable{ - public final Map sizeof; - - public NType(Map sizeof) { - this.sizeof = sizeof; - } - - public NType(){ - this(new HashMap()); - } - - public NType(int sz32, int sz64){ - this(); - this.sizeof.put(Width.W32, sz32); - this.sizeof.put(Width.W64, sz32); - } - - public int sizeof32(){ return sizeof.get(Width.W32); } - public int sizeof64(){ return sizeof.get(Width.W64); } - - protected abstract boolean equals2(NType nt); - - private String _toString; - @Override public String toString(){ return _toString != null ? _toString : (_toString = NTypePrinter.inst().print(this)); } - @Override public boolean equals(Object o) { - return o!=null && (o==this || (getClass().isInstance(o) - && this.sizeof.equals(((NType) o).sizeof) - && equals2((NType) o))); - } - public int compareTo(NType o){ return toString().compareTo(o.toString()); } - - // ** NType subclasses - // ------------------- - - public static class NBitfield extends NType{ - public final int length; - - public NBitfield(int length){ - super(-1, -1); - this.length = length; - } - - @Override protected boolean equals2(NType nt) { return ((NBitfield) nt).length == length; } - @Override public int hashCode() { return Integer.valueOf(length).hashCode(); } - } - - public static class NPrimitive extends NType{ - public static Collection CODES = Arrays.asList( - 'B', 'c', 'C', 's', 'S', 'i', 'I', 'l', 'L', 'q', 'Q', 'f', 'd'); - - public final char type; - - protected NPrimitive(char c){ - super(PrimitiveCoderDescriptor.createCoderDescriptorFor(c).getCoder().sizeof(Width.W32), - PrimitiveCoderDescriptor.createCoderDescriptorFor(c).getCoder().sizeof(Width.W64)); - type = c; - } - private static final Map cache = new HashMap(); - public static final NPrimitive inst(final char c){ - if(!cache.containsKey(c)) cache.put(c, new NPrimitive(c)); - return cache.get(c); - } - - @Override protected boolean equals2(NType nt) { return ((NPrimitive)nt).type == type; } - @Override public int hashCode() { return Character.valueOf(type).hashCode(); } - } - - public static class NVoid extends NType{ - protected NVoid(){ super(); } - private final static NVoid INST = new NVoid(); - public static NVoid inst() { return INST; } - - @Override protected boolean equals2(NType nt) { return true; } - } - - public static class NPointer extends NType{ - public final NType subject; - - public NPointer(NType subject){ - super(4, 8); - QA.nonNull(subject); - this.subject = subject; - } - - @Override protected boolean equals2(NType nt) { return ((NPointer)nt).subject.equals(subject); } - @Override public int hashCode() { return subject.hashCode(); } - } - - public static class NObject extends NType{ - protected NObject(){ super(4, 8); } - private final static NObject INST = new NObject(); - public static NObject inst() { return INST; } - - @Override protected boolean equals2(NType nt) { return true; } - } - - public static class NClass extends NType{ - protected NClass(){ super(4, 8); } - private final static NClass INST = new NClass(); - public static NClass inst() { return INST; } - - @Override protected boolean equals2(NType nt) { return true; } - } - - public static class NSelector extends NType{ - protected NSelector(){ super(4, 8); } - private final static NSelector INST = new NSelector(); - public static NSelector inst() { return INST; } - - @Override protected boolean equals2(NType nt) { return true;} - } - - public static class NField{ - public final Map offset; - public final String name; - public final NType type; - - public NField(String name, NType type, Map offset) { - QA.nonNull(name, type, offset); - this.name = name; - this.type = type; - this.offset = offset; - } - - public NField(String name, NType type) { - this(name, type, new HashMap()); - } - - public int offset32(){ return offset.get(Width.W32); } - public int offset64(){ return offset.get(Width.W64); } - - @Override public int hashCode() { return name.hashCode() + type.hashCode(); } - @Override public boolean equals(Object o) { - return o!=null && (o==this || - (o instanceof NField - && this.offset.equals(((NField) o).offset) - && ((NField) o).name.equals(this.name) - && ((NField) o).type.equals(this.type))); - } - } - - public static class NStruct extends NType{ - public final String name; - public final List fields; - - public NStruct(String name, List fields, Map sizeof){ - super(sizeof); - QA.nonNull(name, fields); - this.name = name; - this.fields = fields; - } - - public NStruct(String name, List fields){ - super(); - QA.nonNull(name, fields); - this.name = name; - this.fields = fields; - } - - @Override protected boolean equals2(NType nt) { - return ((NStruct)nt).name.equals(name) && ((NStruct)nt).fields.equals(fields); - } - - @Override public int hashCode() { return name.hashCode() + fields.hashCode(); } - } - - // A Union is like a Struct, but the offset of every field is 0. - public static class NUnion extends NStruct{ - public NUnion(String concreteName, List fields){ - super(concreteName, fields); - assert Fp.all(hasZeroOffsets, fields) : Utils.joinWComma(fields); - } - - public NUnion(String name, List fields, Map sizeof) { - super(name, fields, sizeof); - assert Fp.all(hasZeroOffsets, fields) : Utils.joinWComma(fields); - } - - public static final Fp.Map1 hasZeroOffsets = new Fp.Map1(){ - public Boolean apply(NField a) { - for(int i : a.offset.values()) - if(i != 0) - return false; - return true; - }}; - public static final Fp.Map1 zeroOffsets = new Fp.Map1(){ - public NField apply(NField a) { - Map off = new HashMap(); - for(Width w : a.offset.keySet()) - off.put(w, 0); - return new NField(a.name, a.type, off); - }}; - } - - public static class NArray extends NType{ - public final int length; - public final NType type; - - public NArray(int length, NType type){ - QA.nonNull(type); - this.length = length; - this.type = type; - } - - @Override protected boolean equals2(NType nt) { return ((NArray)nt).length == length && ((NArray)nt).type.equals(type); } - @Override public int hashCode(){ return Long.valueOf(length).hashCode() + type.hashCode(); } - } - - // Seems to be used for callbacks - public static class NUnknown extends NType{ - protected NUnknown(){ super(); } - private final static NUnknown INST = new NUnknown(); - public static NUnknown inst() { return INST; } - - @Override protected boolean equals2(NType nt) { return true;} - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/types/Type.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/types/Type.java deleted file mode 100644 index 740e68154b2..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/types/Type.java +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.model.types; - -import java.util.ArrayList; -import java.util.List; -import java.util.HashMap; -import java.util.Map; - -import com.apple.internal.jobjc.generator.model.types.NType.NObject; -import com.apple.internal.jobjc.generator.model.types.NType.NPointer; -import com.apple.internal.jobjc.generator.model.types.NType.NPrimitive; -import com.apple.internal.jobjc.generator.model.types.NType.NVoid; -import com.apple.internal.jobjc.generator.model.types.NType.NStruct; -import com.apple.internal.jobjc.generator.model.types.NType.NField; -import com.apple.internal.jobjc.generator.utils.NTypeMerger; -import com.apple.internal.jobjc.generator.utils.QA; -import com.apple.internal.jobjc.generator.utils.Fp.Pair; -import com.apple.internal.jobjc.generator.utils.NTypeMerger.MergeFailed; - -public class Type implements Comparable{ - public static Type VOID = Type.getType("void", NVoid.inst(), null); - public static Type VOID_PTR = Type.getType("void*", new NPointer(NVoid.inst()), null); - - final public String name; - final public NType type32; - final public NType type64; - - // HACK BS bug where some types have inconsistent definitions in the metadata, - // e.g. (l / i) in some places and just (l) (and thus (l / l)) in others. - // This is a mapping from the type name to a Type object with the correct definition. - private static final Map exceptions; - static { - exceptions = new HashMap(); - exceptions.put("OSStatus", getType("OSStatus", new NPrimitive('l'), new NPrimitive('i'))); // (l / i) vs. (l) - exceptions.put("CGFloat", getType("CGFloat", new NPrimitive('f'), new NPrimitive('d'))); // (f / d) vs. (f) - exceptions.put("NSRect", getType("NSRect", getNSRectType(), getCGRectType())); // ({{_NSPoint}{_NSSize}} / {{CGPoint}{CGSize}}) vs. ({{_NSPoint}{_NSSize}}) - exceptions.put("NSPoint", getType("NSPoint", getNSPointType(), getCGPointType())); // (_NSPoint / CGPoint) vs. (_NSPoint) - exceptions.put("NSSize", getType("NSSize", getNSSizeType(), getCGSizeType())); // (_NSSize / CGSize) vs. (_NSSize) - exceptions.put("NSInteger", getType("NSInteger", new NPrimitive('i'), new NPrimitive('q'))); // (i / q) vs. (i) - exceptions.put("NSPointArray", getType("NSPointArray", new NPointer(getNSPointType()), new NPointer(getCGPointType()))); // (^_NSPoint / ^CGPoint) vs. (^_NSPoint) - exceptions.put("NSMultibyteGlyphPacking", getType("NSMultibyteGlyphPacking", new NPrimitive('I'), new NPrimitive('Q'))); // (I / Q) vs. (I) - exceptions.put("CFTypeRef", getType("CFTypeRef", new NPointer(NVoid.inst()), new NPointer(NVoid.inst()))); // (^v, ^v) vs. (@, @) - } - - public static Type getType(final String name, final NType t32, final NType t64){ - return TypeCache.inst().pingType(new Type(name, t32, t64)); - } - - private Type(final String name, final NType t32, final NType t64) { - QA.nonNull(t32); - this.name = cleanName(name); - this.type32 = t32; - this.type64 = t64 == null || t32.equals(t64) ? t32 : t64; - } - - private JType _getJType; - public JType getJType() { - return _getJType!=null ? _getJType : (_getJType = TypeToJType.inst().getJTypeFor(TypeCache.inst().pingType(this))); - } - - private String _toString; - @Override public String toString() { - return _toString != null ? _toString : (_toString = name + " " + new Pair(type32, type64).toString()); - } - - @Override public boolean equals(Object o){ - if(o==null || !(o instanceof Type)) return false; - Type t = (Type) o; - return QA.bothNullOrEquals(t.name, this.name) - && t.type32.equals(this.type32) - && t.type64.equals(this.type64); - } - - @Override public int hashCode(){ - return (name == null ? 0 : name.hashCode()) - + type32.hashCode() + type64.hashCode(); - } - - public int compareTo(Type o) { return toString().compareTo(o.toString()); } - - public static Type merge(Type a, Type b) throws MergeFailed{ - if(a!=null && b==null) return a; - if(a==null && b!=null) return b; - if(QA.bothNullOrEquals(a, b)) return a; - if (exceptions.containsKey(a.name)) return exceptions.get(a.name); // HACK BS bug - if(a.name != null && b.name != null && !a.name.equals(b.name)){ - System.out.println("Merging:"); - System.out.println("\ta.....: " + a.toString()); - System.out.println("\tb.....: " + b.toString()); - } - final Type merged = new Type(NTypeMerger.inst().mergeName(a.name, b.name), - NTypeMerger.inst().merge(a.type32, b.type32), - NTypeMerger.inst().merge(a.type64, b.type64)); - if(a.name != null && b.name != null && !a.name.equals(b.name)){ - System.out.println("\tmerged: " + merged.toString()); - } - return merged; - } - - // HACK BS bug where sometimes the name is declared as "id fields = new ArrayList(); - fields.add(new NField("origin", getCGPointType())); - fields.add(new NField("size", getCGSizeType())); - return new NStruct("CGRect", fields); - } - - private static NType getNSRectType() { - List fields = new ArrayList(); - fields.add(new NField("origin", getNSPointType())); - fields.add(new NField("size", getNSSizeType())); - return new NStruct("_NSRect", fields); - } - - private static NType getCGPointType() { - List fields = new ArrayList(); - fields.add(new NField("x", new NPrimitive('d'))); - fields.add(new NField("y", new NPrimitive('d'))); - return new NStruct("CGPoint", fields); - } - - private static NType getNSPointType() { - List fields = new ArrayList(); - fields.add(new NField("x", new NPrimitive('f'))); - fields.add(new NField("y", new NPrimitive('f'))); - return new NStruct("_NSPoint", fields); - } - - private static NType getCGSizeType() { - List fields = new ArrayList(); - fields.add(new NField("width", new NPrimitive('d'))); - fields.add(new NField("height", new NPrimitive('d'))); - return new NStruct("CGSize", fields); - } - - private static NType getNSSizeType() { - List fields = new ArrayList(); - fields.add(new NField("width", new NPrimitive('f'))); - fields.add(new NField("height", new NPrimitive('f'))); - return new NStruct("_NSSize", fields); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/types/TypeCache.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/types/TypeCache.java deleted file mode 100644 index dabf0d99ff2..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/types/TypeCache.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.model.types; - -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeSet; - -import com.apple.internal.jobjc.generator.model.CFType; -import com.apple.internal.jobjc.generator.model.Clazz; -import com.apple.internal.jobjc.generator.model.Framework; -import com.apple.internal.jobjc.generator.model.Opaque; -import com.apple.internal.jobjc.generator.model.Struct; -import com.apple.internal.jobjc.generator.utils.Fp.Pair; - -/** - * Central store for types found in the frameworks. - */ -public class TypeCache { - private static TypeCache INST = new TypeCache(); - public static TypeCache inst(){ return INST; } - protected TypeCache(){} - - /** - * When a new Type is discovered, pass it through here to - * hit the cache, potentially merge with other types, etc. - * - * Always do: - * - * Type type = TypeCache.inst().pingType(new Type(a,b,c)); - * - * because this should return a better merge for you. - */ - public Type pingType(final Type type_){ - Type typex = type_; - - // XXX Exception for void* clashes: void* (^{OpaqueCMProfileRef}), void* (^{X}), etc - if("void*".equals(typex.name) && getTypeByName(typex.name)!=null) - return getTypeByName(typex.name); - - if(typex.name != null) - typex = Type.merge(typex, getTypeByName(typex.name)); - else // type.name == null - typex = Type.merge(typex, getTypeByNTypes(new Pair(typex.type32, typex.type64))); - putTypeByName(typex.name, typex); - putTypeByNTypes(new Pair(typex.type32, typex.type64), typex); - return typex; - } - - public final Map typesByName = new HashMap(); - public Type getTypeByName(final String name) { return typesByName.get(Type.cleanName(name)); } - public void putTypeByName(String name, Type type) { if(name!=null) typesByName.put(name, type); } - - public final Map, Type> typesByNTypes = new HashMap, Type>(); - public Type getTypeByNTypes(Pair pair) { return typesByNTypes.get(pair); } - public void putTypeByNTypes(Pair pair, Type type) { if(pair!=null) typesByNTypes.put(pair, type); } - - private final Map classesByName = new HashMap(); - private final Map structsByName = new HashMap(); - private final Map cfTypesByName = new HashMap(); - private final Map opaquesByName = new HashMap(); - - public void load(final List frameworks) { - for (final Framework framework : frameworks) { - for (final Clazz obj : framework.classes) { - final Clazz previous = classesByName.put(obj.name, obj); - if(previous != null) - throw new RuntimeException(String.format( - "TypeCache: naming collision: class name: %1$-10s -- framework1: %2$-10s -- framework2: %3$-10s \n", - obj.name, obj.parent.name, previous.parent.name)); - } - - for (final Struct obj : framework.structs) { - final Struct previous = structsByName.put(obj.name, obj); - if(previous != null) - throw new RuntimeException(String.format( - "TypeCache: naming collision: name: %1$-10s -- type1: %2$-10s -- type2: %3$-10s \n", - obj.name, obj.type, previous.type)); - } - - for (final CFType obj : framework.cfTypes) { - final CFType previous = cfTypesByName.put(obj.name, obj); - if(previous != null) - throw new RuntimeException(String.format( - "TypeCache: naming collision: name: %1$-10s -- type1: %2$-10s -- type2: %3$-10s \n", - obj.name, obj.type, previous.type)); - } - - for (final Opaque obj : framework.opaques) { - final Opaque previous = opaquesByName.put(obj.name, obj); - if(previous != null) - throw new RuntimeException(String.format( - "TypeCache: naming collision: name: %1$-10s -- type1: %2$-10s -- type2: %3$-10s \n", - obj.name, obj.type, previous.type)); - } - } - } - - public Collection getAllClasses() { return classesByName.values(); } - public Clazz getClassForName(final String className) { return classesByName.get(className); } - public Struct getStructForName(final String declaredType) { return structsByName.get(declaredType); } - public CFType getCFTypeForName(final String declaredType) { return cfTypesByName.get(declaredType); } - public Opaque getOpaqueForName(final String declaredType) { return opaquesByName.get(declaredType); } - - final Set unknownTypes = new TreeSet(); - public Set getUnknownTypes() { return unknownTypes; } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/types/TypeToJType.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/types/TypeToJType.java deleted file mode 100644 index 82ee3f7aaef..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/types/TypeToJType.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.model.types; - -import com.apple.internal.jobjc.generator.model.CFType; -import com.apple.internal.jobjc.generator.model.Clazz; -import com.apple.internal.jobjc.generator.model.Opaque; -import com.apple.internal.jobjc.generator.model.Struct; -import com.apple.internal.jobjc.generator.model.coders.ComplexCoderDescriptor; -import com.apple.internal.jobjc.generator.model.types.JType.JCFType; -import com.apple.internal.jobjc.generator.model.types.JType.JClass; -import com.apple.internal.jobjc.generator.model.types.JType.JObject; -import com.apple.internal.jobjc.generator.model.types.JType.JOpaque; -import com.apple.internal.jobjc.generator.model.types.JType.JPointer; -import com.apple.internal.jobjc.generator.model.types.JType.JPrimitive; -import com.apple.internal.jobjc.generator.model.types.JType.JSelector; -import com.apple.internal.jobjc.generator.model.types.JType.JStruct; -import com.apple.internal.jobjc.generator.model.types.JType.JUnknown; -import com.apple.internal.jobjc.generator.model.types.JType.JVoid; -import com.apple.internal.jobjc.generator.model.types.NType.NClass; -import com.apple.internal.jobjc.generator.model.types.NType.NObject; -import com.apple.internal.jobjc.generator.model.types.NType.NPointer; -import com.apple.internal.jobjc.generator.model.types.NType.NPrimitive; -import com.apple.internal.jobjc.generator.model.types.NType.NSelector; -import com.apple.internal.jobjc.generator.model.types.NType.NStruct; -import com.apple.internal.jobjc.generator.model.types.NType.NVoid; -import com.apple.internal.jobjc.generator.utils.Fp.CacheMap; -import com.apple.internal.jobjc.generator.utils.Fp.Dispatcher; -import com.apple.internal.jobjc.generator.utils.Fp.Map0; - -public class TypeToJType { - private static TypeToJType INST = new TypeToJType(); - public static TypeToJType inst(){ return INST; } - - private CacheMap cache = new CacheMap(); - public JType getJTypeFor(final Type type){ - return cache.get(type, new Map0(){ - public JType apply() { - try { - return Dispatcher.dispatch(TypeToJType.this.getClass(), TypeToJType.this, "accept", type, type.type32, type.type64); - } catch (NoSuchMethodException e) { - return new JUnknown(type); - } - }}); - } - - protected JType accept(Type type, NObject nt32, NObject nt64){ - if ("id".equals(type.name)) return JObject.ID_TYPE; - - final String className = type.name.replaceAll("\\*$", ""); - assert !className.endsWith("*"); - - final Clazz clazz = TypeCache.inst().getClassForName(className); - if (clazz == null) return new JUnknown(type); - // TODO Instead of JUnknown, ID_TYPE might be more appropriate. Investigate. - - return new JObject(type, clazz); - } - - protected JType accept(Type type, NPointer nt32, NPointer nt64){ - final CFType cfType = TypeCache.inst().getCFTypeForName(type.name); - if(cfType != null) return new JCFType(cfType); - - final Opaque opaque = TypeCache.inst().getOpaqueForName(type.name); - if(opaque != null) return new JOpaque(opaque); - - if("void*".equals(type.name)) return JPointer.VOID_PTR; - - if(type.name != null && type.name.endsWith("*")){ - final String subDeclaredType = type.name.substring(0, type.name.length() - 1); - final Type subType = TypeCache.inst().getTypeByName(subDeclaredType); - if (subType == null) return new JUnknown(type); - // TODO Instead of JUnknown, VOID_PTR might be a good fallback. Investigate. - - final JType javaType = TypeToJType.inst().getJTypeFor(subType).getParameterizableType(); - - final JPointer pointer = new JPointer(javaType); - return pointer; - } - - return new JUnknown(type); - } - - protected JType accept(Type type, NPrimitive nt32, NPrimitive nt64){ - final ComplexCoderDescriptor coderDesc = ComplexCoderDescriptor.getCoderDescriptorFor(type.type32, type.type64); - if (coderDesc == null) return null; - return new JPrimitive(type, coderDesc); - } - - protected JType accept(Type type, NVoid nt32, NVoid nt64){ - return JVoid.INST; - } - - protected JType accept(Type type, NSelector nt32, NSelector nt64){ - return JSelector.INST; - } - - protected JType accept(Type type, NClass nt32, NClass nt64){ - return JClass.INST; - } - - protected JType accept(Type type, NStruct nt32, NStruct nt64){ - Struct st = TypeCache.inst().getStructForName(type.name); - return st != null ? new JStruct(st) : new JUnknown(type); - // TODO We could probably generate a struct here based on the type. But we need access to its parent framework. - // Maybe we could use a fallback anonymous struct, but we need the SIZEOF. - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/Fp.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/Fp.java deleted file mode 100644 index 5c7db20c91b..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/Fp.java +++ /dev/null @@ -1,260 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.utils; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeMap; - -/** - * Functional programming constructs and utilities. Java for Lisp and Haskell nerds. - */ -public abstract class Fp { - /** - * Multiple dynamic dispatch (multi-methods) for Java. - * - * This is implemented with Java reflection: - * Class.getDeclaredMethod and Method.invoke. - * It is about 20-40 times slower than chains of - * "if instanceof" statements. - */ - public static abstract class Dispatcher{ - /** - * Shorthand, works only if no arg is null. - */ - public static final R dispatch(Class clazz, Object instance, String method, Object... args) throws NoSuchMethodException{ - Class[] types = new Class[args.length]; - for(int i = 0; i < args.length; i++) types[i] = args[i].getClass(); - return (R) dispatch(clazz, instance, method, args, types); - } - - /** - * Dispatch `args` of `types` to `method` on `clazz` for `instance`. If `method` is static, `instance` should be null. - */ - public static final R dispatch(Class clazz, Object instance, String method, Object[] args, Class[] types) throws NoSuchMethodException{ - try{ - java.lang.reflect.Method m = clazz.getDeclaredMethod(method, types); - m.setAccessible(true); - return (R) m.invoke(instance, args); - } - catch(NoSuchMethodException x){ - if(clazz.getSuperclass() != null) return (R) dispatch(clazz.getSuperclass(), instance, method, args, types); - else throw x; - } - catch(Exception x){ - throw new RuntimeException(x); - } - } - } - - /** - * The "Maybe" type encapsulates an optional value. A value of type - * "Maybe a" either contains a value of type "a" (represented as "Just a"), - * or it is empty (represented as "Nothing"). - * - * http://haskell.org/ghc/docs/latest/html/libraries/base/Data-Maybe.html - */ - public static abstract class Maybe{ - public abstract boolean isJust(); - public abstract boolean isNothing(); - public abstract A fromJust() throws ClassCastException; - public abstract A fromMaybe(final A fallback); - - public static class Nothing extends Maybe{ - @Override public A fromJust() throws ClassCastException { throw new ClassCastException("Cannot extract value from Nothing."); } - @Override public A fromMaybe(A fallback) { return fallback; } - @Override public boolean isJust() { return false; } - @Override public boolean isNothing() { return true; } - } - public static class Just extends Maybe{ - public final A a; - public Just(A a){ this.a = a; } - @Override public A fromJust(){ return a; } - @Override public A fromMaybe(A fallback) { return a; } - @Override public boolean isJust() { return true; } - @Override public boolean isNothing() { return false; } - } - } - - public static class NonNull{ - public final A obj; - public NonNull(A o){ - if(o==null) throw new RuntimeException("o may not be null."); - this.obj = o; - } - } - - // Closures - public static interface Map0{ A apply(); } - public static interface Map1{ B apply(final A a); } - public static interface Map2{ C apply(final A a, final B b); } - - public static class CacheMap,V>{ - private Map cache = new TreeMap(); - public V get(K key, Map0 create){ - if(cache.containsKey(key)) return cache.get(key); - V value = create.apply(); - cache.put(key, value); - return value; - } - } - - public static class Curry2to1 implements Map1{ - private Map2 target; private A a; - public Curry2to1(Map2 targett, A aa) { target = targett; a = aa; } - public C apply(B b) { return target.apply(a, b); } - } - - // Tuple - public static class Pair implements Comparable>{ - public final A a; public final B b; - public Pair(final A aa, final B bb){ a=aa; b=bb; } - @Override public int hashCode(){ return (a==null ? 0 : a.hashCode()) + (b==null ? 0 : b.hashCode()); } - @Override public boolean equals(Object o){ - if(!(o instanceof Pair)) return false; - Pair p = (Pair) o; - return QA.bothNullOrEquals(a, p.a) && QA.bothNullOrEquals(b, p.b); - } - @Override public String toString(){ return "(" + a + ", " + b + ")"; } - public int compareTo(Pair o){ return toString().compareTo(o.toString()); } - } - - /** - * @return [fn(x) | x <- items] - */ - public static List map(Map1 fn, final Collection xs){ - ArrayList rs = new ArrayList(xs.size()); - for(A x : xs) rs.add(fn.apply(x)); - return rs; - } - - public static List map2(Map2 fn, final Collection as, final Collection bs){ - assert as.size() == bs.size(); - ArrayList cs = new ArrayList(as.size()); - Iterator aiter = as.iterator(); - Iterator biter = bs.iterator(); - while(aiter.hasNext() && biter.hasNext()) - cs.add(fn.apply(aiter.next(), biter.next())); - return cs; - } - - /** - * Same as map, but does not retain results. - */ - public static void each(Map1 fn, final Collection xs){ - for(A x : xs) fn.apply(x); - } - - /** - * @return [x | x <- items, take(x)] - */ - public static List filter(Map1 take, final Collection xs){ - List rs = new ArrayList(xs.size()); - for(A x : xs) if(take.apply(x)) rs.add(x); - return rs; - } - - /** - * @return [x | x <- items, take(x)] - */ - public static Set filterSet(Map1 take, final Collection xs){ - Set rs = new HashSet(xs.size()); - for(A x : xs) if(take.apply(x)) rs.add(x); - return rs; - } - - /** - * @return the first x in items that satisfies take(x), or null if none - */ - public static X find(Map1 take, final Collection xs){ - for(X x : xs) if(take.apply(x)) return x; - return null; - } - - public static A foldl(final Map2 f, A a, final Collection xs){ - for(B b : xs) a = f.apply(a, b); - return a; - } - - /** - * @return All x : p(x) == true - */ - public static boolean all(Map1 p, Collection xs) { - for(A x : xs) if(!p.apply(x)) return false; - return true; - } - - /** - * @return Any x : p(x) == true - */ - public static boolean any(Map1 p, Collection xs) { - for(A x : xs) if(p.apply(x)) return true; - return false; - } - - public static String join(final String sep, final Collection xs) { - if(xs.size() == 0) return ""; - if(xs.size() == 1) return xs.iterator().next().toString(); - return Fp.foldl(new Fp.Map2(){ - public String apply(String a, A b) { - String sb = b==null? "null" : b.toString(); - return a == null ? sb : a + sep + sb; - }}, null, xs); - } - - public static Map2 operatorPlus = new Map2(){ - public Integer apply(Integer a, Integer b) { return (int)a + (int)b;} - }; - - public static int sum(Collection xs){ return foldl(operatorPlus, 0, xs); } - - public static List append(Collection xs, Collection ys) { - List rs = new ArrayList(xs.size() + ys.size()); - rs.addAll(xs); - rs.addAll(ys); - return rs; - } - - public static Set appendSet(Collection xs, Collection ys) { - Set rs = new HashSet(xs.size() + ys.size()); - rs.addAll(xs); - rs.addAll(ys); - return rs; - } - - public static Map litMap(K key, V value, Object... pairs){ - Map ret = new HashMap(1 + pairs.length/2); - ret.put(key, value); - for(int i = 0; i < pairs.length; i += 2) - ret.put(pairs[i], pairs[i+1]); - return ret; - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/JavaLang.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/JavaLang.java deleted file mode 100644 index 799ab7770d3..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/JavaLang.java +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.utils; - -import java.io.StringWriter; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Set; -import java.util.TreeSet; - -import com.apple.internal.jobjc.generator.Utils; -import com.apple.internal.jobjc.generator.Utils.Substituter; - -/** - * Utility for generating Java source code. - */ -public abstract class JavaLang { - - public static String makeSingleton(final String instanceVariable, final String methodName, final String className, final String...constructorArgs) { - return generateSingleton(new Substituter( - "#private $CLASS $IVAR = null;~" + - "#public $CLASS $METHOD() {~" + - "##return $IVAR != null ? $IVAR : ($IVAR = new $CLASS($CTORARGS));~" + - "#}~"), - instanceVariable, methodName, className, constructorArgs); - } - - public static String makeStaticSingleton(final String instanceVariable, final String methodName, final String className, final String...constructorArgs) { - return generateSingleton(new Substituter( - "#private static $CLASS $IVAR = null;~" + - "#public static $CLASS $METHOD() {~" + - "##return $IVAR != null ? $IVAR : ($IVAR = new $CLASS($CTORARGS));~" + - "#}~"), - instanceVariable, methodName, className, constructorArgs); - } - - private static String generateSingleton(final Substituter singleton, final String instanceVariable, final String methodName, final String className, final String...constructorArgs) { - singleton.replace("IVAR", instanceVariable); - singleton.replace("METHOD", methodName); - singleton.replace("CLASS", className); - singleton.replace("CTORARGS", Utils.joinWComma(constructorArgs)); - return singleton.toString(); - } - - /// - - public static class JLTertiary{ - public Object cond, tExp, fExp; - public JLTertiary(){} - public JLTertiary(Object cond, Object tExp, Object fExp){ - this.cond = cond; - this.tExp = tExp; - this.fExp = fExp; - } - @Override public String toString() { - return "((" + cond + ")\n\t? (" + tExp + ")\n\t: (" + fExp + "))"; - } - } - - public static class JLCall{ - public String fun; - public List args = new ArrayList(); - public JLCall(String fun, Object... args){ - this.fun = fun; - this.args.addAll(Arrays.asList(args)); - } - @Override public String toString(){ - return fun + "(" + Fp.join(", ", args) + ")"; - } - } - - public static class JLField{ - public Set mods = new TreeSet(); - public String type; - public String name; - public Object value; - - public JLField(String mods, String type, String name){ - this(mods, type, name, null); - } - - public JLField(String mods, String type, String name, Object value){ - this.mods.addAll(Arrays.asList(mods.split("\\s"))); - this.type = type; - this.name = name; - this.value = value; - } - - @Override public String toString(){ - return "\t" + Fp.join(" ", mods) + " " + type + " " + name + (value==null ? "" : " = " + value) + ";\n"; - } - } - - public static class JLCtor extends JLMethod{ - public JLCtor(String mods, String name, Object... args) { - super(mods, "", name, args); - } - - @Override public String toString(){ - this.type = ""; - return super.toString(); - } - } - - public static class JLReturn{ - public Object target; - public JLReturn(Object target){ - this.target = target; - } - @Override public String toString(){ - return "return " + target + ";"; - } - } - - public static class JLMethod{ - public List jdoc = new ArrayList(); - public Set attrs = new TreeSet(); - public Set mods = new TreeSet(); - public String type; - public String name; - public List args = new ArrayList(); - public List body = new ArrayList(); - - public JLMethod(){} - public JLMethod(String mods, String type, String name, Object... args) { - this.mods.addAll(Arrays.asList(mods.split("\\s"))); - this.type = type; - this.name = name; - this.args.addAll(Arrays.asList(args)); - } - - @Override public String toString(){ - StringWriter out = new StringWriter(); - if(jdoc.size() > 0){ - out.append("\t/**\n"); - out.append("\t * " + Fp.join("\n\t * ", jdoc)); - out.append("\t */\n"); - } - out.append("\t" + Fp.join(" ", attrs) + " " + Fp.join(" ", mods) + " " + type + " " + name + "(" + Fp.join(", ", args) + "){\n"); - out.append("\t\t" + Fp.join("\n\t\t", body) + "\n"); - out.append("\t}\n"); - return out.toString(); - } - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/NTypeMerger.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/NTypeMerger.java deleted file mode 100644 index a1ad5658050..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/NTypeMerger.java +++ /dev/null @@ -1,190 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.utils; - -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.apple.internal.jobjc.generator.model.types.NType; -import com.apple.internal.jobjc.generator.model.types.NType.NArray; -import com.apple.internal.jobjc.generator.model.types.NType.NBitfield; -import com.apple.internal.jobjc.generator.model.types.NType.NClass; -import com.apple.internal.jobjc.generator.model.types.NType.NField; -import com.apple.internal.jobjc.generator.model.types.NType.NObject; -import com.apple.internal.jobjc.generator.model.types.NType.NPointer; -import com.apple.internal.jobjc.generator.model.types.NType.NPrimitive; -import com.apple.internal.jobjc.generator.model.types.NType.NSelector; -import com.apple.internal.jobjc.generator.model.types.NType.NStruct; -import com.apple.internal.jobjc.generator.model.types.NType.NUnion; -import com.apple.internal.jobjc.generator.model.types.NType.NUnknown; -import com.apple.internal.jobjc.generator.model.types.NType.NVoid; -import com.apple.internal.jobjc.generator.utils.Fp.Dispatcher; -import com.apple.internal.jobjc.generator.utils.Fp.Map2; -import com.apple.jobjc.JObjCRuntime.Width; - -/** - * Merges two NTypes. All merge does is fill out missing information. It doesn't choose the larger primitive when there's a conflict or anything like that. - * - * Example: - *
- * a: {_NSRect={_NSPoint="x"f"y"f}"size"{_NSSize=ff}}
- * b: {_NSRect="origin"{_NSPoint=ff}{_NSSize="width"f"height"f}}
- * c: {_NSRect="origin"{_NSPoint="x"f"y"f}"size"{_NSSize="width"f"height"f}}
- *
- */ -public class NTypeMerger { - public static class MergeFailed extends RuntimeException{ - public MergeFailed(String reason, Object a, Object b){ - super(reason - + " -- (" + a.getClass().getSimpleName() + ") a: " + a - + " -- (" + b.getClass().getSimpleName() + ") b: " + b); - } - } - - private static NTypeMerger INST = new NTypeMerger(); - public static NTypeMerger inst(){ return INST; } - - /** - * Merge a and b. - */ - public NType merge(NType a, NType b) throws MergeFailed{ - if(a!=null && b==null) return a; - if(a==null && b!=null) return b; - if(a==null && b==null) return null; - if(a.equals(b)) return a; - try { - return Dispatcher.dispatch(getClass(), this, "accept", a, b); - } catch (NoSuchMethodException e) { - throw new MergeFailed("a and b are of different NType", a, b); - } - } - - private static Collection emptyNames = Arrays.asList(null, "", "?"); - /** - * Merge two identifiers: - * - If they're equal, return one. - * - If one is null, "", "?", return the other one. - * - else throw MergeFailed - * - * Exception: Due to a bug in BridgeSupport, this will return - * a (the first arg) instead of throwing MergeFailed. - */ - public String mergeName(String a, String b) throws MergeFailed{ - if(QA.bothNullOrEquals(a, b)) return a; - if(emptyNames.contains(a) && !emptyNames.contains(b)) return b; - if(emptyNames.contains(b) && !emptyNames.contains(a)) return a; - return a; // HACK BS bug #5954843 -// throw new MergeFailed("a and b have different names"); - } - - private Map mergeMap(Map a, Map b) throws MergeFailed{ - if(a.equals(b)) return a; - Map ret = new HashMap(); - Set keys = new HashSet(Fp.append(a.keySet(), b.keySet())); - for(Object key : keys){ - Object ai = a.get(key); - Object bi = b.get(key); - if(ai != null && bi == null) ret.put(key, ai); - else if(ai == null && bi != null) ret.put(key, bi); - else if(ai.equals(bi)) ret.put(key, ai); - else throw new MergeFailed("a and b are different", ai, bi); - } - return ret; - } - - public Map mergeSizeOf(Map a, Map b) throws MergeFailed{ - return mergeMap(a, b); - } - - public Map mergeOffset(Map a, Map b) throws MergeFailed{ - return mergeMap(a, b); - } - - // - - private void mustEqual(NType a, NType b){ - if(!a.equals(b)) throw new MergeFailed("a must equal b", a, b); - } - - protected NType accept(NBitfield a, NBitfield b) { - mustEqual(a, b); - return a; - } - - protected NType accept(NPrimitive a, NPrimitive b) { - mustEqual(a, b); - return a; - } - - protected NType accept(NPointer a, NPointer b) { - return new NPointer(NTypeMerger.inst().merge(a.subject, b.subject)); - } - - // Merge structs - - protected NField mergeNFields(NField a, NField b) { - return new NField(mergeName(a.name, b.name), - NTypeMerger.inst().merge(a.type, b.type), - mergeOffset(a.offset, b.offset)); - } - - protected NStruct mergeStructs(NStruct a, NStruct b){ - if(a.fields.size() != b.fields.size()) - throw new MergeFailed("a and b have different numbers of fields", a, b); - - List fields = Fp.map2(new Map2(){ - public NField apply(NField f32, NField f64) { return mergeNFields(f32, f64); } - }, a.fields, b.fields); - - return new NStruct(mergeName(a.name, b.name), - fields, mergeSizeOf(a.sizeof, b.sizeof)); - } - - protected NType accept(NStruct a, NStruct b) { - return mergeStructs(a, b); - } - - protected NType accept(NUnion a, NUnion b) { - NStruct nst = mergeStructs(a, b); - return new NUnion(nst.name, Fp.map(NUnion.zeroOffsets, nst.fields), nst.sizeof); - } - - protected NType accept(NArray a, NArray b) { - if(a.length != b.length) - throw new MergeFailed("a and b are of different sizes", a, b); - return new NArray(a.length, NTypeMerger.inst().merge(a.type, b.type)); - } - - protected NType accept(NVoid a, NVoid b) { return NVoid.inst(); } - protected NType accept(NObject a, NObject b) { return NObject.inst(); } - protected NType accept(NClass a, NClass b) { return NClass.inst(); } - protected NType accept(NSelector a, NSelector b) { return NSelector.inst(); } - protected NType accept(NUnknown a, NUnknown b) { return NUnknown.inst(); } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/NTypeParser.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/NTypeParser.java deleted file mode 100644 index 850076280a2..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/NTypeParser.java +++ /dev/null @@ -1,273 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.utils; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import com.apple.internal.jobjc.generator.model.types.NType; -import com.apple.internal.jobjc.generator.model.types.NType.NArray; -import com.apple.internal.jobjc.generator.model.types.NType.NBitfield; -import com.apple.internal.jobjc.generator.model.types.NType.NClass; -import com.apple.internal.jobjc.generator.model.types.NType.NObject; -import com.apple.internal.jobjc.generator.model.types.NType.NPointer; -import com.apple.internal.jobjc.generator.model.types.NType.NPrimitive; -import com.apple.internal.jobjc.generator.model.types.NType.NSelector; -import com.apple.internal.jobjc.generator.model.types.NType.NStruct; -import com.apple.internal.jobjc.generator.model.types.NType.NUnion; -import com.apple.internal.jobjc.generator.model.types.NType.NUnknown; -import com.apple.internal.jobjc.generator.model.types.NType.NVoid; - -/** - * NTypeParser (Native Type Parser) parses type & type64 attributes from BridgeSupport. - * - * See Obj-C Language: Type Encodings - */ -public abstract class NTypeParser { - // ** Parser entry point - - private static Map cached = new HashMap(); - public static NType parseFrom(String s) { - if(!cached.containsKey(s)) cached.put(s, parseFrom(new StringStream(s))); - return cached.get(s); - } - - // ** Parser driver - - private static List PARSERS = new ArrayList( - Arrays.asList(new NBitfieldParser(), new NPrimitiveParser(), new NVoidParser(), - new NPointerParser(), new NStructParser(), new NUnionParser(), - new NObjectParser(), new NClassParser(), new NSelectorParser(), - new NArrayParser(), new NUnknownParser(), new NSpecifierParser())); - - protected static NType parseFrom(StringStream ss) { - if(ss.left() == 0) - return null; - try{ - for(NTypeParser nt : PARSERS) - if(nt.parsePossible(ss)) - return nt.parse(ss); - } - catch(RuntimeException x){ - throw new RuntimeException("Exception while parsing '" + ss.remainingToString() - + "' from '" + ss.toString() + "'", x); - } - throw new RuntimeException("Found no parser for '" + ss.remainingToString() - + "' from '" + ss.toString() + "'"); - } - - // ** Methods for parsers - - protected abstract boolean parsePossible(StringStream ss); - protected abstract NType parse(StringStream ss); - - // ** Individual parsers - - public static class NBitfieldParser extends NTypeParser{ - @Override protected boolean parsePossible(StringStream ss) { - return ss.left() >= 2 && ss.peekAt(0) == 'b' && Character.isDigit(ss.peekAt(1)); - } - - @Override protected NType parse(StringStream ss) { - assert parsePossible(ss); - ss.eat('b'); - return new NBitfield(Integer.parseInt(ss.readWhileDigits())); - } - } - - public static class NPrimitiveParser extends NTypeParser{ - @Override protected boolean parsePossible(StringStream ss) { - return NPrimitive.CODES.contains(ss.peek()); - } - - @Override protected NType parse(StringStream ss) { - assert parsePossible(ss); - return NPrimitive.inst(ss.read()); - } - } - - public static class NVoidParser extends NTypeParser{ - @Override protected boolean parsePossible(StringStream ss) { - return ss.peek() == 'v'; - } - - @Override protected NType parse(StringStream ss) { - ss.eat('v'); - return NVoid.inst(); - } - } - - public static class NPointerParser extends NTypeParser{ - private static NPointer CHAR_PTR = new NPointer(NPrimitive.inst('C')); - - @Override protected boolean parsePossible(StringStream ss) { - return (ss.left() >= 2 && ss.peek() == '^') || (ss.peek() == '*'); - } - - @Override protected NType parse(StringStream ss) { - if(ss.peek() == '*'){ - ss.eat('*'); - return CHAR_PTR; - } - else{ - ss.eat('^'); - return new NPointer(NTypeParser.parseFrom(ss)); - } - } - } - - public static class NStructParser extends NTypeParser{ - protected char getOpen(){ return '{'; }; - protected char getClose(){ return '}'; }; - - @Override protected boolean parsePossible(StringStream ss) { - return ss.left() >= 2 && ss.peek() == getOpen(); - } - - @Override protected NType parse(StringStream ss) { - assert parsePossible(ss); - // {_NSRect= - // "origin"{_NSPoint="x"f"y"f} - // "size"{_NSSize="width"f"height"f}} - ss.eat(getOpen()); - String cname = ss.readUntilEither("=" + getClose()); - List fields = new ArrayList(); - if(ss.peek() == '='){ - ss.eat('='); - while(ss.peek() != getClose()){ - String fname = ""; - if(ss.peek() == '"'){ - ss.eat('"'); - fname = ss.readUntil('"'); - ss.eat('"'); - } - NType type = NTypeParser.parseFrom(ss); - fields.add(new NStruct.NField(fname, type)); - } - } - ss.eat(getClose()); - return getNew(cname, fields); - } - - protected NType getNew(String cname, List fields){ - return new NStruct(cname, fields); - } - } - - // A Union is very much like a Struct. - public static class NUnionParser extends NStructParser{ - @Override protected char getOpen(){ return '('; }; - - @Override protected char getClose(){ return ')'; }; - - @Override protected NType getNew(String cname, List fields){ - return new NUnion(cname, Fp.map(NUnion.zeroOffsets, fields)); - } - } - - public static class NArrayParser extends NTypeParser{ - @Override protected boolean parsePossible(StringStream ss) { - return ss.peek() == '['; - } - - @Override protected NType parse(StringStream ss) { - ss.eat('['); - int size = Integer.parseInt(ss.readWhileDigits()); - NType type = NTypeParser.parseFrom(ss); - ss.eat(']'); - return new NArray(size, type); - } - } - - public static class NObjectParser extends NTypeParser{ - @Override protected boolean parsePossible(StringStream ss) { - return ss.peek() == '@'; - } - - @Override protected NType parse(StringStream ss) { - ss.eat('@'); - return NObject.inst(); - } - } - - public static class NClassParser extends NTypeParser{ - @Override protected boolean parsePossible(StringStream ss) { - return ss.peek() == '#'; - } - - @Override protected NType parse(StringStream ss) { - ss.eat('#'); - return NClass.inst(); - } - } - - public static class NSelectorParser extends NTypeParser{ - @Override protected boolean parsePossible(StringStream ss) { - return ss.peek() == ':'; - } - - @Override protected NType parse(StringStream ss) { - ss.eat(':'); - return NSelector.inst(); - } - } - - public static class NUnknownParser extends NTypeParser{ - @Override protected boolean parsePossible(StringStream ss) { - return ss.peek() == '?'; - } - - @Override protected NType parse(StringStream ss) { - ss.eat('?'); - return NUnknown.inst(); - } - } - - /** - * Specifier Encoding - * const r - * in n - * inout N - * out o - * bycopy O - * oneway V - */ - public static class NSpecifierParser extends NTypeParser{ - private static Collection SPECS = Arrays.asList('r', 'n', 'N', 'o', 'O', 'V'); - @Override protected boolean parsePossible(StringStream ss) { - return SPECS.contains(ss.peek()); - } - - @Override protected NType parse(StringStream ss) { - assert parsePossible(ss); - ss.seek(); // XXX Just ignore specs for now and return the affected type. - return NTypeParser.parseFrom(ss); - } - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/NTypePrinter.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/NTypePrinter.java deleted file mode 100644 index 07ba7259e37..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/NTypePrinter.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.utils; - -import java.io.StringWriter; - -import com.apple.internal.jobjc.generator.model.types.NType; -import com.apple.internal.jobjc.generator.model.types.NType.NArray; -import com.apple.internal.jobjc.generator.model.types.NType.NBitfield; -import com.apple.internal.jobjc.generator.model.types.NType.NClass; -import com.apple.internal.jobjc.generator.model.types.NType.NField; -import com.apple.internal.jobjc.generator.model.types.NType.NObject; -import com.apple.internal.jobjc.generator.model.types.NType.NPointer; -import com.apple.internal.jobjc.generator.model.types.NType.NPrimitive; -import com.apple.internal.jobjc.generator.model.types.NType.NSelector; -import com.apple.internal.jobjc.generator.model.types.NType.NStruct; -import com.apple.internal.jobjc.generator.model.types.NType.NUnion; -import com.apple.internal.jobjc.generator.model.types.NType.NUnknown; -import com.apple.internal.jobjc.generator.model.types.NType.NVoid; -import com.apple.internal.jobjc.generator.utils.Fp.Dispatcher; - -/** - * Print an NType to the BridgeSupport encoding. - */ -public class NTypePrinter{ - private static NTypePrinter INST = new NTypePrinter(); - public static NTypePrinter inst(){ return INST; } - - public String print(NType nt){ - try { - return Dispatcher.dispatch(getClass(), this, "accept", nt); - } catch (NoSuchMethodException e) { - throw new RuntimeException(e); - } - } - - protected String accept(NBitfield nt) { - return "b" + nt.length; - } - - protected String accept(NPrimitive nt) { - return Character.toString(nt.type); - } - - protected String accept(NPointer nt) { - if(nt.subject instanceof NPrimitive && ((NPrimitive) nt.subject).type == 'C') - return "*"; - else - return "^" + print(nt.subject); - } - - protected String printStruct(NStruct nt, char open, char close){ - StringWriter sw = new StringWriter(); - sw.append(open); - sw.append(nt.name); - if(nt.fields.size() > 0){ - sw.append('='); - for(NField f : nt.fields){ - if(f.name != null && f.name.length() > 0) - sw.append("\"" + f.name + "\""); - sw.append(print(f.type)); - } - } - sw.append(close); - return sw.toString(); - } - - protected String accept(NStruct nt) { - return printStruct(nt, '{', '}'); - } - - protected String accept(NUnion nt) { - return printStruct(nt, '(', ')'); - } - - protected String accept(NArray nt) { - return "[" + nt.length + print(nt.type) + "]"; - } - - protected String accept(NObject nt) { return "@"; } - protected String accept(NVoid nt) { return "v"; } - protected String accept(NClass nt) { return "#"; } - protected String accept(NSelector nt) { return ":"; } - protected String accept(NUnknown nt) { return "?"; } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/ObjectInspector.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/ObjectInspector.java deleted file mode 100644 index e54ba340987..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/ObjectInspector.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.utils; - -import java.io.StringWriter; -import java.lang.reflect.Field; - -public abstract class ObjectInspector { - /** - * @return a string representation of object internals. - */ - public static String inspect(Object obj) { - StringWriter sw = new StringWriter(); - inspectForClass(obj, obj.getClass(), sw); - return sw.toString(); - } - - private static void inspectForClass(Object instance, Class clazz, StringWriter sw){ - boolean willGoSuper = clazz.getSuperclass() != null && !clazz.getSuperclass().getName().equals("java.lang.Object"); - - sw.append(clazz.getSimpleName()); - sw.append("{"); - Field[] fs = clazz.getDeclaredFields(); - for(int i = 0; i < fs.length; i++){ - Field f = fs[i]; - f.setAccessible(true); - sw.append(f.getName()); - sw.append(": "); - try { - Object o = f.get(instance); - sw.append(o == null ? "null" : o.toString()); - } catch (IllegalArgumentException ex) { - throw new RuntimeException(ex); - } catch (IllegalAccessException ex) { - throw new RuntimeException(ex); - } - if(i < fs.length - 1 || willGoSuper) - sw.append(", "); - } - - if(willGoSuper){ - sw.append("super: "); - inspectForClass(instance, clazz.getSuperclass(), sw); - } - - sw.append("}"); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/StringStream.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/StringStream.java deleted file mode 100644 index 448d4be12e6..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/StringStream.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.utils; - -import java.io.StringWriter; - -/** - * Stream-like class backed by a string. Useful for parsers. - */ -public class StringStream{ - private String data; - private int pos; - - public StringStream(String s){ - QA.nonNull(s); - this.data = s; - this.pos = 0; - } - - /** - * Number of characters left. - */ - public int left(){ return data.length() - pos; } - - /** - * Are there any characters left? - */ - public boolean atEOF(){ return left() <= 0; } - - /** - * Read next character. - */ - public char read(){ return data.charAt(pos++); } - - /** - * Read n characters and return string. - */ - public String readN(int n){ - String s = data.substring(pos, pos + n); - pos += n; - return s; - } - - /** - * Read until the next char is c, and return the string. - */ - public String readUntil(char c){ - int ix = data.indexOf(c, pos); - if(ix == -1) throw new RuntimeException("readUntil did not find character '" + c + "'"); - return readN(data.indexOf(c, pos) - pos); - } - - /** - * Read until the next char is one in s, and return the string. - */ - public String readUntilEither(String s) { - int ix = Integer.MAX_VALUE; - - for(char c : s.toCharArray()){ - int ixx = data.indexOf(c, pos); - if(ixx >= 0 && ixx < ix) - ix = ixx; - } - - if(ix == -1) throw new RuntimeException("readUntilEither did not find any character in '" + s + "'"); - return readN(ix - pos); - } - - public String readWhile(String s) { - StringWriter sw = new StringWriter(); - while(s.indexOf(peek()) != -1) - sw.append(read()); - return sw.toString(); - } - - public String readWhileDigits() { - return readWhile("0123456789"); - } - - /** - * @return the nth char from the current position. - */ - public char peekAt(int n){ return data.charAt(pos + n); } - - /** - * @return the next n chars. - */ - public String peekN(int n){ return data.substring(pos, pos + n); } - - /** - * @return the next char. - */ - public char peek(){ return peekAt(0); } - - /** - * Skip n chars ahead. - */ - public void seekN(int n){ pos += n; } - - /** - * Skip 1 char ahead. - */ - public void seek(){ seekN(1); } - - /** - * If the next character is c, seek over it. Otherwise throw RuntimeException. - */ - public void eat(char c) { - if(peek() != c) throw new RuntimeException("Parser expected '" + c + "' but got '" + peek() + "'."); - seek(); - } - - /** - * If the next characters are the same as those in s, seek over them. Otherwise throw RuntimeException. - */ - public void eat(String s) { - String pn = peekN(s.length()); - if(!pn.equals(s)) throw new RuntimeException("Parser expected '" + s + "' but got '" + pn + "'."); - seekN(s.length()); - } - - @Override - public String toString(){ - return data; - } - - /** - * @return the remaining characters as a String. - */ - public String remainingToString() { - return data.substring(pos); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/StructOffsetResolver.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/StructOffsetResolver.java deleted file mode 100644 index c207aae323a..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/StructOffsetResolver.java +++ /dev/null @@ -1,255 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.utils; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileWriter; -import java.io.InputStreamReader; -import java.io.PrintWriter; -import java.util.Arrays; -import java.util.Collection; -import java.util.Map; -import java.util.Set; -import java.util.TreeSet; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import com.apple.internal.jobjc.generator.Utils; -import com.apple.internal.jobjc.generator.model.Framework; -import com.apple.internal.jobjc.generator.model.Struct; -import com.apple.internal.jobjc.generator.model.types.NType; -import com.apple.internal.jobjc.generator.model.types.TypeCache; -import com.apple.internal.jobjc.generator.model.types.NType.NField; -import com.apple.internal.jobjc.generator.model.types.NType.NStruct; -import com.apple.internal.jobjc.generator.utils.Fp.Map1; -import com.apple.jobjc.JObjCRuntime.Width; -import java.util.Date; - -/** - * Takes a framework, compiles a native source file with all its structs, - * and figures out their sizes and field offsets. - */ -public class StructOffsetResolver { - public void resolve(Collection fws){ - try { - _resolve(fws); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - protected void _resolve(final Collection fws) throws Exception{ - for(final Framework fw : fws){ - for(final Width width : Width.values()){ - System.out.println("SOR -- Getting Struct offsets @" + width + " for " + fw.name); - String nativeSrc = generateFileForFramework(fw, width); - String executable = compileObjC(nativeSrc, width); - execute(executable, new Map1(){ - public Object apply(String ln) { - try { - processLine(ln, fws, width); - return null; - } catch (Exception e) { - throw new RuntimeException(e); - } - } - }); - } - } - } - - static Set alwaysHeaders_shared = new TreeSet(Arrays.asList( - "", - "\"/System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/Headers/HIToolbox.h\"")); - static Map> alwaysHeaders = Fp.litMap( - Width.W32, alwaysHeaders_shared, - Width.W64, alwaysHeaders_shared); - - static Set bannedHeaders_shared = new TreeSet(Arrays.asList( - "NSJavaSetup.h", "IMKInputController.h", "NSSimpleHorizontalTypesetter.h", "NSSpellServer.h", "IMKServer.h", "IKImageBrowserCell.h")); - static Map> bannedHeaders = Fp.litMap( - Width.W32, bannedHeaders_shared, - Width.W64, Fp.appendSet(bannedHeaders_shared, - Arrays.asList("npapi.h", "npruntime.h", "npfunctions.h"))); - - // We can cache the last accessed framework because, 99% of the time, - // the caller will ask for the same one, over and over again. - protected Framework cachedFw; - protected Framework findFrameworkByName(Collection fws, String name){ - if(cachedFw != null && cachedFw.name.equals(name)) - return cachedFw; - cachedFw = null; - for(Framework fw : fws) - if(fw.name.equals(name)){ - cachedFw = fw; - break; - } - return cachedFw; - } - - protected void processLine(String ln, Collection fws, Width arch) throws Exception{ - System.out.println("\tSOR '" + ln + "'"); - if(ln.trim().length() == 0) return; - Pattern stinfo = Pattern.compile("^(.*) (.*):(\\d+).*$"); - Matcher m = stinfo.matcher(ln); - if(!m.matches()) throw new RuntimeException("Failed to parse line from exec: " + ln); - String fwname = m.group(1); - String stname = m.group(2); - int stsize = Integer.parseInt(m.group(3)); - - Framework fw = findFrameworkByName(fws, fwname); - - Struct st = fw.getStructByName(stname); - NStruct nst = wget(arch, st.type.type32, st.type.type64); - nst.sizeof.put(arch, stsize); - -// System.out.println(st.name + " : " + stsize); - - Pattern finfo = Pattern.compile(" (-?\\d+)"); - Matcher fm = finfo.matcher(ln); - int fi = 0; - while(fm.find()){ - NField sf = nst.fields.get(fi++); - sf.offset.put(arch, Integer.parseInt(fm.group(1))); -// System.out.println("\t" + sf.name + " : " + off); - } - - TypeCache.inst().pingType(st.type); - } - - /** - * Generates Objective-C file and returns absolute path name. - */ - private String generateFileForFramework(Framework fw, Width arch) throws Exception{ - File tempfile = File.createTempFile("JObjC-SOR-" + fw.name + "-" + arch + "-", ".mm"); - PrintWriter out = new PrintWriter(new FileWriter(tempfile)); - out.println("#include"); - printHeaderLines(fw, arch, out); - out.println(""); - out.println("int main(int argc, char** argv){"); - printStructInfos(fw, arch, out); - out.println("\treturn 0;"); - out.println("}"); - out.close(); - return tempfile.getAbsolutePath(); - } - - protected void execute(String executable, Fp.Map1 lineProcessor) throws Exception { -// System.out.println(">>>> Executing " + new Date().toString()); - Process p = Runtime.getRuntime().exec(new String[]{executable}); - - if(lineProcessor != null){ - BufferedReader stdout = new BufferedReader(new InputStreamReader(p.getInputStream())); - String line; - while ((line = stdout.readLine()) != null) - lineProcessor.apply(line); - stdout.close(); - } - p.waitFor(); - if(p.exitValue() != 0) - throw new RuntimeException(executable + " did not execute successfully: " + p.exitValue()); - } - - private static Map gccFlag = Fp.litMap(Width.W32, "-m32", Width.W64, "-m64"); - - static boolean isDone(Process p){ - try{ - p.exitValue(); - return true; - } - catch(Exception x){ - return false; - } - } - - protected static String compileObjC(String nativeSrc, Width arch) throws Exception { - String execPath = nativeSrc.replace(".mm", ""); - Process p = Runtime.getRuntime().exec(new String[]{ - "llvm-g++", "-Wall", gccFlag.get(arch), "-ObjC++", "-framework", "Foundation", "-o", execPath, nativeSrc - }); - BufferedReader stdout = new BufferedReader(new InputStreamReader(p.getInputStream())); - BufferedReader stderr = new BufferedReader(new InputStreamReader(p.getErrorStream())); - while(!isDone(p)){ - while(stdout.ready()) System.out.println(stdout.readLine()); - while(stderr.ready()) System.out.println(stderr.readLine()); - } - p.waitFor(); - while(stdout.ready() || stderr.ready()){ - if(stdout.ready()) System.out.println(stdout.readLine()); - if(stderr.ready()) System.out.println(stderr.readLine()); - } - if(p.exitValue() != 0) - throw new RuntimeException("gcc did not compile '" + nativeSrc + "' successfully: " + p.exitValue()); - return execPath; - } - - static void printStructInfos(Framework fw, Width arch, PrintWriter out){ - for(Struct st : fw.structs){ - NStruct nst = wget(arch, st.type.type32, st.type.type64); - out.println("std::cout << \"" + fw.name + " " + st.name + "\" << ':' << sizeof("+st.name+")"); - for(NField sf : nst.fields){ - out.print("\t<< ' ' << "); - out.println(sf.type instanceof NType.NBitfield - ? "-1" - : "offsetof("+st.name+","+sf.name+")"); - } - out.println("\t<< std::endl;"); - } - } - - static void printHeaderLines(Framework fw, Width arch, PrintWriter out) throws Exception { - Collection always = alwaysHeaders.get(arch); - Collection banned = bannedHeaders.get(arch); - out.println("#define COREFOUNDATION_CFPLUGINCOM_SEPARATE 0"); - for(String header : always) - out.println("#import " + header); - - out.println("#undef COREFOUNDATION_CFPLUGINCOM_SEPARATE"); - String umbrella = fw.path + "/Headers/" + fw.name; - if(new File(umbrella).exists()) - out.println("#import \"" + umbrella + "\""); - - for(File header : getHeaders(fw)) - if(!banned.contains(header.getName())) - out.println("#import \"" + header.getAbsolutePath() + "\""); - } - - static A wget(Width arch, B x32, B x64){ - switch(arch){ - case W32: return (A) x32; - case W64: return (A) x64; - default: throw new RuntimeException(); - } - } - - /** - * Gets the absolute path to every header in FOO.framework/Headers - */ - static Collection getHeaders(Framework fw) throws Exception { - String hpath = fw.path + "/Headers"; - return Utils.find(new File(hpath), "^.*\\.h$", ""); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/StructOffsetResolverBigBang.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/StructOffsetResolverBigBang.java deleted file mode 100644 index 212df7734b5..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/StructOffsetResolverBigBang.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.utils; - -import java.io.File; -import java.io.FileWriter; -import java.io.PrintWriter; -import java.util.Collection; - -import com.apple.internal.jobjc.generator.model.Framework; -import com.apple.internal.jobjc.generator.utils.Fp.Map1; -import com.apple.jobjc.JObjCRuntime.Width; - -/** - * Takes a framework, compiles a native source file with all its structs, - * and figures out their sizes and field offsets. - * - * BigBang significantly speeds up the process by - * compiling all frameworks as one big Objective-C file. - */ -public class StructOffsetResolverBigBang extends StructOffsetResolver{ - - @Override protected void _resolve(final Collection fws) throws Exception{ - for(final Width arch : Width.values()){ - System.out.println("SORBB -- Getting Struct offsets @" + arch.toString()); - String nativeSrc = generateFileForFrameworks(fws, arch); - String executable = compileObjC(nativeSrc, arch); - execute(executable, new Map1(){ - public Object apply(String ln) { - try { - processLine(ln, fws, arch); - return null; - } catch (Exception e) { - throw new RuntimeException(e); - } - } - }); - } - } - - /** - * Generates Objective-C file and returns absolute path name. - */ - protected String generateFileForFrameworks(final Collection fws, final Width arch) throws Exception{ - File tempfile = File.createTempFile("JObjC-SORBB-" + arch + "-", ".mm"); - PrintWriter out = new PrintWriter(new FileWriter(tempfile)); - - out.println("#include"); - for(Framework fw : fws) printHeaderLines(fw, arch, out); - out.println("int main(int argc, char** argv){"); - for(Framework fw : fws) printStructInfos(fw, arch, out); - out.println("\treturn 0;"); - out.println("}"); - - out.close(); - return tempfile.getAbsolutePath(); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/jobjc/SuperClassExtractor.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/jobjc/SuperClassExtractor.java deleted file mode 100644 index cc0b3f9047c..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/jobjc/SuperClassExtractor.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - -import java.util.Map; - -import com.apple.internal.jobjc.generator.model.Clazz; - -/* - * Isolating all the reflection trickery to hijack the runtime into giving up its secrets - * without actually having a full working version of JObjC. Below is a bunch of evil reflection, - * but it allows the generated output to have a cleaner design. - */ -public class SuperClassExtractor { - public static Clazz getSuperClassFor(final String className, final MacOSXFramework nativeFramework, final Map allClasses) throws Throwable { - final NSClass nativeClass = new NSClass(className, nativeFramework.getRuntime()); - final NSClass nativeSuperClass = UnsafeRuntimeAccess.getSuperClass(nativeClass); - final String superClassName = UnsafeRuntimeAccess.getClassNameFor(nativeSuperClass); - if ("nil".equals(superClassName)) return null; - - final Clazz superClazz = allClasses.get(superClassName); - if (superClazz != null) return superClazz; - - final Clazz superClazzX = getSuperClassFor(superClassName, nativeFramework, allClasses); - System.out.print("[Warning] class \"" + superClassName + "\" not found in bridge support files, "); - System.out.println("using \"" + superClazzX.name + "\" as superclass for \"" + className + "\""); - return superClazzX; - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/jobjc/UnsafeRuntimeAccess.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/jobjc/UnsafeRuntimeAccess.java deleted file mode 100644 index 556ba97021a..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/jobjc/UnsafeRuntimeAccess.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - -import com.apple.jobjc.Invoke.FunCall; -import com.apple.jobjc.Invoke.MsgSend; - -public class UnsafeRuntimeAccess { - public static NativeArgumentBuffer getNativeBuffer() { - return NativeArgumentBuffer.getThreadLocalBuffer(JObjCRuntime.getInstance()); - } - - public static String getClassNameFor(final long obj) { - return NSClass.getClassNameOfClass(obj); - } - - public static String getClassNameFor(final NSClass cls) { - return NSClass.getClassNameOfClass(cls.ptr); - } - - public static NSClass getSuperClass(final NSClass clazz) { - return clazz.getSuperClass(); - } - - public static String getDescriptionForPtr(final long objPtr) { - return ID.getNativeDescription(objPtr); - } - - public static MacOSXFramework getFramework(final String[] frameworkLibs) { - return new MacOSXFramework(JObjCRuntime.getInstance(), frameworkLibs); - } - - public static FunCall createFunCall(final MacOSXFramework framework, final String fxnName, final Coder returnCoder, final Coder ... argCoders) { - return new FunCall(framework, fxnName, returnCoder, argCoders); - } - - public static MsgSend createMsgSend(final NSClass clazz, final String selName, final Coder returnCoder, final Coder ... argCoders) { - return new MsgSend(clazz.getRuntime(), selName, returnCoder, argCoders); - } - - public static NSClass getNSClass(final MacOSXFramework framework, final String name) { - return new NSClass(name, framework.getRuntime()); - } - - public static long getObjPtr(final ID obj) { - return obj.ptr; - } -} diff --git a/jdk/src/macosx/native/jobjc/src/runtime-additions/java/com/apple/jobjc/Utils.java b/jdk/src/macosx/native/jobjc/src/runtime-additions/java/com/apple/jobjc/Utils.java deleted file mode 100644 index a22851de4cb..00000000000 --- a/jdk/src/macosx/native/jobjc/src/runtime-additions/java/com/apple/jobjc/Utils.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - -import java.util.concurrent.Callable; - -import com.apple.jobjc.foundation.NSNumber; -import com.apple.jobjc.foundation.NSString; - -public class Utils { - JObjCRuntime runtime; - Utils(JObjCRuntime runtime){ this.runtime = runtime; } - - private static Utils utils; - public static Utils get() { - JObjCRuntime runtime = JObjCRuntime.getInstance(); // enforce security check - return utils != null ? utils : (utils = new Utils(runtime)); - } - - private Strings strings_; - public Strings strings() { - return strings_ != null ? strings_ : (strings_ = new Strings(runtime)); - } - - private Numbers numbers_; - public Numbers numbers() { - return numbers_ != null ? numbers_ : (numbers_ = new Numbers(runtime)); - } - - private Threads threads_; - public Threads threads() { - return threads_ != null ? threads_ : (threads_ = new Threads(runtime)); - } - - public static class Strings { - private static native long getNativeNSStringForJavaString(final String javaString); - private static native String getNativeJavaStringForNSString(final long nsString); - - JObjCRuntime runtime; - Strings(JObjCRuntime runtime) { this.runtime = runtime; } - - public NSString nsString(final String str) { - if (str == null) return null; - final long nsString = getNativeNSStringForJavaString(str); - return ID.createNewObjCObjectForClass(NSString.class, nsString, runtime); - } - - public String javaString(final NSString str) { - if (str == null) return null; - return getNativeJavaStringForNSString(((ID)str).ptr); - } - -// static public CString cStringForJavaString(final String str) { -// return null; -// } - } - - public static class Numbers { - private static native long getNativeNSNumberForJavaNumber(final Number num); - private static native Number getNativeJavaNumberForNSNumber(final long num); - - JObjCRuntime runtime; - Numbers(JObjCRuntime runtime) { this.runtime = runtime; } - - public NSNumber nsNumber(final Number num) { - if (num == null) return null; - final long nsNumber = getNativeNSNumberForJavaNumber(num); - return ID.createNewObjCObjectForClass(NSNumber.class, nsNumber, runtime); - } - - public Number javaNumber(final NSNumber num) { - if (num == null) return null; - return getNativeJavaNumberForNSNumber(((ID)num).ptr); - } - } - - public static class Threads { - private static native void performRunnableOnMainThread(final Runnable runnable, final boolean wait); - private static native V performCallableOnMainThread(final Callable callable) throws Exception; - - JObjCRuntime runtime; - Threads(JObjCRuntime runtime) { this.runtime = runtime; } - - /** - * Perform callable on main thread. Exceptions that are thrown on the main thread are ignored. - */ - public void performOnMainThread(final Runnable runnable, final boolean wait) { - performRunnableOnMainThread(runnable, wait); - } - - /** - * Perform callable on main thread, block until done, and return the result. - * This also catches any exceptions on the main thread, brings them back and throws them to the caller. - */ - public V performOnMainThread(final Callable callable) throws Exception{ - return performCallableOnMainThread(callable); - } - } -} diff --git a/jdk/src/macosx/native/jobjc/src/runtime-additions/native/NativeNumber.m b/jdk/src/macosx/native/jobjc/src/runtime-additions/native/NativeNumber.m deleted file mode 100644 index 395f46fb211..00000000000 --- a/jdk/src/macosx/native/jobjc/src/runtime-additions/native/NativeNumber.m +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "com_apple_jobjc_Utils_Numbers.h" - -#include - -/* - * Class: com_apple_jobjc_Utils_Numbers - * Method: getNativeNSNumberForJavaNumber - * Signature: (Ljava/lang/Number;)J - */ -JNIEXPORT jlong JNICALL Java_com_apple_jobjc_Utils_00024Numbers_getNativeNSNumberForJavaNumber -(JNIEnv *env, jclass clazz, jobject javaNumber) -{ - return ptr_to_jlong(JNFJavaToNSNumber(env, javaNumber)); -} - -/* - * Class: com_apple_jobjc_Utils_Numbers - * Method: getNativeJavaNumberForNSNumber - * Signature: (J)Ljava/lang/Number; - */ -JNIEXPORT jobject JNICALL Java_com_apple_jobjc_Utils_00024Numbers_getNativeJavaNumberForNSNumber -(JNIEnv *env, jclass clazz, jlong nativeNumber) -{ - return JNFNSToJavaNumber(env, (NSNumber *)jlong_to_ptr(nativeNumber)); -} diff --git a/jdk/src/macosx/native/jobjc/src/runtime-additions/native/NativeString.m b/jdk/src/macosx/native/jobjc/src/runtime-additions/native/NativeString.m deleted file mode 100644 index 1e01545555d..00000000000 --- a/jdk/src/macosx/native/jobjc/src/runtime-additions/native/NativeString.m +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "com_apple_jobjc_Utils_Strings.h" - -#include - -/* - * Class: com_apple_jobjc_Utils_Strings - * Method: getNativeNSStringForJavaString - * Signature: (Ljava/lang/String;)J - */ -JNIEXPORT jlong JNICALL Java_com_apple_jobjc_Utils_00024Strings_getNativeNSStringForJavaString -(JNIEnv *env, jclass clazz, jstring javaString) -{ - return ptr_to_jlong(JNFJavaToNSString(env, javaString)); -} - -/* - * Class: com_apple_jobjc_Utils_Strings - * Method: getNativeJavaStringForNSString - * Signature: (J)Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL Java_com_apple_jobjc_Utils_00024Strings_getNativeJavaStringForNSString -(JNIEnv *env, jclass clazz, jlong nativeString) -{ - return JNFNSToJavaString(env, (NSString *)jlong_to_ptr(nativeString)); -} diff --git a/jdk/src/macosx/native/jobjc/src/runtime-additions/native/NativeThread.m b/jdk/src/macosx/native/jobjc/src/runtime-additions/native/NativeThread.m deleted file mode 100644 index 75062e44e0c..00000000000 --- a/jdk/src/macosx/native/jobjc/src/runtime-additions/native/NativeThread.m +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "com_apple_jobjc_Utils_Threads.h" - -#import -#import - - -@interface JObjCCallable : NSObject { - @public jobject returnValue; - @public jthrowable exception; -} -@property jobject returnValue; -@property jthrowable exception; -- (void) performCallable:(JNFJObjectWrapper *)callableWrapper; -@end - -/* - * Class: com_apple_jobjc_Utils_Threads - * Method: performRunnableOnMainThreadNative - * Signature: (Ljava/lang/Runnable;Z)V - */ -JNIEXPORT void JNICALL Java_com_apple_jobjc_Utils_00024Threads_performRunnableOnMainThread -(JNIEnv *env, jclass clazz, jobject runnable, jboolean jWaitUntilDone) -{ -JNF_COCOA_ENTER(env); - [JNFRunLoop performOnMainThreadWaiting:jWaitUntilDone - withBlock:[JNFRunnable blockWithRunnable:runnable - withEnv:env]]; -JNF_COCOA_EXIT(env); -} - -/* - * Class: com_apple_jobjc_Utils_Threads - * Method: performCallableOnMainThreadNative - * Signature: (Ljava/util/concurrent/Callable;)Ljava/lang/Object; - */ -JNIEXPORT jobject JNICALL Java_com_apple_jobjc_Utils_00024Threads_performCallableOnMainThread -(JNIEnv *env, jclass clazz, jobject callable) -{ - jobject returnValue = NULL; - -JNF_COCOA_ENTER(env); - JNFJObjectWrapper *callableWrapper = [[JNFJObjectWrapper alloc] initWithJObject:callable withEnv:env]; - JObjCCallable *ncallable = [JObjCCallable alloc]; - - [ncallable performSelectorOnMainThread:@selector(performCallable:) - withObject:callableWrapper - waitUntilDone:true]; - - returnValue = ncallable.returnValue; - jthrowable exception = ncallable.exception; - - [ncallable release]; - if(exception) (*env)->Throw(env, exception); - -JNF_COCOA_EXIT(env); - - return returnValue; -} - - -@implementation JObjCCallable -@synthesize returnValue; -@synthesize exception; - -- (void) performCallable:(JNFJObjectWrapper *)callableWrapper { - static JNF_CLASS_CACHE(jc_Callable, "java/util/concurrent/Callable"); - static JNF_MEMBER_CACHE(jm_Callable_call, jc_Callable, "call", "()Ljava/lang/Object;"); - - JNFThreadContext threadWasAttached = JNFThreadDetachOnThreadDeath; - JNIEnv *env = JNFObtainEnv(&threadWasAttached); - jobject callable = [callableWrapper jObject]; - - @try{ - self.returnValue = JNFCallObjectMethod(env, callable, jm_Callable_call); - } @catch (JNFException *x) { - [x raiseToJava:env]; - } - - self.exception = (*env)->ExceptionOccurred(env); - (*env)->ExceptionClear(env); - - [callableWrapper release]; - JNFReleaseEnv(env, &threadWasAttached); -} - -@end diff --git a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/BaseBench.java b/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/BaseBench.java deleted file mode 100644 index dbbb80cd31f..00000000000 --- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/BaseBench.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - -import sun.misc.Unsafe; - -public class BaseBench extends PooledTestCase { - protected final static JObjCRuntime RUNTIME = JObjCRuntime.getInstance(); - protected final static JObjC JOBJC = JObjC.getInstance(); - protected final static Unsafe UNSAFE = JObjCRuntime.getInstance().unsafe; - protected final static NativeArgumentBuffer ARGS = JObjCRuntime.getInstance().getThreadLocalState(); - - public abstract static class Task{ - final String name; - public Task(String name){ this.name = name; } - public abstract void run(); - } - - public void bench(final String title, final long warmup, final long runs, final long iterations, final Task... tasks){ - final long[] runtimes = new long[tasks.length]; - - for(int t = 0; t < tasks.length; ++t){ - long runtime = 0; - for(int i = 0; i < warmup; ++i) - singleBench(iterations, tasks[t]); - for(int i = 0; i < runs; ++i) - runtime = runtime + singleBench(iterations, tasks[t]); - runtimes[t] = runtime; - } - - final float[] relatives = new float[tasks.length]; - - for(int t = 0; t < tasks.length; ++t) - relatives[t] = ((float) runtimes[t] / (float) runs); - - float min = relatives[0]; - for(float t : relatives) - if(t < min) - min = t; - - for(int t = 0; t < tasks.length; ++t) - relatives[t] = relatives[t] / min; - - System.out.format("\n* %1$s\n", title); - for(int t = 0; t < tasks.length; ++t) - System.out.format("%1$60s : %2$.1f\n", tasks[t].name, relatives[t]); - } - - public long singleBench(final long iterations, final Task task){ - long start = System.currentTimeMillis(); - for(long i = 0; i < iterations; ++i) - task.run(); - long end = System.currentTimeMillis(); - return end - start; - } -} diff --git a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/BenchFunCall.java b/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/BenchFunCall.java deleted file mode 100644 index 417ad6d1187..00000000000 --- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/BenchFunCall.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - -import com.apple.jobjc.Invoke.FunCall; -import com.apple.jobjc.PrimitiveCoder.DoubleCoder; - -public final class BenchFunCall extends BaseBench{ - final static int ITERS = 1000; - final static FunCall fc = new FunCall(JObjCRuntime.getInstance(), "sin", DoubleCoder.INST, DoubleCoder.INST); - final static double ARG = 3.14159265 / 2.0; - final static double RET = 1.0; - - private static native double jniSin(double arg); - - public void testBench(){ - this.bench("Calling functions", 5, 3, 10000L, - - new Task("JNI Invoke"){ - @Override public void run() { - for(int i = 0; i < ITERS; ++i) - jniSin(ARG); - }}, - - new Task("JObjC FunCall"){ - @Override public void run() { - for(int i = 0; i < ITERS; ++i){ - fc.init(ARGS); - DoubleCoder.INST.push(ARGS, ARG); - fc.invoke(ARGS); - DoubleCoder.INST.pop(ARGS); - } - }}, - - new Task("JObjC FunCall (inlined)"){ - @Override public void run() { - for(int i = 0; i < ITERS; ++i){ - // init - ARGS.argPtrsPtr = ARGS.buffer.bufferPtr; - ARGS.argValuesPtr = ARGS.buffer.bufferPtr + 256; - // push double - //// push arg ptr - if(JObjCRuntime.IS64) - UNSAFE.putLong(ARGS.argPtrsPtr, ARGS.argValuesPtr); - else - UNSAFE.putInt(ARGS.argPtrsPtr, (int) ARGS.argValuesPtr); - ARGS.argPtrsPtr += JObjCRuntime.PTR_LEN; - //// push arg value - UNSAFE.putDouble(ARGS.argValuesPtr, ARG); - ARGS.argValuesPtr += 8; - // invoke - FunCall.invoke(fc.cif.cif.bufferPtr, fc.fxnPtr, ARGS.retValPtr, ARGS.buffer.bufferPtr); - // pop - UNSAFE.getDouble(ARGS.retValPtr); - } - }} - ); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/BenchIDPop.java b/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/BenchIDPop.java deleted file mode 100644 index b24059b3644..00000000000 --- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/BenchIDPop.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - -import com.apple.jobjc.foundation.FoundationFramework; -import com.apple.jobjc.foundation.NSString; - -public class BenchIDPop extends BaseBench{ - static native long jniNSStringAlloc(); - static native long jniNSStringAllocAndRetain(); - static native long jniNSStringCached(); - static native void jniCFRetain(long x); - static native void jniCFRelease(long x); - - final static int ITERS = 1000; - final static FoundationFramework FND = JOBJC.Foundation(); - - private static class LongWrap{ - long l; - public LongWrap(long l){ this.l = l; } - } - - public void testIt(){ - bench("Alloc, retain, pop a new NSString", 2, 3, 2000, - new Task("jniNSStringAllocAndRetain()"){ - @Override public void run() { - for(int i = 0; i < ITERS; i++) - jniNSStringAllocAndRetain(); - }}, - - new Task("new LongWrap(jniNSStringAllocAndRetain())"){ - @Override public void run() { - for(int i = 0; i < ITERS; i++) - new LongWrap(jniNSStringAllocAndRetain()); - }}, - - new Task("FND.NSString().alloc()"){ - @Override public void run() { - for(int i = 0; i < ITERS; i++) - FND.NSString().alloc(); - }}, - - new Task("new NSString(jniNSStringAlloc(), RUNTIME)"){ - @Override public void run() { - for(int i = 0; i < ITERS; i++) - new NSString(jniNSStringAlloc(), RUNTIME); - }} - ); - - final long nsstringPtr = jniNSStringAlloc(); - - bench("Get and hold an existing object", 2, 3, 2000, - new Task("jniCFRetain(nsstringPtr)"){ - @Override public void run() { - for(int i = 0; i < ITERS; i++) - jniCFRetain(nsstringPtr); - }}, - - new Task("jniCFRetain(new LongWrap(nsstringPtr).l"){ - @Override public void run() { - for(int i = 0; i < ITERS; i++) - jniCFRetain(new LongWrap(nsstringPtr).l); - }}, - - new Task("ID.getInstance(nsstringPtr, RUNTIME)"){ - @Override public void run() { - for(int i = 0; i < ITERS; i++) - ID.getInstance(nsstringPtr, RUNTIME); - }} - ); - } - -} diff --git a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/BenchStructCoding.java b/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/BenchStructCoding.java deleted file mode 100644 index 9d0a769805a..00000000000 --- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/BenchStructCoding.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - -import com.apple.jobjc.Coder.StructCoder; -import com.apple.jobjc.Invoke.FunCall; -import com.apple.jobjc.foundation.FoundationFramework; -import com.apple.jobjc.foundation.NSRect; - -public class BenchStructCoding extends BaseBench { - final static FoundationFramework FND = JOBJC.Foundation(); - final static int ITERS = 1000; - final static PrimitiveCoder CODER = com.apple.jobjc.MixedPrimitiveCoder.FloatDoubleCoder; - final static StructCoder RCODER = NSRect.getStructCoder(); - final static FunCall nsMakePoint = - new com.apple.jobjc.Invoke.FunCall(FND, "NSMakeRect", com.apple.jobjc.foundation.NSRect.getStructCoder(), - com.apple.jobjc.MixedPrimitiveCoder.FloatDoubleCoder, - com.apple.jobjc.MixedPrimitiveCoder.FloatDoubleCoder, - com.apple.jobjc.MixedPrimitiveCoder.FloatDoubleCoder, - com.apple.jobjc.MixedPrimitiveCoder.FloatDoubleCoder); - - public void testFoo(){ - bench("NSMakeRect", 3, 3, 10, - new Task("FND.NSMakeRect"){ - @Override public void run() { - for(int i = 0; i < ITERS; ++i){ - NSRect s = FND.NSMakeRect(0, 1, 2, 3); -// assertEquals(1.0D, s.origin().y()); - } - }}, - - new Task("nsMakeRect.invoke(..., s)"){ - @Override public void run() { - for(int i = 0; i < ITERS; ++i){ - nsMakePoint.init(ARGS); - CODER.push(ARGS, 0.0D); - CODER.push(ARGS, 1.0D); - CODER.push(ARGS, 2.0D); - CODER.push(ARGS, 3.0D); - NSRect s = FND.makeNSRect(); - nsMakePoint.invoke(ARGS, s); -// assertEquals(1.0D, s.origin().y()); - } - }}, - - new Task("nsMakeRect.invoke(..); NSRect r = pop(..);"){ - @Override public void run() { - for(int i = 0; i < ITERS; ++i){ - nsMakePoint.init(ARGS); - CODER.push(ARGS, 0.0D); - CODER.push(ARGS, 1.0D); - CODER.push(ARGS, 2.0D); - CODER.push(ARGS, 3.0D); - nsMakePoint.invoke(ARGS); - NSRect s = (NSRect) RCODER.pop(ARGS); -// assertEquals(1.0D, s.origin().y()); - } - }} - ); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/BenchUnsafe.java b/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/BenchUnsafe.java deleted file mode 100644 index f04c99d3dc8..00000000000 --- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/BenchUnsafe.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - -import java.nio.ByteBuffer; - -public class BenchUnsafe extends BaseBench{ - final static int ITERS = 1000000; - - final static NativeBuffer NBUF = new NativeBuffer(2 * ITERS); - final static ByteBuffer BBUF = NBUF.buffer; - final static long ADDR = NBUF.bufferPtr; - final static long ADDR_MAX = NBUF.bufferPtr + ITERS; - - final static NativeBuffer NBUF2 = new NativeBuffer(2 * ITERS); - final static ByteBuffer BBUF2 = NBUF2.buffer; - final static long ADDR2 = NBUF2.bufferPtr; - final static long ADDR2_MAX = NBUF2.bufferPtr + ITERS; - - final static long ARG = 345; - - final static long BUFSIZE = BBUF.limit(); - - public void testIt(){ - this.bench("Memory writes", 5, 3, 100L, - - new Task("buffer.putLong"){ - @Override public void run() { - for(long i = 0; i < ITERS; i++) - BBUF.putLong((int) i, ARG); - }}, - - new Task("unsafe.putLong"){ - @Override public void run() { - for(long i = ADDR; i < ADDR_MAX; i++) - UNSAFE.putLong(i, ARG); - }}); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/CategoryTest.java b/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/CategoryTest.java deleted file mode 100644 index b762d7e9bb2..00000000000 --- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/CategoryTest.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - -import com.apple.jobjc.appkit.AppKitFramework; -import com.apple.jobjc.appkit.NSStringCategory; -import com.apple.jobjc.foundation.NSSize; -import com.apple.jobjc.foundation.NSString; - -public class CategoryTest extends PooledTestCase { - public void testAppKit_NSString(){ - AppKitFramework APPKIT = JObjC.getInstance().AppKit(); - - NSString nstr = Utils.get().strings().nsString("mirzapirza"); - NSStringCategory nstrx = APPKIT.NSStringCategory(nstr); - NSSize sz = nstrx.sizeWithAttributes(null); - - assertEquals(57.0, sz.width()); - assertEquals(15.0, sz.height()); - } - - public static void main(String[] args){ - junit.textui.TestRunner.run(CategoryTest.class); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/FunctionTest.java b/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/FunctionTest.java deleted file mode 100644 index 00e3c4deac1..00000000000 --- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/FunctionTest.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - -import com.apple.jobjc.Coder.PointerCoder; -import com.apple.jobjc.Coder.PrimitivePointerCoder; -import com.apple.jobjc.Coder.VoidCoder; -import com.apple.jobjc.Invoke.FunCall; - -public class FunctionTest extends PooledTestCase { - NativeArgumentBuffer nativeBuffer; - JObjCRuntime runtime; - - @Override - public void setUp() throws Exception { - super.setUp(); - nativeBuffer = UnsafeRuntimeAccess.getNativeBuffer(); - runtime = nativeBuffer.runtime; - } - - public void testInvokeNoParamNoReturn() throws Throwable { - final FunCall fxn = UnsafeRuntimeAccess.createFunCall(TestUtils.getAppKit(), "NSBeep", VoidCoder.INST); - - fxn.init(nativeBuffer); - fxn.invoke(nativeBuffer); - } - - public void testInvokeNoParams() throws Throwable { - final FunCall fxn = UnsafeRuntimeAccess.createFunCall(TestUtils.getFoundation(), "NSFullUserName", PointerCoder.INST); - - fxn.init(nativeBuffer); - fxn.invoke(nativeBuffer); - - final long ptr = PrimitivePointerCoder.INST.pop(nativeBuffer); - System.out.println("0x" + Long.toHexString(ptr) + ": " + UnsafeRuntimeAccess.getDescriptionForPtr(ptr)); - } - - public void testInvokeOneParam() throws Throwable { - final FunCall getHomeDirFxn = UnsafeRuntimeAccess.createFunCall(TestUtils.getAppKit(), "NSHomeDirectory", PointerCoder.INST); - - getHomeDirFxn.init(nativeBuffer); - getHomeDirFxn.invoke(nativeBuffer); - - final long homeDirPtr = PrimitivePointerCoder.INST.pop(nativeBuffer); - System.out.println("0x" + Long.toHexString(homeDirPtr) + ": " + UnsafeRuntimeAccess.getDescriptionForPtr(homeDirPtr)); - - final FunCall getTypeOfFxn = UnsafeRuntimeAccess.createFunCall(TestUtils.getFoundation(), "NSLog", PointerCoder.INST, PointerCoder.INST); - getTypeOfFxn.init(nativeBuffer); - PrimitivePointerCoder.INST.push(runtime, nativeBuffer, homeDirPtr); - getTypeOfFxn.invoke(nativeBuffer); - - // long typePtr = PointerCoder.pointer_coder.popPtr(nativeBuffer); - // System.out.println("0x" + Long.toHexString(typePtr) + ": " + TestUtils.getDescriptionForPtr(typePtr)); - } - - public static void main(final String[] args) { - junit.textui.TestRunner.run(FunctionTest.class); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/GUIDemo.java b/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/GUIDemo.java deleted file mode 100644 index c9a3f46b05e..00000000000 --- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/GUIDemo.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - -import com.apple.jobjc.Utils.Strings; -import com.apple.jobjc.appkit.NSApplication; -import com.apple.jobjc.appkit.NSButton; -import com.apple.jobjc.appkit.NSDrawer; -import com.apple.jobjc.appkit.NSMenu; -import com.apple.jobjc.appkit.NSWindow; -import com.apple.jobjc.foundation.NSAutoreleasePool; -import com.apple.jobjc.foundation.NSObject; -import com.apple.jobjc.foundation.NSObjectClass; -import com.apple.jobjc.foundation.NSRect; -import com.apple.jobjc.foundation.NSSize; - -class MyDelegate extends NSObject{ - static final JObjC objc = JObjC.getInstance(); - static final Strings str = Utils.get().strings(); - - public MyDelegate(long ptr, JObjCRuntime r) { super(ptr, r); } - - private NSWindow myWindow; - private NSDrawer myDrawer; - - public void printHello(ID sender){ - System.out.println("Hello!"); - myDrawer.toggle(this); - } - - public void createMenu(){ - NSMenu menu = objc.AppKit().NSMenu().newID(); - menu.addItemWithTitle_action_keyEquivalent( - str.nsString("Quit"), - new SEL("terminate:"), - str.nsString("q")); - NSApplication app = objc.AppKit().NSApp(); - app.setMainMenu(menu); - } - - public void createWindow(){ - NSRect rect; - int styleMask = objc.AppKit().NSTitledWindowMask() | objc.AppKit().NSMiniaturizableWindowMask(); - NSButton myButton; - NSSize buttonSize; - myButton = objc.AppKit().NSButton().newID(); - myButton.setTitle(str.nsString("Print Hello!")); - myButton.sizeToFit(); - myButton.setTarget(this); - myButton.setAction(new SEL("printHello:")); - buttonSize = myButton.frame().size(); - rect = objc.Foundation().NSMakeRect(100, 100, 2*buttonSize.width(), 2*buttonSize.height()); - myWindow = objc.AppKit().NSWindow().alloc(); - myWindow = myWindow.initWithContentRect_styleMask_backing_defer( - rect, styleMask, objc.AppKit().NSBackingStoreBuffered(), false); - myWindow.setTitle(str.nsString("This is a test window.")); - myWindow.setContentView(myButton); - - myDrawer = objc.AppKit().NSDrawer().alloc(); - myDrawer = myDrawer.initWithContentSize_preferredEdge( - objc.Foundation().NSMakeSize(100, 40), objc.Foundation().NSMinYEdge()); - myDrawer.setParentWindow(myWindow); - } - - public void applicationWillFinishLaunching(ID not){ - createMenu(); - createWindow(); - } - - public void applicationDidFinishLaunching(ID not){ - myWindow.makeKeyAndOrderFront(null); - } -} - -class MyDelegateClass extends NSObjectClass{ - public MyDelegateClass(JObjCRuntime r){ super(r); } -} - -public class GUIDemo{ - static final JObjC objc = JObjC.getInstance(); - - public static void main(String[] args){ - JObjCRuntime.getInstance().registerUserClass(MyDelegate.class, MyDelegateClass.class); - - objc.AppKit().NSApplication().sharedApplication(); - NSApplication app = objc.AppKit().NSApp(); - - NSAutoreleasePool pool = objc.Foundation().NSAutoreleasePool().alloc(); - pool = pool.init(); - app.setDelegate(new MyDelegateClass(JObjCRuntime.getInstance()).newID()); - app.run(); - pool.drain(); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/IBDemo.java b/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/IBDemo.java deleted file mode 100644 index dbfc1eff4a3..00000000000 --- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/IBDemo.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -/** - * To locate the nib correctly, this demo must run from - * a .app (created with Jar Bundler...). - * - * TODO Add .app/Jar Bundler as ant task - */ - -package com.apple.jobjc; - -import java.awt.Toolkit; - -import com.apple.jobjc.appkit.AppKitFramework; -import com.apple.jobjc.appkit.NSApplication; -import com.apple.jobjc.appkit.NSView; -import com.apple.jobjc.appkit.NSViewClass; -import com.apple.jobjc.foundation.FoundationFramework; -import com.apple.jobjc.foundation.NSRect; -import com.apple.jobjc.foundation.NSString; - -class MyView extends NSView{ - static final AppKitFramework APPKIT = JObjC.getInstance().AppKit(); - - public MyView(long objPtr, JObjCRuntime runtime) { super(objPtr, runtime); } - - @Override public void drawRect(NSRect r){ - APPKIT.NSColor().redColor().set(); - APPKIT.NSBezierPath().fillRect(r); - } -} - -class MyViewClass extends NSViewClass{ - protected MyViewClass(String name, JObjCRuntime runtime) { super(name, runtime); } - public MyViewClass(JObjCRuntime runtime){ this(MyView.class.getSimpleName(), runtime); } -} - -public class IBDemo{ - final static FoundationFramework FOUNDATION = JObjC.getInstance().Foundation(); - final static AppKitFramework APPKIT = JObjC.getInstance().AppKit(); - - // Works if the JVM is launched on the main thread, - // but JavaApplicationStub does not understand -XstartOnFirstThread - public static void mainWithAppMain(String[] args){ - APPKIT.NSApplicationMain(0, null); - } - - // Work around: let someone else init, and then - // get on the main thread to load the nib. - public static void mainWithoutAppMain(String[] args){ - Toolkit.getDefaultToolkit(); - - Utils.get().threads().performOnMainThread(new Runnable(){ - public void run() { - APPKIT.NSApplication().sharedApplication(); - NSApplication APP = APPKIT.NSApp(); - - NSString nibName = Utils.get().strings().nsString("MainMenu"); - boolean loadedNib = APPKIT.NSBundleCategory().loadNibNamed_owner(nibName, APP); - if(!loadedNib) throw new RuntimeException("Failed to load nib."); - }}, false); - } - - public static void main(String[] args){ - JObjCRuntime.getInstance().registerUserClass(MyView.class, MyViewClass.class); - mainWithoutAppMain(args); - //mainWithAppMain(args); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/IntroTest.java b/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/IntroTest.java deleted file mode 100644 index edd5f072575..00000000000 --- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/IntroTest.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - -import junit.framework.TestCase; - -import com.apple.jobjc.Invoke.FunCall; -import com.apple.jobjc.PrimitiveCoder.DoubleCoder; -import com.apple.jobjc.appkit.AppKitFramework; -import com.apple.jobjc.appkit.NSApplication; -import com.apple.jobjc.appkit.NSApplicationClass; -import com.apple.jobjc.appkit.NSColorPanel; -import com.apple.jobjc.appkit.NSWorkspace; -import com.apple.jobjc.foundation.FoundationFramework; -import com.apple.jobjc.foundation.NSAutoreleasePool; -import com.apple.jobjc.foundation.NSPoint; -import com.apple.jobjc.foundation.NSString; -import com.apple.jobjc.foundation.NSStringClass; - -public class IntroTest extends TestCase{ - // The low-level core makes function calls, sends messages, marshals data, etc. - public void testCore(){ - // pass security check and get ahold of a runtime (should cache this) - final JObjCRuntime RUNTIME = JObjCRuntime.getInstance(); - final NativeArgumentBuffer ARGS = JObjCRuntime.getInstance().getThreadLocalState(); - - // create a funcall (should cache this) - final FunCall fc = new FunCall(RUNTIME, "sin", DoubleCoder.INST, DoubleCoder.INST); - - // start function call - fc.init(ARGS); - // push an arg - DoubleCoder.INST.push(ARGS, 3.14159265 / 2.0); - // make the call - fc.invoke(ARGS); - // read the return value - double ret = DoubleCoder.INST.pop(ARGS); - - assertEquals(1.0, ret); - } - - // Frameworks bridge the Mac OS X frameworks - public void testFrameworks(){ - // First, get an instance of JObjC: - final JObjC JOBJC = com.apple.jobjc.JObjC.getInstance(); - - // It's your gateway to the frameworks. - final FoundationFramework FND = JOBJC.Foundation(); - final AppKitFramework APP = JOBJC.AppKit(); - - // From which you can then access... - - // enums, defines, constants - int nsmye = FND.NSMaxYEdge(); - boolean debug = FND.NSDebugEnabled(); - - // structs - NSPoint p = FND.makeNSPoint(); - p.setX(3); - assertEquals(3.0, p.x()); - - // C functions - NSPoint p2 = FND.NSMakePoint(12, 34); - assertEquals(12.0, p2.x()); - - // ... Let's create an AutoreleasePool before we go on - NSAutoreleasePool pool = ((NSAutoreleasePool) FND.NSAutoreleasePool().alloc()).init(); - - // Objective-C classes - NSStringClass nsc = FND.NSString(); - - // class-methods - NSString nsStringClassDescr = nsc.description(); - - // instances - NSString nsi = ((NSString) FND.NSString().alloc()).init(); - - // instance methods - NSString d = nsi.description(); - - // The bridge marshals some types for you, but it doesn't - // convert between NSString and Java String automatically. - // For that we use Utils.get().strings().nsString(String) - // and Utils.get().strings().javaString(NSString); - - assertEquals("NSString", Utils.get().strings().javaString(nsStringClassDescr)); - - NSString format = Utils.get().strings().nsString("Foo bar %d baz"); - - NSString formatted = ((NSString) FND.NSString().alloc()).initWithFormat(format, 34); - String jformatted = Utils.get().strings().javaString(formatted); - - assertEquals("Foo bar 34 baz", jformatted); - - // Reveal in Finder -// NSString file = Utils.get().strings().nsString( -// "/Applications/Calculator.app/Contents/Resources/Calculator.icns"); -// APP.NSWorkspace().sharedWorkspace() -// .selectFile_inFileViewerRootedAtPath(file, null); - - pool.drain(); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/NSClassTest.java b/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/NSClassTest.java deleted file mode 100644 index cbd5105737f..00000000000 --- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/NSClassTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - -import com.apple.jobjc.foundation.FoundationFramework; -import com.apple.jobjc.foundation.NSString; -import com.apple.jobjc.foundation.NSStringClass; - -public class NSClassTest extends PooledTestCase{ - JObjC JOBJC = JObjC.getInstance(); - FoundationFramework FND = JOBJC.Foundation(); - - public void testNSClassName(){ - NSString s = ((NSString) FND.NSString().alloc()).init(); - - NSString cname = s.className(); - String jcname = Utils.get().strings().javaString(cname); - assertEquals("NSCFString", jcname); - } - - public void testNSClassPop(){ - NSString s = ((NSString) FND.NSString().alloc()).init(); - - NSStringClass c = s.classNSClass(); - String jdescr = Utils.get().strings().javaString(c.description()); - assertEquals("NSCFString", jdescr); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/NativeBufferTest.java b/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/NativeBufferTest.java deleted file mode 100644 index a6c93ab382e..00000000000 --- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/NativeBufferTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - -import junit.framework.TestCase; - -public class NativeBufferTest extends TestCase{ - public void testSlicePtrs(){ - JObjC.getInstance(); - - NativeBuffer b = new NativeBuffer(123); - b.position(1); - NativeBuffer c = b.slice(); - assertEquals(b.bufferPtr + 1, c.bufferPtr); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/NativeTypeTest.java b/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/NativeTypeTest.java deleted file mode 100644 index fb352f78046..00000000000 --- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/NativeTypeTest.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - -import com.apple.internal.jobjc.generator.model.types.NType; -import com.apple.internal.jobjc.generator.utils.NTypeMerger; -import com.apple.internal.jobjc.generator.utils.NTypeParser; - -public class NativeTypeTest extends PooledTestCase{ - - private NType doParse(String type){ - NType nt = NTypeParser.parseFrom(type); - String printed = nt.toString(); - System.out.println("Original: " + type); - System.out.println("Printed.: " + printed); - assertEquals(type, printed); - return nt; - } - - // {_NSRect= - // "origin"{_NSPoint="x"f"y"f} - // "size"{_NSSize="width"f"height"f}} - public void testStruct(){ - doParse("{_NSRect=\"origin\"{_NSPoint=\"x\"f\"y\"f}\"size\"{_NSSize=\"width\"f\"height\"f}}"); - } - - // {IOBluetoothL2CAPChannelEvent= - // "eventType"i - // "u"(?= - // "data"{IOBluetoothL2CAPChannelDataBlock= - // "dataPtr"^v - // "dataSize"I} - // "writeRefCon"^v - // "padding"[32C]) - // "status"i} - public void testUnion(){ - doParse("{IOBluetoothL2CAPChannelEvent=\"eventType\"i\"u\"(?=\"data\"{IOBluetoothL2CAPChannelDataBlock=\"dataPtr\"^v\"dataSize\"I}\"writeRefCon\"^v\"padding\"[32C])\"status\"i}"); - } - - public void testUnknown(){ - doParse("{_CFSocketContext=\"version\"i\"info\"^v\"retain\"^?\"release\"^?\"copyDescription\"^?}"); - } - - public void testEmptyStruct(){ - doParse("{_CFSocketSignature=\"protocolFamily\"i\"socketType\"i\"protocol\"i\"address\"^{__CFData}}"); - } - - public void testCharPtr(){ - doParse("^*"); - } - - public void doEquals(final String s){ - assertEquals(doParse(s), doParse(s)); - } - - public void testEquals(){ - doEquals("{_NSRect=\"origin\"{_NSPoint=\"x\"f\"y\"f}\"size\"{_NSSize=\"width\"f\"height\"f}}"); - doEquals("{IOBluetoothL2CAPChannelEvent=\"eventType\"i\"u\"(?=\"data\"{IOBluetoothL2CAPChannelDataBlock=\"dataPtr\"^v\"dataSize\"I}\"writeRefCon\"^v\"padding\"[32C])\"status\"i}"); - doEquals("{_CFSocketContext=\"version\"i\"info\"^v\"retain\"^?\"release\"^?\"copyDescription\"^?}"); - doEquals("{_CFSocketSignature=\"protocolFamily\"i\"socketType\"i\"protocol\"i\"address\"^{__CFData}}"); - } - - public void testMerge(){ - NType a = doParse("{_NSRect={_NSPoint=\"x\"f\"y\"f}\"size\"{_NSSize=ff}}"); - NType b = doParse("{_NSRect=\"origin\"{_NSPoint=ff}{_NSSize=\"width\"f\"height\"f}}"); - NType c = NTypeMerger.inst().merge(a, b); - NType expected = doParse("{_NSRect=\"origin\"{_NSPoint=\"x\"f\"y\"f}\"size\"{_NSSize=\"width\"f\"height\"f}}"); - System.out.println("Merge results:"); - System.out.println("\ta: " + a.toString()); - System.out.println("\tb: " + b.toString()); - System.out.println("\tc: " + c.toString()); - System.out.println("\tx: " + expected.toString()); - assertEquals(expected, c); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/PooledTestCase.java b/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/PooledTestCase.java deleted file mode 100644 index f52c3860f47..00000000000 --- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/PooledTestCase.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - -import junit.framework.TestCase; - -import com.apple.jobjc.foundation.FoundationFramework; -import com.apple.jobjc.foundation.NSAutoreleasePool; - -public class PooledTestCase extends TestCase { - static{ - System.loadLibrary("JObjC-tests"); - } - NSAutoreleasePool pool; - - @Override public void setUp() throws Exception { - FoundationFramework foundation = JObjC.getInstance().Foundation(); - pool = foundation.NSAutoreleasePool().alloc(); - pool.init(); - } - - @Override public void tearDown() throws Exception { - pool.drain(); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/SELTest.java b/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/SELTest.java deleted file mode 100644 index 1fd94e12ec1..00000000000 --- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/SELTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - -import com.apple.jobjc.Coder.PointerCoder; -import com.apple.jobjc.Coder.PrimitivePointerCoder; -import com.apple.jobjc.Invoke.MsgSend; - -public class SELTest extends PooledTestCase { - - NativeArgumentBuffer nativeBuffer; - JObjCRuntime runtime; - - @Override - public void setUp() throws Exception { - super.setUp(); - nativeBuffer = UnsafeRuntimeAccess.getNativeBuffer(); - runtime = nativeBuffer.runtime; - } - - public void testGetBlackColor() throws Throwable { - final MacOSXFramework appKit = TestUtils.getAppKit(); - final NSClass clazz = UnsafeRuntimeAccess.getNSClass(appKit, "NSColor"); - final MsgSend sel = UnsafeRuntimeAccess.createMsgSend(clazz, "redColor", PointerCoder.INST); - - sel.init(nativeBuffer, clazz); - sel.invoke(nativeBuffer); - - final long blackColorPtr = PrimitivePointerCoder.INST.pop(nativeBuffer); - String dscr = UnsafeRuntimeAccess.getDescriptionForPtr(blackColorPtr); - - System.out.println("0x" + Long.toHexString(blackColorPtr) + ": " + dscr); - assertEquals("NSCalibratedRGBColorSpace 1 0 0 1", dscr); - } - - public static void main(final String[] args) { - junit.textui.TestRunner.run(SELTest.class); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/StructTest.java b/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/StructTest.java deleted file mode 100644 index b55e731fa58..00000000000 --- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/StructTest.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - -import java.io.StringWriter; - -import com.apple.jobjc.coreaudio.AudioBuffer; -import com.apple.jobjc.foundation.NSPoint; -import com.apple.jobjc.foundation.NSRect; - -public class StructTest extends PooledTestCase { - public void testSimpleStruct(){ - AudioBuffer b = JObjC.getInstance().CoreAudio().makeAudioBuffer(); - assertEquals(0, b.mNumberChannels()); - assertEquals(0, b.mDataByteSize()); - b.setMNumberChannels(1); - b.setMDataByteSize(3); - assertEquals(1, b.mNumberChannels()); - assertEquals(3, b.mDataByteSize()); - } - - public void testNestedStruct(){ - NSRect r = JObjC.getInstance().Foundation().makeNSRect(); - assertTrue(0f == r.size().width()); - r.size().setWidth(3f); - assertTrue(3f == r.size().width()); - assertTrue(r.size() == r.size()); - } - - public void testSTRET(){ - NSPoint point = JObjC.getInstance().Foundation().NSMakePoint(3, 4); - assertTrue(point.x() == 3); - assertTrue(point.y() == 4); - - NSRect rect = JObjC.getInstance().Foundation().NSMakeRect(0, 1, 2, 3); - assertTrue(rect.origin().x() == 0); - assertTrue(rect.origin().y() == 1); - assertTrue(rect.size().width() == 2); - assertTrue(rect.size().height() == 3); - } - - // - - private char halfByteToHex(int b){ - return (b >= 0x0 && b < 0xA) ? (char) ('0' + b) : (char) ('A' + (b-0xA)); - } - - private String byteToHexString(Byte b){ - StringWriter sw = new StringWriter(); - sw.append(halfByteToHex(b & 0xF)); - sw.append(halfByteToHex((b & 0xF0) >> 4)); - return sw.toString(); - } - - String print(Struct st){ - StringWriter sw = new StringWriter(); - st.raw.position(0); - sw.append(st.getClass().getSimpleName() + ":" + st.raw.limit() + " @ " + Long.toHexString(st.raw.bufferPtr) + " : "); - for(int i = 0; i < st.raw.limit(); i++){ - sw.append(byteToHexString(st.raw.get()) + " "); - if((i+1) % 4 == 0) - sw.append(" "); - } - System.out.println(sw.toString().trim()); - return sw.toString().trim(); - } - - public static void main(String[] args){ - junit.textui.TestRunner.run(StructTest.class); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/SubclassingTest.java b/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/SubclassingTest.java deleted file mode 100644 index bfe91440d2b..00000000000 --- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/SubclassingTest.java +++ /dev/null @@ -1,231 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - -import com.apple.jobjc.Coder.IDCoder; -import com.apple.jobjc.Coder.VoidCoder; -import com.apple.jobjc.Invoke.MsgSend; -import com.apple.jobjc.Invoke.MsgSendSuper; -import com.apple.jobjc.PrimitiveCoder.DoubleCoder; -import com.apple.jobjc.PrimitiveCoder.FloatCoder; -import com.apple.jobjc.PrimitiveCoder.SIntCoder; -import com.apple.jobjc.PrimitiveCoder.SLongLongCoder; -import com.apple.jobjc.foundation.NSObject; -import com.apple.jobjc.foundation.NSObjectClass; -import com.apple.jobjc.foundation.NSPoint; -import com.apple.jobjc.foundation.NSString; - -public class SubclassingTest extends PooledTestCase{ - JObjCRuntime runtime; - NativeArgumentBuffer ctx; - - @Override public void setUp() throws Exception{ - super.setUp(); - this.runtime = JObjCRuntime.getInstance(); - this.ctx = runtime.getThreadLocalState(); - - runtime.registerUserClass(MyObject.class, MyObjectClass.class); - } - - public void testClass(){ - final MyObjectClass cls = new MyObjectClass(runtime); - assertEquals(MyObject.class.getSimpleName(), UnsafeRuntimeAccess.getClassNameFor(cls)); - } - - public void testInst(){ - final MyObjectClass cls = new MyObjectClass(runtime); - final MyObject instObj = cls.alloc(); - final MyObject retrievedObj = Subclassing.getJObjectFromIVar(UnsafeRuntimeAccess.getObjPtr(instObj)); - assertTrue(instObj == retrievedObj); - } - - public void testVoidVoidMethod(){ - final MyObject instObj = new MyObjectClass(runtime).alloc(); - - assertEquals(0, instObj.myMethodHits); - MsgSend sel = new MsgSend(runtime, "myMethod", VoidCoder.INST); - sel.init(ctx, instObj); - sel.invoke(ctx); - assertEquals(1, instObj.myMethodHits); - } - - public void testMsgSendSuper(){ - final MyObjectClass cls = new MyObjectClass(runtime); - final MyObject obj = ((MyObject) cls.alloc()).init(); - - // direct descr - - assertEquals("foo", Utils.get().strings().javaString(obj.description())); - - // indirect (from native) descr - { - MsgSend msgSend = new MsgSend(runtime, "description", IDCoder.INST); - msgSend.init(ctx, obj); - msgSend.invoke(ctx); - assertEquals("foo", Utils.get().strings().javaString((NSString) IDCoder.INST.pop(ctx))); - } - - // indirect (from native) descr - { - MsgSendSuper msgSendSuper = new MsgSendSuper(runtime, "description", IDCoder.INST); - msgSendSuper.init(ctx, obj, cls); - msgSendSuper.invoke(ctx); - assertEquals("foo", Utils.get().strings().javaString((NSString) IDCoder.INST.pop(ctx))); - } - - // nso descr - { - MsgSendSuper msgSendSuper = new MsgSendSuper(runtime, "description", IDCoder.INST); - msgSendSuper.init(ctx, obj, JObjC.getInstance().Foundation().NSObject()); - msgSendSuper.invoke(ctx); - - final NSString nsod = (NSString) IDCoder.INST.pop(ctx); - String jde = Utils.get().strings().javaString(nsod); - assertEquals(jde.substring(0, 9), " 0) - js2 += jss; - return Utils.get().strings().nsString(js2); - } - - public double add_and_and(int a, long b, float c){ - return a + b + c; - } - - public NSPoint doubleIt(NSPoint p){ - System.out.println("Doubling NSPoint(" + p.x() + ", " + p.y() + ")."); - p.setX(p.x() * 2); - p.setY(p.y() * 2); - return p; - } - - @Override public NSString description(){ - return Utils.get().strings().nsString("foo"); - } -} - -class MyObjectClass extends NSObjectClass{ - protected MyObjectClass(String name, JObjCRuntime runtime) { - super(name, runtime); - } - - public MyObjectClass(JObjCRuntime runtime){ - this("MyObject", runtime); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/UtilsTest.java b/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/UtilsTest.java deleted file mode 100644 index b77a82f92af..00000000000 --- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/UtilsTest.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - -import java.util.concurrent.Callable; - -import com.apple.jobjc.foundation.NSString; - -public class UtilsTest extends PooledTestCase{ - public void testStrings(){ - String s = "fooBarBazDazzle"; - NSString ns = Utils.get().strings().nsString(s); - String t = Utils.get().strings().javaString(ns); - assertEquals(s, t); - } - - public void testThreadsPerformRunnableOnMainThread(){ - final long testThreadId = Thread.currentThread().getId(); - class Wrap{ public long x = testThreadId; } - final Wrap wrap = new Wrap(); - assertTrue(testThreadId == wrap.x); - - Utils.get().threads().performOnMainThread(new Runnable(){ - public void run() { - wrap.x = Thread.currentThread().getId(); - } - }, true); - - assertTrue(testThreadId != wrap.x); - } - - public void testThreadsPerformCallableOnMainThread() throws Exception{ - final long testThreadId = Thread.currentThread().getId(); - final long mainThreadId = Utils.get().threads().performOnMainThread(new Callable(){ - public Long call() { return Thread.currentThread().getId(); } - }); - assertTrue(testThreadId != mainThreadId); - } - - public void testThreadsPerformCallableOnMainThreadException() throws Exception{ - class FooException extends RuntimeException{} - try { - Utils.get().threads().performOnMainThread(new Callable(){ - public Object call() { throw new FooException(); } - }); - } catch (FooException e) { - return; - } - fail("Failed to catch exception."); - } - - public static void main(String[] args){ - junit.textui.TestRunner.run(UtilsTest.class); - } -} - diff --git a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/VarArgsTest.java b/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/VarArgsTest.java deleted file mode 100644 index 6d8774ece87..00000000000 --- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/VarArgsTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - -import com.apple.jobjc.foundation.FoundationFramework; -import com.apple.jobjc.foundation.NSDictionary; -import com.apple.jobjc.foundation.NSString; - -public class VarArgsTest extends PooledTestCase { - FoundationFramework FND = JObjC.getInstance().Foundation(); - - public void testNSString_initWithFormat(){ - String expected = "1 + 0.2 = 1.2 abracadabra"; - NSString format = Utils.get().strings().nsString("%d + %.1f = %.1f %@"); - - NSString abra = Utils.get().strings().nsString("abracadabra"); - - NSString nstr = ((NSString)FND.NSString().alloc()).initWithFormat(format, 1, 0.2, 1.2, abra); - String actual = Utils.get().strings().javaString(nstr); - - assertEquals(expected, actual); - } - - public void testNSDictionary(){ - NSString v1 = Utils.get().strings().nsString("value1"); - NSString v2 = Utils.get().strings().nsString("value2"); - NSString k1 = Utils.get().strings().nsString("key1"); - NSString k2 = Utils.get().strings().nsString("key2"); - - NSDictionary dict = ((NSDictionary)FND.NSDictionary().alloc()).initWithObjectsAndKeys(v1, k1, v2, k2, null); - - NSString nsdescr = dict.description(); - String jdescr = Utils.get().strings().javaString(nsdescr); - - assertEquals("{\n key1 = value1;\n key2 = value2;\n}", jdescr); - } - - public static void main(String[] args){ - junit.textui.TestRunner.run(VarArgsTest.class); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/tests/native/FunCallBench.m b/jdk/src/macosx/native/jobjc/src/tests/native/FunCallBench.m deleted file mode 100644 index 3c5f9adcc8f..00000000000 --- a/jdk/src/macosx/native/jobjc/src/tests/native/FunCallBench.m +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -#include -#include - -#include "com_apple_jobjc_BenchFunCall.h" -#include - -JNIEXPORT jdouble JNICALL Java_com_apple_jobjc_BenchFunCall_jniSin -(JNIEnv *env, jclass clazz, jdouble x) -{ - return (jdouble) sin((double) x); -} - - -#include "com_apple_jobjc_BenchIDPop.h" - -JNIEXPORT void JNICALL Java_com_apple_jobjc_BenchIDPop_jniCFRetain -(JNIEnv *env, jclass clazz, jlong x) -{ - CFRetain(jlong_to_ptr(x)); -} - -JNIEXPORT void JNICALL Java_com_apple_jobjc_BenchIDPop_jniCFRelease -(JNIEnv *env, jclass clazz, jlong x) -{ - CFRelease(jlong_to_ptr(x)); -} - -JNIEXPORT jlong JNICALL Java_com_apple_jobjc_BenchIDPop_jniNSStringAlloc -(JNIEnv *env, jclass clazz) -{ - return ptr_to_jlong([NSString alloc]); -} - -JNIEXPORT jlong JNICALL Java_com_apple_jobjc_BenchIDPop_jniNSStringAllocAndRetain -(JNIEnv *env, jclass clazz) -{ - return ptr_to_jlong(CFRetain([NSString alloc])); -} - -JNIEXPORT jlong JNICALL Java_com_apple_jobjc_BenchIDPop_jniNSStringCached -(JNIEnv *env, jclass clazz) -{ - static jlong str = 0; - if(!str) str = ptr_to_jlong([NSString alloc]); - return str; -} diff --git a/jdk/src/macosx/native/sun/awt/AWTView.m b/jdk/src/macosx/native/sun/awt/AWTView.m index 830fb77e82b..a59ff1a51ae 100644 --- a/jdk/src/macosx/native/sun/awt/AWTView.m +++ b/jdk/src/macosx/native/sun/awt/AWTView.m @@ -440,17 +440,20 @@ AWT_ASSERT_APPKIT_THREAD; JNIEnv *env = [ThreadUtilities getJNIEnv]; jstring characters = NULL; + jstring charactersIgnoringModifiers = NULL; if ([event type] != NSFlagsChanged) { characters = JNFNSToJavaString(env, [event characters]); + charactersIgnoringModifiers = JNFNSToJavaString(env, [event charactersIgnoringModifiers]); } static JNF_CLASS_CACHE(jc_NSEvent, "sun/lwawt/macosx/NSEvent"); - static JNF_CTOR_CACHE(jctor_NSEvent, jc_NSEvent, "(IISLjava/lang/String;)V"); + static JNF_CTOR_CACHE(jctor_NSEvent, jc_NSEvent, "(IISLjava/lang/String;Ljava/lang/String;)V"); jobject jEvent = JNFNewObject(env, jctor_NSEvent, [event type], [event modifierFlags], [event keyCode], - characters); + characters, + charactersIgnoringModifiers); CHECK_NULL(jEvent); static JNF_CLASS_CACHE(jc_PlatformView, "sun/lwawt/macosx/CPlatformView"); diff --git a/jdk/src/macosx/native/sun/awt/AWTWindow.m b/jdk/src/macosx/native/sun/awt/AWTWindow.m index 6a9c1166e84..5cb5621a159 100644 --- a/jdk/src/macosx/native/sun/awt/AWTWindow.m +++ b/jdk/src/macosx/native/sun/awt/AWTWindow.m @@ -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 @@ -252,6 +252,10 @@ AWT_ASSERT_APPKIT_THREAD; self.ownerWindow = owner; [self setPropertiesForStyleBits:styleBits mask:MASK(_METHOD_PROP_BITMASK)]; + if (IS(self.styleBits, IS_POPUP)) { + [self.nsWindow setCollectionBehavior:(1 << 8) /*NSWindowCollectionBehaviorFullScreenAuxiliary*/]; + } + return self; } diff --git a/jdk/src/macosx/native/sun/awt/CGraphicsDevice.m b/jdk/src/macosx/native/sun/awt/CGraphicsDevice.m index a1813b6154d..36df94b1236 100644 --- a/jdk/src/macosx/native/sun/awt/CGraphicsDevice.m +++ b/jdk/src/macosx/native/sun/awt/CGraphicsDevice.m @@ -57,7 +57,7 @@ static CFMutableArrayRef getAllValidDisplayModes(jint displayID){ CFArrayRef allModes = CGDisplayCopyAllDisplayModes(displayID, NULL); CFIndex numModes = CFArrayGetCount(allModes); - CFMutableArrayRef validModes = CFArrayCreateMutable(kCFAllocatorDefault, numModes + 1, NULL); + CFMutableArrayRef validModes = CFArrayCreateMutable(kCFAllocatorDefault, numModes + 1, &kCFTypeArrayCallBacks); CFIndex n; for (n=0; n < numModes; n++) { diff --git a/jdk/src/macosx/native/sun/awt/CWrapper.m b/jdk/src/macosx/native/sun/awt/CWrapper.m index 247358f0df9..bf0d6b2fccd 100644 --- a/jdk/src/macosx/native/sun/awt/CWrapper.m +++ b/jdk/src/macosx/native/sun/awt/CWrapper.m @@ -337,12 +337,17 @@ JNF_COCOA_EXIT(env); */ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CWrapper_00024NSWindow_setBackgroundColor -(JNIEnv *env, jclass cls, jlong windowPtr, jlong colorPtr) +(JNIEnv *env, jclass cls, jlong windowPtr, jint rgb) { JNF_COCOA_ENTER(env); NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr); - NSColor *color = (NSColor *)jlong_to_ptr(colorPtr); + CGFloat alpha = (((rgb >> 24) & 0xff) / 255.0); + CGFloat red = (((rgb >> 16) & 0xff) / 255.0); + CGFloat green = (((rgb >> 8) & 0xff) / 255.0); + CGFloat blue = (((rgb >> 0) & 0xff) / 255.0); + NSColor *color = [NSColor colorWithCalibratedRed:red green:green blue:blue + alpha:alpha]; [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [window setBackgroundColor:color]; }]; @@ -575,26 +580,3 @@ JNF_COCOA_ENTER(env); JNF_COCOA_EXIT(env); } - -/* - * Class: sun_lwawt_macosx_CWrapper$NSColor - * Method: clearColor - * Signature: ()J - */ -JNIEXPORT jlong JNICALL -Java_sun_lwawt_macosx_CWrapper_00024NSColor_clearColor -(JNIEnv *env, jclass cls) -{ - __block jlong clearColorPtr = 0L; - -JNF_COCOA_ENTER(env); - - [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ - clearColorPtr = ptr_to_jlong([NSColor clearColor]); - }]; - -JNF_COCOA_EXIT(env); - - return clearColorPtr; -} - diff --git a/jdk/src/macosx/native/sun/osxapp/ThreadUtilities.m b/jdk/src/macosx/native/sun/osxapp/ThreadUtilities.m index c7dd0b78726..7deb34d0baa 100644 --- a/jdk/src/macosx/native/sun/osxapp/ThreadUtilities.m +++ b/jdk/src/macosx/native/sun/osxapp/ThreadUtilities.m @@ -36,7 +36,7 @@ static JNIEnv *appKitEnv = NULL; static jobject appkitThreadGroup = NULL; static BOOL awtEmbedded = NO; -inline void attachCurrentThread(void** env) { +static inline void attachCurrentThread(void** env) { if ([NSThread isMainThread]) { JavaVMAttachArgs args; args.version = JNI_VERSION_1_4; diff --git a/jdk/src/share/back/debugInit.c b/jdk/src/share/back/debugInit.c index 25ffbffc91a..a1e366ec05f 100644 --- a/jdk/src/share/back/debugInit.c +++ b/jdk/src/share/back/debugInit.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, 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 @@ -202,8 +202,6 @@ Agent_OnLoad(JavaVM *vm, char *options, void *reserved) jint jvmtiCompileTimeMajorVersion; jint jvmtiCompileTimeMinorVersion; jint jvmtiCompileTimeMicroVersion; - char *boot_path = NULL; - char npt_lib[MAXPATHLEN]; /* See if it's already loaded */ if ( gdata!=NULL && gdata->isLoaded==JNI_TRUE ) { @@ -268,24 +266,6 @@ Agent_OnLoad(JavaVM *vm, char *options, void *reserved) forceExit(1); /* Kill entire process, no core dump wanted */ } - JVMTI_FUNC_PTR(gdata->jvmti, GetSystemProperty) - (gdata->jvmti, (const char *)"sun.boot.library.path", - &boot_path); - - dbgsysBuildLibName(npt_lib, sizeof(npt_lib), boot_path, NPT_LIBNAME); - /* Npt and Utf function init */ - NPT_INITIALIZE(npt_lib, &(gdata->npt), NPT_VERSION, NULL); - jvmtiDeallocate(boot_path); - if (gdata->npt == NULL) { - ERROR_MESSAGE(("JDWP: unable to initialize NPT library")); - return JNI_ERR; - } - gdata->npt->utf = (gdata->npt->utfInitialize)(NULL); - if (gdata->npt->utf == NULL) { - ERROR_MESSAGE(("JDWP: UTF function initialization failed")); - return JNI_ERR; - } - /* Parse input options */ if (!parseOptions(options)) { /* No message necessary, should have been printed out already */ @@ -1307,22 +1287,26 @@ debugInit_exit(jvmtiError error, const char *msg) if ( error != JVMTI_ERROR_NONE ) { exit_code = 1; if ( docoredump ) { + LOG_MISC(("Dumping core as requested by command line")); finish_logging(exit_code); abort(); } } + if ( msg==NULL ) { msg = ""; } LOG_MISC(("Exiting with error %s(%d): %s", jvmtiErrorText(error), error, msg)); - gdata->vmDead = JNI_TRUE; + if (gdata != NULL) { + gdata->vmDead = JNI_TRUE; - /* Let's try and cleanup the JVMTI, if we even have one */ - if ( gdata->jvmti != NULL ) { - /* Dispose of jvmti (gdata->jvmti becomes NULL) */ - disposeEnvironment(gdata->jvmti); + /* Let's try and cleanup the JVMTI, if we even have one */ + if ( gdata->jvmti != NULL ) { + /* Dispose of jvmti (gdata->jvmti becomes NULL) */ + disposeEnvironment(gdata->jvmti); + } } /* Finish up logging. We reach here if JDWP is doing the exiting. */ diff --git a/jdk/src/share/back/error_messages.c b/jdk/src/share/back/error_messages.c index d6207965497..9c2fdd72927 100644 --- a/jdk/src/share/back/error_messages.c +++ b/jdk/src/share/back/error_messages.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, 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 @@ -47,6 +47,7 @@ #include #include "util.h" +#include "utf_util.h" #include "proc_md.h" /* Maximim length of a message */ @@ -70,13 +71,8 @@ vprint_message(FILE *fp, const char *prefix, const char *suffix, len = (int)strlen((char*)utf8buf); /* Convert to platform encoding (ignore errors, dangerous area) */ - if (gdata->npt != NULL) { - (void)(gdata->npt->utf8ToPlatform)(gdata->npt->utf, - utf8buf, len, pbuf, MAX_MESSAGE_LEN); - } else { - /* May be called before NPT is initialized so don't fault */ - strncpy(pbuf, (char*)utf8buf, len); - } + (void)utf8ToPlatform(utf8buf, len, pbuf, MAX_MESSAGE_LEN); + (void)fprintf(fp, "%s%s%s", prefix, pbuf, suffix); } diff --git a/jdk/src/share/back/inStream.c b/jdk/src/share/back/inStream.c index 3c4d5b266d3..0e1ca3f18e4 100644 --- a/jdk/src/share/back/inStream.c +++ b/jdk/src/share/back/inStream.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2008, 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 @@ -24,6 +24,7 @@ */ #include "util.h" +#include "utf_util.h" #include "stream.h" #include "inStream.h" #include "transport.h" @@ -379,15 +380,12 @@ inStream_readString(PacketInputStream *stream) string[length] = '\0'; /* This is Standard UTF-8, convert to Modified UTF-8 if necessary */ - new_length = (gdata->npt->utf8sToUtf8mLength) - (gdata->npt->utf, (jbyte*)string, length); + new_length = utf8sToUtf8mLength((jbyte*)string, length); if ( new_length != length ) { char *new_string; new_string = jvmtiAllocate(new_length+1); - (gdata->npt->utf8sToUtf8m) - (gdata->npt->utf, (jbyte*)string, length, - (jbyte*)new_string, new_length); + utf8sToUtf8m((jbyte*)string, length, (jbyte*)new_string, new_length); jvmtiDeallocate(string); return new_string; } diff --git a/jdk/src/share/back/outStream.c b/jdk/src/share/back/outStream.c index 93c55ba1d83..17edb14364a 100644 --- a/jdk/src/share/back/outStream.c +++ b/jdk/src/share/back/outStream.c @@ -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 @@ -24,6 +24,7 @@ */ #include "util.h" +#include "utf_util.h" #include "stream.h" #include "outStream.h" #include "inStream.h" @@ -307,8 +308,7 @@ outStream_writeString(PacketOutputStream *stream, char *string) } else { jint new_length; - new_length = (gdata->npt->utf8mToUtf8sLength) - (gdata->npt->utf, (jbyte*)string, length); + new_length = utf8mToUtf8sLength((jbyte*)string, length); if ( new_length == length ) { (void)outStream_writeInt(stream, length); error = writeBytes(stream, (jbyte *)string, length); @@ -316,9 +316,7 @@ outStream_writeString(PacketOutputStream *stream, char *string) char *new_string; new_string = jvmtiAllocate(new_length+1); - (gdata->npt->utf8mToUtf8s) - (gdata->npt->utf, (jbyte*)string, length, - (jbyte*)new_string, new_length); + utf8mToUtf8s((jbyte*)string, length, (jbyte*)new_string, new_length); (void)outStream_writeInt(stream, new_length); error = writeBytes(stream, (jbyte *)new_string, new_length); jvmtiDeallocate(new_string); diff --git a/jdk/src/share/back/transport.c b/jdk/src/share/back/transport.c index 4a17118e89a..c05d39c4267 100644 --- a/jdk/src/share/back/transport.c +++ b/jdk/src/share/back/transport.c @@ -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 @@ -24,6 +24,7 @@ */ #include "util.h" +#include "utf_util.h" #include "transport.h" #include "debugLoop.h" #include "sys.h" @@ -65,8 +66,7 @@ printLastError(jdwpTransportEnv *t, jdwpTransportError err) len = (int)strlen(msg); maxlen = len+len/2+2; /* Should allow for plenty of room */ utf8msg = (jbyte*)jvmtiAllocate(maxlen+1); - (void)(gdata->npt->utf8FromPlatform)(gdata->npt->utf, - msg, len, utf8msg, maxlen); + (void)utf8FromPlatform(msg, len, utf8msg, maxlen); utf8msg[maxlen] = 0; } if (rv == JDWPTRANSPORT_ERROR_NONE) { @@ -110,8 +110,7 @@ loadTransportLibrary(const char *libdir, const char *name) int len; len = (int)strlen(libdir); - (void)(gdata->npt->utf8ToPlatform)(gdata->npt->utf, - (jbyte*)libdir, len, buf, (int)sizeof(buf)); + (void)utf8ToPlatform((jbyte*)libdir, len, buf, (int)sizeof(buf)); plibdir = buf; } @@ -392,8 +391,7 @@ launch(char *command, char *name, char *address) /* Convert commandLine from UTF-8 to platform encoding */ len = (int)strlen(commandLine); buf = jvmtiAllocate(len*3+3); - (void)(gdata->npt->utf8ToPlatform)(gdata->npt->utf, - (jbyte*)commandLine, len, buf, len*3+3); + (void)utf8ToPlatform((jbyte*)commandLine, len, buf, len*3+3); /* Exec commandLine */ rc = dbgsysExec(buf); diff --git a/jdk/src/share/npt/utf.c b/jdk/src/share/back/utf_util.c similarity index 53% rename from jdk/src/share/npt/utf.c rename to jdk/src/share/back/utf_util.c index a3b437d346d..38793dfd95a 100644 --- a/jdk/src/share/npt/utf.c +++ b/jdk/src/share/back/utf_util.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 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 @@ -23,117 +23,25 @@ * questions. */ -/* Misc functions for conversion of Unicode and UTF-8 and platform encoding */ - -#include -#include #include -#include -#include #include #include "jni.h" -#include "utf.h" +#include "utf_util.h" -/* - * Error handler - */ -void -utfError(char *file, int line, char *message) -{ + +/* Error and assert macros */ +#define UTF_ERROR(m) utfError(__FILE__, __LINE__, m) +#define UTF_ASSERT(x) ( (x)==0 ? UTF_ERROR("ASSERT ERROR " #x) : (void)0 ) + +// Platform independed part + +static void utfError(char *file, int line, char *message) { (void)fprintf(stderr, "UTF ERROR [\"%s\":%d]: %s\n", file, line, message); abort(); } -/* - * Convert UTF-8 to UTF-16 - * Returns length or -1 if output overflows. - */ -int JNICALL -utf8ToUtf16(struct UtfInst *ui, jbyte *utf8, int len, unsigned short *output, int outputMaxLen) -{ - int outputLen; - int i; - - UTF_ASSERT(utf8); - UTF_ASSERT(len>=0); - UTF_ASSERT(output); - UTF_ASSERT(outputMaxLen>0); - - i = 0; - outputLen = 0; - while ( i= outputMaxLen ) { - return -1; - } - x = (unsigned char)utf8[i++]; - code = x; - if ( (x & 0xE0)==0xE0 ) { - y = (unsigned char)utf8[i++]; - z = (unsigned char)utf8[i++]; - code = ((x & 0xF)<<12) + ((y & 0x3F)<<6) + (z & 0x3F); - } else if ( (x & 0xC0)==0xC0 ) { - y = (unsigned char)utf8[i++]; - code = ((x & 0x1F)<<6) + (y & 0x3F); - } - output[outputLen++] = code; - } - return outputLen; -} - -/* - * Convert UTF-16 to UTF-8 Modified - * Returns length or -1 if output overflows. - */ -int JNICALL -utf16ToUtf8m(struct UtfInst *ui, unsigned short *utf16, int len, jbyte *output, int outputMaxLen) -{ - int i; - int outputLen; - - UTF_ASSERT(utf16); - UTF_ASSERT(len>=0); - UTF_ASSERT(output); - UTF_ASSERT(outputMaxLen>0); - - outputLen = 0; - for (i = 0; i < len; i++) { - unsigned code; - - code = utf16[i]; - if ( code >= 0x0001 && code <= 0x007F ) { - if ( outputLen + 1 >= outputMaxLen ) { - return -1; - } - output[outputLen++] = code; - } else if ( code == 0 || ( code >= 0x0080 && code <= 0x07FF ) ) { - if ( outputLen + 2 >= outputMaxLen ) { - return -1; - } - output[outputLen++] = ((code>>6) & 0x1F) | 0xC0; - output[outputLen++] = (code & 0x3F) | 0x80; - } else if ( code >= 0x0800 && code <= 0xFFFF ) { - if ( outputLen + 3 >= outputMaxLen ) { - return -1; - } - output[outputLen++] = ((code>>12) & 0x0F) | 0xE0; - output[outputLen++] = ((code>>6) & 0x3F) | 0x80; - output[outputLen++] = (code & 0x3F) | 0x80; - } - } - output[outputLen] = 0; - return outputLen; -} - -int JNICALL -utf16ToUtf8s(struct UtfInst *ui, unsigned short *utf16, int len, jbyte *output, int outputMaxLen) -{ - return -1; /* FIXUP */ -} - /* Determine length of this Standard UTF-8 in Modified UTF-8. * Validation is done of the basic UTF encoding rules, returns * length (no change) when errors are detected in the UTF encoding. @@ -141,56 +49,54 @@ utf16ToUtf8s(struct UtfInst *ui, unsigned short *utf16, int len, jbyte *output, * Note: Accepts Modified UTF-8 also, no verification on the * correctness of Standard UTF-8 is done. e,g, 0xC080 input is ok. */ -int JNICALL -utf8sToUtf8mLength(struct UtfInst *ui, jbyte *string, int length) -{ - int newLength; - int i; +int JNICALL utf8sToUtf8mLength(jbyte *string, int length) { + int newLength; + int i; - newLength = 0; - for ( i = 0 ; i < length ; i++ ) { - unsigned byte; + newLength = 0; + for ( i = 0 ; i < length ; i++ ) { + unsigned byte; - byte = (unsigned char)string[i]; - if ( (byte & 0x80) == 0 ) { /* 1byte encoding */ - newLength++; - if ( byte == 0 ) { - newLength++; /* We gain one byte in length on NULL bytes */ - } - } else if ( (byte & 0xE0) == 0xC0 ) { /* 2byte encoding */ - /* Check encoding of following bytes */ - if ( (i+1) >= length || (string[i+1] & 0xC0) != 0x80 ) { - break; /* Error condition */ - } - i++; /* Skip next byte */ - newLength += 2; - } else if ( (byte & 0xF0) == 0xE0 ) { /* 3byte encoding */ - /* Check encoding of following bytes */ - if ( (i+2) >= length || (string[i+1] & 0xC0) != 0x80 - || (string[i+2] & 0xC0) != 0x80 ) { - break; /* Error condition */ - } - i += 2; /* Skip next two bytes */ - newLength += 3; - } else if ( (byte & 0xF8) == 0xF0 ) { /* 4byte encoding */ - /* Check encoding of following bytes */ - if ( (i+3) >= length || (string[i+1] & 0xC0) != 0x80 - || (string[i+2] & 0xC0) != 0x80 - || (string[i+3] & 0xC0) != 0x80 ) { - break; /* Error condition */ - } - i += 3; /* Skip next 3 bytes */ - newLength += 6; /* 4byte encoding turns into 2 3byte ones */ - } else { - break; /* Error condition */ + byte = (unsigned char)string[i]; + if ( (byte & 0x80) == 0 ) { /* 1byte encoding */ + newLength++; + if ( byte == 0 ) { + newLength++; /* We gain one byte in length on NULL bytes */ + } + } else if ( (byte & 0xE0) == 0xC0 ) { /* 2byte encoding */ + /* Check encoding of following bytes */ + if ( (i+1) >= length || (string[i+1] & 0xC0) != 0x80 ) { + break; /* Error condition */ + } + i++; /* Skip next byte */ + newLength += 2; + } else if ( (byte & 0xF0) == 0xE0 ) { /* 3byte encoding */ + /* Check encoding of following bytes */ + if ( (i+2) >= length || (string[i+1] & 0xC0) != 0x80 + || (string[i+2] & 0xC0) != 0x80 ) { + break; /* Error condition */ } + i += 2; /* Skip next two bytes */ + newLength += 3; + } else if ( (byte & 0xF8) == 0xF0 ) { /* 4byte encoding */ + /* Check encoding of following bytes */ + if ( (i+3) >= length || (string[i+1] & 0xC0) != 0x80 + || (string[i+2] & 0xC0) != 0x80 + || (string[i+3] & 0xC0) != 0x80 ) { + break; /* Error condition */ + } + i += 3; /* Skip next 3 bytes */ + newLength += 6; /* 4byte encoding turns into 2 3byte ones */ + } else { + break; /* Error condition */ } - if ( i != length ) { - /* Error in finding new length, return old length so no conversion */ - /* FIXUP: ERROR_MESSAGE? */ - return length; - } - return newLength; + } + if ( i != length ) { + /* Error in finding new length, return old length so no conversion */ + /* FIXUP: ERROR_MESSAGE? */ + return length; + } + return newLength; } /* Convert Standard UTF-8 to Modified UTF-8. @@ -199,9 +105,7 @@ utf8sToUtf8mLength(struct UtfInst *ui, jbyte *string, int length) * Note: Accepts Modified UTF-8 also, no verification on the * correctness of Standard UTF-8 is done. e,g, 0xC080 input is ok. */ -void JNICALL -utf8sToUtf8m(struct UtfInst *ui, jbyte *string, int length, jbyte *newString, int newLength) -{ +void JNICALL utf8sToUtf8m(jbyte *string, int length, jbyte *newString, int newLength) { int i; int j; @@ -263,9 +167,7 @@ utf8sToUtf8m(struct UtfInst *ui, jbyte *string, int length, jbyte *newString, in * Note: No validation is made that this is indeed Modified UTF-8 coming in. * */ -int JNICALL -utf8mToUtf8sLength(struct UtfInst *ui, jbyte *string, int length) -{ +int JNICALL utf8mToUtf8sLength(jbyte *string, int length) { int newLength; int i; @@ -330,9 +232,7 @@ utf8mToUtf8sLength(struct UtfInst *ui, jbyte *string, int length) * Note: No validation is made that this is indeed Modified UTF-8 coming in. * */ -void JNICALL -utf8mToUtf8s(struct UtfInst *ui, jbyte *string, int length, jbyte *newString, int newLength) -{ +void JNICALL utf8mToUtf8s(jbyte *string, int length, jbyte *newString, int newLength) { int i; int j; @@ -394,107 +294,247 @@ utf8mToUtf8s(struct UtfInst *ui, jbyte *string, int length, jbyte *newString, in newString[j] = 0; } -/* ================================================================= */ +#ifdef _WIN32 +// Microsoft Windows specific part -#ifdef COMPILE_WITH_UTF_TEST /* Test program */ +#include -/* - * Convert any byte array into a printable string. - * Returns length or -1 if output overflows. - */ -static int -bytesToPrintable(struct UtfInst *ui, char *bytes, int len, char *output, int outputMaxLen) -{ - int outputLen; - int i; +static UINT getCodepage() { + LANGID langID; + LCID localeID; + TCHAR strCodePage[7]; // ANSI code page id - UTF_ASSERT(bytes); - UTF_ASSERT(len>=0); - UTF_ASSERT(output); - UTF_ASSERT(outputMaxLen>=0); + static UINT intCodePage = -1; - outputLen = 0; - for ( i=0; i= outputMaxLen ) { - return -1; - } - output[outputLen++] = (char)byte; - } else { - if ( outputLen + 4 >= outputMaxLen ) { - return -1; - } - (void)sprintf(output+outputLen,"\\x%02x",byte); - outputLen += 4; + if (intCodePage == -1) { + // Firts call, get codepage from the os + langID = LANGIDFROMLCID(GetUserDefaultLCID()); + localeID = MAKELCID(langID, SORT_DEFAULT); + if (GetLocaleInfo(localeID, LOCALE_IDEFAULTANSICODEPAGE, + strCodePage, sizeof(strCodePage)/sizeof(TCHAR)) > 0 ) { + intCodePage = atoi(strCodePage); + } + else { + intCodePage = GetACP(); } } - output[outputLen] = 0; - return outputLen; + + return intCodePage; } -static void -test(void) -{ - static char *strings[] = { - "characters", - "abcdefghijklmnopqrstuvwxyz", - "0123456789", - "!@#$%^&*()_+=-{}[]:;", - NULL }; - int i; - struct UtfInst *ui; +/* + * Get wide string (assumes len>0) + */ +static WCHAR* getWideString(UINT codePage, char* str, int len, int *pwlen) { + int wlen; + WCHAR* wstr; - ui = utfInitialize(NULL); + /* Convert the string to WIDE string */ + wlen = MultiByteToWideChar(codePage, 0, str, len, NULL, 0); + *pwlen = wlen; + if (wlen <= 0) { + UTF_ERROR(("Can't get WIDE string length")); + return NULL; + } + wstr = (WCHAR*)malloc(wlen * sizeof(WCHAR)); + if (wstr == NULL) { + UTF_ERROR(("Can't malloc() any space")); + return NULL; + } + if (MultiByteToWideChar(codePage, 0, str, len, wstr, wlen) == 0) { + UTF_ERROR(("Can't get WIDE string")); + return NULL; + } + return wstr; +} - i = 0; - while ( strings[i] != NULL ) { - char *str; - #define MAX 1024 - char buf0[MAX]; - char buf1[MAX]; - char buf2[MAX]; - unsigned short buf3[MAX]; - int len1; - int len2; - int len3; +/* + * Convert UTF-8 to a platform string + */ +int JNICALL utf8ToPlatform(jbyte *utf8, int len, char* output, int outputMaxLen) { + int wlen; + int plen; + WCHAR* wstr; + UINT codepage; - str = strings[i]; + UTF_ASSERT(utf8); + UTF_ASSERT(output); + UTF_ASSERT(outputMaxLen > len); - (void)bytesToPrintable(ui, str, (int)strlen(str), buf0, 1024); - - len1 = utf8FromPlatform(ui, str, (int)strlen(str), (jbyte*)buf1, 1024); - - UTF_ASSERT(len1==(int)strlen(str)); - - len3 = utf8ToUtf16(ui, (jbyte*)buf1, len1, (jchar*)buf3, 1024); - - UTF_ASSERT(len3==len1); - - len1 = utf16ToUtf8m(ui, (jchar*)buf3, len3, (jbyte*)buf1, 1024); - - UTF_ASSERT(len1==len3); - UTF_ASSERT(strcmp(str, buf1) == 0); - - len2 = utf8ToPlatform(ui, (jbyte*)buf1, len1, buf2, 1024); - - UTF_ASSERT(len2==len1); - UTF_ASSERT(strcmp(str, buf2) == 0); - - i++; + /* Zero length is ok, but we don't need to do much */ + if ( len == 0 ) { + output[0] = 0; + return 0; } - utfTerminate(ui, NULL); + /* Get WIDE string version (assumes len>0) */ + wstr = getWideString(CP_UTF8, (char*)utf8, len, &wlen); + if ( wstr == NULL ) { + // Can't allocate WIDE string + goto just_copy_bytes; + } + /* Convert WIDE string to MultiByte string */ + codepage = getCodepage(); + plen = WideCharToMultiByte(codepage, 0, wstr, wlen, + output, outputMaxLen, NULL, NULL); + free(wstr); + if (plen <= 0) { + // Can't convert WIDE string to multi-byte + goto just_copy_bytes; + } + output[plen] = '\0'; + return plen; + +just_copy_bytes: + (void)memcpy(output, utf8, len); + output[len] = 0; + return len; } -int -main(int argc, char **argv) -{ - test(); - return 0; +/* + * Convert Platform Encoding to UTF-8. + */ +int JNICALL utf8FromPlatform(char *str, int len, jbyte *output, int outputMaxLen) { + int wlen; + int plen; + WCHAR* wstr; + UINT codepage; + + UTF_ASSERT(str); + UTF_ASSERT(output); + UTF_ASSERT(outputMaxLen > len); + + /* Zero length is ok, but we don't need to do much */ + if ( len == 0 ) { + output[0] = 0; + return 0; + } + + /* Get WIDE string version (assumes len>0) */ + codepage = getCodepage(); + wstr = getWideString(codepage, str, len, &wlen); + if ( wstr == NULL ) { + goto just_copy_bytes; + } + + /* Convert WIDE string to UTF-8 string */ + plen = WideCharToMultiByte(CP_UTF8, 0, wstr, wlen, + (char*)output, outputMaxLen, NULL, NULL); + free(wstr); + if (plen <= 0) { + UTF_ERROR(("Can't convert WIDE string to multi-byte")); + goto just_copy_bytes; + } + output[plen] = '\0'; + return plen; + +just_copy_bytes: + (void)memcpy(output, str, len); + output[len] = 0; + return len; +} + + +#else +// *NIX specific part + +#include +#include +#include +#include + +typedef enum {TO_UTF8, FROM_UTF8} conv_direction; + +/* + * Do iconv() conversion. + * Returns length or -1 if output overflows. + */ +static int iconvConvert(conv_direction drn, char *bytes, size_t len, char *output, size_t outputMaxLen) { + + static char *codeset = 0; + iconv_t func; + size_t bytes_converted; + size_t inLeft, outLeft; + char *inbuf, *outbuf; + + UTF_ASSERT(bytes); + UTF_ASSERT(output); + UTF_ASSERT(outputMaxLen > len); + + /* Zero length is ok, but we don't need to do much */ + if ( len == 0 ) { + output[0] = 0; + return 0; + } + + if (codeset == NULL && codeset != (char *) -1) { + // locale is not initialized, do it now + if (setlocale(LC_ALL, "") != NULL) { + // nl_langinfo returns ANSI_X3.4-1968 by default + codeset = (char*)nl_langinfo(CODESET); + } + + if (codeset == NULL) { + // Not able to intialize process locale from platform one. + codeset = (char *) -1; + } + } + + if (codeset == (char *) -1) { + // There was an error during initialization, so just bail out + goto just_copy_bytes; + } + + func = (drn == TO_UTF8) ? iconv_open(codeset, "UTF-8") : iconv_open("UTF-8", codeset); + if (func == (iconv_t) -1) { + // Requested charset combination is not supported, conversion couldn't be done. + // make sure we will not try it again + codeset = (char *) -1; + goto just_copy_bytes; + } + + // perform conversion + inbuf = bytes; + outbuf = output; + inLeft = len; + outLeft = outputMaxLen; + + bytes_converted = iconv(func, (void*)&inbuf, &inLeft, &outbuf, &outLeft); + if (bytes_converted == (size_t) -1 || bytes_converted == 0 || inLeft != 0) { + // Input string is invalid, not able to convert entire string + // or some other iconv error happens. + iconv_close(func); + goto just_copy_bytes; + } + + iconv_close(func); + // Overwrite bytes_converted with value of actually stored bytes + bytes_converted = outputMaxLen-outLeft; + output[bytes_converted] = 0; + return bytes_converted; + + +just_copy_bytes: + (void)memcpy(output, bytes, len); + output[len] = 0; + return len; + } + +/* + * Convert UTF-8 to Platform Encoding. + * Returns length or -1 if output overflows. + */ +int JNICALL utf8ToPlatform(jbyte *utf8, int len, char *output, int outputMaxLen) { + return iconvConvert(FROM_UTF8, (char*)utf8, len, output, outputMaxLen); +} + +/* + * Convert Platform Encoding to UTF-8. + * Returns length or -1 if output overflows. + */ +int JNICALL utf8FromPlatform(char *str, int len, jbyte *output, int outputMaxLen) { + return iconvConvert(TO_UTF8, str, len, (char*) output, outputMaxLen); } #endif diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Protocol.java b/jdk/src/share/back/utf_util.h similarity index 66% rename from jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Protocol.java rename to jdk/src/share/back/utf_util.h index b0e548e63f3..0892150adc7 100644 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Protocol.java +++ b/jdk/src/share/back/utf_util.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, 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 @@ -22,12 +22,19 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package com.apple.internal.jobjc.generator.model; -public class Protocol { +#ifndef _utf_util_h_ +#define _utf_util_h_ - public Protocol(final Clazz protocol) { +#include "jni.h" - } -} +int JNICALL utf8sToUtf8mLength(jbyte *string, int length); +void JNICALL utf8sToUtf8m(jbyte *string, int length, jbyte *newString, int newLength); +int JNICALL utf8mToUtf8sLength(jbyte *string, int length); +void JNICALL utf8mToUtf8s(jbyte *string, int length, jbyte *newString, int newLength); + +int JNICALL utf8ToPlatform(jbyte *utf8, int len, char* output, int outputMaxLen); +int JNICALL utf8FromPlatform(char *str, int len, jbyte *output, int outputMaxLen); + +#endif diff --git a/jdk/src/share/back/util.h b/jdk/src/share/back/util.h index 0f9aa1cd802..4a08823a2aa 100644 --- a/jdk/src/share/back/util.h +++ b/jdk/src/share/back/util.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2005, 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 @@ -53,9 +53,6 @@ #include "error_messages.h" #include "debugInit.h" -/* Get access to Native Platform Toolkit functions */ -#include "npt.h" - /* Definition of a CommonRef tracked by the backend for the frontend */ typedef struct RefNode { jlong seqNum; /* ID of reference, also key for hash table */ @@ -123,9 +120,6 @@ typedef struct { unsigned log_flags; - /* The Native Platform Toolkit access */ - NptEnv *npt; - /* Common References static data */ jrawMonitorID refLock; jlong nextSeqNum; diff --git a/jdk/src/share/classes/com/sun/crypto/provider/CipherCore.java b/jdk/src/share/classes/com/sun/crypto/provider/CipherCore.java index 8d54633adb1..6b5eea85d6d 100644 --- a/jdk/src/share/classes/com/sun/crypto/provider/CipherCore.java +++ b/jdk/src/share/classes/com/sun/crypto/provider/CipherCore.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -720,6 +720,15 @@ final class CipherCore { int outLen = 0; if (len != 0) { // there is some work to do + if ((input == output) + && (outputOffset < (inputOffset + inputLen)) + && (inputOffset < (outputOffset + buffer.length))) { + // copy 'input' out to avoid its content being + // overwritten prematurely. + input = Arrays.copyOfRange(input, inputOffset, + inputOffset + inputLen); + inputOffset = 0; + } if (len <= buffered) { // all to-be-processed data are from 'buffer' if (decrypting) { @@ -732,37 +741,37 @@ final class CipherCore { System.arraycopy(buffer, len, buffer, 0, buffered); } } else { // len > buffered - if ((input != output) && (buffered == 0)) { - // all to-be-processed data are from 'input' - // however, note that if 'input' and 'output' are the same, - // then they can't be passed directly to the underlying cipher - // engine operations as data may be overwritten before they - // are read. + int inputConsumed = len - buffered; + int temp; + if (buffered > 0) { + int bufferCapacity = buffer.length - buffered; + if (bufferCapacity != 0) { + temp = Math.min(bufferCapacity, inputConsumed); + System.arraycopy(input, inputOffset, buffer, buffered, temp); + inputOffset += temp; + inputConsumed -= temp; + inputLen -= temp; + buffered += temp; + } + // process 'buffer' if (decrypting) { - outLen = cipher.decrypt(input, inputOffset, len, output, outputOffset); + outLen = cipher.decrypt(buffer, 0, buffered, output, outputOffset); } else { - outLen = cipher.encrypt(input, inputOffset, len, output, outputOffset); - } - inputOffset += len; - inputLen -= len; - } else { - // assemble the data using both 'buffer' and 'input' - byte[] in = new byte[len]; - int inConsumed = len - buffered; - if (buffered != 0) { - System.arraycopy(buffer, 0, in, 0, buffered); - buffered = 0; - } - if (inConsumed != 0) { - System.arraycopy(input, inputOffset, in, len - inConsumed, inConsumed); - inputOffset += inConsumed; - inputLen -= inConsumed; + outLen = cipher.encrypt(buffer, 0, buffered, output, outputOffset); } + outputOffset += outLen; + buffered = 0; + } + if (inputConsumed > 0) { // still has input to process if (decrypting) { - outLen = cipher.decrypt(in, 0, len, output, outputOffset); + outLen += cipher.decrypt(input, inputOffset, inputConsumed, + output, outputOffset); } else { - outLen = cipher.encrypt(in, 0, len, output, outputOffset); + outLen += cipher.encrypt(input, inputOffset, inputConsumed, + output, outputOffset); } + inputOffset += inputConsumed; + inputLen -= inputConsumed; } } // Let's keep track of how many bytes are needed to make @@ -925,8 +934,10 @@ final class CipherCore { byte[] finalBuf = input; int finalOffset = inputOffset; int finalBufLen = inputLen; - if ((input == output) || (buffered != 0) || - (!decrypting && padding != null)) { + if ((buffered != 0) || (!decrypting && padding != null) || + ((input == output) + && (outputOffset < (inputOffset + inputLen)) + && (inputOffset < (outputOffset + buffer.length)))) { if (decrypting || padding == null) { paddingLen = 0; } diff --git a/jdk/src/share/classes/com/sun/crypto/provider/JceKeyStore.java b/jdk/src/share/classes/com/sun/crypto/provider/JceKeyStore.java index 5d48553c25a..cbbc54e42e1 100644 --- a/jdk/src/share/classes/com/sun/crypto/provider/JceKeyStore.java +++ b/jdk/src/share/classes/com/sun/crypto/provider/JceKeyStore.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2011, 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 @@ -107,7 +107,7 @@ public final class JceKeyStore extends KeyStoreSpi { { Key key = null; - Object entry = entries.get(alias.toLowerCase()); + Object entry = entries.get(alias.toLowerCase(Locale.ENGLISH)); if (!((entry instanceof PrivateKeyEntry) || (entry instanceof SecretKeyEntry))) { @@ -150,7 +150,7 @@ public final class JceKeyStore extends KeyStoreSpi { { Certificate[] chain = null; - Object entry = entries.get(alias.toLowerCase()); + Object entry = entries.get(alias.toLowerCase(Locale.ENGLISH)); if ((entry instanceof PrivateKeyEntry) && (((PrivateKeyEntry)entry).chain != null)) { @@ -178,7 +178,7 @@ public final class JceKeyStore extends KeyStoreSpi { public Certificate engineGetCertificate(String alias) { Certificate cert = null; - Object entry = entries.get(alias.toLowerCase()); + Object entry = entries.get(alias.toLowerCase(Locale.ENGLISH)); if (entry != null) { if (entry instanceof TrustedCertEntry) { @@ -203,7 +203,7 @@ public final class JceKeyStore extends KeyStoreSpi { public Date engineGetCreationDate(String alias) { Date date = null; - Object entry = entries.get(alias.toLowerCase()); + Object entry = entries.get(alias.toLowerCase(Locale.ENGLISH)); if (entry != null) { // We have to create a new instance of java.util.Date because @@ -266,7 +266,7 @@ public final class JceKeyStore extends KeyStoreSpi { } // store the entry - entries.put(alias.toLowerCase(), entry); + entries.put(alias.toLowerCase(Locale.ENGLISH), entry); } else { SecretKeyEntry entry = new SecretKeyEntry(); @@ -274,7 +274,7 @@ public final class JceKeyStore extends KeyStoreSpi { // seal and store the key entry.sealedKey = keyProtector.seal(key); - entries.put(alias.toLowerCase(), entry); + entries.put(alias.toLowerCase(Locale.ENGLISH), entry); } } catch (Exception e) { @@ -322,7 +322,7 @@ public final class JceKeyStore extends KeyStoreSpi { entry.chain = null; } - entries.put(alias.toLowerCase(), entry); + entries.put(alias.toLowerCase(Locale.ENGLISH), entry); } } @@ -345,7 +345,7 @@ public final class JceKeyStore extends KeyStoreSpi { { synchronized(entries) { - Object entry = entries.get(alias.toLowerCase()); + Object entry = entries.get(alias.toLowerCase(Locale.ENGLISH)); if (entry != null) { if (entry instanceof PrivateKeyEntry) { throw new KeyStoreException("Cannot overwrite own " @@ -358,7 +358,7 @@ public final class JceKeyStore extends KeyStoreSpi { TrustedCertEntry trustedCertEntry = new TrustedCertEntry(); trustedCertEntry.cert = cert; trustedCertEntry.date = new Date(); - entries.put(alias.toLowerCase(), trustedCertEntry); + entries.put(alias.toLowerCase(Locale.ENGLISH), trustedCertEntry); } } @@ -373,7 +373,7 @@ public final class JceKeyStore extends KeyStoreSpi { throws KeyStoreException { synchronized(entries) { - entries.remove(alias.toLowerCase()); + entries.remove(alias.toLowerCase(Locale.ENGLISH)); } } @@ -394,7 +394,7 @@ public final class JceKeyStore extends KeyStoreSpi { * @return true if the alias exists, false otherwise */ public boolean engineContainsAlias(String alias) { - return entries.containsKey(alias.toLowerCase()); + return entries.containsKey(alias.toLowerCase(Locale.ENGLISH)); } /** @@ -416,7 +416,7 @@ public final class JceKeyStore extends KeyStoreSpi { public boolean engineIsKeyEntry(String alias) { boolean isKey = false; - Object entry = entries.get(alias.toLowerCase()); + Object entry = entries.get(alias.toLowerCase(Locale.ENGLISH)); if ((entry instanceof PrivateKeyEntry) || (entry instanceof SecretKeyEntry)) { isKey = true; @@ -434,7 +434,7 @@ public final class JceKeyStore extends KeyStoreSpi { */ public boolean engineIsCertificateEntry(String alias) { boolean isCert = false; - Object entry = entries.get(alias.toLowerCase()); + Object entry = entries.get(alias.toLowerCase(Locale.ENGLISH)); if (entry instanceof TrustedCertEntry) { isCert = true; } diff --git a/jdk/src/share/classes/com/sun/crypto/provider/PBEKey.java b/jdk/src/share/classes/com/sun/crypto/provider/PBEKey.java index d954d0fe6a5..10ba5cb79f6 100644 --- a/jdk/src/share/classes/com/sun/crypto/provider/PBEKey.java +++ b/jdk/src/share/classes/com/sun/crypto/provider/PBEKey.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, 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 @@ -27,6 +27,7 @@ package com.sun.crypto.provider; import java.security.KeyRep; import java.security.spec.InvalidKeySpecException; +import java.util.Locale; import javax.crypto.SecretKey; import javax.crypto.spec.PBEKeySpec; @@ -91,7 +92,7 @@ final class PBEKey implements SecretKey { for (int i = 1; i < this.key.length; i++) { retval += this.key[i] * i; } - return(retval ^= getAlgorithm().toLowerCase().hashCode()); + return(retval ^= getAlgorithm().toLowerCase(Locale.ENGLISH).hashCode()); } public boolean equals(Object obj) { diff --git a/jdk/src/share/classes/com/sun/crypto/provider/PBEKeyFactory.java b/jdk/src/share/classes/com/sun/crypto/provider/PBEKeyFactory.java index 26dd0867c95..0c87971876f 100644 --- a/jdk/src/share/classes/com/sun/crypto/provider/PBEKeyFactory.java +++ b/jdk/src/share/classes/com/sun/crypto/provider/PBEKeyFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, 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 @@ -32,6 +32,7 @@ import javax.crypto.SecretKey; import javax.crypto.SecretKeyFactorySpi; import javax.crypto.spec.PBEKeySpec; import java.util.HashSet; +import java.util.Locale; /** * This class implements a key factory for PBE keys according to PKCS#5, @@ -56,24 +57,24 @@ abstract class PBEKeyFactory extends SecretKeyFactorySpi { static { validTypes = new HashSet(17); - validTypes.add("PBEWithMD5AndDES".toUpperCase()); - validTypes.add("PBEWithSHA1AndDESede".toUpperCase()); - validTypes.add("PBEWithSHA1AndRC2_40".toUpperCase()); - validTypes.add("PBEWithSHA1AndRC2_128".toUpperCase()); - validTypes.add("PBEWithSHA1AndRC4_40".toUpperCase()); - validTypes.add("PBEWithSHA1AndRC4_128".toUpperCase()); + validTypes.add("PBEWithMD5AndDES".toUpperCase(Locale.ENGLISH)); + validTypes.add("PBEWithSHA1AndDESede".toUpperCase(Locale.ENGLISH)); + validTypes.add("PBEWithSHA1AndRC2_40".toUpperCase(Locale.ENGLISH)); + validTypes.add("PBEWithSHA1AndRC2_128".toUpperCase(Locale.ENGLISH)); + validTypes.add("PBEWithSHA1AndRC4_40".toUpperCase(Locale.ENGLISH)); + validTypes.add("PBEWithSHA1AndRC4_128".toUpperCase(Locale.ENGLISH)); // Proprietary algorithm. - validTypes.add("PBEWithMD5AndTripleDES".toUpperCase()); - validTypes.add("PBEWithHmacSHA1AndAES_128".toUpperCase()); - validTypes.add("PBEWithHmacSHA224AndAES_128".toUpperCase()); - validTypes.add("PBEWithHmacSHA256AndAES_128".toUpperCase()); - validTypes.add("PBEWithHmacSHA384AndAES_128".toUpperCase()); - validTypes.add("PBEWithHmacSHA512AndAES_128".toUpperCase()); - validTypes.add("PBEWithHmacSHA1AndAES_256".toUpperCase()); - validTypes.add("PBEWithHmacSHA224AndAES_256".toUpperCase()); - validTypes.add("PBEWithHmacSHA256AndAES_256".toUpperCase()); - validTypes.add("PBEWithHmacSHA384AndAES_256".toUpperCase()); - validTypes.add("PBEWithHmacSHA512AndAES_256".toUpperCase()); + validTypes.add("PBEWithMD5AndTripleDES".toUpperCase(Locale.ENGLISH)); + validTypes.add("PBEWithHmacSHA1AndAES_128".toUpperCase(Locale.ENGLISH)); + validTypes.add("PBEWithHmacSHA224AndAES_128".toUpperCase(Locale.ENGLISH)); + validTypes.add("PBEWithHmacSHA256AndAES_128".toUpperCase(Locale.ENGLISH)); + validTypes.add("PBEWithHmacSHA384AndAES_128".toUpperCase(Locale.ENGLISH)); + validTypes.add("PBEWithHmacSHA512AndAES_128".toUpperCase(Locale.ENGLISH)); + validTypes.add("PBEWithHmacSHA1AndAES_256".toUpperCase(Locale.ENGLISH)); + validTypes.add("PBEWithHmacSHA224AndAES_256".toUpperCase(Locale.ENGLISH)); + validTypes.add("PBEWithHmacSHA256AndAES_256".toUpperCase(Locale.ENGLISH)); + validTypes.add("PBEWithHmacSHA384AndAES_256".toUpperCase(Locale.ENGLISH)); + validTypes.add("PBEWithHmacSHA512AndAES_256".toUpperCase(Locale.ENGLISH)); } public static final class PBEWithMD5AndDES @@ -237,7 +238,7 @@ abstract class PBEKeyFactory extends SecretKeyFactorySpi { protected KeySpec engineGetKeySpec(SecretKey key, Class keySpecCl) throws InvalidKeySpecException { if ((key instanceof SecretKey) - && (validTypes.contains(key.getAlgorithm().toUpperCase())) + && (validTypes.contains(key.getAlgorithm().toUpperCase(Locale.ENGLISH))) && (key.getFormat().equalsIgnoreCase("RAW"))) { // Check if requested key spec is amongst the valid ones @@ -279,7 +280,7 @@ abstract class PBEKeyFactory extends SecretKeyFactorySpi { { try { if ((key != null) && - (validTypes.contains(key.getAlgorithm().toUpperCase())) && + (validTypes.contains(key.getAlgorithm().toUpperCase(Locale.ENGLISH))) && (key.getFormat().equalsIgnoreCase("RAW"))) { // Check if key originates from this factory diff --git a/jdk/src/share/classes/com/sun/crypto/provider/PBKDF2KeyImpl.java b/jdk/src/share/classes/com/sun/crypto/provider/PBKDF2KeyImpl.java index ec3bd3e7992..16756fbe5e0 100644 --- a/jdk/src/share/classes/com/sun/crypto/provider/PBKDF2KeyImpl.java +++ b/jdk/src/share/classes/com/sun/crypto/provider/PBKDF2KeyImpl.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 @@ -30,6 +30,7 @@ import java.nio.ByteBuffer; import java.nio.CharBuffer; import java.nio.charset.Charset; import java.util.Arrays; +import java.util.Locale; import java.security.KeyRep; import java.security.GeneralSecurityException; import java.security.NoSuchAlgorithmException; @@ -143,7 +144,7 @@ final class PBKDF2KeyImpl implements javax.crypto.interfaces.PBEKey { @Override public int hashCode() { return Arrays.hashCode(password) * 41 + - prf.getAlgorithm().toLowerCase().hashCode(); + prf.getAlgorithm().toLowerCase(Locale.ENGLISH).hashCode(); } @Override public boolean equals(Object obj) { @@ -221,7 +222,7 @@ final class PBKDF2KeyImpl implements javax.crypto.interfaces.PBEKey { for (int i = 1; i < this.key.length; i++) { retval += this.key[i] * i; } - return(retval ^= getAlgorithm().toLowerCase().hashCode()); + return(retval ^= getAlgorithm().toLowerCase(Locale.ENGLISH).hashCode()); } public boolean equals(Object obj) { diff --git a/jdk/src/share/classes/com/sun/imageio/plugins/gif/GIFImageReader.java b/jdk/src/share/classes/com/sun/imageio/plugins/gif/GIFImageReader.java index 650fd313051..82814627077 100644 --- a/jdk/src/share/classes/com/sun/imageio/plugins/gif/GIFImageReader.java +++ b/jdk/src/share/classes/com/sun/imageio/plugins/gif/GIFImageReader.java @@ -509,7 +509,7 @@ public class GIFImageReader extends ImageReader { byte[] signature = new byte[6]; stream.readFully(signature); - StringBuffer version = new StringBuffer(3); + StringBuilder version = new StringBuilder(3); version.append((char)signature[3]); version.append((char)signature[4]); version.append((char)signature[5]); @@ -616,7 +616,7 @@ public class GIFImageReader extends ImageReader { return index; } - Long l1 = new Long(stream.getStreamPosition()); + Long l1 = stream.getStreamPosition(); imageStartPosition.add(l1); ++index; } diff --git a/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReader.java b/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReader.java index 961255ce8c9..5743cedc904 100644 --- a/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReader.java +++ b/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReader.java @@ -89,7 +89,7 @@ public class JPEGImageReader extends ImageReader { java.security.AccessController.doPrivileged( new java.security.PrivilegedAction() { public Void run() { - System.loadLibrary("jpeg"); + System.loadLibrary("javajpeg"); return null; } }); @@ -367,10 +367,10 @@ public class JPEGImageReader extends ImageReader { // Now we are at the first image if there are any, so add it // to the list if (hasNextImage()) { - imagePositions.add(new Long(iis.getStreamPosition())); + imagePositions.add(iis.getStreamPosition()); } } else { // Not tables only, so add original pos to the list - imagePositions.add(new Long(savePos)); + imagePositions.add(savePos); // And set current image since we've read it now currentImage = 0; } @@ -498,7 +498,7 @@ public class JPEGImageReader extends ImageReader { if (!hasNextImage()) { throw new IndexOutOfBoundsException(); } - pos = new Long(iis.getStreamPosition()); + pos = iis.getStreamPosition(); imagePositions.add(pos); if (seekForwardOnly) { iis.flushBefore(pos.longValue()); diff --git a/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageWriter.java b/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageWriter.java index 1913ef4641f..477e6738b5f 100644 --- a/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageWriter.java +++ b/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageWriter.java @@ -179,7 +179,7 @@ public class JPEGImageWriter extends ImageWriter { java.security.AccessController.doPrivileged( new java.security.PrivilegedAction() { public Void run() { - System.loadLibrary("jpeg"); + System.loadLibrary("javajpeg"); return null; } }); diff --git a/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGMetadata.java b/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGMetadata.java index 3ad3a8b6420..11018ec4015 100644 --- a/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGMetadata.java +++ b/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGMetadata.java @@ -900,7 +900,7 @@ public class PNGMetadata extends IIOMetadata implements Cloneable { if (times == 1) { return s; } - StringBuffer sb = new StringBuffer((s.length() + 1)*times - 1); + StringBuilder sb = new StringBuilder((s.length() + 1)*times - 1); sb.append(s); for (int i = 1; i < times; i++) { sb.append(" "); diff --git a/jdk/src/share/classes/com/sun/java/browser/dom/DOMAccessException.java b/jdk/src/share/classes/com/sun/java/browser/dom/DOMAccessException.java deleted file mode 100644 index 77307d834f5..00000000000 --- a/jdk/src/share/classes/com/sun/java/browser/dom/DOMAccessException.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.java.browser.dom; - -@SuppressWarnings("serial") // JDK implementation class -public class DOMAccessException extends Exception -{ - /** - * Constructs a new DOMAccessException with no detail message. - */ - public DOMAccessException() - { - this(null, null); - } - - - /** - * Constructs a new DOMAccessException with the given detail message. - * - * @param msg Detail message. - */ - public DOMAccessException(String msg) - { - this(null, msg); - } - - /** - * Constructs a new DOMAccessException with the given exception as a root clause. - * - * @param e Exception. - */ - public DOMAccessException(Exception e) - { - this(e, null); - } - - /** - * Constructs a new DOMAccessException with the given exception as a root clause and the given detail message. - * - * @param e Exception. - * @param msg Detail message. - */ - public DOMAccessException(Exception e, String msg) - { - this.ex = e; - this.msg = msg; - } - - /** - * Returns the detail message of the error or null if there is no detail message. - */ - public String getMessage() - { - return msg; - } - - /** - * Returns the root cause of the error or null if there is none. - */ - public Throwable getCause() - { - return ex; - } - - private Throwable ex; - private String msg; -} diff --git a/jdk/src/share/classes/com/sun/java/browser/dom/DOMService.java b/jdk/src/share/classes/com/sun/java/browser/dom/DOMService.java deleted file mode 100644 index 9a418cf5edc..00000000000 --- a/jdk/src/share/classes/com/sun/java/browser/dom/DOMService.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.java.browser.dom; - -import java.security.AccessController; -import java.security.PrivilegedAction; - -public abstract class DOMService -{ - /** - * Returns new instance of a DOMService. The implementation - * of the DOMService returns depends on the setting of the - * com.sun.java.browser.dom.DOMServiceProvider property or, - * if the property is not set, a platform specific default. - * - * Throws DOMUnsupportedException if the DOMService is not - * available to the obj. - * - * @param obj Object to leverage the DOMService - */ - public static DOMService getService(Object obj) - throws DOMUnsupportedException - { - try - { - String provider = AccessController.doPrivileged( - (PrivilegedAction) () -> - System.getProperty("com.sun.java.browser.dom.DOMServiceProvider")); - - Class clazz = Class.forName("sun.plugin.dom.DOMService"); - - return (DOMService) clazz.newInstance(); - } - catch (Throwable e) - { - throw new DOMUnsupportedException(e.toString()); - } - } - - /** - * An empty constructor is provided. Implementations of this - * abstract class must provide a public no-argument constructor - * in order for the static getService() method to work correctly. - * Application programmers should not be able to directly - * construct implementation subclasses of this abstract subclass. - */ - public DOMService() - { - } - - /** - * Causes action.run() to be executed synchronously on the - * DOM action dispatching thread. This call will block until all - * pending DOM actions have been processed and (then) - * action.run() returns. This method should be used when an - * application thread needs to access the browser's DOM. - * It should not be called from the DOMActionDispatchThread. - * - * Note that if the DOMAction.run() method throws an uncaught - * exception (on the DOM action dispatching thread), it's caught - * and re-thrown, as an DOMAccessException, on the caller's thread. - * - * If the DOMAction.run() method throws any DOM security related - * exception (on the DOM action dispatching thread), it's caught - * and re-thrown, as an DOMSecurityException, on the caller's thread. - * - * @param action DOMAction. - */ - public abstract Object invokeAndWait(DOMAction action) throws DOMAccessException; - - /** - * Causes action.run() to be executed asynchronously on the - * DOM action dispatching thread. This method should be used - * when an application thread needs to access the browser's - * DOM. It should not be called from the DOMActionDispatchThread. - * - * Note that if the DOMAction.run() method throws an uncaught - * exception (on the DOM action dispatching thread), it will not be - * caught and re-thrown on the caller's thread. - * - * @param action DOMAction. - */ - public abstract void invokeLater(DOMAction action); -} diff --git a/jdk/src/share/classes/com/sun/java/browser/dom/DOMServiceProvider.java b/jdk/src/share/classes/com/sun/java/browser/dom/DOMServiceProvider.java deleted file mode 100644 index 8cd7aa1e3a8..00000000000 --- a/jdk/src/share/classes/com/sun/java/browser/dom/DOMServiceProvider.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.java.browser.dom; - -public abstract class DOMServiceProvider -{ - /** - * An empty constructor is provided. Implementations should - * provide a public constructor so that the DOMService - * can instantiate instances of the implementation class. - * Application programmers should not be able to directly - * construct implementation subclasses of this abstract subclass. - * The only way an application should be able to obtain a - * reference to a DOMServiceProvider implementation - * instance is by using the appropriate methods of the - * DOMService. - */ - public DOMServiceProvider() - { - } - - /** - * Returns true if the DOMService can determine the association - * between the obj and the underlying DOM in the browser. - */ - public abstract boolean canHandle(Object obj); - - /** - * Returns the Document object of the DOM. - */ - public abstract org.w3c.dom.Document getDocument(Object obj) throws DOMUnsupportedException; - - /** - * Returns the DOMImplemenation object of the DOM. - */ - public abstract org.w3c.dom.DOMImplementation getDOMImplementation(); -} diff --git a/jdk/src/share/classes/com/sun/java/browser/dom/DOMUnsupportedException.java b/jdk/src/share/classes/com/sun/java/browser/dom/DOMUnsupportedException.java deleted file mode 100644 index 2796339f39a..00000000000 --- a/jdk/src/share/classes/com/sun/java/browser/dom/DOMUnsupportedException.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.java.browser.dom; - -@SuppressWarnings("serial") // JDK implementation class -public class DOMUnsupportedException extends Exception -{ - /** - * Constructs a new DOMUnsupportedException with no detail message. - */ - public DOMUnsupportedException() - { - this(null, null); - } - - /** - * Constructs a new DOMUnsupportedException with the given detail message. - * - * @param msg Detail message. - */ - public DOMUnsupportedException(String msg) - { - this(null, msg); - } - - /** - * Constructs a new DOMUnsupportedException with the given exception as a root clause. - * - * @param e Exception. - */ - public DOMUnsupportedException(Exception e) - { - this(e, null); - } - - /** - * Constructs a new DOMUnsupportedException with the given exception as a root clause and the given detail message. - * - * @param e Exception. - * @param msg Detail message. - */ - public DOMUnsupportedException(Exception e, String msg) - { - this.ex = e; - this.msg = msg; - } - - /** - * Returns the detail message of the error or null if there is no detail message. - */ - public String getMessage() - { - return msg; - } - - /** - * Returns the root cause of the error or null if there is none. - */ - public Throwable getCause() - { - return ex; - } - - private Throwable ex; - private String msg; -} diff --git a/jdk/src/share/classes/com/sun/java/browser/net/ProxyInfo.java b/jdk/src/share/classes/com/sun/java/browser/net/ProxyInfo.java deleted file mode 100644 index f966e813591..00000000000 --- a/jdk/src/share/classes/com/sun/java/browser/net/ProxyInfo.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.java.browser.net; - -/** - * - * @author Zhengyu Gu - */ -public interface ProxyInfo { - public String getHost(); - public int getPort(); - public boolean isSocks(); -} diff --git a/jdk/src/share/classes/com/sun/java/swing/SwingUtilities3.java b/jdk/src/share/classes/com/sun/java/swing/SwingUtilities3.java index 1ca240dd743..6b2891aa517 100644 --- a/jdk/src/share/classes/com/sun/java/swing/SwingUtilities3.java +++ b/jdk/src/share/classes/com/sun/java/swing/SwingUtilities3.java @@ -25,15 +25,13 @@ package com.sun.java.swing; -import sun.awt.EventQueueDelegate; import sun.awt.AppContext; +import sun.awt.SunToolkit; + import java.util.Collections; import java.util.Map; import java.util.WeakHashMap; -import java.util.concurrent.Callable; import java.applet.Applet; -import java.awt.AWTEvent; -import java.awt.EventQueue; import java.awt.Component; import java.awt.Container; import java.awt.Window; @@ -117,8 +115,8 @@ public class SwingUtilities3 { public static RepaintManager getDelegateRepaintManager(Component component) { RepaintManager delegate = null; - if (Boolean.TRUE == AppContext.getAppContext().get( - DELEGATE_REPAINT_MANAGER_KEY)) { + if (Boolean.TRUE == SunToolkit.targetToAppContext(component) + .get(DELEGATE_REPAINT_MANAGER_KEY)) { while (delegate == null && component != null) { while (component != null && ! (component instanceof JComponent)) { @@ -135,86 +133,4 @@ public class SwingUtilities3 { } return delegate; } - - /* - * We use maps to avoid reflection. Hopefully it should perform better - * this way. - */ - public static void setEventQueueDelegate( - Map> map) { - EventQueueDelegate.setDelegate(new EventQueueDelegateFromMap(map)); - } - - private static class EventQueueDelegateFromMap - implements EventQueueDelegate.Delegate { - private final AWTEvent[] afterDispatchEventArgument; - private final Object[] afterDispatchHandleArgument; - private final Callable afterDispatchCallable; - - private final AWTEvent[] beforeDispatchEventArgument; - private final Callable beforeDispatchCallable; - - private final EventQueue[] getNextEventEventQueueArgument; - private final Callable getNextEventCallable; - - @SuppressWarnings("unchecked") - public EventQueueDelegateFromMap(Map> objectMap) { - Map methodMap = objectMap.get("afterDispatch"); - afterDispatchEventArgument = (AWTEvent[]) methodMap.get("event"); - afterDispatchHandleArgument = (Object[]) methodMap.get("handle"); - afterDispatchCallable = (Callable) methodMap.get("method"); - - methodMap = objectMap.get("beforeDispatch"); - beforeDispatchEventArgument = (AWTEvent[]) methodMap.get("event"); - beforeDispatchCallable = (Callable) methodMap.get("method"); - - methodMap = objectMap.get("getNextEvent"); - getNextEventEventQueueArgument = - (EventQueue[]) methodMap.get("eventQueue"); - getNextEventCallable = (Callable) methodMap.get("method"); - } - - @Override - public void afterDispatch(AWTEvent event, Object handle) throws InterruptedException { - afterDispatchEventArgument[0] = event; - afterDispatchHandleArgument[0] = handle; - try { - afterDispatchCallable.call(); - } catch (InterruptedException e) { - throw e; - } catch (RuntimeException e) { - throw e; - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - @Override - public Object beforeDispatch(AWTEvent event) throws InterruptedException { - beforeDispatchEventArgument[0] = event; - try { - return beforeDispatchCallable.call(); - } catch (InterruptedException e) { - throw e; - } catch (RuntimeException e) { - throw e; - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - @Override - public AWTEvent getNextEvent(EventQueue eventQueue) throws InterruptedException { - getNextEventEventQueueArgument[0] = eventQueue; - try { - return getNextEventCallable.call(); - } catch (InterruptedException e) { - throw e; - } catch (RuntimeException e) { - throw e; - } catch (Exception e) { - throw new RuntimeException(e); - } - } - } } diff --git a/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/GTKFileChooserUI.java b/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/GTKFileChooserUI.java index ddbdcded4b6..0a6bd6ae57f 100644 --- a/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/GTKFileChooserUI.java +++ b/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/GTKFileChooserUI.java @@ -169,23 +169,23 @@ class GTKFileChooserUI extends SynthFileChooserUI { result.add(typedInName); } - StringBuffer buf = new StringBuffer(); + StringBuilder sb = new StringBuilder(); len = result.size(); // construct the resulting string for (int i=0; i 0) { - buf.append(" "); + sb.append(" "); } if (len > 1) { - buf.append("\""); + sb.append("\""); } - buf.append(result.get(i)); + sb.append(result.get(i)); if (len > 1) { - buf.append("\""); + sb.append("\""); } } - return buf.toString(); + return sb.toString(); } public void setFileName(String fileName) { diff --git a/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/Metacity.java b/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/Metacity.java index 72167580a92..85527e44a4c 100644 --- a/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/Metacity.java +++ b/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/Metacity.java @@ -533,13 +533,13 @@ class Metacity implements SynthConstants { // Pending: verify character encoding spec for gconf Reader reader = new InputStreamReader(url.openStream(), "ISO-8859-1"); char[] buf = new char[1024]; - StringBuffer strBuf = new StringBuffer(); + StringBuilder sb = new StringBuilder(); int n; while ((n = reader.read(buf)) >= 0) { - strBuf.append(buf, 0, n); + sb.append(buf, 0, n); } reader.close(); - String str = strBuf.toString(); + String str = sb.toString(); if (str != null) { String strLowerCase = str.toLowerCase(); int i = strLowerCase.indexOf("", i); if (i > 0) { i += "".length(); - int i2 = str.indexOf("<", i); + int i2 = str.indexOf('<', i); return str.substring(i, i2); } } diff --git a/jdk/src/share/classes/com/sun/java/swing/plaf/motif/MotifFileChooserUI.java b/jdk/src/share/classes/com/sun/java/swing/plaf/motif/MotifFileChooserUI.java index f707ad84268..2735f2475da 100644 --- a/jdk/src/share/classes/com/sun/java/swing/plaf/motif/MotifFileChooserUI.java +++ b/jdk/src/share/classes/com/sun/java/swing/plaf/motif/MotifFileChooserUI.java @@ -121,20 +121,20 @@ public class MotifFileChooserUI extends BasicFileChooserUI { } private String fileNameString(File[] files) { - StringBuffer buf = new StringBuffer(); + StringBuilder sb = new StringBuilder(); for (int i = 0; files != null && i < files.length; i++) { if (i > 0) { - buf.append(" "); + sb.append(" "); } if (files.length > 1) { - buf.append("\""); + sb.append("\""); } - buf.append(fileNameString(files[i])); + sb.append(fileNameString(files[i])); if (files.length > 1) { - buf.append("\""); + sb.append("\""); } } - return buf.toString(); + return sb.toString(); } public MotifFileChooserUI(JFileChooser filechooser) { diff --git a/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsFileChooserUI.java b/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsFileChooserUI.java index 0def92eba15..76a30a13c5a 100644 --- a/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsFileChooserUI.java +++ b/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsFileChooserUI.java @@ -690,7 +690,7 @@ public class WindowsFileChooserUI extends BasicFileChooserUI { } private String fileNameString(File[] files) { - StringBuffer buf = new StringBuffer(); + StringBuilder buf = new StringBuilder(); for (int i = 0; files != null && i < files.length; i++) { if (i > 0) { buf.append(" "); diff --git a/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java b/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java index a6c1c895757..5998f85483c 100644 --- a/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java +++ b/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java @@ -1102,8 +1102,7 @@ public class WindowsLookAndFeel extends BasicLookAndFeel "PasswordField.selectionBackground", SelectionBackgroundColor, "PasswordField.selectionForeground", SelectionTextColor, "PasswordField.caretForeground",WindowTextColor, - "PasswordField.echoChar", new XPValue(new Character((char)0x25CF), - new Character('*')), + "PasswordField.echoChar", new XPValue((char)0x25CF, '*'), // *** ProgressBar "ProgressBar.font", ControlFont, diff --git a/jdk/src/share/classes/com/sun/java/util/jar/pack/BandStructure.java b/jdk/src/share/classes/com/sun/java/util/jar/pack/BandStructure.java index 1152aa73f0c..a7db9784946 100644 --- a/jdk/src/share/classes/com/sun/java/util/jar/pack/BandStructure.java +++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/BandStructure.java @@ -628,7 +628,7 @@ class BandStructure { } if (metaCoding.length > 0 && (verbose > 2 || verbose > 1 && metaCoding.length > 1)) { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); for (int i = 0; i < metaCoding.length; i++) { if (i == 1) sb.append(" /"); sb.append(" ").append(metaCoding[i] & 0xFF); @@ -756,7 +756,7 @@ class BandStructure { " size="+outputSize()+ irr+" coding="+bandCoding); if (metaCoding != noMetaCoding) { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); for (int i = 0; i < metaCoding.length; i++) { if (i == 1) sb.append(" /"); sb.append(" ").append(metaCoding[i] & 0xFF); diff --git a/jdk/src/share/classes/com/sun/java/util/jar/pack/ConstantPool.java b/jdk/src/share/classes/com/sun/java/util/jar/pack/ConstantPool.java index fd17dea7fdd..e4c7d7d931d 100644 --- a/jdk/src/share/classes/com/sun/java/util/jar/pack/ConstantPool.java +++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/ConstantPool.java @@ -1026,7 +1026,7 @@ class ConstantPool { } static String stringValueOf(MethodHandleEntry bsmRef, Entry[] argRefs) { - StringBuffer sb = new StringBuffer(bsmRef.stringValue()); + StringBuilder sb = new StringBuilder(bsmRef.stringValue()); // Arguments are formatted as "" instead of "[foo,bar,baz]". // This ensures there will be no confusion if "[,]" appear inside of names. char nextSep = '<'; diff --git a/jdk/src/share/classes/com/sun/jmx/snmp/IPAcl/NetMaskImpl.java b/jdk/src/share/classes/com/sun/jmx/snmp/IPAcl/NetMaskImpl.java index ac0fcc8b68c..9606c020266 100644 --- a/jdk/src/share/classes/com/sun/jmx/snmp/IPAcl/NetMaskImpl.java +++ b/jdk/src/share/classes/com/sun/jmx/snmp/IPAcl/NetMaskImpl.java @@ -63,12 +63,12 @@ class NetMaskImpl extends PrincipalImpl implements Group, Serializable { if (SNMP_LOGGER.isLoggable(Level.FINEST)) { SNMP_LOGGER.logp(Level.FINEST, NetMaskImpl.class.getName(), "extractSubNet", "BINARY ARRAY :"); - StringBuffer buff = new StringBuffer(); + StringBuilder sb = new StringBuilder(); for(int i =0; i < addrLength; i++) { - buff.append((b[i] &0xFF) +":"); + sb.append((b[i] & 0xFF) + ":"); } SNMP_LOGGER.logp(Level.FINEST, NetMaskImpl.class.getName(), - "extractSubNet", buff.toString()); + "extractSubNet", sb.toString()); } // 8 is a byte size. Common to any InetAddress (V4 or V6). diff --git a/jdk/src/share/classes/com/sun/jmx/snmp/IPAcl/ParseException.java b/jdk/src/share/classes/com/sun/jmx/snmp/IPAcl/ParseException.java index 7d7f3f7abba..78be1da103b 100644 --- a/jdk/src/share/classes/com/sun/jmx/snmp/IPAcl/ParseException.java +++ b/jdk/src/share/classes/com/sun/jmx/snmp/IPAcl/ParseException.java @@ -170,7 +170,7 @@ class ParseException extends Exception { * string literal. */ protected String add_escapes(String str) { - StringBuffer retval = new StringBuffer(); + StringBuilder retval = new StringBuilder(); char ch; for (int i = 0; i < str.length(); i++) { switch (str.charAt(i)) diff --git a/jdk/src/share/classes/com/sun/jmx/snmp/IPAcl/SnmpAcl.java b/jdk/src/share/classes/com/sun/jmx/snmp/IPAcl/SnmpAcl.java index a8e43c5337e..1a3fb7cc0cf 100644 --- a/jdk/src/share/classes/com/sun/jmx/snmp/IPAcl/SnmpAcl.java +++ b/jdk/src/share/classes/com/sun/jmx/snmp/IPAcl/SnmpAcl.java @@ -186,8 +186,8 @@ public class SnmpAcl implements InetAddressAcl, Serializable { public static String getDefaultAclFileName() { final String fileSeparator = System.getProperty("file.separator"); - final StringBuffer defaultAclName = - new StringBuffer(System.getProperty("java.home")). + final StringBuilder defaultAclName = + new StringBuilder(System.getProperty("java.home")). append(fileSeparator).append("lib").append(fileSeparator). append("snmp.acl"); return defaultAclName.toString(); diff --git a/jdk/src/share/classes/com/sun/jmx/snmp/IPAcl/TokenMgrError.java b/jdk/src/share/classes/com/sun/jmx/snmp/IPAcl/TokenMgrError.java index 1a0eba110ab..b09c4530d83 100644 --- a/jdk/src/share/classes/com/sun/jmx/snmp/IPAcl/TokenMgrError.java +++ b/jdk/src/share/classes/com/sun/jmx/snmp/IPAcl/TokenMgrError.java @@ -65,7 +65,7 @@ class TokenMgrError extends Error * equivalents in the given string */ protected static final String addEscapes(String str) { - StringBuffer retval = new StringBuffer(); + StringBuilder retval = new StringBuilder(); char ch; for (int i = 0; i < str.length(); i++) { switch (str.charAt(i)) diff --git a/jdk/src/share/classes/com/sun/jmx/snmp/SnmpCounter64.java b/jdk/src/share/classes/com/sun/jmx/snmp/SnmpCounter64.java index 7d29b251127..f65d887050b 100644 --- a/jdk/src/share/classes/com/sun/jmx/snmp/SnmpCounter64.java +++ b/jdk/src/share/classes/com/sun/jmx/snmp/SnmpCounter64.java @@ -84,7 +84,7 @@ public class SnmpCounter64 extends SnmpValue { * @return The Long representation of the value. */ public Long toLong() { - return new Long(value) ; + return value; } /** diff --git a/jdk/src/share/classes/com/sun/jmx/snmp/SnmpInt.java b/jdk/src/share/classes/com/sun/jmx/snmp/SnmpInt.java index a6114d7dbc5..eb536581bb8 100644 --- a/jdk/src/share/classes/com/sun/jmx/snmp/SnmpInt.java +++ b/jdk/src/share/classes/com/sun/jmx/snmp/SnmpInt.java @@ -130,7 +130,7 @@ public class SnmpInt extends SnmpValue { * @return The Long representation of the value. */ public Long toLong() { - return new Long(value) ; + return value; } /** diff --git a/jdk/src/share/classes/com/sun/jmx/snmp/SnmpMessage.java b/jdk/src/share/classes/com/sun/jmx/snmp/SnmpMessage.java index 32685602ff0..ec4c87466c0 100644 --- a/jdk/src/share/classes/com/sun/jmx/snmp/SnmpMessage.java +++ b/jdk/src/share/classes/com/sun/jmx/snmp/SnmpMessage.java @@ -347,7 +347,7 @@ public class SnmpMessage extends SnmpMsg implements SnmpDefinitions { * @return The string containing the dump. */ public String printMessage() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); if (community == null) { sb.append("Community: null") ; } diff --git a/jdk/src/share/classes/com/sun/jmx/snmp/SnmpMsg.java b/jdk/src/share/classes/com/sun/jmx/snmp/SnmpMsg.java index d72dc822c2e..cea4c744ad0 100644 --- a/jdk/src/share/classes/com/sun/jmx/snmp/SnmpMsg.java +++ b/jdk/src/share/classes/com/sun/jmx/snmp/SnmpMsg.java @@ -181,22 +181,22 @@ public abstract class SnmpMsg implements SnmpDefinitions { * @return The string containing the dump. */ public static String dumpHexBuffer(byte [] b, int offset, int len) { - StringBuffer buf = new StringBuffer(len << 1) ; + StringBuilder sb = new StringBuilder(len << 1) ; int k = 1 ; int flen = offset + len ; for (int i = offset; i < flen ; i++) { int j = b[i] & 0xFF ; - buf.append(Character.forDigit((j >>> 4) , 16)) ; - buf.append(Character.forDigit((j & 0x0F), 16)) ; + sb.append(Character.forDigit((j >>> 4), 16)) ; + sb.append(Character.forDigit((j & 0x0F), 16)) ; k++ ; if (k%16 == 0) { - buf.append('\n') ; + sb.append('\n') ; k = 1 ; } else - buf.append(' ') ; + sb.append(' ') ; } - return buf.toString() ; + return sb.toString() ; } /** @@ -205,7 +205,7 @@ public abstract class SnmpMsg implements SnmpDefinitions { * @return The string containing the dump. */ public String printMessage() { - StringBuffer sb = new StringBuffer() ; + StringBuilder sb = new StringBuilder() ; sb.append("Version: ") ; sb.append(version) ; sb.append("\n") ; diff --git a/jdk/src/share/classes/com/sun/jmx/snmp/SnmpOpaque.java b/jdk/src/share/classes/com/sun/jmx/snmp/SnmpOpaque.java index afe948e1519..50bb8b8c9aa 100644 --- a/jdk/src/share/classes/com/sun/jmx/snmp/SnmpOpaque.java +++ b/jdk/src/share/classes/com/sun/jmx/snmp/SnmpOpaque.java @@ -73,7 +73,7 @@ public class SnmpOpaque extends SnmpString { * @return The String representation of the value. */ public String toString() { - StringBuffer result = new StringBuffer() ; + StringBuilder result = new StringBuilder() ; for (int i = 0 ; i < value.length ; i++) { byte b = value[i] ; int n = (b >= 0) ? b : b + 256 ; diff --git a/jdk/src/share/classes/com/sun/jmx/snmp/SnmpString.java b/jdk/src/share/classes/com/sun/jmx/snmp/SnmpString.java index 169b67bcad3..675386ab1be 100644 --- a/jdk/src/share/classes/com/sun/jmx/snmp/SnmpString.java +++ b/jdk/src/share/classes/com/sun/jmx/snmp/SnmpString.java @@ -140,7 +140,7 @@ public class SnmpString extends SnmpValue { public Byte[] toByte() { Byte[] result = new Byte[value.length] ; for (int i = 0 ; i < value.length ; i++) { - result[i] = new Byte(value[i]) ; + result[i] = value[i]; } return result ; } diff --git a/jdk/src/share/classes/com/sun/jmx/snmp/SnmpV3Message.java b/jdk/src/share/classes/com/sun/jmx/snmp/SnmpV3Message.java index bcdcc3ed0a0..64288f14c61 100644 --- a/jdk/src/share/classes/com/sun/jmx/snmp/SnmpV3Message.java +++ b/jdk/src/share/classes/com/sun/jmx/snmp/SnmpV3Message.java @@ -478,7 +478,7 @@ public class SnmpV3Message extends SnmpMsg { * @return The string containing the dump. */ public String printMessage() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append("msgId : " + msgId + "\n"); sb.append("msgMaxSize : " + msgMaxSize + "\n"); sb.append("msgFlags : " + msgFlags + "\n"); diff --git a/jdk/src/share/classes/com/sun/jmx/snmp/agent/SnmpMibGroup.java b/jdk/src/share/classes/com/sun/jmx/snmp/agent/SnmpMibGroup.java index b689ef287e7..99223ea0cb8 100644 --- a/jdk/src/share/classes/com/sun/jmx/snmp/agent/SnmpMibGroup.java +++ b/jdk/src/share/classes/com/sun/jmx/snmp/agent/SnmpMibGroup.java @@ -136,7 +136,7 @@ public abstract class SnmpMibGroup extends SnmpMibOid */ public boolean isNestedArc(long arc) { if (subgroups == null) return false; - Object obj = subgroups.get(new Long(arc)); + Object obj = subgroups.get(arc); // if the arc is registered in the hashtable, // it leads to a subgroup. return (obj != null); @@ -260,7 +260,7 @@ public abstract class SnmpMibGroup extends SnmpMibOid * */ void registerNestedArc(long arc) { - Long obj = new Long(arc); + Long obj = arc; if (subgroups == null) subgroups = new Hashtable<>(); // registers the arc in the hashtable. subgroups.put(obj,obj); diff --git a/jdk/src/share/classes/com/sun/jmx/snmp/daemon/SnmpAdaptorServer.java b/jdk/src/share/classes/com/sun/jmx/snmp/daemon/SnmpAdaptorServer.java index 612d4c57437..b55c32ab1ea 100644 --- a/jdk/src/share/classes/com/sun/jmx/snmp/daemon/SnmpAdaptorServer.java +++ b/jdk/src/share/classes/com/sun/jmx/snmp/daemon/SnmpAdaptorServer.java @@ -858,7 +858,7 @@ public class SnmpAdaptorServer extends CommunicatorServer */ @Override public Long getSnmpOutTraps() { - return new Long(snmpOutTraps); + return (long)snmpOutTraps; } /** @@ -868,7 +868,7 @@ public class SnmpAdaptorServer extends CommunicatorServer */ @Override public Long getSnmpOutGetResponses() { - return new Long(snmpOutGetResponses); + return (long)snmpOutGetResponses; } /** @@ -878,7 +878,7 @@ public class SnmpAdaptorServer extends CommunicatorServer */ @Override public Long getSnmpOutGenErrs() { - return new Long(snmpOutGenErrs); + return (long)snmpOutGenErrs; } /** @@ -888,7 +888,7 @@ public class SnmpAdaptorServer extends CommunicatorServer */ @Override public Long getSnmpOutBadValues() { - return new Long(snmpOutBadValues); + return (long)snmpOutBadValues; } /** @@ -898,7 +898,7 @@ public class SnmpAdaptorServer extends CommunicatorServer */ @Override public Long getSnmpOutNoSuchNames() { - return new Long(snmpOutNoSuchNames); + return (long)snmpOutNoSuchNames; } /** @@ -908,7 +908,7 @@ public class SnmpAdaptorServer extends CommunicatorServer */ @Override public Long getSnmpOutTooBigs() { - return new Long(snmpOutTooBigs); + return (long)snmpOutTooBigs; } /** @@ -918,7 +918,7 @@ public class SnmpAdaptorServer extends CommunicatorServer */ @Override public Long getSnmpInASNParseErrs() { - return new Long(snmpInASNParseErrs); + return (long)snmpInASNParseErrs; } /** @@ -928,7 +928,7 @@ public class SnmpAdaptorServer extends CommunicatorServer */ @Override public Long getSnmpInBadCommunityUses() { - return new Long(snmpInBadCommunityUses); + return (long)snmpInBadCommunityUses; } /** @@ -939,7 +939,7 @@ public class SnmpAdaptorServer extends CommunicatorServer */ @Override public Long getSnmpInBadCommunityNames() { - return new Long(snmpInBadCommunityNames); + return (long)snmpInBadCommunityNames; } /** @@ -949,7 +949,7 @@ public class SnmpAdaptorServer extends CommunicatorServer */ @Override public Long getSnmpInBadVersions() { - return new Long(snmpInBadVersions); + return (long)snmpInBadVersions; } /** @@ -959,7 +959,7 @@ public class SnmpAdaptorServer extends CommunicatorServer */ @Override public Long getSnmpOutPkts() { - return new Long(snmpOutPkts); + return (long)snmpOutPkts; } /** @@ -969,7 +969,7 @@ public class SnmpAdaptorServer extends CommunicatorServer */ @Override public Long getSnmpInPkts() { - return new Long(snmpInPkts); + return (long)snmpInPkts; } /** @@ -979,7 +979,7 @@ public class SnmpAdaptorServer extends CommunicatorServer */ @Override public Long getSnmpInGetRequests() { - return new Long(snmpInGetRequests); + return (long)snmpInGetRequests; } /** @@ -989,7 +989,7 @@ public class SnmpAdaptorServer extends CommunicatorServer */ @Override public Long getSnmpInGetNexts() { - return new Long(snmpInGetNexts); + return (long)snmpInGetNexts; } /** @@ -999,7 +999,7 @@ public class SnmpAdaptorServer extends CommunicatorServer */ @Override public Long getSnmpInSetRequests() { - return new Long(snmpInSetRequests); + return (long)snmpInSetRequests; } /** @@ -1009,7 +1009,7 @@ public class SnmpAdaptorServer extends CommunicatorServer */ @Override public Long getSnmpInTotalSetVars() { - return new Long(snmpInTotalSetVars); + return (long)snmpInTotalSetVars; } /** @@ -1019,7 +1019,7 @@ public class SnmpAdaptorServer extends CommunicatorServer */ @Override public Long getSnmpInTotalReqVars() { - return new Long(snmpInTotalReqVars); + return (long)snmpInTotalReqVars; } /** @@ -1032,7 +1032,7 @@ public class SnmpAdaptorServer extends CommunicatorServer */ @Override public Long getSnmpSilentDrops() { - return new Long(snmpSilentDrops); + return (long)snmpSilentDrops; } /** @@ -1045,7 +1045,7 @@ public class SnmpAdaptorServer extends CommunicatorServer */ @Override public Long getSnmpProxyDrops() { - return new Long(0); + return 0L; } diff --git a/jdk/src/share/classes/com/sun/jndi/cosnaming/CNNameParser.java b/jdk/src/share/classes/com/sun/jndi/cosnaming/CNNameParser.java index 3b746528c3b..ebd0f05e65a 100644 --- a/jdk/src/share/classes/com/sun/jndi/cosnaming/CNNameParser.java +++ b/jdk/src/share/classes/com/sun/jndi/cosnaming/CNNameParser.java @@ -96,7 +96,7 @@ final public class CNNameParser implements NameParser { * Used by CNCtx.getNameInNamespace(), CNCompoundName.toString(). */ static String cosNameToInsString(NameComponent[] cname) { - StringBuffer str = new StringBuffer(); + StringBuilder str = new StringBuilder(); for ( int i = 0; i < cname.length; i++) { if ( i > 0) { str.append(compSeparator); @@ -254,7 +254,7 @@ final public class CNNameParser implements NameParser { } private static String stringifyComponent(NameComponent comp) { - StringBuffer one = new StringBuffer(escape(comp.id)); + StringBuilder one = new StringBuilder(escape(comp.id)); if (comp.kind != null && !comp.kind.equals("")) { one.append(kindSeparator + escape(comp.kind)); } diff --git a/jdk/src/share/classes/com/sun/jndi/dns/DnsContextFactory.java b/jdk/src/share/classes/com/sun/jndi/dns/DnsContextFactory.java index 587d9b236d5..b6ad2c15bfc 100644 --- a/jdk/src/share/classes/com/sun/jndi/dns/DnsContextFactory.java +++ b/jdk/src/share/classes/com/sun/jndi/dns/DnsContextFactory.java @@ -198,14 +198,14 @@ public class DnsContextFactory implements InitialContextFactory { } } - StringBuffer buf = new StringBuffer(); + StringBuilder sb = new StringBuilder(); for (int i = 0; i < servers.length; i++) { if (i > 0) { - buf.append(' '); + sb.append(' '); } - buf.append("dns://").append(servers[i]).append(path); + sb.append("dns://").append(servers[i]).append(path); } - return buf.toString(); + return sb.toString(); } /* diff --git a/jdk/src/share/classes/com/sun/jndi/dns/DnsName.java b/jdk/src/share/classes/com/sun/jndi/dns/DnsName.java index d2f76added9..eb4a7fb96f4 100644 --- a/jdk/src/share/classes/com/sun/jndi/dns/DnsName.java +++ b/jdk/src/share/classes/com/sun/jndi/dns/DnsName.java @@ -415,7 +415,7 @@ public final class DnsName implements Name { */ private void parse(String name) throws InvalidNameException { - StringBuffer label = new StringBuffer(); // label being parsed + StringBuilder label = new StringBuilder(); // label being parsed for (int i = 0; i < name.length(); i++) { char c = name.charAt(i); @@ -564,15 +564,15 @@ public final class DnsName implements Name { * into account. See compareLabels(). */ private static String keyForLabel(String label) { - StringBuffer buf = new StringBuffer(label.length()); + StringBuilder sb = new StringBuilder(label.length()); for (int i = 0; i < label.length(); i++) { char c = label.charAt(i); if (c >= 'A' && c <= 'Z') { c += 'a' - 'A'; // to lower case } - buf.append(c); + sb.append(c); } - return buf.toString(); + return sb.toString(); } diff --git a/jdk/src/share/classes/com/sun/jndi/dns/ResourceRecord.java b/jdk/src/share/classes/com/sun/jndi/dns/ResourceRecord.java index 846135c45aa..c34bd680983 100644 --- a/jdk/src/share/classes/com/sun/jndi/dns/ResourceRecord.java +++ b/jdk/src/share/classes/com/sun/jndi/dns/ResourceRecord.java @@ -596,21 +596,21 @@ public class ResourceRecord { // If bestBase != -1, compress zeros in [bestBase, bestBase+bestLen) boolean compress = (bestBase != -1); - StringBuffer buf = new StringBuffer(40); + StringBuilder sb = new StringBuilder(40); if (bestBase == 0) { - buf.append(':'); + sb.append(':'); } for (int i = 0; i < 8; i++) { if (!compress || (i < bestBase) || (i >= bestBase + bestLen)) { - buf.append(Integer.toHexString(addr6[i])); + sb.append(Integer.toHexString(addr6[i])); if (i < 7) { - buf.append(':'); + sb.append(':'); } } else if (compress && (i == bestBase)) { // first compressed zero - buf.append(':'); + sb.append(':'); } } - return buf.toString(); + return sb.toString(); } } diff --git a/jdk/src/share/classes/com/sun/jndi/ldap/ClientId.java b/jdk/src/share/classes/com/sun/jndi/ldap/ClientId.java index 9f75e8373e3..7a30c1c7beb 100644 --- a/jdk/src/share/classes/com/sun/jndi/ldap/ClientId.java +++ b/jdk/src/share/classes/com/sun/jndi/ldap/ClientId.java @@ -210,7 +210,7 @@ class ClientId { if (ctls == null) { return ""; } - StringBuffer str = new StringBuffer(); + StringBuilder str = new StringBuilder(); for (int i = 0; i < ctls.length; i++) { str.append(ctls[i].getID()); str.append(' '); diff --git a/jdk/src/share/classes/com/sun/jndi/ldap/Connection.java b/jdk/src/share/classes/com/sun/jndi/ldap/Connection.java index d41c94480e9..c5a957ce6d7 100644 --- a/jdk/src/share/classes/com/sun/jndi/ldap/Connection.java +++ b/jdk/src/share/classes/com/sun/jndi/ldap/Connection.java @@ -111,6 +111,7 @@ public final class Connection implements Runnable { private static final boolean debug = false; private static final int dump = 0; // > 0 r, > 1 rw + public static final long DEFAULT_READ_TIMEOUT_MILLIS = 15 * 1000; // 15 second timeout; final private Thread worker; // Initialized in constructor @@ -460,7 +461,7 @@ public final class Connection implements Runnable { // available ldr.wait(readTimeout); } else { - ldr.wait(15 * 1000); // 15 second timeout + ldr.wait(DEFAULT_READ_TIMEOUT_MILLIS); } waited = true; } else { diff --git a/jdk/src/share/classes/com/sun/jndi/ldap/DigestClientId.java b/jdk/src/share/classes/com/sun/jndi/ldap/DigestClientId.java index b4f19d02b3b..e7078098cbd 100644 --- a/jdk/src/share/classes/com/sun/jndi/ldap/DigestClientId.java +++ b/jdk/src/share/classes/com/sun/jndi/ldap/DigestClientId.java @@ -103,14 +103,14 @@ class DigestClientId extends SimpleClientId { public String toString() { if (propvals != null) { - StringBuffer buf = new StringBuffer(); + StringBuilder sb = new StringBuilder(); for (int i = 0; i < propvals.length; i++) { - buf.append(':'); + sb.append(':'); if (propvals[i] != null) { - buf.append(propvals[i]); + sb.append(propvals[i]); } } - return super.toString() + buf.toString(); + return super.toString() + sb.toString(); } else { return super.toString(); } diff --git a/jdk/src/share/classes/com/sun/jndi/ldap/LdapPoolManager.java b/jdk/src/share/classes/com/sun/jndi/ldap/LdapPoolManager.java index 88b36cba315..a40b964c592 100644 --- a/jdk/src/share/classes/com/sun/jndi/ldap/LdapPoolManager.java +++ b/jdk/src/share/classes/com/sun/jndi/ldap/LdapPoolManager.java @@ -421,7 +421,7 @@ public final class LdapPoolManager { try { return Long.getLong(propName, defVal); } catch (SecurityException e) { - return new Long(defVal); + return defVal; } } }); diff --git a/jdk/src/share/classes/com/sun/jndi/ldap/LdapSchemaParser.java b/jdk/src/share/classes/com/sun/jndi/ldap/LdapSchemaParser.java index 7804314fc15..7fddd7799f5 100644 --- a/jdk/src/share/classes/com/sun/jndi/ldap/LdapSchemaParser.java +++ b/jdk/src/share/classes/com/sun/jndi/ldap/LdapSchemaParser.java @@ -767,7 +767,7 @@ final class LdapSchemaParser { final private String classDef2ObjectDesc(Attributes attrs) throws NamingException { - StringBuffer objectDesc = new StringBuffer("( "); + StringBuilder objectDesc = new StringBuilder("( "); Attribute attr = null; int count = 0; @@ -879,7 +879,7 @@ final class LdapSchemaParser { final private String attrDef2AttrDesc(Attributes attrs) throws NamingException { - StringBuffer attrDesc = new StringBuffer("( "); // opening parens + StringBuilder attrDesc = new StringBuilder("( "); // opening parens Attribute attr = null; int count = 0; @@ -1012,7 +1012,7 @@ final class LdapSchemaParser { final private String syntaxDef2SyntaxDesc(Attributes attrs) throws NamingException { - StringBuffer syntaxDesc = new StringBuffer("( "); // opening parens + StringBuilder syntaxDesc = new StringBuilder("( "); // opening parens Attribute attr = null; int count = 0; @@ -1068,7 +1068,7 @@ final class LdapSchemaParser { final private String matchRuleDef2MatchRuleDesc(Attributes attrs) throws NamingException { - StringBuffer matchRuleDesc = new StringBuffer("( "); // opening parens + StringBuilder matchRuleDesc = new StringBuilder("( "); // opening parens Attribute attr = null; int count = 0; @@ -1196,7 +1196,7 @@ final class LdapSchemaParser { // write QDList - StringBuffer qdList = new StringBuffer(attr.getID()); + StringBuilder qdList = new StringBuilder(attr.getID()); qdList.append(WHSP); qdList.append(OID_LIST_BEGIN); @@ -1233,7 +1233,7 @@ final class LdapSchemaParser { // write OID List - StringBuffer oidList = new StringBuffer(oidsAttr.getID()); + StringBuilder oidList = new StringBuilder(oidsAttr.getID()); oidList.append(WHSP); oidList.append(OID_LIST_BEGIN); diff --git a/jdk/src/share/classes/com/sun/jndi/ldap/NamingEventNotifier.java b/jdk/src/share/classes/com/sun/jndi/ldap/NamingEventNotifier.java index d614aa943da..20794f8e502 100644 --- a/jdk/src/share/classes/com/sun/jndi/ldap/NamingEventNotifier.java +++ b/jdk/src/share/classes/com/sun/jndi/ldap/NamingEventNotifier.java @@ -221,7 +221,7 @@ final class NamingEventNotifier implements Runnable { return; NamingEvent e = new NamingEvent(eventSrc, NamingEvent.OBJECT_ADDED, - newBd, null, new Long(changeID)); + newBd, null, changeID); support.queueEvent(e, namingListeners); } @@ -233,7 +233,7 @@ final class NamingEventNotifier implements Runnable { return; NamingEvent e = new NamingEvent(eventSrc, NamingEvent.OBJECT_REMOVED, - null, oldBd, new Long(changeID)); + null, oldBd, changeID); support.queueEvent(e, namingListeners); } @@ -248,7 +248,7 @@ final class NamingEventNotifier implements Runnable { Binding oldBd = new Binding(newBd.getName(), null, newBd.isRelative()); NamingEvent e = new NamingEvent( - eventSrc, NamingEvent.OBJECT_CHANGED, newBd, oldBd, new Long(changeID)); + eventSrc, NamingEvent.OBJECT_CHANGED, newBd, oldBd, changeID); support.queueEvent(e, namingListeners); } @@ -273,7 +273,7 @@ final class NamingEventNotifier implements Runnable { } NamingEvent e = new NamingEvent( - eventSrc, NamingEvent.OBJECT_RENAMED, newBd, oldBd, new Long(changeID)); + eventSrc, NamingEvent.OBJECT_RENAMED, newBd, oldBd, changeID); support.queueEvent(e, namingListeners); } diff --git a/jdk/src/share/classes/com/sun/jndi/ldap/ServiceLocator.java b/jdk/src/share/classes/com/sun/jndi/ldap/ServiceLocator.java index 5bbd58da462..05df1bbd6b7 100644 --- a/jdk/src/share/classes/com/sun/jndi/ldap/ServiceLocator.java +++ b/jdk/src/share/classes/com/sun/jndi/ldap/ServiceLocator.java @@ -68,7 +68,7 @@ class ServiceLocator { if (dn == null) { return null; } - StringBuffer domain = new StringBuffer(); + StringBuilder domain = new StringBuilder(); LdapName ldapName = new LdapName(dn); // process RDNs left-to-right diff --git a/jdk/src/share/classes/com/sun/jndi/ldap/sasl/DefaultCallbackHandler.java b/jdk/src/share/classes/com/sun/jndi/ldap/sasl/DefaultCallbackHandler.java index 3bea1cc403d..3e0098eaaa4 100644 --- a/jdk/src/share/classes/com/sun/jndi/ldap/sasl/DefaultCallbackHandler.java +++ b/jdk/src/share/classes/com/sun/jndi/ldap/sasl/DefaultCallbackHandler.java @@ -88,7 +88,7 @@ final class DefaultCallbackHandler implements CallbackHandler { } } if (selected == -1) { - StringBuffer allChoices = new StringBuffer(); + StringBuilder allChoices = new StringBuilder(); for (int j = 0; j < choices.length; j++) { allChoices.append(choices[j] + ","); } diff --git a/jdk/src/share/classes/com/sun/jndi/toolkit/dir/SearchFilter.java b/jdk/src/share/classes/com/sun/jndi/toolkit/dir/SearchFilter.java index ffdc9b8279f..cf23c3dd2e4 100644 --- a/jdk/src/share/classes/com/sun/jndi/toolkit/dir/SearchFilter.java +++ b/jdk/src/share/classes/com/sun/jndi/toolkit/dir/SearchFilter.java @@ -379,7 +379,7 @@ public class SearchFilter implements AttrFilter { // used for substring comparisons (where proto has "*" wildcards private boolean substringMatch(String proto, String value) { // simple case 1: "*" means attribute presence is being tested - if(proto.equals(new Character(WILDCARD_TOKEN).toString())) { + if(proto.equals(Character.toString(WILDCARD_TOKEN))) { if(debug) {System.out.println("simple presence assertion");} return true; } @@ -520,30 +520,30 @@ public class SearchFilter implements AttrFilter { str = (String)obj; } int len = str.length(); - StringBuffer buf = new StringBuffer(len); + StringBuilder sb = new StringBuilder(len); char ch; for (int i = 0; i < len; i++) { switch (ch=str.charAt(i)) { case '*': - buf.append("\\2a"); + sb.append("\\2a"); break; case '(': - buf.append("\\28"); + sb.append("\\28"); break; case ')': - buf.append("\\29"); + sb.append("\\29"); break; case '\\': - buf.append("\\5c"); + sb.append("\\5c"); break; case 0: - buf.append("\\00"); + sb.append("\\00"); break; default: - buf.append(ch); + sb.append(ch); } } - return buf.toString(); + return sb.toString(); } @@ -585,7 +585,7 @@ public class SearchFilter implements AttrFilter { int param; int where = 0, start = 0; - StringBuffer answer = new StringBuffer(expr.length()); + StringBuilder answer = new StringBuilder(expr.length()); while ((where = findUnescaped('{', expr, start)) >= 0) { int pstart = where + 1; // skip '{' diff --git a/jdk/src/share/classes/com/sun/media/sound/SoftPerformer.java b/jdk/src/share/classes/com/sun/media/sound/SoftPerformer.java index 905bdb3128e..5cd7c6eb92e 100644 --- a/jdk/src/share/classes/com/sun/media/sound/SoftPerformer.java +++ b/jdk/src/share/classes/com/sun/media/sound/SoftPerformer.java @@ -326,7 +326,7 @@ public final class SoftPerformer { private static KeySortComparator keySortComparator = new KeySortComparator(); private String extractKeys(ModelConnectionBlock conn) { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); if (conn.getSources() != null) { sb.append("["); ModelSource[] srcs = conn.getSources(); diff --git a/jdk/src/share/classes/com/sun/media/sound/WaveExtensibleFileReader.java b/jdk/src/share/classes/com/sun/media/sound/WaveExtensibleFileReader.java index 827cef6a23a..ba46be6cf5a 100644 --- a/jdk/src/share/classes/com/sun/media/sound/WaveExtensibleFileReader.java +++ b/jdk/src/share/classes/com/sun/media/sound/WaveExtensibleFileReader.java @@ -162,7 +162,7 @@ public final class WaveExtensibleFileReader extends AudioFileReader { 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71); private String decodeChannelMask(long channelmask) { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); long m = 1; for (int i = 0; i < allchannelnames.length; i++) { if ((channelmask & m) != 0L) { diff --git a/jdk/src/share/classes/com/sun/media/sound/services/linux-i586/javax.sound.sampled.spi.MixerProvider b/jdk/src/share/classes/com/sun/media/sound/services/linux-i586/javax.sound.sampled.spi.MixerProvider deleted file mode 100644 index 56b8f12b0fb..00000000000 --- a/jdk/src/share/classes/com/sun/media/sound/services/linux-i586/javax.sound.sampled.spi.MixerProvider +++ /dev/null @@ -1,6 +0,0 @@ -# service provider file for Linux: with DirectAudioDeviceProvider -# last mixer is default mixer -com.sun.media.sound.PortMixerProvider -com.sun.media.sound.SimpleInputDeviceProvider -com.sun.media.sound.DirectAudioDeviceProvider -com.sun.media.sound.HeadspaceMixerProvider diff --git a/jdk/src/share/classes/com/sun/media/sound/services/windows-i586/javax.sound.sampled.spi.MixerProvider b/jdk/src/share/classes/com/sun/media/sound/services/windows-i586/javax.sound.sampled.spi.MixerProvider deleted file mode 100644 index 7e39afe741a..00000000000 --- a/jdk/src/share/classes/com/sun/media/sound/services/windows-i586/javax.sound.sampled.spi.MixerProvider +++ /dev/null @@ -1,6 +0,0 @@ -# service provider file for Windows: with DirectAudioDeviceProvider -# last mixer is default mixer -com.sun.media.sound.PortMixerProvider -com.sun.media.sound.SimpleInputDeviceProvider -com.sun.media.sound.DirectAudioDeviceProvider -com.sun.media.sound.HeadspaceMixerProvider diff --git a/jdk/src/share/classes/com/sun/media/sound/services/windows-ia64/javax.sound.sampled.spi.MixerProvider b/jdk/src/share/classes/com/sun/media/sound/services/windows-ia64/javax.sound.sampled.spi.MixerProvider deleted file mode 100644 index cf3bc8acaa6..00000000000 --- a/jdk/src/share/classes/com/sun/media/sound/services/windows-ia64/javax.sound.sampled.spi.MixerProvider +++ /dev/null @@ -1,6 +0,0 @@ -# service provider file for Windows IA64: with DirectAudioDeviceProvider -# last mixer is default mixer -com.sun.media.sound.PortMixerProvider -com.sun.media.sound.SimpleInputDeviceProvider -com.sun.media.sound.DirectAudioDeviceProvider -com.sun.media.sound.HeadspaceMixerProvider diff --git a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/Base64.java b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/Base64.java index db1f49eaee4..de822922b36 100644 --- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/Base64.java +++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/Base64.java @@ -257,7 +257,7 @@ public class Base64 { public static final byte[] decode(Element element) throws Base64DecodingException { Node sibling = element.getFirstChild(); - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); while (sibling != null) { if (sibling.getNodeType() == Node.TEXT_NODE) { diff --git a/jdk/src/share/classes/com/sun/security/auth/SolarisNumericGroupPrincipal.java b/jdk/src/share/classes/com/sun/security/auth/SolarisNumericGroupPrincipal.java index 7924362f28b..04229eaab9c 100644 --- a/jdk/src/share/classes/com/sun/security/auth/SolarisNumericGroupPrincipal.java +++ b/jdk/src/share/classes/com/sun/security/auth/SolarisNumericGroupPrincipal.java @@ -110,7 +110,7 @@ public class SolarisNumericGroupPrincipal implements * */ public SolarisNumericGroupPrincipal(long name, boolean primaryGroup) { - this.name = (new Long(name)).toString(); + this.name = Long.toString(name); this.primaryGroup = primaryGroup; } @@ -137,7 +137,7 @@ public class SolarisNumericGroupPrincipal implements * SolarisNumericGroupPrincipal as a long. */ public long longValue() { - return ((new Long(name)).longValue()); + return Long.parseLong(name); } /** diff --git a/jdk/src/share/classes/com/sun/security/auth/SolarisNumericUserPrincipal.java b/jdk/src/share/classes/com/sun/security/auth/SolarisNumericUserPrincipal.java index 86f7ed67768..d7ba9c038d7 100644 --- a/jdk/src/share/classes/com/sun/security/auth/SolarisNumericUserPrincipal.java +++ b/jdk/src/share/classes/com/sun/security/auth/SolarisNumericUserPrincipal.java @@ -96,7 +96,7 @@ public class SolarisNumericUserPrincipal implements * represented as a long. */ public SolarisNumericUserPrincipal(long name) { - this.name = (new Long(name)).toString(); + this.name = Long.toString(name); } /** @@ -122,7 +122,7 @@ public class SolarisNumericUserPrincipal implements * SolarisNumericUserPrincipal as a long. */ public long longValue() { - return ((new Long(name)).longValue()); + return Long.parseLong(name); } /** diff --git a/jdk/src/share/classes/com/sun/security/auth/UnixNumericGroupPrincipal.java b/jdk/src/share/classes/com/sun/security/auth/UnixNumericGroupPrincipal.java index db5775ab329..63c9d28c34d 100644 --- a/jdk/src/share/classes/com/sun/security/auth/UnixNumericGroupPrincipal.java +++ b/jdk/src/share/classes/com/sun/security/auth/UnixNumericGroupPrincipal.java @@ -102,7 +102,7 @@ public class UnixNumericGroupPrincipal implements * */ public UnixNumericGroupPrincipal(long name, boolean primaryGroup) { - this.name = (new Long(name)).toString(); + this.name = Long.toString(name); this.primaryGroup = primaryGroup; } @@ -129,7 +129,7 @@ public class UnixNumericGroupPrincipal implements * UnixNumericGroupPrincipal as a long. */ public long longValue() { - return ((new Long(name)).longValue()); + return Long.parseLong(name); } /** diff --git a/jdk/src/share/classes/com/sun/security/auth/UnixNumericUserPrincipal.java b/jdk/src/share/classes/com/sun/security/auth/UnixNumericUserPrincipal.java index c6dfd7eaf1b..e2016efe77d 100644 --- a/jdk/src/share/classes/com/sun/security/auth/UnixNumericUserPrincipal.java +++ b/jdk/src/share/classes/com/sun/security/auth/UnixNumericUserPrincipal.java @@ -87,7 +87,7 @@ public class UnixNumericUserPrincipal implements * represented as a long. */ public UnixNumericUserPrincipal(long name) { - this.name = (new Long(name)).toString(); + this.name = Long.toString(name); } /** @@ -113,7 +113,7 @@ public class UnixNumericUserPrincipal implements * UnixNumericUserPrincipal as a long. */ public long longValue() { - return ((new Long(name)).longValue()); + return Long.parseLong(name); } /** diff --git a/jdk/src/share/classes/com/sun/security/ntlm/Client.java b/jdk/src/share/classes/com/sun/security/ntlm/Client.java index ba3e90c3858..9aacd433793 100644 --- a/jdk/src/share/classes/com/sun/security/ntlm/Client.java +++ b/jdk/src/share/classes/com/sun/security/ntlm/Client.java @@ -46,7 +46,7 @@ public final class Client extends NTLM { final private String hostname; final private String username; - private String domain; // might be updated by Type 2 msg + private String domain; private byte[] pw1, pw2; /** @@ -82,7 +82,7 @@ public final class Client extends NTLM { } this.hostname = hostname; this.username = username; - this.domain = domain; + this.domain = domain == null ? "" : domain; this.pw1 = getP1(password); this.pw2 = getP2(password); debug("NTLM Client: (h,u,t,version(v)) = (%s,%s,%s,%s(%s))\n", @@ -95,19 +95,13 @@ public final class Client extends NTLM { */ public byte[] type1() { Writer p = new Writer(1, 32); - int flags = 0x8203; - if (hostname != null) { - flags |= 0x2000; - } - if (domain != null) { - flags |= 0x1000; - } + // Negotiate always sign, Negotiate NTLM, + // Request Target, Negotiate OEM, Negotiate unicode + int flags = 0x8207; if (v != Version.NTLM) { flags |= 0x80000; } p.writeInt(12, flags); - p.writeSecurityBuffer(24, hostname, false); - p.writeSecurityBuffer(16, domain, false); debug("NTLM Client: Type 1 created\n"); debug(p.getBytes()); return p.getBytes(); @@ -133,13 +127,10 @@ public final class Client extends NTLM { byte[] challenge = r.readBytes(24, 8); int inputFlags = r.readInt(20); boolean unicode = (inputFlags & 1) == 1; - String domainFromServer = r.readSecurityBuffer(12, unicode); - if (domainFromServer != null) { - domain = domainFromServer; - } - if (domain == null) { - domain = ""; - } + + // IE uses domainFromServer to generate an alist if server has not + // provided one. Firefox/WebKit do not. Neither do we. + //String domainFromServer = r.readSecurityBuffer(12, unicode); int flags = 0x88200 | (inputFlags & 3); Writer p = new Writer(3, 64); @@ -163,7 +154,9 @@ public final class Client extends NTLM { if (writeLM) lm = calcV2(nthash, username.toUpperCase(Locale.US)+domain, nonce, challenge); if (writeNTLM) { - byte[] alist = type2.length > 48 ? + // Some client create a alist even if server does not send + // one: (i16)2 (i16)len target_in_unicode (i16)0 (i16) 0 + byte[] alist = ((inputFlags & 0x800000) != 0) ? r.readSecurityBuffer(40) : new byte[0]; byte[] blob = new byte[32+alist.length]; System.arraycopy(new byte[]{1,1,0,0,0,0,0,0}, 0, blob, 0, 8); diff --git a/jdk/src/share/classes/com/sun/security/ntlm/Server.java b/jdk/src/share/classes/com/sun/security/ntlm/Server.java index 0593b2e1c89..adec1a3fa29 100644 --- a/jdk/src/share/classes/com/sun/security/ntlm/Server.java +++ b/jdk/src/share/classes/com/sun/security/ntlm/Server.java @@ -1,3 +1,4 @@ + /* * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -92,7 +93,9 @@ public abstract class Server extends NTLM { debug("NTLM Server: Type 1 received\n"); if (type1 != null) debug(type1); Writer p = new Writer(2, 32); - int flags = 0x80205; + // Negotiate NTLM2 Key, Target Type Domain, + // Negotiate NTLM, Request Target, Negotiate unicode + int flags = 0x90205; p.writeSecurityBuffer(12, domain, true); p.writeInt(20, flags); p.writeBytes(24, nonce); @@ -127,8 +130,9 @@ public abstract class Server extends NTLM { "Wrong domain: " + incomingDomain + " vs " + domain); // Needed? }*/ + boolean verified = false; - char[] password = getPassword(domain, username); + char[] password = getPassword(incomingDomain, username); if (password == null) { throw new NTLMException(NTLMException.USER_UNKNOWN, "Unknown user"); @@ -179,6 +183,8 @@ public abstract class Server extends NTLM { } } if (incomingNTLM.length > 0) { + // We didn't sent alist in type2(), so there + // is nothing to check here. byte[] clientBlob = Arrays.copyOfRange( incomingNTLM, 16, incomingNTLM.length); byte[] ntlmresponse = calcV2(nthash, diff --git a/jdk/src/share/classes/com/sun/security/sasl/CramMD5Base.java b/jdk/src/share/classes/com/sun/security/sasl/CramMD5Base.java index 5d0309c60d0..4e51266f97b 100644 --- a/jdk/src/share/classes/com/sun/security/sasl/CramMD5Base.java +++ b/jdk/src/share/classes/com/sun/security/sasl/CramMD5Base.java @@ -195,7 +195,7 @@ abstract class CramMD5Base { digest = md5.digest(); // Get character representation of digest - StringBuffer digestString = new StringBuffer(); + StringBuilder digestString = new StringBuilder(); for (i = 0; i < digest.length; i++) { if ((digest[i] & 0x000000ff) < 0x10) { diff --git a/jdk/src/share/classes/com/sun/security/sasl/CramMD5Server.java b/jdk/src/share/classes/com/sun/security/sasl/CramMD5Server.java index b87867b3ae7..94512f806dd 100644 --- a/jdk/src/share/classes/com/sun/security/sasl/CramMD5Server.java +++ b/jdk/src/share/classes/com/sun/security/sasl/CramMD5Server.java @@ -117,15 +117,15 @@ final class CramMD5Server extends CramMD5Base implements SaslServer { long rand = random.nextLong(); long timestamp = System.currentTimeMillis(); - StringBuffer buf = new StringBuffer(); - buf.append('<'); - buf.append(rand); - buf.append('.'); - buf.append(timestamp); - buf.append('@'); - buf.append(fqdn); - buf.append('>'); - String challengeStr = buf.toString(); + StringBuilder sb = new StringBuilder(); + sb.append('<'); + sb.append(rand); + sb.append('.'); + sb.append(timestamp); + sb.append('@'); + sb.append(fqdn); + sb.append('>'); + String challengeStr = sb.toString(); logger.log(Level.FINE, "CRAMSRV01:Generated challenge: {0}", challengeStr); diff --git a/jdk/src/share/classes/com/sun/security/sasl/digest/DigestMD5Base.java b/jdk/src/share/classes/com/sun/security/sasl/digest/DigestMD5Base.java index 548bac7273b..3469e708233 100644 --- a/jdk/src/share/classes/com/sun/security/sasl/digest/DigestMD5Base.java +++ b/jdk/src/share/classes/com/sun/security/sasl/digest/DigestMD5Base.java @@ -387,7 +387,7 @@ abstract class DigestMD5Base extends AbstractSaslImpl { protected byte[] binaryToHex(byte[] digest) throws UnsupportedEncodingException { - StringBuffer digestString = new StringBuffer(); + StringBuilder digestString = new StringBuilder(); for (int i = 0; i < digest.length; i ++) { if ((digest[i] & 0x000000ff) < 0x10) { @@ -598,7 +598,7 @@ abstract class DigestMD5Base extends AbstractSaslImpl { protected static String nonceCountToHex(int count) { String str = Integer.toHexString(count); - StringBuffer pad = new StringBuffer(); + StringBuilder pad = new StringBuilder(); if (str.length() < 8) { for (int i = 0; i < 8-str.length(); i ++) { @@ -1460,7 +1460,7 @@ abstract class DigestMD5Base extends AbstractSaslImpl { if (logger.isLoggable(Level.INFO)) { logger.log(Level.INFO, "DIGEST39:Incorrect padding: {0}", - new Byte(msgWithPadding[msgWithPadding.length - 1])); + msgWithPadding[msgWithPadding.length - 1]); } return EMPTY_BYTE_ARRAY; } diff --git a/jdk/src/share/classes/com/sun/security/sasl/digest/DigestMD5Server.java b/jdk/src/share/classes/com/sun/security/sasl/digest/DigestMD5Server.java index b722f0b36ba..449284258c3 100644 --- a/jdk/src/share/classes/com/sun/security/sasl/digest/DigestMD5Server.java +++ b/jdk/src/share/classes/com/sun/security/sasl/digest/DigestMD5Server.java @@ -203,19 +203,19 @@ final class DigestMD5Server extends DigestMD5Base implements SaslServer { String supportedCiphers = null; if ((allQop&PRIVACY_PROTECTION) != 0) { myCiphers = getPlatformCiphers(); - StringBuffer buf = new StringBuffer(); + StringBuilder sb = new StringBuilder(); // myCipher[i] is a byte that indicates whether CIPHER_TOKENS[i] // is supported for (int i = 0; i < CIPHER_TOKENS.length; i++) { if (myCiphers[i] != 0) { - if (buf.length() > 0) { - buf.append(','); + if (sb.length() > 0) { + sb.append(','); } - buf.append(CIPHER_TOKENS[i]); + sb.append(CIPHER_TOKENS[i]); } } - supportedCiphers = buf.toString(); + supportedCiphers = sb.toString(); } try { diff --git a/jdk/src/share/classes/com/sun/security/sasl/gsskerb/GssKrb5Base.java b/jdk/src/share/classes/com/sun/security/sasl/gsskerb/GssKrb5Base.java index 30461e25f7c..7a7dc52a26c 100644 --- a/jdk/src/share/classes/com/sun/security/sasl/gsskerb/GssKrb5Base.java +++ b/jdk/src/share/classes/com/sun/security/sasl/gsskerb/GssKrb5Base.java @@ -26,11 +26,14 @@ package com.sun.security.sasl.gsskerb; +import java.util.Locale; import java.util.Map; import java.util.logging.Level; import javax.security.sasl.*; import com.sun.security.sasl.util.AbstractSaslImpl; import org.ietf.jgss.*; +import com.sun.security.jgss.ExtendedGSSContext; +import com.sun.security.jgss.InquireType; abstract class GssKrb5Base extends AbstractSaslImpl { @@ -61,6 +64,36 @@ abstract class GssKrb5Base extends AbstractSaslImpl { return "GSSAPI"; } + @Override + public Object getNegotiatedProperty(String propName) { + if (!completed) { + throw new IllegalStateException("Authentication incomplete"); + } + String xprefix = "com.sun.security.jgss.inquiretype."; + if (propName.startsWith(xprefix)) { + String type = propName.substring(xprefix.length()); + if (logger.isLoggable(Level.FINEST)) { + logger.logp(Level.FINE, "GssKrb5Base", + "getNegotiatedProperty", propName); + } + for (InquireType t: InquireType.values()) { + if (t.name().toLowerCase(Locale.US).equals(type)) { + try { + return ((ExtendedGSSContext)secCtx).inquireSecContext(t); + } catch (GSSException e) { + if (logger.isLoggable(Level.FINEST)) { + logger.log(Level.WARNING, "inquireSecContext error", e); + } + return null; + } + } + } + // No such InquireType. Although not likely to be defined + // as a property in a parent class, still try it. + } + return super.getNegotiatedProperty(propName); + } + public byte[] unwrap(byte[] incoming, int start, int len) throws SaslException { if (!completed) { diff --git a/jdk/src/share/classes/com/sun/security/sasl/gsskerb/GssKrb5Client.java b/jdk/src/share/classes/com/sun/security/sasl/gsskerb/GssKrb5Client.java index e8d9a4cc866..aca462929f7 100644 --- a/jdk/src/share/classes/com/sun/security/sasl/gsskerb/GssKrb5Client.java +++ b/jdk/src/share/classes/com/sun/security/sasl/gsskerb/GssKrb5Client.java @@ -241,7 +241,7 @@ final class GssKrb5Client extends GssKrb5Base implements SaslClient { "KRB5CLNT05:Challenge [unwrapped]:", gssOutToken); } logger.log(Level.FINE, "KRB5CLNT06:Server protections: {0}", - new Byte(gssOutToken[0])); + gssOutToken[0]); } // Client selects preferred protection @@ -293,7 +293,7 @@ final class GssKrb5Client extends GssKrb5Base implements SaslClient { if (logger.isLoggable(Level.FINE)) { logger.log(Level.FINE, "KRB5CLNT08:Selected protection: {0}; privacy: {1}; integrity: {2}", - new Object[]{new Byte(selectedQop), + new Object[]{selectedQop, Boolean.valueOf(privacy), Boolean.valueOf(integrity)}); } diff --git a/jdk/src/share/classes/com/sun/security/sasl/gsskerb/GssKrb5Server.java b/jdk/src/share/classes/com/sun/security/sasl/gsskerb/GssKrb5Server.java index 94ce39c0ad1..c15dfc9aae7 100644 --- a/jdk/src/share/classes/com/sun/security/sasl/gsskerb/GssKrb5Server.java +++ b/jdk/src/share/classes/com/sun/security/sasl/gsskerb/GssKrb5Server.java @@ -221,7 +221,7 @@ final class GssKrb5Server extends GssKrb5Base implements SaslServer { if (logger.isLoggable(Level.FINE)) { logger.log(Level.FINE, "KRB5SRV06:Supported protections: {0}; recv max buf size: {1}", - new Object[]{new Byte(allQop), + new Object[]{allQop, new Integer(recvMaxBufSize)}); } @@ -288,7 +288,7 @@ final class GssKrb5Server extends GssKrb5Base implements SaslServer { if (logger.isLoggable(Level.FINE)) { logger.log(Level.FINE, "KRB5SRV10:Selected protection: {0}; privacy: {1}; integrity: {2}", - new Object[]{new Byte(selectedQop), + new Object[]{selectedQop, Boolean.valueOf(privacy), Boolean.valueOf(integrity)}); logger.log(Level.FINE, diff --git a/jdk/src/share/classes/com/sun/security/sasl/ntlm/NTLMClient.java b/jdk/src/share/classes/com/sun/security/sasl/ntlm/NTLMClient.java index dbb1d610d31..2cf561c0d3c 100644 --- a/jdk/src/share/classes/com/sun/security/sasl/ntlm/NTLMClient.java +++ b/jdk/src/share/classes/com/sun/security/sasl/ntlm/NTLMClient.java @@ -160,9 +160,17 @@ final class NTLMClient implements SaslClient { } } try { + String name = ncb.getName(); + if (name == null) { + name = authzid; + } + String domain = dcb.getText(); + if (domain == null) { + domain = serverName; + } client = new Client(version, hostname, - ncb.getName(), - dcb.getText(), + name, + domain, pcb.getPassword()); } catch (NTLMException ne) { throw new SaslException( diff --git a/jdk/src/share/classes/com/sun/security/sasl/ntlm/NTLMServer.java b/jdk/src/share/classes/com/sun/security/sasl/ntlm/NTLMServer.java index 9589abd358e..c1a8eb6d595 100644 --- a/jdk/src/share/classes/com/sun/security/sasl/ntlm/NTLMServer.java +++ b/jdk/src/share/classes/com/sun/security/sasl/ntlm/NTLMServer.java @@ -141,8 +141,10 @@ final class NTLMServer implements SaslServer { server = new Server(version, domain) { public char[] getPassword(String ntdomain, String username) { try { - RealmCallback rcb = new RealmCallback( - "Domain: ", ntdomain); + RealmCallback rcb = + (ntdomain == null || ntdomain.isEmpty()) + ? new RealmCallback("Domain: ") + : new RealmCallback("Domain: ", ntdomain); NameCallback ncb = new NameCallback( "Name: ", username); PasswordCallback pcb = new PasswordCallback( diff --git a/jdk/src/share/classes/com/sun/security/sasl/util/AbstractSaslImpl.java b/jdk/src/share/classes/com/sun/security/sasl/util/AbstractSaslImpl.java index c0df4bf960d..1136d8db723 100644 --- a/jdk/src/share/classes/com/sun/security/sasl/util/AbstractSaslImpl.java +++ b/jdk/src/share/classes/com/sun/security/sasl/util/AbstractSaslImpl.java @@ -77,16 +77,16 @@ public abstract class AbstractSaslImpl { if (logger.isLoggable(Level.FINE)) { logger.logp(Level.FINE, myClassName, "constructor", - "SASLIMPL02:Preferred qop mask: {0}", new Byte(allQop)); + "SASLIMPL02:Preferred qop mask: {0}", allQop); if (qop.length > 0) { - StringBuffer qopbuf = new StringBuffer(); + StringBuilder str = new StringBuilder(); for (int i = 0; i < qop.length; i++) { - qopbuf.append(Byte.toString(qop[i])); - qopbuf.append(' '); + str.append(Byte.toString(qop[i])); + str.append(' '); } logger.logp(Level.FINE, myClassName, "constructor", - "SASLIMPL03:Preferred qops : {0}", qopbuf.toString()); + "SASLIMPL03:Preferred qops : {0}", str.toString()); } } @@ -95,13 +95,13 @@ public abstract class AbstractSaslImpl { logger.logp(Level.FINE, myClassName, "constructor", "SASLIMPL04:Preferred strength property: {0}", prop); if (logger.isLoggable(Level.FINE) && strength.length > 0) { - StringBuffer strbuf = new StringBuffer(); + StringBuilder str = new StringBuilder(); for (int i = 0; i < strength.length; i++) { - strbuf.append(Byte.toString(strength[i])); - strbuf.append(' '); + str.append(Byte.toString(strength[i])); + str.append(' '); } logger.logp(Level.FINE, myClassName, "constructor", - "SASLIMPL05:Cipher strengths: {0}", strbuf.toString()); + "SASLIMPL05:Cipher strengths: {0}", str.toString()); } // Max receive buffer size diff --git a/jdk/src/share/classes/com/sun/tools/example/debug/bdi/ExceptionSpec.java b/jdk/src/share/classes/com/sun/tools/example/debug/bdi/ExceptionSpec.java index 489da6afc90..df87688152c 100644 --- a/jdk/src/share/classes/com/sun/tools/example/debug/bdi/ExceptionSpec.java +++ b/jdk/src/share/classes/com/sun/tools/example/debug/bdi/ExceptionSpec.java @@ -102,8 +102,8 @@ public class ExceptionSpec extends EventRequestSpec { @Override public String toString() { - StringBuffer buffer = new StringBuffer("exception catch "); - buffer.append(refSpec.toString()); - return buffer.toString(); + StringBuilder sb = new StringBuilder("exception catch "); + sb.append(refSpec.toString()); + return sb.toString(); } } diff --git a/jdk/src/share/classes/com/sun/tools/example/debug/bdi/LineBreakpointSpec.java b/jdk/src/share/classes/com/sun/tools/example/debug/bdi/LineBreakpointSpec.java index 0cfe97a75e2..f7d66ce2d52 100644 --- a/jdk/src/share/classes/com/sun/tools/example/debug/bdi/LineBreakpointSpec.java +++ b/jdk/src/share/classes/com/sun/tools/example/debug/bdi/LineBreakpointSpec.java @@ -118,13 +118,13 @@ public class LineBreakpointSpec extends BreakpointSpec { @Override public String toString() { - StringBuffer buffer = new StringBuffer("breakpoint "); - buffer.append(refSpec.toString()); - buffer.append(':'); - buffer.append(lineNumber); - buffer.append(" ("); - buffer.append(getStatusString()); - buffer.append(')'); - return buffer.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/share/classes/com/sun/tools/example/debug/bdi/MethodBreakpointSpec.java b/jdk/src/share/classes/com/sun/tools/example/debug/bdi/MethodBreakpointSpec.java index 112d3a87f68..b414443faf7 100644 --- a/jdk/src/share/classes/com/sun/tools/example/debug/bdi/MethodBreakpointSpec.java +++ b/jdk/src/share/classes/com/sun/tools/example/debug/bdi/MethodBreakpointSpec.java @@ -126,26 +126,26 @@ public class MethodBreakpointSpec extends BreakpointSpec { @Override public String toString() { - StringBuffer buffer = new StringBuffer("breakpoint "); - buffer.append(refSpec.toString()); - buffer.append('.'); - buffer.append(methodId); + StringBuilder sb = new StringBuilder("breakpoint "); + sb.append(refSpec.toString()); + sb.append('.'); + sb.append(methodId); if (methodArgs != null) { boolean first = true; - buffer.append('('); + sb.append('('); for (String name : methodArgs) { if (!first) { - buffer.append(','); + sb.append(','); } - buffer.append(name); + sb.append(name); first = false; } - buffer.append(")"); + sb.append(")"); } - buffer.append(" ("); - buffer.append(getStatusString()); - buffer.append(')'); - return buffer.toString(); + sb.append(" ("); + sb.append(getStatusString()); + sb.append(')'); + return sb.toString(); } private boolean isValidMethodName(String s) { @@ -225,8 +225,8 @@ public class MethodBreakpointSpec extends BreakpointSpec { * stripping whitespace after the name ends. */ int i = 0; - StringBuffer typePart = new StringBuffer(); - StringBuffer arrayPart = new StringBuffer(); + StringBuilder typePart = new StringBuilder(); + StringBuilder arrayPart = new StringBuilder(); name = name.trim(); int nameLength = name.length(); /* diff --git a/jdk/src/share/classes/com/sun/tools/example/debug/expr/ExpressionParser.java b/jdk/src/share/classes/com/sun/tools/example/debug/expr/ExpressionParser.java index 69deb789a94..5f0c12086d6 100644 --- a/jdk/src/share/classes/com/sun/tools/example/debug/expr/ExpressionParser.java +++ b/jdk/src/share/classes/com/sun/tools/example/debug/expr/ExpressionParser.java @@ -185,7 +185,7 @@ public class ExpressionParser implements ExpressionParserConstants { } final public String Name() throws ParseException { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); jj_consume_token(IDENTIFIER); sb.append(token); label_2: diff --git a/jdk/src/share/classes/com/sun/tools/example/debug/expr/ParseException.java b/jdk/src/share/classes/com/sun/tools/example/debug/expr/ParseException.java index 6df5e4bafc6..77b0980c282 100644 --- a/jdk/src/share/classes/com/sun/tools/example/debug/expr/ParseException.java +++ b/jdk/src/share/classes/com/sun/tools/example/debug/expr/ParseException.java @@ -114,7 +114,7 @@ public class ParseException extends Exception { int[][] expectedTokenSequences, String[] tokenImage) { String eol = System.getProperty("line.separator", "\n"); - StringBuffer expected = new StringBuffer(); + StringBuilder expected = new StringBuilder(); int maxSize = 0; for (int i = 0; i < expectedTokenSequences.length; i++) { if (maxSize < expectedTokenSequences[i].length) { @@ -164,7 +164,7 @@ public class ParseException extends Exception { * string literal. */ static String add_escapes(String str) { - StringBuffer retval = new StringBuffer(); + StringBuilder retval = new StringBuilder(); char ch; for (int i = 0; i < str.length(); i++) { switch (str.charAt(i)) diff --git a/jdk/src/share/classes/com/sun/tools/example/debug/expr/TokenMgrError.java b/jdk/src/share/classes/com/sun/tools/example/debug/expr/TokenMgrError.java index 5bc49c343a6..f6408697b48 100644 --- a/jdk/src/share/classes/com/sun/tools/example/debug/expr/TokenMgrError.java +++ b/jdk/src/share/classes/com/sun/tools/example/debug/expr/TokenMgrError.java @@ -73,7 +73,7 @@ public class TokenMgrError extends Error * equivalents in the given string */ protected static final String addEscapes(String str) { - StringBuffer retval = new StringBuffer(); + StringBuilder retval = new StringBuilder(); char ch; for (int i = 0; i < str.length(); i++) { switch (str.charAt(i)) diff --git a/jdk/src/share/classes/com/sun/tools/example/debug/gui/CommandInterpreter.java b/jdk/src/share/classes/com/sun/tools/example/debug/gui/CommandInterpreter.java index 8b7e88facac..fbff95b2703 100644 --- a/jdk/src/share/classes/com/sun/tools/example/debug/gui/CommandInterpreter.java +++ b/jdk/src/share/classes/com/sun/tools/example/debug/gui/CommandInterpreter.java @@ -267,7 +267,7 @@ public class CommandInterpreter { buf[j] = ' '; } buf[79] = '\0'; - StringBuffer sbOut = new StringBuffer(); + StringBuilder sbOut = new StringBuilder(); sbOut.append(buf); // Right-justify the thread number at start of output string @@ -381,16 +381,16 @@ public class CommandInterpreter { } } else { clname = t.nextToken(); - StringBuffer sbuf = new StringBuffer(); + StringBuilder str = new StringBuilder(); // Allow VM arguments to be specified here? while (t.hasMoreTokens()) { String tok = t.nextToken(); - sbuf.append(tok); + str.append(tok); if (t.hasMoreTokens()) { - sbuf.append(' '); + str.append(' '); } } - String args = sbuf.toString(); + String args = str.toString(); try { String vmArgs = context.getVmArguments(); runtime.run(suspended, vmArgs, clname, args); diff --git a/jdk/src/share/classes/com/sun/tools/example/debug/gui/ContextManager.java b/jdk/src/share/classes/com/sun/tools/example/debug/gui/ContextManager.java index 52ceca4c19b..74c61b55969 100644 --- a/jdk/src/share/classes/com/sun/tools/example/debug/gui/ContextManager.java +++ b/jdk/src/share/classes/com/sun/tools/example/debug/gui/ContextManager.java @@ -333,7 +333,7 @@ public class ContextManager { private String processClasspathDefaults(String javaArgs) { if (javaArgs.indexOf("-classpath ") == -1) { - StringBuffer munged = new StringBuffer(javaArgs); + StringBuilder munged = new StringBuilder(javaArgs); SearchPath classpath = classManager.getClassPath(); if (classpath.isEmpty()) { String envcp = System.getProperty("env.class.path"); diff --git a/jdk/src/share/classes/com/sun/tools/example/debug/gui/SourceModel.java b/jdk/src/share/classes/com/sun/tools/example/debug/gui/SourceModel.java index dc93d21ff4c..9b26646a70a 100644 --- a/jdk/src/share/classes/com/sun/tools/example/debug/gui/SourceModel.java +++ b/jdk/src/share/classes/com/sun/tools/example/debug/gui/SourceModel.java @@ -236,7 +236,7 @@ public class SourceModel extends AbstractListModel { private String expandTabs(String s) { int col = 0; int len = s.length(); - StringBuffer sb = new StringBuffer(132); + StringBuilder sb = new StringBuilder(132); for (int i = 0; i < len; i++) { char c = s.charAt(i); sb.append(c); diff --git a/jdk/src/share/classes/com/sun/tools/example/debug/tty/BreakpointSpec.java b/jdk/src/share/classes/com/sun/tools/example/debug/tty/BreakpointSpec.java index f39a7f8059e..2bd04857e00 100644 --- a/jdk/src/share/classes/com/sun/tools/example/debug/tty/BreakpointSpec.java +++ b/jdk/src/share/classes/com/sun/tools/example/debug/tty/BreakpointSpec.java @@ -142,8 +142,8 @@ class BreakpointSpec extends EventRequestSpec { refSpec.toString())); } else if (e instanceof LineNotFoundException) { return (MessageOutput.format("No code at line", - new Object [] {new Long (lineNumber()), - refSpec.toString()})); + new Object [] {Long.valueOf(lineNumber()), + refSpec.toString()})); } else if (e instanceof InvalidTypeException) { return (MessageOutput.format("Breakpoints can be located only in classes.", refSpec.toString())); @@ -154,27 +154,27 @@ class BreakpointSpec extends EventRequestSpec { @Override public String toString() { - StringBuffer buffer = new StringBuffer(refSpec.toString()); + StringBuilder sb = new StringBuilder(refSpec.toString()); if (isMethodBreakpoint()) { - buffer.append('.'); - buffer.append(methodId); + sb.append('.'); + sb.append(methodId); if (methodArgs != null) { boolean first = true; - buffer.append('('); + sb.append('('); for (String arg : methodArgs) { if (!first) { - buffer.append(','); + sb.append(','); } - buffer.append(arg); + sb.append(arg); first = false; } - buffer.append(")"); + sb.append(")"); } } else { - buffer.append(':'); - buffer.append(lineNumber); + sb.append(':'); + sb.append(lineNumber); } - return MessageOutput.format("breakpoint", buffer.toString()); + return MessageOutput.format("breakpoint", sb.toString()); } private Location location(ReferenceType refType) throws @@ -275,8 +275,8 @@ class BreakpointSpec extends EventRequestSpec { * stripping whitespace after the name ends */ int i = 0; - StringBuffer typePart = new StringBuffer(); - StringBuffer arrayPart = new StringBuffer(); + StringBuilder typePart = new StringBuilder(); + StringBuilder arrayPart = new StringBuilder(); name = name.trim(); int nameLength = name.length(); /* diff --git a/jdk/src/share/classes/com/sun/tools/example/debug/tty/Commands.java b/jdk/src/share/classes/com/sun/tools/example/debug/tty/Commands.java index 33f6e3ddf7f..2ea7d487a02 100644 --- a/jdk/src/share/classes/com/sun/tools/example/debug/tty/Commands.java +++ b/jdk/src/share/classes/com/sun/tools/example/debug/tty/Commands.java @@ -164,30 +164,30 @@ class Commands { } String typedName(Method method) { - StringBuffer buf = new StringBuffer(); - buf.append(method.name()); - buf.append("("); + StringBuilder sb = new StringBuilder(); + sb.append(method.name()); + sb.append("("); List args = method.argumentTypeNames(); int lastParam = args.size() - 1; // output param types except for the last for (int ii = 0; ii < lastParam; ii++) { - buf.append(args.get(ii)); - buf.append(", "); + sb.append(args.get(ii)); + sb.append(", "); } if (lastParam >= 0) { // output the last param String lastStr = args.get(lastParam); if (method.isVarArgs()) { // lastParam is an array. Replace the [] with ... - buf.append(lastStr.substring(0, lastStr.length() - 2)); - buf.append("..."); + sb.append(lastStr.substring(0, lastStr.length() - 2)); + sb.append("..."); } else { - buf.append(lastStr); + sb.append(lastStr); } } - buf.append(")"); - return buf.toString(); + sb.append(")"); + return sb.toString(); } void commandConnectors(VirtualMachineManager vmm) { @@ -226,7 +226,7 @@ class Commands { } void commandClasses() { - StringBuffer classList = new StringBuffer(); + StringBuilder classList = new StringBuilder(); for (ReferenceType refType : Env.vm().allClasses()) { classList.append(refType.name()); classList.append("\n"); @@ -309,7 +309,7 @@ class Commands { String idClass = t.nextToken(); ReferenceType cls = Env.getReferenceTypeFromToken(idClass); if (cls != null) { - StringBuffer methodsList = new StringBuffer(); + StringBuilder methodsList = new StringBuilder(); for (Method method : cls.allMethods()) { methodsList.append(method.declaringType().name()); methodsList.append(" "); @@ -333,7 +333,7 @@ class Commands { if (cls != null) { List fields = cls.allFields(); List visible = cls.visibleFields(); - StringBuffer fieldsList = new StringBuffer(); + StringBuilder fieldsList = new StringBuilder(); for (Field field : fields) { String s; if (!visible.contains(field)) { @@ -391,11 +391,11 @@ class Commands { * very long thread names, at the possible cost of lines * being wrapped by the display device. */ - StringBuffer idBuffer = new StringBuffer(Env.description(thr)); + StringBuilder idBuffer = new StringBuilder(Env.description(thr)); for (int i = idBuffer.length(); i < maxIdLength; i++) { idBuffer.append(" "); } - StringBuffer nameBuffer = new StringBuffer(thr.name()); + StringBuilder nameBuffer = new StringBuilder(thr.name()); for (int i = nameBuffer.length(); i < maxNameLength; i++) { nameBuffer.append(" "); } @@ -935,7 +935,7 @@ class Commands { try { methodInfo = loc.sourceName() + MessageOutput.format("line number", - new Object [] {new Long(lineNumber)}); + new Object [] {Long.valueOf(lineNumber)}); } catch (AbsentInformationException e) { methodInfo = MessageOutput.format("unknown"); } @@ -946,7 +946,7 @@ class Commands { meth.declaringType().name(), meth.name(), methodInfo, - new Long(pc)}); + Long.valueOf(pc)}); } else { MessageOutput.println("stack frame dump", new Object [] {new Integer(frameNumber + 1), @@ -1015,7 +1015,7 @@ class Commands { new Object [] {loc.declaringType().name(), loc.method().name(), new Integer (loc.lineNumber()), - new Long (loc.codeIndex())}); + Long.valueOf(loc.codeIndex())}); } void listBreakpoints() { @@ -1606,16 +1606,16 @@ class Commands { private void dump(ObjectReference obj, ReferenceType refType, ReferenceType refTypeBase) { for (Field field : refType.fields()) { - StringBuffer o = new StringBuffer(); - o.append(" "); + StringBuilder sb = new StringBuilder(); + sb.append(" "); if (!refType.equals(refTypeBase)) { - o.append(refType.name()); - o.append("."); + sb.append(refType.name()); + sb.append("."); } - o.append(field.name()); - o.append(MessageOutput.format("colon space")); - o.append(obj.getValue(field)); - MessageOutput.printDirectln(o.toString()); // Special case: use printDirectln() + sb.append(field.name()); + sb.append(MessageOutput.format("colon space")); + sb.append(obj.getValue(field)); + MessageOutput.printDirectln(sb.toString()); // Special case: use printDirectln() } if (refType instanceof ClassType) { ClassType sup = ((ClassType)refType).superclass(); @@ -1954,7 +1954,7 @@ class Commands { } } - StringBuffer line = new StringBuffer(80); + StringBuilder line = new StringBuilder(80); line.append("0000: "); for (int i = 0; i < bytecodes.length; i++) { if ((i > 0) && (i % 16 == 0)) { diff --git a/jdk/src/share/classes/com/sun/tools/example/debug/tty/Env.java b/jdk/src/share/classes/com/sun/tools/example/debug/tty/Env.java index 63e1fe10e0e..b67295e840e 100644 --- a/jdk/src/share/classes/com/sun/tools/example/debug/tty/Env.java +++ b/jdk/src/share/classes/com/sun/tools/example/debug/tty/Env.java @@ -114,12 +114,12 @@ class Env { } static String excludesString() { - StringBuffer buffer = new StringBuffer(); + StringBuilder sb = new StringBuilder(); for (String pattern : excludes()) { - buffer.append(pattern); - buffer.append(","); + sb.append(pattern); + sb.append(","); } - return buffer.toString(); + return sb.toString(); } static void addExcludes(StepRequest request) { diff --git a/jdk/src/share/classes/com/sun/tools/example/debug/tty/TTY.java b/jdk/src/share/classes/com/sun/tools/example/debug/tty/TTY.java index 1958b9a8eca..8de89b26689 100644 --- a/jdk/src/share/classes/com/sun/tools/example/debug/tty/TTY.java +++ b/jdk/src/share/classes/com/sun/tools/example/debug/tty/TTY.java @@ -827,17 +827,17 @@ public class TTY implements EventNotifier { private static String addArgument(String string, String argument) { if (hasWhitespace(argument) || argument.indexOf(',') != -1) { // Quotes were stripped out for this argument, add 'em back. - StringBuffer buffer = new StringBuffer(string); - buffer.append('"'); + StringBuilder sb = new StringBuilder(string); + sb.append('"'); for (int i = 0; i < argument.length(); i++) { char c = argument.charAt(i); if (c == '"') { - buffer.append('\\'); + sb.append('\\'); } - buffer.append(c); + sb.append(c); } - buffer.append("\" "); - return buffer.toString(); + sb.append("\" "); + return sb.toString(); } else { return string + argument + ' '; } diff --git a/jdk/src/share/classes/com/sun/tools/example/trace/Trace.java b/jdk/src/share/classes/com/sun/tools/example/trace/Trace.java index fa66b3bd3d5..2ce99f97a01 100644 --- a/jdk/src/share/classes/com/sun/tools/example/trace/Trace.java +++ b/jdk/src/share/classes/com/sun/tools/example/trace/Trace.java @@ -121,7 +121,7 @@ public class Trace { usage(); System.exit(1); } - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append(args[inx]); for (++inx; inx < args.length; ++inx) { sb.append(' '); diff --git a/jdk/src/share/classes/com/sun/tools/hat/internal/model/JavaLazyReadObject.java b/jdk/src/share/classes/com/sun/tools/hat/internal/model/JavaLazyReadObject.java index 0727d519ca6..7b80466f488 100644 --- a/jdk/src/share/classes/com/sun/tools/hat/internal/model/JavaLazyReadObject.java +++ b/jdk/src/share/classes/com/sun/tools/hat/internal/model/JavaLazyReadObject.java @@ -102,7 +102,7 @@ public abstract class JavaLazyReadObject extends JavaHeapObject { if ((id & ~Snapshot.SMALL_ID_MASK) == 0) { return new Integer((int)id); } else { - return new Long(id); + return id; } } diff --git a/jdk/src/share/classes/com/sun/tools/hat/internal/model/Snapshot.java b/jdk/src/share/classes/com/sun/tools/hat/internal/model/Snapshot.java index 4d881fd0d72..51f922c8044 100644 --- a/jdk/src/share/classes/com/sun/tools/hat/internal/model/Snapshot.java +++ b/jdk/src/share/classes/com/sun/tools/hat/internal/model/Snapshot.java @@ -583,7 +583,7 @@ public class Snapshot { if (identifierSize == 4) { return new Integer((int)id); } else { - return new Long(id); + return id; } } diff --git a/jdk/src/share/classes/com/sun/tools/hat/internal/parser/HprofReader.java b/jdk/src/share/classes/com/sun/tools/hat/internal/parser/HprofReader.java index 33cdb3aa3e1..8a5afa88854 100644 --- a/jdk/src/share/classes/com/sun/tools/hat/internal/parser/HprofReader.java +++ b/jdk/src/share/classes/com/sun/tools/hat/internal/parser/HprofReader.java @@ -215,7 +215,7 @@ public class HprofReader extends Reader /* imports */ implements ArrayTypeCodes long id = readID(); byte[] chars = new byte[(int)length - identifierSize]; in.readFully(chars); - names.put(new Long(id), new String(chars)); + names.put(id, new String(chars)); break; } case HPROF_LOAD_CLASS: { @@ -223,7 +223,7 @@ public class HprofReader extends Reader /* imports */ implements ArrayTypeCodes long classID = readID(); int stackTraceSerialNo = in.readInt(); long classNameID = readID(); - Long classIdI = new Long(classID); + Long classIdI = classID; String nm = getNameFromID(classNameID).replace('/', '.'); classNameFromObjectID.put(classIdI, nm); if (classNameFromSerialNo != null) { @@ -303,7 +303,7 @@ public class HprofReader extends Reader /* imports */ implements ArrayTypeCodes warn("Weird stack frame line number: " + lineNumber); lineNumber = StackFrame.LINE_NUMBER_UNKNOWN; } - stackFrames.put(new Long(id), + stackFrames.put(id, new StackFrame(methodName, methodSig, className, sourceFile, lineNumber)); @@ -319,7 +319,7 @@ public class HprofReader extends Reader /* imports */ implements ArrayTypeCodes StackFrame[] frames = new StackFrame[in.readInt()]; for (int i = 0; i < frames.length; i++) { long fid = readID(); - frames[i] = stackFrames.get(new Long(fid)); + frames[i] = stackFrames.get(fid); if (frames[i] == null) { throw new IOException("Stack frame " + toHex(fid) + " not found"); } @@ -619,7 +619,7 @@ public class HprofReader extends Reader /* imports */ implements ArrayTypeCodes } private String getNameFromID(long id) throws IOException { - return getNameFromID(new Long(id)); + return getNameFromID(Long.valueOf(id)); } private String getNameFromID(Long id) throws IOException { @@ -703,7 +703,7 @@ public class HprofReader extends Reader /* imports */ implements ArrayTypeCodes String signature = "" + ((char) type); fields[i] = new JavaField(fieldName, signature); } - String name = classNameFromObjectID.get(new Long(id)); + String name = classNameFromObjectID.get(id); if (name == null) { warn("Class name not found for " + toHex(id)); name = "unknown-name@" + toHex(id); diff --git a/jdk/src/share/classes/com/sun/tools/hat/internal/server/RefsByTypeQuery.java b/jdk/src/share/classes/com/sun/tools/hat/internal/server/RefsByTypeQuery.java index ccffc6d5602..73755c2e523 100644 --- a/jdk/src/share/classes/com/sun/tools/hat/internal/server/RefsByTypeQuery.java +++ b/jdk/src/share/classes/com/sun/tools/hat/internal/server/RefsByTypeQuery.java @@ -63,9 +63,9 @@ public class RefsByTypeQuery extends QueryHandler { } Long count = referrersStat.get(cl); if (count == null) { - count = new Long(1); + count = 1L; } else { - count = new Long(count.longValue() + 1); + count = count + 1L; } referrersStat.put(cl, count); } @@ -75,9 +75,9 @@ public class RefsByTypeQuery extends QueryHandler { JavaClass cl = obj.getClazz(); Long count = refereesStat.get(cl); if (count == null) { - count = new Long(1); + count = 1L; } else { - count = new Long(count.longValue() + 1); + count = count + 1L; } refereesStat.put(cl, count); } diff --git a/jdk/src/share/classes/com/sun/tools/hat/internal/util/Misc.java b/jdk/src/share/classes/com/sun/tools/hat/internal/util/Misc.java index 0fdf405967c..84a9291003c 100644 --- a/jdk/src/share/classes/com/sun/tools/hat/internal/util/Misc.java +++ b/jdk/src/share/classes/com/sun/tools/hat/internal/util/Misc.java @@ -83,30 +83,30 @@ public class Misc { public static String encodeHtml(String str) { final int len = str.length(); - StringBuffer buf = new StringBuffer(); + StringBuilder sb = new StringBuilder(); for (int i = 0; i < len; i++) { char ch = str.charAt(i); if (ch == '<') { - buf.append("<"); + sb.append("<"); } else if (ch == '>') { - buf.append(">"); + sb.append(">"); } else if (ch == '"') { - buf.append("""); + sb.append("""); } else if (ch == '\'') { - buf.append("'"); + sb.append("'"); } else if (ch == '&') { - buf.append("&"); + sb.append("&"); } else if (ch < ' ') { - buf.append("&#" + Integer.toString(ch) + ";"); + sb.append("&#" + Integer.toString(ch) + ";"); } else { int c = (ch & 0xFFFF); if (c > 127) { - buf.append("&#" + Integer.toString(c) + ";"); + sb.append("&#" + Integer.toString(c) + ";"); } else { - buf.append(ch); + sb.append(ch); } } } - return buf.toString(); + return sb.toString(); } } diff --git a/jdk/src/share/classes/com/sun/tools/jdi/FieldImpl.java b/jdk/src/share/classes/com/sun/tools/jdi/FieldImpl.java index ecf6fdcb625..a7d46501d1c 100644 --- a/jdk/src/share/classes/com/sun/tools/jdi/FieldImpl.java +++ b/jdk/src/share/classes/com/sun/tools/jdi/FieldImpl.java @@ -95,12 +95,12 @@ public class FieldImpl extends TypeComponentImpl } public String toString() { - StringBuffer buf = new StringBuffer(); + StringBuilder sb = new StringBuilder(); - buf.append(declaringType().name()); - buf.append('.'); - buf.append(name()); + sb.append(declaringType().name()); + sb.append('.'); + sb.append(name()); - return buf.toString(); + return sb.toString(); } } diff --git a/jdk/src/share/classes/com/sun/tools/jdi/JNITypeParser.java b/jdk/src/share/classes/com/sun/tools/jdi/JNITypeParser.java index 2ed7265eb7a..4905fc69065 100644 --- a/jdk/src/share/classes/com/sun/tools/jdi/JNITypeParser.java +++ b/jdk/src/share/classes/com/sun/tools/jdi/JNITypeParser.java @@ -44,11 +44,11 @@ public class JNITypeParser { } static String typeNameToSignature(String signature) { - StringBuffer buffer = new StringBuffer(); + StringBuilder sb = new StringBuilder(); int firstIndex = signature.indexOf('['); int index = firstIndex; while (index != -1) { - buffer.append('['); + sb.append('['); index = signature.indexOf('[', index + 1); } @@ -57,28 +57,28 @@ public class JNITypeParser { } if (signature.equals("boolean")) { - buffer.append('Z'); + sb.append('Z'); } else if (signature.equals("byte")) { - buffer.append('B'); + sb.append('B'); } else if (signature.equals("char")) { - buffer.append('C'); + sb.append('C'); } else if (signature.equals("short")) { - buffer.append('S'); + sb.append('S'); } else if (signature.equals("int")) { - buffer.append('I'); + sb.append('I'); } else if (signature.equals("long")) { - buffer.append('J'); + sb.append('J'); } else if (signature.equals("float")) { - buffer.append('F'); + sb.append('F'); } else if (signature.equals("double")) { - buffer.append('D'); + sb.append('D'); } else { - buffer.append('L'); - buffer.append(signature.replace('.', '/')); - buffer.append(';'); + sb.append('L'); + sb.append(signature.replace('.', '/')); + sb.append(';'); } - return buffer.toString(); + return sb.toString(); } String typeName() { diff --git a/jdk/src/share/classes/com/sun/tools/jdi/MethodImpl.java b/jdk/src/share/classes/com/sun/tools/jdi/MethodImpl.java index 1d93f4c76ba..b5cd9c67abd 100644 --- a/jdk/src/share/classes/com/sun/tools/jdi/MethodImpl.java +++ b/jdk/src/share/classes/com/sun/tools/jdi/MethodImpl.java @@ -387,7 +387,7 @@ public abstract class MethodImpl extends TypeComponentImpl } public String toString() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append(declaringType().name()); sb.append("."); sb.append(name()); diff --git a/jdk/src/share/classes/com/sun/tools/jdi/ReferenceTypeImpl.java b/jdk/src/share/classes/com/sun/tools/jdi/ReferenceTypeImpl.java index be98d5e0f3e..ab76a876e6d 100644 --- a/jdk/src/share/classes/com/sun/tools/jdi/ReferenceTypeImpl.java +++ b/jdk/src/share/classes/com/sun/tools/jdi/ReferenceTypeImpl.java @@ -751,7 +751,7 @@ implements ReferenceType { String baseSourceDir() { if (baseSourceDir == null) { String typeName = name(); - StringBuffer sb = new StringBuffer(typeName.length() + 10); + StringBuilder sb = new StringBuilder(typeName.length() + 10); int index = 0; int nextIndex; diff --git a/jdk/src/share/classes/com/sun/tools/jdi/SDE.java b/jdk/src/share/classes/com/sun/tools/jdi/SDE.java index 2ccaf25eb66..25fed40042d 100644 --- a/jdk/src/share/classes/com/sun/tools/jdi/SDE.java +++ b/jdk/src/share/classes/com/sun/tools/jdi/SDE.java @@ -56,16 +56,16 @@ class SDE { if (sourcePath == null) { sourcePath = refType.baseSourceDir() + sourceName; } else { - StringBuffer buf = new StringBuffer(); + StringBuilder sb = new StringBuilder(); for (int i = 0; i < sourcePath.length(); ++i) { char ch = sourcePath.charAt(i); if (ch == '/') { - buf.append(File.separatorChar); + sb.append(File.separatorChar); } else { - buf.append(ch); + sb.append(ch); } } - sourcePath = buf.toString(); + sourcePath = sb.toString(); } isConverted = true; } @@ -327,7 +327,7 @@ class SDE { } String readLine() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); char ch; ignoreWhite(); diff --git a/jdk/src/share/classes/com/sun/tools/jdi/TargetVM.java b/jdk/src/share/classes/com/sun/tools/jdi/TargetVM.java index a94eb43eafd..941ab405130 100644 --- a/jdk/src/share/classes/com/sun/tools/jdi/TargetVM.java +++ b/jdk/src/share/classes/com/sun/tools/jdi/TargetVM.java @@ -78,7 +78,7 @@ public class TargetVM implements Runnable { ", errorCode=" + packet.errorCode + ", flags=" + packet.flags); } - StringBuffer line = new StringBuffer(80); + StringBuilder line = new StringBuilder(80); line.append("0000: "); for (int i = 0; i < packet.data.length; i++) { if ((i > 0) && (i % 16 == 0)) { diff --git a/jdk/src/share/classes/com/sun/tools/jdi/VirtualMachineImpl.java b/jdk/src/share/classes/com/sun/tools/jdi/VirtualMachineImpl.java index 3397e0f3ad1..c03ed4de31b 100644 --- a/jdk/src/share/classes/com/sun/tools/jdi/VirtualMachineImpl.java +++ b/jdk/src/share/classes/com/sun/tools/jdi/VirtualMachineImpl.java @@ -742,7 +742,7 @@ class VirtualMachineImpl extends MirrorImpl } void printReceiveTrace(int depth, String string) { - StringBuffer sb = new StringBuffer("Receiving:"); + StringBuilder sb = new StringBuilder("Receiving:"); for (int i = depth; i > 0; --i) { sb.append(" "); } @@ -781,7 +781,7 @@ class VirtualMachineImpl extends MirrorImpl type.setSignature(signature); } - typesByID.put(new Long(id), type); + typesByID.put(id, type); typesBySignature.add(type); if ((vm.traceFlags & VirtualMachine.TRACE_REFTYPES) != 0) { @@ -809,7 +809,7 @@ class VirtualMachineImpl extends MirrorImpl if (comp == 0) { matches++; iter.remove(); - typesByID.remove(new Long(type.ref())); + typesByID.remove(type.ref()); if ((vm.traceFlags & VirtualMachine.TRACE_REFTYPES) != 0) { vm.printTrace("Uncaching ReferenceType, sig=" + signature + ", id=" + type.ref()); @@ -872,7 +872,7 @@ class VirtualMachineImpl extends MirrorImpl ReferenceTypeImpl referenceType(long id, int tag, String signature) { if ((vm.traceFlags & VirtualMachine.TRACE_REFTYPES) != 0) { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append("Looking up "); if (tag == JDWP.TypeTag.CLASS) { sb.append("Class"); @@ -895,7 +895,7 @@ class VirtualMachineImpl extends MirrorImpl ReferenceTypeImpl retType = null; synchronized (this) { if (typesByID != null) { - retType = (ReferenceTypeImpl)typesByID.get(new Long(id)); + retType = (ReferenceTypeImpl)typesByID.get(id); } if (retType == null) { retType = addReferenceType(id, tag, signature); @@ -1247,7 +1247,7 @@ class VirtualMachineImpl extends MirrorImpl return null; } ObjectReferenceImpl object = null; - Long key = new Long(id); + Long key = id; /* * Attempt to retrieve an existing object object reference @@ -1313,7 +1313,7 @@ class VirtualMachineImpl extends MirrorImpl // Handle any queue elements that are not strongly reachable processQueue(); - SoftObjectReference ref = objectsByID.remove(new Long(object.ref())); + SoftObjectReference ref = objectsByID.remove(object.ref()); if (ref != null) { batchForDispose(ref); } else { diff --git a/jdk/src/share/classes/java/awt/AWTEvent.java b/jdk/src/share/classes/java/awt/AWTEvent.java index db51f2c1088..4a935f39848 100644 --- a/jdk/src/share/classes/java/awt/AWTEvent.java +++ b/jdk/src/share/classes/java/awt/AWTEvent.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 @@ -388,6 +388,8 @@ public abstract class AWTEvent extends EventObject { /** * Returns the event type. + * + * @return the event's type id */ public int getID() { return id; @@ -446,6 +448,9 @@ public abstract class AWTEvent extends EventObject { /** * Returns whether this event has been consumed. + * + * @return {@code true} if this event has been consumed; + * otherwise {@code false} */ protected boolean isConsumed() { return consumed; diff --git a/jdk/src/share/classes/java/awt/AWTEventMulticaster.java b/jdk/src/share/classes/java/awt/AWTEventMulticaster.java index de51ab1c0b4..112dbb62ace 100644 --- a/jdk/src/share/classes/java/awt/AWTEventMulticaster.java +++ b/jdk/src/share/classes/java/awt/AWTEventMulticaster.java @@ -110,7 +110,15 @@ public class AWTEventMulticaster implements TextListener, InputMethodListener, HierarchyListener, HierarchyBoundsListener, MouseWheelListener { - protected final EventListener a, b; + /** + * A variable in the event chain (listener-a) + */ + protected final EventListener a; + + /** + * A variable in the event chain (listener-b) + */ + protected final EventListener b; /** * Creates an event multicaster instance which chains listener-a @@ -537,6 +545,7 @@ public class AWTEventMulticaster implements * returns the resulting multicast listener. * @param a component-listener-a * @param b component-listener-b + * @return the resulting listener */ public static ComponentListener add(ComponentListener a, ComponentListener b) { return (ComponentListener)addInternal(a, b); @@ -547,6 +556,7 @@ public class AWTEventMulticaster implements * returns the resulting multicast listener. * @param a container-listener-a * @param b container-listener-b + * @return the resulting listener */ public static ContainerListener add(ContainerListener a, ContainerListener b) { return (ContainerListener)addInternal(a, b); @@ -557,6 +567,7 @@ public class AWTEventMulticaster implements * returns the resulting multicast listener. * @param a focus-listener-a * @param b focus-listener-b + * @return the resulting listener */ public static FocusListener add(FocusListener a, FocusListener b) { return (FocusListener)addInternal(a, b); @@ -567,6 +578,7 @@ public class AWTEventMulticaster implements * returns the resulting multicast listener. * @param a key-listener-a * @param b key-listener-b + * @return the resulting listener */ public static KeyListener add(KeyListener a, KeyListener b) { return (KeyListener)addInternal(a, b); @@ -577,6 +589,7 @@ public class AWTEventMulticaster implements * returns the resulting multicast listener. * @param a mouse-listener-a * @param b mouse-listener-b + * @return the resulting listener */ public static MouseListener add(MouseListener a, MouseListener b) { return (MouseListener)addInternal(a, b); @@ -587,6 +600,7 @@ public class AWTEventMulticaster implements * returns the resulting multicast listener. * @param a mouse-motion-listener-a * @param b mouse-motion-listener-b + * @return the resulting listener */ public static MouseMotionListener add(MouseMotionListener a, MouseMotionListener b) { return (MouseMotionListener)addInternal(a, b); @@ -597,6 +611,7 @@ public class AWTEventMulticaster implements * returns the resulting multicast listener. * @param a window-listener-a * @param b window-listener-b + * @return the resulting listener */ public static WindowListener add(WindowListener a, WindowListener b) { return (WindowListener)addInternal(a, b); @@ -607,6 +622,7 @@ public class AWTEventMulticaster implements * and returns the resulting multicast listener. * @param a window-state-listener-a * @param b window-state-listener-b + * @return the resulting listener * @since 1.4 */ @SuppressWarnings("overloads") @@ -620,6 +636,7 @@ public class AWTEventMulticaster implements * and returns the resulting multicast listener. * @param a window-focus-listener-a * @param b window-focus-listener-b + * @return the resulting listener * @since 1.4 */ public static WindowFocusListener add(WindowFocusListener a, @@ -632,6 +649,7 @@ public class AWTEventMulticaster implements * returns the resulting multicast listener. * @param a action-listener-a * @param b action-listener-b + * @return the resulting listener */ @SuppressWarnings("overloads") public static ActionListener add(ActionListener a, ActionListener b) { @@ -643,6 +661,7 @@ public class AWTEventMulticaster implements * returns the resulting multicast listener. * @param a item-listener-a * @param b item-listener-b + * @return the resulting listener */ @SuppressWarnings("overloads") public static ItemListener add(ItemListener a, ItemListener b) { @@ -654,11 +673,21 @@ public class AWTEventMulticaster implements * returns the resulting multicast listener. * @param a adjustment-listener-a * @param b adjustment-listener-b + * @return the resulting listener */ @SuppressWarnings("overloads") public static AdjustmentListener add(AdjustmentListener a, AdjustmentListener b) { return (AdjustmentListener)addInternal(a, b); } + + /** + * Adds text-listener-a with text-listener-b and + * returns the resulting multicast listener. + * + * @param a text-listener-a + * @param b text-listener-b + * @return the resulting listener + */ @SuppressWarnings("overloads") public static TextListener add(TextListener a, TextListener b) { return (TextListener)addInternal(a, b); @@ -669,6 +698,7 @@ public class AWTEventMulticaster implements * returns the resulting multicast listener. * @param a input-method-listener-a * @param b input-method-listener-b + * @return the resulting listener */ public static InputMethodListener add(InputMethodListener a, InputMethodListener b) { return (InputMethodListener)addInternal(a, b); @@ -679,6 +709,7 @@ public class AWTEventMulticaster implements * returns the resulting multicast listener. * @param a hierarchy-listener-a * @param b hierarchy-listener-b + * @return the resulting listener * @since 1.3 */ @SuppressWarnings("overloads") @@ -691,6 +722,7 @@ public class AWTEventMulticaster implements * returns the resulting multicast listener. * @param a hierarchy-bounds-listener-a * @param b hierarchy-bounds-listener-b + * @return the resulting listener * @since 1.3 */ public static HierarchyBoundsListener add(HierarchyBoundsListener a, HierarchyBoundsListener b) { @@ -702,6 +734,7 @@ public class AWTEventMulticaster implements * returns the resulting multicast listener. * @param a mouse-wheel-listener-a * @param b mouse-wheel-listener-b + * @return the resulting listener * @since 1.4 */ @SuppressWarnings("overloads") @@ -715,6 +748,7 @@ public class AWTEventMulticaster implements * returns the resulting multicast listener. * @param l component-listener-l * @param oldl the component-listener being removed + * @return the resulting listener */ public static ComponentListener remove(ComponentListener l, ComponentListener oldl) { return (ComponentListener) removeInternal(l, oldl); @@ -725,6 +759,7 @@ public class AWTEventMulticaster implements * returns the resulting multicast listener. * @param l container-listener-l * @param oldl the container-listener being removed + * @return the resulting listener */ public static ContainerListener remove(ContainerListener l, ContainerListener oldl) { return (ContainerListener) removeInternal(l, oldl); @@ -735,6 +770,7 @@ public class AWTEventMulticaster implements * returns the resulting multicast listener. * @param l focus-listener-l * @param oldl the focus-listener being removed + * @return the resulting listener */ public static FocusListener remove(FocusListener l, FocusListener oldl) { return (FocusListener) removeInternal(l, oldl); @@ -745,6 +781,7 @@ public class AWTEventMulticaster implements * returns the resulting multicast listener. * @param l key-listener-l * @param oldl the key-listener being removed + * @return the resulting listener */ public static KeyListener remove(KeyListener l, KeyListener oldl) { return (KeyListener) removeInternal(l, oldl); @@ -755,6 +792,7 @@ public class AWTEventMulticaster implements * returns the resulting multicast listener. * @param l mouse-listener-l * @param oldl the mouse-listener being removed + * @return the resulting listener */ public static MouseListener remove(MouseListener l, MouseListener oldl) { return (MouseListener) removeInternal(l, oldl); @@ -765,6 +803,7 @@ public class AWTEventMulticaster implements * and returns the resulting multicast listener. * @param l mouse-motion-listener-l * @param oldl the mouse-motion-listener being removed + * @return the resulting listener */ public static MouseMotionListener remove(MouseMotionListener l, MouseMotionListener oldl) { return (MouseMotionListener) removeInternal(l, oldl); @@ -775,6 +814,7 @@ public class AWTEventMulticaster implements * returns the resulting multicast listener. * @param l window-listener-l * @param oldl the window-listener being removed + * @return the resulting listener */ public static WindowListener remove(WindowListener l, WindowListener oldl) { return (WindowListener) removeInternal(l, oldl); @@ -785,6 +825,7 @@ public class AWTEventMulticaster implements * and returns the resulting multicast listener. * @param l window-state-listener-l * @param oldl the window-state-listener being removed + * @return the resulting listener * @since 1.4 */ @SuppressWarnings("overloads") @@ -798,6 +839,7 @@ public class AWTEventMulticaster implements * and returns the resulting multicast listener. * @param l window-focus-listener-l * @param oldl the window-focus-listener being removed + * @return the resulting listener * @since 1.4 */ public static WindowFocusListener remove(WindowFocusListener l, @@ -810,6 +852,7 @@ public class AWTEventMulticaster implements * returns the resulting multicast listener. * @param l action-listener-l * @param oldl the action-listener being removed + * @return the resulting listener */ @SuppressWarnings("overloads") public static ActionListener remove(ActionListener l, ActionListener oldl) { @@ -821,6 +864,7 @@ public class AWTEventMulticaster implements * returns the resulting multicast listener. * @param l item-listener-l * @param oldl the item-listener being removed + * @return the resulting listener */ @SuppressWarnings("overloads") public static ItemListener remove(ItemListener l, ItemListener oldl) { @@ -832,11 +876,21 @@ public class AWTEventMulticaster implements * returns the resulting multicast listener. * @param l adjustment-listener-l * @param oldl the adjustment-listener being removed + * @return the resulting listener */ @SuppressWarnings("overloads") public static AdjustmentListener remove(AdjustmentListener l, AdjustmentListener oldl) { return (AdjustmentListener) removeInternal(l, oldl); } + + /** + * Removes the old text-listener from text-listener-l and + * returns the resulting multicast listener. + * + * @param l text-listener-l + * @param oldl the text-listener being removed + * @return the resulting listener + */ @SuppressWarnings("overloads") public static TextListener remove(TextListener l, TextListener oldl) { return (TextListener) removeInternal(l, oldl); @@ -847,6 +901,7 @@ public class AWTEventMulticaster implements * returns the resulting multicast listener. * @param l input-method-listener-l * @param oldl the input-method-listener being removed + * @return the resulting listener */ public static InputMethodListener remove(InputMethodListener l, InputMethodListener oldl) { return (InputMethodListener) removeInternal(l, oldl); @@ -857,6 +912,7 @@ public class AWTEventMulticaster implements * returns the resulting multicast listener. * @param l hierarchy-listener-l * @param oldl the hierarchy-listener being removed + * @return the resulting listener * @since 1.3 */ @SuppressWarnings("overloads") @@ -870,6 +926,7 @@ public class AWTEventMulticaster implements * listener. * @param l hierarchy-bounds-listener-l * @param oldl the hierarchy-bounds-listener being removed + * @return the resulting listener * @since 1.3 */ public static HierarchyBoundsListener remove(HierarchyBoundsListener l, HierarchyBoundsListener oldl) { @@ -881,6 +938,7 @@ public class AWTEventMulticaster implements * and returns the resulting multicast listener. * @param l mouse-wheel-listener-l * @param oldl the mouse-wheel-listener being removed + * @return the resulting listener * @since 1.4 */ @SuppressWarnings("overloads") @@ -898,6 +956,7 @@ public class AWTEventMulticaster implements * a new AWTEventMulticaster instance which chains a with b. * @param a event listener-a * @param b event listener-b + * @return the resulting listener */ protected static EventListener addInternal(EventListener a, EventListener b) { if (a == null) return b; @@ -915,6 +974,7 @@ public class AWTEventMulticaster implements * Else, returns listener l. * @param l the listener being removed from * @param oldl the listener being removed + * @return the resulting listener */ protected static EventListener removeInternal(EventListener l, EventListener oldl) { if (l == oldl || l == null) { @@ -927,9 +987,14 @@ public class AWTEventMulticaster implements } - /* Serialization support. - */ - + /** + * Serialization support. Saves all Serializable listeners + * to a serialization stream. + * + * @param s the stream to save to + * @param k a prefix stream to put before each serializable listener + * @throws IOException if serialization fails + */ protected void saveInternal(ObjectOutputStream s, String k) throws IOException { if (a instanceof AWTEventMulticaster) { ((AWTEventMulticaster)a).saveInternal(s, k); @@ -948,6 +1013,14 @@ public class AWTEventMulticaster implements } } + /** + * Saves a Serializable listener chain to a serialization stream. + * + * @param s the stream to save to + * @param k a prefix stream to put before each serializable listener + * @param l the listener chain to save + * @throws IOException if serialization fails + */ protected static void save(ObjectOutputStream s, String k, EventListener l) throws IOException { if (l == null) { return; diff --git a/jdk/src/share/classes/java/awt/AWTKeyStroke.java b/jdk/src/share/classes/java/awt/AWTKeyStroke.java index 4be729b8c89..681113a07db 100644 --- a/jdk/src/share/classes/java/awt/AWTKeyStroke.java +++ b/jdk/src/share/classes/java/awt/AWTKeyStroke.java @@ -802,6 +802,7 @@ public class AWTKeyStroke implements Serializable { * AWTKeyStroke) which is equal to this instance. * * @return a cached instance which is equal to this instance + * @throws java.io.ObjectStreamException if a serialization problem occurs */ protected Object readResolve() throws java.io.ObjectStreamException { synchronized (AWTKeyStroke.class) { diff --git a/jdk/src/share/classes/java/awt/AlphaComposite.java b/jdk/src/share/classes/java/awt/AlphaComposite.java index f08ea2b47bf..542d2884a01 100644 --- a/jdk/src/share/classes/java/awt/AlphaComposite.java +++ b/jdk/src/share/classes/java/awt/AlphaComposite.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 @@ -621,7 +621,9 @@ public final class AlphaComposite implements Composite { /** * Creates an AlphaComposite object with the specified rule. + * * @param rule the compositing rule + * @return the {@code AlphaComposite} object created * @throws IllegalArgumentException if rule is not one of * the following: {@link #CLEAR}, {@link #SRC}, {@link #DST}, * {@link #SRC_OVER}, {@link #DST_OVER}, {@link #SRC_IN}, @@ -664,10 +666,12 @@ public final class AlphaComposite implements Composite { * the constant alpha to multiply with the alpha of the source. * The source is multiplied with the specified alpha before being composited * with the destination. + * * @param rule the compositing rule * @param alpha the constant alpha to be multiplied with the alpha of * the source. alpha must be a floating point number in the * inclusive range [0.0, 1.0]. + * @return the {@code AlphaComposite} object created * @throws IllegalArgumentException if * alpha is less than 0.0 or greater than 1.0, or if * rule is not one of diff --git a/jdk/src/share/classes/java/awt/BorderLayout.java b/jdk/src/share/classes/java/awt/BorderLayout.java index b2f7e25fe19..fd891bc371b 100644 --- a/jdk/src/share/classes/java/awt/BorderLayout.java +++ b/jdk/src/share/classes/java/awt/BorderLayout.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 @@ -367,6 +367,8 @@ public class BorderLayout implements LayoutManager2, /** * Returns the horizontal gap between components. + * + * @return the horizontal gap between components * @since 1.1 */ public int getHgap() { @@ -375,6 +377,7 @@ public class BorderLayout implements LayoutManager2, /** * Sets the horizontal gap between components. + * * @param hgap the horizontal gap between components * @since 1.1 */ @@ -384,6 +387,8 @@ public class BorderLayout implements LayoutManager2, /** * Returns the vertical gap between components. + * + * @return the vertical gap between components * @since 1.1 */ public int getVgap() { @@ -392,6 +397,7 @@ public class BorderLayout implements LayoutManager2, /** * Sets the vertical gap between components. + * * @param vgap the vertical gap between components * @since 1.1 */ diff --git a/jdk/src/share/classes/java/awt/Button.java b/jdk/src/share/classes/java/awt/Button.java index 08e569d446a..cc01947a9f1 100644 --- a/jdk/src/share/classes/java/awt/Button.java +++ b/jdk/src/share/classes/java/awt/Button.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 @@ -238,6 +238,8 @@ public class Button extends Component implements Accessible { * Returns the command name of the action event fired by this button. * If the command name is null (default) then this method * returns the label of the button. + * + * @return the action command name (or label) for this button */ public String getActionCommand() { return (actionCommand == null? label : actionCommand); diff --git a/jdk/src/share/classes/java/awt/Checkbox.java b/jdk/src/share/classes/java/awt/Checkbox.java index 8e8b5dd226a..021b2fcebaa 100644 --- a/jdk/src/share/classes/java/awt/Checkbox.java +++ b/jdk/src/share/classes/java/awt/Checkbox.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 @@ -713,6 +713,9 @@ public class Checkbox extends Component implements ItemSelectable, Accessible { */ private static final long serialVersionUID = 7881579233144754107L; + /** + * Constructor for {@code AccessibleAWTCheckbox} + */ public AccessibleAWTCheckbox() { super(); Checkbox.this.addItemListener(this); diff --git a/jdk/src/share/classes/java/awt/CheckboxGroup.java b/jdk/src/share/classes/java/awt/CheckboxGroup.java index a34c337b712..15e91c4d2a0 100644 --- a/jdk/src/share/classes/java/awt/CheckboxGroup.java +++ b/jdk/src/share/classes/java/awt/CheckboxGroup.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 @@ -91,6 +91,10 @@ public class CheckboxGroup implements java.io.Serializable { } /** + * Returns the current choice from this check box group + * or {@code null} if none of checkboxes are selected. + * + * @return the selected checkbox * @deprecated As of JDK version 1.1, * replaced by getSelectedCheckbox(). */ @@ -120,6 +124,11 @@ public class CheckboxGroup implements java.io.Serializable { } /** + * Sets the currently selected check box in this group + * to be the specified check box and unsets all others. + * + * @param box the {@code Checkbox} to set as the + * current selection. * @deprecated As of JDK version 1.1, * replaced by setSelectedCheckbox(Checkbox). */ diff --git a/jdk/src/share/classes/java/awt/Choice.java b/jdk/src/share/classes/java/awt/Choice.java index 1d79dc71831..a6f20718321 100644 --- a/jdk/src/share/classes/java/awt/Choice.java +++ b/jdk/src/share/classes/java/awt/Choice.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 @@ -156,6 +156,7 @@ public class Choice extends Component implements ItemSelectable, Accessible { /** * Returns the number of items in this Choice menu. + * * @return the number of items in this Choice menu * @see #getItem * @since 1.1 @@ -165,6 +166,9 @@ public class Choice extends Component implements ItemSelectable, Accessible { } /** + * Returns the number of items in this {@code Choice} menu. + * + * @return the number of items in this {@code Choice} menu * @deprecated As of JDK version 1.1, * replaced by getItemCount(). */ @@ -176,8 +180,10 @@ public class Choice extends Component implements ItemSelectable, Accessible { /** * Gets the string at the specified index in this * Choice menu. - * @param index the index at which to begin - * @see #getItemCount + * + * @param index the index at which to begin + * @return the item at the specified index + * @see #getItemCount */ public String getItem(int index) { return getItemImpl(index); @@ -759,6 +765,9 @@ public class Choice extends Component implements ItemSelectable, Accessible { */ private static final long serialVersionUID = 7175603582428509322L; + /** + * Constructor for {@code AccessibleAWTChoice} + */ public AccessibleAWTChoice() { super(); } diff --git a/jdk/src/share/classes/java/awt/Component.java b/jdk/src/share/classes/java/awt/Component.java index e5659d7cce3..24cc58733e7 100644 --- a/jdk/src/share/classes/java/awt/Component.java +++ b/jdk/src/share/classes/java/awt/Component.java @@ -1075,6 +1075,7 @@ public abstract class Component implements ImageObserver, MenuContainer, * @deprecated As of JDK version 1.1, * programs should not directly manipulate peers; * replaced by boolean isDisplayable(). + * @return the peer for this component */ @Deprecated public ComponentPeer getPeer() { @@ -1132,6 +1133,8 @@ public abstract class Component implements ImageObserver, MenuContainer, /** * Gets the DropTarget associated with this * Component. + * + * @return the drop target */ public synchronized DropTarget getDropTarget() { return dropTarget; } @@ -1498,6 +1501,11 @@ public abstract class Component implements ImageObserver, MenuContainer, } /** + * Enables or disables this component. + * + * @param b {@code true} to enable this component; + * otherwise {@code false} + * * @deprecated As of JDK version 1.1, * replaced by setEnabled(boolean). */ @@ -1656,6 +1664,11 @@ public abstract class Component implements ImageObserver, MenuContainer, } /** + * Makes this component visible or invisible. + * + * @param b {@code true} to make this component visible; + * otherwise {@code false} + * * @deprecated As of JDK version 1.1, * replaced by setVisible(boolean). */ @@ -2068,6 +2081,9 @@ public abstract class Component implements ImageObserver, MenuContainer, /** + * Returns the location of this component's top left corner. + * + * @return the location of this component's top left corner * @deprecated As of JDK version 1.1, * replaced by getLocation(). */ @@ -2102,6 +2118,13 @@ public abstract class Component implements ImageObserver, MenuContainer, } /** + * Moves this component to a new location. + * + * @param x the x-coordinate of the new location's + * top-left corner in the parent's coordinate space + * @param y the y-coordinate of the new location's + * top-left corner in the parent's coordinate space + * * @deprecated As of JDK version 1.1, * replaced by setLocation(int, int). */ @@ -2150,6 +2173,11 @@ public abstract class Component implements ImageObserver, MenuContainer, } /** + * Returns the size of this component in the form of a + * {@code Dimension} object. + * + * @return the {@code Dimension} object that indicates the + * size of this component * @deprecated As of JDK version 1.1, * replaced by getSize(). */ @@ -2177,6 +2205,10 @@ public abstract class Component implements ImageObserver, MenuContainer, } /** + * Resizes this component. + * + * @param width the new width of the component + * @param height the new height of the component * @deprecated As of JDK version 1.1, * replaced by setSize(int, int). */ @@ -2208,6 +2240,10 @@ public abstract class Component implements ImageObserver, MenuContainer, } /** + * Resizes this component so that it has width {@code d.width} + * and height {@code d.height}. + * + * @param d the new size of this component * @deprecated As of JDK version 1.1, * replaced by setSize(Dimension). */ @@ -2231,6 +2267,9 @@ public abstract class Component implements ImageObserver, MenuContainer, } /** + * Returns the bounding rectangle of this component. + * + * @return the bounding rectangle for this component * @deprecated As of JDK version 1.1, * replaced by getBounds(). */ @@ -2265,6 +2304,13 @@ public abstract class Component implements ImageObserver, MenuContainer, } /** + * Reshapes the bounding rectangle for this component. + * + * @param x the x coordinate of the upper left corner of the rectangle + * @param y the y coordinate of the upper left corner of the rectangle + * @param width the width of the rectangle + * @param height the height of the rectangle + * * @deprecated As of JDK version 1.1, * replaced by setBounds(int, int, int, int). */ @@ -2631,6 +2677,9 @@ public abstract class Component implements ImageObserver, MenuContainer, /** + * Returns the component's preferred size. + * + * @return the component's preferred size * @deprecated As of JDK version 1.1, * replaced by getPreferredSize(). */ @@ -2701,6 +2750,9 @@ public abstract class Component implements ImageObserver, MenuContainer, } /** + * Returns the minimum size of this component. + * + * @return the minimum size of this component * @deprecated As of JDK version 1.1, * replaced by getMinimumSize(). */ @@ -2781,6 +2833,8 @@ public abstract class Component implements ImageObserver, MenuContainer, * components. The value should be a number between 0 and 1 * where 0 represents alignment along the origin, 1 is aligned * the furthest away from the origin, 0.5 is centered, etc. + * + * @return the horizontal alignment of this component */ public float getAlignmentX() { return CENTER_ALIGNMENT; @@ -2792,6 +2846,8 @@ public abstract class Component implements ImageObserver, MenuContainer, * components. The value should be a number between 0 and 1 * where 0 represents alignment along the origin, 1 is aligned * the furthest away from the origin, 0.5 is centered, etc. + * + * @return the vertical alignment of this component */ public float getAlignmentY() { return CENTER_ALIGNMENT; @@ -3157,8 +3213,10 @@ public abstract class Component implements ImageObserver, MenuContainer, * not have a cursor set, the cursor of its parent is returned. * If no cursor is set in the entire hierarchy, * Cursor.DEFAULT_CURSOR is returned. + * + * @return the cursor for this component * @see #setCursor - * @since 1.1 + * @since 1.1 */ public Cursor getCursor() { return getCursor_NoClientCode(); @@ -3411,7 +3469,7 @@ public abstract class Component implements ImageObserver, MenuContainer, (width > 0) && (height > 0)) { PaintEvent e = new PaintEvent(this, PaintEvent.UPDATE, new Rectangle(x, y, width, height)); - Toolkit.getEventQueue().postEvent(e); + SunToolkit.postEvent(SunToolkit.targetToAppContext(this), e); } } } @@ -3942,6 +4000,7 @@ public abstract class Component implements ImageObserver, MenuContainer, * a lost state. */ protected boolean validatedContents; // = false + /** * Size of the back buffers. (Note: these fields were added in 6.0 * but kept package-private to avoid exposing them in the spec. @@ -3949,7 +4008,15 @@ public abstract class Component implements ImageObserver, MenuContainer, * protected when they were introduced in 1.4, but now we just have * to live with that decision.) */ + + /** + * The width of the back buffers + */ int width; + + /** + * The height of the back buffers + */ int height; /** @@ -4304,6 +4371,8 @@ public abstract class Component implements ImageObserver, MenuContainer, /** * Creates the back buffers + * + * @param numBuffers the number of buffers to create */ protected void createBackBuffers(int numBuffers) { if (numBuffers == 0) { @@ -4593,6 +4662,9 @@ public abstract class Component implements ImageObserver, MenuContainer, * better performance is desired, or if page-flipping is used as the * buffer strategy. * + * @param ignoreRepaint {@code true} if the paint messages from the OS + * should be ignored; otherwise {@code false} + * * @since 1.4 * @see #getIgnoreRepaint * @see Canvas#createBufferStrategy @@ -4619,8 +4691,11 @@ public abstract class Component implements ImageObserver, MenuContainer, * Checks whether this component "contains" the specified point, * where x and y are defined to be * relative to the coordinate system of this component. + * * @param x the x coordinate of the point * @param y the y coordinate of the point + * @return {@code true} if the point is within the component; + * otherwise {@code false} * @see #getComponentAt(int, int) * @since 1.1 */ @@ -4629,6 +4704,12 @@ public abstract class Component implements ImageObserver, MenuContainer, } /** + * Checks whether the point is inside of this component. + * + * @param x the x coordinate of the point + * @param y the y coordinate of the point + * @return {@code true} if the point is within the component; + * otherwise {@code false} * @deprecated As of JDK version 1.1, * replaced by contains(int, int). */ @@ -4641,7 +4722,10 @@ public abstract class Component implements ImageObserver, MenuContainer, * Checks whether this component "contains" the specified point, * where the point's x and y coordinates are defined * to be relative to the coordinate system of this component. + * * @param p the point + * @return {@code true} if the point is within the component; + * otherwise {@code false} * @throws NullPointerException if {@code p} is {@code null} * @see #getComponentAt(Point) * @since 1.1 @@ -4676,6 +4760,13 @@ public abstract class Component implements ImageObserver, MenuContainer, } /** + * Returns the component occupying the position specified (this component, + * or immediate child component, or null if neither + * of the first two occupies the location). + * + * @param x the x coordinate to search for components at + * @param y the y coordinate to search for components at + * @return the component at the specified location or {@code null} * @deprecated As of JDK version 1.1, * replaced by getComponentAt(int, int). */ @@ -4687,15 +4778,17 @@ public abstract class Component implements ImageObserver, MenuContainer, /** * Returns the component or subcomponent that contains the * specified point. - * @param p the point - * @see java.awt.Component#contains - * @since 1.1 + * @param p the point + * @return the component at the specified location or {@code null} + * @see java.awt.Component#contains + * @since 1.1 */ public Component getComponentAt(Point p) { return getComponentAt(p.x, p.y); } /** + * @param e the event to deliver * @deprecated As of JDK version 1.1, * replaced by dispatchEvent(AWTEvent e). */ @@ -6746,6 +6839,8 @@ public abstract class Component implements ImageObserver, MenuContainer, } /** + * @param evt the event to handle + * @return {@code true} if the event was handled, {@code false} otherwise * @deprecated As of JDK version 1.1 * replaced by processEvent(AWTEvent). */ @@ -6789,6 +6884,10 @@ public abstract class Component implements ImageObserver, MenuContainer, } /** + * @param evt the event to handle + * @param x the x coordinate + * @param y the y coordinate + * @return {@code false} * @deprecated As of JDK version 1.1, * replaced by processMouseEvent(MouseEvent). */ @@ -6798,6 +6897,10 @@ public abstract class Component implements ImageObserver, MenuContainer, } /** + * @param evt the event to handle + * @param x the x coordinate + * @param y the y coordinate + * @return {@code false} * @deprecated As of JDK version 1.1, * replaced by processMouseMotionEvent(MouseEvent). */ @@ -6807,6 +6910,10 @@ public abstract class Component implements ImageObserver, MenuContainer, } /** + * @param evt the event to handle + * @param x the x coordinate + * @param y the y coordinate + * @return {@code false} * @deprecated As of JDK version 1.1, * replaced by processMouseEvent(MouseEvent). */ @@ -6816,6 +6923,10 @@ public abstract class Component implements ImageObserver, MenuContainer, } /** + * @param evt the event to handle + * @param x the x coordinate + * @param y the y coordinate + * @return {@code false} * @deprecated As of JDK version 1.1, * replaced by processMouseMotionEvent(MouseEvent). */ @@ -6825,6 +6936,10 @@ public abstract class Component implements ImageObserver, MenuContainer, } /** + * @param evt the event to handle + * @param x the x coordinate + * @param y the y coordinate + * @return {@code false} * @deprecated As of JDK version 1.1, * replaced by processMouseEvent(MouseEvent). */ @@ -6834,6 +6949,10 @@ public abstract class Component implements ImageObserver, MenuContainer, } /** + * @param evt the event to handle + * @param x the x coordinate + * @param y the y coordinate + * @return {@code false} * @deprecated As of JDK version 1.1, * replaced by processMouseEvent(MouseEvent). */ @@ -6843,6 +6962,9 @@ public abstract class Component implements ImageObserver, MenuContainer, } /** + * @param evt the event to handle + * @param key the key pressed + * @return {@code false} * @deprecated As of JDK version 1.1, * replaced by processKeyEvent(KeyEvent). */ @@ -6852,6 +6974,9 @@ public abstract class Component implements ImageObserver, MenuContainer, } /** + * @param evt the event to handle + * @param key the key pressed + * @return {@code false} * @deprecated As of JDK version 1.1, * replaced by processKeyEvent(KeyEvent). */ @@ -6861,6 +6986,9 @@ public abstract class Component implements ImageObserver, MenuContainer, } /** + * @param evt the event to handle + * @param what the object acted on + * @return {@code false} * @deprecated As of JDK version 1.1, * should register this component as ActionListener on component * which fires action events. @@ -7070,6 +7198,9 @@ public abstract class Component implements ImageObserver, MenuContainer, } /** + * @param evt the event to handle + * @param what the object focused + * @return {@code false} * @deprecated As of JDK version 1.1, * replaced by processFocusEvent(FocusEvent). */ @@ -7079,6 +7210,9 @@ public abstract class Component implements ImageObserver, MenuContainer, } /** + * @param evt the event to handle + * @param what the object focused + * @return {@code false} * @deprecated As of JDK version 1.1, * replaced by processFocusEvent(FocusEvent). */ @@ -8390,6 +8524,7 @@ public abstract class Component implements ImageObserver, MenuContainer, * Returns an array of all the listeners which have been associated * with the named property. * + * @param propertyName the property name * @return all of the PropertyChangeListeners associated with * the named property; if no such listeners have been added or * if propertyName is null, an empty @@ -8400,8 +8535,7 @@ public abstract class Component implements ImageObserver, MenuContainer, * @see #getPropertyChangeListeners * @since 1.4 */ - public PropertyChangeListener[] getPropertyChangeListeners( - String propertyName) { + public PropertyChangeListener[] getPropertyChangeListeners(String propertyName) { synchronized (getObjectLock()) { if (changeSupport == null) { return new PropertyChangeListener[0]; @@ -8506,7 +8640,7 @@ public abstract class Component implements ImageObserver, MenuContainer, if (changeSupport == null || oldValue == newValue) { return; } - firePropertyChange(propertyName, new Character(oldValue), new Character(newValue)); + firePropertyChange(propertyName, Character.valueOf(oldValue), Character.valueOf(newValue)); } /** @@ -8879,6 +9013,7 @@ public abstract class Component implements ImageObserver, MenuContainer, * This method changes layout-related information, and therefore, * invalidates the component hierarchy. * + * @param o the orientation to be set * * @see ComponentOrientation * @see #invalidate @@ -8906,6 +9041,7 @@ public abstract class Component implements ImageObserver, MenuContainer, * subclasses that wish to respect orientation should call this method to * get the component's orientation before performing layout or drawing. * + * @return the orientation to order the elements or text * @see ComponentOrientation * * @author Laura Werner, IBM @@ -9063,7 +9199,16 @@ public abstract class Component implements ImageObserver, MenuContainer, */ private volatile transient int propertyListenersCount = 0; + /** + * A component listener to track show/hide/resize events + * and convert them to PropertyChange events. + */ protected ComponentListener accessibleAWTComponentHandler = null; + + /** + * A listener to track focus events + * and convert them to PropertyChange events. + */ protected FocusListener accessibleAWTFocusHandler = null; /** diff --git a/jdk/src/share/classes/java/awt/ComponentOrientation.java b/jdk/src/share/classes/java/awt/ComponentOrientation.java index 8655aafa322..226b004a273 100644 --- a/jdk/src/share/classes/java/awt/ComponentOrientation.java +++ b/jdk/src/share/classes/java/awt/ComponentOrientation.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2006, 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 @@ -126,6 +126,8 @@ public final class ComponentOrientation implements java.io.Serializable * Are lines horizontal? * This will return true for horizontal, left-to-right writing * systems such as Roman. + * + * @return {@code true} if this orientation has horizontal lines */ public boolean isHorizontal() { return (orientation & HORIZ_BIT) != 0; @@ -136,6 +138,8 @@ public final class ComponentOrientation implements java.io.Serializable * Vertical Lines: Do lines run left-to-right?
* This will return true for horizontal, left-to-right writing * systems such as Roman. + * + * @return {@code true} if this orientation is left-to-right */ public boolean isLeftToRight() { return (orientation & LTR_BIT) != 0; @@ -143,7 +147,9 @@ public final class ComponentOrientation implements java.io.Serializable /** * Returns the orientation that is appropriate for the given locale. + * * @param locale the specified locale + * @return the orientation for the locale */ public static ComponentOrientation getOrientation(Locale locale) { // A more flexible implementation would consult a ResourceBundle @@ -171,6 +177,8 @@ public final class ComponentOrientation implements java.io.Serializable *
  • Return the default locale's orientation. * * + * @param bdl the bundle to use + * @return the orientation * @deprecated As of J2SE 1.4, use {@link #getOrientation(java.util.Locale)}. */ @Deprecated diff --git a/jdk/src/share/classes/java/awt/Container.java b/jdk/src/share/classes/java/awt/Container.java index a352bab43ef..95997f4f900 100644 --- a/jdk/src/share/classes/java/awt/Container.java +++ b/jdk/src/share/classes/java/awt/Container.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 @@ -310,6 +310,9 @@ public class Container extends Component { } /** + * Returns the number of components in this container. + * + * @return the number of components in this container * @deprecated As of JDK version 1.1, * replaced by getComponentCount(). */ @@ -391,8 +394,11 @@ public class Container extends Component { } /** + * Returns the insets for this container. + * * @deprecated As of JDK version 1.1, * replaced by getInsets(). + * @return the insets for this container */ @Deprecated public Insets insets() { @@ -438,6 +444,9 @@ public class Container extends Component { * displayed, the hierarchy must be validated thereafter in order to * display the added component. * + * @param name the name of the component to be added + * @param comp the component to be added + * @return the component added * @exception NullPointerException if {@code comp} is {@code null} * @see #add(Component, Object) * @see #invalidate @@ -1471,8 +1480,10 @@ public class Container extends Component { /** * Gets the layout manager for this container. + * * @see #doLayout * @see #setLayout + * @return the current layout manager for this container */ public LayoutManager getLayout() { return layoutMgr; @@ -3854,6 +3865,10 @@ public class Container extends Component { */ private volatile transient int propertyListenersCount = 0; + /** + * The handler to fire {@code PropertyChange} + * when children are added or removed + */ protected ContainerListener accessibleContainerHandler = null; /** diff --git a/jdk/src/share/classes/java/awt/Cursor.java b/jdk/src/share/classes/java/awt/Cursor.java index 794c7c9b242..1468e162134 100644 --- a/jdk/src/share/classes/java/awt/Cursor.java +++ b/jdk/src/share/classes/java/awt/Cursor.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 @@ -294,6 +294,7 @@ public class Cursor implements java.io.Serializable { * @return the system specific custom cursor named * @exception HeadlessException if * GraphicsEnvironment.isHeadless returns true + * @exception AWTException in case of erroneous retrieving of the cursor */ static public Cursor getSystemCustomCursor(final String name) throws AWTException, HeadlessException { @@ -378,6 +379,8 @@ public class Cursor implements java.io.Serializable { /** * Return the system default cursor. + * + * @return the default cursor */ static public Cursor getDefaultCursor() { return getPredefinedCursor(Cursor.DEFAULT_CURSOR); @@ -416,6 +419,8 @@ public class Cursor implements java.io.Serializable { /** * Returns the type for this cursor. + * + * @return the cursor type */ public int getType() { return type; diff --git a/jdk/src/share/classes/java/awt/DisplayMode.java b/jdk/src/share/classes/java/awt/DisplayMode.java index 71a5d7e8122..41564300615 100644 --- a/jdk/src/share/classes/java/awt/DisplayMode.java +++ b/jdk/src/share/classes/java/awt/DisplayMode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -125,6 +125,8 @@ public final class DisplayMode { /** * Returns whether the two display modes are equal. + * + * @param dm the display mode to compare to * @return whether the two display modes are equal */ public boolean equals(DisplayMode dm) { diff --git a/jdk/src/share/classes/java/awt/EventDispatchThread.java b/jdk/src/share/classes/java/awt/EventDispatchThread.java index 51344658c7e..962039c8374 100644 --- a/jdk/src/share/classes/java/awt/EventDispatchThread.java +++ b/jdk/src/share/classes/java/awt/EventDispatchThread.java @@ -33,7 +33,6 @@ import java.util.ArrayList; import sun.util.logging.PlatformLogger; import sun.awt.dnd.SunDragSourceContextPeer; -import sun.awt.EventQueueDelegate; /** * EventDispatchThread is a package-private AWT class which takes @@ -158,17 +157,11 @@ class EventDispatchThread extends Thread { boolean eventOK = false; try { EventQueue eq = null; - EventQueueDelegate.Delegate delegate = null; do { // EventQueue may change during the dispatching eq = getEventQueue(); - delegate = EventQueueDelegate.getDelegate(); - if (delegate != null && id == ANY_EVENT) { - event = delegate.getNextEvent(eq); - } else { - event = (id == ANY_EVENT) ? eq.getNextEvent() : eq.getNextEvent(id); - } + event = (id == ANY_EVENT) ? eq.getNextEvent() : eq.getNextEvent(id); eventOK = true; synchronized (eventFilters) { @@ -194,14 +187,7 @@ class EventDispatchThread extends Thread { eventLog.finest("Dispatching: " + event); } - Object handle = null; - if (delegate != null) { - handle = delegate.beforeDispatch(event); - } eq.dispatchEvent(event); - if (delegate != null) { - delegate.afterDispatch(event, handle); - } } catch (ThreadDeath death) { doDispatch = false; diff --git a/jdk/src/share/classes/java/awt/EventQueue.java b/jdk/src/share/classes/java/awt/EventQueue.java index 4164641392e..a89311352ab 100644 --- a/jdk/src/share/classes/java/awt/EventQueue.java +++ b/jdk/src/share/classes/java/awt/EventQueue.java @@ -214,9 +214,17 @@ public class EventQueue { FwDispatcher dispatcher) { eventQueue.setFwDispatcher(dispatcher); } + + @Override + public long getMostRecentEventTime(EventQueue eventQueue) { + return eventQueue.getMostRecentEventTimeImpl(); + } }); } + /** + * Initializes a new instance of {@code EventQueue}. + */ public EventQueue() { for (int i = 0; i < NUM_PRIORITIES; i++) { queues[i] = new Queue(); diff --git a/jdk/src/share/classes/java/awt/Frame.java b/jdk/src/share/classes/java/awt/Frame.java index df3fcda4773..c6ce4814078 100644 --- a/jdk/src/share/classes/java/awt/Frame.java +++ b/jdk/src/share/classes/java/awt/Frame.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 @@ -1089,6 +1089,9 @@ public class Frame extends Window implements MenuContainer { } /** + * Sets the cursor for this frame to the specified type. + * + * @param cursorType the cursor type * @deprecated As of JDK version 1.1, * replaced by Component.setCursor(Cursor). */ @@ -1103,6 +1106,7 @@ public class Frame extends Window implements MenuContainer { /** * @deprecated As of JDK version 1.1, * replaced by Component.getCursor(). + * @return the cursor type for this frame */ @Deprecated public int getCursorType() { @@ -1124,6 +1128,8 @@ public class Frame extends Window implements MenuContainer { * ownerless {@code Dialog}s (introduced in release 1.6), use {@link * Window#getOwnerlessWindows Window.getOwnerlessWindows}. * + * @return the array of all {@code Frame}s created by this application + * * @see Window#getWindows() * @see Window#getOwnerlessWindows * diff --git a/jdk/src/share/classes/java/awt/GraphicsEnvironment.java b/jdk/src/share/classes/java/awt/GraphicsEnvironment.java index e9e9080dba6..2d6436cc00d 100644 --- a/jdk/src/share/classes/java/awt/GraphicsEnvironment.java +++ b/jdk/src/share/classes/java/awt/GraphicsEnvironment.java @@ -357,6 +357,8 @@ public abstract class GraphicsEnvironment { *

    Notice that an application can supersede the registration * of an earlier created font with a new one. * + * + * @param font the font to be registered * @return true if the font is successfully * registered in this GraphicsEnvironment. * @throws NullPointerException if font is null diff --git a/jdk/src/share/classes/java/awt/GridBagLayout.java b/jdk/src/share/classes/java/awt/GridBagLayout.java index 0b2c32ba2b5..981c993751a 100644 --- a/jdk/src/share/classes/java/awt/GridBagLayout.java +++ b/jdk/src/share/classes/java/awt/GridBagLayout.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 @@ -981,9 +981,15 @@ java.io.Serializable { * This method is obsolete and supplied for backwards * compatibility only; new code should call {@link * #getLayoutInfo(java.awt.Container, int) getLayoutInfo} instead. - * This method is the same as getLayoutInfo; - * refer to getLayoutInfo for details on parameters - * and return value. + * + * Fills in an instance of {@code GridBagLayoutInfo} for the + * current set of managed children. This method is the same + * as {@code getLayoutInfo}; refer to {@code getLayoutInfo} + * description for details. + * + * @param parent the layout container + * @param sizeflag either {@code PREFERREDSIZE} or {@code MINSIZE} + * @return the {@code GridBagLayoutInfo} for the set of children */ protected GridBagLayoutInfo GetLayoutInfo(Container parent, int sizeflag) { synchronized (parent.getTreeLock()) { @@ -1611,13 +1617,17 @@ java.io.Serializable { } /** + * Adjusts the x, y, width, and height fields to the correct + * values depending on the constraint geometry and pads. + *

    * This method is obsolete and supplied for backwards * compatibility only; new code should call {@link * #adjustForGravity(java.awt.GridBagConstraints, java.awt.Rectangle) * adjustForGravity} instead. - * This method is the same as adjustForGravity; - * refer to adjustForGravity for details - * on parameters. + * This method is the same as adjustForGravity + * + * @param constraints the constraints to be applied + * @param r the {@code Rectangle} to be adjusted */ protected void AdjustForGravity(GridBagConstraints constraints, Rectangle r) { @@ -1995,9 +2005,12 @@ java.io.Serializable { * This method is obsolete and supplied for backwards * compatibility only; new code should call {@link * #getMinSize(java.awt.Container, GridBagLayoutInfo) getMinSize} instead. - * This method is the same as getMinSize; - * refer to getMinSize for details on parameters - * and return value. + * This method is the same as getMinSize + * + * @param parent the layout container + * @param info the layout info for this parent + * @return a Dimension object containing the + * minimum size */ protected Dimension GetMinSize(Container parent, GridBagLayoutInfo info) { Dimension d = new Dimension(); @@ -2035,9 +2048,9 @@ java.io.Serializable { * This method is obsolete and supplied for backwards * compatibility only; new code should call {@link * #arrangeGrid(Container) arrangeGrid} instead. - * This method is the same as arrangeGrid; - * refer to arrangeGrid for details on the - * parameter. + * This method is the same as arrangeGrid + * + * @param parent the layout container */ protected void ArrangeGrid(Container parent) { Component comp; diff --git a/jdk/src/share/classes/java/awt/HeadlessException.java b/jdk/src/share/classes/java/awt/HeadlessException.java index db53a351c6d..5809ffd9faf 100644 --- a/jdk/src/share/classes/java/awt/HeadlessException.java +++ b/jdk/src/share/classes/java/awt/HeadlessException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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,10 +38,24 @@ public class HeadlessException extends UnsupportedOperationException { * JDK 1.4 serialVersionUID */ private static final long serialVersionUID = 167183644944358563L; + + /** + * Constructs new {@code HeadlessException} + */ public HeadlessException() {} + + /** + * Create a new instance with the specified detailed error message. + * + * @param msg the error message + */ public HeadlessException(String msg) { super(msg); } + + /** + * {@inheritDoc} + */ public String getMessage() { String superMessage = super.getMessage(); String headlessMessage = GraphicsEnvironment.getHeadlessMessage(); diff --git a/jdk/src/share/classes/java/awt/ItemSelectable.java b/jdk/src/share/classes/java/awt/ItemSelectable.java index d19afb3ab0d..e11b70ef48f 100644 --- a/jdk/src/share/classes/java/awt/ItemSelectable.java +++ b/jdk/src/share/classes/java/awt/ItemSelectable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2000, 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,6 +39,8 @@ public interface ItemSelectable { /** * Returns the selected items or null if no * items are selected. + * + * @return the list of selected objects, or {@code null} */ public Object[] getSelectedObjects(); diff --git a/jdk/src/share/classes/java/awt/KeyboardFocusManager.java b/jdk/src/share/classes/java/awt/KeyboardFocusManager.java index 8758a2b50e3..57a8f733ce7 100644 --- a/jdk/src/share/classes/java/awt/KeyboardFocusManager.java +++ b/jdk/src/share/classes/java/awt/KeyboardFocusManager.java @@ -1459,6 +1459,7 @@ public abstract class KeyboardFocusManager * Returns an array of all the PropertyChangeListeners * associated with the named property. * + * @param propertyName the property name * @return all of the PropertyChangeListeners associated with * the named property or an empty array if no such listeners have * been added. @@ -1628,6 +1629,7 @@ public abstract class KeyboardFocusManager * Returns an array of all the VetoableChangeListeners * associated with the named property. * + * @param propertyName the property name * @return all of the VetoableChangeListeners associated with * the named property or an empty array if no such listeners have * been added. diff --git a/jdk/src/share/classes/java/awt/Label.java b/jdk/src/share/classes/java/awt/Label.java index 20ccdcd4c86..c8aab9569ff 100644 --- a/jdk/src/share/classes/java/awt/Label.java +++ b/jdk/src/share/classes/java/awt/Label.java @@ -193,7 +193,8 @@ public class Label extends Component implements Accessible { * Gets the current alignment of this label. Possible values are * Label.LEFT, Label.RIGHT, and * Label.CENTER. - * @see java.awt.Label#setAlignment + * @return the alignment of this label + * @see java.awt.Label#setAlignment */ public int getAlignment() { return alignment; @@ -321,6 +322,9 @@ public class Label extends Component implements Accessible { */ private static final long serialVersionUID = -3568967560160480438L; + /** + * Constructor for the accessible label. + */ public AccessibleAWTLabel() { super(); } diff --git a/jdk/src/share/classes/java/awt/LayoutManager.java b/jdk/src/share/classes/java/awt/LayoutManager.java index 5a00db263e6..d7abfbb1c29 100644 --- a/jdk/src/share/classes/java/awt/LayoutManager.java +++ b/jdk/src/share/classes/java/awt/LayoutManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2005, 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 @@ -61,7 +61,9 @@ public interface LayoutManager { /** * Calculates the preferred size dimensions for the specified * container, given the components it contains. - * @param parent the container to be laid out + * + * @param parent the container to be laid out + * @return the preferred dimension for the container * * @see #minimumLayoutSize */ @@ -70,7 +72,10 @@ public interface LayoutManager { /** * Calculates the minimum size dimensions for the specified * container, given the components it contains. - * @param parent the component to be laid out + * + * @param parent the component to be laid out + * @return the minimum dimension for the container + * * @see #preferredLayoutSize */ Dimension minimumLayoutSize(Container parent); diff --git a/jdk/src/share/classes/java/awt/LayoutManager2.java b/jdk/src/share/classes/java/awt/LayoutManager2.java index ae6516e17b8..347295052e4 100644 --- a/jdk/src/share/classes/java/awt/LayoutManager2.java +++ b/jdk/src/share/classes/java/awt/LayoutManager2.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2001, 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 @@ -55,8 +55,11 @@ public interface LayoutManager2 extends LayoutManager { /** * Calculates the maximum size dimensions for the specified container, * given the components it contains. + * * @see java.awt.Component#getMaximumSize * @see LayoutManager + * @param target the target container + * @return the maximum size of the container */ public Dimension maximumLayoutSize(Container target); @@ -66,6 +69,9 @@ public interface LayoutManager2 extends LayoutManager { * components. The value should be a number between 0 and 1 * where 0 represents alignment along the origin, 1 is aligned * the furthest away from the origin, 0.5 is centered, etc. + * + * @param target the target container + * @return the x-axis alignment preference */ public float getLayoutAlignmentX(Container target); @@ -75,12 +81,16 @@ public interface LayoutManager2 extends LayoutManager { * components. The value should be a number between 0 and 1 * where 0 represents alignment along the origin, 1 is aligned * the furthest away from the origin, 0.5 is centered, etc. + * + * @param target the target container + * @return the y-axis alignment preference */ public float getLayoutAlignmentY(Container target); /** * Invalidates the layout, indicating that if the layout manager * has cached information it should be discarded. + * @param target the target container */ public void invalidateLayout(Container target); diff --git a/jdk/src/share/classes/java/awt/List.java b/jdk/src/share/classes/java/awt/List.java index df638c26724..ede6f643157 100644 --- a/jdk/src/share/classes/java/awt/List.java +++ b/jdk/src/share/classes/java/awt/List.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 @@ -282,6 +282,9 @@ public class List extends Component implements ItemSelectable, Accessible { } /** + * Returns the number of items in the list. + * + * @return the number of items in the list * @deprecated As of JDK version 1.1, * replaced by getItemCount(). */ @@ -333,7 +336,10 @@ public class List extends Component implements ItemSelectable, Accessible { } /** - * @deprecated replaced by add(String). + * Adds the specified item to the end of the list. + * + * @param item the item to be added + * @deprecated replaced by add(String). */ @Deprecated public void addItem(String item) { @@ -358,7 +364,12 @@ public class List extends Component implements ItemSelectable, Accessible { } /** - * @deprecated replaced by add(String, int). + * Adds the specified item to the the list + * at the position indicated by the index. + * + * @param item the item to be added + * @param index the position at which to add the item + * @deprecated replaced by add(String, int). */ @Deprecated public synchronized void addItem(String item, int index) { @@ -455,8 +466,11 @@ public class List extends Component implements ItemSelectable, Accessible { } /** - * @deprecated replaced by remove(String) - * and remove(int). + * Removes the item at the specified position. + * + * @param position the index of the item to delete + * @deprecated replaced by remove(String) + * and remove(int). */ @Deprecated public void delItem(int position) { @@ -646,6 +660,10 @@ public class List extends Component implements ItemSelectable, Accessible { } /** + * Determines if the specified item in the list is selected. + * + * @param index specifies the item to be checked + * @return {@code true} if the item is selected; otherwise {@code false} * @deprecated As of JDK version 1.1, * replaced by isIndexSelected(int). */ @@ -672,6 +690,7 @@ public class List extends Component implements ItemSelectable, Accessible { /** * Determines whether this list allows multiple selections. + * * @return true if this list allows multiple * selections; otherwise, false * @see #setMultipleMode @@ -682,6 +701,10 @@ public class List extends Component implements ItemSelectable, Accessible { } /** + * Determines whether this list allows multiple selections. + * + * @return {@code true} if this list allows multiple + * selections; otherwise {@code false} * @deprecated As of JDK version 1.1, * replaced by isMultipleMode(). */ @@ -709,6 +732,9 @@ public class List extends Component implements ItemSelectable, Accessible { } /** + * Enables or disables multiple selection mode for this list. + * + * @param b {@code true} to enable multiple mode, {@code false} otherwise * @deprecated As of JDK version 1.1, * replaced by setMultipleMode(boolean). */ @@ -760,6 +786,11 @@ public class List extends Component implements ItemSelectable, Accessible { } /** + * Returns the preferred size of this component + * assuming it has the specified number of rows. + * + * @param rows the number of rows + * @return the preferred dimensions for displaying this list * @deprecated As of JDK version 1.1, * replaced by getPreferredSize(int). */ @@ -810,6 +841,11 @@ public class List extends Component implements ItemSelectable, Accessible { } /** + * Returns the minimum dimensions for the list + * with the specified number of rows. + * + * @param rows the number of rows in the list + * @return the minimum dimensions for displaying this list * @deprecated As of JDK version 1.1, * replaced by getMinimumSize(int). */ @@ -1146,6 +1182,10 @@ public class List extends Component implements ItemSelectable, Accessible { } /** + * Deletes the list items in the specified index range. + * + * @param start the beginning index of the range to delete + * @param end the ending index of the range to delete * @deprecated As of JDK version 1.1, * Not for public use in the future. * This method is expected to be retained only as a package @@ -1290,6 +1330,9 @@ public class List extends Component implements ItemSelectable, Accessible { */ private static final long serialVersionUID = 7924617370136012829L; + /** + * Constructs new {@code AccessibleAWTList} + */ public AccessibleAWTList() { super(); List.this.addActionListener(this); @@ -1491,6 +1534,13 @@ public class List extends Component implements ItemSelectable, Accessible { private List parent; private int indexInParent; + /** + * Constructs new {@code AccessibleAWTListChild} with the given + * parent {@code List} and 0-based index of this object in the parent. + * + * @param parent the parent {@code List} + * @param indexInParent the index in the parent + */ public AccessibleAWTListChild(List parent, int indexInParent) { this.parent = parent; this.setAccessibleParent(parent); diff --git a/jdk/src/share/classes/java/awt/MediaTracker.java b/jdk/src/share/classes/java/awt/MediaTracker.java index e8e8212208b..dd8f9e0825f 100644 --- a/jdk/src/share/classes/java/awt/MediaTracker.java +++ b/jdk/src/share/classes/java/awt/MediaTracker.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 @@ -226,7 +226,9 @@ public class MediaTracker implements java.io.Serializable { addImageImpl(image, id, w, h); Image rvImage = getResolutionVariant(image); if (rvImage != null) { - addImageImpl(rvImage, id, 2 * w, 2 * h); + addImageImpl(rvImage, id, + w == -1 ? -1 : 2 * w, + h == -1 ? -1 : 2 * h); } } @@ -641,9 +643,11 @@ public class MediaTracker implements java.io.Serializable { * image is considered to have finished loading. Use the * statusID, isErrorID, and * isErrorAny methods to check for errors. - * @param id the identifier of the images to check - * @param ms the length of time, in milliseconds, to wait - * for the loading to complete + * @param id the identifier of the images to check + * @param ms the length of time, in milliseconds, to wait + * for the loading to complete + * @return {@code true} if the loading completed in time; + * otherwise {@code false} * @see java.awt.MediaTracker#waitForAll * @see java.awt.MediaTracker#waitForID(int) * @see java.awt.MediaTracker#statusID @@ -810,8 +814,9 @@ public class MediaTracker implements java.io.Serializable { removeImageImpl(image, id, width, height); Image rvImage = getResolutionVariant(image); if (rvImage != null) { - removeImageImpl(rvImage, id, 2 * width, 2 * height); - + removeImageImpl(rvImage, id, + width == -1 ? -1 : 2 * width, + height == -1 ? -1 : 2 * height); } notifyAll(); // Notify in case remaining images are "done". } diff --git a/jdk/src/share/classes/java/awt/Menu.java b/jdk/src/share/classes/java/awt/Menu.java index 177f208be05..3c8154338ac 100644 --- a/jdk/src/share/classes/java/awt/Menu.java +++ b/jdk/src/share/classes/java/awt/Menu.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 @@ -213,7 +213,7 @@ public class Menu extends MenuItem implements MenuContainer, Accessible { /** * Get the number of items in this menu. - * @return the number of items in this menu. + * @return the number of items in this menu * @since 1.1 */ public int getItemCount() { @@ -221,6 +221,9 @@ public class Menu extends MenuItem implements MenuContainer, Accessible { } /** + * Returns the number of items in this menu. + * + * @return the number of items in this menu * @deprecated As of JDK version 1.1, * replaced by getItemCount(). */ diff --git a/jdk/src/share/classes/java/awt/MenuBar.java b/jdk/src/share/classes/java/awt/MenuBar.java index 4e48c7c38ce..4fa4723c417 100644 --- a/jdk/src/share/classes/java/awt/MenuBar.java +++ b/jdk/src/share/classes/java/awt/MenuBar.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 @@ -279,6 +279,9 @@ public class MenuBar extends MenuComponent implements MenuContainer, Accessible } /** + * Gets the number of menus on the menu bar. + * + * @return the number of menus on the menu bar. * @deprecated As of JDK version 1.1, * replaced by getMenuCount(). */ @@ -338,10 +341,11 @@ public class MenuBar extends MenuComponent implements MenuContainer, Accessible * or null if none of the menu items being managed * by this menu bar is associated with the specified menu * shortcut. - * @param s the specified menu shortcut. - * @see java.awt.MenuItem - * @see java.awt.MenuShortcut - * @since 1.1 + * @param s the specified menu shortcut. + * @return the menu item for the specified shortcut. + * @see java.awt.MenuItem + * @see java.awt.MenuShortcut + * @since 1.1 */ public MenuItem getShortcutMenuItem(MenuShortcut s) { int nmenus = getMenuCount(); diff --git a/jdk/src/share/classes/java/awt/MenuComponent.java b/jdk/src/share/classes/java/awt/MenuComponent.java index 28fb9ab209e..4ea95bf5969 100644 --- a/jdk/src/share/classes/java/awt/MenuComponent.java +++ b/jdk/src/share/classes/java/awt/MenuComponent.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 @@ -220,6 +220,7 @@ public abstract class MenuComponent implements java.io.Serializable { /** * @deprecated As of JDK version 1.1, * programs should not directly manipulate peers. + * @return the peer for this component */ @Deprecated public MenuComponentPeer getPeer() { diff --git a/jdk/src/share/classes/java/awt/MenuContainer.java b/jdk/src/share/classes/java/awt/MenuContainer.java index 8b43f992f4f..8ba5e70245b 100644 --- a/jdk/src/share/classes/java/awt/MenuContainer.java +++ b/jdk/src/share/classes/java/awt/MenuContainer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2004, 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 @@ -31,10 +31,25 @@ package java.awt; */ public interface MenuContainer { + + /** + * Returns the font in use by this container. + * + * @return the menu font + */ Font getFont(); + + /** + * Removes the specified menu component from the menu. + * + * @param comp the menu component to remove + */ void remove(MenuComponent comp); /** + * Posts an event to the listeners. + * + * @param evt the event to dispatch * @deprecated As of JDK version 1.1 * replaced by dispatchEvent(AWTEvent). */ diff --git a/jdk/src/share/classes/java/awt/MenuItem.java b/jdk/src/share/classes/java/awt/MenuItem.java index a81c1314700..ab797f4dd1a 100644 --- a/jdk/src/share/classes/java/awt/MenuItem.java +++ b/jdk/src/share/classes/java/awt/MenuItem.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 @@ -264,6 +264,9 @@ public class MenuItem extends MenuComponent implements Accessible { /** * Checks whether this menu item is enabled. + * + * @return {@code true} if the item is enabled; + * otherwise {@code false} * @see java.awt.MenuItem#setEnabled * @since 1.0 */ @@ -296,6 +299,10 @@ public class MenuItem extends MenuComponent implements Accessible { } /** + * Sets whether or not this menu item can be chosen. + * + * @param b if {@code true}, enables this menu item; + * otherwise disables * @deprecated As of JDK version 1.1, * replaced by setEnabled(boolean). */ @@ -494,8 +501,10 @@ public class MenuItem extends MenuComponent implements Accessible { /** * Gets the command name of the action event that is fired * by this menu item. - * @see java.awt.MenuItem#setActionCommand - * @since 1.1 + * + * @return the action command name + * @see java.awt.MenuItem#setActionCommand + * @since 1.1 */ public String getActionCommand() { return getActionCommandImpl(); diff --git a/jdk/src/share/classes/java/awt/PrintGraphics.java b/jdk/src/share/classes/java/awt/PrintGraphics.java index 91e5173f81f..74c2f84a31e 100644 --- a/jdk/src/share/classes/java/awt/PrintGraphics.java +++ b/jdk/src/share/classes/java/awt/PrintGraphics.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 1997, 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 @@ -35,6 +35,8 @@ public interface PrintGraphics { /** * Returns the PrintJob object from which this PrintGraphics * object originated. + * + * @return the print job for this object */ public PrintJob getPrintJob(); diff --git a/jdk/src/share/classes/java/awt/PrintJob.java b/jdk/src/share/classes/java/awt/PrintJob.java index 996d7653526..fcc6afebf2a 100644 --- a/jdk/src/share/classes/java/awt/PrintJob.java +++ b/jdk/src/share/classes/java/awt/PrintJob.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 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 @@ -42,6 +42,7 @@ public abstract class PrintJob { * object is disposed. This graphics object will also implement * the PrintGraphics interface. * @see PrintGraphics + * @return the graphics context for printing the next page */ public abstract Graphics getGraphics(); @@ -49,6 +50,8 @@ public abstract class PrintJob { * Returns the dimensions of the page in pixels. * The resolution of the page is chosen so that it * is similar to the screen resolution. + * + * @return the page dimension */ public abstract Dimension getPageDimension(); @@ -56,11 +59,16 @@ public abstract class PrintJob { * Returns the resolution of the page in pixels per inch. * Note that this doesn't have to correspond to the physical * resolution of the printer. + * + * @return the page resolution */ public abstract int getPageResolution(); /** * Returns true if the last page will be printed first. + * + * @return {@code true} if the last page will be printed first; + * otherwise {@code false} */ public abstract boolean lastPageFirst(); diff --git a/jdk/src/share/classes/java/awt/Robot.java b/jdk/src/share/classes/java/awt/Robot.java index cc734dd45a2..8de89ee8ed9 100644 --- a/jdk/src/share/classes/java/awt/Robot.java +++ b/jdk/src/share/classes/java/awt/Robot.java @@ -498,6 +498,8 @@ public class Robot { /** * Returns the number of milliseconds this Robot sleeps after generating an event. + * + * @return the delay duration in milliseconds */ public synchronized int getAutoDelay() { return autoDelay; @@ -505,7 +507,10 @@ public class Robot { /** * Sets the number of milliseconds this Robot sleeps after generating an event. - * @throws IllegalArgumentException If ms is not between 0 and 60,000 milliseconds inclusive + * + * @param ms the delay duration in milliseconds + * @throws IllegalArgumentException If {@code ms} + * is not between 0 and 60,000 milliseconds inclusive */ public synchronized void setAutoDelay(int ms) { checkDelayArgument(ms); @@ -523,9 +528,11 @@ public class Robot { * Sleeps for the specified time. * To catch any InterruptedExceptions that occur, * Thread.sleep() may be used instead. - * @param ms time to sleep in milliseconds - * @throws IllegalArgumentException if ms is not between 0 and 60,000 milliseconds inclusive - * @see java.lang.Thread#sleep + * + * @param ms time to sleep in milliseconds + * @throws IllegalArgumentException if {@code ms} + * is not between 0 and 60,000 milliseconds inclusive + * @see java.lang.Thread#sleep */ public synchronized void delay(int ms) { checkDelayArgument(ms); diff --git a/jdk/src/share/classes/java/awt/ScrollPane.java b/jdk/src/share/classes/java/awt/ScrollPane.java index 70ca48f4d74..fb5401d06f6 100644 --- a/jdk/src/share/classes/java/awt/ScrollPane.java +++ b/jdk/src/share/classes/java/awt/ScrollPane.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 @@ -323,7 +323,9 @@ public class ScrollPane extends Container implements Accessible { * represents the state of the vertical scrollbar. * The declared return type of this method is * Adjustable to maintain backward compatibility. + * * @see java.awt.ScrollPaneAdjustable + * @return the vertical scrollbar state */ public Adjustable getVAdjustable() { return vAdjustable; @@ -334,7 +336,9 @@ public class ScrollPane extends Container implements Accessible { * represents the state of the horizontal scrollbar. * The declared return type of this method is * Adjustable to maintain backward compatibility. + * * @see java.awt.ScrollPaneAdjustable + * @return the horizontal scrollbar state */ public Adjustable getHAdjustable() { return hAdjustable; @@ -657,6 +661,9 @@ public class ScrollPane extends Container implements Accessible { * Indicates whether or not scrolling will take place in response to * the mouse wheel. Wheel scrolling is enabled by default. * + * @return {@code true} if the wheel scrolling enabled; + * otherwise {@code false} + * * @see #setWheelScrollingEnabled(boolean) * @since 1.4 */ diff --git a/jdk/src/share/classes/java/awt/Scrollbar.java b/jdk/src/share/classes/java/awt/Scrollbar.java index bf119ae2779..28c84efb923 100644 --- a/jdk/src/share/classes/java/awt/Scrollbar.java +++ b/jdk/src/share/classes/java/awt/Scrollbar.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 @@ -656,6 +656,9 @@ public class Scrollbar extends Component implements Adjustable, Accessible { } /** + * Returns the visible amount of this scroll bar. + * + * @return the visible amount of this scroll bar * @deprecated As of JDK version 1.1, * replaced by getVisibleAmount(). */ @@ -729,6 +732,10 @@ public class Scrollbar extends Component implements Adjustable, Accessible { } /** + * Sets the unit increment for this scroll bar. + * + * @param v the increment value + * * @deprecated As of JDK version 1.1, * replaced by setUnitIncrement(int). */ @@ -768,6 +775,9 @@ public class Scrollbar extends Component implements Adjustable, Accessible { } /** + * Returns the unit increment for this scrollbar. + * + * @return the unit increment for this scrollbar * @deprecated As of JDK version 1.1, * replaced by getUnitIncrement(). */ @@ -797,6 +807,9 @@ public class Scrollbar extends Component implements Adjustable, Accessible { } /** + * Sets the block increment for this scroll bar. + * + * @param v the block increment * @deprecated As of JDK version 1.1, * replaced by setBlockIncrement(). */ @@ -833,6 +846,10 @@ public class Scrollbar extends Component implements Adjustable, Accessible { } /** + * Returns the block increment of this scroll bar. + * + * @return the block increment of this scroll bar + * * @deprecated As of JDK version 1.1, * replaced by getBlockIncrement(). */ diff --git a/jdk/src/share/classes/java/awt/TextArea.java b/jdk/src/share/classes/java/awt/TextArea.java index dd90aa7414e..f29da08b537 100644 --- a/jdk/src/share/classes/java/awt/TextArea.java +++ b/jdk/src/share/classes/java/awt/TextArea.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 @@ -314,6 +314,11 @@ public class TextArea extends TextComponent { } /** + * Inserts the specified text at the specified position + * in this text area. + * + * @param str the non-{@code null} text to insert + * @param pos the position at which to insert * @deprecated As of JDK version 1.1, * replaced by insert(String, int). */ @@ -342,6 +347,9 @@ public class TextArea extends TextComponent { } /** + * Appends the given text to the text area's current text. + * + * @param str the text to append * @deprecated As of JDK version 1.1, * replaced by append(String). */ @@ -378,6 +386,15 @@ public class TextArea extends TextComponent { } /** + * Replaces a range of characters between + * the indicated start and end positions + * with the specified replacement text (the text at the end + * position will not be replaced). + * + * @param str the non-{@code null} text to use as + * the replacement + * @param start the start position + * @param end the end position * @deprecated As of JDK version 1.1, * replaced by replaceRange(String, int, int). */ @@ -492,6 +509,12 @@ public class TextArea extends TextComponent { } /** + * Determines the preferred size of the text area with the specified + * number of rows and columns. + * + * @param rows the number of rows + * @param columns the number of columns + * @return the preferred dimensions needed for the text area * @deprecated As of JDK version 1.1, * replaced by getPreferredSize(int, int). */ @@ -544,6 +567,12 @@ public class TextArea extends TextComponent { } /** + * Determines the minimum size of the text area with the specified + * number of rows and columns. + * + * @param rows the number of rows + * @param columns the number of columns + * @return the minimum size for the text area * @deprecated As of JDK version 1.1, * replaced by getMinimumSize(int, int). */ diff --git a/jdk/src/share/classes/java/awt/TextComponent.java b/jdk/src/share/classes/java/awt/TextComponent.java index 104fe02e53b..639438a2a1d 100644 --- a/jdk/src/share/classes/java/awt/TextComponent.java +++ b/jdk/src/share/classes/java/awt/TextComponent.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 @@ -107,6 +107,9 @@ public class TextComponent extends Component implements Accessible { // the background color of non-editable TextComponents. boolean backgroundSetByClientCode = false; + /** + * A list of listeners that will receive events from this object. + */ transient protected TextListener textListener; /* diff --git a/jdk/src/share/classes/java/awt/TextField.java b/jdk/src/share/classes/java/awt/TextField.java index 3b4646896e1..ebebc828b96 100644 --- a/jdk/src/share/classes/java/awt/TextField.java +++ b/jdk/src/share/classes/java/awt/TextField.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 @@ -272,6 +272,10 @@ public class TextField extends TextComponent { } /** + * Sets the character to be echoed when protected input is displayed. + * + * @param c the echo character for this text field + * * @deprecated As of JDK version 1.1, * replaced by setEchoChar(char). */ @@ -368,6 +372,12 @@ public class TextField extends TextComponent { } /** + * Returns the preferred size for this text field + * with the specified number of columns. + * + * @param columns the number of columns + * @return the preferred size for the text field + * * @deprecated As of JDK version 1.1, * replaced by getPreferredSize(int). */ @@ -407,8 +417,9 @@ public class TextField extends TextComponent { /** * Gets the minimum dimensions for a text field with * the specified number of columns. - * @param columns the number of columns in - * this text field. + * @param columns the number of columns in + * this text field. + * @return the minimum size for this text field * @since 1.1 */ public Dimension getMinimumSize(int columns) { @@ -416,6 +427,11 @@ public class TextField extends TextComponent { } /** + * Returns the minimum dimensions for a text field with + * the specified number of columns. + * + * @param columns the number of columns + * @return the minimum size for this text field * @deprecated As of JDK version 1.1, * replaced by getMinimumSize(int). */ diff --git a/jdk/src/share/classes/java/awt/Toolkit.java b/jdk/src/share/classes/java/awt/Toolkit.java index 7bc8c24f625..65b494ba52d 100644 --- a/jdk/src/share/classes/java/awt/Toolkit.java +++ b/jdk/src/share/classes/java/awt/Toolkit.java @@ -422,7 +422,8 @@ public abstract class Toolkit { * and allows the Component and Container classes to be extended directly * to create windowless components that are defined entirely in java. * - * @param target The Component to be created. + * @param target The Component to be created. + * @return the peer for the specified component */ protected LightweightPeer createComponent(Component target) { if (lightweightMarker == null) { @@ -1370,6 +1371,9 @@ public abstract class Toolkit { * {@link java.awt.event.KeyEvent#VK_SCROLL_LOCK VK_SCROLL_LOCK}, and * {@link java.awt.event.KeyEvent#VK_KANA_LOCK VK_KANA_LOCK}. * + * @param keyCode the key code + * @return {@code true} if the given key is currently in its "on" state; + * otherwise {@code false} * @exception java.lang.IllegalArgumentException if keyCode * is not one of the valid key codes * @exception java.lang.UnsupportedOperationException if the host system doesn't @@ -1404,6 +1408,8 @@ public abstract class Toolkit { * involve event processing and therefore may not be immediately * observable through getLockingKeyState. * + * @param keyCode the key code + * @param on the state of the key * @exception java.lang.IllegalArgumentException if keyCode * is not one of the valid key codes * @exception java.lang.UnsupportedOperationException if the host system doesn't @@ -1429,6 +1435,9 @@ public abstract class Toolkit { /** * Give native peers the ability to query the native container * given a native component (eg the direct parent may be lightweight). + * + * @param c the component to fetch the container for + * @return the native container object for the component */ protected static Container getNativeContainer(Component c) { return c.getNativeContainer(); @@ -1449,6 +1458,7 @@ public abstract class Toolkit { * @param name a localized description of the cursor, for Java Accessibility use * @exception IndexOutOfBoundsException if the hotSpot values are outside * the bounds of the cursor + * @return the cursor created * @exception HeadlessException if GraphicsEnvironment.isHeadless() * returns true * @see java.awt.GraphicsEnvironment#isHeadless @@ -1675,6 +1685,11 @@ public abstract class Toolkit { /** * Gets a property with the specified key and default. * This method returns defaultValue if the property is not found. + * + * @param key the key + * @param defaultValue the default value + * @return the value of the property or the default value + * if the property was not found */ public static String getProperty(String key, String defaultValue) { // first try platform specific bundle @@ -1738,6 +1753,9 @@ public abstract class Toolkit { * Creates the peer for a DragSourceContext. * Always throws InvalidDndOperationException if * GraphicsEnvironment.isHeadless() returns true. + * + * @param dge the {@code DragGestureEvent} + * @return the peer created * @see java.awt.GraphicsEnvironment#isHeadless */ public abstract DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException; @@ -1775,6 +1793,9 @@ public abstract class Toolkit { * representation for an underlying platform dependent desktop setting. * For more information on desktop properties supported by the AWT see * AWT Desktop Properties. + * + * @param propertyName the property name + * @return the value for the specified desktop property */ public final synchronized Object getDesktopProperty(String propertyName) { // This is a workaround for headless toolkits. It would be @@ -1818,6 +1839,9 @@ public abstract class Toolkit { /** * Sets the named desktop property to the specified value and fires a * property change event to notify any listeners that the value has changed. + * + * @param name the property name + * @param newValue the new property value */ protected final void setDesktopProperty(String name, Object newValue) { // This is a workaround for headless toolkits. It would be diff --git a/jdk/src/share/classes/java/awt/Window.java b/jdk/src/share/classes/java/awt/Window.java index 47bcdf301ca..629f1df75a4 100644 --- a/jdk/src/share/classes/java/awt/Window.java +++ b/jdk/src/share/classes/java/awt/Window.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 @@ -1452,6 +1452,8 @@ public class Window extends Container implements Accessible { /** * Returns the owner of this window. + * + * @return the owner of this window * @since 1.2 */ public Window getOwner() { @@ -1464,6 +1466,8 @@ public class Window extends Container implements Accessible { /** * Return an array containing all the windows this * window currently owns. + * + * @return the array of all the owned windows * @since 1.2 */ public Window[] getOwnedWindows() { @@ -1586,6 +1590,7 @@ public class Window extends Container implements Accessible { * dialogs such as component positions, {@code LayoutManager}s * or serialization. * + * @return the array of all the {@code Window}s created by the application * @see Frame#getFrames * @see Window#getOwnerlessWindows * @@ -1608,6 +1613,8 @@ public class Window extends Container implements Accessible { * dialogs such as component positions, {@code LayoutManager}s * or serialization. * + * @return the array of all the ownerless {@code Window}s + * created by this application * @see Frame#getFrames * @see Window#getWindows() * @@ -2849,6 +2856,7 @@ public class Window extends Container implements Accessible { * * This method can only be called while the window is not displayable. * + * @param type the window type * @throws IllegalComponentStateException if the window * is displayable. * @throws IllegalArgumentException if the type is {@code null} @@ -2874,6 +2882,7 @@ public class Window extends Container implements Accessible { /** * Returns the type of the window. * + * @return the type of the window * @see #setType * @since 1.7 */ diff --git a/jdk/src/share/classes/java/awt/event/InputMethodEvent.java b/jdk/src/share/classes/java/awt/event/InputMethodEvent.java index 104f10b8fea..ca214ed6e45 100644 --- a/jdk/src/share/classes/java/awt/event/InputMethodEvent.java +++ b/jdk/src/share/classes/java/awt/event/InputMethodEvent.java @@ -25,6 +25,10 @@ package java.awt.event; +import sun.awt.AWTAccessor; +import sun.awt.AppContext; +import sun.awt.SunToolkit; + import java.awt.AWTEvent; import java.awt.Component; import java.awt.EventQueue; @@ -217,8 +221,10 @@ public class InputMethodEvent extends AWTEvent { public InputMethodEvent(Component source, int id, AttributedCharacterIterator text, int committedCharacterCount, TextHitInfo caret, TextHitInfo visiblePosition) { - this(source, id, EventQueue.getMostRecentEventTime(), text, - committedCharacterCount, caret, visiblePosition); + this(source, id, + getMostRecentEventTimeForSource(source), + text, committedCharacterCount, + caret, visiblePosition); } /** @@ -258,8 +264,9 @@ public class InputMethodEvent extends AWTEvent { */ public InputMethodEvent(Component source, int id, TextHitInfo caret, TextHitInfo visiblePosition) { - this(source, id, EventQueue.getMostRecentEventTime(), null, - 0, caret, visiblePosition); + this(source, id, + getMostRecentEventTimeForSource(source), + null, 0, caret, visiblePosition); } /** @@ -411,7 +418,25 @@ public class InputMethodEvent extends AWTEvent { private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException { s.defaultReadObject(); if (when == 0) { - when = EventQueue.getMostRecentEventTime(); + when = getMostRecentEventTimeForSource(this.source); } } + + /** + * Get the most recent event time in the {@code EventQueue} which the {@code source} + * belongs to. + * + * @param source the source of the event + * @exception IllegalArgumentException if source is null. + * @return most recent event time in the {@code EventQueue} + */ + private static long getMostRecentEventTimeForSource(Object source) { + if (source == null) { + // throw the IllegalArgumentException to conform to EventObject spec + throw new IllegalArgumentException("null source"); + } + AppContext appContext = SunToolkit.targetToAppContext(source); + EventQueue eventQueue = SunToolkit.getSystemEventQueueImplPP(appContext); + return AWTAccessor.getEventQueueAccessor().getMostRecentEventTime(eventQueue); + } } diff --git a/jdk/src/share/classes/com/sun/java/browser/net/ProxyService.java b/jdk/src/share/classes/java/awt/font/JavaAWTFontAccessImpl.java similarity index 53% rename from jdk/src/share/classes/com/sun/java/browser/net/ProxyService.java rename to jdk/src/share/classes/java/awt/font/JavaAWTFontAccessImpl.java index b4960905fda..a15b9311fb9 100644 --- a/jdk/src/share/classes/com/sun/java/browser/net/ProxyService.java +++ b/jdk/src/share/classes/java/awt/font/JavaAWTFontAccessImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 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 @@ -23,39 +23,35 @@ * questions. */ -package com.sun.java.browser.net; +package java.awt.font; -import java.net.URL; -import java.io.IOException; +import java.lang.reflect.Field; +import sun.misc.JavaAWTFontAccess; -/** - * - * @author Zhengyu Gu - */ -public class ProxyService extends Object { - private static ProxyServiceProvider provider = null; +class JavaAWTFontAccessImpl implements sun.misc.JavaAWTFontAccess { + // java.awt.font.TextAttribute constants + public Object getTextAttributeConstant(String name) { + switch (name) { + case "RUN_DIRECTION": + case "NUMERIC_SHAPING": + case "BIDI_EMBEDDING": + case "RUN_DIRECTION_LTR": + try { + Field f = TextAttribute.class.getField(name); + return f.get(null); + } catch (NoSuchFieldException | IllegalAccessException x) { + throw new AssertionError(x); + } + } - public static void setProvider(ProxyServiceProvider p) - throws IOException { - if(null == provider) - provider = p; - else - throw new IOException("Proxy service provider has already been set."); + throw new AssertionError("Constant name is not recognized"); } - - /** - *

    The function returns proxy information of the specified URL.

    - * @param url URL - * @return returns proxy information. If there is not proxy, returns null - * @since 1.4 - */ - public static ProxyInfo[] getProxyInfo(URL url) - throws IOException { - if(null == provider) - throw new IOException("Proxy service provider is not yet set"); - - return provider.getProxyInfo(url); + // java.awt.font.NumericShaper + public void shape(Object shaper, char[] text, int start, int count) { + assert shaper instanceof NumericShaper; + ((NumericShaper)shaper).shape(text, start,count); } + } diff --git a/jdk/src/share/classes/java/awt/font/NumericShaper.java b/jdk/src/share/classes/java/awt/font/NumericShaper.java index 7e1980e9fe2..c02d959e0bd 100644 --- a/jdk/src/share/classes/java/awt/font/NumericShaper.java +++ b/jdk/src/share/classes/java/awt/font/NumericShaper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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.Arrays; import java.util.Comparator; import java.util.EnumSet; import java.util.Set; +import sun.misc.SharedSecrets; /** * The NumericShaper class is used to convert Latin-1 (European) @@ -134,6 +135,14 @@ import java.util.Set; */ public final class NumericShaper implements java.io.Serializable { + + // For access from java.text.Bidi + static { + if (SharedSecrets.getJavaAWTFontAccess() == null) { + SharedSecrets.setJavaAWTFontAccess(new JavaAWTFontAccessImpl()); + } + } + /** * A {@code NumericShaper.Range} represents a Unicode range of a * script having its own decimal digits. For example, the {@link diff --git a/jdk/src/share/classes/java/awt/font/StyledParagraph.java b/jdk/src/share/classes/java/awt/font/StyledParagraph.java index 2087fa09455..380fa36e918 100644 --- a/jdk/src/share/classes/java/awt/font/StyledParagraph.java +++ b/jdk/src/share/classes/java/awt/font/StyledParagraph.java @@ -38,9 +38,9 @@ import java.text.AttributedCharacterIterator.Attribute; import java.util.Vector; import java.util.HashMap; import java.util.Map; +import sun.font.CodePointIterator; import sun.font.Decoration; import sun.font.FontResolver; -import sun.text.CodePointIterator; /** * This class stores Font, GraphicAttribute, and Decoration intervals diff --git a/jdk/src/share/classes/java/awt/font/TextAttribute.java b/jdk/src/share/classes/java/awt/font/TextAttribute.java index 264871bd031..3a7714ba1dd 100644 --- a/jdk/src/share/classes/java/awt/font/TextAttribute.java +++ b/jdk/src/share/classes/java/awt/font/TextAttribute.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 @@ -44,6 +44,7 @@ import java.io.InvalidObjectException; import java.text.AttributedCharacterIterator.Attribute; import java.util.Map; import java.util.HashMap; +import sun.misc.SharedSecrets; /** * The TextAttribute class defines attribute keys and @@ -257,6 +258,13 @@ public final class TextAttribute extends Attribute { private static final Map instanceMap = new HashMap(29); + // For access from java.text.Bidi + static { + if (SharedSecrets.getJavaAWTFontAccess() == null) { + SharedSecrets.setJavaAWTFontAccess(new JavaAWTFontAccessImpl()); + } + } + /** * Constructs a TextAttribute with the specified name. * @param name the attribute name to assign to this diff --git a/jdk/src/share/classes/java/awt/font/TextLayout.java b/jdk/src/share/classes/java/awt/font/TextLayout.java index 08d779427a1..45da5af89c6 100644 --- a/jdk/src/share/classes/java/awt/font/TextLayout.java +++ b/jdk/src/share/classes/java/awt/font/TextLayout.java @@ -60,13 +60,13 @@ import java.util.Map; import java.util.HashMap; import java.util.Hashtable; import sun.font.AttributeValues; +import sun.font.CodePointIterator; import sun.font.CoreMetrics; import sun.font.Decoration; import sun.font.FontLineMetrics; import sun.font.FontResolver; import sun.font.GraphicComponent; import sun.font.LayoutPathImpl; -import sun.text.CodePointIterator; /** * diff --git a/jdk/src/share/classes/java/awt/font/TextLine.java b/jdk/src/share/classes/java/awt/font/TextLine.java index 9efcdc32de2..c1c4e899997 100644 --- a/jdk/src/share/classes/java/awt/font/TextLine.java +++ b/jdk/src/share/classes/java/awt/font/TextLine.java @@ -50,6 +50,7 @@ import java.util.Hashtable; import java.util.Map; import sun.font.AttributeValues; import sun.font.BidiUtils; +import sun.font.CodePointIterator; import sun.font.CoreMetrics; import sun.font.Decoration; import sun.font.FontLineMetrics; @@ -60,7 +61,6 @@ import sun.font.LayoutPathImpl.EmptyPath; import sun.font.LayoutPathImpl.SegmentPathBuilder; import sun.font.TextLabelFactory; import sun.font.TextLineComponent; -import sun.text.CodePointIterator; import java.awt.geom.Line2D; diff --git a/jdk/src/share/classes/java/awt/geom/Path2D.java b/jdk/src/share/classes/java/awt/geom/Path2D.java index 7a401d36cf4..d75adf0cb57 100644 --- a/jdk/src/share/classes/java/awt/geom/Path2D.java +++ b/jdk/src/share/classes/java/awt/geom/Path2D.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 @@ -285,6 +285,8 @@ public abstract class Path2D implements Shape, Cloneable { int grow = size; if (grow > EXPAND_MAX) { grow = EXPAND_MAX; + } else if (grow == 0) { + grow = 1; } pointTypes = Arrays.copyOf(pointTypes, size+grow); } @@ -1121,6 +1123,8 @@ public abstract class Path2D implements Shape, Cloneable { int grow = size; if (grow > EXPAND_MAX) { grow = EXPAND_MAX; + } else if (grow == 0) { + grow = 1; } pointTypes = Arrays.copyOf(pointTypes, size+grow); } diff --git a/jdk/src/share/classes/java/awt/image/renderable/ParameterBlock.java b/jdk/src/share/classes/java/awt/image/renderable/ParameterBlock.java index bf14e8ce2d3..e6b923dda0e 100644 --- a/jdk/src/share/classes/java/awt/image/renderable/ParameterBlock.java +++ b/jdk/src/share/classes/java/awt/image/renderable/ParameterBlock.java @@ -337,7 +337,7 @@ public class ParameterBlock implements Cloneable, Serializable { * the specified parameter. */ public ParameterBlock add(byte b) { - return add(new Byte(b)); + return add(Byte.valueOf(b)); } /** @@ -348,7 +348,7 @@ public class ParameterBlock implements Cloneable, Serializable { * the specified parameter. */ public ParameterBlock add(char c) { - return add(new Character(c)); + return add(Character.valueOf(c)); } /** @@ -359,7 +359,7 @@ public class ParameterBlock implements Cloneable, Serializable { * the specified parameter. */ public ParameterBlock add(short s) { - return add(new Short(s)); + return add(Short.valueOf(s)); } /** @@ -381,7 +381,7 @@ public class ParameterBlock implements Cloneable, Serializable { * the specified parameter. */ public ParameterBlock add(long l) { - return add(new Long(l)); + return add(Long.valueOf(l)); } /** @@ -441,7 +441,7 @@ public class ParameterBlock implements Cloneable, Serializable { * the specified parameter. */ public ParameterBlock set(byte b, int index) { - return set(new Byte(b), index); + return set(Byte.valueOf(b), index); } /** @@ -457,7 +457,7 @@ public class ParameterBlock implements Cloneable, Serializable { * the specified parameter. */ public ParameterBlock set(char c, int index) { - return set(new Character(c), index); + return set(Character.valueOf(c), index); } /** @@ -473,7 +473,7 @@ public class ParameterBlock implements Cloneable, Serializable { * the specified parameter. */ public ParameterBlock set(short s, int index) { - return set(new Short(s), index); + return set(Short.valueOf(s), index); } /** @@ -505,7 +505,7 @@ public class ParameterBlock implements Cloneable, Serializable { * the specified parameter. */ public ParameterBlock set(long l, int index) { - return set(new Long(l), index); + return set(Long.valueOf(l), index); } /** diff --git a/jdk/src/share/classes/java/beans/BeanDescriptor.java b/jdk/src/share/classes/java/beans/BeanDescriptor.java index fee54153bd3..10912ed7f4d 100644 --- a/jdk/src/share/classes/java/beans/BeanDescriptor.java +++ b/jdk/src/share/classes/java/beans/BeanDescriptor.java @@ -33,6 +33,8 @@ import java.lang.ref.Reference; *

    * This is one of the kinds of descriptor returned by a BeanInfo object, * which also returns descriptors for properties, method, and events. + * + * @since 1.1 */ public class BeanDescriptor extends FeatureDescriptor { diff --git a/jdk/src/share/classes/java/beans/BeanInfo.java b/jdk/src/share/classes/java/beans/BeanInfo.java index bb43f2fd4e8..92be1eb81a4 100644 --- a/jdk/src/share/classes/java/beans/BeanInfo.java +++ b/jdk/src/share/classes/java/beans/BeanInfo.java @@ -48,6 +48,8 @@ import java.awt.Image; * the {@code SimpleBeanInfo} class to define specific information. *

    * See also the {@link Introspector} class to learn more about bean behavior. + * + * @since 1.1 */ public interface BeanInfo { diff --git a/jdk/src/share/classes/java/beans/Beans.java b/jdk/src/share/classes/java/beans/Beans.java index 5bf13fa7d09..cd864899ea6 100644 --- a/jdk/src/share/classes/java/beans/Beans.java +++ b/jdk/src/share/classes/java/beans/Beans.java @@ -56,6 +56,8 @@ import java.util.Vector; /** * This class provides some general purpose beans control methods. + * + * @since 1.1 */ public class Beans { @@ -96,6 +98,7 @@ public class Beans { * @exception ClassNotFoundException if the class of a serialized * object could not be found. * @exception IOException if an I/O error occurs. + * @since 1.2 */ public static Object instantiate(ClassLoader cls, String beanName, BeanContext beanContext) throws IOException, ClassNotFoundException { @@ -152,6 +155,7 @@ public class Beans { * @exception ClassNotFoundException if the class of a serialized * object could not be found. * @exception IOException if an I/O error occurs. + * @since 1.2 */ public static Object instantiate(ClassLoader cls, String beanName, BeanContext beanContext, AppletInitializer initializer) diff --git a/jdk/src/share/classes/java/beans/Customizer.java b/jdk/src/share/classes/java/beans/Customizer.java index 07d70631e78..5dcd03b0b5a 100644 --- a/jdk/src/share/classes/java/beans/Customizer.java +++ b/jdk/src/share/classes/java/beans/Customizer.java @@ -33,6 +33,8 @@ package java.beans; * it can be instantiated inside an AWT dialog or panel. *

    * Each customizer should have a null constructor. + * + * @since 1.1 */ public interface Customizer { diff --git a/jdk/src/share/classes/java/beans/EventHandler.java b/jdk/src/share/classes/java/beans/EventHandler.java index 470991e11bd..dd41750f2f1 100644 --- a/jdk/src/share/classes/java/beans/EventHandler.java +++ b/jdk/src/share/classes/java/beans/EventHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -446,7 +446,7 @@ public class EventHandler implements InvocationHandler { } if (listenerMethodName == null || listenerMethodName.equals(methodName)) { - Class[] argTypes = null; + Class[] argTypes = null; Object[] newArgs = null; if (eventPropertyName == null) { // Nullary method. diff --git a/jdk/src/share/classes/java/beans/EventSetDescriptor.java b/jdk/src/share/classes/java/beans/EventSetDescriptor.java index 78bc44d2978..d05d2f79375 100644 --- a/jdk/src/share/classes/java/beans/EventSetDescriptor.java +++ b/jdk/src/share/classes/java/beans/EventSetDescriptor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2012, 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 @@ -36,6 +36,8 @@ import java.lang.reflect.Modifier; * The given group of events are all delivered as method calls on a single * event listener interface, and an event listener object can be registered * via a call on a registration method supplied by the event source. + * + * @since 1.1 */ public class EventSetDescriptor extends FeatureDescriptor { @@ -81,7 +83,7 @@ public class EventSetDescriptor extends FeatureDescriptor { String eventName = NameGenerator.capitalize(eventSetName) + "Event"; Method[] listenerMethods = getListenerMethods(); if (listenerMethods.length > 0) { - Class[] args = getParameterTypes(getClass0(), listenerMethods[0]); + Class[] args = getParameterTypes(getClass0(), listenerMethods[0]); // Check for EventSet compliance. Special case for vetoableChange. See 4529996 if (!"vetoableChange".equals(eventSetName) && !args[0].getName().endsWith(eventName)) { throw new IntrospectionException("Method \"" + listenerMethodName + diff --git a/jdk/src/share/classes/java/beans/FeatureDescriptor.java b/jdk/src/share/classes/java/beans/FeatureDescriptor.java index 75f06f33fc2..6a82de9f971 100644 --- a/jdk/src/share/classes/java/beans/FeatureDescriptor.java +++ b/jdk/src/share/classes/java/beans/FeatureDescriptor.java @@ -46,6 +46,8 @@ import java.util.Map.Entry; *

    * In addition it provides an extension mechanism so that arbitrary * attribute/value pairs can be associated with a design feature. + * + * @since 1.1 */ public class FeatureDescriptor { @@ -145,6 +147,7 @@ public class FeatureDescriptor { * important for presenting to humans. * * @return True if this feature should be preferentially shown to human users. + * @since 1.2 */ public boolean isPreferred() { return preferred; @@ -156,6 +159,7 @@ public class FeatureDescriptor { * * @param preferred True if this feature should be preferentially shown * to human users. + * @since 1.2 */ public void setPreferred(boolean preferred) { this.preferred = preferred; diff --git a/jdk/src/share/classes/java/beans/IndexedPropertyDescriptor.java b/jdk/src/share/classes/java/beans/IndexedPropertyDescriptor.java index 1f329a31c55..9449421eae2 100644 --- a/jdk/src/share/classes/java/beans/IndexedPropertyDescriptor.java +++ b/jdk/src/share/classes/java/beans/IndexedPropertyDescriptor.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 @@ -36,6 +36,8 @@ import java.lang.reflect.Method; * An indexed property may also provide simple non-indexed read and write * methods. If these are present, they read and write arrays of the type * returned by the indexed read method. + * + * @since 1.1 */ public class IndexedPropertyDescriptor extends PropertyDescriptor { @@ -209,6 +211,8 @@ public class IndexedPropertyDescriptor extends PropertyDescriptor { * @param readMethod The new indexed read method. * @throws IntrospectionException if an exception occurs during * introspection. + * + * @since 1.2 */ public synchronized void setIndexedReadMethod(Method readMethod) throws IntrospectionException { @@ -288,6 +292,8 @@ public class IndexedPropertyDescriptor extends PropertyDescriptor { * @param writeMethod The new indexed write method. * @throws IntrospectionException if an exception occurs during * introspection. + * + * @since 1.2 */ public synchronized void setIndexedWriteMethod(Method writeMethod) throws IntrospectionException { @@ -353,7 +359,7 @@ public class IndexedPropertyDescriptor extends PropertyDescriptor { Class indexedPropertyType = null; if (indexedReadMethod != null) { - Class params[] = getParameterTypes(getClass0(), indexedReadMethod); + Class[] params = getParameterTypes(getClass0(), indexedReadMethod); if (params.length != 1) { throw new IntrospectionException("bad indexed read method arg count"); } @@ -366,7 +372,7 @@ public class IndexedPropertyDescriptor extends PropertyDescriptor { } } if (indexedWriteMethod != null) { - Class params[] = getParameterTypes(getClass0(), indexedWriteMethod); + Class[] params = getParameterTypes(getClass0(), indexedWriteMethod); if (params.length != 2) { throw new IntrospectionException("bad indexed write method arg count"); } diff --git a/jdk/src/share/classes/java/beans/IntrospectionException.java b/jdk/src/share/classes/java/beans/IntrospectionException.java index c9cf2eeb44b..432ba99e93b 100644 --- a/jdk/src/share/classes/java/beans/IntrospectionException.java +++ b/jdk/src/share/classes/java/beans/IntrospectionException.java @@ -32,6 +32,8 @@ package java.beans; * to a Class object, not being able to resolve a string method name, * or specifying a method name that has the wrong type signature for * its intended use. + * + * @since 1.1 */ public diff --git a/jdk/src/share/classes/java/beans/Introspector.java b/jdk/src/share/classes/java/beans/Introspector.java index 10efa7ae5a8..85baed810bf 100644 --- a/jdk/src/share/classes/java/beans/Introspector.java +++ b/jdk/src/share/classes/java/beans/Introspector.java @@ -90,6 +90,8 @@ import sun.reflect.misc.ReflectUtil; * For more information about introspection and design patterns, please * consult the * JavaBeans™ specification. + * + * @since 1.1 */ public class Introspector { @@ -97,14 +99,17 @@ public class Introspector { // Flags that can be used to control getBeanInfo: /** * Flag to indicate to use of all beaninfo. + * @since 1.2 */ public final static int USE_ALL_BEANINFO = 1; /** * Flag to indicate to ignore immediate beaninfo. + * @since 1.2 */ public final static int IGNORE_IMMEDIATE_BEANINFO = 2; /** * Flag to indicate to ignore all beaninfo. + * @since 1.2 */ public final static int IGNORE_ALL_BEANINFO = 3; @@ -214,6 +219,7 @@ public class Introspector { * @return A BeanInfo object describing the target bean. * @exception IntrospectionException if an exception occurs during * introspection. + * @since 1.2 */ public static BeanInfo getBeanInfo(Class beanClass, int flags) throws IntrospectionException { @@ -354,6 +360,8 @@ public class Introspector { * not normally required. It is normally only needed by advanced * tools that update existing "Class" objects in-place and need * to make the Introspector re-analyze existing Class objects. + * + * @since 1.2 */ public static void flushCaches() { @@ -377,6 +385,7 @@ public class Introspector { * * @param clz Class object to be flushed. * @throws NullPointerException If the Class object is null. + * @since 1.2 */ public static void flushFromCaches(Class clz) { if (clz == null) { @@ -1282,7 +1291,7 @@ public class Introspector { * Creates a key for a method in a method cache. */ private static String makeQualifiedMethodName(String name, String[] params) { - StringBuffer sb = new StringBuffer(name); + StringBuilder sb = new StringBuilder(name); sb.append('='); for (int i = 0; i < params.length; i++) { sb.append(':'); @@ -1384,7 +1393,7 @@ public class Introspector { * parameter list on a given class. */ private static Method internalFindMethod(Class start, String methodName, - int argCount, Class args[]) { + int argCount, Class args[]) { // For overriden methods we need to find the most derived version. // So we start with the given class and walk up the superclass chain. @@ -1426,7 +1435,7 @@ public class Introspector { // Now check any inherited interfaces. This is necessary both when // the argument class is itself an interface, and when the argument // class is an abstract class. - Class ifcs[] = start.getInterfaces(); + Class[] ifcs = start.getInterfaces(); for (int i = 0 ; i < ifcs.length; i++) { // Note: The original implementation had both methods calling // the 3 arg method. This is preserved but perhaps it should @@ -1459,7 +1468,7 @@ public class Introspector { * @return the method or null if not found */ static Method findMethod(Class cls, String methodName, int argCount, - Class args[]) { + Class[] args) { if (methodName == null) { return null; } @@ -1502,7 +1511,7 @@ public class Introspector { * Return true iff the given method throws the given exception. */ private boolean throwsException(Method method, Class exception) { - Class exs[] = method.getExceptionTypes(); + Class[] exs = method.getExceptionTypes(); for (int i = 0; i < exs.length; i++) { if (exs[i] == exception) { return true; diff --git a/jdk/src/share/classes/java/beans/MetaData.java b/jdk/src/share/classes/java/beans/MetaData.java index 3ae1e0375f9..d0e7108179d 100644 --- a/jdk/src/share/classes/java/beans/MetaData.java +++ b/jdk/src/share/classes/java/beans/MetaData.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -1401,7 +1401,7 @@ static final class sun_swing_PrintColorUIResource_PersistenceDelegate extends Pe } private static boolean isValid(Constructor constructor, String[] names) { - Class[] parameters = constructor.getParameterTypes(); + Class[] parameters = constructor.getParameterTypes(); if (names.length != parameters.length) { return false; } diff --git a/jdk/src/share/classes/java/beans/MethodDescriptor.java b/jdk/src/share/classes/java/beans/MethodDescriptor.java index 1e169046746..ca295be74dc 100644 --- a/jdk/src/share/classes/java/beans/MethodDescriptor.java +++ b/jdk/src/share/classes/java/beans/MethodDescriptor.java @@ -34,6 +34,8 @@ import java.util.ArrayList; /** * A MethodDescriptor describes a particular method that a Java Bean * supports for external access from other components. + * + * @since 1.1 */ public class MethodDescriptor extends FeatureDescriptor { diff --git a/jdk/src/share/classes/java/beans/ParameterDescriptor.java b/jdk/src/share/classes/java/beans/ParameterDescriptor.java index 3b7013f4ad0..243df016ea0 100644 --- a/jdk/src/share/classes/java/beans/ParameterDescriptor.java +++ b/jdk/src/share/classes/java/beans/ParameterDescriptor.java @@ -32,6 +32,8 @@ package java.beans; * class. *

    * Currently all our state comes from the FeatureDescriptor base class. + * + * @since 1.1 */ public class ParameterDescriptor extends FeatureDescriptor { diff --git a/jdk/src/share/classes/java/beans/PropertyChangeEvent.java b/jdk/src/share/classes/java/beans/PropertyChangeEvent.java index eeaa6512730..ec7d8ed51c0 100644 --- a/jdk/src/share/classes/java/beans/PropertyChangeEvent.java +++ b/jdk/src/share/classes/java/beans/PropertyChangeEvent.java @@ -43,6 +43,8 @@ import java.util.EventObject; * An event source may send a null object as the name to indicate that an * arbitrary set of if its properties have changed. In this case the * old and new values should also be null. + * + * @since 1.1 */ public class PropertyChangeEvent extends EventObject { private static final long serialVersionUID = 7042693688939648123L; diff --git a/jdk/src/share/classes/java/beans/PropertyChangeListener.java b/jdk/src/share/classes/java/beans/PropertyChangeListener.java index 5b78d482439..70d50a85caf 100644 --- a/jdk/src/share/classes/java/beans/PropertyChangeListener.java +++ b/jdk/src/share/classes/java/beans/PropertyChangeListener.java @@ -29,6 +29,7 @@ package java.beans; * A "PropertyChange" event gets fired whenever a bean changes a "bound" * property. You can register a PropertyChangeListener with a source * bean so as to be notified of any bound property updates. + * @since 1.1 */ public interface PropertyChangeListener extends java.util.EventListener { diff --git a/jdk/src/share/classes/java/beans/PropertyChangeSupport.java b/jdk/src/share/classes/java/beans/PropertyChangeSupport.java index d55ae76efc8..40e58ae1e5d 100644 --- a/jdk/src/share/classes/java/beans/PropertyChangeSupport.java +++ b/jdk/src/share/classes/java/beans/PropertyChangeSupport.java @@ -77,6 +77,7 @@ import java.util.Map.Entry; * non-serializable listeners will be skipped during serialization. * * @see VetoableChangeSupport + * @since 1.1 */ public class PropertyChangeSupport implements Serializable { private PropertyChangeListenerMap map = new PropertyChangeListenerMap(); @@ -191,6 +192,7 @@ public class PropertyChangeSupport implements Serializable { * * @param propertyName The name of the property to listen on. * @param listener The PropertyChangeListener to be added + * @since 1.2 */ public void addPropertyChangeListener( String propertyName, @@ -216,6 +218,7 @@ public class PropertyChangeSupport implements Serializable { * * @param propertyName The name of the property that was listened on. * @param listener The PropertyChangeListener to be removed + * @since 1.2 */ public void removePropertyChangeListener( String propertyName, @@ -277,6 +280,7 @@ public class PropertyChangeSupport implements Serializable { * @param propertyName the programmatic name of the property that was changed * @param oldValue the old value of the property * @param newValue the new value of the property + * @since 1.2 */ public void firePropertyChange(String propertyName, int oldValue, int newValue) { if (oldValue != newValue) { @@ -297,6 +301,7 @@ public class PropertyChangeSupport implements Serializable { * @param propertyName the programmatic name of the property that was changed * @param oldValue the old value of the property * @param newValue the new value of the property + * @since 1.2 */ public void firePropertyChange(String propertyName, boolean oldValue, boolean newValue) { if (oldValue != newValue) { @@ -312,6 +317,7 @@ public class PropertyChangeSupport implements Serializable { * No event is fired if the given event's old and new values are equal and non-null. * * @param event the {@code PropertyChangeEvent} to be fired + * @since 1.2 */ public void firePropertyChange(PropertyChangeEvent event) { Object oldValue = event.getOldValue(); @@ -410,6 +416,7 @@ public class PropertyChangeSupport implements Serializable { * * @param propertyName the property name. * @return true if there are one or more listeners for the given property + * @since 1.2 */ public boolean hasListeners(String propertyName) { return this.map.hasListeners(propertyName); diff --git a/jdk/src/share/classes/java/beans/PropertyDescriptor.java b/jdk/src/share/classes/java/beans/PropertyDescriptor.java index 07149f9752d..9f26590418f 100644 --- a/jdk/src/share/classes/java/beans/PropertyDescriptor.java +++ b/jdk/src/share/classes/java/beans/PropertyDescriptor.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.lang.reflect.Constructor; /** * A PropertyDescriptor describes one property that a Java Bean * exports via a pair of accessor methods. + * @since 1.1 */ public class PropertyDescriptor extends FeatureDescriptor { @@ -112,7 +113,7 @@ public class PropertyDescriptor extends FeatureDescriptor { // If this class or one of its base classes allow PropertyChangeListener, // then we assume that any properties we discover are "bound". // See Introspector.getTargetPropertyInfo() method. - Class[] args = { PropertyChangeListener.class }; + Class[] args = { PropertyChangeListener.class }; this.bound = null != Introspector.findMethod(beanClass, "addPropertyChangeListener", args.length, args); } @@ -244,6 +245,7 @@ public class PropertyDescriptor extends FeatureDescriptor { * * @param readMethod The new read method. * @throws IntrospectionException if the read method is invalid + * @since 1.2 */ public synchronized void setReadMethod(Method readMethod) throws IntrospectionException { @@ -314,6 +316,7 @@ public class PropertyDescriptor extends FeatureDescriptor { * * @param writeMethod The new write method. * @throws IntrospectionException if the write method is invalid + * @since 1.2 */ public synchronized void setWriteMethod(Method writeMethod) throws IntrospectionException { diff --git a/jdk/src/share/classes/java/beans/PropertyEditor.java b/jdk/src/share/classes/java/beans/PropertyEditor.java index 041cb805d9e..69ad2c04074 100644 --- a/jdk/src/share/classes/java/beans/PropertyEditor.java +++ b/jdk/src/share/classes/java/beans/PropertyEditor.java @@ -51,6 +51,8 @@ package java.beans; * or support setAsText. *

    * Each PropertyEditor should have a null constructor. + * + * @since 1.1 */ public interface PropertyEditor { diff --git a/jdk/src/share/classes/java/beans/PropertyEditorManager.java b/jdk/src/share/classes/java/beans/PropertyEditorManager.java index 46ec87de944..ae664b8c4cc 100644 --- a/jdk/src/share/classes/java/beans/PropertyEditorManager.java +++ b/jdk/src/share/classes/java/beans/PropertyEditorManager.java @@ -48,6 +48,8 @@ package java.beans; * Default PropertyEditors will be provided for the Java primitive types * "boolean", "byte", "short", "int", "long", "float", and "double"; and * for the classes java.lang.String. java.awt.Color, and java.awt.Font. + * + * @since 1.1 */ public class PropertyEditorManager { diff --git a/jdk/src/share/classes/java/beans/PropertyEditorSupport.java b/jdk/src/share/classes/java/beans/PropertyEditorSupport.java index 1569c652e97..cfc350fbb20 100644 --- a/jdk/src/share/classes/java/beans/PropertyEditorSupport.java +++ b/jdk/src/share/classes/java/beans/PropertyEditorSupport.java @@ -31,6 +31,8 @@ import java.beans.*; * This is a support class to help build property editors. *

    * It can be used either as a base class or as a delegate. + * + * @since 1.1 */ public class PropertyEditorSupport implements PropertyEditor { diff --git a/jdk/src/share/classes/java/beans/PropertyVetoException.java b/jdk/src/share/classes/java/beans/PropertyVetoException.java index 27a2f82f341..86220b18785 100644 --- a/jdk/src/share/classes/java/beans/PropertyVetoException.java +++ b/jdk/src/share/classes/java/beans/PropertyVetoException.java @@ -29,6 +29,7 @@ package java.beans; /** * A PropertyVetoException is thrown when a proposed change to a * property represents an unacceptable value. + * @since 1.1 */ public diff --git a/jdk/src/share/classes/java/beans/SimpleBeanInfo.java b/jdk/src/share/classes/java/beans/SimpleBeanInfo.java index 29fd9cc4b5a..7b97e414ebb 100644 --- a/jdk/src/share/classes/java/beans/SimpleBeanInfo.java +++ b/jdk/src/share/classes/java/beans/SimpleBeanInfo.java @@ -34,6 +34,8 @@ package java.beans; * When the introspector sees the "noop" values, it will apply low * level introspection and design patterns to automatically analyze * the target bean. + * + * @since 1.1 */ public class SimpleBeanInfo implements BeanInfo { diff --git a/jdk/src/share/classes/java/beans/Statement.java b/jdk/src/share/classes/java/beans/Statement.java index 8eb88242a72..fc11a42be12 100644 --- a/jdk/src/share/classes/java/beans/Statement.java +++ b/jdk/src/share/classes/java/beans/Statement.java @@ -248,7 +248,7 @@ public class Statement { // ignored elsewhere. if (target == Character.class && arguments.length == 1 && argClasses[0] == String.class) { - return new Character(((String)arguments[0]).charAt(0)); + return ((String)arguments[0]).charAt(0); } try { m = ConstructorFinder.findConstructor((Class)target, argClasses); @@ -340,7 +340,7 @@ public class Statement { if (arguments == null) { arguments = emptyArray; } - StringBuffer result = new StringBuffer(instanceName(target) + "." + methodName + "("); + StringBuilder result = new StringBuilder(instanceName(target) + "." + methodName + "("); int n = arguments.length; for(int i = 0; i < n; i++) { result.append(instanceName(arguments[i])); diff --git a/jdk/src/share/classes/java/beans/VetoableChangeListener.java b/jdk/src/share/classes/java/beans/VetoableChangeListener.java index 898fd82fb4b..9edc175375d 100644 --- a/jdk/src/share/classes/java/beans/VetoableChangeListener.java +++ b/jdk/src/share/classes/java/beans/VetoableChangeListener.java @@ -29,6 +29,7 @@ package java.beans; * A VetoableChange event gets fired whenever a bean changes a "constrained" * property. You can register a VetoableChangeListener with a source bean * so as to be notified of any constrained property updates. + * @since 1.1 */ public interface VetoableChangeListener extends java.util.EventListener { /** diff --git a/jdk/src/share/classes/java/beans/VetoableChangeSupport.java b/jdk/src/share/classes/java/beans/VetoableChangeSupport.java index 293ae5af2c6..14902cc6276 100644 --- a/jdk/src/share/classes/java/beans/VetoableChangeSupport.java +++ b/jdk/src/share/classes/java/beans/VetoableChangeSupport.java @@ -77,6 +77,7 @@ import java.util.Map.Entry; * non-serializable listeners will be skipped during serialization. * * @see PropertyChangeSupport + * @since 1.1 */ public class VetoableChangeSupport implements Serializable { private VetoableChangeListenerMap map = new VetoableChangeListenerMap(); @@ -191,6 +192,7 @@ public class VetoableChangeSupport implements Serializable { * * @param propertyName The name of the property to listen on. * @param listener The VetoableChangeListener to be added + * @since 1.2 */ public void addVetoableChangeListener( String propertyName, @@ -216,6 +218,7 @@ public class VetoableChangeSupport implements Serializable { * * @param propertyName The name of the property that was listened on. * @param listener The VetoableChangeListener to be removed + * @since 1.2 */ public void removeVetoableChangeListener( String propertyName, @@ -292,6 +295,7 @@ public class VetoableChangeSupport implements Serializable { * @param oldValue the old value of the property * @param newValue the new value of the property * @throws PropertyVetoException if one of listeners vetoes the property update + * @since 1.2 */ public void fireVetoableChange(String propertyName, int oldValue, int newValue) throws PropertyVetoException { @@ -320,6 +324,7 @@ public class VetoableChangeSupport implements Serializable { * @param oldValue the old value of the property * @param newValue the new value of the property * @throws PropertyVetoException if one of listeners vetoes the property update + * @since 1.2 */ public void fireVetoableChange(String propertyName, boolean oldValue, boolean newValue) throws PropertyVetoException { @@ -343,6 +348,7 @@ public class VetoableChangeSupport implements Serializable { * * @param event the {@code PropertyChangeEvent} to be fired * @throws PropertyVetoException if one of listeners vetoes the property update + * @since 1.2 */ public void fireVetoableChange(PropertyChangeEvent event) throws PropertyVetoException { @@ -399,6 +405,7 @@ public class VetoableChangeSupport implements Serializable { * * @param propertyName the property name. * @return true if there are one or more listeners for the given property + * @since 1.2 */ public boolean hasListeners(String propertyName) { return this.map.hasListeners(propertyName); diff --git a/jdk/src/share/classes/java/beans/Visibility.java b/jdk/src/share/classes/java/beans/Visibility.java index af413833879..5aab3f3afe7 100644 --- a/jdk/src/share/classes/java/beans/Visibility.java +++ b/jdk/src/share/classes/java/beans/Visibility.java @@ -34,6 +34,8 @@ package java.beans; * This interface is for expert developers, and is not needed * for normal simple beans. To avoid confusing end-users we * avoid using getXXX setXXX design patterns for these methods. + * + * @since 1.1 */ public interface Visibility { diff --git a/jdk/src/share/classes/java/beans/beancontext/BeanContextServiceAvailableEvent.java b/jdk/src/share/classes/java/beans/beancontext/BeanContextServiceAvailableEvent.java index c1034ef73cc..24eb66aa96f 100644 --- a/jdk/src/share/classes/java/beans/beancontext/BeanContextServiceAvailableEvent.java +++ b/jdk/src/share/classes/java/beans/beancontext/BeanContextServiceAvailableEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2009, 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 @@ -47,7 +47,7 @@ public class BeanContextServiceAvailableEvent extends BeanContextEvent { * @param bcs The context in which the service has become available * @param sc A Class reference to the newly available service */ - public BeanContextServiceAvailableEvent(BeanContextServices bcs, Class sc) { + public BeanContextServiceAvailableEvent(BeanContextServices bcs, Class sc) { super((BeanContext)bcs); serviceClass = sc; @@ -65,13 +65,13 @@ public class BeanContextServiceAvailableEvent extends BeanContextEvent { * Gets the service class that is the subject of this notification. * @return A Class reference to the newly available service */ - public Class getServiceClass() { return serviceClass; } + public Class getServiceClass() { return serviceClass; } /** * Gets the list of service dependent selectors. * @return the current selectors available from the service */ - public Iterator getCurrentServiceSelectors() { + public Iterator getCurrentServiceSelectors() { return ((BeanContextServices)getSource()).getCurrentServiceSelectors(serviceClass); } @@ -82,5 +82,5 @@ public class BeanContextServiceAvailableEvent extends BeanContextEvent { /** * A Class reference to the newly available service */ - protected Class serviceClass; + protected Class serviceClass; } diff --git a/jdk/src/share/classes/java/beans/beancontext/BeanContextServiceProvider.java b/jdk/src/share/classes/java/beans/beancontext/BeanContextServiceProvider.java index 5e724ca325f..104051e3952 100644 --- a/jdk/src/share/classes/java/beans/beancontext/BeanContextServiceProvider.java +++ b/jdk/src/share/classes/java/beans/beancontext/BeanContextServiceProvider.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 @@ -70,7 +70,7 @@ public interface BeanContextServiceProvider { * * @return a reference to the requested service */ - Object getService(BeanContextServices bcs, Object requestor, Class serviceClass, Object serviceSelector); + Object getService(BeanContextServices bcs, Object requestor, Class serviceClass, Object serviceSelector); /** * Invoked by BeanContextServices, @@ -100,5 +100,5 @@ public interface BeanContextServiceProvider { * @param serviceClass the specified service * @return the current service selectors for the specified serviceClass */ - Iterator getCurrentServiceSelectors(BeanContextServices bcs, Class serviceClass); + Iterator getCurrentServiceSelectors(BeanContextServices bcs, Class serviceClass); } diff --git a/jdk/src/share/classes/java/beans/beancontext/BeanContextServiceRevokedEvent.java b/jdk/src/share/classes/java/beans/beancontext/BeanContextServiceRevokedEvent.java index 30d99862903..b886e30a86f 100644 --- a/jdk/src/share/classes/java/beans/beancontext/BeanContextServiceRevokedEvent.java +++ b/jdk/src/share/classes/java/beans/beancontext/BeanContextServiceRevokedEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2009, 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 @@ -46,7 +46,7 @@ public class BeanContextServiceRevokedEvent extends BeanContextEvent { * @param sc the service that is being revoked * @param invalidate true for immediate revocation */ - public BeanContextServiceRevokedEvent(BeanContextServices bcs, Class sc, boolean invalidate) { + public BeanContextServiceRevokedEvent(BeanContextServices bcs, Class sc, boolean invalidate) { super((BeanContext)bcs); serviceClass = sc; @@ -67,7 +67,7 @@ public class BeanContextServiceRevokedEvent extends BeanContextEvent { * @return A Class reference to the * service that is being revoked */ - public Class getServiceClass() { return serviceClass; } + public Class getServiceClass() { return serviceClass; } /** * Checks this event to determine whether or not @@ -76,7 +76,7 @@ public class BeanContextServiceRevokedEvent extends BeanContextEvent { * @return true if the service being revoked is of the * same class as the specified service */ - public boolean isServiceClass(Class service) { + public boolean isServiceClass(Class service) { return serviceClass.equals(service); } @@ -94,6 +94,6 @@ public class BeanContextServiceRevokedEvent extends BeanContextEvent { /** * A Class reference to the service that is being revoked. */ - protected Class serviceClass; + protected Class serviceClass; private boolean invalidateRefs; } diff --git a/jdk/src/share/classes/java/beans/beancontext/BeanContextServices.java b/jdk/src/share/classes/java/beans/beancontext/BeanContextServices.java index 0348817bfe8..62652ec5443 100644 --- a/jdk/src/share/classes/java/beans/beancontext/BeanContextServices.java +++ b/jdk/src/share/classes/java/beans/beancontext/BeanContextServices.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 @@ -62,7 +62,7 @@ public interface BeanContextServices extends BeanContext, BeanContextServicesLis * associated with the service * @return true if the service was successful added, false otherwise */ - boolean addService(Class serviceClass, BeanContextServiceProvider serviceProvider); + boolean addService(Class serviceClass, BeanContextServiceProvider serviceProvider); /** * BeanContextServiceProviders wishing to remove @@ -83,7 +83,7 @@ public interface BeanContextServices extends BeanContext, BeanContextServicesLis * terminate service to all currently outstanding references * to the specified service. */ - void revokeService(Class serviceClass, BeanContextServiceProvider serviceProvider, boolean revokeCurrentServicesNow); + void revokeService(Class serviceClass, BeanContextServiceProvider serviceProvider, boolean revokeCurrentServicesNow); /** * Reports whether or not a given service is @@ -91,7 +91,7 @@ public interface BeanContextServices extends BeanContext, BeanContextServicesLis * @param serviceClass the service in question * @return true if the service is available */ - boolean hasService(Class serviceClass); + boolean hasService(Class serviceClass); /** * A BeanContextChild, or any arbitrary object @@ -113,7 +113,7 @@ public interface BeanContextServices extends BeanContext, BeanContextServicesLis * @return a reference to this context's named * Service as requested or null */ - Object getService(BeanContextChild child, Object requestor, Class serviceClass, Object serviceSelector, BeanContextServiceRevokedListener bcsrl) throws TooManyListenersException; + Object getService(BeanContextChild child, Object requestor, Class serviceClass, Object serviceSelector, BeanContextServiceRevokedListener bcsrl) throws TooManyListenersException; /** * Releases a BeanContextChild's @@ -131,7 +131,7 @@ public interface BeanContextServices extends BeanContext, BeanContextServicesLis * @return an Iterator consisting of the * currently available services */ - Iterator getCurrentServiceClasses(); + Iterator getCurrentServiceClasses(); /** * Gets the list of service dependent service parameters @@ -142,7 +142,7 @@ public interface BeanContextServices extends BeanContext, BeanContextServicesLis * @return the currently available service selectors * for the named serviceClass */ - Iterator getCurrentServiceSelectors(Class serviceClass); + Iterator getCurrentServiceSelectors(Class serviceClass); /** * Adds a BeanContextServicesListener to this BeanContext diff --git a/jdk/src/share/classes/java/beans/beancontext/BeanContextServicesSupport.java b/jdk/src/share/classes/java/beans/beancontext/BeanContextServicesSupport.java index 41cfa9d7a89..507e8ec0215 100644 --- a/jdk/src/share/classes/java/beans/beancontext/BeanContextServicesSupport.java +++ b/jdk/src/share/classes/java/beans/beancontext/BeanContextServicesSupport.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 @@ -129,9 +129,8 @@ public class BeanContextServicesSupport extends BeanContextSupport public void initialize() { super.initialize(); - - services = new HashMap(serializable + 1); - bcsListeners = new ArrayList(1); + services = new HashMap<>(serializable + 1); + bcsListeners = new ArrayList<>(1); } /** @@ -169,7 +168,7 @@ public class BeanContextServicesSupport extends BeanContextSupport // create an instance of a service ref - BCSSCServiceClassRef(Class sc, BeanContextServiceProvider bcsp, boolean delegated) { + BCSSCServiceClassRef(Class sc, BeanContextServiceProvider bcsp, boolean delegated) { super(); serviceClass = sc; @@ -183,7 +182,7 @@ public class BeanContextServicesSupport extends BeanContextSupport // add a requestor and assoc listener void addRequestor(Object requestor, BeanContextServiceRevokedListener bcsrl) throws TooManyListenersException { - BeanContextServiceRevokedListener cbcsrl = (BeanContextServiceRevokedListener)requestors.get(requestor); + BeanContextServiceRevokedListener cbcsrl = requestors.get(requestor); if (cbcsrl != null && !cbcsrl.equals(bcsrl)) throw new TooManyListenersException(); @@ -200,7 +199,7 @@ public class BeanContextServicesSupport extends BeanContextSupport // check a requestors listener void verifyRequestor(Object requestor, BeanContextServiceRevokedListener bcsrl) throws TooManyListenersException { - BeanContextServiceRevokedListener cbcsrl = (BeanContextServiceRevokedListener)requestors.get(requestor); + BeanContextServiceRevokedListener cbcsrl = requestors.get(requestor); if (cbcsrl != null && !cbcsrl.equals(bcsrl)) throw new TooManyListenersException(); @@ -230,15 +229,18 @@ public class BeanContextServicesSupport extends BeanContextSupport } - Iterator cloneOfEntries() { - return ((HashMap)requestors.clone()).entrySet().iterator(); + @SuppressWarnings("unchecked") // Cast from clone + Iterator> cloneOfEntries() { + return ((HashMap)requestors.clone()).entrySet().iterator(); } - Iterator entries() { return requestors.entrySet().iterator(); } + Iterator> entries() { + return requestors.entrySet().iterator(); + } boolean isEmpty() { return requestors.isEmpty(); } - Class getServiceClass() { return serviceClass; } + Class getServiceClass() { return serviceClass; } BeanContextServiceProvider getServiceProvider() { return serviceProvider; @@ -281,7 +283,7 @@ public class BeanContextServicesSupport extends BeanContextSupport * fields */ - Class serviceClass; + Class serviceClass; BeanContextServiceProvider serviceProvider; int serviceRefs; @@ -289,7 +291,7 @@ public class BeanContextServicesSupport extends BeanContextSupport BeanContextServiceProvider delegateProvider; // proxy int delegateRefs; - HashMap requestors = new HashMap(1); + HashMap requestors = new HashMap<>(1); } /* @@ -322,16 +324,16 @@ public class BeanContextServicesSupport extends BeanContextSupport // note usage of service per requestor, per service - synchronized void usingService(Object requestor, Object service, Class serviceClass, BeanContextServiceProvider bcsp, boolean isDelegated, BeanContextServiceRevokedListener bcsrl) throws TooManyListenersException, UnsupportedOperationException { + synchronized void usingService(Object requestor, Object service, Class serviceClass, BeanContextServiceProvider bcsp, boolean isDelegated, BeanContextServiceRevokedListener bcsrl) throws TooManyListenersException, UnsupportedOperationException { // first, process mapping from serviceClass to requestor(s) BCSSCServiceClassRef serviceClassRef = null; if (serviceClasses == null) - serviceClasses = new HashMap(1); + serviceClasses = new HashMap<>(1); else - serviceClassRef = (BCSSCServiceClassRef)serviceClasses.get(serviceClass); + serviceClassRef = serviceClasses.get(serviceClass); if (serviceClassRef == null) { // new service being used ... serviceClassRef = new BCSSCServiceClassRef(serviceClass, bcsp, isDelegated); @@ -348,20 +350,20 @@ public class BeanContextServicesSupport extends BeanContextSupport // now handle mapping from requestor to service(s) BCSSCServiceRef serviceRef = null; - Map services = null; + Map services = null; if (serviceRequestors == null) { - serviceRequestors = new HashMap(1); + serviceRequestors = new HashMap<>(1); } else { - services = (Map)serviceRequestors.get(requestor); + services = serviceRequestors.get(requestor); } if (services == null) { - services = new HashMap(1); + services = new HashMap<>(1); serviceRequestors.put(requestor, services); } else - serviceRef = (BCSSCServiceRef)services.get(service); + serviceRef = services.get(service); if (serviceRef == null) { serviceRef = new BCSSCServiceRef(serviceClassRef, isDelegated); @@ -377,11 +379,11 @@ public class BeanContextServicesSupport extends BeanContextSupport synchronized void releaseService(Object requestor, Object service) { if (serviceRequestors == null) return; - Map services = (Map)serviceRequestors.get(requestor); + Map services = serviceRequestors.get(requestor); if (services == null) return; // oops its not there anymore! - BCSSCServiceRef serviceRef = (BCSSCServiceRef)services.get(service); + BCSSCServiceRef serviceRef = services.get(service); if (serviceRef == null) return; // oops its not there anymore! @@ -418,33 +420,33 @@ public class BeanContextServicesSupport extends BeanContextSupport // revoke a service - synchronized void revokeService(Class serviceClass, boolean isDelegated, boolean revokeNow) { + synchronized void revokeService(Class serviceClass, boolean isDelegated, boolean revokeNow) { if (serviceClasses == null) return; - BCSSCServiceClassRef serviceClassRef = (BCSSCServiceClassRef)serviceClasses.get(serviceClass); + BCSSCServiceClassRef serviceClassRef = serviceClasses.get(serviceClass); if (serviceClassRef == null) return; - Iterator i = serviceClassRef.cloneOfEntries(); + Iterator> i = serviceClassRef.cloneOfEntries(); BeanContextServiceRevokedEvent bcsre = new BeanContextServiceRevokedEvent(BeanContextServicesSupport.this.getBeanContextServicesPeer(), serviceClass, revokeNow); boolean noMoreRefs = false; while (i.hasNext() && serviceRequestors != null) { - Map.Entry entry = (Map.Entry)i.next(); - BeanContextServiceRevokedListener listener = (BeanContextServiceRevokedListener)entry.getValue(); + Map.Entry entry = i.next(); + BeanContextServiceRevokedListener listener = entry.getValue(); if (revokeNow) { Object requestor = entry.getKey(); - Map services = (Map)serviceRequestors.get(requestor); + Map services = serviceRequestors.get(requestor); if (services != null) { - Iterator i1 = services.entrySet().iterator(); + Iterator> i1 = services.entrySet().iterator(); while (i1.hasNext()) { - Map.Entry tmp = (Map.Entry)i1.next(); + Map.Entry tmp = i1.next(); - BCSSCServiceRef serviceRef = (BCSSCServiceRef)tmp.getValue(); + BCSSCServiceRef serviceRef = tmp.getValue(); if (serviceRef.getServiceClassRef().equals(serviceClassRef) && isDelegated == serviceRef.isDelegated()) { i1.remove(); } @@ -479,19 +481,19 @@ public class BeanContextServicesSupport extends BeanContextSupport if (serviceRequestors == null) return; - Iterator requestors = serviceRequestors.entrySet().iterator(); + Iterator>> requestors = serviceRequestors.entrySet().iterator(); while(requestors.hasNext()) { - Map.Entry tmp = (Map.Entry)requestors.next(); + Map.Entry> tmp = requestors.next(); Object requestor = tmp.getKey(); - Iterator services = ((Map)tmp.getValue()).entrySet().iterator(); + Iterator> services = tmp.getValue().entrySet().iterator(); requestors.remove(); while (services.hasNext()) { - Map.Entry entry = (Map.Entry)services.next(); + Map.Entry entry = services.next(); Object service = entry.getKey(); - BCSSCServiceRef sref = (BCSSCServiceRef)entry.getValue(); + BCSSCServiceRef sref = entry.getValue(); BCSSCServiceClassRef scref = sref.getServiceClassRef(); @@ -513,32 +515,32 @@ public class BeanContextServicesSupport extends BeanContextSupport void revokeAllDelegatedServicesNow() { if (serviceClasses == null) return; - Iterator serviceClassRefs = - new HashSet(serviceClasses.values()).iterator(); + Iterator serviceClassRefs = + new HashSet<>(serviceClasses.values()).iterator(); while (serviceClassRefs.hasNext()) { - BCSSCServiceClassRef serviceClassRef = (BCSSCServiceClassRef)serviceClassRefs.next(); + BCSSCServiceClassRef serviceClassRef = serviceClassRefs.next(); if (!serviceClassRef.isDelegated()) continue; - Iterator i = serviceClassRef.cloneOfEntries(); + Iterator> i = serviceClassRef.cloneOfEntries(); BeanContextServiceRevokedEvent bcsre = new BeanContextServiceRevokedEvent(BeanContextServicesSupport.this.getBeanContextServicesPeer(), serviceClassRef.getServiceClass(), true); boolean noMoreRefs = false; while (i.hasNext()) { - Map.Entry entry = (Map.Entry)i.next(); - BeanContextServiceRevokedListener listener = (BeanContextServiceRevokedListener)entry.getValue(); + Map.Entry entry = i.next(); + BeanContextServiceRevokedListener listener = entry.getValue(); Object requestor = entry.getKey(); - Map services = (Map)serviceRequestors.get(requestor); + Map services = serviceRequestors.get(requestor); if (services != null) { - Iterator i1 = services.entrySet().iterator(); + Iterator> i1 = services.entrySet().iterator(); while (i1.hasNext()) { - Map.Entry tmp = (Map.Entry)i1.next(); + Map.Entry tmp = i1.next(); - BCSSCServiceRef serviceRef = (BCSSCServiceRef)tmp.getValue(); + BCSSCServiceRef serviceRef = tmp.getValue(); if (serviceRef.getServiceClassRef().equals(serviceClassRef) && serviceRef.isDelegated()) { i1.remove(); } @@ -568,8 +570,8 @@ public class BeanContextServicesSupport extends BeanContextSupport * fields */ - private transient HashMap serviceClasses; - private transient HashMap serviceRequestors; + private transient HashMap, BCSSCServiceClassRef> serviceClasses; + private transient HashMap> serviceRequestors; } /** @@ -597,7 +599,7 @@ public class BeanContextServicesSupport extends BeanContextSupport protected static class BCSSServiceProvider implements Serializable { private static final long serialVersionUID = 861278251667444782L; - BCSSServiceProvider(Class sc, BeanContextServiceProvider bcsp) { + BCSSServiceProvider(Class sc, BeanContextServiceProvider bcsp) { super(); serviceProvider = bcsp; @@ -627,7 +629,7 @@ public class BeanContextServicesSupport extends BeanContextSupport * @return a service provider without overriding addService() */ - protected BCSSServiceProvider createBCSSServiceProvider(Class sc, BeanContextServiceProvider bcsp) { + protected BCSSServiceProvider createBCSSServiceProvider(Class sc, BeanContextServiceProvider bcsp) { return new BCSSServiceProvider(sc, bcsp); } @@ -671,7 +673,7 @@ public class BeanContextServicesSupport extends BeanContextSupport * @param bcsp the service provider */ - public boolean addService(Class serviceClass, BeanContextServiceProvider bcsp) { + public boolean addService(Class serviceClass, BeanContextServiceProvider bcsp) { return addService(serviceClass, bcsp, true); } @@ -683,7 +685,7 @@ public class BeanContextServicesSupport extends BeanContextSupport * @return true if the service was successfully added */ - protected boolean addService(Class serviceClass, BeanContextServiceProvider bcsp, boolean fireEvent) { + protected boolean addService(Class serviceClass, BeanContextServiceProvider bcsp, boolean fireEvent) { if (serviceClass == null) throw new NullPointerException("serviceClass"); if (bcsp == null) throw new NullPointerException("bcsp"); @@ -704,7 +706,7 @@ public class BeanContextServicesSupport extends BeanContextSupport fireServiceAdded(bcssae); synchronized(children) { - Iterator i = children.keySet().iterator(); + Iterator i = children.keySet().iterator(); while (i.hasNext()) { Object c = i.next(); @@ -727,7 +729,7 @@ public class BeanContextServicesSupport extends BeanContextSupport * @param revokeCurrentServicesNow whether or not to revoke the service */ - public void revokeService(Class serviceClass, BeanContextServiceProvider bcsp, boolean revokeCurrentServicesNow) { + public void revokeService(Class serviceClass, BeanContextServiceProvider bcsp, boolean revokeCurrentServicesNow) { if (serviceClass == null) throw new NullPointerException("serviceClass"); if (bcsp == null) throw new NullPointerException("bcsp"); @@ -735,7 +737,7 @@ public class BeanContextServicesSupport extends BeanContextSupport synchronized(BeanContext.globalHierarchyLock) { if (!services.containsKey(serviceClass)) return; - BCSSServiceProvider bcsssp = (BCSSServiceProvider)services.get(serviceClass); + BCSSServiceProvider bcsssp = services.get(serviceClass); if (!bcsssp.getServiceProvider().equals(bcsp)) throw new IllegalArgumentException("service provider mismatch"); @@ -744,7 +746,7 @@ public class BeanContextServicesSupport extends BeanContextSupport if (bcsp instanceof Serializable) serializable--; - Iterator i = bcsChildren(); // get the BCSChild values. + Iterator i = bcsChildren(); // get the BCSChild values. while (i.hasNext()) { ((BCSSChild)i.next()).revokeService(serviceClass, false, revokeCurrentServicesNow); @@ -758,7 +760,7 @@ public class BeanContextServicesSupport extends BeanContextSupport * has a service, which may be delegated */ - public synchronized boolean hasService(Class serviceClass) { + public synchronized boolean hasService(Class serviceClass) { if (serviceClass == null) throw new NullPointerException("serviceClass"); synchronized(BeanContext.globalHierarchyLock) { @@ -791,7 +793,7 @@ public class BeanContextServicesSupport extends BeanContextSupport nestingCtxt = bcs; } - public Object getService(BeanContextServices bcs, Object requestor, Class serviceClass, Object serviceSelector) { + public Object getService(BeanContextServices bcs, Object requestor, Class serviceClass, Object serviceSelector) { Object service = null; try { @@ -807,12 +809,12 @@ public class BeanContextServicesSupport extends BeanContextSupport nestingCtxt.releaseService(bcs, requestor, service); } - public Iterator getCurrentServiceSelectors(BeanContextServices bcs, Class serviceClass) { + public Iterator getCurrentServiceSelectors(BeanContextServices bcs, Class serviceClass) { return nestingCtxt.getCurrentServiceSelectors(serviceClass); } public void serviceRevoked(BeanContextServiceRevokedEvent bcsre) { - Iterator i = bcsChildren(); // get the BCSChild values. + Iterator i = bcsChildren(); // get the BCSChild values. while (i.hasNext()) { ((BCSSChild)i.next()).revokeService(bcsre.getServiceClass(), true, bcsre.isCurrentServiceInvalidNow()); @@ -832,7 +834,7 @@ public class BeanContextServicesSupport extends BeanContextSupport * obtain a service which may be delegated */ - public Object getService(BeanContextChild child, Object requestor, Class serviceClass, Object serviceSelector, BeanContextServiceRevokedListener bcsrl) throws TooManyListenersException { + public Object getService(BeanContextChild child, Object requestor, Class serviceClass, Object serviceSelector, BeanContextServiceRevokedListener bcsrl) throws TooManyListenersException { if (child == null) throw new NullPointerException("child"); if (serviceClass == null) throw new NullPointerException("serviceClass"); if (requestor == null) throw new NullPointerException("requestor"); @@ -847,7 +849,7 @@ public class BeanContextServicesSupport extends BeanContextSupport if (bcsc == null) throw new IllegalArgumentException("not a child of this context"); // not a child ... - BCSSServiceProvider bcsssp = (BCSSServiceProvider)services.get(serviceClass); + BCSSServiceProvider bcsssp = services.get(serviceClass); if (bcsssp != null) { BeanContextServiceProvider bcsp = bcsssp.getServiceProvider(); @@ -918,7 +920,7 @@ public class BeanContextServicesSupport extends BeanContextSupport * @return an iterator for all the currently registered service classes. */ - public Iterator getCurrentServiceClasses() { + public Iterator getCurrentServiceClasses() { return new BCSIterator(services.keySet().iterator()); } @@ -927,9 +929,9 @@ public class BeanContextServicesSupport extends BeanContextSupport * (if any) available for the specified service. */ - public Iterator getCurrentServiceSelectors(Class serviceClass) { + public Iterator getCurrentServiceSelectors(Class serviceClass) { - BCSSServiceProvider bcsssp = (BCSSServiceProvider)services.get(serviceClass); + BCSSServiceProvider bcsssp = services.get(serviceClass); return bcsssp != null ? new BCSIterator(bcsssp.getServiceProvider().getCurrentServiceSelectors(getBeanContextServicesPeer(), serviceClass)) : null; } @@ -950,7 +952,7 @@ public class BeanContextServicesSupport extends BeanContextSupport fireServiceAdded(bcssae); - Iterator i; + Iterator i; synchronized(children) { i = children.keySet().iterator(); @@ -982,7 +984,7 @@ public class BeanContextServicesSupport extends BeanContextSupport fireServiceRevoked(bcssre); - Iterator i; + Iterator i; synchronized(children) { i = children.keySet().iterator(); @@ -1085,7 +1087,7 @@ public class BeanContextServicesSupport extends BeanContextSupport * Fires a BeanContextServiceEvent notifying of a new service. * @param serviceClass the service class */ - protected final void fireServiceAdded(Class serviceClass) { + protected final void fireServiceAdded(Class serviceClass) { BeanContextServiceAvailableEvent bcssae = new BeanContextServiceAvailableEvent(getBeanContextServicesPeer(), serviceClass); fireServiceAdded(bcssae); @@ -1129,7 +1131,7 @@ public class BeanContextServicesSupport extends BeanContextSupport * @param serviceClass the service class * @param revokeNow whether or not the event should be revoked now */ - protected final void fireServiceRevoked(Class serviceClass, boolean revokeNow) { + protected final void fireServiceRevoked(Class serviceClass, boolean revokeNow) { Object[] copy; BeanContextServiceRevokedEvent bcsre = new BeanContextServiceRevokedEvent(getBeanContextServicesPeer(), serviceClass, revokeNow); @@ -1159,14 +1161,14 @@ public class BeanContextServicesSupport extends BeanContextSupport int count = 0; - Iterator i = services.entrySet().iterator(); + Iterator> i = services.entrySet().iterator(); while (i.hasNext() && count < serializable) { - Map.Entry entry = (Map.Entry)i.next(); + Map.Entry entry = i.next(); BCSSServiceProvider bcsp = null; try { - bcsp = (BCSSServiceProvider)entry.getValue(); + bcsp = entry.getValue(); } catch (ClassCastException cce) { continue; } @@ -1201,7 +1203,7 @@ public class BeanContextServicesSupport extends BeanContextSupport int count = serializable; while (count > 0) { - services.put(ois.readObject(), ois.readObject()); + services.put(ois.readObject(), (BCSSServiceProvider)ois.readObject()); count--; } } @@ -1236,7 +1238,7 @@ public class BeanContextServicesSupport extends BeanContextSupport * all accesses to the protected transient HashMap services * field should be synchronized on that object */ - protected transient HashMap services; + protected transient HashMap services; /** * The number of instances of a serializable BeanContextServceProvider. @@ -1253,5 +1255,5 @@ public class BeanContextServicesSupport extends BeanContextSupport /** * List of BeanContextServicesListener objects. */ - protected transient ArrayList bcsListeners; + protected transient ArrayList bcsListeners; } diff --git a/jdk/src/share/classes/java/beans/beancontext/BeanContextSupport.java b/jdk/src/share/classes/java/beans/beancontext/BeanContextSupport.java index e8cd43b6293..4845650e745 100644 --- a/jdk/src/share/classes/java/beans/beancontext/BeanContextSupport.java +++ b/jdk/src/share/classes/java/beans/beancontext/BeanContextSupport.java @@ -254,7 +254,7 @@ public class BeanContextSupport extends BeanContextChildSupport * currently nested in this BeanContext. * @return an Iterator of the nested children */ - public Iterator iterator() { + public Iterator iterator() { synchronized(children) { return new BCSIterator(children.keySet().iterator()); } @@ -292,14 +292,14 @@ public class BeanContextSupport extends BeanContextChildSupport * a noop remove() method. */ - protected static final class BCSIterator implements Iterator { - BCSIterator(Iterator i) { super(); src = i; } + protected static final class BCSIterator implements Iterator { + BCSIterator(Iterator i) { super(); src = i; } public boolean hasNext() { return src.hasNext(); } - public Object next() { return src.next(); } + public Object next() { return src.next(); } public void remove() { /* do nothing */ } - private Iterator src; + private Iterator src; } /************************************************************************/ @@ -504,7 +504,7 @@ public class BeanContextSupport extends BeanContextChildSupport throw new IllegalStateException(); } - BCSChild bcsc = (BCSChild)children.get(targetChild); + BCSChild bcsc = children.get(targetChild); BCSChild pbcsc = null; Object peer = null; @@ -533,7 +533,7 @@ public class BeanContextSupport extends BeanContextChildSupport children.remove(targetChild); if (bcsc.isProxyPeer()) { - pbcsc = (BCSChild)children.get(peer = bcsc.getProxyPeer()); + pbcsc = children.get(peer = bcsc.getProxyPeer()); children.remove(peer); } } @@ -566,9 +566,10 @@ public class BeanContextSupport extends BeanContextChildSupport * in the collection are children of * this BeanContext, false if not. */ + @SuppressWarnings("rawtypes") public boolean containsAll(Collection c) { synchronized(children) { - Iterator i = c.iterator(); + Iterator i = c.iterator(); while (i.hasNext()) if(!contains(i.next())) return false; @@ -583,6 +584,7 @@ public class BeanContextSupport extends BeanContextChildSupport * @throws UnsupportedOperationException thrown unconditionally by this implementation * @return this implementation unconditionally throws {@code UnsupportedOperationException} */ + @SuppressWarnings("rawtypes") public boolean addAll(Collection c) { throw new UnsupportedOperationException(); } @@ -594,6 +596,7 @@ public class BeanContextSupport extends BeanContextChildSupport * @return this implementation unconditionally throws {@code UnsupportedOperationException} */ + @SuppressWarnings("rawtypes") public boolean removeAll(Collection c) { throw new UnsupportedOperationException(); } @@ -605,6 +608,7 @@ public class BeanContextSupport extends BeanContextChildSupport * @throws UnsupportedOperationException thrown unconditionally by this implementation * @return this implementation unconditionally throws {@code UnsupportedOperationException} */ + @SuppressWarnings("rawtypes") public boolean retainAll(Collection c) { throw new UnsupportedOperationException(); } @@ -763,7 +767,7 @@ public class BeanContextSupport extends BeanContextChildSupport } synchronized(children) { - for (Iterator i = children.keySet().iterator(); i.hasNext();) { + for (Iterator i = children.keySet().iterator(); i.hasNext();) { Object c = i.next(); try { @@ -790,7 +794,7 @@ public class BeanContextSupport extends BeanContextChildSupport // lets also tell the Children that can that they may not use their GUI's synchronized(children) { - for (Iterator i = children.keySet().iterator(); i.hasNext();) { + for (Iterator i = children.keySet().iterator(); i.hasNext();) { Visibility v = getChildVisibility(i.next()); if (v != null) v.dontUseGui(); @@ -809,7 +813,7 @@ public class BeanContextSupport extends BeanContextChildSupport // lets also tell the Children that can that they may use their GUI's synchronized(children) { - for (Iterator i = children.keySet().iterator(); i.hasNext();) { + for (Iterator i = children.keySet().iterator(); i.hasNext();) { Visibility v = getChildVisibility(i.next()); if (v != null) v.okToUseGui(); @@ -841,7 +845,7 @@ public class BeanContextSupport extends BeanContextChildSupport * of this BeanContext. * @return an iterator for all the current BCSChild values */ - protected Iterator bcsChildren() { synchronized(children) { return children.values().iterator(); } } + protected Iterator bcsChildren() { synchronized(children) { return children.values().iterator(); } } /** * called by writeObject after defaultWriteObject() but prior to @@ -896,7 +900,7 @@ public class BeanContextSupport extends BeanContextChildSupport * @param coll the Collection to serialize * @throws IOException if serialization failed */ - protected final void serialize(ObjectOutputStream oos, Collection coll) throws IOException { + protected final void serialize(ObjectOutputStream oos, Collection coll) throws IOException { int count = 0; Object[] objects = coll.toArray(); @@ -926,6 +930,7 @@ public class BeanContextSupport extends BeanContextChildSupport * @throws IOException if deserialization failed * @throws ClassNotFoundException if needed classes are not found */ + @SuppressWarnings({"rawtypes", "unchecked"}) protected final void deserialize(ObjectInputStream ois, Collection coll) throws IOException, ClassNotFoundException { int count = 0; @@ -953,10 +958,10 @@ public class BeanContextSupport extends BeanContextChildSupport int count = 0; synchronized(children) { - Iterator i = children.entrySet().iterator(); + Iterator> i = children.entrySet().iterator(); while (i.hasNext() && count < serializable) { - Map.Entry entry = (Map.Entry)i.next(); + Map.Entry entry = i.next(); if (entry.getKey() instanceof Serializable) { try { @@ -1082,7 +1087,7 @@ public class BeanContextSupport extends BeanContextChildSupport if (serializable > 0 && this.equals(getBeanContextPeer())) readChildren(ois); - deserialize(ois, bcmListeners = new ArrayList(1)); + deserialize(ois, bcmListeners = new ArrayList<>(1)); } } @@ -1101,7 +1106,7 @@ public class BeanContextSupport extends BeanContextChildSupport ) { if (!validatePendingRemove(source)) { throw new PropertyVetoException("current BeanContext vetoes setBeanContext()", pce); - } else ((BCSChild)children.get(source)).setRemovePending(true); + } else children.get(source).setRemovePending(true); } } } @@ -1117,13 +1122,13 @@ public class BeanContextSupport extends BeanContextChildSupport synchronized(children) { if ("beanContext".equals(propertyName) && containsKey(source) && - ((BCSChild)children.get(source)).isRemovePending()) { + children.get(source).isRemovePending()) { BeanContext bc = getBeanContextPeer(); if (bc.equals(pce.getOldValue()) && !bc.equals(pce.getNewValue())) { remove(source, false); } else { - ((BCSChild)children.get(source)).setRemovePending(false); + children.get(source).setRemovePending(false); } } } @@ -1312,8 +1317,8 @@ public class BeanContextSupport extends BeanContextChildSupport */ protected synchronized void initialize() { - children = new HashMap(serializable + 1); - bcmListeners = new ArrayList(1); + children = new HashMap<>(serializable + 1); + bcmListeners = new ArrayList<>(1); childPCL = new PropertyChangeListener() { @@ -1359,7 +1364,7 @@ public class BeanContextSupport extends BeanContextChildSupport * @param second the second object * @return true if equal, false if not */ - protected static final boolean classEquals(Class first, Class second) { + protected static final boolean classEquals(Class first, Class second) { return first.equals(second) || first.getName().equals(second.getName()); } @@ -1373,7 +1378,7 @@ public class BeanContextSupport extends BeanContextChildSupport * all accesses to the protected HashMap children field * shall be synchronized on that object. */ - protected transient HashMap children; + protected transient HashMap children; private int serializable = 0; // children serializable @@ -1381,7 +1386,7 @@ public class BeanContextSupport extends BeanContextChildSupport * all accesses to the protected ArrayList bcmListeners field * shall be synchronized on that object. */ - protected transient ArrayList bcmListeners; + protected transient ArrayList bcmListeners; // diff --git a/jdk/src/share/classes/java/io/File.java b/jdk/src/share/classes/java/io/File.java index f0528c73754..306cc84097d 100644 --- a/jdk/src/share/classes/java/io/File.java +++ b/jdk/src/share/classes/java/io/File.java @@ -1997,8 +1997,10 @@ public class File File directory) throws IOException { - if (prefix.length() < 3) - throw new IllegalArgumentException("Prefix string too short"); + if (prefix.length() < 3) { + throw new IllegalArgumentException("Prefix string \"" + prefix + + "\" too short: length must be at least 3"); + } if (suffix == null) suffix = ".tmp"; diff --git a/jdk/src/share/classes/java/io/RandomAccessFile.java b/jdk/src/share/classes/java/io/RandomAccessFile.java index d5703937e54..ae1e530f168 100644 --- a/jdk/src/share/classes/java/io/RandomAccessFile.java +++ b/jdk/src/share/classes/java/io/RandomAccessFile.java @@ -890,7 +890,7 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable { */ public final String readLine() throws IOException { - StringBuffer input = new StringBuffer(); + StringBuilder input = new StringBuilder(); int c = -1; boolean eol = false; diff --git a/jdk/src/share/classes/java/lang/Class.java b/jdk/src/share/classes/java/lang/Class.java index 71daa390286..ed7fa95e121 100644 --- a/jdk/src/share/classes/java/lang/Class.java +++ b/jdk/src/share/classes/java/lang/Class.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2013, 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 @@ -130,11 +130,15 @@ public final class Class implements java.io.Serializable, } /* - * Constructor. Only the Java Virtual Machine creates Class - * objects. + * Private constructor. Only the Java Virtual Machine creates Class objects. + * This constructor is not used and prevents the default constructor being + * generated. */ - private Class() {} - + private Class(ClassLoader loader) { + // Initialize final field for classLoader. The initialization value of non-null + // prevents future JIT optimizations from assuming this final field is null. + classLoader = loader; + } /** * Converts the object to a string. The string representation is the @@ -677,8 +681,10 @@ public final class Class implements java.io.Serializable, } // Package-private to allow ClassLoader access - native ClassLoader getClassLoader0(); + ClassLoader getClassLoader0() { return classLoader; } + // Initialized in JVM not by private constructor + private final ClassLoader classLoader; /** * Returns an array of {@code TypeVariable} objects that represent the diff --git a/jdk/src/share/classes/java/lang/ClassLoader.java b/jdk/src/share/classes/java/lang/ClassLoader.java index 876b1855012..1652d6cc4eb 100644 --- a/jdk/src/share/classes/java/lang/ClassLoader.java +++ b/jdk/src/share/classes/java/lang/ClassLoader.java @@ -1859,18 +1859,17 @@ public abstract class ClassLoader { String name = NativeLibrary.findBuiltinLib(file.getName()); boolean isBuiltin = (name != null); if (!isBuiltin) { - boolean exists = AccessController.doPrivileged( - new PrivilegedAction() { - public Object run() { - return file.exists() ? Boolean.TRUE : null; - }}) - != null; - if (!exists) { - return false; - } - try { - name = file.getCanonicalPath(); - } catch (IOException e) { + name = AccessController.doPrivileged( + new PrivilegedAction() { + public String run() { + try { + return file.exists() ? file.getCanonicalPath() : null; + } catch (IOException e) { + return null; + } + } + }); + if (name == null) { return false; } } diff --git a/jdk/src/share/classes/java/lang/Package.java b/jdk/src/share/classes/java/lang/Package.java index f59176f558e..95abe98cd4b 100644 --- a/jdk/src/share/classes/java/lang/Package.java +++ b/jdk/src/share/classes/java/lang/Package.java @@ -107,6 +107,7 @@ import java.lang.annotation.Annotation; * loader to be found. * * @see ClassLoader#definePackage + * @since 1.2 */ public class Package implements java.lang.reflect.AnnotatedElement { /** diff --git a/jdk/src/share/classes/java/lang/SafeVarargs.java b/jdk/src/share/classes/java/lang/SafeVarargs.java index 6fcd48e97d7..9f49bf7a73f 100644 --- a/jdk/src/share/classes/java/lang/SafeVarargs.java +++ b/jdk/src/share/classes/java/lang/SafeVarargs.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 @@ -45,7 +45,7 @@ import java.lang.annotation.*; *
  • the declaration is a fixed arity method or constructor * *
  • the declaration is a variable arity method that is neither - * {@code static} nor {@code final}. + * {@code static} nor {@code final} nor {@code private}. * * * diff --git a/jdk/src/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java b/jdk/src/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java index d881fe5d18d..3ab5d9c4dcf 100644 --- a/jdk/src/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java +++ b/jdk/src/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java @@ -40,6 +40,7 @@ import static java.lang.invoke.MethodHandleStatics.*; import static java.lang.invoke.MethodHandleNatives.Constants.*; import static java.lang.invoke.LambdaForm.BasicType.*; import sun.invoke.util.VerifyType; +import sun.reflect.misc.ReflectUtil; /** * Code generation backend for LambdaForm. @@ -594,6 +595,8 @@ class InvokerBytecodeGenerator { return false; // inner class of some sort if (cls.getClassLoader() != MethodHandle.class.getClassLoader()) return false; // not on BCP + if (ReflectUtil.isVMAnonymousClass(cls)) // FIXME: switch to supported API once it is added + return false; MethodType mtype = member.getMethodOrFieldType(); if (!isStaticallyNameable(mtype.returnType())) return false; @@ -612,6 +615,8 @@ class InvokerBytecodeGenerator { cls = cls.getComponentType(); if (cls.isPrimitive()) return true; // int[].class, for example + if (ReflectUtil.isVMAnonymousClass(cls)) // FIXME: switch to supported API once it is added + return false; // could use VerifyAccess.isClassAccessible but the following is a safe approximation if (cls.getClassLoader() != Object.class.getClassLoader()) return false; diff --git a/jdk/src/share/classes/java/lang/reflect/AccessibleObject.java b/jdk/src/share/classes/java/lang/reflect/AccessibleObject.java index a5931e145a7..f85ab432388 100644 --- a/jdk/src/share/classes/java/lang/reflect/AccessibleObject.java +++ b/jdk/src/share/classes/java/lang/reflect/AccessibleObject.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 @@ -129,16 +129,24 @@ public class AccessibleObject implements AnnotatedElement { setAccessible0(this, flag); } - /* Check that you aren't exposing java.lang.Class.. */ + /* Check that you aren't exposing java.lang.Class. or sensitive + fields in java.lang.Class. */ private static void setAccessible0(AccessibleObject obj, boolean flag) throws SecurityException { if (obj instanceof Constructor && flag == true) { Constructor c = (Constructor)obj; if (c.getDeclaringClass() == Class.class) { - throw new SecurityException("Can not make a java.lang.Class" + + throw new SecurityException("Cannot make a java.lang.Class" + " constructor accessible"); } + } else if (obj instanceof Field && flag == true) { + Field f = (Field)obj; + if (f.getDeclaringClass() == Class.class && + f.getName().equals("classLoader")) { + throw new SecurityException("Cannot make java.lang.Class.classLoader" + + " accessible"); + } } obj.override = flag; } diff --git a/jdk/src/share/classes/java/net/IDN.java b/jdk/src/share/classes/java/net/IDN.java index 34642b9824c..d4c8f5e426d 100644 --- a/jdk/src/share/classes/java/net/IDN.java +++ b/jdk/src/share/classes/java/net/IDN.java @@ -111,7 +111,7 @@ public final class IDN { public static String toASCII(String input, int flag) { int p = 0, q = 0; - StringBuffer out = new StringBuffer(); + StringBuilder out = new StringBuilder(); if (isRootLabel(input)) { return "."; @@ -172,7 +172,7 @@ public final class IDN { */ public static String toUnicode(String input, int flag) { int p = 0, q = 0; - StringBuffer out = new StringBuffer(); + StringBuilder out = new StringBuilder(); if (isRootLabel(input)) { return "."; diff --git a/jdk/src/share/classes/java/net/SocketPermission.java b/jdk/src/share/classes/java/net/SocketPermission.java index d44c8471613..1f3248077be 100644 --- a/jdk/src/share/classes/java/net/SocketPermission.java +++ b/jdk/src/share/classes/java/net/SocketPermission.java @@ -733,7 +733,7 @@ public final class SocketPermission extends Permission InetAddress auth; try { - StringBuffer sb = new StringBuffer(39); + StringBuilder sb = new StringBuilder(39); for (int i = 15; i >= 0; i--) { sb.append(Integer.toHexString(((addr[i]) & 0x0f))); diff --git a/jdk/src/share/classes/java/net/URI.java b/jdk/src/share/classes/java/net/URI.java index 0035d00ead7..62dea657c04 100644 --- a/jdk/src/share/classes/java/net/URI.java +++ b/jdk/src/share/classes/java/net/URI.java @@ -1957,7 +1957,7 @@ public final class URI private void defineString() { if (string != null) return; - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); if (scheme != null) { sb.append(scheme); sb.append(':'); @@ -2015,7 +2015,7 @@ public final class URI if (i >= 0) path = base.substring(0, i + 1); } else { - StringBuffer sb = new StringBuffer(base.length() + cn); + StringBuilder sb = new StringBuilder(base.length() + cn); // 5.2 (6a) if (i >= 0) sb.append(base.substring(0, i + 1)); @@ -2778,7 +2778,7 @@ public final class URI if (s.indexOf('%') < 0) return s; - StringBuffer sb = new StringBuffer(n); + StringBuilder sb = new StringBuilder(n); ByteBuffer bb = ByteBuffer.allocate(n); CharBuffer cb = CharBuffer.allocate(n); CharsetDecoder dec = ThreadLocalCoders.decoderFor("UTF-8") diff --git a/jdk/src/share/classes/java/net/URISyntaxException.java b/jdk/src/share/classes/java/net/URISyntaxException.java index 8072c37244e..17d12bd9637 100644 --- a/jdk/src/share/classes/java/net/URISyntaxException.java +++ b/jdk/src/share/classes/java/net/URISyntaxException.java @@ -121,7 +121,7 @@ public class URISyntaxException * @return A string describing the parse error */ public String getMessage() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append(getReason()); if (index > -1) { sb.append(" at index "); diff --git a/jdk/src/share/classes/java/net/URL.java b/jdk/src/share/classes/java/net/URL.java index 9987bc08a4d..e0abaace2b5 100644 --- a/jdk/src/share/classes/java/net/URL.java +++ b/jdk/src/share/classes/java/net/URL.java @@ -1071,7 +1071,7 @@ public final class URL implements java.io.Serializable { /** * The URLStreamHandler factory. */ - static URLStreamHandlerFactory factory; + private static volatile URLStreamHandlerFactory factory; /** * Sets an application's {@code URLStreamHandlerFactory}. @@ -1106,6 +1106,7 @@ public final class URL implements java.io.Serializable { security.checkSetFactory(); } handlers.clear(); + // safe publication of URLStreamHandlerFactory with volatile write factory = fac; } } @@ -1127,9 +1128,11 @@ public final class URL implements java.io.Serializable { boolean checkedWithFactory = false; - // Use the factory (if any) - if (factory != null) { - handler = factory.createURLStreamHandler(protocol); + // Use the factory (if any). Volatile read makes + // URLStreamHandlerFactory appear fully initialized to current thread. + URLStreamHandlerFactory fac = factory; + if (fac != null) { + handler = fac.createURLStreamHandler(protocol); checkedWithFactory = true; } @@ -1193,8 +1196,8 @@ public final class URL implements java.io.Serializable { // Check with factory if another thread set a // factory since our last check - if (!checkedWithFactory && factory != null) { - handler2 = factory.createURLStreamHandler(protocol); + if (!checkedWithFactory && (fac = factory) != null) { + handler2 = fac.createURLStreamHandler(protocol); } if (handler2 != null) { diff --git a/jdk/src/share/classes/java/net/URLDecoder.java b/jdk/src/share/classes/java/net/URLDecoder.java index 1e1138ad7ec..2c65c95fefc 100644 --- a/jdk/src/share/classes/java/net/URLDecoder.java +++ b/jdk/src/share/classes/java/net/URLDecoder.java @@ -134,7 +134,7 @@ public class URLDecoder { boolean needToChange = false; int numChars = s.length(); - StringBuffer sb = new StringBuffer(numChars > 500 ? numChars / 2 : numChars); + StringBuilder sb = new StringBuilder(numChars > 500 ? numChars / 2 : numChars); int i = 0; if (enc.length() == 0) { diff --git a/jdk/src/share/classes/java/net/URLEncoder.java b/jdk/src/share/classes/java/net/URLEncoder.java index 657572c6176..5ad817bc72c 100644 --- a/jdk/src/share/classes/java/net/URLEncoder.java +++ b/jdk/src/share/classes/java/net/URLEncoder.java @@ -201,7 +201,7 @@ public class URLEncoder { throws UnsupportedEncodingException { boolean needToChange = false; - StringBuffer out = new StringBuffer(s.length()); + StringBuilder out = new StringBuilder(s.length()); Charset charset; CharArrayWriter charArrayWriter = new CharArrayWriter(); diff --git a/jdk/src/share/classes/java/net/URLStreamHandler.java b/jdk/src/share/classes/java/net/URLStreamHandler.java index 0a8f1f1d5fe..9ea65260f3d 100644 --- a/jdk/src/share/classes/java/net/URLStreamHandler.java +++ b/jdk/src/share/classes/java/net/URLStreamHandler.java @@ -486,7 +486,7 @@ public abstract class URLStreamHandler { if (u.getRef() != null) len += 1 + u.getRef().length(); - StringBuffer result = new StringBuffer(len); + StringBuilder result = new StringBuilder(len); result.append(u.getProtocol()); result.append(":"); if (u.getAuthority() != null && u.getAuthority().length() > 0) { diff --git a/jdk/src/share/classes/java/nio/file/InvalidPathException.java b/jdk/src/share/classes/java/nio/file/InvalidPathException.java index 2c628652c24..c3d617b2896 100644 --- a/jdk/src/share/classes/java/nio/file/InvalidPathException.java +++ b/jdk/src/share/classes/java/nio/file/InvalidPathException.java @@ -117,7 +117,7 @@ public class InvalidPathException * @return a string describing the error */ public String getMessage() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append(getReason()); if (index > -1) { sb.append(" at index "); diff --git a/jdk/src/share/classes/java/rmi/dgc/VMID.java b/jdk/src/share/classes/java/rmi/dgc/VMID.java index 913c598be2e..840bae4eeaa 100644 --- a/jdk/src/share/classes/java/rmi/dgc/VMID.java +++ b/jdk/src/share/classes/java/rmi/dgc/VMID.java @@ -120,15 +120,15 @@ public final class VMID implements java.io.Serializable { * Return string representation of this VMID. */ public String toString() { - StringBuffer result = new StringBuffer(); + StringBuilder sb = new StringBuilder(); if (addr != null) for (int i = 0; i < addr.length; ++ i) { int x = addr[i] & 0xFF; - result.append((x < 0x10 ? "0" : "") + - Integer.toString(x, 16)); + sb.append((x < 0x10 ? "0" : "") + + Integer.toString(x, 16)); } - result.append(':'); - result.append(uid.toString()); - return result.toString(); + sb.append(':'); + sb.append(uid.toString()); + return sb.toString(); } } diff --git a/jdk/src/share/classes/java/security/CodeSigner.java b/jdk/src/share/classes/java/security/CodeSigner.java index 37c12b153b3..a1d37ee208a 100644 --- a/jdk/src/share/classes/java/security/CodeSigner.java +++ b/jdk/src/share/classes/java/security/CodeSigner.java @@ -154,7 +154,7 @@ public final class CodeSigner implements Serializable { * if present. */ public String toString() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append("("); sb.append("Signer: " + signerCertPath.getCertificates().get(0)); if (timestamp != null) { diff --git a/jdk/src/share/classes/java/security/Timestamp.java b/jdk/src/share/classes/java/security/Timestamp.java index f66d2883e62..668a6114510 100644 --- a/jdk/src/share/classes/java/security/Timestamp.java +++ b/jdk/src/share/classes/java/security/Timestamp.java @@ -141,7 +141,7 @@ public final class Timestamp implements Serializable { * its signer's certificate. */ public String toString() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append("("); sb.append("timestamp: " + timestamp); List certs = signerCertPath.getCertificates(); diff --git a/jdk/src/share/classes/java/security/cert/CertPath.java b/jdk/src/share/classes/java/security/cert/CertPath.java index 8717f948203..88df135f6c0 100644 --- a/jdk/src/share/classes/java/security/cert/CertPath.java +++ b/jdk/src/share/classes/java/security/cert/CertPath.java @@ -220,7 +220,7 @@ public abstract class CertPath implements Serializable { * @return a string representation of this certification path */ public String toString() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); Iterator stringIterator = getCertificates().iterator(); diff --git a/jdk/src/share/classes/java/security/cert/CollectionCertStoreParameters.java b/jdk/src/share/classes/java/security/cert/CollectionCertStoreParameters.java index 12bd358cfff..e6ca94383fb 100644 --- a/jdk/src/share/classes/java/security/cert/CollectionCertStoreParameters.java +++ b/jdk/src/share/classes/java/security/cert/CollectionCertStoreParameters.java @@ -132,7 +132,7 @@ public class CollectionCertStoreParameters * @return a formatted string describing the parameters */ public String toString() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append("CollectionCertStoreParameters: [\n"); sb.append(" collection: " + coll + "\n"); sb.append("]"); diff --git a/jdk/src/share/classes/java/security/cert/LDAPCertStoreParameters.java b/jdk/src/share/classes/java/security/cert/LDAPCertStoreParameters.java index 96fe9cd0939..2daef343d50 100644 --- a/jdk/src/share/classes/java/security/cert/LDAPCertStoreParameters.java +++ b/jdk/src/share/classes/java/security/cert/LDAPCertStoreParameters.java @@ -138,7 +138,7 @@ public class LDAPCertStoreParameters implements CertStoreParameters { * @return a formatted string describing the parameters */ public String toString() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append("LDAPCertStoreParameters: [\n"); sb.append(" serverName: " + serverName + "\n"); diff --git a/jdk/src/share/classes/java/security/cert/PKIXBuilderParameters.java b/jdk/src/share/classes/java/security/cert/PKIXBuilderParameters.java index b33e1f8c1e2..51cf21e5e99 100644 --- a/jdk/src/share/classes/java/security/cert/PKIXBuilderParameters.java +++ b/jdk/src/share/classes/java/security/cert/PKIXBuilderParameters.java @@ -189,7 +189,7 @@ public class PKIXBuilderParameters extends PKIXParameters { * @return a formatted string describing the parameters */ public String toString() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append("[\n"); sb.append(super.toString()); sb.append(" Maximum Path Length: " + maxPathLength + "\n"); diff --git a/jdk/src/share/classes/java/security/cert/PKIXCertPathBuilderResult.java b/jdk/src/share/classes/java/security/cert/PKIXCertPathBuilderResult.java index 3255a3bbda6..01cedffe9c8 100644 --- a/jdk/src/share/classes/java/security/cert/PKIXCertPathBuilderResult.java +++ b/jdk/src/share/classes/java/security/cert/PKIXCertPathBuilderResult.java @@ -107,7 +107,7 @@ public class PKIXCertPathBuilderResult extends PKIXCertPathValidatorResult * {@code PKIXCertPathBuilderResult} */ public String toString() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append("PKIXCertPathBuilderResult: [\n"); sb.append(" Certification Path: " + certPath + "\n"); sb.append(" Trust Anchor: " + getTrustAnchor().toString() + "\n"); diff --git a/jdk/src/share/classes/java/security/cert/PKIXCertPathValidatorResult.java b/jdk/src/share/classes/java/security/cert/PKIXCertPathValidatorResult.java index b40cd393c7d..3ba1e335a54 100644 --- a/jdk/src/share/classes/java/security/cert/PKIXCertPathValidatorResult.java +++ b/jdk/src/share/classes/java/security/cert/PKIXCertPathValidatorResult.java @@ -148,7 +148,7 @@ public class PKIXCertPathValidatorResult implements CertPathValidatorResult { * {@code PKIXCertPathValidatorResult} */ public String toString() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append("PKIXCertPathValidatorResult: [\n"); sb.append(" Trust Anchor: " + trustAnchor.toString() + "\n"); sb.append(" Policy Tree: " + String.valueOf(policyTree) + "\n"); diff --git a/jdk/src/share/classes/java/security/cert/PKIXParameters.java b/jdk/src/share/classes/java/security/cert/PKIXParameters.java index 4d8a344532e..a411f6e2aec 100644 --- a/jdk/src/share/classes/java/security/cert/PKIXParameters.java +++ b/jdk/src/share/classes/java/security/cert/PKIXParameters.java @@ -693,7 +693,7 @@ public class PKIXParameters implements CertPathParameters { * @return a formatted string describing the parameters. */ public String toString() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append("[\n"); /* start with trusted anchor info */ diff --git a/jdk/src/share/classes/java/security/cert/PolicyQualifierInfo.java b/jdk/src/share/classes/java/security/cert/PolicyQualifierInfo.java index ec06a88ae58..c09ccd6c3cd 100644 --- a/jdk/src/share/classes/java/security/cert/PolicyQualifierInfo.java +++ b/jdk/src/share/classes/java/security/cert/PolicyQualifierInfo.java @@ -161,7 +161,7 @@ public class PolicyQualifierInfo { if (pqiString != null) return pqiString; HexDumpEncoder enc = new HexDumpEncoder(); - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append("PolicyQualifierInfo: [\n"); sb.append(" qualifierID: " + mId + "\n"); sb.append(" qualifier: " + diff --git a/jdk/src/share/classes/java/security/cert/TrustAnchor.java b/jdk/src/share/classes/java/security/cert/TrustAnchor.java index c98bf814caf..f7fb2c89497 100644 --- a/jdk/src/share/classes/java/security/cert/TrustAnchor.java +++ b/jdk/src/share/classes/java/security/cert/TrustAnchor.java @@ -317,7 +317,7 @@ public class TrustAnchor { * @return a formatted string describing the {@code TrustAnchor} */ public String toString() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append("[\n"); if (pubKey != null) { sb.append(" Trusted CA Public Key: " + pubKey.toString() + "\n"); diff --git a/jdk/src/share/classes/java/security/cert/X509CRLSelector.java b/jdk/src/share/classes/java/security/cert/X509CRLSelector.java index 0580ee36bf2..a0e6b5b600a 100644 --- a/jdk/src/share/classes/java/security/cert/X509CRLSelector.java +++ b/jdk/src/share/classes/java/security/cert/X509CRLSelector.java @@ -566,7 +566,7 @@ public class X509CRLSelector implements CRLSelector { * {@code X509CRLSelector}. */ public String toString() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append("X509CRLSelector: [\n"); if (issuerNames != null) { sb.append(" IssuerNames:\n"); diff --git a/jdk/src/share/classes/java/security/cert/X509CertSelector.java b/jdk/src/share/classes/java/security/cert/X509CertSelector.java index aae32c93f44..feb85d28b58 100644 --- a/jdk/src/share/classes/java/security/cert/X509CertSelector.java +++ b/jdk/src/share/classes/java/security/cert/X509CertSelector.java @@ -1811,7 +1811,7 @@ public class X509CertSelector implements CertSelector { * {@code CertSelector} */ public String toString() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append("X509CertSelector: [\n"); if (x509Cert != null) { sb.append(" Certificate: " + x509Cert.toString() + "\n"); diff --git a/jdk/src/share/classes/java/security/package-info.java b/jdk/src/share/classes/java/security/package-info.java index 599e95259ba..2c8205b09b9 100644 --- a/jdk/src/share/classes/java/security/package-info.java +++ b/jdk/src/share/classes/java/security/package-info.java @@ -92,14 +92,14 @@ *
  • * *
  • keytool - * ( + * ( * for Solaris/Linux) * ( * for Windows) *
  • * *
  • jarsigner - * ( + * ( * for Solaris/Linux) * ( * for Windows) diff --git a/jdk/src/share/classes/java/text/AttributedString.java b/jdk/src/share/classes/java/text/AttributedString.java index fa398e943aa..2e82924510a 100644 --- a/jdk/src/share/classes/java/text/AttributedString.java +++ b/jdk/src/share/classes/java/text/AttributedString.java @@ -243,11 +243,11 @@ public class AttributedString { throw new IllegalArgumentException("Invalid substring range"); // Copy the given string - StringBuffer textBuffer = new StringBuffer(); + StringBuilder textBuilder = new StringBuilder(); text.setIndex(beginIndex); for (char c = text.current(); text.getIndex() < endIndex; c = text.next()) - textBuffer.append(c); - this.text = textBuffer.toString(); + textBuilder.append(c); + this.text = textBuilder.toString(); if (beginIndex == endIndex) return; diff --git a/jdk/src/share/classes/java/text/ChoiceFormat.java b/jdk/src/share/classes/java/text/ChoiceFormat.java index f55837f8a4c..f8bd9a90b59 100644 --- a/jdk/src/share/classes/java/text/ChoiceFormat.java +++ b/jdk/src/share/classes/java/text/ChoiceFormat.java @@ -259,7 +259,7 @@ public class ChoiceFormat extends NumberFormat { * @return the pattern string */ public String toPattern() { - StringBuffer result = new StringBuffer(); + StringBuilder result = new StringBuilder(); for (int i = 0; i < choiceLimits.length; ++i) { if (i != 0) { result.append('|'); diff --git a/jdk/src/share/classes/java/text/DecimalFormat.java b/jdk/src/share/classes/java/text/DecimalFormat.java index f89fd151749..a82011fd7d5 100644 --- a/jdk/src/share/classes/java/text/DecimalFormat.java +++ b/jdk/src/share/classes/java/text/DecimalFormat.java @@ -2094,7 +2094,7 @@ public class DecimalFormat extends NumberFormat { } return gotDouble ? - (Number)new Double(doubleResult) : (Number)new Long(longResult); + (Number)new Double(doubleResult) : (Number)Long.valueOf(longResult); } } diff --git a/jdk/src/share/classes/java/time/Instant.java b/jdk/src/share/classes/java/time/Instant.java index 879cd1f5d40..32a4d4401e8 100644 --- a/jdk/src/share/classes/java/time/Instant.java +++ b/jdk/src/share/classes/java/time/Instant.java @@ -375,7 +375,7 @@ public final class Instant return Instant.ofEpochSecond(instantSecs, nanoOfSecond); } catch (DateTimeException ex) { throw new DateTimeException("Unable to obtain Instant from TemporalAccessor: " + - temporal + " of type " + temporal.getClass().getName()); + temporal + " of type " + temporal.getClass().getName(), ex); } } @@ -1058,7 +1058,8 @@ public final class Instant } // inline TemporalAccessor.super.query(query) as an optimization if (query == TemporalQueries.chronology() || query == TemporalQueries.zoneId() || - query == TemporalQueries.zone() || query == TemporalQueries.offset()) { + query == TemporalQueries.zone() || query == TemporalQueries.offset() || + query == TemporalQueries.localDate() || query == TemporalQueries.localTime()) { return null; } return query.queryFrom(this); diff --git a/jdk/src/share/classes/java/time/OffsetDateTime.java b/jdk/src/share/classes/java/time/OffsetDateTime.java index 49b918b0604..1ee62411ab6 100644 --- a/jdk/src/share/classes/java/time/OffsetDateTime.java +++ b/jdk/src/share/classes/java/time/OffsetDateTime.java @@ -357,10 +357,11 @@ public final class OffsetDateTime } try { ZoneOffset offset = ZoneOffset.from(temporal); - try { - LocalDateTime ldt = LocalDateTime.from(temporal); - return OffsetDateTime.of(ldt, offset); - } catch (DateTimeException ignore) { + LocalDate date = temporal.query(TemporalQueries.localDate()); + LocalTime time = temporal.query(TemporalQueries.localTime()); + if (date != null && time != null) { + return OffsetDateTime.of(date, time, offset); + } else { Instant instant = Instant.from(temporal); return OffsetDateTime.ofInstant(instant, offset); } diff --git a/jdk/src/share/classes/java/time/ZonedDateTime.java b/jdk/src/share/classes/java/time/ZonedDateTime.java index a1e703cd434..8048b157010 100644 --- a/jdk/src/share/classes/java/time/ZonedDateTime.java +++ b/jdk/src/share/classes/java/time/ZonedDateTime.java @@ -81,6 +81,7 @@ import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; import java.time.temporal.TemporalAmount; import java.time.temporal.TemporalField; +import java.time.temporal.TemporalQueries; import java.time.temporal.TemporalQuery; import java.time.temporal.TemporalUnit; import java.time.temporal.UnsupportedTemporalTypeException; @@ -551,14 +552,14 @@ public final class ZonedDateTime } try { ZoneId zone = ZoneId.from(temporal); - try { + if (temporal.isSupported(INSTANT_SECONDS)) { long epochSecond = temporal.getLong(INSTANT_SECONDS); int nanoOfSecond = temporal.get(NANO_OF_SECOND); return create(epochSecond, nanoOfSecond, zone); - - } catch (DateTimeException ex1) { - LocalDateTime ldt = LocalDateTime.from(temporal); - return of(ldt, zone); + } else { + LocalDate date = LocalDate.from(temporal); + LocalTime time = LocalTime.from(temporal); + return of(date, time, zone); } } catch (DateTimeException ex) { throw new DateTimeException("Unable to obtain ZonedDateTime from TemporalAccessor: " + @@ -2039,8 +2040,12 @@ public final class ZonedDateTime * @throws DateTimeException if unable to query (defined by the query) * @throws ArithmeticException if numeric overflow occurs (defined by the query) */ + @SuppressWarnings("unchecked") @Override // override for Javadoc public R query(TemporalQuery query) { + if (query == TemporalQueries.localDate()) { + return (R) toLocalDate(); + } return ChronoZonedDateTime.super.query(query); } diff --git a/jdk/src/share/classes/java/time/format/DateTimeFormatterBuilder.java b/jdk/src/share/classes/java/time/format/DateTimeFormatterBuilder.java index f77339670d8..f2fce14586e 100644 --- a/jdk/src/share/classes/java/time/format/DateTimeFormatterBuilder.java +++ b/jdk/src/share/classes/java/time/format/DateTimeFormatterBuilder.java @@ -3283,7 +3283,7 @@ public final class DateTimeFormatterBuilder { } catch (RuntimeException ex) { return ~position; } - int successPos = text.length(); + int successPos = pos; successPos = context.setParsedField(INSTANT_SECONDS, instantSecs, position, successPos); return context.setParsedField(NANO_OF_SECOND, nano, position, successPos); } diff --git a/jdk/src/share/classes/java/time/format/Parsed.java b/jdk/src/share/classes/java/time/format/Parsed.java index 1ae19b58a73..1eb88454414 100644 --- a/jdk/src/share/classes/java/time/format/Parsed.java +++ b/jdk/src/share/classes/java/time/format/Parsed.java @@ -66,6 +66,7 @@ import static java.time.temporal.ChronoField.CLOCK_HOUR_OF_AMPM; import static java.time.temporal.ChronoField.CLOCK_HOUR_OF_DAY; import static java.time.temporal.ChronoField.HOUR_OF_AMPM; import static java.time.temporal.ChronoField.HOUR_OF_DAY; +import static java.time.temporal.ChronoField.INSTANT_SECONDS; import static java.time.temporal.ChronoField.MICRO_OF_DAY; import static java.time.temporal.ChronoField.MICRO_OF_SECOND; import static java.time.temporal.ChronoField.MILLI_OF_DAY; @@ -74,14 +75,17 @@ import static java.time.temporal.ChronoField.MINUTE_OF_DAY; import static java.time.temporal.ChronoField.MINUTE_OF_HOUR; import static java.time.temporal.ChronoField.NANO_OF_DAY; import static java.time.temporal.ChronoField.NANO_OF_SECOND; +import static java.time.temporal.ChronoField.OFFSET_SECONDS; import static java.time.temporal.ChronoField.SECOND_OF_DAY; import static java.time.temporal.ChronoField.SECOND_OF_MINUTE; import java.time.DateTimeException; +import java.time.Instant; import java.time.LocalDate; import java.time.LocalTime; import java.time.Period; import java.time.ZoneId; +import java.time.ZoneOffset; import java.time.chrono.ChronoLocalDate; import java.time.chrono.ChronoLocalDateTime; import java.time.chrono.ChronoZonedDateTime; @@ -241,12 +245,15 @@ final class Parsed implements TemporalAccessor { resolveTimeLenient(); crossCheck(); resolvePeriod(); + resolveFractional(); + resolveInstant(); return this; } //----------------------------------------------------------------------- private void resolveFields() { // resolve ChronoField + resolveInstantFields(); resolveDateFields(); resolveTimeFields(); @@ -300,6 +307,7 @@ final class Parsed implements TemporalAccessor { } // if something changed then have to redo ChronoField resolve if (changedCount > 0) { + resolveInstantFields(); resolveDateFields(); resolveTimeFields(); } @@ -315,6 +323,29 @@ final class Parsed implements TemporalAccessor { } } + //----------------------------------------------------------------------- + private void resolveInstantFields() { + // resolve parsed instant seconds to date and time if zone available + if (fieldValues.containsKey(INSTANT_SECONDS)) { + if (zone != null) { + resolveInstantFields0(zone); + } else { + Long offsetSecs = fieldValues.get(OFFSET_SECONDS); + if (offsetSecs != null) { + ZoneOffset offset = ZoneOffset.ofTotalSeconds(offsetSecs.intValue()); + resolveInstantFields0(offset); + } + } + } + } + + private void resolveInstantFields0(ZoneId selectedZone) { + Instant instant = Instant.ofEpochSecond(fieldValues.remove(INSTANT_SECONDS)); + ChronoZonedDateTime zdt = chrono.zonedDateTime(instant, selectedZone); + updateCheckConflict(zdt.toLocalDate()); + updateCheckConflict(INSTANT_SECONDS, SECOND_OF_DAY, (long) zdt.toLocalTime().toSecondOfDay()); + } + //----------------------------------------------------------------------- private void resolveDateFields() { updateCheckConflict(chrono.resolveDate(fieldValues, resolverStyle)); @@ -533,6 +564,42 @@ final class Parsed implements TemporalAccessor { } } + private void resolveFractional() { + // ensure fractional seconds available as ChronoField requires + // resolveTimeLenient() will have merged MICRO_OF_SECOND/MILLI_OF_SECOND to NANO_OF_SECOND + if (time == null && + (fieldValues.containsKey(INSTANT_SECONDS) || + fieldValues.containsKey(SECOND_OF_DAY) || + fieldValues.containsKey(SECOND_OF_MINUTE))) { + if (fieldValues.containsKey(NANO_OF_SECOND)) { + long nos = fieldValues.get(NANO_OF_SECOND); + fieldValues.put(MICRO_OF_SECOND, nos / 1000); + fieldValues.put(MILLI_OF_SECOND, nos / 1000000); + } else { + fieldValues.put(NANO_OF_SECOND, 0L); + fieldValues.put(MICRO_OF_SECOND, 0L); + fieldValues.put(MILLI_OF_SECOND, 0L); + } + } + } + + private void resolveInstant() { + // add instant seconds if we have date, time and zone + if (date != null && time != null) { + if (zone != null) { + long instant = date.atTime(time).atZone(zone).getLong(ChronoField.INSTANT_SECONDS); + fieldValues.put(INSTANT_SECONDS, instant); + } else { + Long offsetSecs = fieldValues.get(OFFSET_SECONDS); + if (offsetSecs != null) { + ZoneOffset offset = ZoneOffset.ofTotalSeconds(offsetSecs.intValue()); + long instant = date.atTime(time).atZone(offset).getLong(ChronoField.INSTANT_SECONDS); + fieldValues.put(INSTANT_SECONDS, instant); + } + } + } + } + private void updateCheckConflict(LocalTime timeToSet, Period periodToSet) { if (time != null) { if (time.equals(timeToSet) == false) { @@ -568,18 +635,20 @@ final class Parsed implements TemporalAccessor { for (Iterator> it = fieldValues.entrySet().iterator(); it.hasNext(); ) { Entry entry = it.next(); TemporalField field = entry.getKey(); - long val1; - try { - val1 = target.getLong(field); - } catch (RuntimeException ex) { - continue; + if (target.isSupported(field)) { + long val1; + try { + val1 = target.getLong(field); + } catch (RuntimeException ex) { + continue; + } + long val2 = entry.getValue(); + if (val1 != val2) { + throw new DateTimeException("Conflict found: Field " + field + " " + val1 + + " differs from " + field + " " + val2 + " derived from " + target); + } + it.remove(); } - long val2 = entry.getValue(); - if (val1 != val2) { - throw new DateTimeException("Conflict found: Field " + field + " " + val1 + - " differs from " + field + " " + val2 + " derived from " + target); - } - it.remove(); } } diff --git a/jdk/src/share/classes/java/util/Collections.java b/jdk/src/share/classes/java/util/Collections.java index e229f5f5dd4..f6a65c7b106 100644 --- a/jdk/src/share/classes/java/util/Collections.java +++ b/jdk/src/share/classes/java/util/Collections.java @@ -3031,9 +3031,11 @@ public class Collections { final Collection c; final Class type; - void typeCheck(Object o) { + @SuppressWarnings("unchecked") + E typeCheck(Object o) { if (o != null && !type.isInstance(o)) throw new ClassCastException(badElementMsg(o)); + return (E) o; } private String badElementMsg(Object o) { @@ -3042,10 +3044,8 @@ public class Collections { } CheckedCollection(Collection c, Class type) { - if (c==null || type == null) - throw new NullPointerException(); - this.c = c; - this.type = type; + this.c = Objects.requireNonNull(c, "c"); + this.type = Objects.requireNonNull(type, "type"); } public int size() { return c.size(); } @@ -3077,10 +3077,7 @@ public class Collections { public void remove() { it.remove(); }}; } - public boolean add(E e) { - typeCheck(e); - return c.add(e); - } + public boolean add(E e) { return c.add(typeCheck(e)); } private E[] zeroLengthElementArray; // Lazily initialized @@ -3091,7 +3088,7 @@ public class Collections { @SuppressWarnings("unchecked") Collection checkedCopyOf(Collection coll) { - Object[] a = null; + Object[] a; try { E[] z = zeroLengthElementArray(); a = coll.toArray(z); @@ -3187,11 +3184,7 @@ public class Collections { public E peek() {return queue.peek();} public E poll() {return queue.poll();} public E remove() {return queue.remove();} - - public boolean offer(E e) { - typeCheck(e); - return add(e); - } + public boolean offer(E e) {return queue.offer(typeCheck(e));} } /** @@ -3440,13 +3433,11 @@ public class Collections { public int lastIndexOf(Object o) { return list.lastIndexOf(o); } public E set(int index, E element) { - typeCheck(element); - return list.set(index, element); + return list.set(index, typeCheck(element)); } public void add(int index, E element) { - typeCheck(element); - list.add(index, element); + list.add(index, typeCheck(element)); } public boolean addAll(int index, Collection c) { @@ -3467,13 +3458,11 @@ public class Collections { public void remove() { i.remove(); } public void set(E e) { - typeCheck(e); - i.set(e); + i.set(typeCheck(e)); } public void add(E e) { - typeCheck(e); - i.add(e); + i.add(typeCheck(e)); } @Override @@ -3487,10 +3476,19 @@ public class Collections { return new CheckedList<>(list.subList(fromIndex, toIndex), type); } + /** + * {@inheritDoc} + * + * @throws ClassCastException if the class of an element returned by the + * operator prevents it from being added to this collection. The + * exception may be thrown after some elements of the list have + * already been replaced. + */ @Override public void replaceAll(UnaryOperator operator) { - list.replaceAll(operator); + list.replaceAll(e -> typeCheck(operator.apply(e))); } + @Override public void sort(Comparator c) { list.sort(c); diff --git a/jdk/src/share/classes/java/util/Currency.java b/jdk/src/share/classes/java/util/Currency.java index 2c4a2e720be..5af9c7193ca 100644 --- a/jdk/src/share/classes/java/util/Currency.java +++ b/jdk/src/share/classes/java/util/Currency.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -212,13 +212,9 @@ public final class Currency implements Serializable { AccessController.doPrivileged(new PrivilegedAction() { @Override public Void run() { - String homeDir = System.getProperty("java.home"); try { - String dataFile = homeDir + File.separator + - "lib" + File.separator + "currency.data"; try (DataInputStream dis = new DataInputStream( - new BufferedInputStream( - new FileInputStream(dataFile)))) { + new BufferedInputStream(getClass().getResourceAsStream("/java/util/currency.data")))) { if (dis.readInt() != MAGIC_NUMBER) { throw new InternalError("Currency data is possibly corrupted"); } @@ -248,7 +244,7 @@ public final class Currency implements Serializable { // look for the properties file for overrides String propsFile = System.getProperty("java.util.currency.data"); if (propsFile == null) { - propsFile = homeDir + File.separator + "lib" + + propsFile = System.getProperty("java.home") + File.separator + "lib" + File.separator + "currency.properties"; } try { diff --git a/jdk/src/share/classes/java/util/IdentityHashMap.java b/jdk/src/share/classes/java/util/IdentityHashMap.java index f96055bc6c1..d4ad6006c92 100644 --- a/jdk/src/share/classes/java/util/IdentityHashMap.java +++ b/jdk/src/share/classes/java/util/IdentityHashMap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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,7 +25,6 @@ package java.util; -import java.io.*; import java.lang.reflect.Array; import java.util.function.BiConsumer; import java.util.function.BiFunction; @@ -74,7 +73,7 @@ import java.util.function.Consumer; * maximum size and the number of buckets is unspecified. * *

    If the size of the map (the number of key-value mappings) sufficiently - * exceeds the expected maximum size, the number of buckets is increased + * exceeds the expected maximum size, the number of buckets is increased. * Increasing the number of buckets ("rehashing") may be fairly expensive, so * it pays to create identity hash maps with a sufficiently large expected * maximum size. On the other hand, iteration over collection views requires @@ -160,6 +159,10 @@ public class IdentityHashMap * The maximum capacity, used if a higher value is implicitly specified * by either of the constructors with arguments. * MUST be a power of two <= 1<<29. + * + * In fact, the map can hold no more than MAXIMUM_CAPACITY-1 items + * because it has to have at least one slot with the key == null + * in order to avoid infinite loops in get(), put(), remove() */ private static final int MAXIMUM_CAPACITY = 1 << 29; @@ -180,11 +183,6 @@ public class IdentityHashMap */ transient int modCount; - /** - * The next size value at which to resize (capacity * load factor). - */ - private transient int threshold; - /** * Value representing null keys inside tables. */ @@ -229,27 +227,18 @@ public class IdentityHashMap } /** - * Returns the appropriate capacity for the specified expected maximum - * size. Returns the smallest power of two between MINIMUM_CAPACITY - * and MAXIMUM_CAPACITY, inclusive, that is greater than - * (3 * expectedMaxSize)/2, if such a number exists. Otherwise - * returns MAXIMUM_CAPACITY. If (3 * expectedMaxSize)/2 is negative, it - * is assumed that overflow has occurred, and MAXIMUM_CAPACITY is returned. + * Returns the appropriate capacity for the given expected maximum size. + * Returns the smallest power of two between MINIMUM_CAPACITY and + * MAXIMUM_CAPACITY, inclusive, that is greater than (3 * + * expectedMaxSize)/2, if such a number exists. Otherwise returns + * MAXIMUM_CAPACITY. */ - private int capacity(int expectedMaxSize) { - // Compute min capacity for expectedMaxSize given a load factor of 2/3 - int minCapacity = (3 * expectedMaxSize)/2; - - // Compute the appropriate capacity - int result; - if (minCapacity > MAXIMUM_CAPACITY || minCapacity < 0) { - result = MAXIMUM_CAPACITY; - } else { - result = MINIMUM_CAPACITY; - while (result < minCapacity) - result <<= 1; - } - return result; + private static int capacity(int expectedMaxSize) { + // assert expectedMaxSize >= 0; + return + (expectedMaxSize > MAXIMUM_CAPACITY / 3) ? MAXIMUM_CAPACITY : + (expectedMaxSize <= 2 * MINIMUM_CAPACITY / 3) ? MINIMUM_CAPACITY : + Integer.highestOneBit(expectedMaxSize + (expectedMaxSize << 1)); } /** @@ -262,7 +251,6 @@ public class IdentityHashMap // assert initCapacity >= MINIMUM_CAPACITY; // assert initCapacity <= MAXIMUM_CAPACITY; - threshold = (initCapacity * 2)/3; table = new Object[2 * initCapacity]; } @@ -429,52 +417,58 @@ public class IdentityHashMap * @see #containsKey(Object) */ public V put(K key, V value) { - Object k = maskNull(key); - Object[] tab = table; - int len = tab.length; - int i = hash(k, len); + final Object k = maskNull(key); - Object item; - while ( (item = tab[i]) != null) { - if (item == k) { - @SuppressWarnings("unchecked") - V oldValue = (V) tab[i + 1]; - tab[i + 1] = value; - return oldValue; + retryAfterResize: for (;;) { + final Object[] tab = table; + final int len = tab.length; + int i = hash(k, len); + + for (Object item; (item = tab[i]) != null; + i = nextKeyIndex(i, len)) { + if (item == k) { + @SuppressWarnings("unchecked") + V oldValue = (V) tab[i + 1]; + tab[i + 1] = value; + return oldValue; + } } - i = nextKeyIndex(i, len); - } - modCount++; - tab[i] = k; - tab[i + 1] = value; - if (++size >= threshold) - resize(len); // len == 2 * current capacity. - return null; + final int s = size + 1; + // Use optimized form of 3 * s. + // Next capacity is len, 2 * current capacity. + if (s + (s << 1) > len && resize(len)) + continue retryAfterResize; + + modCount++; + tab[i] = k; + tab[i + 1] = value; + size = s; + return null; + } } /** - * Resize the table to hold given capacity. + * Resizes the table if necessary to hold given capacity. * * @param newCapacity the new capacity, must be a power of two. + * @return whether a resize did in fact take place */ - private void resize(int newCapacity) { + private boolean resize(int newCapacity) { // assert (newCapacity & -newCapacity) == newCapacity; // power of 2 int newLength = newCapacity * 2; Object[] oldTable = table; int oldLength = oldTable.length; - if (oldLength == 2*MAXIMUM_CAPACITY) { // can't expand any further - if (threshold == MAXIMUM_CAPACITY-1) + if (oldLength == 2 * MAXIMUM_CAPACITY) { // can't expand any further + if (size == MAXIMUM_CAPACITY - 1) throw new IllegalStateException("Capacity exhausted."); - threshold = MAXIMUM_CAPACITY-1; // Gigantic map! - return; + return false; } if (oldLength >= newLength) - return; + return false; Object[] newTable = new Object[newLength]; - threshold = newLength / 3; for (int j = 0; j < oldLength; j += 2) { Object key = oldTable[j]; @@ -490,6 +484,7 @@ public class IdentityHashMap } } table = newTable; + return true; } /** @@ -504,8 +499,8 @@ public class IdentityHashMap int n = m.size(); if (n == 0) return; - if (n > threshold) // conservatively pre-expand - resize(capacity(n)); + if (n > size) + resize(capacity(n)); // conservatively pre-expand for (Entry e : m.entrySet()) put(e.getKey(), e.getValue()); @@ -542,7 +537,6 @@ public class IdentityHashMap return null; i = nextKeyIndex(i, len); } - } /** @@ -1266,8 +1260,8 @@ public class IdentityHashMap private static final long serialVersionUID = 8188218128353913216L; /** - * Save the state of the IdentityHashMap instance to a stream - * (i.e., serialize it). + * Saves the state of the IdentityHashMap instance to a stream + * (i.e., serializes it). * * @serialData The size of the HashMap (the number of key-value * mappings) (int), followed by the key (Object) and @@ -1295,8 +1289,8 @@ public class IdentityHashMap } /** - * Reconstitute the IdentityHashMap instance from a stream (i.e., - * deserialize it). + * Reconstitutes the IdentityHashMap instance from a stream (i.e., + * deserializes it). */ private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException { @@ -1305,9 +1299,10 @@ public class IdentityHashMap // Read in size (number of Mappings) int size = s.readInt(); - - // Allow for 33% growth (i.e., capacity is >= 2* size()). - init(capacity((size*4)/3)); + if (size < 0) + throw new java.io.StreamCorruptedException + ("Illegal mappings count: " + size); + init(capacity(size)); // Read the keys and values, and put the mappings in the table for (int i=0; i * update modCount, etc. */ private void putForCreate(K key, V value) - throws IOException + throws java.io.StreamCorruptedException { Object k = maskNull(key); Object[] tab = table; diff --git a/jdk/src/share/classes/java/util/Properties.java b/jdk/src/share/classes/java/util/Properties.java index 1df838e6394..e313c9716d0 100644 --- a/jdk/src/share/classes/java/util/Properties.java +++ b/jdk/src/share/classes/java/util/Properties.java @@ -602,7 +602,7 @@ class Properties extends Hashtable { if (bufLen < 0) { bufLen = Integer.MAX_VALUE; } - StringBuffer outBuffer = new StringBuffer(bufLen); + StringBuilder outBuffer = new StringBuilder(bufLen); for(int x=0; xA ConcurrentHashMap can be used as scalable frequency map (a + *

    A ConcurrentHashMap can be used as a scalable frequency map (a * form of histogram or multiset) by using {@link * java.util.concurrent.atomic.LongAdder} values and initializing via * {@link #computeIfAbsent computeIfAbsent}. For example, to add a count * to a {@code ConcurrentHashMap freqs}, you can use - * {@code freqs.computeIfAbsent(k -> new LongAdder()).increment();} + * {@code freqs.computeIfAbsent(key, k -> new LongAdder()).increment();} * *

    This class and its views and iterators implement all of the * optional methods of the {@link Map} and {@link Iterator} diff --git a/jdk/src/share/classes/java/util/concurrent/atomic/LongAdder.java b/jdk/src/share/classes/java/util/concurrent/atomic/LongAdder.java index e7415dea821..6810edf0010 100644 --- a/jdk/src/share/classes/java/util/concurrent/atomic/LongAdder.java +++ b/jdk/src/share/classes/java/util/concurrent/atomic/LongAdder.java @@ -57,7 +57,7 @@ import java.io.Serializable; * frequency map (a form of histogram or multiset). For example, to * add a count to a {@code ConcurrentHashMap freqs}, * initializing if not already present, you can use {@code - * freqs.computeIfAbsent(k -> new LongAdder()).increment();} + * freqs.computeIfAbsent(key, k -> new LongAdder()).increment();} * *

    This class extends {@link Number}, but does not define * methods such as {@code equals}, {@code hashCode} and {@code diff --git a/jdk/src/share/classes/java/util/logging/FileHandler.java b/jdk/src/share/classes/java/util/logging/FileHandler.java index cad034ececb..d58fd0ebc84 100644 --- a/jdk/src/share/classes/java/util/logging/FileHandler.java +++ b/jdk/src/share/classes/java/util/logging/FileHandler.java @@ -25,6 +25,7 @@ package java.util.logging; +import static java.nio.file.StandardOpenOption.APPEND; import static java.nio.file.StandardOpenOption.CREATE_NEW; import static java.nio.file.StandardOpenOption.WRITE; @@ -34,10 +35,17 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import java.nio.channels.FileChannel; +import java.nio.channels.OverlappingFileLockException; import java.nio.file.FileAlreadyExistsException; +import java.nio.file.Files; +import java.nio.file.LinkOption; +import java.nio.file.NoSuchFileException; +import java.nio.file.Path; import java.nio.file.Paths; import java.security.AccessController; import java.security.PrivilegedAction; +import java.util.HashSet; +import java.util.Set; /** * Simple file logging Handler. @@ -149,7 +157,7 @@ public class FileHandler extends StreamHandler { private FileChannel lockFileChannel; private File files[]; private static final int MAX_LOCKS = 100; - private static final java.util.HashMap locks = new java.util.HashMap<>(); + private static final Set locks = new HashSet<>(); /** * A metered stream is a subclass of OutputStream that @@ -428,34 +436,80 @@ public class FileHandler extends StreamHandler { // between processes (and not within a process), we first check // if we ourself already have the file locked. synchronized(locks) { - if (locks.get(lockFileName) != null) { + if (locks.contains(lockFileName)) { // We already own this lock, for a different FileHandler // object. Try again. continue; } - try { - lockFileChannel = FileChannel.open(Paths.get(lockFileName), - CREATE_NEW, WRITE); - } catch (FileAlreadyExistsException ix) { - // try the next lock file name in the sequence - continue; + final Path lockFilePath = Paths.get(lockFileName); + FileChannel channel = null; + int retries = -1; + boolean fileCreated = false; + while (channel == null && retries++ < 1) { + try { + channel = FileChannel.open(lockFilePath, + CREATE_NEW, WRITE); + fileCreated = true; + } catch (FileAlreadyExistsException ix) { + // This may be a zombie file left over by a previous + // execution. Reuse it - but only if we can actually + // write to its directory. + // Note that this is a situation that may happen, + // but not too frequently. + if (Files.isRegularFile(lockFilePath, LinkOption.NOFOLLOW_LINKS) + && Files.isWritable(lockFilePath.getParent())) { + try { + channel = FileChannel.open(lockFilePath, + WRITE, APPEND); + } catch (NoSuchFileException x) { + // Race condition - retry once, and if that + // fails again just try the next name in + // the sequence. + continue; + } catch(IOException x) { + // the file may not be writable for us. + // try the next name in the sequence + break; + } + } else { + // at this point channel should still be null. + // break and try the next name in the sequence. + break; + } + } } + if (channel == null) continue; // try the next name; + lockFileChannel = channel; + boolean available; try { available = lockFileChannel.tryLock() != null; // We got the lock OK. + // At this point we could call File.deleteOnExit(). + // However, this could have undesirable side effects + // as indicated by JDK-4872014. So we will instead + // rely on the fact that close() will remove the lock + // file and that whoever is creating FileHandlers should + // be responsible for closing them. } catch (IOException ix) { // We got an IOException while trying to get the lock. // This normally indicates that locking is not supported // on the target directory. We have to proceed without - // getting a lock. Drop through. - available = true; + // getting a lock. Drop through, but only if we did + // create the file... + available = fileCreated; + } catch (OverlappingFileLockException x) { + // someone already locked this file in this VM, through + // some other channel - that is - using something else + // than new FileHandler(...); + // continue searching for an available lock. + available = false; } if (available) { // We got the lock. Remember it. - locks.put(lockFileName, lockFileName); + locks.add(lockFileName); break; } diff --git a/jdk/src/share/classes/java/util/prefs/Base64.java b/jdk/src/share/classes/java/util/prefs/Base64.java index c0d8d5318d3..50ed3582bb6 100644 --- a/jdk/src/share/classes/java/util/prefs/Base64.java +++ b/jdk/src/share/classes/java/util/prefs/Base64.java @@ -57,7 +57,7 @@ class Base64 { int numFullGroups = aLen/3; int numBytesInPartialGroup = aLen - 3*numFullGroups; int resultLen = 4*((aLen + 2)/3); - StringBuffer result = new StringBuffer(resultLen); + StringBuilder result = new StringBuilder(resultLen); char[] intToAlpha = (alternate ? intToAltBase64 : intToBase64); // Translate all full groups from byte array elements to Base64 diff --git a/jdk/src/share/classes/java/util/regex/PatternSyntaxException.java b/jdk/src/share/classes/java/util/regex/PatternSyntaxException.java index d6ac72a2085..f7b767a75ba 100644 --- a/jdk/src/share/classes/java/util/regex/PatternSyntaxException.java +++ b/jdk/src/share/classes/java/util/regex/PatternSyntaxException.java @@ -105,7 +105,7 @@ public class PatternSyntaxException * @return The full detail message */ public String getMessage() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append(desc); if (index >= 0) { sb.append(" near index "); diff --git a/jdk/src/share/classes/java/util/stream/Collectors.java b/jdk/src/share/classes/java/util/stream/Collectors.java index 75ca1ca0f50..6f68322119d 100644 --- a/jdk/src/share/classes/java/util/stream/Collectors.java +++ b/jdk/src/share/classes/java/util/stream/Collectors.java @@ -729,7 +729,7 @@ public final class Collectors { * person in each city: *

    {@code
          *     Comparator byHeight = Comparator.comparing(Person::getHeight);
    -     *     Map tallestByCity
    +     *     Map> tallestByCity
          *         = people.stream().collect(groupingBy(Person::getCity, reducing(BinaryOperator.maxBy(byHeight))));
          * }
    * @@ -784,7 +784,7 @@ public final class Collectors { * Comparator byLength = Comparator.comparing(String::length); * Map longestLastNameByCity * = people.stream().collect(groupingBy(Person::getCity, - * reducing(Person::getLastName, BinaryOperator.maxBy(byLength)))); + * reducing("", Person::getLastName, BinaryOperator.maxBy(byLength)))); * } * * @param the type of the input elements @@ -1220,7 +1220,7 @@ public final class Collectors { * students to their grade point average: *
    {@code
          *     Map studentToGPA
    -     *         students.stream().collect(toMap(Functions.identity(),
    +     *         students.stream().collect(toMap(Function.identity(),
          *                                         student -> computeGPA(student)));
          * }
    * And the following produces a {@code Map} mapping a unique identifier to @@ -1228,7 +1228,7 @@ public final class Collectors { *
    {@code
          *     Map studentIdToStudent
          *         students.stream().collect(toMap(Student::getId,
    -     *                                         Functions.identity());
    +     *                                         Function.identity());
          * }
    * * @implNote @@ -1390,7 +1390,7 @@ public final class Collectors { * students to their grade point average: *
    {@code
          *     Map studentToGPA
    -     *         students.stream().collect(toMap(Functions.identity(),
    +     *         students.stream().collect(toMap(Function.identity(),
          *                                         student -> computeGPA(student)));
          * }
    * And the following produces a {@code Map} mapping a unique identifier to @@ -1398,7 +1398,7 @@ public final class Collectors { *
    {@code
          *     Map studentIdToStudent
          *         students.stream().collect(toConcurrentMap(Student::getId,
    -     *                                                   Functions.identity());
    +     *                                                   Function.identity());
          * }
    * *

    This is a {@link Collector.Characteristics#CONCURRENT concurrent} and diff --git a/jdk/src/share/classes/java/util/stream/package-info.java b/jdk/src/share/classes/java/util/stream/package-info.java index 016c86dd382..2353870425e 100644 --- a/jdk/src/share/classes/java/util/stream/package-info.java +++ b/jdk/src/share/classes/java/util/stream/package-info.java @@ -468,7 +468,7 @@ *

    {@code
      *     int sumOfWeights = widgets.stream()
      *                               .reduce(0,
    - *                                       (sum, b) -> sum + b.getWeight())
    + *                                       (sum, b) -> sum + b.getWeight(),
      *                                       Integer::sum);
      * }
    * though the explicit map-reduce form is more readable and therefore should diff --git a/jdk/src/share/classes/javax/crypto/CipherInputStream.java b/jdk/src/share/classes/javax/crypto/CipherInputStream.java index 0e80a6013d5..f9be4611d83 100644 --- a/jdk/src/share/classes/javax/crypto/CipherInputStream.java +++ b/jdk/src/share/classes/javax/crypto/CipherInputStream.java @@ -170,7 +170,6 @@ public class CipherInputStream extends FilterInputStream { * @return the next byte of data, or -1 if the end of the * stream is reached. * @exception IOException if an I/O error occurs. - * @since JCE1.2 */ public int read() throws IOException { if (ostart >= ofinish) { @@ -196,7 +195,6 @@ public class CipherInputStream extends FilterInputStream { * the stream has been reached. * @exception IOException if an I/O error occurs. * @see java.io.InputStream#read(byte[], int, int) - * @since JCE1.2 */ public int read(byte b[]) throws IOException { return read(b, 0, b.length); @@ -217,7 +215,6 @@ public class CipherInputStream extends FilterInputStream { * the stream has been reached. * @exception IOException if an I/O error occurs. * @see java.io.InputStream#read() - * @since JCE1.2 */ public int read(byte b[], int off, int len) throws IOException { if (ostart >= ofinish) { @@ -254,7 +251,6 @@ public class CipherInputStream extends FilterInputStream { * @param n the number of bytes to be skipped. * @return the actual number of bytes skipped. * @exception IOException if an I/O error occurs. - * @since JCE1.2 */ public long skip(long n) throws IOException { int available = ofinish - ostart; @@ -277,7 +273,6 @@ public class CipherInputStream extends FilterInputStream { * @return the number of bytes that can be read from this input stream * without blocking. * @exception IOException if an I/O error occurs. - * @since JCE1.2 */ public int available() throws IOException { return (ofinish - ostart); @@ -292,7 +287,6 @@ public class CipherInputStream extends FilterInputStream { * stream. * * @exception IOException if an I/O error occurs. - * @since JCE1.2 */ public void close() throws IOException { if (closed) { @@ -321,7 +315,6 @@ public class CipherInputStream extends FilterInputStream { * mark and reset methods. * @see java.io.InputStream#mark(int) * @see java.io.InputStream#reset() - * @since JCE1.2 */ public boolean markSupported() { return false; diff --git a/jdk/src/share/classes/javax/crypto/CipherOutputStream.java b/jdk/src/share/classes/javax/crypto/CipherOutputStream.java index 6b8d2734901..40e7dc49a6a 100644 --- a/jdk/src/share/classes/javax/crypto/CipherOutputStream.java +++ b/jdk/src/share/classes/javax/crypto/CipherOutputStream.java @@ -114,7 +114,6 @@ public class CipherOutputStream extends FilterOutputStream { * * @param b the byte. * @exception IOException if an I/O error occurs. - * @since JCE1.2 */ public void write(int b) throws IOException { ibuffer[0] = (byte) b; @@ -138,7 +137,6 @@ public class CipherOutputStream extends FilterOutputStream { * @exception NullPointerException if b is null. * @exception IOException if an I/O error occurs. * @see javax.crypto.CipherOutputStream#write(byte[], int, int) - * @since JCE1.2 */ public void write(byte b[]) throws IOException { write(b, 0, b.length); @@ -152,7 +150,6 @@ public class CipherOutputStream extends FilterOutputStream { * @param off the start offset in the data. * @param len the number of bytes to write. * @exception IOException if an I/O error occurs. - * @since JCE1.2 */ public void write(byte b[], int off, int len) throws IOException { obuffer = cipher.update(b, off, len); @@ -174,7 +171,6 @@ public class CipherOutputStream extends FilterOutputStream { * the cipher's block size, no bytes will be written out. * * @exception IOException if an I/O error occurs. - * @since JCE1.2 */ public void flush() throws IOException { if (obuffer != null) { @@ -198,7 +194,6 @@ public class CipherOutputStream extends FilterOutputStream { * stream. * * @exception IOException if an I/O error occurs. - * @since JCE1.2 */ public void close() throws IOException { if (closed) { diff --git a/jdk/src/share/classes/javax/crypto/spec/SecretKeySpec.java b/jdk/src/share/classes/javax/crypto/spec/SecretKeySpec.java index aedd9ca130c..94c35e0b80d 100644 --- a/jdk/src/share/classes/javax/crypto/spec/SecretKeySpec.java +++ b/jdk/src/share/classes/javax/crypto/spec/SecretKeySpec.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,6 +26,7 @@ package javax.crypto.spec; import java.security.spec.KeySpec; +import java.util.Locale; import javax.crypto.SecretKey; /** @@ -194,7 +195,8 @@ public class SecretKeySpec implements KeySpec, SecretKey { if (this.algorithm.equalsIgnoreCase("TripleDES")) return (retval ^= "desede".hashCode()); else - return (retval ^= this.algorithm.toLowerCase().hashCode()); + return (retval ^= + this.algorithm.toLowerCase(Locale.ENGLISH).hashCode()); } /** diff --git a/jdk/src/share/classes/javax/imageio/stream/ImageInputStreamImpl.java b/jdk/src/share/classes/javax/imageio/stream/ImageInputStreamImpl.java index 46d7748732c..5d2484017cb 100644 --- a/jdk/src/share/classes/javax/imageio/stream/ImageInputStreamImpl.java +++ b/jdk/src/share/classes/javax/imageio/stream/ImageInputStreamImpl.java @@ -289,7 +289,7 @@ public abstract class ImageInputStreamImpl implements ImageInputStream { } public String readLine() throws IOException { - StringBuffer input = new StringBuffer(); + StringBuilder input = new StringBuilder(); int c = -1; boolean eol = false; diff --git a/jdk/src/share/classes/javax/management/loading/MLet.java b/jdk/src/share/classes/javax/management/loading/MLet.java index ac80c38b93c..54f2a872512 100644 --- a/jdk/src/share/classes/javax/management/loading/MLet.java +++ b/jdk/src/share/classes/javax/management/loading/MLet.java @@ -1307,11 +1307,11 @@ public class MLet extends java.net.URLClassLoader if (type.compareTo("java.lang.Boolean") == 0) return Boolean.valueOf(param); if (type.compareTo("java.lang.Byte") == 0) - return new Byte(param); + return Byte.valueOf(param); if (type.compareTo("java.lang.Short") == 0) - return new Short(param); + return Short.valueOf(param); if (type.compareTo("java.lang.Long") == 0) - return new Long(param); + return Long.valueOf(param); if (type.compareTo("java.lang.Integer") == 0) return new Integer(param); if (type.compareTo("java.lang.Float") == 0) diff --git a/jdk/src/share/classes/javax/management/modelmbean/RequiredModelMBean.java b/jdk/src/share/classes/javax/management/modelmbean/RequiredModelMBean.java index 869a2c8cdc8..d9323203a03 100644 --- a/jdk/src/share/classes/javax/management/modelmbean/RequiredModelMBean.java +++ b/jdk/src/share/classes/javax/management/modelmbean/RequiredModelMBean.java @@ -544,7 +544,7 @@ public class RequiredModelMBean } // convert seconds to milliseconds for time comparison - currencyPeriod = ((new Long(expTime)).longValue()) * 1000; + currencyPeriod = Long.parseLong(expTime) * 1000; if (currencyPeriod < 0) { /* if currencyTimeLimit is -1 then value is never cached */ returnCachedValue = false; @@ -580,7 +580,7 @@ public class RequiredModelMBean if (tStamp == null) tStamp = "0"; - long lastTime = (new Long(tStamp)).longValue(); + long lastTime = Long.parseLong(tStamp); if (tracing) { MODELMBEAN_LOGGER.logp(Level.FINER, diff --git a/jdk/src/share/classes/javax/naming/BinaryRefAddr.java b/jdk/src/share/classes/javax/naming/BinaryRefAddr.java index 214e2aaa7f9..9061e2198de 100644 --- a/jdk/src/share/classes/javax/naming/BinaryRefAddr.java +++ b/jdk/src/share/classes/javax/naming/BinaryRefAddr.java @@ -165,7 +165,7 @@ public class BinaryRefAddr extends RefAddr { * @return The non-null string representation of this address. */ public String toString(){ - StringBuffer str = new StringBuffer("Address Type: " + addrType + "\n"); + StringBuilder str = new StringBuilder("Address Type: " + addrType + "\n"); str.append("AddressContents: "); for (int i = 0; i[] getUnsupportedAttributes(); /** * Returns the array of printing attributes for which the Print Service diff --git a/jdk/src/share/classes/javax/print/DocFlavor.java b/jdk/src/share/classes/javax/print/DocFlavor.java index d016cb7edb8..eac9d38954d 100644 --- a/jdk/src/share/classes/javax/print/DocFlavor.java +++ b/jdk/src/share/classes/javax/print/DocFlavor.java @@ -545,8 +545,7 @@ public class DocFlavor implements Serializable, Cloneable { * @exception NullPointerException if paramName is null. */ public String getParameter(String paramName) { - return - (String)myMimeType.getParameterMap().get(paramName.toLowerCase()); + return myMimeType.getParameterMap().get(paramName.toLowerCase()); } /** diff --git a/jdk/src/share/classes/javax/print/MimeType.java b/jdk/src/share/classes/javax/print/MimeType.java index 14251b59bda..87891f655b7 100644 --- a/jdk/src/share/classes/javax/print/MimeType.java +++ b/jdk/src/share/classes/javax/print/MimeType.java @@ -117,18 +117,18 @@ class MimeType implements Serializable, Cloneable { /** * Parameter map entry. */ - private class ParameterMapEntry implements Map.Entry { + private class ParameterMapEntry implements Map.Entry { private int myIndex; public ParameterMapEntry(int theIndex) { myIndex = theIndex; } - public Object getKey(){ + public String getKey(){ return myPieces[myIndex]; } - public Object getValue(){ + public String getValue(){ return myPieces[myIndex+1]; } - public Object setValue (Object value) { + public String setValue (String value) { throw new UnsupportedOperationException(); } public boolean equals(Object o) { @@ -145,12 +145,12 @@ class MimeType implements Serializable, Cloneable { /** * Parameter map entry set iterator. */ - private class ParameterMapEntrySetIterator implements Iterator { + private class ParameterMapEntrySetIterator implements Iterator> { private int myIndex = 2; public boolean hasNext() { return myIndex < myPieces.length; } - public Object next() { + public Map.Entry next() { if (hasNext()) { ParameterMapEntry result = new ParameterMapEntry (myIndex); myIndex += 2; @@ -167,8 +167,8 @@ class MimeType implements Serializable, Cloneable { /** * Parameter map entry set. */ - private class ParameterMapEntrySet extends AbstractSet { - public Iterator iterator() { + private class ParameterMapEntrySet extends AbstractSet> { + public Iterator> iterator() { return new ParameterMapEntrySetIterator(); } public int size() { @@ -179,8 +179,8 @@ class MimeType implements Serializable, Cloneable { /** * Parameter map. */ - private class ParameterMap extends AbstractMap { - public Set entrySet() { + private class ParameterMap extends AbstractMap { + public Set> entrySet() { if (myEntrySet == null) { myEntrySet = new ParameterMapEntrySet(); } @@ -234,7 +234,7 @@ class MimeType implements Serializable, Cloneable { * * @return Parameter map for this MIME type object. */ - public Map getParameterMap() { + public Map getParameterMap() { if (myParameterMap == null) { myParameterMap = new ParameterMap(); } @@ -285,7 +285,7 @@ class MimeType implements Serializable, Cloneable { */ private String getStringValue() { if (myStringValue == null) { - StringBuffer result = new StringBuffer(); + StringBuilder result = new StringBuilder(); result.append (myPieces[0]); result.append ('/'); result.append (myPieces[1]); @@ -510,7 +510,7 @@ class MimeType implements Serializable, Cloneable { int n = s.length(); int i; char c; - StringBuffer result = new StringBuffer (n+2); + StringBuilder result = new StringBuilder (n+2); result.append ('\"'); for (i = 0; i < n; ++ i) { c = s.charAt (i); @@ -548,7 +548,7 @@ class MimeType implements Serializable, Cloneable { } LexicalAnalyzer theLexer = new LexicalAnalyzer (s); int theLexemeType; - Vector thePieces = new Vector(); + Vector thePieces = new Vector<>(); boolean mediaTypeIsText = false; boolean parameterNameIsCharset = false; @@ -623,7 +623,7 @@ class MimeType implements Serializable, Cloneable { // Save the pieces. Parameters are not in ascending order yet. int n = thePieces.size(); - myPieces = (String[]) thePieces.toArray (new String [n]); + myPieces = thePieces.toArray (new String [n]); // Sort the parameters into ascending order using an insertion sort. int i, j; diff --git a/jdk/src/share/classes/javax/print/PrintServiceLookup.java b/jdk/src/share/classes/javax/print/PrintServiceLookup.java index a466a8a4b38..aece5d1205a 100644 --- a/jdk/src/share/classes/javax/print/PrintServiceLookup.java +++ b/jdk/src/share/classes/javax/print/PrintServiceLookup.java @@ -69,8 +69,8 @@ import java.util.ServiceConfigurationError; public abstract class PrintServiceLookup { static class Services { - private ArrayList listOfLookupServices = null; - private ArrayList registeredServices = null; + private ArrayList listOfLookupServices = null; + private ArrayList registeredServices = null; } private static Services getServicesForContext() { @@ -83,23 +83,23 @@ public abstract class PrintServiceLookup { return services; } - private static ArrayList getListOfLookupServices() { + private static ArrayList getListOfLookupServices() { return getServicesForContext().listOfLookupServices; } - private static ArrayList initListOfLookupServices() { - ArrayList listOfLookupServices = new ArrayList(); + private static ArrayList initListOfLookupServices() { + ArrayList listOfLookupServices = new ArrayList<>(); getServicesForContext().listOfLookupServices = listOfLookupServices; return listOfLookupServices; } - private static ArrayList getRegisteredServices() { + private static ArrayList getRegisteredServices() { return getServicesForContext().registeredServices; } - private static ArrayList initRegisteredServices() { - ArrayList registeredServices = new ArrayList(); + private static ArrayList initRegisteredServices() { + ArrayList registeredServices = new ArrayList<>(); getServicesForContext().registeredServices = registeredServices; return registeredServices; } @@ -120,8 +120,8 @@ public abstract class PrintServiceLookup { public static final PrintService[] lookupPrintServices(DocFlavor flavor, AttributeSet attributes) { - ArrayList list = getServices(flavor, attributes); - return (PrintService[])(list.toArray(new PrintService[list.size()])); + ArrayList list = getServices(flavor, attributes); + return list.toArray(new PrintService[list.size()]); } @@ -148,9 +148,8 @@ public abstract class PrintServiceLookup { public static final MultiDocPrintService[] lookupMultiDocPrintServices(DocFlavor[] flavors, AttributeSet attributes) { - ArrayList list = getMultiDocServices(flavors, attributes); - return (MultiDocPrintService[]) - list.toArray(new MultiDocPrintService[list.size()]); + ArrayList list = getMultiDocServices(flavors, attributes); + return list.toArray(new MultiDocPrintService[list.size()]); } @@ -177,10 +176,10 @@ public abstract class PrintServiceLookup { public static final PrintService lookupDefaultPrintService() { - Iterator psIterator = getAllLookupServices().iterator(); + Iterator psIterator = getAllLookupServices().iterator(); while (psIterator.hasNext()) { try { - PrintServiceLookup lus = (PrintServiceLookup)psIterator.next(); + PrintServiceLookup lus = psIterator.next(); PrintService service = lus.getDefaultPrintService(); if (service != null) { return service; @@ -208,7 +207,8 @@ public abstract class PrintServiceLookup { */ public static boolean registerServiceProvider(PrintServiceLookup sp) { synchronized (PrintServiceLookup.class) { - Iterator psIterator = getAllLookupServices().iterator(); + Iterator psIterator = + getAllLookupServices().iterator(); while (psIterator.hasNext()) { try { Object lus = psIterator.next(); @@ -249,7 +249,7 @@ public abstract class PrintServiceLookup { if (service instanceof StreamPrintService) { return false; } - ArrayList registeredServices = getRegisteredServices(); + ArrayList registeredServices = getRegisteredServices(); if (registeredServices == null) { registeredServices = initRegisteredServices(); } @@ -326,9 +326,9 @@ public abstract class PrintServiceLookup { */ public abstract PrintService getDefaultPrintService(); - private static ArrayList getAllLookupServices() { + private static ArrayList getAllLookupServices() { synchronized (PrintServiceLookup.class) { - ArrayList listOfLookupServices = getListOfLookupServices(); + ArrayList listOfLookupServices = getListOfLookupServices(); if (listOfLookupServices != null) { return listOfLookupServices; } else { @@ -336,12 +336,12 @@ public abstract class PrintServiceLookup { } try { java.security.AccessController.doPrivileged( - new java.security.PrivilegedExceptionAction() { + new java.security.PrivilegedExceptionAction() { public Object run() { Iterator iterator = ServiceLoader.load(PrintServiceLookup.class). iterator(); - ArrayList los = getListOfLookupServices(); + ArrayList los = getListOfLookupServices(); while (iterator.hasNext()) { try { los.add(iterator.next()); @@ -364,14 +364,14 @@ public abstract class PrintServiceLookup { } } - private static ArrayList getServices(DocFlavor flavor, - AttributeSet attributes) { + private static ArrayList getServices(DocFlavor flavor, + AttributeSet attributes) { - ArrayList listOfServices = new ArrayList(); - Iterator psIterator = getAllLookupServices().iterator(); + ArrayList listOfServices = new ArrayList<>(); + Iterator psIterator = getAllLookupServices().iterator(); while (psIterator.hasNext()) { try { - PrintServiceLookup lus = (PrintServiceLookup)psIterator.next(); + PrintServiceLookup lus = psIterator.next(); PrintService[] services=null; if (flavor == null && attributes == null) { try { @@ -391,7 +391,7 @@ public abstract class PrintServiceLookup { } } /* add any directly registered services */ - ArrayList registeredServices = null; + ArrayList registeredServices = null; try { SecurityManager security = System.getSecurityManager(); if (security != null) { @@ -401,8 +401,7 @@ public abstract class PrintServiceLookup { } catch (SecurityException se) { } if (registeredServices != null) { - PrintService[] services = (PrintService[]) - registeredServices.toArray( + PrintService[] services = registeredServices.toArray( new PrintService[registeredServices.size()]); for (int i=0; i getMultiDocServices(DocFlavor[] flavors, + AttributeSet attributes) { - ArrayList listOfServices = new ArrayList(); - Iterator psIterator = getAllLookupServices().iterator(); + ArrayList listOfServices = new ArrayList<>(); + Iterator psIterator = getAllLookupServices().iterator(); while (psIterator.hasNext()) { try { - PrintServiceLookup lus = (PrintServiceLookup)psIterator.next(); + PrintServiceLookup lus = psIterator.next(); MultiDocPrintService[] services = lus.getMultiDocPrintServices(flavors, attributes); if (services == null) { @@ -442,7 +441,7 @@ public abstract class PrintServiceLookup { } } /* add any directly registered services */ - ArrayList registeredServices = null; + ArrayList registeredServices = null; try { SecurityManager security = System.getSecurityManager(); if (security != null) { @@ -452,14 +451,13 @@ public abstract class PrintServiceLookup { } catch (Exception e) { } if (registeredServices != null) { - PrintService[] services = (PrintService[]) - registeredServices.toArray( - new PrintService[registeredServices.size()]); + PrintService[] services = + registeredServices.toArray(new PrintService[registeredServices.size()]); for (int i=0; i dstCategory = Destination.class; + Class amCategory = SunAlternateMedia.class; + Class fdCategory = Fidelity.class; if (attributes.containsKey(dstCategory) && !newas.containsKey(dstCategory)) @@ -315,7 +315,7 @@ public class ServiceUI { Attribute[] usAttrs = asUnsupported.toArray(); for (int i=0; i category = usAttrs[i].getCategory(); if (ps.isAttributeCategorySupported(category)) { Attribute attr = diff --git a/jdk/src/share/classes/javax/print/SimpleDoc.java b/jdk/src/share/classes/javax/print/SimpleDoc.java index 8bb812a66f4..3cf0d779086 100644 --- a/jdk/src/share/classes/javax/print/SimpleDoc.java +++ b/jdk/src/share/classes/javax/print/SimpleDoc.java @@ -89,7 +89,7 @@ public final class SimpleDoc implements Doc { throw new IllegalArgumentException("null argument(s)"); } - Class repClass = null; + Class repClass = null; try { String className = flavor.getRepresentationClassName(); sun.reflect.misc.ReflectUtil.checkPackageAccess(className); diff --git a/jdk/src/share/classes/javax/print/StreamPrintServiceFactory.java b/jdk/src/share/classes/javax/print/StreamPrintServiceFactory.java index 3199dac2985..dfa91a70fcb 100644 --- a/jdk/src/share/classes/javax/print/StreamPrintServiceFactory.java +++ b/jdk/src/share/classes/javax/print/StreamPrintServiceFactory.java @@ -59,7 +59,7 @@ import java.util.ServiceConfigurationError; public abstract class StreamPrintServiceFactory { static class Services { - private ArrayList listOfFactories = null; + private ArrayList listOfFactories = null; } private static Services getServices() { @@ -72,12 +72,12 @@ public abstract class StreamPrintServiceFactory { return services; } - private static ArrayList getListOfFactories() { + private static ArrayList getListOfFactories() { return getServices().listOfFactories; } - private static ArrayList initListOfFactories() { - ArrayList listOfFactories = new ArrayList(); + private static ArrayList initListOfFactories() { + ArrayList listOfFactories = new ArrayList<>(); getServices().listOfFactories = listOfFactories; return listOfFactories; } @@ -108,9 +108,8 @@ public abstract class StreamPrintServiceFactory { lookupStreamPrintServiceFactories(DocFlavor flavor, String outputMimeType) { - ArrayList list = getFactories(flavor, outputMimeType); - return (StreamPrintServiceFactory[]) - (list.toArray(new StreamPrintServiceFactory[list.size()])); + ArrayList list = getFactories(flavor, outputMimeType); + return list.toArray(new StreamPrintServiceFactory[list.size()]); } /** Queries the factory for the document format that is emitted @@ -162,10 +161,10 @@ public abstract class StreamPrintServiceFactory { public abstract StreamPrintService getPrintService(OutputStream out); - private static ArrayList getAllFactories() { + private static ArrayList getAllFactories() { synchronized (StreamPrintServiceFactory.class) { - ArrayList listOfFactories = getListOfFactories(); + ArrayList listOfFactories = getListOfFactories(); if (listOfFactories != null) { return listOfFactories; } else { @@ -174,12 +173,12 @@ public abstract class StreamPrintServiceFactory { try { java.security.AccessController.doPrivileged( - new java.security.PrivilegedExceptionAction() { + new java.security.PrivilegedExceptionAction() { public Object run() { Iterator iterator = ServiceLoader.load (StreamPrintServiceFactory.class).iterator(); - ArrayList lof = getListOfFactories(); + ArrayList lof = getListOfFactories(); while (iterator.hasNext()) { try { lof.add(iterator.next()); @@ -210,17 +209,16 @@ public abstract class StreamPrintServiceFactory { return false; } - private static ArrayList getFactories(DocFlavor flavor, String outType) { + private static ArrayList getFactories(DocFlavor flavor, String outType) { if (flavor == null && outType == null) { return getAllFactories(); } - ArrayList list = new ArrayList(); - Iterator iterator = getAllFactories().iterator(); + ArrayList list = new ArrayList<>(); + Iterator iterator = getAllFactories().iterator(); while (iterator.hasNext()) { - StreamPrintServiceFactory factory = - (StreamPrintServiceFactory)iterator.next(); + StreamPrintServiceFactory factory = iterator.next(); if ((outType == null || outType.equalsIgnoreCase(factory.getOutputFormat())) && (flavor == null || diff --git a/jdk/src/share/classes/javax/print/attribute/AttributeSetUtilities.java b/jdk/src/share/classes/javax/print/attribute/AttributeSetUtilities.java index 42ebc1f512d..2c5896f633f 100644 --- a/jdk/src/share/classes/javax/print/attribute/AttributeSetUtilities.java +++ b/jdk/src/share/classes/javax/print/attribute/AttributeSetUtilities.java @@ -523,7 +523,7 @@ public final class AttributeSetUtilities { public static Class verifyAttributeCategory(Object object, Class interfaceName) { - Class result = (Class) object; + Class result = (Class) object; if (interfaceName.isAssignableFrom (result)) { return result; } diff --git a/jdk/src/share/classes/javax/print/attribute/HashAttributeSet.java b/jdk/src/share/classes/javax/print/attribute/HashAttributeSet.java index a1995014525..7956794d304 100644 --- a/jdk/src/share/classes/javax/print/attribute/HashAttributeSet.java +++ b/jdk/src/share/classes/javax/print/attribute/HashAttributeSet.java @@ -48,13 +48,13 @@ public class HashAttributeSet implements AttributeSet, Serializable { * or a subinterface thereof. * @serial */ - private Class myInterface; + private Class myInterface; /* * A HashMap used by the implementation. * The serialised form doesn't include this instance variable. */ - private transient HashMap attrMap = new HashMap(); + private transient HashMap, Attribute> attrMap = new HashMap<>(); /** * Write the instance to a stream (ie serialize the object) @@ -82,7 +82,7 @@ public class HashAttributeSet implements AttributeSet, Serializable { throws ClassNotFoundException, IOException { s.defaultReadObject(); - attrMap = new HashMap(); + attrMap = new HashMap<>(); int count = s.readInt(); Attribute attr; for (int i = 0; i < count; i++) { @@ -274,10 +274,9 @@ public class HashAttributeSet implements AttributeSet, Serializable { * Attribute Attribute}. */ public Attribute get(Class category) { - return (Attribute) - attrMap.get(AttributeSetUtilities. - verifyAttributeCategory(category, - Attribute.class)); + return attrMap.get(AttributeSetUtilities. + verifyAttributeCategory(category, + Attribute.class)); } /** diff --git a/jdk/src/share/classes/javax/print/attribute/ResolutionSyntax.java b/jdk/src/share/classes/javax/print/attribute/ResolutionSyntax.java index f5a12408a6f..1089381d1c6 100644 --- a/jdk/src/share/classes/javax/print/attribute/ResolutionSyntax.java +++ b/jdk/src/share/classes/javax/print/attribute/ResolutionSyntax.java @@ -241,7 +241,7 @@ public abstract class ResolutionSyntax implements Serializable, Cloneable { * (unchecked exception) Thrown if {@code units < 1}. */ public String toString(int units, String unitsName) { - StringBuffer result = new StringBuffer(); + StringBuilder result = new StringBuilder(); result.append(getCrossFeedResolution (units)); result.append('x'); result.append(getFeedResolution (units)); @@ -326,7 +326,7 @@ public abstract class ResolutionSyntax implements Serializable, Cloneable { * resolution. The values are reported in the internal units of dphi. */ public String toString() { - StringBuffer result = new StringBuffer(); + StringBuilder result = new StringBuilder(); result.append(crossFeedResolution); result.append('x'); result.append(feedResolution); diff --git a/jdk/src/share/classes/javax/print/attribute/SetOfIntegerSyntax.java b/jdk/src/share/classes/javax/print/attribute/SetOfIntegerSyntax.java index 344a5941294..0aed773fe6e 100644 --- a/jdk/src/share/classes/javax/print/attribute/SetOfIntegerSyntax.java +++ b/jdk/src/share/classes/javax/print/attribute/SetOfIntegerSyntax.java @@ -112,7 +112,7 @@ public abstract class SetOfIntegerSyntax implements Serializable, Cloneable { private static int[][] parse(String members) { // Create vector to hold int[] elements, each element being one range // parsed out of members. - Vector theRanges = new Vector(); + Vector theRanges = new Vector<>(); // Run state machine over members. int n = (members == null ? 0 : members.length()); @@ -243,7 +243,7 @@ public abstract class SetOfIntegerSyntax implements Serializable, Cloneable { * Accumulate the given range (lb .. ub) into the canonical array form * into the given vector of int[] objects. */ - private static void accumulate(Vector ranges, int lb,int ub) { + private static void accumulate(Vector ranges, int lb,int ub) { // Make sure range is non-null. if (lb <= ub) { // Stick range at the back of the vector. @@ -253,10 +253,10 @@ public abstract class SetOfIntegerSyntax implements Serializable, Cloneable { // with the existing ranges. for (int j = ranges.size()-2; j >= 0; -- j) { // Get lower and upper bounds of the two ranges being compared. - int[] rangea = (int[]) ranges.elementAt (j); + int[] rangea = ranges.elementAt (j); int lba = rangea[0]; int uba = rangea[1]; - int[] rangeb = (int[]) ranges.elementAt (j+1); + int[] rangeb = ranges.elementAt (j+1); int lbb = rangeb[0]; int ubb = rangeb[1]; @@ -293,8 +293,8 @@ public abstract class SetOfIntegerSyntax implements Serializable, Cloneable { /** * Convert the given vector of int[] objects to canonical array form. */ - private static int[][] canonicalArrayForm(Vector ranges) { - return (int[][]) ranges.toArray (new int[ranges.size()][]); + private static int[][] canonicalArrayForm(Vector ranges) { + return ranges.toArray (new int[ranges.size()][]); } /** @@ -323,7 +323,7 @@ public abstract class SetOfIntegerSyntax implements Serializable, Cloneable { private static int[][] parse(int[][] members) { // Create vector to hold int[] elements, each element being one range // parsed out of members. - Vector ranges = new Vector(); + Vector ranges = new Vector<>(); // Process all integer groups in members. int n = (members == null ? 0 : members.length); @@ -540,7 +540,7 @@ public abstract class SetOfIntegerSyntax implements Serializable, Cloneable { * "i-j" otherwise. */ public String toString() { - StringBuffer result = new StringBuffer(); + StringBuilder result = new StringBuilder(); int n = members.length; for (int i = 0; i < n; i++) { if (i > 0) { diff --git a/jdk/src/share/classes/javax/print/attribute/Size2DSyntax.java b/jdk/src/share/classes/javax/print/attribute/Size2DSyntax.java index aac527fed26..0f6a5dfe6c4 100644 --- a/jdk/src/share/classes/javax/print/attribute/Size2DSyntax.java +++ b/jdk/src/share/classes/javax/print/attribute/Size2DSyntax.java @@ -257,7 +257,7 @@ public abstract class Size2DSyntax implements Serializable, Cloneable { * (unchecked exception) Thrown if {@code units < 1}. */ public String toString(int units, String unitsName) { - StringBuffer result = new StringBuffer(); + StringBuilder result = new StringBuilder(); result.append(getX (units)); result.append('x'); result.append(getY (units)); @@ -312,7 +312,7 @@ public abstract class Size2DSyntax implements Serializable, Cloneable { * The values are reported in the internal units of micrometers. */ public String toString() { - StringBuffer result = new StringBuffer(); + StringBuilder result = new StringBuilder(); result.append(x); result.append('x'); result.append(y); diff --git a/jdk/src/share/classes/javax/print/attribute/standard/DialogTypeSelection.java b/jdk/src/share/classes/javax/print/attribute/standard/DialogTypeSelection.java index 0a41fc23830..43cc15ee96a 100644 --- a/jdk/src/share/classes/javax/print/attribute/standard/DialogTypeSelection.java +++ b/jdk/src/share/classes/javax/print/attribute/standard/DialogTypeSelection.java @@ -26,6 +26,7 @@ package javax.print.attribute.standard; import javax.print.attribute.EnumSyntax; +import javax.print.attribute.Attribute; import javax.print.attribute.PrintRequestAttribute; /** @@ -110,7 +111,7 @@ public final class DialogTypeSelection extends EnumSyntax * @return Printing attribute class (category), an instance of class * {@link java.lang.Class java.lang.Class}. */ - public final Class getCategory() { + public final Class getCategory() { return DialogTypeSelection.class; } diff --git a/jdk/src/share/classes/javax/print/attribute/standard/MediaSize.java b/jdk/src/share/classes/javax/print/attribute/standard/MediaSize.java index e50960e5060..af173a8d6ea 100644 --- a/jdk/src/share/classes/javax/print/attribute/standard/MediaSize.java +++ b/jdk/src/share/classes/javax/print/attribute/standard/MediaSize.java @@ -56,9 +56,9 @@ public class MediaSize extends Size2DSyntax implements Attribute { private MediaSizeName mediaName; - private static HashMap mediaMap = new HashMap(100, 10); + private static HashMap mediaMap = new HashMap<>(100, 10); - private static Vector sizeVector = new Vector(100, 10); + private static Vector sizeVector = new Vector<>(100, 10); /** * Construct a new media size attribute from the given floating-point @@ -174,7 +174,7 @@ public class MediaSize extends Size2DSyntax implements Attribute { * with any size. */ public static MediaSize getMediaSizeForName(MediaSizeName media) { - return (MediaSize)mediaMap.get(media); + return mediaMap.get(media); } /** @@ -213,7 +213,7 @@ public class MediaSize extends Size2DSyntax implements Attribute { float diffy = y; for (int i=0; i < sizeVector.size() ; i++) { - MediaSize mediaSize = (MediaSize)sizeVector.elementAt(i); + MediaSize mediaSize = sizeVector.elementAt(i); dim = mediaSize.getSize(units); if (x == dim[0] && y == dim[1]) { match = mediaSize; diff --git a/jdk/src/share/classes/javax/print/attribute/standard/PrinterStateReasons.java b/jdk/src/share/classes/javax/print/attribute/standard/PrinterStateReasons.java index de695b78aa0..89b08f311ad 100644 --- a/jdk/src/share/classes/javax/print/attribute/standard/PrinterStateReasons.java +++ b/jdk/src/share/classes/javax/print/attribute/standard/PrinterStateReasons.java @@ -242,16 +242,18 @@ public final class PrinterStateReasons extends AbstractSet { private Severity mySeverity; - private Set myEntrySet; - public PrinterStateReasonSet(Severity severity, Set entrySet) { + private Set> myEntrySet; + + public PrinterStateReasonSet(Severity severity, + Set> entrySet) { mySeverity = severity; myEntrySet = entrySet; } public int size() { int result = 0; - Iterator iter = iterator(); + Iterator iter = iterator(); while (iter.hasNext()) { iter.next(); ++ result; @@ -259,19 +261,19 @@ public final class PrinterStateReasons return result; } - public Iterator iterator() { + public Iterator iterator() { return new PrinterStateReasonSetIterator(mySeverity, myEntrySet.iterator()); } } - private class PrinterStateReasonSetIterator implements Iterator { + private class PrinterStateReasonSetIterator implements Iterator { private Severity mySeverity; - private Iterator myIterator; - private Map.Entry myEntry; + private Iterator> myIterator; + private Map.Entry myEntry; public PrinterStateReasonSetIterator(Severity severity, - Iterator iterator) { + Iterator> iterator) { mySeverity = severity; myIterator = iterator; goToNext(); @@ -280,8 +282,8 @@ public final class PrinterStateReasons private void goToNext() { myEntry = null; while (myEntry == null && myIterator.hasNext()) { - myEntry = (Map.Entry) myIterator.next(); - if ((Severity) myEntry.getValue() != mySeverity) { + myEntry = myIterator.next(); + if (myEntry.getValue() != mySeverity) { myEntry = null; } } @@ -291,11 +293,11 @@ public final class PrinterStateReasons return myEntry != null; } - public Object next() { + public PrinterStateReason next() { if (myEntry == null) { throw new NoSuchElementException(); } - Object result = myEntry.getKey(); + PrinterStateReason result = myEntry.getKey(); goToNext(); return result; } diff --git a/jdk/src/share/classes/javax/security/auth/Subject.java b/jdk/src/share/classes/javax/security/auth/Subject.java index 2c9e8b8083f..e8ce12c9eee 100644 --- a/jdk/src/share/classes/javax/security/auth/Subject.java +++ b/jdk/src/share/classes/javax/security/auth/Subject.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 @@ -142,7 +142,9 @@ public final class Subject implements java.io.Serializable { *

    The newly constructed Sets check whether this {@code Subject} * has been set read-only before permitting subsequent modifications. * The newly created Sets also prevent illegal modifications - * by ensuring that callers have sufficient permissions. + * by ensuring that callers have sufficient permissions. These Sets + * also prohibit null elements, and attempts to add or query a null + * element will result in a {@code NullPointerException}. * *

    To modify the Principals Set, the caller must have * {@code AuthPermission("modifyPrincipals")}. @@ -170,7 +172,9 @@ public final class Subject implements java.io.Serializable { * These newly created Sets check whether this {@code Subject} * has been set read-only before permitting subsequent modifications. * The newly created Sets also prevent illegal modifications - * by ensuring that callers have sufficient permissions. + * by ensuring that callers have sufficient permissions. These Sets + * also prohibit null elements, and attempts to add or query a null + * element will result in a {@code NullPointerException}. * *

    To modify the Principals Set, the caller must have * {@code AuthPermission("modifyPrincipals")}. @@ -194,17 +198,16 @@ public final class Subject implements java.io.Serializable { * * @exception NullPointerException if the specified * {@code principals}, {@code pubCredentials}, - * or {@code privCredentials} are {@code null}. + * or {@code privCredentials} are {@code null}, + * or a null value exists within any of these three + * Sets. */ public Subject(boolean readOnly, Set principals, Set pubCredentials, Set privCredentials) { - - if (principals == null || - pubCredentials == null || - privCredentials == null) - throw new NullPointerException - (ResourcesMgr.getString("invalid.null.input.s.")); + collectionNullClean(principals); + collectionNullClean(pubCredentials); + collectionNullClean(privCredentials); this.principals = Collections.synchronizedSet(new SecureSet (this, PRINCIPAL_SET, principals)); @@ -287,18 +290,17 @@ public final class Subject implements java.io.Serializable { sm.checkPermission(AuthPermissionHolder.GET_SUBJECT_PERMISSION); } - if (acc == null) { - throw new NullPointerException(ResourcesMgr.getString + Objects.requireNonNull(acc, ResourcesMgr.getString ("invalid.null.AccessControlContext.provided")); - } // return the Subject from the DomainCombiner of the provided context return AccessController.doPrivileged (new java.security.PrivilegedAction() { public Subject run() { DomainCombiner dc = acc.getDomainCombiner(); - if (!(dc instanceof SubjectDomainCombiner)) + if (!(dc instanceof SubjectDomainCombiner)) { return null; + } SubjectDomainCombiner sdc = (SubjectDomainCombiner)dc; return sdc.getSubject(); } @@ -347,9 +349,9 @@ public final class Subject implements java.io.Serializable { if (sm != null) { sm.checkPermission(AuthPermissionHolder.DO_AS_PERMISSION); } - if (action == null) - throw new NullPointerException - (ResourcesMgr.getString("invalid.null.action.provided")); + + Objects.requireNonNull(action, + ResourcesMgr.getString("invalid.null.action.provided")); // set up the new Subject-based AccessControlContext // for doPrivileged @@ -410,9 +412,8 @@ public final class Subject implements java.io.Serializable { sm.checkPermission(AuthPermissionHolder.DO_AS_PERMISSION); } - if (action == null) - throw new NullPointerException - (ResourcesMgr.getString("invalid.null.action.provided")); + Objects.requireNonNull(action, + ResourcesMgr.getString("invalid.null.action.provided")); // set up the new Subject-based AccessControlContext for doPrivileged final AccessControlContext currentAcc = AccessController.getContext(); @@ -467,9 +468,8 @@ public final class Subject implements java.io.Serializable { sm.checkPermission(AuthPermissionHolder.DO_AS_PRIVILEGED_PERMISSION); } - if (action == null) - throw new NullPointerException - (ResourcesMgr.getString("invalid.null.action.provided")); + Objects.requireNonNull(action, + ResourcesMgr.getString("invalid.null.action.provided")); // set up the new Subject-based AccessControlContext // for doPrivileged @@ -534,9 +534,8 @@ public final class Subject implements java.io.Serializable { sm.checkPermission(AuthPermissionHolder.DO_AS_PRIVILEGED_PERMISSION); } - if (action == null) - throw new NullPointerException - (ResourcesMgr.getString("invalid.null.action.provided")); + Objects.requireNonNull(action, + ResourcesMgr.getString("invalid.null.action.provided")); // set up the new Subject-based AccessControlContext for doPrivileged final AccessControlContext callerAcc = @@ -557,13 +556,14 @@ public final class Subject implements java.io.Serializable { return java.security.AccessController.doPrivileged (new java.security.PrivilegedAction() { public AccessControlContext run() { - if (subject == null) + if (subject == null) { return new AccessControlContext(acc, null); - else + } else { return new AccessControlContext (acc, new SubjectDomainCombiner(subject)); } + } }); } @@ -615,9 +615,8 @@ public final class Subject implements java.io.Serializable { */ public Set getPrincipals(Class c) { - if (c == null) - throw new NullPointerException - (ResourcesMgr.getString("invalid.null.Class.provided")); + Objects.requireNonNull(c, + ResourcesMgr.getString("invalid.null.Class.provided")); // always return an empty Set instead of null // so LoginModules can add to the Set if necessary @@ -711,9 +710,8 @@ public final class Subject implements java.io.Serializable { */ public Set getPublicCredentials(Class c) { - if (c == null) - throw new NullPointerException - (ResourcesMgr.getString("invalid.null.Class.provided")); + Objects.requireNonNull(c, + ResourcesMgr.getString("invalid.null.Class.provided")); // always return an empty Set instead of null // so LoginModules can add to the Set if necessary @@ -758,9 +756,8 @@ public final class Subject implements java.io.Serializable { // would do is protect the set operations themselves // (like size()), which don't seem security-sensitive. - if (c == null) - throw new NullPointerException - (ResourcesMgr.getString("invalid.null.Class.provided")); + Objects.requireNonNull(c, + ResourcesMgr.getString("invalid.null.Class.provided")); // always return an empty Set instead of null // so LoginModules can add to the Set if necessary @@ -790,11 +787,13 @@ public final class Subject implements java.io.Serializable { */ public boolean equals(Object o) { - if (o == null) + if (o == null) { return false; + } - if (this == o) + if (this == o) { return true; + } if (o instanceof Subject) { @@ -969,11 +968,10 @@ public final class Subject implements java.io.Serializable { Set inputPrincs = (Set)gf.get("principals", null); + Objects.requireNonNull(inputPrincs, + ResourcesMgr.getString("invalid.null.input.s.")); + // Rewrap the principals into a SecureSet - if (inputPrincs == null) { - throw new NullPointerException - (ResourcesMgr.getString("invalid.null.input.s.")); - } try { principals = Collections.synchronizedSet(new SecureSet (this, PRINCIPAL_SET, inputPrincs)); @@ -992,14 +990,44 @@ public final class Subject implements java.io.Serializable { (new SecureSet(this, PRIV_CREDENTIAL_SET)); } + /** + * Tests for null-clean collections (both non-null reference and + * no null elements) + * + * @param coll A {@code Collection} to be tested for null references + * + * @exception NullPointerException if the specified collection is either + * {@code null} or contains a {@code null} element + */ + private static void collectionNullClean(Collection coll) { + boolean hasNullElements = false; + + Objects.requireNonNull(coll, + ResourcesMgr.getString("invalid.null.input.s.")); + + try { + hasNullElements = coll.contains(null); + } catch (NullPointerException npe) { + // A null-hostile collection may choose to throw + // NullPointerException if contains(null) is called on it + // rather than returning false. + // If this happens we know the collection is null-clean. + hasNullElements = false; + } finally { + if (hasNullElements) { + throw new NullPointerException + (ResourcesMgr.getString("invalid.null.input.s.")); + } + } + } + /** * Prevent modifications unless caller has permission. * * @serial include */ private static class SecureSet - extends AbstractSet - implements java.io.Serializable { + implements Set, java.io.Serializable { private static final long serialVersionUID = 7911754171111800359L; @@ -1098,6 +1126,9 @@ public final class Subject implements java.io.Serializable { public boolean add(E o) { + Objects.requireNonNull(o, + ResourcesMgr.getString("invalid.null.input.s.")); + if (subject.isReadOnly()) { throw new IllegalStateException (ResourcesMgr.getString("Subject.is.read.only")); @@ -1133,12 +1164,16 @@ public final class Subject implements java.io.Serializable { // check for duplicates if (!elements.contains(o)) return elements.add(o); - else + else { return false; } + } public boolean remove(Object o) { + Objects.requireNonNull(o, + ResourcesMgr.getString("invalid.null.input.s.")); + final Iterator e = iterator(); while (e.hasNext()) { E next; @@ -1153,12 +1188,7 @@ public final class Subject implements java.io.Serializable { }); } - if (next == null) { - if (o == null) { - e.remove(); - return true; - } - } else if (next.equals(o)) { + if (next.equals(o)) { e.remove(); return true; } @@ -1167,6 +1197,10 @@ public final class Subject implements java.io.Serializable { } public boolean contains(Object o) { + + Objects.requireNonNull(o, + ResourcesMgr.getString("invalid.null.input.s.")); + final Iterator e = iterator(); while (e.hasNext()) { E next; @@ -1194,19 +1228,28 @@ public final class Subject implements java.io.Serializable { }); } - if (next == null) { - if (o == null) { - return true; - } - } else if (next.equals(o)) { + if (next.equals(o)) { return true; } } return false; } + public boolean addAll(Collection c) { + boolean result = false; + + collectionNullClean(c); + + for (E item : c) { + result |= this.add(item); + } + + return result; + } + public boolean removeAll(Collection c) { - Objects.requireNonNull(c); + collectionNullClean(c); + boolean modified = false; final Iterator e = iterator(); while (e.hasNext()) { @@ -1224,30 +1267,34 @@ public final class Subject implements java.io.Serializable { Iterator ce = c.iterator(); while (ce.hasNext()) { - Object o = ce.next(); - if (next == null) { - if (o == null) { + if (next.equals(ce.next())) { e.remove(); modified = true; break; } - } else if (next.equals(o)) { - e.remove(); - modified = true; - break; - } } } return modified; } + public boolean containsAll(Collection c) { + collectionNullClean(c); + + for (Object item : c) { + if (this.contains(item) == false) { + return false; + } + } + + return true; + } + public boolean retainAll(Collection c) { - Objects.requireNonNull(c); + collectionNullClean(c); + boolean modified = false; - boolean retain = false; final Iterator e = iterator(); while (e.hasNext()) { - retain = false; E next; if (which != Subject.PRIV_CREDENTIAL_SET) { next = e.next(); @@ -1260,26 +1307,12 @@ public final class Subject implements java.io.Serializable { }); } - Iterator ce = c.iterator(); - while (ce.hasNext()) { - Object o = ce.next(); - if (next == null) { - if (o == null) { - retain = true; - break; - } - } else if (next.equals(o)) { - retain = true; - break; + if (c.contains(next) == false) { + e.remove(); + modified = true; } } - if (!retain) { - e.remove(); - retain = false; - modified = true; - } - } return modified; } @@ -1301,6 +1334,73 @@ public final class Subject implements java.io.Serializable { } } + public boolean isEmpty() { + return elements.isEmpty(); + } + + public Object[] toArray() { + final Iterator e = iterator(); + while (e.hasNext()) { + // The next() method performs a security manager check + // on each element in the SecureSet. If we make it all + // the way through we should be able to simply return + // element's toArray results. Otherwise we'll let + // the SecurityException pass up the call stack. + e.next(); + } + + return elements.toArray(); + } + + public T[] toArray(T[] a) { + final Iterator e = iterator(); + while (e.hasNext()) { + // The next() method performs a security manager check + // on each element in the SecureSet. If we make it all + // the way through we should be able to simply return + // element's toArray results. Otherwise we'll let + // the SecurityException pass up the call stack. + e.next(); + } + + return elements.toArray(a); + } + + public boolean equals(Object o) { + if (o == this) { + return true; + } + + if (!(o instanceof Set)) { + return false; + } + + Collection c = (Collection) o; + if (c.size() != size()) { + return false; + } + + try { + return containsAll(c); + } catch (ClassCastException unused) { + return false; + } catch (NullPointerException unused) { + return false; + } + } + + public int hashCode() { + int h = 0; + Iterator i = iterator(); + while (i.hasNext()) { + E obj = i.next(); + if (obj != null) { + h += obj.hashCode(); + } + } + return h; + } + /** * Writes this object out to a stream (i.e., serializes it). * @@ -1338,12 +1438,16 @@ public final class Subject implements java.io.Serializable { which = fields.get("which", 0); LinkedList tmp = (LinkedList) fields.get("elements", null); + + Subject.collectionNullClean(tmp); + if (tmp.getClass() != LinkedList.class) { elements = new LinkedList(tmp); } else { elements = tmp; } } + } /** diff --git a/jdk/src/share/classes/javax/security/auth/kerberos/KerberosTicket.java b/jdk/src/share/classes/javax/security/auth/kerberos/KerberosTicket.java index c9e2b283e98..da38df976e7 100644 --- a/jdk/src/share/classes/javax/security/auth/kerberos/KerberosTicket.java +++ b/jdk/src/share/classes/javax/security/auth/kerberos/KerberosTicket.java @@ -636,11 +636,11 @@ public class KerberosTicket implements Destroyable, Refreshable, public String toString() { if (destroyed) throw new IllegalStateException("This ticket is no longer valid"); - StringBuffer caddrBuf = new StringBuffer(); + StringBuilder caddrString = new StringBuilder(); if (clientAddresses != null) { for (int i = 0; i < clientAddresses.length; i++) { - caddrBuf.append("clientAddresses[" + i + "] = " + - clientAddresses[i].toString()); + caddrString.append("clientAddresses[" + i + "] = " + + clientAddresses[i].toString()); } } return ("Ticket (hex) = " + "\n" + @@ -660,7 +660,7 @@ public class KerberosTicket implements Destroyable, Refreshable, "End Time = " + endTime.toString() + "\n" + "Renew Till = " + String.valueOf(renewTill) + "\n" + "Client Addresses " + - (clientAddresses == null ? " Null " : caddrBuf.toString() + + (clientAddresses == null ? " Null " : caddrString.toString() + "\n")); } diff --git a/jdk/src/share/classes/javax/security/sasl/SaslClient.java b/jdk/src/share/classes/javax/security/sasl/SaslClient.java index c7258f4007b..a488132301c 100644 --- a/jdk/src/share/classes/javax/security/sasl/SaslClient.java +++ b/jdk/src/share/classes/javax/security/sasl/SaslClient.java @@ -204,6 +204,10 @@ public abstract interface SaslClient { * This method can be called only after the authentication exchange has * completed (i.e., when {@code isComplete()} returns true); otherwise, an * {@code IllegalStateException} is thrown. + *

    + * The {@link Sasl} class includes several well-known property names + * (For example, {@link Sasl#QOP}). A SASL provider can support other + * properties which are specific to the vendor and/or a mechanism. * * @param propName The non-null property name. * @return The value of the negotiated property. If null, the property was diff --git a/jdk/src/share/classes/javax/security/sasl/SaslServer.java b/jdk/src/share/classes/javax/security/sasl/SaslServer.java index 818ae999654..a80772cff11 100644 --- a/jdk/src/share/classes/javax/security/sasl/SaslServer.java +++ b/jdk/src/share/classes/javax/security/sasl/SaslServer.java @@ -196,6 +196,10 @@ public abstract interface SaslServer { * This method can be called only after the authentication exchange has * completed (i.e., when {@code isComplete()} returns true); otherwise, an * {@code IllegalStateException} is thrown. + *

    + * The {@link Sasl} class includes several well-known property names + * (For example, {@link Sasl#QOP}). A SASL provider can support other + * properties which are specific to the vendor and/or a mechanism. * * @param propName the property * @return The value of the negotiated property. If null, the property was diff --git a/jdk/src/share/classes/javax/sound/midi/MidiFileFormat.java b/jdk/src/share/classes/javax/sound/midi/MidiFileFormat.java index 0d496490dd0..c34bb6d1900 100644 --- a/jdk/src/share/classes/javax/sound/midi/MidiFileFormat.java +++ b/jdk/src/share/classes/javax/sound/midi/MidiFileFormat.java @@ -266,6 +266,7 @@ public class MidiFileFormat { * @see #getProperty(String) * @since 1.5 */ + @SuppressWarnings("unchecked") // Cast of result of clone public Map properties() { Map ret; if (properties == null) { diff --git a/jdk/src/share/classes/javax/sound/midi/MidiSystem.java b/jdk/src/share/classes/javax/sound/midi/MidiSystem.java index c661e23304d..d6ef5432978 100644 --- a/jdk/src/share/classes/javax/sound/midi/MidiSystem.java +++ b/jdk/src/share/classes/javax/sound/midi/MidiSystem.java @@ -187,17 +187,17 @@ public class MidiSystem { * an array of length 0 is returned. */ public static MidiDevice.Info[] getMidiDeviceInfo() { - List allInfos = new ArrayList(); - List providers = getMidiDeviceProviders(); + List allInfos = new ArrayList<>(); + List providers = getMidiDeviceProviders(); for(int i = 0; i < providers.size(); i++) { - MidiDeviceProvider provider = (MidiDeviceProvider) providers.get(i); + MidiDeviceProvider provider = providers.get(i); MidiDevice.Info[] tmpinfo = provider.getDeviceInfo(); for (int j = 0; j < tmpinfo.length; j++) { allInfos.add( tmpinfo[j] ); } } - MidiDevice.Info[] infosArray = (MidiDevice.Info[]) allInfos.toArray(new MidiDevice.Info[0]); + MidiDevice.Info[] infosArray = allInfos.toArray(new MidiDevice.Info[0]); return infosArray; } @@ -214,10 +214,10 @@ public class MidiSystem { * @see #getMidiDeviceInfo */ public static MidiDevice getMidiDevice(MidiDevice.Info info) throws MidiUnavailableException { - List providers = getMidiDeviceProviders(); + List providers = getMidiDeviceProviders(); for(int i = 0; i < providers.size(); i++) { - MidiDeviceProvider provider = (MidiDeviceProvider) providers.get(i); + MidiDeviceProvider provider = providers.get(i); if (provider.isDeviceSupported(info)) { MidiDevice device = provider.getDevice(info); return device; @@ -528,10 +528,10 @@ public class MidiSystem { SoundbankReader sp = null; Soundbank s = null; - List providers = getSoundbankReaders(); + List providers = getSoundbankReaders(); for(int i = 0; i < providers.size(); i++) { - sp = (SoundbankReader)providers.get(i); + sp = providers.get(i); s = sp.getSoundbank(stream); if( s!= null) { @@ -559,10 +559,10 @@ public class MidiSystem { SoundbankReader sp = null; Soundbank s = null; - List providers = getSoundbankReaders(); + List providers = getSoundbankReaders(); for(int i = 0; i < providers.size(); i++) { - sp = (SoundbankReader)providers.get(i); + sp = providers.get(i); s = sp.getSoundbank(url); if( s!= null) { @@ -591,10 +591,10 @@ public class MidiSystem { SoundbankReader sp = null; Soundbank s = null; - List providers = getSoundbankReaders(); + List providers = getSoundbankReaders(); for(int i = 0; i < providers.size(); i++) { - sp = (SoundbankReader)providers.get(i); + sp = providers.get(i); s = sp.getSoundbank(file); if( s!= null) { @@ -641,11 +641,11 @@ public class MidiSystem { public static MidiFileFormat getMidiFileFormat(InputStream stream) throws InvalidMidiDataException, IOException { - List providers = getMidiFileReaders(); + List providers = getMidiFileReaders(); MidiFileFormat format = null; for(int i = 0; i < providers.size(); i++) { - MidiFileReader reader = (MidiFileReader) providers.get(i); + MidiFileReader reader = providers.get(i); try { format = reader.getMidiFileFormat( stream ); // throws IOException break; @@ -687,11 +687,11 @@ public class MidiSystem { public static MidiFileFormat getMidiFileFormat(URL url) throws InvalidMidiDataException, IOException { - List providers = getMidiFileReaders(); + List providers = getMidiFileReaders(); MidiFileFormat format = null; for(int i = 0; i < providers.size(); i++) { - MidiFileReader reader = (MidiFileReader) providers.get(i); + MidiFileReader reader = providers.get(i); try { format = reader.getMidiFileFormat( url ); // throws IOException break; @@ -733,11 +733,11 @@ public class MidiSystem { public static MidiFileFormat getMidiFileFormat(File file) throws InvalidMidiDataException, IOException { - List providers = getMidiFileReaders(); + List providers = getMidiFileReaders(); MidiFileFormat format = null; for(int i = 0; i < providers.size(); i++) { - MidiFileReader reader = (MidiFileReader) providers.get(i); + MidiFileReader reader = providers.get(i); try { format = reader.getMidiFileFormat( file ); // throws IOException break; @@ -788,11 +788,11 @@ public class MidiSystem { public static Sequence getSequence(InputStream stream) throws InvalidMidiDataException, IOException { - List providers = getMidiFileReaders(); + List providers = getMidiFileReaders(); Sequence sequence = null; for(int i = 0; i < providers.size(); i++) { - MidiFileReader reader = (MidiFileReader) providers.get(i); + MidiFileReader reader = providers.get(i); try { sequence = reader.getSequence( stream ); // throws IOException break; @@ -832,11 +832,11 @@ public class MidiSystem { public static Sequence getSequence(URL url) throws InvalidMidiDataException, IOException { - List providers = getMidiFileReaders(); + List providers = getMidiFileReaders(); Sequence sequence = null; for(int i = 0; i < providers.size(); i++) { - MidiFileReader reader = (MidiFileReader) providers.get(i); + MidiFileReader reader = providers.get(i); try { sequence = reader.getSequence( url ); // throws IOException break; @@ -876,11 +876,11 @@ public class MidiSystem { public static Sequence getSequence(File file) throws InvalidMidiDataException, IOException { - List providers = getMidiFileReaders(); + List providers = getMidiFileReaders(); Sequence sequence = null; for(int i = 0; i < providers.size(); i++) { - MidiFileReader reader = (MidiFileReader) providers.get(i); + MidiFileReader reader = providers.get(i); try { sequence = reader.getSequence( file ); // throws IOException break; @@ -905,13 +905,13 @@ public class MidiSystem { */ public static int[] getMidiFileTypes() { - List providers = getMidiFileWriters(); - Set allTypes = new HashSet(); + List providers = getMidiFileWriters(); + Set allTypes = new HashSet<>(); // gather from all the providers for (int i = 0; i < providers.size(); i++ ) { - MidiFileWriter writer = (MidiFileWriter) providers.get(i); + MidiFileWriter writer = providers.get(i); int[] types = writer.getMidiFileTypes(); for (int j = 0; j < types.length; j++ ) { allTypes.add(new Integer(types[j])); @@ -919,9 +919,9 @@ public class MidiSystem { } int resultTypes[] = new int[allTypes.size()]; int index = 0; - Iterator iterator = allTypes.iterator(); + Iterator iterator = allTypes.iterator(); while (iterator.hasNext()) { - Integer integer = (Integer) iterator.next(); + Integer integer = iterator.next(); resultTypes[index++] = integer.intValue(); } return resultTypes; @@ -937,10 +937,10 @@ public class MidiSystem { */ public static boolean isFileTypeSupported(int fileType) { - List providers = getMidiFileWriters(); + List providers = getMidiFileWriters(); for (int i = 0; i < providers.size(); i++ ) { - MidiFileWriter writer = (MidiFileWriter) providers.get(i); + MidiFileWriter writer = providers.get(i); if( writer.isFileTypeSupported(fileType)) { return true; } @@ -959,13 +959,13 @@ public class MidiSystem { */ public static int[] getMidiFileTypes(Sequence sequence) { - List providers = getMidiFileWriters(); - Set allTypes = new HashSet(); + List providers = getMidiFileWriters(); + Set allTypes = new HashSet<>(); // gather from all the providers for (int i = 0; i < providers.size(); i++ ) { - MidiFileWriter writer = (MidiFileWriter) providers.get(i); + MidiFileWriter writer = providers.get(i); int[] types = writer.getMidiFileTypes(sequence); for (int j = 0; j < types.length; j++ ) { allTypes.add(new Integer(types[j])); @@ -973,9 +973,9 @@ public class MidiSystem { } int resultTypes[] = new int[allTypes.size()]; int index = 0; - Iterator iterator = allTypes.iterator(); + Iterator iterator = allTypes.iterator(); while (iterator.hasNext()) { - Integer integer = (Integer) iterator.next(); + Integer integer = iterator.next(); resultTypes[index++] = integer.intValue(); } return resultTypes; @@ -993,10 +993,10 @@ public class MidiSystem { */ public static boolean isFileTypeSupported(int fileType, Sequence sequence) { - List providers = getMidiFileWriters(); + List providers = getMidiFileWriters(); for (int i = 0; i < providers.size(); i++ ) { - MidiFileWriter writer = (MidiFileWriter) providers.get(i); + MidiFileWriter writer = providers.get(i); if( writer.isFileTypeSupported(fileType,sequence)) { return true; } @@ -1020,12 +1020,12 @@ public class MidiSystem { */ public static int write(Sequence in, int fileType, OutputStream out) throws IOException { - List providers = getMidiFileWriters(); + List providers = getMidiFileWriters(); //$$fb 2002-04-17: Fix for 4635287: Standard MidiFileWriter cannot write empty Sequences int bytesWritten = -2; for (int i = 0; i < providers.size(); i++ ) { - MidiFileWriter writer = (MidiFileWriter) providers.get(i); + MidiFileWriter writer = providers.get(i); if( writer.isFileTypeSupported( fileType, in ) ) { bytesWritten = writer.write(in, fileType, out); @@ -1054,12 +1054,12 @@ public class MidiSystem { */ public static int write(Sequence in, int type, File out) throws IOException { - List providers = getMidiFileWriters(); + List providers = getMidiFileWriters(); //$$fb 2002-04-17: Fix for 4635287: Standard MidiFileWriter cannot write empty Sequences int bytesWritten = -2; for (int i = 0; i < providers.size(); i++ ) { - MidiFileWriter writer = (MidiFileWriter) providers.get(i); + MidiFileWriter writer = providers.get(i); if( writer.isFileTypeSupported( type, in ) ) { bytesWritten = writer.write(in, type, out); @@ -1075,24 +1075,24 @@ public class MidiSystem { // HELPER METHODS - - private static List getMidiDeviceProviders() { - return getProviders(MidiDeviceProvider.class); + @SuppressWarnings("unchecked") + private static List getMidiDeviceProviders() { + return (List) getProviders(MidiDeviceProvider.class); } - - private static List getSoundbankReaders() { - return getProviders(SoundbankReader.class); + @SuppressWarnings("unchecked") + private static List getSoundbankReaders() { + return (List) getProviders(SoundbankReader.class); } - - private static List getMidiFileWriters() { - return getProviders(MidiFileWriter.class); + @SuppressWarnings("unchecked") + private static List getMidiFileWriters() { + return (List) getProviders(MidiFileWriter.class); } - - private static List getMidiFileReaders() { - return getProviders(MidiFileReader.class); + @SuppressWarnings("unchecked") + private static List getMidiFileReaders() { + return (List) getProviders(MidiFileReader.class); } @@ -1109,7 +1109,7 @@ public class MidiSystem { * Sequencer.class, Receiver.class or Transmitter.class. * @throws MidiUnavalableException on failure. */ - private static MidiDevice getDefaultDeviceWrapper(Class deviceClass) + private static MidiDevice getDefaultDeviceWrapper(Class deviceClass) throws MidiUnavailableException{ try { return getDefaultDevice(deviceClass); @@ -1128,8 +1128,8 @@ public class MidiSystem { * Sequencer.class, Receiver.class or Transmitter.class. * @throws IllegalArgumentException on failure. */ - private static MidiDevice getDefaultDevice(Class deviceClass) { - List providers = getMidiDeviceProviders(); + private static MidiDevice getDefaultDevice(Class deviceClass) { + List providers = getMidiDeviceProviders(); String providerClassName = JDK13Services.getDefaultProviderClassName(deviceClass); String instanceName = JDK13Services.getDefaultInstanceName(deviceClass); MidiDevice device; @@ -1179,9 +1179,10 @@ public class MidiSystem { @return A MidiDeviceProvider of the requested class, or null if none is found. */ - private static MidiDeviceProvider getNamedProvider(String providerClassName, List providers) { + private static MidiDeviceProvider getNamedProvider(String providerClassName, + List providers) { for(int i = 0; i < providers.size(); i++) { - MidiDeviceProvider provider = (MidiDeviceProvider) providers.get(i); + MidiDeviceProvider provider = providers.get(i); if (provider.getClass().getName().equals(providerClassName)) { return provider; } @@ -1200,7 +1201,7 @@ public class MidiSystem { */ private static MidiDevice getNamedDevice(String deviceName, MidiDeviceProvider provider, - Class deviceClass) { + Class deviceClass) { MidiDevice device; // try to get MIDI port device = getNamedDevice(deviceName, provider, deviceClass, @@ -1232,7 +1233,7 @@ public class MidiSystem { */ private static MidiDevice getNamedDevice(String deviceName, MidiDeviceProvider provider, - Class deviceClass, + Class deviceClass, boolean allowSynthesizer, boolean allowSequencer) { MidiDevice.Info[] infos = provider.getDeviceInfo(); @@ -1259,8 +1260,8 @@ public class MidiSystem { @return A Mixer matching the requirements, or null if none is found. */ private static MidiDevice getNamedDevice(String deviceName, - List providers, - Class deviceClass) { + List providers, + Class deviceClass) { MidiDevice device; // try to get MIDI port device = getNamedDevice(deviceName, providers, deviceClass, @@ -1292,12 +1293,12 @@ public class MidiSystem { @return A Mixer matching the requirements, or null if none is found. */ private static MidiDevice getNamedDevice(String deviceName, - List providers, - Class deviceClass, + List providers, + Class deviceClass, boolean allowSynthesizer, boolean allowSequencer) { for(int i = 0; i < providers.size(); i++) { - MidiDeviceProvider provider = (MidiDeviceProvider) providers.get(i); + MidiDeviceProvider provider = providers.get(i); MidiDevice device = getNamedDevice(deviceName, provider, deviceClass, allowSynthesizer, @@ -1318,7 +1319,7 @@ public class MidiSystem { appropriate device is found. */ private static MidiDevice getFirstDevice(MidiDeviceProvider provider, - Class deviceClass) { + Class deviceClass) { MidiDevice device; // try to get MIDI port device = getFirstDevice(provider, deviceClass, @@ -1348,7 +1349,7 @@ public class MidiSystem { appropriate device is found. */ private static MidiDevice getFirstDevice(MidiDeviceProvider provider, - Class deviceClass, + Class deviceClass, boolean allowSynthesizer, boolean allowSequencer) { MidiDevice.Info[] infos = provider.getDeviceInfo(); @@ -1371,8 +1372,8 @@ public class MidiSystem { @return A MidiDevice that is considered appropriate, or null if none is found. */ - private static MidiDevice getFirstDevice(List providers, - Class deviceClass) { + private static MidiDevice getFirstDevice(List providers, + Class deviceClass) { MidiDevice device; // try to get MIDI port device = getFirstDevice(providers, deviceClass, @@ -1402,12 +1403,12 @@ public class MidiSystem { @return A MidiDevice that is considered appropriate, or null if none is found. */ - private static MidiDevice getFirstDevice(List providers, - Class deviceClass, + private static MidiDevice getFirstDevice(List providers, + Class deviceClass, boolean allowSynthesizer, boolean allowSequencer) { for(int i = 0; i < providers.size(); i++) { - MidiDeviceProvider provider = (MidiDeviceProvider) providers.get(i); + MidiDeviceProvider provider = providers.get(i); MidiDevice device = getFirstDevice(provider, deviceClass, allowSynthesizer, allowSequencer); @@ -1441,11 +1442,11 @@ public class MidiSystem { rules given above, false otherwise. */ private static boolean isAppropriateDevice(MidiDevice device, - Class deviceClass, + Class deviceClass, boolean allowSynthesizer, boolean allowSequencer) { if (deviceClass.isInstance(device)) { - // This clause is for deviceClass being either Synthesizer + // This clause is for deviceClass being either Synthesizer // or Sequencer. return true; } else { @@ -1479,7 +1480,7 @@ public class MidiSystem { * @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); + private static List getProviders(Class providerClass) { + return JDK13Services.getProviders(providerClass); } } diff --git a/jdk/src/share/classes/javax/sound/midi/SoundbankResource.java b/jdk/src/share/classes/javax/sound/midi/SoundbankResource.java index 87c0864a627..52ba8f78feb 100644 --- a/jdk/src/share/classes/javax/sound/midi/SoundbankResource.java +++ b/jdk/src/share/classes/javax/sound/midi/SoundbankResource.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 @@ -83,7 +83,7 @@ public abstract class SoundbankResource { /** * The class used to represent the sample's data. */ - private final Class dataClass; + private final Class dataClass; /** diff --git a/jdk/src/share/classes/javax/sound/midi/Track.java b/jdk/src/share/classes/javax/sound/midi/Track.java index 4e54a8aa3dd..d9e0f438b6c 100644 --- a/jdk/src/share/classes/javax/sound/midi/Track.java +++ b/jdk/src/share/classes/javax/sound/midi/Track.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 @@ -66,10 +66,10 @@ public class Track { // TODO: use arrays for faster access // the list containing the events - private ArrayList eventsList = new ArrayList(); + private ArrayList eventsList = new ArrayList<>(); // use a hashset to detect duplicate events in add(MidiEvent) - private HashSet set = new HashSet(); + private HashSet set = new HashSet<>(); private MidiEvent eotEvent; @@ -108,7 +108,7 @@ public class Track { // get the last event MidiEvent lastEvent = null; if (eventsCount > 0) { - lastEvent = (MidiEvent) eventsList.get(eventsCount - 1); + lastEvent = eventsList.get(eventsCount - 1); } // sanity check that we have a correct end-of-track if (lastEvent != eotEvent) { @@ -148,7 +148,7 @@ public class Track { // tick order int i = eventsCount; for ( ; i > 0; i--) { - if (event.getTick() >= ((MidiEvent)eventsList.get(i-1)).getTick()) { + if (event.getTick() >= (eventsList.get(i-1)).getTick()) { break; } } @@ -220,7 +220,7 @@ public class Track { public MidiEvent get(int index) throws ArrayIndexOutOfBoundsException { try { synchronized(eventsList) { - return (MidiEvent)eventsList.get(index); + return eventsList.get(index); } } catch (IndexOutOfBoundsException ioobe) { throw new ArrayIndexOutOfBoundsException(ioobe.getMessage()); @@ -253,7 +253,7 @@ public class Track { long ret = 0; synchronized (eventsList) { if (eventsList.size() > 0) { - ret = ((MidiEvent)eventsList.get(eventsList.size() - 1)).getTick(); + ret = (eventsList.get(eventsList.size() - 1)).getTick(); } } return ret; diff --git a/jdk/src/share/classes/javax/sound/sampled/AudioFileFormat.java b/jdk/src/share/classes/javax/sound/sampled/AudioFileFormat.java index 63f43dcc160..9c6ba5a3e4e 100644 --- a/jdk/src/share/classes/javax/sound/sampled/AudioFileFormat.java +++ b/jdk/src/share/classes/javax/sound/sampled/AudioFileFormat.java @@ -25,36 +25,29 @@ package javax.sound.sampled; -import java.io.File; -import java.io.OutputStream; -import java.io.IOException; import java.util.Collections; import java.util.HashMap; import java.util.Map; - /** - * An instance of the AudioFileFormat class describes - * an audio file, including the file type, the file's length in bytes, - * the length in sample frames of the audio data contained in the file, - * and the format of the audio data. + * An instance of the {@code AudioFileFormat} class describes an audio file, + * including the file type, the file's length in bytes, the length in sample + * frames of the audio data contained in the file, and the format of the audio + * data. *

    - * The {@link AudioSystem} class includes methods for determining the format - * of an audio file, obtaining an audio input stream from an audio file, and + * The {@link AudioSystem} class includes methods for determining the format of + * an audio file, obtaining an audio input stream from an audio file, and * writing an audio file from an audio input stream. - * - *

    An AudioFileFormat 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, copyright, or file duration). - * 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: + *

    + * An {@code AudioFileFormat} 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, copyright, or file duration). + * 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: * * * @@ -104,17 +97,13 @@ import java.util.Map; */ public class AudioFileFormat { - - // INSTANCE VARIABLES - - /** * File type. */ private Type type; /** - * File length in bytes + * File length in bytes. */ private int byteLength; @@ -124,25 +113,26 @@ public class AudioFileFormat { private AudioFormat format; /** - * Audio data length in sample frames + * Audio data length in sample frames. */ private int frameLength; - - /** The set of properties */ + /** + * The set of properties. + */ private HashMap properties; - /** - * Constructs an audio file format object. - * This protected constructor is intended for use by providers of file-reading - * services when returning information about an audio file or about supported audio file - * formats. - * @param type the type of the audio file - * @param byteLength the length of the file in bytes, or AudioSystem.NOT_SPECIFIED - * @param format the format of the audio data contained in the file - * @param frameLength the audio data length in sample frames, or AudioSystem.NOT_SPECIFIED + * Constructs an audio file format object. This protected constructor is + * intended for use by providers of file-reading services when returning + * information about an audio file or about supported audio file formats. * + * @param type the type of the audio file + * @param byteLength the length of the file in bytes, or + * {@code AudioSystem.NOT_SPECIFIED} + * @param format the format of the audio data contained in the file + * @param frameLength the audio data length in sample frames, or + * {@code AudioSystem.NOT_SPECIFIED} * @see #getType */ protected AudioFileFormat(Type type, int byteLength, AudioFormat format, int frameLength) { @@ -154,14 +144,15 @@ public class AudioFileFormat { this.properties = null; } - /** - * Constructs an audio file format object. - * This public constructor may be used by applications to describe the - * properties of a requested audio file. - * @param type the type of the audio file - * @param format the format of the audio data contained in the file - * @param frameLength the audio data length in sample frames, or AudioSystem.NOT_SPECIFIED + * Constructs an audio file format object. This public constructor may be + * used by applications to describe the properties of a requested audio + * file. + * + * @param type the type of the audio file + * @param format the format of the audio data contained in the file + * @param frameLength the audio data length in sample frames, or + * {@code AudioSystem.NOT_SPECIFIED} */ public AudioFileFormat(Type type, AudioFormat format, int frameLength) { @@ -170,19 +161,16 @@ public class AudioFileFormat { } /** - * Construct an audio file format object with a set of - * defined properties. + * Construct an audio file format object with a set of defined properties. * This public constructor may be used by applications to describe the - * properties of a requested audio file. The properties map - * will be copied to prevent any changes to it. - * - * @param type the type of the audio file - * @param format the format of the audio data contained in the file - * @param frameLength the audio data length in sample frames, or - * AudioSystem.NOT_SPECIFIED - * @param properties a Map<String,Object> object - * with properties + * properties of a requested audio file. The properties map will be copied + * to prevent any changes to it. * + * @param type the type of the audio file + * @param format the format of the audio data contained in the file + * @param frameLength the audio data length in sample frames, or + * {@code AudioSystem.NOT_SPECIFIED} + * @param properties a {@code Map} object with properties * @since 1.5 */ public AudioFileFormat(Type type, AudioFormat format, @@ -191,11 +179,10 @@ public class AudioFileFormat { this.properties = new HashMap(properties); } - /** - * Obtains the audio file type, such as WAVE or AU. - * @return the audio file type + * Obtains the audio file type, such as {@code WAVE} or {@code AU}. * + * @return the audio file type * @see Type#WAVE * @see Type#AU * @see Type#AIFF @@ -207,7 +194,9 @@ public class AudioFileFormat { } /** - * Obtains the size in bytes of the entire audio file (not just its audio data). + * Obtains the size in bytes of the entire audio file (not just its audio + * data). + * * @return the audio file length in bytes * @see AudioSystem#NOT_SPECIFIED */ @@ -217,6 +206,7 @@ public class AudioFileFormat { /** * Obtains the format of the audio data contained in the audio file. + * * @return the audio data format */ public AudioFormat getFormat() { @@ -224,7 +214,9 @@ public class AudioFileFormat { } /** - * Obtains the length of the audio data contained in the file, expressed in sample frames. + * Obtains the length of the audio data contained in the file, expressed in + * sample frames. + * * @return the number of sample frames of audio data in the file * @see AudioSystem#NOT_SPECIFIED */ @@ -233,41 +225,35 @@ public class AudioFileFormat { } /** - * Obtain an unmodifiable map of properties. - * The concept of properties is further explained in - * the {@link AudioFileFormat 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 AudioFileFormat 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 */ - public Map properties() { + @SuppressWarnings("unchecked") // Cast of result of clone + public Map properties() { Map ret; if (properties == null) { - ret = new HashMap(0); + ret = new HashMap<>(0); } else { ret = (Map) (properties.clone()); } return Collections.unmodifiableMap(ret); } - /** - * Obtain the property value specified by the key. - * The concept of properties is further explained in - * the {@link AudioFileFormat 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 AudioFileFormat 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 */ @@ -278,11 +264,12 @@ public class AudioFileFormat { return properties.get(key); } - /** * Provides a string representation of the file format. + * * @return the file format as a string */ + @Override public String toString() { StringBuffer buf = new StringBuffer(); @@ -307,11 +294,9 @@ public class AudioFileFormat { return new String(buf); } - /** - * An instance of the Type class represents one of the - * standard types of audio file. Static instances are provided for the - * common types. + * An instance of the {@code Type} class represents one of the standard + * types of audio file. Static instances are provided for the common types. */ public static class Type { @@ -342,9 +327,6 @@ public class AudioFileFormat { */ public static final Type SND = new Type("SND", "snd"); - - // INSTANCE VARIABLES - /** * File type name. */ @@ -355,27 +337,22 @@ public class AudioFileFormat { */ private final String extension; - - // CONSTRUCTOR - /** * Constructs a file type. - * @param name the string that names the file type - * @param extension the string that commonly marks the file type - * without leading dot. + * + * @param name the string that names the file type + * @param extension the string that commonly marks the file type + * without leading dot */ public Type(String name, String extension) { - this.name = name; this.extension = extension; } - - // METHODS - /** - * Finalizes the equals method + * Finalizes the equals method. */ + @Override public final boolean equals(Object obj) { if (toString() == null) { return (obj != null) && (obj.toString() == null); @@ -387,8 +364,9 @@ public class AudioFileFormat { } /** - * Finalizes the hashCode method + * Finalizes the hashCode method. */ + @Override public final int hashCode() { if (toString() == null) { return 0; @@ -397,22 +375,23 @@ public class AudioFileFormat { } /** - * Provides the file type's name as the String representation - * of the file type. + * Provides the file type's name as the {@code String} representation of + * the file type. + * * @return the file type's name */ + @Override public final String toString() { return name; } /** * Obtains the common file name extension for this file type. + * * @return file type extension */ public String getExtension() { return extension; } - - } // class Type - -} // class AudioFileFormat + } +} diff --git a/jdk/src/share/classes/javax/sound/sampled/AudioFormat.java b/jdk/src/share/classes/javax/sound/sampled/AudioFormat.java index cd084fcd32d..39264aacf84 100644 --- a/jdk/src/share/classes/javax/sound/sampled/AudioFormat.java +++ b/jdk/src/share/classes/javax/sound/sampled/AudioFormat.java @@ -30,59 +30,63 @@ import java.util.HashMap; import java.util.Map; /** - * AudioFormat is the class that specifies a particular arrangement of data in a sound stream. - * By examining the information stored in the audio format, you can discover how to interpret the bits in the - * binary sound data. + * {@code AudioFormat} is the class that specifies a particular arrangement of + * data in a sound stream. By examining the information stored in the audio + * format, you can discover how to interpret the bits in the binary sound data. *

    - * Every data line has an audio format associated with its data stream. The audio format of a source (playback) data line indicates - * what kind of data the data line expects to receive for output. For a target (capture) data line, the audio format specifies the kind - * of the data that can be read from the line. - * Sound files also have audio formats, of course. The {@link AudioFileFormat} - * class encapsulates an AudioFormat in addition to other, - * file-specific information. Similarly, an {@link AudioInputStream} has an - * AudioFormat. + * Every data line has an audio format associated with its data stream. The + * audio format of a source (playback) data line indicates what kind of data the + * data line expects to receive for output. For a target (capture) data line, + * the audio format specifies the kind of the data that can be read from the + * line. + * Sound files also have audio formats, of course. The {@link AudioFileFormat} + * class encapsulates an {@code AudioFormat} in addition to other, file-specific + * information. Similarly, an {@link AudioInputStream} has an + * {@code AudioFormat}. *

    - * The AudioFormat class accommodates a number of common sound-file encoding techniques, including - * pulse-code modulation (PCM), mu-law encoding, and a-law encoding. These encoding techniques are predefined, - * but service providers can create new encoding types. - * The encoding that a specific format uses is named by its encoding field. - *

    - * In addition to the encoding, the audio format includes other properties that further specify the exact - * arrangement of the data. - * These include the number of channels, sample rate, sample size, byte order, frame rate, and frame size. - * Sounds may have different numbers of audio channels: one for mono, two for stereo. - * The sample rate measures how many "snapshots" (samples) of the sound pressure are taken per second, per channel. - * (If the sound is stereo rather than mono, two samples are actually measured at each instant of time: one for the left channel, - * and another for the right channel; however, the sample rate still measures the number per channel, so the rate is the same - * regardless of the number of channels. This is the standard use of the term.) - * The sample size indicates how many bits are used to store each snapshot; 8 and 16 are typical values. - * For 16-bit samples (or any other sample size larger than a byte), - * byte order is important; the bytes in each sample are arranged in - * either the "little-endian" or "big-endian" style. - * For encodings like PCM, a frame consists of the set of samples for all channels at a given - * point in time, and so the size of a frame (in bytes) is always equal to the size of a sample (in bytes) times - * the number of channels. However, with some other sorts of encodings a frame can contain - * a bundle of compressed data for a whole series of samples, as well as additional, non-sample - * data. For such encodings, the sample rate and sample size refer to the data after it is decoded into PCM, - * and so they are completely different from the frame rate and frame size. - * - *

    An AudioFormat 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 format specifications, like the bit rate for - * compressed formats. Properties are mainly used as a means - * to transport additional information of the audio format - * to and from the service providers. Therefore, properties - * are ignored in the {@link #matches(AudioFormat)} method. - * However, methods which rely on the installed service - * providers, like {@link AudioSystem#isConversionSupported - * (AudioFormat, AudioFormat) isConversionSupported} may consider - * properties, depending on the respective service provider - * implementation. - * - *

    The following table lists some common properties which - * service providers should use, if applicable: + * The {@code AudioFormat} class accommodates a number of common sound-file + * encoding techniques, including pulse-code modulation (PCM), mu-law encoding, + * and a-law encoding. These encoding techniques are predefined, but service + * providers can create new encoding types. The encoding that a specific format + * uses is named by its {@code encoding} field. + *

    + * In addition to the encoding, the audio format includes other properties that + * further specify the exact arrangement of the data. These include the number + * of channels, sample rate, sample size, byte order, frame rate, and frame + * size. Sounds may have different numbers of audio channels: one for mono, two + * for stereo. The sample rate measures how many "snapshots" (samples) of the + * sound pressure are taken per second, per channel. (If the sound is stereo + * rather than mono, two samples are actually measured at each instant of time: + * one for the left channel, and another for the right channel; however, the + * sample rate still measures the number per channel, so the rate is the same + * regardless of the number of channels. This is the standard use of the term.) + * The sample size indicates how many bits are used to store each snapshot; 8 + * and 16 are typical values. For 16-bit samples (or any other sample size + * larger than a byte), byte order is important; the bytes in each sample are + * arranged in either the "little-endian" or "big-endian" style. For encodings + * like PCM, a frame consists of the set of samples for all channels at a given + * point in time, and so the size of a frame (in bytes) is always equal to the + * size of a sample (in bytes) times the number of channels. However, with some + * other sorts of encodings a frame can contain a bundle of compressed data for + * a whole series of samples, as well as additional, non-sample data. For such + * encodings, the sample rate and sample size refer to the data after it is + * decoded into PCM, and so they are completely different from the frame rate + * and frame size. + *

    + * An {@code AudioFormat} 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 format + * specifications, like the bit rate for compressed formats. Properties are + * mainly used as a means to transport additional information of the audio + * format to and from the service providers. Therefore, properties are ignored + * in the {@link #matches(AudioFormat)} method. However, methods which rely on + * the installed service providers, like + * {@link AudioSystem#isConversionSupported (AudioFormat, AudioFormat) + * isConversionSupported} may consider properties, depending on the respective + * service provider implementation. + *

    + * The following table lists some common properties which service providers + * should use, if applicable: * *

    Audio File Format Properties
    * @@ -99,7 +103,7 @@ import java.util.Map; * * * - * * * @@ -108,11 +112,10 @@ import java.util.Map; * * *
    Audio Format Properties
    "vbr"{@link java.lang.Boolean Boolean}true, if the file is encoded in variable bit + * {@code true}, if the file is encoded in variable bit * rate (VBR)
    encoding/conversion quality, 1..100
    - * - *

    Vendors of service providers (plugins) are encouraged - * to seek information about other already established - * properties in third party plugins, and follow the same - * conventions. + *

    + * Vendors of service providers (plugins) are encouraged to seek information + * about other already established properties in third party plugins, and follow + * the same conventions. * * @author Kara Kytle * @author Florian Bomers @@ -124,16 +127,14 @@ import java.util.Map; */ public class AudioFormat { - // INSTANCE VARIABLES - - /** * The audio encoding technique used by this format. */ protected Encoding encoding; /** - * The number of samples played or recorded per second, for sounds that have this format. + * The number of samples played or recorded per second, for sounds that have + * this format. */ protected float sampleRate; @@ -153,34 +154,37 @@ public class AudioFormat { protected int frameSize; /** - * The number of frames played or recorded per second, for sounds that have this format. + * The number of frames played or recorded per second, for sounds that have + * this format. */ protected float frameRate; /** - * Indicates whether the audio data is stored in big-endian or little-endian order. + * Indicates whether the audio data is stored in big-endian or little-endian + * order. */ protected boolean bigEndian; - - /** The set of properties */ + /** + * The set of properties. + */ private HashMap properties; - /** - * Constructs an AudioFormat with the given parameters. - * The encoding specifies the convention used to represent the data. - * The other parameters are further explained in the {@link AudioFormat - * class description}. - * @param encoding the audio encoding technique - * @param sampleRate the number of samples per second - * @param sampleSizeInBits the number of bits in each sample - * @param channels the number of channels (1 for mono, 2 for stereo, and so on) - * @param frameSize the number of bytes in each frame - * @param frameRate the number of frames per second - * @param bigEndian indicates whether the data for a single sample - * is stored in big-endian byte order (false - * means little-endian) + * Constructs an {@code AudioFormat} with the given parameters. The encoding + * specifies the convention used to represent the data. The other parameters + * are further explained in the {@link AudioFormat class description}. + * + * @param encoding the audio encoding technique + * @param sampleRate the number of samples per second + * @param sampleSizeInBits the number of bits in each sample + * @param channels the number of channels (1 for mono, 2 for stereo, + * and so on) + * @param frameSize the number of bytes in each frame + * @param frameRate the number of frames per second + * @param bigEndian indicates whether the data for a single sample is + * stored in big-endian byte order ({@code false} means + * little-endian) */ public AudioFormat(Encoding encoding, float sampleRate, int sampleSizeInBits, int channels, int frameSize, float frameRate, boolean bigEndian) { @@ -195,25 +199,22 @@ public class AudioFormat { this.properties = null; } - /** - * Constructs an AudioFormat with the given parameters. - * The encoding specifies the convention used to represent the data. - * The other parameters are further explained in the {@link AudioFormat - * class description}. - * @param encoding the audio encoding technique - * @param sampleRate the number of samples per second - * @param sampleSizeInBits the number of bits in each sample - * @param channels the number of channels (1 for mono, 2 for - * stereo, and so on) - * @param frameSize the number of bytes in each frame - * @param frameRate the number of frames per second - * @param bigEndian indicates whether the data for a single sample - * is stored in big-endian byte order - * (false means little-endian) - * @param properties a Map<String,Object> object - * containing format properties + * Constructs an {@code AudioFormat} with the given parameters. The encoding + * specifies the convention used to represent the data. The other parameters + * are further explained in the {@link AudioFormat class description}. * + * @param encoding the audio encoding technique + * @param sampleRate the number of samples per second + * @param sampleSizeInBits the number of bits in each sample + * @param channels the number of channels (1 for mono, 2 for stereo, and so + * on) + * @param frameSize the number of bytes in each frame + * @param frameRate the number of frames per second + * @param bigEndian indicates whether the data for a single sample is + * stored in big-endian byte order ({@code false} means little-endian) + * @param properties a {@code Map} object containing format + * properties * @since 1.5 */ public AudioFormat(Encoding encoding, float sampleRate, @@ -225,20 +226,20 @@ public class AudioFormat { this.properties = new HashMap(properties); } - /** - * Constructs an AudioFormat with a linear PCM encoding and - * the given parameters. The frame size is set to the number of bytes - * required to contain one sample from each channel, and the frame rate - * is set to the sample rate. + * Constructs an {@code AudioFormat} with a linear PCM encoding and the + * given parameters. The frame size is set to the number of bytes required + * to contain one sample from each channel, and the frame rate is set to the + * sample rate. * - * @param sampleRate the number of samples per second - * @param sampleSizeInBits the number of bits in each sample - * @param channels the number of channels (1 for mono, 2 for stereo, and so on) - * @param signed indicates whether the data is signed or unsigned - * @param bigEndian indicates whether the data for a single sample - * is stored in big-endian byte order (false - * means little-endian) + * @param sampleRate the number of samples per second + * @param sampleSizeInBits the number of bits in each sample + * @param channels the number of channels (1 for mono, 2 for stereo, and so + * on) + * @param signed indicates whether the data is signed or unsigned + * @param bigEndian indicates whether the data for a single sample is + * stored in big-endian byte order ({@code false} means + * little-endian) */ public AudioFormat(float sampleRate, int sampleSizeInBits, int channels, boolean signed, boolean bigEndian) { @@ -269,19 +270,17 @@ public class AudioFormat { } /** - * Obtains the sample rate. - * For compressed formats, the return value is the sample rate of the uncompressed - * audio data. - * When this AudioFormat is used for queries (e.g. {@link - * AudioSystem#isConversionSupported(AudioFormat, AudioFormat) - * AudioSystem.isConversionSupported}) or capabilities (e.g. {@link - * DataLine.Info#getFormats() DataLine.Info.getFormats}), a sample rate of - * AudioSystem.NOT_SPECIFIED means that any sample rate is - * acceptable. AudioSystem.NOT_SPECIFIED is also returned when - * the sample rate is not defined for this audio format. - * @return the number of samples per second, - * or AudioSystem.NOT_SPECIFIED + * Obtains the sample rate. For compressed formats, the return value is the + * sample rate of the uncompressed audio data. When this AudioFormat is used + * for queries (e.g. {@link AudioSystem#isConversionSupported(AudioFormat, + * AudioFormat) AudioSystem.isConversionSupported}) or capabilities (e.g. + * {@link DataLine.Info#getFormats DataLine.Info.getFormats}), a sample rate + * of {@code AudioSystem.NOT_SPECIFIED} means that any sample rate is + * acceptable. {@code AudioSystem.NOT_SPECIFIED} is also returned when the + * sample rate is not defined for this audio format. * + * @return the number of samples per second, or + * {@code AudioSystem.NOT_SPECIFIED} * @see #getFrameRate() * @see AudioSystem#NOT_SPECIFIED */ @@ -291,19 +290,18 @@ public class AudioFormat { } /** - * Obtains the size of a sample. - * For compressed formats, the return value is the sample size of the - * uncompressed audio data. - * When this AudioFormat is used for queries (e.g. {@link - * AudioSystem#isConversionSupported(AudioFormat, AudioFormat) - * AudioSystem.isConversionSupported}) or capabilities (e.g. {@link - * DataLine.Info#getFormats() DataLine.Info.getFormats}), a sample size of - * AudioSystem.NOT_SPECIFIED means that any sample size is - * acceptable. AudioSystem.NOT_SPECIFIED is also returned when - * the sample size is not defined for this audio format. - * @return the number of bits in each sample, - * or AudioSystem.NOT_SPECIFIED + * Obtains the size of a sample. For compressed formats, the return value is + * the sample size of the uncompressed audio data. When this AudioFormat is + * used for queries (e.g. {@link AudioSystem#isConversionSupported( + * AudioFormat,AudioFormat) AudioSystem.isConversionSupported}) or + * capabilities (e.g. + * {@link DataLine.Info#getFormats DataLine.Info.getFormats}), a sample size + * of {@code AudioSystem.NOT_SPECIFIED} means that any sample size is + * acceptable. {@code AudioSystem.NOT_SPECIFIED} is also returned when the + * sample size is not defined for this audio format. * + * @return the number of bits in each sample, or + * {@code AudioSystem.NOT_SPECIFIED} * @see #getFrameSize() * @see AudioSystem#NOT_SPECIFIED */ @@ -313,16 +311,15 @@ public class AudioFormat { } /** - * Obtains the number of channels. - * When this AudioFormat is used for queries (e.g. {@link - * AudioSystem#isConversionSupported(AudioFormat, AudioFormat) - * AudioSystem.isConversionSupported}) or capabilities (e.g. {@link - * DataLine.Info#getFormats() DataLine.Info.getFormats}), a return value of - * AudioSystem.NOT_SPECIFIED means that any (positive) number of channels is - * acceptable. - * @return The number of channels (1 for mono, 2 for stereo, etc.), - * or AudioSystem.NOT_SPECIFIED + * Obtains the number of channels. When this AudioFormat is used for queries + * (e.g. {@link AudioSystem#isConversionSupported(AudioFormat, AudioFormat) + * AudioSystem.isConversionSupported}) or capabilities (e.g. + * {@link DataLine.Info#getFormats DataLine.Info.getFormats}), a return + * value of {@code AudioSystem.NOT_SPECIFIED} means that any (positive) + * number of channels is acceptable. * + * @return The number of channels (1 for mono, 2 for stereo, etc.), or + * {@code AudioSystem.NOT_SPECIFIED} * @see AudioSystem#NOT_SPECIFIED */ public int getChannels() { @@ -331,17 +328,16 @@ public class AudioFormat { } /** - * Obtains the frame size in bytes. - * When this AudioFormat is used for queries (e.g. {@link - * AudioSystem#isConversionSupported(AudioFormat, AudioFormat) - * AudioSystem.isConversionSupported}) or capabilities (e.g. {@link - * DataLine.Info#getFormats() DataLine.Info.getFormats}), a frame size of - * AudioSystem.NOT_SPECIFIED means that any frame size is - * acceptable. AudioSystem.NOT_SPECIFIED is also returned when - * the frame size is not defined for this audio format. - * @return the number of bytes per frame, - * or AudioSystem.NOT_SPECIFIED + * Obtains the frame size in bytes. When this AudioFormat is used for + * queries (e.g. {@link AudioSystem#isConversionSupported(AudioFormat, + * AudioFormat) AudioSystem.isConversionSupported}) or capabilities (e.g. + * {@link DataLine.Info#getFormats DataLine.Info.getFormats}), a frame size + * of {@code AudioSystem.NOT_SPECIFIED} means that any frame size is + * acceptable. {@code AudioSystem.NOT_SPECIFIED} is also returned when the + * frame size is not defined for this audio format. * + * @return the number of bytes per frame, or + * {@code AudioSystem.NOT_SPECIFIED} * @see #getSampleSizeInBits() * @see AudioSystem#NOT_SPECIFIED */ @@ -351,17 +347,17 @@ public class AudioFormat { } /** - * Obtains the frame rate in frames per second. - * When this AudioFormat is used for queries (e.g. {@link - * AudioSystem#isConversionSupported(AudioFormat, AudioFormat) - * AudioSystem.isConversionSupported}) or capabilities (e.g. {@link - * DataLine.Info#getFormats() DataLine.Info.getFormats}), a frame rate of - * AudioSystem.NOT_SPECIFIED means that any frame rate is - * acceptable. AudioSystem.NOT_SPECIFIED is also returned when - * the frame rate is not defined for this audio format. - * @return the number of frames per second, - * or AudioSystem.NOT_SPECIFIED + * Obtains the frame rate in frames per second. When this AudioFormat is + * used for queries (e.g. {@link AudioSystem#isConversionSupported( + * AudioFormat,AudioFormat) AudioSystem.isConversionSupported}) or + * capabilities (e.g. + * {@link DataLine.Info#getFormats DataLine.Info.getFormats}), a frame rate + * of {@code AudioSystem.NOT_SPECIFIED} means that any frame rate is + * acceptable. {@code AudioSystem.NOT_SPECIFIED} is also returned when the + * frame rate is not defined for this audio format. * + * @return the number of frames per second, or + * {@code AudioSystem.NOT_SPECIFIED} * @see #getSampleRate() * @see AudioSystem#NOT_SPECIFIED */ @@ -370,56 +366,49 @@ public class AudioFormat { return frameRate; } - /** * Indicates whether the audio data is stored in big-endian or little-endian - * byte order. If the sample size is not more than one byte, the return value is - * irrelevant. - * @return true if the data is stored in big-endian byte order, - * false if little-endian + * byte order. If the sample size is not more than one byte, the return + * value is irrelevant. + * + * @return {@code true} if the data is stored in big-endian byte order, + * {@code false} if little-endian */ public boolean isBigEndian() { return bigEndian; } - /** - * Obtain an unmodifiable map of properties. - * The concept of properties is further explained in - * the {@link AudioFileFormat 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 AudioFileFormat 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 */ + @SuppressWarnings("unchecked") // Cast of result of clone. public Map properties() { Map ret; if (properties == null) { - ret = new HashMap(0); + ret = new HashMap<>(0); } else { ret = (Map) (properties.clone()); } return Collections.unmodifiableMap(ret); } - /** - * Obtain the property value specified by the key. - * The concept of properties is further explained in - * the {@link AudioFileFormat 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 AudioFileFormat 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 */ @@ -430,21 +419,18 @@ public class AudioFormat { return properties.get(key); } - /** - * Indicates whether this format matches the one specified. - * To match, two formats must have the same encoding, - * and consistent values of the number of channels, sample rate, sample size, - * frame rate, and frame size. - * The values of the property are consistent if they are equal - * or the specified format has the property value - * {@code AudioSystem.NOT_SPECIFIED}. - * The byte order (big-endian or little-endian) must be the same - * if the sample size is greater than one byte. + * Indicates whether this format matches the one specified. To match, two + * formats must have the same encoding, and consistent values of the number + * of channels, sample rate, sample size, frame rate, and frame size. The + * values of the property are consistent if they are equal or the specified + * format has the property value {@code AudioSystem.NOT_SPECIFIED}. The byte + * order (big-endian or little-endian) must be the same if the sample size + * is greater than one byte. * - * @param format format to test for match + * @param format format to test for match * @return {@code true} if this format matches the one specified, - * {@code false} otherwise. + * {@code false} otherwise */ public boolean matches(AudioFormat format) { if (format.getEncoding().equals(getEncoding()) @@ -465,14 +451,14 @@ public class AudioFormat { return false; } - /** - * Returns a string that describes the format, such as: - * "PCM SIGNED 22050 Hz 16 bit mono big-endian". The contents of the string - * may vary between implementations of Java Sound. + * Returns a string that describes the format, such as: "PCM SIGNED 22050 Hz + * 16 bit mono big-endian". The contents of the string may vary between + * implementations of Java Sound. * * @return a string that describes the format parameters */ + @Override public String toString() { String sEncoding = ""; if (getEncoding() != null) { @@ -546,42 +532,36 @@ public class AudioFormat { } /** - * The Encoding class names the specific type of data representation - * used for an audio stream. The encoding includes aspects of the - * sound format other than the number of channels, sample rate, sample size, - * frame rate, frame size, and byte order. + * The {@code Encoding} class names the specific type of data representation + * used for an audio stream. The encoding includes aspects of the sound + * format other than the number of channels, sample rate, sample size, frame + * rate, frame size, and byte order. *

    * One ubiquitous type of audio encoding is pulse-code modulation (PCM), * which is simply a linear (proportional) representation of the sound - * waveform. With PCM, the number stored in each sample is proportional - * to the instantaneous amplitude of the sound pressure at that point in - * time. The numbers may be signed or unsigned integers or floats. - * Besides PCM, other encodings include mu-law and a-law, which are nonlinear - * mappings of the sound amplitude that are often used for recording speech. + * waveform. With PCM, the number stored in each sample is proportional to + * the instantaneous amplitude of the sound pressure at that point in time. + * The numbers may be signed or unsigned integers or floats. Besides PCM, + * other encodings include mu-law and a-law, which are nonlinear mappings of + * the sound amplitude that are often used for recording speech. *

    * You can use a predefined encoding by referring to one of the static - * objects created by this class, such as PCM_SIGNED or - * PCM_UNSIGNED. Service providers can create new encodings, such as - * compressed audio formats, and make - * these available through the {@link AudioSystem} class. + * objects created by this class, such as PCM_SIGNED or PCM_UNSIGNED. + * Service providers can create new encodings, such as compressed audio + * formats, and make these available through the {@link AudioSystem} class. *

    - * The Encoding class is static, so that all - * AudioFormat objects that have the same encoding will refer - * to the same object (rather than different instances of the same class). - * This allows matches to be made by checking that two format's encodings - * are equal. - * - * @see AudioFormat - * @see javax.sound.sampled.spi.FormatConversionProvider + * The {@code Encoding} class is static, so that all {@code AudioFormat} + * objects that have the same encoding will refer to the same object (rather + * than different instances of the same class). This allows matches to be + * made by checking that two format's encodings are equal. * * @author Kara Kytle + * @see AudioFormat + * @see javax.sound.sampled.spi.FormatConversionProvider * @since 1.3 */ public static class Encoding { - - // ENCODING DEFINES - /** * Specifies signed, linear PCM data. */ @@ -609,31 +589,24 @@ public class AudioFormat { */ public static final Encoding ALAW = new Encoding("ALAW"); - - // INSTANCE VARIABLES - /** * Encoding name. */ private String name; - - // CONSTRUCTOR - /** * Constructs a new encoding. - * @param name the name of the new type of encoding + * + * @param name the name of the new type of encoding */ public Encoding(String name) { this.name = name; } - - // METHODS - /** - * Finalizes the equals method + * Finalizes the equals method. */ + @Override public final boolean equals(Object obj) { if (toString() == null) { return (obj != null) && (obj.toString() == null); @@ -645,8 +618,9 @@ public class AudioFormat { } /** - * Finalizes the hashCode method + * Finalizes the hashCode method. */ + @Override public final int hashCode() { if (toString() == null) { return 0; @@ -655,16 +629,17 @@ public class AudioFormat { } /** - * Provides the String representation of the encoding. This String is - * the same name that was passed to the constructor. For the predefined encodings, the name - * is similar to the encoding's variable (field) name. For example, PCM_SIGNED.toString() returns - * the name "pcm_signed". + * Provides the {@code String} representation of the encoding. This + * {@code String} is the same name that was passed to the constructor. + * For the predefined encodings, the name is similar to the encoding's + * variable (field) name. For example, {@code PCM_SIGNED.toString()} + * returns the name "pcm_signed". * * @return the encoding name */ + @Override public final String toString() { return name; } - - } // class Encoding + } } diff --git a/jdk/src/share/classes/javax/sound/sampled/AudioInputStream.java b/jdk/src/share/classes/javax/sound/sampled/AudioInputStream.java index ea4162fa2f3..14e7b537f1b 100644 --- a/jdk/src/share/classes/javax/sound/sampled/AudioInputStream.java +++ b/jdk/src/share/classes/javax/sound/sampled/AudioInputStream.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,24 @@ package javax.sound.sampled; -import java.io.InputStream; -import java.io.PushbackInputStream; import java.io.IOException; +import java.io.InputStream; /** * An audio input stream is an input stream with a specified audio format and - * length. The length is expressed in sample frames, not bytes. - * Several methods are provided for reading a certain number of bytes from - * the stream, or an unspecified number of bytes. - * The audio input stream keeps track of the last byte that was read. - * You can skip over an arbitrary number of bytes to get to a later position - * for reading. An audio input stream may support marks. When you set a mark, - * the current position is remembered so that you can return to it later. + * length. The length is expressed in sample frames, not bytes. Several methods + * are provided for reading a certain number of bytes from the stream, or an + * unspecified number of bytes. The audio input stream keeps track of the last + * byte that was read. You can skip over an arbitrary number of bytes to get to + * a later position for reading. An audio input stream may support marks. When + * you set a mark, the current position is remembered so that you can return to + * it later. *

    - * The AudioSystem class includes many methods that manipulate - * AudioInputStream objects. - * For example, the methods let you: + * The {@code AudioSystem} class includes many methods that manipulate + * {@code AudioInputStream} objects. For example, the methods let you: *

      - *
    • obtain an - * audio input stream from an external audio file, stream, or URL + *
    • obtain an audio input stream from an external audio file, stream, or URL *
    • write an external file from an audio input stream *
    • convert an audio input stream to a different audio format *
    @@ -53,16 +50,15 @@ import java.io.IOException; * @author David Rivas * @author Kara Kytle * @author Florian Bomers - * * @see AudioSystem - * @see Clip#open(AudioInputStream) Clip.open(AudioInputStream) + * @see Clip#open(AudioInputStream) * @since 1.3 */ public class AudioInputStream extends InputStream { /** - * The InputStream from which this AudioInputStream - * object was constructed. + * The {@code InputStream} from which this {@code AudioInputStream} object + * was constructed. */ private InputStream stream; @@ -92,35 +88,34 @@ public class AudioInputStream extends InputStream { private long markpos; /** - * When the underlying stream could only return - * a non-integral number of frames, store - * the remainder in a temporary buffer + * When the underlying stream could only return a non-integral number of + * frames, store the remainder in a temporary buffer. */ private byte[] pushBackBuffer = null; /** - * number of valid bytes in the pushBackBuffer + * number of valid bytes in the pushBackBuffer. */ private int pushBackLen = 0; /** - * MarkBuffer at mark position + * MarkBuffer at mark position. */ private byte[] markPushBackBuffer = null; /** - * number of valid bytes in the markPushBackBuffer + * number of valid bytes in the markPushBackBuffer. */ private int markPushBackLen = 0; - /** - * Constructs an audio input stream that has the requested format and length in sample frames, - * using audio data from the specified input stream. - * @param stream the stream on which this AudioInputStream - * object is based - * @param format the format of this stream's audio data - * @param length the length in sample frames of the data in this stream + * Constructs an audio input stream that has the requested format and length + * in sample frames, using audio data from the specified input stream. + * + * @param stream the stream on which this {@code AudioInputStream} object + * is based + * @param format the format of this stream's audio data + * @param length the length in sample frames of the data in this stream */ public AudioInputStream(InputStream stream, AudioFormat format, long length) { @@ -141,12 +136,12 @@ public class AudioInputStream extends InputStream { markpos = 0; } - /** - * Constructs an audio input stream that reads its data from the target - * data line indicated. The format of the stream is the same as that of - * the target data line, and the length is AudioSystem#NOT_SPECIFIED. - * @param line the target data line from which this stream obtains its data. + * Constructs an audio input stream that reads its data from the target data + * line indicated. The format of the stream is the same as that of the + * target data line, and the length is AudioSystem#NOT_SPECIFIED. + * + * @param line the target data line from which this stream obtains its data * @see AudioSystem#NOT_SPECIFIED */ public AudioInputStream(TargetDataLine line) { @@ -164,29 +159,29 @@ public class AudioInputStream extends InputStream { markpos = 0; } - /** * Obtains the audio format of the sound data in this audio input stream. + * * @return an audio format object describing this stream's format */ public AudioFormat getFormat() { return format; } - /** - * Obtains the length of the stream, expressed in sample frames rather than bytes. + * Obtains the length of the stream, expressed in sample frames rather than + * bytes. + * * @return the length in sample frames */ public long getFrameLength() { return frameLength; } - /** - * Reads the next byte of data from the audio input stream. The audio input - * stream's frame size must be one byte, or an IOException - * will be thrown. + * Reads the next byte of data from the audio input stream. The audio input + * stream's frame size must be one byte, or an {@code IOException} will be + * thrown. * * @return the next byte of data, or -1 if the end of the stream is reached * @throws IOException if an input or output error occurs @@ -194,6 +189,7 @@ public class AudioInputStream extends InputStream { * @see #read(byte[]) * @see #available */ + @Override public int read() throws IOException { if( frameSize != 1 ) { throw new IOException("cannot read a single byte if frame size > 1"); @@ -208,50 +204,50 @@ public class AudioInputStream extends InputStream { return data[0] & 0xFF; } - /** - * Reads some number of bytes from the audio input stream and stores them into - * the buffer array b. The number of bytes actually read is - * returned as an integer. This method blocks until input data is - * available, the end of the stream is detected, or an exception is thrown. - *

    This method will always read an integral number of frames. - * If the length of the array is not an integral number - * of frames, a maximum of b.length - (b.length % frameSize) - * bytes will be read. + * Reads some number of bytes from the audio input stream and stores them + * into the buffer array {@code b}. The number of bytes actually read is + * returned as an integer. This method blocks until input data is available, + * the end of the stream is detected, or an exception is thrown. + *

    + * This method will always read an integral number of frames. If the length + * of the array is not an integral number of frames, a maximum of + * {@code b.length - (b.length % frameSize)} bytes will be read. * - * @param b the buffer into which the data is read - * @return the total number of bytes read into the buffer, or -1 if there - * is no more data because the end of the stream has been reached + * @param b the buffer into which the data is read + * @return the total number of bytes read into the buffer, or -1 if there is + * no more data because the end of the stream has been reached * @throws IOException if an input or output error occurs * @see #read(byte[], int, int) * @see #read() * @see #available */ + @Override public int read(byte[] b) throws IOException { return read(b,0,b.length); } - /** * Reads up to a specified maximum number of bytes of data from the audio * stream, putting them into the given byte array. - *

    This method will always read an integral number of frames. - * If len does not specify an integral number - * of frames, a maximum of len - (len % frameSize) - * bytes will be read. + *

    + * This method will always read an integral number of frames. If {@code len} + * does not specify an integral number of frames, a maximum of + * {@code len - (len % frameSize)} bytes will be read. * - * @param b the buffer into which the data is read - * @param off the offset, from the beginning of array b, at which - * the data will be written - * @param len the maximum number of bytes to read - * @return the total number of bytes read into the buffer, or -1 if there - * is no more data because the end of the stream has been reached + * @param b the buffer into which the data is read + * @param off the offset, from the beginning of array {@code b}, at which + * the data will be written + * @param len the maximum number of bytes to read + * @return the total number of bytes read into the buffer, or -1 if there is + * no more data because the end of the stream has been reached * @throws IOException if an input or output error occurs * @see #read(byte[]) * @see #read() * @see #skip * @see #available */ + @Override public int read(byte[] b, int off, int len) throws IOException { // make sure we don't read fractions of a frame. @@ -313,16 +309,17 @@ public class AudioInputStream extends InputStream { return bytesRead; } - /** - * Skips over and discards a specified number of bytes from this - * audio input stream. - * @param n the requested number of bytes to be skipped + * Skips over and discards a specified number of bytes from this audio input + * stream. + * + * @param n the requested number of bytes to be skipped * @return the actual number of bytes skipped * @throws IOException if an input or output error occurs * @see #read * @see #available */ + @Override public long skip(long n) throws IOException { // make sure not to skip fractional frames @@ -351,21 +348,23 @@ public class AudioInputStream extends InputStream { } - /** - * Returns the maximum number of bytes that can be read (or skipped over) from this - * audio input stream without blocking. This limit applies only to the next invocation of - * a read or skip method for this audio input stream; the limit - * can vary each time these methods are invoked. - * Depending on the underlying stream,an IOException may be thrown if this - * stream is closed. - * @return the number of bytes that can be read from this audio input stream without blocking + * Returns the maximum number of bytes that can be read (or skipped over) + * from this audio input stream without blocking. This limit applies only + * to the next invocation of a {@code read} or {@code skip} method for this + * audio input stream; the limit can vary each time these methods are + * invoked. Depending on the underlying stream, an IOException may be thrown + * if this stream is closed. + * + * @return the number of bytes that can be read from this audio input stream + * without blocking * @throws IOException if an input or output error occurs * @see #read(byte[], int, int) * @see #read(byte[]) * @see #read() * @see #skip */ + @Override public int available() throws IOException { int temp = stream.available(); @@ -378,25 +377,26 @@ public class AudioInputStream extends InputStream { } } - /** - * Closes this audio input stream and releases any system resources associated - * with the stream. + * Closes this audio input stream and releases any system resources + * associated with the stream. + * * @throws IOException if an input or output error occurs */ + @Override public void close() throws IOException { stream.close(); } - /** * Marks the current position in this audio input stream. - * @param readlimit the maximum number of bytes that can be read before - * the mark position becomes invalid. + * + * @param readlimit the maximum number of bytes that can be read before the + * mark position becomes invalid. * @see #reset * @see #markSupported */ - + @Override public void mark(int readlimit) { stream.mark(readlimit); @@ -413,14 +413,15 @@ public class AudioInputStream extends InputStream { } } - /** - * Repositions this audio input stream to the position it had at the time its - * mark method was last invoked. - * @throws IOException if an input or output error occurs. + * Repositions this audio input stream to the position it had at the time + * its {@code mark} method was last invoked. + * + * @throws IOException if an input or output error occurs * @see #mark * @see #markSupported */ + @Override public void reset() throws IOException { stream.reset(); @@ -435,21 +436,21 @@ public class AudioInputStream extends InputStream { } } - /** - * Tests whether this audio input stream supports the mark and - * reset methods. - * @return true if this stream supports the mark - * and reset methods; false otherwise + * Tests whether this audio input stream supports the {@code mark} and + * {@code reset} methods. + * + * @return {@code true} if this stream supports the {@code mark} and + * {@code reset} methods; {@code false} otherwise * @see #mark * @see #reset */ + @Override public boolean markSupported() { return stream.markSupported(); } - /** * Private inner class that makes a TargetDataLine look like an InputStream. */ @@ -460,19 +461,19 @@ public class AudioInputStream extends InputStream { */ TargetDataLine line; - TargetDataLineInputStream(TargetDataLine line) { super(); this.line = line; } - + @Override public int available() throws IOException { return line.available(); } //$$fb 2001-07-16: added this method to correctly close the underlying TargetDataLine. // fixes bug 4479984 + @Override public void close() throws IOException { // the line needs to be flushed and stopped to avoid a dead lock... // Probably related to bugs 4417527, 4334868, 4383457 @@ -483,6 +484,7 @@ public class AudioInputStream extends InputStream { line.close(); } + @Override public int read() throws IOException { byte[] b = new byte[1]; @@ -502,7 +504,7 @@ public class AudioInputStream extends InputStream { return value; } - + @Override public int read(byte[] b, int off, int len) throws IOException { try { return line.read(b, off, len); diff --git a/jdk/src/share/classes/javax/sound/sampled/AudioPermission.java b/jdk/src/share/classes/javax/sound/sampled/AudioPermission.java index 4e7dcef9602..13655254bf0 100644 --- a/jdk/src/share/classes/javax/sound/sampled/AudioPermission.java +++ b/jdk/src/share/classes/javax/sound/sampled/AudioPermission.java @@ -28,18 +28,18 @@ package javax.sound.sampled; import java.security.BasicPermission; /** - * The AudioPermission class represents access rights to the audio - * system resources. An AudioPermission contains a target name - * but no actions list; you either have the named permission or you don't. + * The {@code AudioPermission} class represents access rights to the audio + * system resources. An {@code AudioPermission} contains a target name but no + * actions list; you either have the named permission or you don't. *

    * The target name is the name of the audio permission (see the table below). - * The names follow the hierarchical property-naming convention. Also, an asterisk - * can be used to represent all the audio permissions. + * The names follow the hierarchical property-naming convention. Also, an + * asterisk can be used to represent all the audio permissions. *

    - * The following table lists the possible AudioPermission target names. - * For each name, the table provides a description of exactly what that permission - * allows, as well as a discussion of the risks of granting code the permission. - * + * The following table lists the possible {@code AudioPermission} target names. + * For each name, the table provides a description of exactly what that + * permission allows, as well as a discussion of the risks of granting code the + * permission. * * * @@ -57,7 +57,7 @@ import java.security.BasicPermission; * applications because the audio from one line may be mixed with other audio * being played on the system, or because manipulation of a mixer affects the * audio for all lines using that mixer. - * + * * * * @@ -68,42 +68,40 @@ import java.security.BasicPermission; * applications because manipulation of a mixer affects the audio for all lines * using that mixer. * This permission can enable an applet or application to eavesdrop on a user. - * - *
    record
    - *

    + * + * * * @author Kara Kytle * @since 1.3 */ public class AudioPermission extends BasicPermission { + private static final long serialVersionUID = -5518053473477801126L; /** - * Creates a new AudioPermission object that has the specified - * symbolic name, such as "play" or "record". An asterisk can be used to indicate - * all audio permissions. - * @param name the name of the new AudioPermission + * Creates a new {@code AudioPermission} object that has the specified + * symbolic name, such as "play" or "record". An asterisk can be used to + * indicate all audio permissions. * - * @throws NullPointerException if name is null. - * @throws IllegalArgumentException if name is empty. + * @param name the name of the new {@code AudioPermission} + * @throws NullPointerException if {@code name} is {@code null} + * @throws IllegalArgumentException if {@code name} is empty */ - public AudioPermission(String name) { - + public AudioPermission(final String name) { super(name); } /** - * Creates a new AudioPermission object that has the specified - * symbolic name, such as "play" or "record". The actions - * parameter is currently unused and should be null. - * @param name the name of the new AudioPermission - * @param actions (unused; should be null) + * Creates a new {@code AudioPermission} object that has the specified + * symbolic name, such as "play" or "record". The {@code actions} parameter + * is currently unused and should be {@code null}. * - * @throws NullPointerException if name is null. - * @throws IllegalArgumentException if name is empty. + * @param name the name of the new {@code AudioPermission} + * @param actions (unused; should be {@code null}) + * @throws NullPointerException if {@code name} is {@code null} + * @throws IllegalArgumentException if {@code name} is empty */ - public AudioPermission(String name, String actions) { - + public AudioPermission(final String name, final String actions) { super(name, actions); } } diff --git a/jdk/src/share/classes/javax/sound/sampled/AudioSystem.java b/jdk/src/share/classes/javax/sound/sampled/AudioSystem.java index 235ed234276..459ef997855 100644 --- a/jdk/src/share/classes/javax/sound/sampled/AudioSystem.java +++ b/jdk/src/share/classes/javax/sound/sampled/AudioSystem.java @@ -50,29 +50,24 @@ import com.sun.media.sound.JDK13Services; /** - * The AudioSystem class acts as the entry point to the - * sampled-audio system resources. This class lets you query and - * access the mixers that are installed on the system. - * AudioSystem includes a number of - * methods for converting audio data between different formats, and for - * translating between audio files and streams. It also provides a method - * for obtaining a {@link Line} directly from the - * AudioSystem without dealing explicitly + * The {@code AudioSystem} class acts as the entry point to the sampled-audio + * system resources. This class lets you query and access the mixers that are + * installed on the system. {@code AudioSystem} includes a number of methods for + * converting audio data between different formats, and for translating between + * audio files and streams. It also provides a method for obtaining a + * {@link Line} directly from the {@code AudioSystem} without dealing explicitly * with mixers. - * - *

    Properties can be used to specify the default mixer - * for specific line types. - * 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: + *

    + * 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: * * * @@ -82,84 +77,68 @@ import com.sun.media.sound.JDK13Services; * * * - * + * * * * * - * + * * * * * - * + * * * * * - * + * * * * *
    Audio System Property Keys
    Affected Method(s)
    javax.sound.sampled.Clip{@code javax.sound.sampled.Clip}{@link Clip}{@link #getLine}, {@link #getClip}
    javax.sound.sampled.Port{@code javax.sound.sampled.Port}{@link Port}{@link #getLine}
    javax.sound.sampled.SourceDataLine{@code javax.sound.sampled.SourceDataLine}{@link SourceDataLine}{@link #getLine}, {@link #getSourceDataLine}
    javax.sound.sampled.TargetDataLine{@code javax.sound.sampled.TargetDataLine}{@link TargetDataLine}{@link #getLine}, {@link #getTargetDataLine}
    * - * 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 String returned by the getName - * method of 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 - * Mixer.Info objects is retrieved - * from the provider. Otherwise, or when these mixers - * do not provide a subsequent match, the list is retrieved - * from {@link #getMixerInfo} to contain - * all available Mixer.Info objects. - * - *

    If a mixer name is specified, the resulting list of - * Mixer.Info objects is searched: - * the first one with a matching name, and whose - * Mixer provides the + * 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. + *

    + * 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 + * from the provider. Otherwise, or when these mixers do not provide a + * subsequent match, the list is retrieved from {@link #getMixerInfo} to contain + * all available {@code Mixer.Info} objects. + *

    + * If a mixer name is specified, the resulting list of {@code Mixer.Info} + * objects is searched: the first one with a matching name, and whose + * {@code Mixer} provides the respective line interface, will be returned. If no + * matching {@code Mixer.Info} object is found, or the mixer name is not + * specified, the first mixer from the resulting list, which provides the * respective line interface, will be returned. - * If no matching Mixer.Info object - * is found, or the mixer name is not specified, - * the first mixer from the resulting - * list, which provides the respective line - * interface, will be returned. * - * For example, the property javax.sound.sampled.Clip - * with a value - * "com.sun.media.sound.MixerProvider#SunClip" - * will have the following consequences when - * getLine is called requesting a Clip - * instance: - * if the class com.sun.media.sound.MixerProvider exists - * in the list of installed mixer providers, - * the first Clip from the first mixer with name - * "SunClip" will be returned. If it cannot - * be found, the first Clip from the first mixer - * of the specified provider will be returned, regardless of name. - * If there is none, the first Clip from the first - * Mixer with name - * "SunClip" in the list of all mixers - * (as returned by getMixerInfo) will be returned, - * or, if not found, the first Clip of the first - * Mixerthat can be found in the list of all - * mixers is returned. - * If that fails, too, an IllegalArgumentException - * is thrown. + * For example, the property {@code javax.sound.sampled.Clip} with a value + * {@code "com.sun.media.sound.MixerProvider#SunClip"} + * will have the following consequences when {@code getLine} is called + * requesting a {@code Clip} instance: if the class + * {@code com.sun.media.sound.MixerProvider} exists in the list of installed + * mixer providers, the first {@code Clip} from the first mixer with name + * {@code "SunClip"} will be returned. If it cannot be found, the + * first {@code Clip} from the first mixer of the specified provider will be + * returned, regardless of name. If there is none, the first {@code Clip} from + * the first {@code Mixer} with name {@code "SunClip"} in the list of + * all mixers (as returned by {@code getMixerInfo}) will be returned, or, if not + * found, the first {@code Clip} of the first {@code Mixer} that can be found in + * the list of all mixers is returned. If that fails, too, an + * {@code IllegalArgumentException} is thrown. * * @author Kara Kytle * @author Florian Bomers * @author Matthias Pfisterer * @author Kevin P. Smith - * * @see AudioFormat * @see AudioInputStream * @see Mixer @@ -170,13 +149,12 @@ import com.sun.media.sound.JDK13Services; public class AudioSystem { /** - * An integer that stands for an unknown numeric value. - * This value is appropriate only for signed quantities that do not - * normally take negative values. Examples include file sizes, frame - * sizes, buffer sizes, and sample rates. - * A number of Java Sound constructors accept - * a value of NOT_SPECIFIED for such parameters. Other - * methods may also accept or return this value, as documented. + * An integer that stands for an unknown numeric value. This value is + * appropriate only for signed quantities that do not normally take negative + * values. Examples include file sizes, frame sizes, buffer sizes, and + * sample rates. A number of Java Sound constructors accept a value of + * {@code NOT_SPECIFIED} for such parameters. Other methods may also accept + * or return this value, as documented. */ public static final int NOT_SPECIFIED = -1; @@ -186,42 +164,43 @@ public class AudioSystem { private AudioSystem() { } - /** - * Obtains an array of mixer info objects that represents - * the set of audio mixers that are currently installed on the system. - * @return an array of info objects for the currently installed mixers. If no mixers - * are available on the system, an array of length 0 is returned. + * Obtains an array of mixer info objects that represents the set of audio + * mixers that are currently installed on the system. + * + * @return an array of info objects for the currently installed mixers. If + * no mixers are available on the system, an array of length 0 is + * returned. * @see #getMixer */ public static Mixer.Info[] getMixerInfo() { - List infos = getMixerInfoList(); - Mixer.Info[] allInfos = (Mixer.Info[]) infos.toArray(new Mixer.Info[infos.size()]); + List infos = getMixerInfoList(); + Mixer.Info[] allInfos = infos.toArray(new Mixer.Info[infos.size()]); return allInfos; } - /** * Obtains the requested audio mixer. - * @param info a Mixer.Info object representing the desired - * mixer, or null for the system default mixer + * + * @param info a {@code Mixer.Info} object representing the desired mixer, + * or {@code null} for the system default mixer * @return the requested mixer - * @throws SecurityException if the requested mixer - * is unavailable because of security restrictions - * @throws IllegalArgumentException if the info object does not represent - * a mixer installed on the system + * @throws SecurityException if the requested mixer is unavailable because + * of security restrictions + * @throws IllegalArgumentException if the info object does not represent a + * mixer installed on the system * @see #getMixerInfo */ public static Mixer getMixer(Mixer.Info info) { Mixer mixer = null; - List providers = getMixerProviders(); + List providers = getMixerProviders(); for(int i = 0; i < providers.size(); i++ ) { try { - return ((MixerProvider)providers.get(i)).getMixer(info); + return providers.get(i).getMixer(info); } catch (IllegalArgumentException e) { } catch (NullPointerException e) { @@ -238,7 +217,7 @@ public class AudioSystem { if (info == null) { for(int i = 0; i < providers.size(); i++ ) { try { - MixerProvider provider = (MixerProvider) providers.get(i); + MixerProvider provider = providers.get(i); Mixer.Info[] infos = provider.getMixerInfo(); // start from 0 to last device (do not reverse this order) for (int ii = 0; ii < infos.length; ii++) { @@ -259,22 +238,22 @@ public class AudioSystem { + (info!=null?info.toString():"null")); } - //$$fb 2002-11-26: fix for 4757930: DOC: AudioSystem.getTarget/SourceLineInfo() is ambiguous + /** - * Obtains information about all source lines of a particular type that are supported - * by the installed mixers. - * @param info a Line.Info object that specifies the kind of - * lines about which information is requested - * @return an array of Line.Info objects describing source lines matching - * the type requested. If no matching source lines are supported, an array of length 0 - * is returned. + * Obtains information about all source lines of a particular type that are + * supported by the installed mixers. * + * @param info a {@code Line.Info} object that specifies the kind of lines + * about which information is requested + * @return an array of {@code Line.Info} objects describing source lines + * matching the type requested. If no matching source lines are + * supported, an array of length 0 is returned. * @see Mixer#getSourceLineInfo(Line.Info) */ public static Line.Info[] getSourceLineInfo(Line.Info info) { - Vector vector = new Vector(); + Vector vector = new Vector<>(); Line.Info[] currentInfoArray; Mixer mixer; @@ -294,27 +273,26 @@ public class AudioSystem { Line.Info[] returnedArray = new Line.Info[vector.size()]; for (int i = 0; i < returnedArray.length; i++) { - returnedArray[i] = (Line.Info)vector.get(i); + returnedArray[i] = vector.get(i); } return returnedArray; } - /** - * Obtains information about all target lines of a particular type that are supported - * by the installed mixers. - * @param info a Line.Info object that specifies the kind of - * lines about which information is requested - * @return an array of Line.Info objects describing target lines matching - * the type requested. If no matching target lines are supported, an array of length 0 - * is returned. + * Obtains information about all target lines of a particular type that are + * supported by the installed mixers. * + * @param info a {@code Line.Info} object that specifies the kind of lines + * about which information is requested + * @return an array of {@code Line.Info} objects describing target lines + * matching the type requested. If no matching target lines are + * supported, an array of length 0 is returned. * @see Mixer#getTargetLineInfo(Line.Info) */ public static Line.Info[] getTargetLineInfo(Line.Info info) { - Vector vector = new Vector(); + Vector vector = new Vector<>(); Line.Info[] currentInfoArray; Mixer mixer; @@ -334,21 +312,21 @@ public class AudioSystem { Line.Info[] returnedArray = new Line.Info[vector.size()]; for (int i = 0; i < returnedArray.length; i++) { - returnedArray[i] = (Line.Info)vector.get(i); + returnedArray[i] = vector.get(i); } return returnedArray; } - /** - * Indicates whether the system supports any lines that match - * the specified Line.Info object. A line is supported if - * any installed mixer supports it. - * @param info a Line.Info object describing the line for which support is queried - * @return true if at least one matching line is - * supported, otherwise false + * Indicates whether the system supports any lines that match the specified + * {@code Line.Info} object. A line is supported if any installed mixer + * supports it. * + * @param info a {@code Line.Info} object describing the line for which + * support is queried + * @return {@code true} if at least one matching line is supported, + * otherwise {@code false} * @see Mixer#isLineSupported(Line.Info) */ public static boolean isLineSupported(Line.Info info) { @@ -371,44 +349,40 @@ public class AudioSystem { /** * Obtains a line that matches the description in the specified - * Line.Info object. + * {@code Line.Info} object. + *

    + * If a {@code DataLine} is requested, and {@code info} is an instance of + * {@code DataLine.Info} specifying at least one fully qualified audio + * format, the last one will be used as the default format of the returned + * {@code DataLine}. + *

    + * If system properties + * {@code javax.sound.sampled.Clip}, + * {@code javax.sound.sampled.Port}, + * {@code javax.sound.sampled.SourceDataLine} and + * {@code javax.sound.sampled.TargetDataLine} are defined or they are + * defined in the file "sound.properties", they are used to retrieve default + * lines. For details, refer to the {@link AudioSystem class description}. * - *

    If a DataLine is requested, and info - * is an instance of DataLine.Info specifying at least - * one fully qualified audio format, the last one - * will be used as the default format of the returned - * DataLine. + * If the respective property is not set, or the mixer requested in the + * property is not installed or does not provide the requested line, all + * installed mixers are queried for the requested line type. A Line will be + * returned from the first mixer providing the requested line type. * - *

    If system properties - * javax.sound.sampled.Clip, - * javax.sound.sampled.Port, - * javax.sound.sampled.SourceDataLine and - * javax.sound.sampled.TargetDataLine are defined - * or they are defined in the file "sound.properties", - * they are used to retrieve default lines. - * For details, refer to the {@link AudioSystem class description}. - * - * If the respective property is not set, or the mixer - * requested in the property is not installed or does not provide the - * requested line, all installed mixers are queried for the - * requested line type. A Line will be returned from the first mixer - * providing the requested line type. - * - * @param info a Line.Info object describing the desired kind of line + * @param info a {@code Line.Info} object describing the desired kind of + * line * @return a line of the requested kind - * - * @throws LineUnavailableException if a matching line - * is not available due to resource restrictions - * @throws SecurityException if a matching line - * is not available due to security restrictions - * @throws IllegalArgumentException if the system does not - * support at least one line matching the specified - * Line.Info object - * through any installed mixer + * @throws LineUnavailableException if a matching line is not available due + * to resource restrictions + * @throws SecurityException if a matching line is not available due to + * security restrictions + * @throws IllegalArgumentException if the system does not support at least + * one line matching the specified {@code Line.Info} object through + * any installed mixer */ public static Line getLine(Line.Info info) throws LineUnavailableException { LineUnavailableException lue = null; - List providers = getMixerProviders(); + List providers = getMixerProviders(); // 1: try from default mixer for this line class @@ -427,7 +401,7 @@ public class AudioSystem { // 2: if that doesn't work, try to find any mixing mixer for(int i = 0; i < providers.size(); i++) { - MixerProvider provider = (MixerProvider) providers.get(i); + MixerProvider provider = providers.get(i); Mixer.Info[] infos = provider.getMixerInfo(); for (int j = 0; j < infos.length; j++) { @@ -449,7 +423,7 @@ public class AudioSystem { // 3: if that didn't work, try to find any non-mixing mixer for(int i = 0; i < providers.size(); i++) { - MixerProvider provider = (MixerProvider) providers.get(i); + MixerProvider provider = providers.get(i); Mixer.Info[] infos = provider.getMixerInfo(); for (int j = 0; j < infos.length; j++) { try { @@ -479,37 +453,30 @@ public class AudioSystem { info.toString() + " is supported."); } - /** - * Obtains a clip that can be used for playing back - * an audio file or an audio stream. The returned clip - * will be provided by the default system mixer, or, - * if not possible, by any other mixer installed in the - * system that supports a Clip - * object. - * - *

    The returned clip must be opened with the - * open(AudioFormat) or - * open(AudioInputStream) method. - * - *

    This is a high-level method that uses getMixer - * and getLine internally. - * - *

    If the system property - * javax.sound.sampled.Clip - * is defined or it is defined in the file "sound.properties", - * it is used to retrieve the default clip. - * For details, refer to the {@link AudioSystem class description}. + * Obtains a clip that can be used for playing back an audio file or an + * audio stream. The returned clip will be provided by the default system + * mixer, or, if not possible, by any other mixer installed in the system + * that supports a {@code Clip} object. + *

    + * The returned clip must be opened with the {@code open(AudioFormat)} or + * {@code open(AudioInputStream)} method. + *

    + * This is a high-level method that uses {@code getMixer} and + * {@code getLine} internally. + *

    + * If the system property {@code javax.sound.sampled.Clip} is defined or it + * is defined in the file "sound.properties", it is used to retrieve the + * default clip. For details, refer to the + * {@link AudioSystem class description}. * * @return the desired clip object - * - * @throws LineUnavailableException if a clip object - * is not available due to resource restrictions - * @throws SecurityException if a clip object - * is not available due to security restrictions - * @throws IllegalArgumentException if the system does not - * support at least one clip instance through any installed mixer - * + * @throws LineUnavailableException if a clip object is not available due to + * resource restrictions + * @throws SecurityException if a clip object is not available due to + * security restrictions + * @throws IllegalArgumentException if the system does not support at least + * one clip instance through any installed mixer * @see #getClip(Mixer.Info) * @since 1.5 */ @@ -522,29 +489,26 @@ public class AudioSystem { return (Clip) AudioSystem.getLine(info); } - /** - * Obtains a clip from the specified mixer that can be - * used for playing back an audio file or an audio stream. + * Obtains a clip from the specified mixer that can be used for playing back + * an audio file or an audio stream. + *

    + * The returned clip must be opened with the {@code open(AudioFormat)} or + * {@code open(AudioInputStream)} method. + *

    + * This is a high-level method that uses {@code getMixer} and + * {@code getLine} internally. * - *

    The returned clip must be opened with the - * open(AudioFormat) or - * open(AudioInputStream) method. - * - *

    This is a high-level method that uses getMixer - * and getLine internally. - * - * @param mixerInfo a Mixer.Info object representing the - * desired mixer, or null for the system default mixer + * @param mixerInfo a {@code Mixer.Info} object representing the desired + * mixer, or {@code null} for the system default mixer * @return a clip object from the specified mixer * - * @throws LineUnavailableException if a clip - * is not available from this mixer due to resource restrictions - * @throws SecurityException if a clip - * is not available from this mixer due to security restrictions - * @throws IllegalArgumentException if the system does not - * support at least one clip through the specified mixer - * + * @throws LineUnavailableException if a clip is not available from this + * mixer due to resource restrictions + * @throws SecurityException if a clip is not available from this mixer due + * to security restrictions + * @throws IllegalArgumentException if the system does not support at least + * one clip through the specified mixer * @see #getClip() * @since 1.5 */ @@ -558,45 +522,38 @@ public class AudioSystem { return (Clip) mixer.getLine(info); } - /** - * Obtains a source data line that can be used for playing back - * audio data in the format specified by the - * AudioFormat object. The returned line - * will be provided by the default system mixer, or, - * if not possible, by any other mixer installed in the - * system that supports a matching - * SourceDataLine object. - * - *

    The returned line should be opened with the - * open(AudioFormat) or - * open(AudioFormat, int) method. - * - *

    This is a high-level method that uses getMixer - * and getLine internally. - * - *

    The returned SourceDataLine's default - * audio format will be initialized with format. - * - *

    If the system property - * javax.sound.sampled.SourceDataLine - * is defined or it is defined in the file "sound.properties", - * it is used to retrieve the default source data line. - * For details, refer to the {@link AudioSystem class description}. - * - * @param format an AudioFormat object specifying - * the supported audio format of the returned line, - * or null for any audio format - * @return the desired SourceDataLine object - * - * @throws LineUnavailableException if a matching source data line - * is not available due to resource restrictions - * @throws SecurityException if a matching source data line - * is not available due to security restrictions - * @throws IllegalArgumentException if the system does not - * support at least one source data line supporting the - * specified audio format through any installed mixer + * Obtains a source data line that can be used for playing back audio data + * in the format specified by the {@code AudioFormat} object. The returned + * line will be provided by the default system mixer, or, if not possible, + * by any other mixer installed in the system that supports a matching + * {@code SourceDataLine} object. + *

    + * The returned line should be opened with the {@code open(AudioFormat)} or + * {@code open(AudioFormat, int)} method. + *

    + * This is a high-level method that uses {@code getMixer} and + * {@code getLine} internally. + *

    + * The returned {@code SourceDataLine}'s default audio format will be + * initialized with {@code format}. + *

    + * If the system property {@code javax.sound.sampled.SourceDataLine} is + * defined or it is defined in the file "sound.properties", it is used to + * retrieve the default source data line. For details, refer to the + * {@link AudioSystem class description}. * + * @param format an {@code AudioFormat} object specifying the supported + * audio format of the returned line, or {@code null} for any audio + * format + * @return the desired {@code SourceDataLine} object + * @throws LineUnavailableException if a matching source data line is not + * available due to resource restrictions + * @throws SecurityException if a matching source data line is not available + * due to security restrictions + * @throws IllegalArgumentException if the system does not support at least + * one source data line supporting the specified audio format + * through any installed mixer * @see #getSourceDataLine(AudioFormat, Mixer.Info) * @since 1.5 */ @@ -606,41 +563,33 @@ public class AudioSystem { return (SourceDataLine) AudioSystem.getLine(info); } - /** - * Obtains a source data line that can be used for playing back - * audio data in the format specified by the - * AudioFormat object, provided by the mixer - * specified by the Mixer.Info object. - * - *

    The returned line should be opened with the - * open(AudioFormat) or - * open(AudioFormat, int) method. - * - *

    This is a high-level method that uses getMixer - * and getLine internally. - * - *

    The returned SourceDataLine's default - * audio format will be initialized with format. - * - * @param format an AudioFormat object specifying - * the supported audio format of the returned line, - * or null for any audio format - * @param mixerinfo a Mixer.Info object representing - * the desired mixer, or null for the system - * default mixer - * @return the desired SourceDataLine object - * - * @throws LineUnavailableException if a matching source data - * line is not available from the specified mixer due - * to resource restrictions - * @throws SecurityException if a matching source data line - * is not available from the specified mixer due to - * security restrictions - * @throws IllegalArgumentException if the specified mixer does - * not support at least one source data line supporting - * the specified audio format + * Obtains a source data line that can be used for playing back audio data + * in the format specified by the {@code AudioFormat} object, provided by + * the mixer specified by the {@code Mixer.Info} object. + *

    + * The returned line should be opened with the {@code open(AudioFormat)} or + * {@code open(AudioFormat, int)} method. + *

    + * This is a high-level method that uses {@code getMixer} and + * {@code getLine} internally. + *

    + * The returned {@code SourceDataLine}'s default audio format will be + * initialized with {@code format}. * + * @param format an {@code AudioFormat} object specifying the supported + * audio format of the returned line, or {@code null} for any audio + * format + * @param mixerinfo a {@code Mixer.Info} object representing the desired + * mixer, or {@code null} for the system default mixer + * @return the desired {@code SourceDataLine} object + * @throws LineUnavailableException if a matching source data line is not + * available from the specified mixer due to resource restrictions + * @throws SecurityException if a matching source data line is not available + * from the specified mixer due to security restrictions + * @throws IllegalArgumentException if the specified mixer does not support + * at least one source data line supporting the specified audio + * format * @see #getSourceDataLine(AudioFormat) * @since 1.5 */ @@ -650,47 +599,40 @@ public class AudioSystem { DataLine.Info info = new DataLine.Info(SourceDataLine.class, format); Mixer mixer = AudioSystem.getMixer(mixerinfo); return (SourceDataLine) mixer.getLine(info); - } - + } /** - * Obtains a target data line that can be used for recording - * audio data in the format specified by the - * AudioFormat object. The returned line - * will be provided by the default system mixer, or, - * if not possible, by any other mixer installed in the - * system that supports a matching - * TargetDataLine object. - * - *

    The returned line should be opened with the - * open(AudioFormat) or - * open(AudioFormat, int) method. - * - *

    This is a high-level method that uses getMixer - * and getLine internally. - * - *

    The returned TargetDataLine's default - * audio format will be initialized with format. - * - *

    If the system property - * {@code javax.sound.sampled.TargetDataLine} - * is defined or it is defined in the file "sound.properties", - * it is used to retrieve the default target data line. - * For details, refer to the {@link AudioSystem class description}. - * - * @param format an AudioFormat object specifying - * the supported audio format of the returned line, - * or null for any audio format - * @return the desired TargetDataLine object - * - * @throws LineUnavailableException if a matching target data line - * is not available due to resource restrictions - * @throws SecurityException if a matching target data line - * is not available due to security restrictions - * @throws IllegalArgumentException if the system does not - * support at least one target data line supporting the - * specified audio format through any installed mixer + * Obtains a target data line that can be used for recording audio data in + * the format specified by the {@code AudioFormat} object. The returned line + * will be provided by the default system mixer, or, if not possible, by any + * other mixer installed in the system that supports a matching + * {@code TargetDataLine} object. + *

    + * The returned line should be opened with the {@code open(AudioFormat)} or + * {@code open(AudioFormat, int)} method. + *

    + * This is a high-level method that uses {@code getMixer} and + * {@code getLine} internally. + *

    + * The returned {@code TargetDataLine}'s default audio format will be + * initialized with {@code format}. + *

    + * If the system property {@code javax.sound.sampled.TargetDataLine} is + * defined or it is defined in the file "sound.properties", it is used to + * retrieve the default target data line. For details, refer to the + * {@link AudioSystem class description}. * + * @param format an {@code AudioFormat} object specifying the supported + * audio format of the returned line, or {@code null} for any audio + * format + * @return the desired {@code TargetDataLine} object + * @throws LineUnavailableException if a matching target data line is not + * available due to resource restrictions + * @throws SecurityException if a matching target data line is not available + * due to security restrictions + * @throws IllegalArgumentException if the system does not support at least + * one target data line supporting the specified audio format + * through any installed mixer * @see #getTargetDataLine(AudioFormat, Mixer.Info) * @see AudioPermission * @since 1.5 @@ -702,41 +644,33 @@ public class AudioSystem { return (TargetDataLine) AudioSystem.getLine(info); } - - /** - * Obtains a target data line that can be used for recording - * audio data in the format specified by the - * AudioFormat object, provided by the mixer - * specified by the Mixer.Info object. - * - *

    The returned line should be opened with the - * open(AudioFormat) or - * open(AudioFormat, int) method. - * - *

    This is a high-level method that uses getMixer - * and getLine internally. - * - *

    The returned TargetDataLine's default - * audio format will be initialized with format. - * - * @param format an AudioFormat object specifying - * the supported audio format of the returned line, - * or null for any audio format - * @param mixerinfo a Mixer.Info object representing the - * desired mixer, or null for the system default mixer - * @return the desired TargetDataLine object - * - * @throws LineUnavailableException if a matching target data - * line is not available from the specified mixer due - * to resource restrictions - * @throws SecurityException if a matching target data line - * is not available from the specified mixer due to - * security restrictions - * @throws IllegalArgumentException if the specified mixer does - * not support at least one target data line supporting - * the specified audio format + * Obtains a target data line that can be used for recording audio data in + * the format specified by the {@code AudioFormat} object, provided by the + * mixer specified by the {@code Mixer.Info} object. + *

    + * The returned line should be opened with the {@code open(AudioFormat)} or + * {@code open(AudioFormat, int)} method. + *

    + * This is a high-level method that uses {@code getMixer} and + * {@code getLine} internally. + *

    + * The returned {@code TargetDataLine}'s default audio format will be + * initialized with {@code format}. * + * @param format an {@code AudioFormat} object specifying the supported + * audio format of the returned line, or {@code null} for any audio + * format + * @param mixerinfo a {@code Mixer.Info} object representing the desired + * mixer, or {@code null} for the system default mixer + * @return the desired {@code TargetDataLine} object + * @throws LineUnavailableException if a matching target data line is not + * available from the specified mixer due to resource restrictions + * @throws SecurityException if a matching target data line is not available + * from the specified mixer due to security restrictions + * @throws IllegalArgumentException if the specified mixer does not support + * at least one target data line supporting the specified audio + * format * @see #getTargetDataLine(AudioFormat) * @see AudioPermission * @since 1.5 @@ -750,28 +684,30 @@ public class AudioSystem { return (TargetDataLine) mixer.getLine(info); } - // $$fb 2002-04-12: fix for 4662082: behavior of AudioSystem.getTargetEncodings() methods doesn't match the spec + /** - * Obtains the encodings that the system can obtain from an - * audio input stream with the specified encoding using the set - * of installed format converters. - * @param sourceEncoding the encoding for which conversion support - * is queried - * @return array of encodings. If sourceEncodingis not supported, - * an array of length 0 is returned. Otherwise, the array will have a length - * of at least 1, representing sourceEncoding (no conversion). + * Obtains the encodings that the system can obtain from an audio input + * stream with the specified encoding using the set of installed format + * converters. + * + * @param sourceEncoding the encoding for which conversion support is + * queried + * @return array of encodings. If {@code sourceEncoding}is not supported, an + * array of length 0 is returned. Otherwise, the array will have a + * length of at least 1, representing {@code sourceEncoding} + * (no conversion). */ public static AudioFormat.Encoding[] getTargetEncodings(AudioFormat.Encoding sourceEncoding) { - List codecs = getFormatConversionProviders(); - Vector encodings = new Vector(); + List codecs = getFormatConversionProviders(); + Vector encodings = new Vector<>(); AudioFormat.Encoding encs[] = null; // gather from all the codecs for(int i=0; isourceFormatis not supported, - * an array of length 0 is returned. Otherwise, the array will have a length - * of at least 1, representing the encoding of sourceFormat (no conversion). + * Obtains the encodings that the system can obtain from an audio input + * stream with the specified format using the set of installed format + * converters. + * + * @param sourceFormat the audio format for which conversion is queried + * @return array of encodings. If {@code sourceFormat}is not supported, an + * array of length 0 is returned. Otherwise, the array will have a + * length of at least 1, representing the encoding of + * {@code sourceFormat} (no conversion). */ public static AudioFormat.Encoding[] getTargetEncodings(AudioFormat sourceFormat) { - List codecs = getFormatConversionProviders(); - Vector encodings = new Vector(); + List codecs = getFormatConversionProviders(); + Vector encodings = new Vector<>(); int size = 0; int index = 0; @@ -809,7 +745,7 @@ public class AudioSystem { // gather from all the codecs for(int i=0; itrue if the conversion is supported, - * otherwise false + * Indicates whether an audio input stream of the specified encoding can be + * obtained from an audio input stream that has the specified format. + * + * @param targetEncoding the desired encoding after conversion + * @param sourceFormat the audio format before conversion + * @return {@code true} if the conversion is supported, otherwise + * {@code false} */ public static boolean isConversionSupported(AudioFormat.Encoding targetEncoding, AudioFormat sourceFormat) { - List codecs = getFormatConversionProviders(); + List codecs = getFormatConversionProviders(); for(int i=0; i codecs = getFormatConversionProviders(); for(int i = 0; i < codecs.size(); i++) { - FormatConversionProvider codec = (FormatConversionProvider) codecs.get(i); + FormatConversionProvider codec = codecs.get(i); if( codec.isConversionSupported( targetEncoding, sourceStream.getFormat() ) ) { return codec.getAudioInputStream( targetEncoding, sourceStream ); } @@ -878,20 +813,20 @@ public class AudioSystem { throw new IllegalArgumentException("Unsupported conversion: " + targetEncoding + " from " + sourceStream.getFormat()); } - /** - * Obtains the formats that have a particular encoding and that the system can - * obtain from a stream of the specified format using the set of + * Obtains the formats that have a particular encoding and that the system + * can obtain from a stream of the specified format using the set of * installed format converters. - * @param targetEncoding the desired encoding after conversion - * @param sourceFormat the audio format before conversion - * @return array of formats. If no formats of the specified - * encoding are supported, an array of length 0 is returned. + * + * @param targetEncoding the desired encoding after conversion + * @param sourceFormat the audio format before conversion + * @return array of formats. If no formats of the specified encoding are + * supported, an array of length 0 is returned. */ public static AudioFormat[] getTargetFormats(AudioFormat.Encoding targetEncoding, AudioFormat sourceFormat) { - List codecs = getFormatConversionProviders(); - Vector formats = new Vector(); + List codecs = getFormatConversionProviders(); + Vector formats = new Vector<>(); int size = 0; int index = 0; @@ -900,7 +835,7 @@ public class AudioSystem { // gather from all the codecs for(int i=0; itrue if the conversion is supported, - * otherwise false + * Indicates whether an audio input stream of a specified format can be + * obtained from an audio input stream of another specified format. + * + * @param targetFormat the desired audio format after conversion + * @param sourceFormat the audio format before conversion + * @return {@code true} if the conversion is supported, otherwise + * {@code false} */ - public static boolean isConversionSupported(AudioFormat targetFormat, AudioFormat sourceFormat) { - List codecs = getFormatConversionProviders(); + List codecs = getFormatConversionProviders(); for(int i=0; i codecs = getFormatConversionProviders(); for(int i = 0; i < codecs.size(); i++) { - FormatConversionProvider codec = (FormatConversionProvider) codecs.get(i); + FormatConversionProvider codec = codecs.get(i); if(codec.isConversionSupported(targetFormat,sourceStream.getFormat()) ) { return codec.getAudioInputStream(targetFormat,sourceStream); } @@ -974,20 +908,22 @@ public class AudioSystem { throw new IllegalArgumentException("Unsupported conversion: " + targetFormat + " from " + sourceStream.getFormat()); } - /** - * Obtains the audio file format of the provided input stream. The stream must - * point to valid audio file data. The implementation of this method may require - * multiple parsers to examine the stream to determine 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 these operations, this method may fail - * with an IOException. - * @param stream the input stream from which file format information should be - * extracted - * @return an AudioFileFormat object describing the stream's audio file format - * @throws UnsupportedAudioFileException if the stream does not point to valid audio - * file data recognized by the system + * Obtains the audio file format of the provided input stream. The stream + * must point to valid audio file data. The implementation of this method + * may require multiple parsers to examine the stream to determine 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 these operations, this method may fail with an + * {@code IOException}. + * + * @param stream the input stream from which file format information should + * be extracted + * @return an {@code AudioFileFormat} object describing the stream's audio + * file format + * @throws UnsupportedAudioFileException if the stream does not point to + * valid audio file data recognized by the system * @throws IOException if an input/output exception occurs * @see InputStream#markSupported * @see InputStream#mark @@ -995,11 +931,11 @@ public class AudioSystem { public static AudioFileFormat getAudioFileFormat(InputStream stream) throws UnsupportedAudioFileException, IOException { - List providers = getAudioFileReaders(); + List providers = getAudioFileReaders(); AudioFileFormat format = null; for(int i = 0; i < providers.size(); i++ ) { - AudioFileReader reader = (AudioFileReader) providers.get(i); + AudioFileReader reader = providers.get(i); try { format = reader.getAudioFileFormat( stream ); // throws IOException break; @@ -1016,23 +952,25 @@ public class AudioSystem { } /** - * Obtains the audio file format of the specified URL. The URL must - * point to valid audio file data. - * @param url the URL from which file format information should be - * extracted - * @return an AudioFileFormat object describing the audio file format - * @throws UnsupportedAudioFileException if the URL does not point to valid audio - * file data recognized by the system + * Obtains the audio file format of the specified URL. The URL must point to + * valid audio file data. + * + * @param url the URL from which file format information should be + * extracted + * @return an {@code AudioFileFormat} object describing the audio file + * format + * @throws UnsupportedAudioFileException if the URL does not point to valid + * audio file data recognized by the system * @throws IOException if an input/output exception occurs */ public static AudioFileFormat getAudioFileFormat(URL url) throws UnsupportedAudioFileException, IOException { - List providers = getAudioFileReaders(); + List providers = getAudioFileReaders(); AudioFileFormat format = null; for(int i = 0; i < providers.size(); i++ ) { - AudioFileReader reader = (AudioFileReader) providers.get(i); + AudioFileReader reader = providers.get(i); try { format = reader.getAudioFileFormat( url ); // throws IOException break; @@ -1049,23 +987,25 @@ public class AudioSystem { } /** - * Obtains the audio file format of the specified File. The File must - * point to valid audio file data. - * @param file the File from which file format information should be - * extracted - * @return an AudioFileFormat object describing the audio file format - * @throws UnsupportedAudioFileException if the File does not point to valid audio - * file data recognized by the system + * Obtains the audio file format of the specified {@code File}. The + * {@code File} must point to valid audio file data. + * + * @param file the {@code File} from which file format information should + * be extracted + * @return an {@code AudioFileFormat} object describing the audio file + * format + * @throws UnsupportedAudioFileException if the {@code File} does not point + * to valid audio file data recognized by the system * @throws IOException if an I/O exception occurs */ public static AudioFileFormat getAudioFileFormat(File file) throws UnsupportedAudioFileException, IOException { - List providers = getAudioFileReaders(); + List providers = getAudioFileReaders(); AudioFileFormat format = null; for(int i = 0; i < providers.size(); i++ ) { - AudioFileReader reader = (AudioFileReader) providers.get(i); + AudioFileReader reader = providers.get(i); try { format = reader.getAudioFileFormat( file ); // throws IOException break; @@ -1081,22 +1021,22 @@ public class AudioSystem { } } - /** - * Obtains an audio input stream from the provided input stream. The stream must - * point to valid audio file data. The implementation of this method may - * require multiple parsers to - * examine the stream to determine 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 these operation, this method may fail - * with an IOException. - * @param stream the input stream from which the AudioInputStream should be - * constructed - * @return an AudioInputStream object based on the audio file data contained - * in the input stream. - * @throws UnsupportedAudioFileException if the stream does not point to valid audio - * file data recognized by the system + * Obtains an audio input stream from the provided input stream. The stream + * must point to valid audio file data. The implementation of this method + * may require multiple parsers to examine the stream to determine 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 these operation, this method may fail with an + * {@code IOException}. + * + * @param stream the input stream from which the {@code AudioInputStream} + * should be constructed + * @return an {@code AudioInputStream} object based on the audio file data + * contained in the input stream + * @throws UnsupportedAudioFileException if the stream does not point to + * valid audio file data recognized by the system * @throws IOException if an I/O exception occurs * @see InputStream#markSupported * @see InputStream#mark @@ -1104,11 +1044,11 @@ public class AudioSystem { public static AudioInputStream getAudioInputStream(InputStream stream) throws UnsupportedAudioFileException, IOException { - List providers = getAudioFileReaders(); + List providers = getAudioFileReaders(); AudioInputStream audioStream = null; for(int i = 0; i < providers.size(); i++ ) { - AudioFileReader reader = (AudioFileReader) providers.get(i); + AudioFileReader reader = providers.get(i); try { audioStream = reader.getAudioInputStream( stream ); // throws IOException break; @@ -1125,24 +1065,25 @@ public class AudioSystem { } /** - * Obtains an audio input stream from the URL provided. The URL must - * point to valid audio file data. - * @param url the URL for which the AudioInputStream should be - * constructed - * @return an AudioInputStream object based on the audio file data pointed - * to by the URL - * @throws UnsupportedAudioFileException if the URL does not point to valid audio - * file data recognized by the system + * Obtains an audio input stream from the URL provided. The URL must point + * to valid audio file data. + * + * @param url the URL for which the {@code AudioInputStream} should be + * constructed + * @return an {@code AudioInputStream} object based on the audio file data + * pointed to by the URL + * @throws UnsupportedAudioFileException if the URL does not point to valid + * audio file data recognized by the system * @throws IOException if an I/O exception occurs */ public static AudioInputStream getAudioInputStream(URL url) throws UnsupportedAudioFileException, IOException { - List providers = getAudioFileReaders(); + List providers = getAudioFileReaders(); AudioInputStream audioStream = null; for(int i = 0; i < providers.size(); i++ ) { - AudioFileReader reader = (AudioFileReader) providers.get(i); + AudioFileReader reader = providers.get(i); try { audioStream = reader.getAudioInputStream( url ); // throws IOException break; @@ -1159,24 +1100,25 @@ public class AudioSystem { } /** - * Obtains an audio input stream from the provided File. The File must - * point to valid audio file data. - * @param file the File for which the AudioInputStream should be - * constructed - * @return an AudioInputStream object based on the audio file data pointed - * to by the File - * @throws UnsupportedAudioFileException if the File does not point to valid audio - * file data recognized by the system + * Obtains an audio input stream from the provided {@code File}. The + * {@code File} must point to valid audio file data. + * + * @param file the {@code File} for which the {@code AudioInputStream} + * should be constructed + * @return an {@code AudioInputStream} object based on the audio file data + * pointed to by the {@code File} + * @throws UnsupportedAudioFileException if the {@code File} does not point + * to valid audio file data recognized by the system * @throws IOException if an I/O exception occurs */ public static AudioInputStream getAudioInputStream(File file) throws UnsupportedAudioFileException, IOException { - List providers = getAudioFileReaders(); + List providers = getAudioFileReaders(); AudioInputStream audioStream = null; for(int i = 0; i < providers.size(); i++ ) { - AudioFileReader reader = (AudioFileReader) providers.get(i); + AudioFileReader reader = providers.get(i); try { audioStream = reader.getAudioInputStream( file ); // throws IOException break; @@ -1192,42 +1134,43 @@ public class AudioSystem { } } - /** - * Obtains the 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. + * Obtains the 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. */ public static AudioFileFormat.Type[] getAudioFileTypes() { - List providers = getAudioFileWriters(); - Set returnTypesSet = new HashSet(); + List providers = getAudioFileWriters(); + Set returnTypesSet = new HashSet<>(); for(int i=0; i < providers.size(); i++) { - AudioFileWriter writer = (AudioFileWriter) providers.get(i); + AudioFileWriter writer = providers.get(i); AudioFileFormat.Type[] fileTypes = writer.getAudioFileTypes(); for(int j=0; j < fileTypes.length; j++) { returnTypesSet.add(fileTypes[j]); } } - AudioFileFormat.Type returnTypes[] = (AudioFileFormat.Type[]) + AudioFileFormat.Type returnTypes[] = returnTypesSet.toArray(new AudioFileFormat.Type[0]); return returnTypes; } - /** - * Indicates whether file writing support for the specified 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 + * Indicates whether file writing support for the specified file type is + * provided by the system. + * + * @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(AudioFileFormat.Type fileType) { - List providers = getAudioFileWriters(); + List providers = getAudioFileWriters(); for(int i=0; i < providers.size(); i++) { - AudioFileWriter writer = (AudioFileWriter) providers.get(i); + AudioFileWriter writer = providers.get(i); if (writer.isFileTypeSupported(fileType)) { return true; } @@ -1235,47 +1178,47 @@ public class AudioSystem { return false; } - /** - * Obtains the file types that the system can write from the - * audio input stream specified. - * @param stream the audio input stream for which audio file type support - * is queried - * @return array of file types. If no file types are supported, - * an array of length 0 is returned. + * Obtains the file types that the system can write from the audio input + * stream specified. + * + * @param stream the audio input stream for which audio file type + * support is queried + * @return array of file types. If no file types are supported, an array of + * length 0 is returned. */ public static AudioFileFormat.Type[] getAudioFileTypes(AudioInputStream stream) { - List providers = getAudioFileWriters(); - Set returnTypesSet = new HashSet(); + List providers = getAudioFileWriters(); + Set returnTypesSet = new HashSet<>(); for(int i=0; i < providers.size(); i++) { - AudioFileWriter writer = (AudioFileWriter) providers.get(i); + AudioFileWriter writer = providers.get(i); AudioFileFormat.Type[] fileTypes = writer.getAudioFileTypes(stream); for(int j=0; j < fileTypes.length; j++) { returnTypesSet.add(fileTypes[j]); } } - AudioFileFormat.Type returnTypes[] = (AudioFileFormat.Type[]) + AudioFileFormat.Type returnTypes[] = returnTypesSet.toArray(new AudioFileFormat.Type[0]); return returnTypes; } - /** * Indicates whether an audio file of the specified file type can be written * from the indicated audio input stream. - * @param fileType the file type for which write capabilities are queried - * @param stream the stream for which file-writing support is queried - * @return true if the file type is supported for this audio input stream, - * otherwise false + * + * @param fileType the file type for which write capabilities are queried + * @param stream the stream for which file-writing support is queried + * @return {@code true} if the file type is supported for this audio input + * stream, otherwise {@code false} */ public static boolean isFileTypeSupported(AudioFileFormat.Type fileType, AudioInputStream stream) { - List providers = getAudioFileWriters(); + List providers = getAudioFileWriters(); for(int i=0; i < providers.size(); i++) { - AudioFileWriter writer = (AudioFileWriter) providers.get(i); + AudioFileWriter writer = providers.get(i); if(writer.isFileTypeSupported(fileType, stream)) { return true; } @@ -1283,35 +1226,34 @@ public class AudioSystem { return false; } - /** - * Writes a stream of bytes representing an audio file of the specified file type - * to the output stream provided. Some file types require that - * the length be written into the file header; such files cannot be written from - * start to finish unless the length is known in advance. An attempt - * to write a file of such a type will fail with an IOException if the length in - * the audio file type is AudioSystem.NOT_SPECIFIED. + * Writes a stream of bytes representing an audio file of the specified file + * type to the output stream provided. Some file types require that the + * length be written into the file header; such files cannot be written from + * start to finish unless the length is known in advance. An attempt to + * write a file of such a type will fail with an IOException if the length + * in the audio file type is {@code AudioSystem.NOT_SPECIFIED}. * - * @param stream the audio input stream containing audio data to be - * written to the file - * @param fileType the kind of audio file to write - * @param out the stream to which the file data should be written + * @param stream the audio input stream containing audio data to be written + * to the file + * @param fileType the kind of audio file to write + * @param out the stream to which the file data should be written * @return the number of bytes written to the output stream * @throws IOException if an input/output 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 - * @see #getAudioFileTypes + * @see #getAudioFileTypes */ public static int write(AudioInputStream stream, AudioFileFormat.Type fileType, OutputStream out) throws IOException { - List providers = getAudioFileWriters(); + List providers = getAudioFileWriters(); int bytesWritten = 0; boolean flag = false; for(int i=0; i < providers.size(); i++) { - AudioFileWriter writer = (AudioFileWriter) providers.get(i); + AudioFileWriter writer = providers.get(i); try { bytesWritten = writer.write( stream, fileType, out ); // throws IOException flag = true; @@ -1328,30 +1270,30 @@ public class AudioSystem { } } - /** - * Writes a stream of bytes representing an audio file of the specified file type - * to the external file provided. - * @param stream the audio input stream containing audio data to be - * written to the file - * @param fileType the kind of audio file to write - * @param out the external file to which the file data should be written + * Writes a stream of bytes representing an audio file of the specified file + * type to the external file provided. + * + * @param stream the audio input stream containing audio data to be written + * to the file + * @param fileType the kind of audio file to write + * @param out the 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 - * @see #getAudioFileTypes + * @see #getAudioFileTypes */ public static int write(AudioInputStream stream, AudioFileFormat.Type fileType, File out) throws IOException { - List providers = getAudioFileWriters(); + List providers = getAudioFileWriters(); int bytesWritten = 0; boolean flag = false; for(int i=0; i < providers.size(); i++) { - AudioFileWriter writer = (AudioFileWriter) providers.get(i); + AudioFileWriter writer = providers.get(i); try { bytesWritten = writer.write( stream, fileType, out ); // throws IOException flag = true; @@ -1368,68 +1310,70 @@ public class AudioSystem { } } - // METHODS FOR INTERNAL IMPLEMENTATION USE /** * Obtains the set of MixerProviders on the system. */ - private static List getMixerProviders() { - return getProviders(MixerProvider.class); + @SuppressWarnings("unchecked") + private static List getMixerProviders() { + return (List) getProviders(MixerProvider.class); } - /** - * 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. - */ - private static List getFormatConversionProviders() { - return getProviders(FormatConversionProvider.class); - } - - - /** - * 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. - */ - private static List getAudioFileReaders() { - return getProviders(AudioFileReader.class); - } - - - /** - * Obtains the set of audio file writers that are currently installed on the system. - * @return a List of - * {@link javax.sound.samples.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. - */ - private static List getAudioFileWriters() { - return getProviders(AudioFileWriter.class); - } - - - - /** Attempts to locate and return a default Mixer that provides lines - * of the specified type. + * Obtains the set of format converters (codecs, transcoders, etc.) that are + * currently installed on the system. * - * @param providers the installed mixer providers - * @param info The requested line type - * TargetDataLine.class, Clip.class or Port.class. - * @return a Mixer that matches the requirements, or null if no default mixer found + * @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. */ - private static Mixer getDefaultMixer(List providers, Line.Info info) { - Class lineClass = info.getLineClass(); + @SuppressWarnings("unchecked") + private static List getFormatConversionProviders() { + return (List) getProviders(FormatConversionProvider.class); + } + + /** + * 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. + */ + @SuppressWarnings("unchecked") + private static List getAudioFileReaders() { + return (List)getProviders(AudioFileReader.class); + } + + /** + * 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. + */ + @SuppressWarnings("unchecked") + private static List getAudioFileWriters() { + return (List)getProviders(AudioFileWriter.class); + } + + /** + * Attempts to locate and return a default Mixer that provides lines of the + * specified type. + * + * @param providers the installed mixer providers + * @param info The requested line type TargetDataLine.class, Clip.class or + * Port.class + * @return a Mixer that matches the requirements, or null if no default + * mixer found + */ + private static Mixer getDefaultMixer(List providers, Line.Info info) { + Class lineClass = info.getLineClass(); String providerClassName = JDK13Services.getDefaultProviderClassName(lineClass); String instanceName = JDK13Services.getDefaultInstanceName(lineClass); Mixer mixer; @@ -1469,21 +1413,18 @@ public class AudioSystem { return null; } - - - /** Return a MixerProvider of a given class from the list of - MixerProviders. - - This method never requires the returned Mixer to do mixing. - @param providerClassName The class name of the provider to be returned. - @param providers The list of MixerProviders that is searched. - @return A MixerProvider of the requested class, or null if none is - found. + /** + * Return a MixerProvider of a given class from the list of MixerProviders. + * This method never requires the returned Mixer to do mixing. + * + * @param providerClassName The class name of the provider to be returned + * @param providers The list of MixerProviders that is searched + * @return A MixerProvider of the requested class, or null if none is found */ private static MixerProvider getNamedProvider(String providerClassName, - List providers) { + List providers) { for(int i = 0; i < providers.size(); i++) { - MixerProvider provider = (MixerProvider) providers.get(i); + MixerProvider provider = providers.get(i); if (provider.getClass().getName().equals(providerClassName)) { return provider; } @@ -1491,15 +1432,14 @@ public class AudioSystem { return null; } - - /** Return a Mixer with a given name from a given MixerProvider. - This method never requires the returned Mixer to do mixing. - @param mixerName The name of the Mixer to be returned. - @param provider The MixerProvider to check for Mixers. - @param info The type of line the returned Mixer is required to - support. - - @return A Mixer matching the requirements, or null if none is found. + /** + * Return a Mixer with a given name from a given MixerProvider. This method + * never requires the returned Mixer to do mixing. + * + * @param mixerName The name of the Mixer to be returned + * @param provider The MixerProvider to check for Mixers + * @param info The type of line the returned Mixer is required to support + * @return A Mixer matching the requirements, or null if none is found */ private static Mixer getNamedMixer(String mixerName, MixerProvider provider, @@ -1516,20 +1456,20 @@ public class AudioSystem { return null; } - - /** From a List of MixerProviders, return a Mixer with a given name. - This method never requires the returned Mixer to do mixing. - @param mixerName The name of the Mixer to be returned. - @param providers The List of MixerProviders to check for Mixers. - @param info The type of line the returned Mixer is required to - support. - @return A Mixer matching the requirements, or null if none is found. + /** + * From a List of MixerProviders, return a Mixer with a given name. This + * method never requires the returned Mixer to do mixing. + * + * @param mixerName The name of the Mixer to be returned + * @param providers The List of MixerProviders to check for Mixers + * @param info The type of line the returned Mixer is required to support + * @return A Mixer matching the requirements, or null if none is found */ private static Mixer getNamedMixer(String mixerName, - List providers, + List providers, Line.Info info) { for(int i = 0; i < providers.size(); i++) { - MixerProvider provider = (MixerProvider) providers.get(i); + MixerProvider provider = providers.get(i); Mixer mixer = getNamedMixer(mixerName, provider, info); if (mixer != null) { return mixer; @@ -1538,16 +1478,14 @@ public class AudioSystem { return null; } - - /** From a given MixerProvider, return the first appropriate Mixer. - @param provider The MixerProvider to check for Mixers. - @param info The type of line the returned Mixer is required to - support. - @param isMixingRequired If true, only Mixers that support mixing are - returned for line types of SourceDataLine and Clip. - - @return A Mixer that is considered appropriate, or null - if none is found. + /** + * From a given MixerProvider, return the first appropriate Mixer. + * + * @param provider The MixerProvider to check for Mixers + * @param info The type of line the returned Mixer is required to support + * @param isMixingRequired If true, only Mixers that support mixing are + * returned for line types of SourceDataLine and Clip + * @return A Mixer that is considered appropriate, or null if none is found */ private static Mixer getFirstMixer(MixerProvider provider, Line.Info info, @@ -1562,15 +1500,14 @@ public class AudioSystem { return null; } - - /** Checks if a Mixer is appropriate. - A Mixer is considered appropriate if it support the given line type. - If isMixingRequired is true and the line type is an output one - (SourceDataLine, Clip), the mixer is appropriate if it supports - at least 2 (concurrent) lines of the given type. - - @return true if the mixer is considered appropriate according to the - rules given above, false otherwise. + /** + * Checks if a Mixer is appropriate. A Mixer is considered appropriate if it + * support the given line type. If isMixingRequired is true and the line + * type is an output one (SourceDataLine, Clip), the mixer is appropriate if + * it supports at least 2 (concurrent) lines of the given type. + * + * @return {@code true} if the mixer is considered appropriate according to + * the rules given above, {@code false} otherwise */ private static boolean isAppropriateMixer(Mixer mixer, Line.Info lineInfo, @@ -1578,7 +1515,7 @@ public class AudioSystem { if (! mixer.isLineSupported(lineInfo)) { return false; } - Class lineClass = lineInfo.getLineClass(); + Class lineClass = lineInfo.getLineClass(); if (isMixingRequired && (SourceDataLine.class.isAssignableFrom(lineClass) || Clip.class.isAssignableFrom(lineClass))) { @@ -1588,28 +1525,25 @@ public class AudioSystem { return true; } - - /** - * Like getMixerInfo, but return List + * Like getMixerInfo, but return List. */ - private static List getMixerInfoList() { - List providers = getMixerProviders(); + private static List getMixerInfoList() { + List providers = getMixerProviders(); return getMixerInfoList(providers); } - /** - * Like getMixerInfo, but return List + * Like getMixerInfo, but return List. */ - private static List getMixerInfoList(List providers) { - List infos = new ArrayList(); + private static List getMixerInfoList(List providers) { + List infos = new ArrayList<>(); Mixer.Info[] someInfos; // per-mixer Mixer.Info[] allInfos; // for all mixers for(int i = 0; i < providers.size(); i++ ) { - someInfos = ((MixerProvider)providers.get(i)).getMixerInfo(); + someInfos = providers.get(i).getMixerInfo(); for (int j = 0; j < someInfos.length; j++) { infos.add(someInfos[j]); @@ -1619,14 +1553,14 @@ public class AudioSystem { return infos; } - /** - * 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 vector 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 vector of length 0 will be returned. */ - private static List getProviders(Class providerClass) { + private static List getProviders(Class providerClass) { return JDK13Services.getProviders(providerClass); } } diff --git a/jdk/src/share/classes/javax/sound/sampled/BooleanControl.java b/jdk/src/share/classes/javax/sound/sampled/BooleanControl.java index e48e06c339c..4f81d7c6514 100644 --- a/jdk/src/share/classes/javax/sound/sampled/BooleanControl.java +++ b/jdk/src/share/classes/javax/sound/sampled/BooleanControl.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 @@ -26,34 +26,29 @@ package javax.sound.sampled; /** - * A BooleanControl provides the ability to switch between - * two possible settings that affect a line's audio. The settings are boolean - * values (true and false). A graphical user interface - * might represent the control by a two-state button, an on/off switch, two - * mutually exclusive buttons, or a checkbox (among other possibilities). - * For example, depressing a button might activate a - * {@link BooleanControl.Type#MUTE MUTE} control to silence - * the line's audio. + * A {@code BooleanControl} provides the ability to switch between two possible + * settings that affect a line's audio. The settings are boolean values + * ({@code true} and {@code false}). A graphical user interface might represent + * the control by a two-state button, an on/off switch, two mutually exclusive + * buttons, or a checkbox (among other possibilities). For example, depressing a + * button might activate a {@link BooleanControl.Type#MUTE MUTE} control to + * silence the line's audio. *

    - * As with other {@link Control} subclasses, a method is - * provided that returns string labels for the values, suitable for - * display in the user interface. + * As with other {@code Control} subclasses, a method is provided that returns + * string labels for the values, suitable for display in the user interface. * * @author Kara Kytle * @since 1.3 */ public abstract class BooleanControl extends Control { - - // INSTANCE VARIABLES - /** - * The true state label, such as "true" or "on." + * The {@code true} state label, such as "true" or "on". */ private final String trueStateLabel; /** - * The false state label, such as "false" or "off." + * The {@code false} state label, such as "false" or "off". */ private final String falseStateLabel; @@ -62,19 +57,15 @@ public abstract class BooleanControl extends Control { */ private boolean value; - - // CONSTRUCTORS - - /** * Constructs a new boolean control object with the given parameters. * - * @param type the type of control represented this float control object - * @param initialValue the initial control value - * @param trueStateLabel the label for the state represented by true, - * such as "true" or "on." - * @param falseStateLabel the label for the state represented by false, - * such as "false" or "off." + * @param type the type of control represented this float control object + * @param initialValue the initial control value + * @param trueStateLabel the label for the state represented by + * {@code true}, such as "true" or "on" + * @param falseStateLabel the label for the state represented by + * {@code false}, such as "false" or "off" */ protected BooleanControl(Type type, boolean initialValue, String trueStateLabel, String falseStateLabel) { @@ -84,110 +75,88 @@ public abstract class BooleanControl extends Control { this.falseStateLabel = falseStateLabel; } - /** - * Constructs a new boolean control object with the given parameters. - * The labels for the true and false states - * default to "true" and "false." + * Constructs a new boolean control object with the given parameters. The + * labels for the {@code true} and {@code false} states default to "true" + * and "false". * - * @param type the type of control represented by this float control object - * @param initialValue the initial control value + * @param type the type of control represented by this float control object + * @param initialValue the initial control value */ protected BooleanControl(Type type, boolean initialValue) { this(type, initialValue, "true", "false"); } - - // METHODS - - /** - * Sets the current value for the control. The default - * implementation simply sets the value as indicated. - * Some controls require that their line be open before they can be affected - * by setting a value. - * @param value desired new value. + * Sets the current value for the control. The default implementation simply + * sets the value as indicated. Some controls require that their line be + * open before they can be affected by setting a value. + * + * @param value desired new value */ public void setValue(boolean value) { this.value = value; } - - /** * Obtains this control's current value. - * @return current value. + * + * @return current value */ public boolean getValue() { return value; } - /** * Obtains the label for the specified state. - * @param state the state whose label will be returned - * @return the label for the specified state, such as "true" or "on" - * for true, or "false" or "off" for false. + * + * @param state the state whose label will be returned + * @return the label for the specified state, such as "true" or "on" for + * {@code true}, or "false" or "off" for {@code false} */ public String getStateLabel(boolean state) { return ((state == true) ? trueStateLabel : falseStateLabel); } - - - // ABSTRACT METHOD IMPLEMENTATIONS: CONTROL - - /** - * Provides a string representation of the control + * Provides a string representation of the control. + * * @return a string description */ + @Override public String toString() { return new String(super.toString() + " with current value: " + getStateLabel(getValue())); } - - // INNER CLASSES - - /** - * An instance of the BooleanControl.Type class identifies one kind of - * boolean control. Static instances are provided for the - * common types. + * An instance of the {@code BooleanControl.Type} class identifies one kind + * of boolean control. Static instances are provided for the common types. * * @author Kara Kytle * @since 1.3 */ public static class Type extends Control.Type { - - // TYPE DEFINES - - /** - * Represents a control for the mute status of a line. - * Note that mute status does not affect gain. + * Represents a control for the mute status of a line. Note that mute + * status does not affect gain. */ public static final Type MUTE = new Type("Mute"); /** - * Represents a control for whether reverberation is applied - * to a line. Note that the status of this control not affect - * the reverberation settings for a line, but does affect whether - * these settings are used. + * Represents a control for whether reverberation is applied to a line. + * Note that the status of this control not affect the reverberation + * settings for a line, but does affect whether these settings are used. */ public static final Type APPLY_REVERB = new Type("Apply Reverb"); - - // CONSTRUCTOR - - /** * Constructs a new boolean control type. - * @param name the name of the new boolean control type + * + * @param name the name of the new boolean control type */ - protected Type(String name) { + protected Type(final String name) { super(name); } - } // class Type + } } diff --git a/jdk/src/share/classes/javax/sound/sampled/Clip.java b/jdk/src/share/classes/javax/sound/sampled/Clip.java index 03965f35528..5ed01df832c 100644 --- a/jdk/src/share/classes/javax/sound/sampled/Clip.java +++ b/jdk/src/share/classes/javax/sound/sampled/Clip.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,188 +25,184 @@ package javax.sound.sampled; -import java.io.InputStream; import java.io.IOException; /** - * The Clip interface represents a special kind of data line whose - * audio data can be loaded prior to playback, instead of being streamed in - * real time. + * The {@code Clip} interface represents a special kind of data line whose audio + * data can be loaded prior to playback, instead of being streamed in real time. *

    - * Because the data is pre-loaded and has a known length, you can set a clip - * to start playing at any position in its audio data. You can also create a - * loop, so that when the clip is played it will cycle repeatedly. Loops are - * specified with a starting and ending sample frame, along with the number of - * times that the loop should be played. + * Because the data is pre-loaded and has a known length, you can set a clip to + * start playing at any position in its audio data. You can also create a loop, + * so that when the clip is played it will cycle repeatedly. Loops are specified + * with a starting and ending sample frame, along with the number of times that + * the loop should be played. *

    - * Clips may be obtained from a {@link Mixer} that supports lines - * of this type. Data is loaded into a clip when it is opened. + * Clips may be obtained from a {@link Mixer} that supports lines of this type. + * Data is loaded into a clip when it is opened. *

    - * Playback of an audio clip may be started and stopped using the start - * and stop methods. These methods do not reset the media position; - * start causes playback to continue from the position where playback - * was last stopped. To restart playback from the beginning of the clip's audio - * data, simply follow the invocation of {@link DataLine#stop stop} - * with setFramePosition(0), which rewinds the media to the beginning - * of the clip. + * Playback of an audio clip may be started and stopped using the + * {@link #start start} and {@link #stop stop} methods. These methods do not + * reset the media position; {@code start} causes playback to continue from the + * position where playback was last stopped. To restart playback from the + * beginning of the clip's audio data, simply follow the invocation of + * {@code stop} with {@code setFramePosition(0)}, which rewinds the media to the + * beginning of the clip. * * @author Kara Kytle * @since 1.3 */ public interface Clip extends DataLine { - /** * A value indicating that looping should continue indefinitely rather than * complete after a specific number of loops. + * * @see #loop */ - public static final int LOOP_CONTINUOUSLY = -1; + int LOOP_CONTINUOUSLY = -1; /** - * Opens the clip, meaning that it should acquire any required - * system resources and become operational. The clip is opened - * with the format and audio data indicated. - * If this operation succeeds, the line is marked as open and an - * {@link LineEvent.Type#OPEN OPEN} event is dispatched - * to the line's listeners. + * Opens the clip, meaning that it should acquire any required system + * resources and become operational. The clip is opened with the format and + * audio data indicated. If this operation succeeds, the line is marked as + * open and an {@link LineEvent.Type#OPEN OPEN} event is dispatched to the + * line's listeners. *

    - * Invoking this method on a line which is already open is illegal - * and may result in an IllegalStateException. + * Invoking this method on a line which is already open is illegal and may + * result in an {@code IllegalStateException}. *

    - * Note that some lines, once closed, cannot be reopened. Attempts - * to reopen such a line will always result in a - * {@link LineUnavailableException}. + * Note that some lines, once closed, cannot be reopened. Attempts to reopen + * such a line will always result in a {@code LineUnavailableException}. * - * @param format the format of the supplied audio data - * @param data a byte array containing audio data to load into the clip - * @param offset the point at which to start copying, expressed in - * bytes from the beginning of the array - * @param bufferSize the number of bytes - * of data to load into the clip from the array. - * @throws LineUnavailableException if the line cannot be - * opened due to resource restrictions - * @throws IllegalArgumentException if the buffer size does not represent - * an integral number of sample frames, - * or if format is not fully specified or invalid + * @param format the format of the supplied audio data + * @param data a byte array containing audio data to load into the clip + * @param offset the point at which to start copying, expressed in + * bytes from the beginning of the array + * @param bufferSize the number of bytes of data to load into the + * clip from the array + * @throws LineUnavailableException if the line cannot be opened due to + * resource restrictions + * @throws IllegalArgumentException if the buffer size does not represent an + * integral number of sample frames, or if {@code format} is not + * fully specified or invalid * @throws IllegalStateException if the line is already open - * @throws SecurityException if the line cannot be - * opened due to security restrictions - * + * @throws SecurityException if the line cannot be opened due to security + * restrictions * @see #close * @see #isOpen * @see LineListener */ - public void open(AudioFormat format, byte[] data, int offset, int bufferSize) throws LineUnavailableException; + void open(AudioFormat format, byte[] data, int offset, int bufferSize) + throws LineUnavailableException; /** - * Opens the clip with the format and audio data present in the provided audio - * input stream. Opening a clip means that it should acquire any required - * system resources and become operational. If this operation - * input stream. If this operation - * succeeds, the line is marked open and an - * {@link LineEvent.Type#OPEN OPEN} event is dispatched - * to the line's listeners. + * Opens the clip with the format and audio data present in the provided + * audio input stream. Opening a clip means that it should acquire any + * required system resources and become operational. If this operation input + * stream. If this operation succeeds, the line is marked open and an + * {@link LineEvent.Type#OPEN OPEN} event is dispatched to the line's + * listeners. *

    - * Invoking this method on a line which is already open is illegal - * and may result in an IllegalStateException. + * Invoking this method on a line which is already open is illegal and may + * result in an {@code IllegalStateException}. *

    - * Note that some lines, once closed, cannot be reopened. Attempts - * to reopen such a line will always result in a - * {@link LineUnavailableException}. + * Note that some lines, once closed, cannot be reopened. Attempts to reopen + * such a line will always result in a {@code LineUnavailableException}. * - * @param stream an audio input stream from which audio data will be read into - * the clip - * @throws LineUnavailableException if the line cannot be - * opened due to resource restrictions - * @throws IOException if an I/O exception occurs during reading of - * the stream - * @throws IllegalArgumentException if the stream's audio format - * is not fully specified or invalid + * @param stream an audio input stream from which audio data will be read + * into the clip + * @throws LineUnavailableException if the line cannot be opened due to + * resource restrictions + * @throws IOException if an I/O exception occurs during reading of the + * stream + * @throws IllegalArgumentException if the stream's audio format is not + * fully specified or invalid * @throws IllegalStateException if the line is already open - * @throws SecurityException if the line cannot be - * opened due to security restrictions - * + * @throws SecurityException if the line cannot be opened due to security + * restrictions * @see #close * @see #isOpen * @see LineListener */ - public void open(AudioInputStream stream) throws LineUnavailableException, IOException; + void open(AudioInputStream stream) + throws LineUnavailableException, IOException; /** * Obtains the media length in sample frames. - * @return the media length, expressed in sample frames, - * or AudioSystem.NOT_SPECIFIED if the line is not open. + * + * @return the media length, expressed in sample frames, or + * {@code AudioSystem.NOT_SPECIFIED} if the line is not open * @see AudioSystem#NOT_SPECIFIED */ - public int getFrameLength(); + int getFrameLength(); /** - * Obtains the media duration in microseconds - * @return the media duration, expressed in microseconds, - * or AudioSystem.NOT_SPECIFIED if the line is not open. + * Obtains the media duration in microseconds. + * + * @return the media duration, expressed in microseconds, or + * {@code AudioSystem.NOT_SPECIFIED} if the line is not open * @see AudioSystem#NOT_SPECIFIED */ - public long getMicrosecondLength(); + long getMicrosecondLength(); /** - * Sets the media position in sample frames. The position is zero-based; - * the first frame is frame number zero. When the clip begins playing the - * next time, it will start by playing the frame at this position. + * Sets the media position in sample frames. The position is zero-based; the + * first frame is frame number zero. When the clip begins playing the next + * time, it will start by playing the frame at this position. *

    * To obtain the current position in sample frames, use the - * {@link DataLine#getFramePosition getFramePosition} - * method of DataLine. + * {@link DataLine#getFramePosition getFramePosition} method of + * {@code DataLine}. * - * @param frames the desired new media position, expressed in sample frames + * @param frames the desired new media position, expressed in sample frames */ - public void setFramePosition(int frames); + void setFramePosition(int frames); /** - * Sets the media position in microseconds. When the clip begins playing the - * next time, it will start at this position. - * The level of precision is not guaranteed. For example, an implementation - * might calculate the microsecond position from the current frame position - * and the audio sample frame rate. The precision in microseconds would - * then be limited to the number of microseconds per sample frame. + * Sets the media position in microseconds. When the clip begins playing the + * next time, it will start at this position. The level of precision is not + * guaranteed. For example, an implementation might calculate the + * microsecond position from the current frame position and the audio sample + * frame rate. The precision in microseconds would then be limited to the + * number of microseconds per sample frame. *

    * To obtain the current position in microseconds, use the - * {@link DataLine#getMicrosecondPosition getMicrosecondPosition} - * method of DataLine. + * {@link DataLine#getMicrosecondPosition getMicrosecondPosition} method of + * {@code DataLine}. * - * @param microseconds the desired new media position, expressed in microseconds + * @param microseconds the desired new media position, expressed in + * microseconds */ - public void setMicrosecondPosition(long microseconds); + void setMicrosecondPosition(long microseconds); /** - * Sets the first and last sample frames that will be played in - * the loop. The ending point must be greater than - * or equal to the starting point, and both must fall within the - * the size of the loaded media. A value of 0 for the starting - * point means the beginning of the loaded media. Similarly, a value of -1 - * for the ending point indicates the last frame of the media. - * @param start the loop's starting position, in sample frames (zero-based) - * @param end the loop's ending position, in sample frames (zero-based), or - * -1 to indicate the final frame - * @throws IllegalArgumentException if the requested - * loop points cannot be set, usually because one or both falls outside - * the media's duration or because the ending point is - * before the starting point + * Sets the first and last sample frames that will be played in the loop. + * The ending point must be greater than or equal to the starting point, and + * both must fall within the the size of the loaded media. A value of 0 for + * the starting point means the beginning of the loaded media. Similarly, a + * value of -1 for the ending point indicates the last frame of the media. + * + * @param start the loop's starting position, in sample frames (zero-based) + * @param end the loop's ending position, in sample frames (zero-based), + * or -1 to indicate the final frame + * @throws IllegalArgumentException if the requested loop points cannot be + * set, usually because one or both falls outside the media's + * duration or because the ending point is before the starting point */ - public void setLoopPoints(int start, int end); + void setLoopPoints(int start, int end); /** - * Starts looping playback from the current position. Playback will - * continue to the loop's end point, then loop back to the loop start point - * count times, and finally continue playback to the end of - * the clip. + * Starts looping playback from the current position. Playback will continue + * to the loop's end point, then loop back to the loop start point + * {@code count} times, and finally continue playback to the end of the + * clip. *

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

    - * A count value of 0 indicates that any current looping should - * cease and playback should continue to the end of the clip. The behavior + * A {@code count} value of 0 indicates that any current looping should + * cease and playback should continue to the end of the clip. The behavior * is undefined when this method is invoked with any other value during a * loop operation. *

    @@ -214,10 +210,10 @@ public interface Clip extends DataLine { * cleared; the behavior of subsequent loop and start requests is 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 + * @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 */ - public void loop(int count); + void loop(int count); } diff --git a/jdk/src/share/classes/javax/sound/sampled/CompoundControl.java b/jdk/src/share/classes/javax/sound/sampled/CompoundControl.java index 1c7ba46ede9..8cd400d7ea0 100644 --- a/jdk/src/share/classes/javax/sound/sampled/CompoundControl.java +++ b/jdk/src/share/classes/javax/sound/sampled/CompoundControl.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 @@ -26,55 +26,37 @@ package javax.sound.sampled; /** - * A CompoundControl, such as a graphic equalizer, provides control - * over two or more related properties, each of which is itself represented as - * a Control. + * A {@code CompoundControl}, such as a graphic equalizer, provides control over + * two or more related properties, each of which is itself represented as a + * {@code Control}. * * @author Kara Kytle * @since 1.3 */ public abstract class CompoundControl extends Control { - - // TYPE DEFINES - - - // INSTANCE VARIABLES - - /** * The set of member controls. */ private Control[] controls; - - - // CONSTRUCTORS - - /** * Constructs a new compound control object with the given parameters. * - * @param type the type of control represented this compound control object - * @param memberControls the set of member controls + * @param type the type of control represented this compound control object + * @param memberControls the set of member controls */ protected CompoundControl(Type type, Control[] memberControls) { - super(type); this.controls = memberControls; } - - - // METHODS - - /** * Returns the set of member controls that comprise the compound control. - * @return the set of member controls. + * + * @return the set of member controls */ public Control[] getMemberControls() { - Control[] localArray = new Control[controls.length]; for (int i = 0; i < controls.length; i++) { @@ -84,37 +66,31 @@ public abstract class CompoundControl extends Control { return localArray; } - - // ABSTRACT METHOD IMPLEMENTATIONS: CONTROL - - /** - * Provides a string representation of the control + * Provides a string representation of the control. + * * @return a string description */ + @Override public String toString() { - StringBuffer buf = new StringBuffer(); + StringBuilder sb = new StringBuilder(); for (int i = 0; i < controls.length; i++) { if (i != 0) { - buf.append(", "); + sb.append(", "); if ((i + 1) == controls.length) { - buf.append("and "); + sb.append("and "); } } - buf.append(controls[i].getType()); + sb.append(controls[i].getType()); } - return new String(getType() + " Control containing " + buf + " Controls."); + return new String(getType() + " Control containing " + sb + " Controls."); } - - // INNER CLASSES - - /** - * An instance of the CompoundControl.Type inner class identifies one kind of - * compound control. Static instances are provided for the + * An instance of the {@code CompoundControl.Type} inner class identifies + * one kind of compound control. Static instances are provided for the * common types. * * @author Kara Kytle @@ -122,19 +98,13 @@ public abstract class CompoundControl extends Control { */ public static class Type extends Control.Type { - - // TYPE DEFINES - - // CONSTRUCTOR - - /** * Constructs a new compound control type. - * @param name the name of the new compound control type + * + * @param name the name of the new compound control type */ - protected Type(String name) { + protected Type(final String name) { super(name); } - } // class Type - -} // class CompoundControl + } +} diff --git a/jdk/src/share/classes/javax/sound/sampled/Control.java b/jdk/src/share/classes/javax/sound/sampled/Control.java index 6b8b9c6a5e4..a3257b8539e 100644 --- a/jdk/src/share/classes/javax/sound/sampled/Control.java +++ b/jdk/src/share/classes/javax/sound/sampled/Control.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,121 +26,102 @@ package javax.sound.sampled; /** - * {@link Line Lines} often have a set of controls, such as gain and pan, that affect - * the audio signal passing through the line. Java Sound's Line objects - * let you obtain a particular control object by passing its class as the - * argument to a {@link Line#getControl(Control.Type) getControl} method. + * {@link Line Lines} often have a set of controls, such as gain and pan, that + * affect the audio signal passing through the line. Java Sound's {@code Line} + * objects let you obtain a particular control object by passing its class as + * the argument to a {@link Line#getControl(Control.Type) getControl} method. *

    * Because the various types of controls have different purposes and features, - * all of their functionality is accessed from the subclasses that define - * each kind of control. + * all of their functionality is accessed from the subclasses that define each + * kind of control. * * @author Kara Kytle - * * @see Line#getControls * @see Line#isControlSupported * @since 1.3 */ public abstract class Control { - - // INSTANCE VARIABLES - /** * The control type. */ private final Type type; - - - // CONSTRUCTORS - /** * Constructs a Control with the specified type. - * @param type the kind of control desired + * + * @param type the kind of control desired */ protected Control(Type type) { this.type = type; } - - // METHODS - /** * Obtains the control's type. - * @return the control's type. + * + * @return the control's type */ public Type getType() { return type; } - - // ABSTRACT METHODS - /** * Obtains a String describing the control type and its current state. - * @return a String representation of the Control. + * + * @return a String representation of the Control */ + @Override public String toString() { return new String(getType() + " Control"); } - /** - * An instance of the Type class represents the type of - * the control. Static instances are provided for the - * common types. + * An instance of the {@code Type} class represents the type of the control. + * Static instances are provided for the common types. */ public static class Type { - // CONTROL TYPE DEFINES - - // INSTANCE VARIABLES - /** * Type name. */ private String name; - - // CONSTRUCTOR - /** - * Constructs a new control type with the name specified. - * The name should be a descriptive string appropriate for - * labelling the control in an application, such as "Gain" or "Balance." - * @param name the name of the new control type. + * Constructs a new control type with the name specified. The name + * should be a descriptive string appropriate for labelling the control + * in an application, such as "Gain" or "Balance". + * + * @param name the name of the new control type */ protected Type(String name) { this.name = name; } - - // METHODS - /** - * Finalizes the equals method + * Finalizes the equals method. */ + @Override public final boolean equals(Object obj) { return super.equals(obj); } /** - * Finalizes the hashCode method + * Finalizes the hashCode method. */ + @Override public final int hashCode() { return super.hashCode(); } /** - * Provides the String representation of the control type. This String is - * the same name that was passed to the constructor. + * Provides the {@code String} representation of the control type. This + * {@code String} is the same name that was passed to the constructor. * * @return the control type name */ + @Override public final String toString() { return name; } - } // class Type - -} // class Control + } +} diff --git a/jdk/src/share/classes/javax/sound/sampled/DataLine.java b/jdk/src/share/classes/javax/sound/sampled/DataLine.java index d0030c9baae..9a81a76c5b6 100644 --- a/jdk/src/share/classes/javax/sound/sampled/DataLine.java +++ b/jdk/src/share/classes/javax/sound/sampled/DataLine.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 @@ -28,40 +28,35 @@ package javax.sound.sampled; import java.util.Arrays; /** - * DataLine adds media-related functionality to its - * superinterface, {@link Line}. This functionality includes - * transport-control methods that start, stop, drain, and flush - * the audio data that passes through the line. A data line can also - * report the current position, volume, and audio format of the media. - * Data lines are used for output of audio by means of the - * subinterfaces {@link SourceDataLine} or - * {@link Clip}, which allow an application program to write data. Similarly, - * audio input is handled by the subinterface {@link TargetDataLine}, - * which allows data to be read. + * {@code DataLine} adds media-related functionality to its superinterface, + * {@code Line}. This functionality includes transport-control methods that + * start, stop, drain, and flush the audio data that passes through the line. A + * data line can also report the current position, volume, and audio format of + * the media. Data lines are used for output of audio by means of the + * subinterfaces {@link SourceDataLine} or {@link Clip}, which allow an + * application program to write data. Similarly, audio input is handled by the + * subinterface {@link TargetDataLine}, which allows data to be read. *

    - * A data line has an internal buffer in which - * the incoming or outgoing audio data is queued. The - * {@link #drain()} method blocks until this internal buffer - * becomes empty, usually because all queued data has been processed. The - * {@link #flush()} method discards any available queued data - * from the internal buffer. + * A data line has an internal buffer in which the incoming or outgoing audio + * data is queued. The {@link #drain()} method blocks until this internal buffer + * becomes empty, usually because all queued data has been processed. The + * {@link #flush()} method discards any available queued data from the internal + * buffer. *

    - * A data line produces {@link LineEvent.Type#START START} and - * {@link LineEvent.Type#STOP STOP} events whenever - * it begins or ceases active presentation or capture of data. These events - * can be generated in response to specific requests, or as a result of - * less direct state changes. For example, if {@link #start()} is called - * on an inactive data line, and data is available for capture or playback, a - * START event will be generated shortly, when data playback - * or capture actually begins. Or, if the flow of data to an active data - * line is constricted so that a gap occurs in the presentation of data, - * a STOP event is generated. + * A data line produces {@link LineEvent.Type#START START} and + * {@link LineEvent.Type#STOP STOP} events whenever it begins or ceases active + * presentation or capture of data. These events can be generated in response to + * specific requests, or as a result of less direct state changes. For example, + * if {@link #start()} is called on an inactive data line, and data is available + * for capture or playback, a {@code START} event will be generated shortly, + * when data playback or capture actually begins. Or, if the flow of data to an + * active data line is constricted so that a gap occurs in the presentation of + * data, a {@code STOP} event is generated. *

    * Mixers often support synchronized control of multiple data lines. * Synchronization can be established through the Mixer interface's - * {@link Mixer#synchronize synchronize} method. - * See the description of the {@link Mixer Mixer} interface - * for a more complete description. + * {@link Mixer#synchronize synchronize} method. See the description of the + * {@link Mixer Mixer} interface for a more complete description. * * @author Kara Kytle * @see LineEvent @@ -69,220 +64,217 @@ import java.util.Arrays; */ public interface DataLine extends Line { - /** - * Drains queued data from the line by continuing data I/O until the - * data line's internal buffer has been emptied. - * This method blocks until the draining is complete. Because this is a - * blocking method, it should be used with care. If drain() - * is invoked on a stopped line that has data in its queue, the method will - * block until the line is running and the data queue becomes empty. If - * drain() is invoked by one thread, and another continues to - * fill the data queue, the operation will not complete. - * This method always returns when the data line is closed. + * Drains queued data from the line by continuing data I/O until the data + * line's internal buffer has been emptied. This method blocks until the + * draining is complete. Because this is a blocking method, it should be + * used with care. If {@code drain()} is invoked on a stopped line that has + * data in its queue, the method will block until the line is running and + * the data queue becomes empty. If {@code drain()} is invoked by one + * thread, and another continues to fill the data queue, the operation will + * not complete. This method always returns when the data line is closed. * * @see #flush() */ - public void drain(); + void drain(); /** - * Flushes queued data from the line. The flushed data is discarded. - * In some cases, not all queued data can be discarded. For example, a - * mixer can flush data from the buffer for a specific input line, but any - * unplayed data already in the output buffer (the result of the mix) will - * still be played. You can invoke this method after pausing a line (the - * normal case) if you want to skip the "stale" data when you restart - * playback or capture. (It is legal to flush a line that is not stopped, - * but doing so on an active line is likely to cause a discontinuity in the - * data, resulting in a perceptible click.) + * Flushes queued data from the line. The flushed data is discarded. In some + * cases, not all queued data can be discarded. For example, a mixer can + * flush data from the buffer for a specific input line, but any unplayed + * data already in the output buffer (the result of the mix) will still be + * played. You can invoke this method after pausing a line (the normal case) + * if you want to skip the "stale" data when you restart playback or + * capture. (It is legal to flush a line that is not stopped, but doing so + * on an active line is likely to cause a discontinuity in the data, + * resulting in a perceptible click.) * * @see #stop() * @see #drain() */ - public void flush(); + void flush(); /** - * Allows a line to engage in data I/O. If invoked on a line - * that is already running, this method does nothing. Unless the data in - * the buffer has been flushed, the line resumes I/O starting - * with the first frame that was unprocessed at the time the line was - * stopped. When audio capture or playback starts, a - * {@link LineEvent.Type#START START} event is generated. + * Allows a line to engage in data I/O. If invoked on a line that is already + * running, this method does nothing. Unless the data in the buffer has been + * flushed, the line resumes I/O starting with the first frame that was + * unprocessed at the time the line was stopped. When audio capture or + * playback starts, a {@link LineEvent.Type#START START} event is generated. * * @see #stop() * @see #isRunning() * @see LineEvent */ - public void start(); + void start(); /** - * Stops the line. A stopped line should cease I/O activity. - * If the line is open and running, however, it should retain the resources required - * to resume activity. A stopped line should retain any audio data in its buffer - * instead of discarding it, so that upon resumption the I/O can continue where it left off, - * if possible. (This doesn't guarantee that there will never be discontinuities beyond the - * current buffer, of course; if the stopped condition continues - * for too long, input or output samples might be dropped.) If desired, the retained data can be - * discarded by invoking the flush method. - * When audio capture or playback stops, a {@link LineEvent.Type#STOP STOP} event is generated. + * Stops the line. A stopped line should cease I/O activity. If the line is + * open and running, however, it should retain the resources required to + * resume activity. A stopped line should retain any audio data in its + * buffer instead of discarding it, so that upon resumption the I/O can + * continue where it left off, if possible. (This doesn't guarantee that + * there will never be discontinuities beyond the current buffer, of course; + * if the stopped condition continues for too long, input or output samples + * might be dropped.) If desired, the retained data can be discarded by + * invoking the {@code flush} method. When audio capture or playback stops, + * a {@link LineEvent.Type#STOP STOP} event is generated. * * @see #start() * @see #isRunning() * @see #flush() * @see LineEvent */ - public void stop(); + void stop(); /** - * Indicates whether the line is running. The default is false. - * An open line begins running when the first data is presented in response to an - * invocation of the start method, and continues - * until presentation ceases in response to a call to stop or - * because playback completes. - * @return true if the line is running, otherwise false + * Indicates whether the line is running. The default is {@code false}. An + * open line begins running when the first data is presented in response to + * an invocation of the {@code start} method, and continues until + * presentation ceases in response to a call to {@code stop} or because + * playback completes. + * + * @return {@code true} if the line is running, otherwise {@code false} * @see #start() * @see #stop() */ - public boolean isRunning(); + boolean isRunning(); /** - * Indicates whether the line is engaging in active I/O (such as playback - * or capture). When an inactive line becomes active, it sends a - * {@link LineEvent.Type#START START} event to its listeners. Similarly, when - * an active line becomes inactive, it sends a - * {@link LineEvent.Type#STOP STOP} event. - * @return true if the line is actively capturing or rendering - * sound, otherwise false + * Indicates whether the line is engaging in active I/O (such as playback or + * capture). When an inactive line becomes active, it sends a + * {@link LineEvent.Type#START START} event to its listeners. Similarly, + * when an active line becomes inactive, it sends a + * {@link LineEvent.Type#STOP STOP} event. + * + * @return {@code true} if the line is actively capturing or rendering + * sound, otherwise {@code false} * @see #isOpen * @see #addLineListener * @see #removeLineListener * @see LineEvent * @see LineListener */ - public boolean isActive(); + boolean isActive(); /** * Obtains the current format (encoding, sample rate, number of channels, * etc.) of the data line's audio data. - * - *

    If the line is not open and has never been opened, it returns - * the default format. The default format is an implementation - * specific audio format, or, if the DataLine.Info - * object, which was used to retrieve this DataLine, - * specifies at least one fully qualified audio format, the - * last one will be used as the default format. Opening the - * line with a specific audio format (e.g. - * {@link SourceDataLine#open(AudioFormat)}) will override the - * default format. + *

    + * If the line is not open and has never been opened, it returns the default + * format. The default format is an implementation specific audio format, + * or, if the {@code DataLine.Info} object, which was used to retrieve this + * {@code DataLine}, specifies at least one fully qualified audio format, + * the last one will be used as the default format. Opening the line with a + * specific audio format (e.g. {@link SourceDataLine#open(AudioFormat)}) + * will override the default format. * * @return current audio data format * @see AudioFormat */ - public AudioFormat getFormat(); + AudioFormat getFormat(); /** - * Obtains the maximum number of bytes of data that will fit in the data line's - * internal buffer. For a source data line, this is the size of the buffer to - * which data can be written. For a target data line, it is the size of - * the buffer from which data can be read. Note that - * the units used are bytes, but will always correspond to an integral - * number of sample frames of audio data. + * Obtains the maximum number of bytes of data that will fit in the data + * line's internal buffer. For a source data line, this is the size of the + * buffer to which data can be written. For a target data line, it is the + * size of the buffer from which data can be read. Note that the units used + * are bytes, but will always correspond to an integral number of sample + * frames of audio data. * * @return the size of the buffer in bytes */ - public int getBufferSize(); + int getBufferSize(); /** * Obtains the number of bytes of data currently available to the - * application for processing in the data line's internal buffer. For a + * application for processing in the data line's internal buffer. For a * source data line, this is the amount of data that can be written to the - * buffer without blocking. For a target data line, this is the amount of data - * available to be read by the application. For a clip, this value is always - * 0 because the audio data is loaded into the buffer when the clip is opened, - * and persists without modification until the clip is closed. + * buffer without blocking. For a target data line, this is the amount of + * data available to be read by the application. For a clip, this value is + * always 0 because the audio data is loaded into the buffer when the clip + * is opened, and persists without modification until the clip is closed. *

    - * Note that the units used are bytes, but will always - * correspond to an integral number of sample frames of audio data. + * Note that the units used are bytes, but will always correspond to an + * integral number of sample frames of audio data. *

    - * An application is guaranteed that a read or - * write operation of up to the number of bytes returned from - * available() will not block; however, there is no guarantee - * that attempts to read or write more data will block. + * An application is guaranteed that a read or write operation of up to the + * number of bytes returned from {@code available()} will not block; + * however, there is no guarantee that attempts to read or write more data + * will block. * * @return the amount of data available, in bytes */ - public int available(); + int available(); /** - * Obtains the current position in the audio data, in sample frames. - * The frame position measures the number of sample - * frames captured by, or rendered from, the line since it was opened. - * This return value will wrap around after 2^31 frames. It is recommended - * to use getLongFramePosition instead. + * Obtains the current position in the audio data, in sample frames. The + * frame position measures the number of sample frames captured by, or + * rendered from, the line since it was opened. This return value will wrap + * around after 2^31 frames. It is recommended to use + * {@code getLongFramePosition} instead. * * @return the number of frames already processed since the line was opened * @see #getLongFramePosition() */ - public int getFramePosition(); - + int getFramePosition(); /** - * Obtains the current position in the audio data, in sample frames. - * The frame position measures the number of sample - * frames captured by, or rendered from, the line since it was opened. + * Obtains the current position in the audio data, in sample frames. The + * frame position measures the number of sample frames captured by, or + * rendered from, the line since it was opened. * * @return the number of frames already processed since the line was opened * @since 1.5 */ - public long getLongFramePosition(); - + long getLongFramePosition(); /** - * Obtains the current position in the audio data, in microseconds. - * The microsecond position measures the time corresponding to the number - * of sample frames captured by, or rendered from, the line since it was opened. - * The level of precision is not guaranteed. For example, an implementation - * might calculate the microsecond position from the current frame position - * and the audio sample frame rate. The precision in microseconds would - * then be limited to the number of microseconds per sample frame. + * Obtains the current position in the audio data, in microseconds. The + * microsecond position measures the time corresponding to the number of + * sample frames captured by, or rendered from, the line since it was + * opened. The level of precision is not guaranteed. For example, an + * implementation might calculate the microsecond position from the current + * frame position and the audio sample frame rate. The precision in + * microseconds would then be limited to the number of microseconds per + * sample frame. * - * @return the number of microseconds of data processed since the line was opened + * @return the number of microseconds of data processed since the line was + * opened */ - public long getMicrosecondPosition(); + long getMicrosecondPosition(); /** - * Obtains the current volume level for the line. This level is a measure - * of the signal's current amplitude, and should not be confused with the - * current setting of a gain control. The range is from 0.0 (silence) to - * 1.0 (maximum possible amplitude for the sound waveform). The units - * measure linear amplitude, not decibels. + * Obtains the current volume level for the line. This level is a measure of + * the signal's current amplitude, and should not be confused with the + * current setting of a gain control. The range is from 0.0 (silence) to 1.0 + * (maximum possible amplitude for the sound waveform). The units measure + * linear amplitude, not decibels. * * @return the current amplitude of the signal in this line, or - * {@link AudioSystem#NOT_SPECIFIED} + * {@link AudioSystem#NOT_SPECIFIED} */ - public float getLevel(); + float getLevel(); /** * Besides the class information inherited from its superclass, - * DataLine.Info provides additional information specific to data lines. - * This information includes: + * {@code DataLine.Info} provides additional information specific to data + * lines. This information includes: *

      *
    • the audio formats supported by the data line *
    • the minimum and maximum sizes of its internal buffer *
    - * Because a Line.Info knows the class of the line its describes, a - * DataLine.Info object can describe DataLine - * subinterfaces such as {@link SourceDataLine}, - * {@link TargetDataLine}, and {@link Clip}. - * You can query a mixer for lines of any of these types, passing an appropriate - * instance of DataLine.Info as the argument to a method such as - * {@link Mixer#getLine Mixer.getLine(Line.Info)}. + * Because a {@code Line.Info} knows the class of the line its describes, a + * {@code DataLine.Info} object can describe {@code DataLine} subinterfaces + * such as {@link SourceDataLine}, {@link TargetDataLine}, and {@link Clip}. + * You can query a mixer for lines of any of these types, passing an + * appropriate instance of {@code DataLine.Info} as the argument to a method + * such as {@link Mixer#getLine(Line.Info)}. * * @see Line.Info * @author Kara Kytle * @since 1.3 */ - public static class Info extends Line.Info { + class Info extends Line.Info { private final AudioFormat[] formats; private final int minBufferSize; @@ -290,14 +282,17 @@ public interface DataLine extends Line { /** * Constructs a data line's info object from the specified information, - * which includes a set of supported audio formats and a range for the buffer size. - * This constructor is typically used by mixer implementations - * when returning information about a supported line. + * which includes a set of supported audio formats and a range for the + * buffer size. This constructor is typically used by mixer + * implementations when returning information about a supported line. * - * @param lineClass the class of the data line described by the info object - * @param formats set of formats supported - * @param minBufferSize minimum buffer size supported by the data line, in bytes - * @param maxBufferSize maximum buffer size supported by the data line, in bytes + * @param lineClass the class of the data line described by the info + * object + * @param formats set of formats supported + * @param minBufferSize minimum buffer size supported by the data + * line, in bytes + * @param maxBufferSize maximum buffer size supported by the data + * line, in bytes */ public Info(Class lineClass, AudioFormat[] formats, int minBufferSize, int maxBufferSize) { @@ -313,16 +308,16 @@ public interface DataLine extends Line { this.maxBufferSize = maxBufferSize; } - /** * Constructs a data line's info object from the specified information, - * which includes a single audio format and a desired buffer size. - * This constructor is typically used by an application to - * describe a desired line. + * which includes a single audio format and a desired buffer size. This + * constructor is typically used by an application to describe a desired + * line. * - * @param lineClass the class of the data line described by the info object - * @param format desired format - * @param bufferSize desired buffer size in bytes + * @param lineClass the class of the data line described by the info + * object + * @param format desired format + * @param bufferSize desired buffer size in bytes */ public Info(Class lineClass, AudioFormat format, int bufferSize) { @@ -338,39 +333,36 @@ public interface DataLine extends Line { this.maxBufferSize = bufferSize; } - /** * Constructs a data line's info object from the specified information, - * which includes a single audio format. - * This constructor is typically used by an application to - * describe a desired line. + * which includes a single audio format. This constructor is typically + * used by an application to describe a desired line. * - * @param lineClass the class of the data line described by the info object - * @param format desired format + * @param lineClass the class of the data line described by the info + * object + * @param format desired format */ public Info(Class lineClass, AudioFormat format) { this(lineClass, format, AudioSystem.NOT_SPECIFIED); } - /** - * Obtains a set of audio formats supported by the data line. - * Note that isFormatSupported(AudioFormat) might return - * true for certain additional formats that are missing from - * the set returned by getFormats(). The reverse is not - * the case: isFormatSupported(AudioFormat) is guaranteed to return - * true for all formats returned by getFormats(). - * + * Obtains a set of audio formats supported by the data line. Note that + * {@code isFormatSupported(AudioFormat)} might return {@code true} for + * certain additional formats that are missing from the set returned by + * {@code getFormats()}. The reverse is not the case: + * {@code isFormatSupported(AudioFormat)} is guaranteed to return + * {@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 - * AudioFormat instances returned by this - * method to 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. + * @return a set of supported audio formats * @see #isFormatSupported(AudioFormat) */ public AudioFormat[] getFormats() { @@ -379,11 +371,12 @@ public interface DataLine extends Line { /** * Indicates whether this data line supports a particular audio format. - * The default implementation of this method simply returns true if - * the specified format matches any of the supported formats. + * The default implementation of this method simply returns {@code true} + * if the specified format matches any of the supported formats. * - * @param format the audio format for which support is queried. - * @return true if the format is supported, otherwise false + * @param format the audio format for which support is queried + * @return {@code true} if the format is supported, otherwise + * {@code false} * @see #getFormats * @see AudioFormat#matches */ @@ -400,32 +393,36 @@ public interface DataLine extends Line { /** * Obtains the minimum buffer size supported by the data line. - * @return minimum buffer size in bytes, or AudioSystem.NOT_SPECIFIED + * + * @return minimum buffer size in bytes, or + * {@code AudioSystem.NOT_SPECIFIED} */ public int getMinBufferSize() { return minBufferSize; } - /** * Obtains the maximum buffer size supported by the data line. - * @return maximum buffer size in bytes, or AudioSystem.NOT_SPECIFIED + * + * @return maximum buffer size in bytes, or + * {@code AudioSystem.NOT_SPECIFIED} */ public int getMaxBufferSize() { return maxBufferSize; } - /** - * Determines whether the specified info object matches this one. - * To match, the superclass match requirements must be met. In - * addition, this object's minimum buffer size must be at least as - * large as that of the object specified, its maximum buffer size must - * be at most as large as that of the object specified, and all of its - * formats must match formats supported by the object specified. - * @return true if this object matches the one specified, - * otherwise false. + * Determines whether the specified info object matches this one. To + * match, the superclass match requirements must be met. In addition, + * this object's minimum buffer size must be at least as large as that + * of the object specified, its maximum buffer size must be at most as + * large as that of the object specified, and all of its formats must + * match formats supported by the object specified. + * + * @return {@code true} if this object matches the one specified, + * otherwise {@code false} */ + @Override public boolean matches(Line.Info info) { if (! (super.matches(info)) ) { @@ -467,28 +464,29 @@ public interface DataLine extends Line { /** * Obtains a textual description of the data line info. + * * @return a string description */ + @Override public String toString() { - StringBuffer buf = new StringBuffer(); + StringBuilder sb = new StringBuilder(); if ( (formats.length == 1) && (formats[0] != null) ) { - buf.append(" supporting format " + formats[0]); + sb.append(" supporting format " + formats[0]); } else if (getFormats().length > 1) { - buf.append(" supporting " + getFormats().length + " audio formats"); + sb.append(" supporting " + getFormats().length + " audio formats"); } if ( (minBufferSize != AudioSystem.NOT_SPECIFIED) && (maxBufferSize != AudioSystem.NOT_SPECIFIED) ) { - buf.append(", and buffers of " + minBufferSize + " to " + maxBufferSize + " bytes"); + sb.append(", and buffers of " + minBufferSize + " to " + maxBufferSize + " bytes"); } else if ( (minBufferSize != AudioSystem.NOT_SPECIFIED) && (minBufferSize > 0) ) { - buf.append(", and buffers of at least " + minBufferSize + " bytes"); + sb.append(", and buffers of at least " + minBufferSize + " bytes"); } else if (maxBufferSize != AudioSystem.NOT_SPECIFIED) { - buf.append(", and buffers of up to " + minBufferSize + " bytes"); + sb.append(", and buffers of up to " + minBufferSize + " bytes"); } - return new String(super.toString() + buf); + return new String(super.toString() + sb); } - } // class Info - -} // interface DataLine + } +} diff --git a/jdk/src/share/classes/javax/sound/sampled/EnumControl.java b/jdk/src/share/classes/javax/sound/sampled/EnumControl.java index d9f4baccbda..c029f224ebc 100644 --- a/jdk/src/share/classes/javax/sound/sampled/EnumControl.java +++ b/jdk/src/share/classes/javax/sound/sampled/EnumControl.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 @@ -26,83 +26,63 @@ package javax.sound.sampled; /** - * A EnumControl provides control over a set of - * discrete possible values, each represented by an object. In a - * graphical user interface, such a control might be represented - * by a set of buttons, each of which chooses one value or setting. For - * example, a reverb control might provide several preset reverberation - * settings, instead of providing continuously adjustable parameters - * of the sort that would be represented by {@link FloatControl} + * A {@code EnumControl} provides control over a set of discrete possible values + * , each represented by an object. In a graphical user interface, such a + * control might be represented by a set of buttons, each of which chooses one + * value or setting. For example, a reverb control might provide several preset + * reverberation settings, instead of providing continuously adjustable + * parameters of the sort that would be represented by {@link FloatControl} * objects. *

    - * Controls that provide a choice between only two settings can often be implemented - * instead as a {@link BooleanControl}, and controls that provide - * a set of values along some quantifiable dimension might be implemented - * instead as a FloatControl with a coarse resolution. - * However, a key feature of EnumControl is that the returned values - * are arbitrary objects, rather than numerical or boolean values. This means that each - * returned object can provide further information. As an example, the settings - * of a {@link EnumControl.Type#REVERB REVERB} control are instances of - * {@link ReverbType} that can be queried for the parameter values - * used for each setting. + * Controls that provide a choice between only two settings can often be + * implemented instead as a {@link BooleanControl}, and controls that provide a + * set of values along some quantifiable dimension might be implemented instead + * as a {@code FloatControl} with a coarse resolution. However, a key feature of + * {@code EnumControl} is that the returned values are arbitrary objects, rather + * than numerical or boolean values. This means that each returned object can + * provide further information. As an example, the settings of a + * {@link EnumControl.Type#REVERB REVERB} control are instances of + * {@link ReverbType} that can be queried for the parameter values used for each + * setting. * * @author Kara Kytle * @since 1.3 */ public abstract class EnumControl extends Control { - - // TYPE DEFINES - - - // INSTANCE VARIABLES - - /** * The set of possible values. */ private Object[] values; - /** * The current value. */ private Object value; - - - // CONSTRUCTORS - - /** * Constructs a new enumerated control object with the given parameters. * - * @param type the type of control represented this enumerated control object - * @param values the set of possible values for the control - * @param value the initial control value + * @param type the type of control represented this enumerated control + * object + * @param values the set of possible values for the control + * @param value the initial control value */ protected EnumControl(Type type, Object[] values, Object value) { - super(type); - this.values = values; this.value = value; } - - - // METHODS - - /** - * Sets the current value for the control. The default implementation - * simply sets the value as indicated. If the value indicated is not - * supported, an IllegalArgumentException is thrown. - * Some controls require that their line be open before they can be affected - * by setting a value. - * @param value the desired new value + * Sets the current value for the control. The default implementation simply + * sets the value as indicated. If the value indicated is not supported, an + * {@code IllegalArgumentException} is thrown. Some controls require that + * their line be open before they can be affected by setting a value. + * + * @param value the desired new value * @throws IllegalArgumentException if the value indicated does not fall - * within the allowable range + * within the allowable range */ public void setValue(Object value) { if (!isValueSupported(value)) { @@ -112,18 +92,18 @@ public abstract class EnumControl extends Control { this.value = value; } - /** * Obtains this control's current value. + * * @return the current value */ public Object getValue() { return value; } - /** * Returns the set of possible values for this control. + * * @return the set of possible values */ public Object[] getValues() { @@ -137,12 +117,11 @@ public abstract class EnumControl extends Control { return localArray; } - /** * Indicates whether the value specified is supported. - * @param value the value for which support is queried - * @return true if the value is supported, - * otherwise false + * + * @param value the value for which support is queried + * @return {@code true} if the value is supported, otherwise {@code false} */ private boolean isValueSupported(Object value) { @@ -157,58 +136,43 @@ public abstract class EnumControl extends Control { return false; } - - - // ABSTRACT METHOD IMPLEMENTATIONS: CONTROL - - /** * Provides a string representation of the control. + * * @return a string description */ + @Override public String toString() { return new String(getType() + " with current value: " + getValue()); } - - // INNER CLASSES - - /** - * An instance of the EnumControl.Type inner class identifies one kind of - * enumerated control. Static instances are provided for the - * common types. - * - * @see EnumControl + * An instance of the {@code EnumControl.Type} inner class identifies one + * kind of enumerated control. Static instances are provided for the common + * types. * * @author Kara Kytle + * @see EnumControl * @since 1.3 */ public static class Type extends Control.Type { - - // TYPE DEFINES - /** * Represents a control over a set of possible reverberation settings. * Each reverberation setting is described by an instance of the - * {@link ReverbType} class. (To access these settings, - * invoke {@link EnumControl#getValues} on an - * enumerated control of type REVERB.) + * {@link ReverbType} class. (To access these settings, invoke + * {@link EnumControl#getValues} on an enumerated control of type + * {@code REVERB}.) */ public static final Type REVERB = new Type("Reverb"); - - // CONSTRUCTOR - - /** * Constructs a new enumerated control type. - * @param name the name of the new enumerated control type + * + * @param name the name of the new enumerated control type */ - protected Type(String name) { + protected Type(final String name) { super(name); } - } // class Type - -} // class EnumControl + } +} diff --git a/jdk/src/share/classes/javax/sound/sampled/FloatControl.java b/jdk/src/share/classes/javax/sound/sampled/FloatControl.java index b2678d11428..27d59fefe1f 100644 --- a/jdk/src/share/classes/javax/sound/sampled/FloatControl.java +++ b/jdk/src/share/classes/javax/sound/sampled/FloatControl.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 @@ -26,39 +26,31 @@ package javax.sound.sampled; /** - * A FloatControl object provides control over a range of - * floating-point values. Float controls are often - * represented in graphical user interfaces by continuously - * adjustable objects such as sliders or rotary knobs. Concrete subclasses - * of FloatControl implement controls, such as gain and pan, that - * affect a line's audio signal in some way that an application can manipulate. - * The {@link FloatControl.Type} - * inner class provides static instances of types that are used to - * identify some common kinds of float control. + * A {@code FloatControl} object provides control over a range of floating-point + * values. Float controls are often represented in graphical user interfaces by + * continuously adjustable objects such as sliders or rotary knobs. Concrete + * subclasses of {@code FloatControl} implement controls, such as gain and pan, + * that affect a line's audio signal in some way that an application can + * manipulate. The {@link FloatControl.Type} inner class provides static + * instances of types that are used to identify some common kinds of float + * control. *

    - * The FloatControl abstract class provides methods to set and get - * the control's current floating-point value. Other methods obtain the possible + * The {@code FloatControl} abstract class provides methods to set and get the + * control's current floating-point value. Other methods obtain the possible * range of values and the control's resolution (the smallest increment between - * returned values). Some float controls allow ramping to a - * new value over a specified period of time. FloatControl also - * includes methods that return string labels for the minimum, maximum, and midpoint - * positions of the control. - * - * @see Line#getControls - * @see Line#isControlSupported + * returned values). Some float controls allow ramping to a new value over a + * specified period of time. {@code FloatControl} also includes methods that + * return string labels for the minimum, maximum, and midpoint positions of the + * control. * * @author David Rivas * @author Kara Kytle + * @see Line#getControls + * @see Line#isControlSupported * @since 1.3 */ public abstract class FloatControl extends Control { - - // INSTANCE VARIABLES - - - // FINAL VARIABLES - /** * The minimum supported value. */ @@ -75,66 +67,60 @@ public abstract class FloatControl extends Control { private float precision; /** - * The smallest time increment in which a value change - * can be effected during a value shift, in microseconds. + * The smallest time increment in which a value change can be effected + * during a value shift, in microseconds. */ private int updatePeriod; - /** - * A label for the units in which the control values are expressed, - * such as "dB" for decibels. + * A label for the units in which the control values are expressed, such as + * "dB" for decibels. */ private final String units; /** - * A label for the minimum value, such as "Left." + * A label for the minimum value, such as "Left". */ private final String minLabel; /** - * A label for the maximum value, such as "Right." + * A label for the maximum value, such as "Right". */ private final String maxLabel; /** - * A label for the mid-point value, such as "Center." + * A label for the mid-point value, such as "Center". */ private final String midLabel; - - // STATE VARIABLES - /** * The current value. */ private float value; - - - // CONSTRUCTORS - - /** - * Constructs a new float control object with the given parameters + * Constructs a new float control object with the given parameters. * - * @param type the kind of control represented by this float control object - * @param minimum the smallest value permitted for the control - * @param maximum the largest value permitted for the control - * @param precision the resolution or granularity of the control. - * This is the size of the increment between discrete valid values. - * @param updatePeriod the smallest time interval, in microseconds, over which the control - * can change from one discrete value to the next during a {@link #shift(float,float,int) shift} - * @param initialValue the value that the control starts with when constructed - * @param units the label for the units in which the control's values are expressed, - * such as "dB" or "frames per second" - * @param minLabel the label for the minimum value, such as "Left" or "Off" - * @param midLabel the label for the midpoint value, such as "Center" or "Default" - * @param maxLabel the label for the maximum value, such as "Right" or "Full" - * - * @throws IllegalArgumentException if {@code minimum} is greater - * than {@code maximum} or {@code initialValue} does not fall - * within the allowable range + * @param type the kind of control represented by this float control object + * @param minimum the smallest value permitted for the control + * @param maximum the largest value permitted for the control + * @param precision the resolution or granularity of the control. This is + * the size of the increment between discrete valid values. + * @param updatePeriod the smallest time interval, in microseconds, over + * which the control can change from one discrete value to the next + * during a {@link #shift(float,float,int) shift} + * @param initialValue the value that the control starts with when + * constructed + * @param units the label for the units in which the control's values are + * expressed, such as "dB" or "frames per second" + * @param minLabel the label for the minimum value, such as "Left" or "Off" + * @param midLabel the label for the midpoint value, such as "Center" or + * "Default" + * @param maxLabel the label for the maximum value, such as "Right" or + * "Full" + * @throws IllegalArgumentException if {@code minimum} is greater than + * {@code maximum} or {@code initialValue} does not fall within the + * allowable range */ protected FloatControl(Type type, float minimum, float maximum, float precision, int updatePeriod, float initialValue, @@ -169,26 +155,26 @@ public abstract class FloatControl extends Control { this.maxLabel = ( (maxLabel == null) ? "" : maxLabel); } - /** - * Constructs a new float control object with the given parameters. - * The labels for the minimum, maximum, and mid-point values are set - * to zero-length strings. + * Constructs a new float control object with the given parameters. The + * labels for the minimum, maximum, and mid-point values are set to + * zero-length strings. * - * @param type the kind of control represented by this float control object - * @param minimum the smallest value permitted for the control - * @param maximum the largest value permitted for the control - * @param precision the resolution or granularity of the control. - * This is the size of the increment between discrete valid values. - * @param updatePeriod the smallest time interval, in microseconds, over which the control - * can change from one discrete value to the next during a {@link #shift(float,float,int) shift} - * @param initialValue the value that the control starts with when constructed - * @param units the label for the units in which the control's values are expressed, - * such as "dB" or "frames per second" - * - * @throws IllegalArgumentException if {@code minimum} is greater - * than {@code maximum} or {@code initialValue} does not fall - * within the allowable range + * @param type the kind of control represented by this float control object + * @param minimum the smallest value permitted for the control + * @param maximum the largest value permitted for the control + * @param precision the resolution or granularity of the control. This is + * the size of the increment between discrete valid values. + * @param updatePeriod the smallest time interval, in microseconds, over + * which the control can change from one discrete value to the next + * during a {@link #shift(float,float,int) shift} + * @param initialValue the value that the control starts with when + * constructed + * @param units the label for the units in which the control's values are + * expressed, such as "dB" or "frames per second" + * @throws IllegalArgumentException if {@code minimum} is greater than + * {@code maximum} or {@code initialValue} does not fall within the + * allowable range */ protected FloatControl(Type type, float minimum, float maximum, float precision, int updatePeriod, float initialValue, String units) { @@ -196,21 +182,16 @@ public abstract class FloatControl extends Control { initialValue, units, "", "", ""); } - - - // METHODS - - /** - * Sets the current value for the control. The default implementation - * simply sets the value as indicated. If the value indicated is greater - * than the maximum value, or smaller than the minimum value, an - * IllegalArgumentException is thrown. - * Some controls require that their line be open before they can be affected - * by setting a value. - * @param newValue desired new value + * Sets the current value for the control. The default implementation simply + * sets the value as indicated. If the value indicated is greater than the + * maximum value, or smaller than the minimum value, an + * {@code IllegalArgumentException} is thrown. Some controls require that + * their line be open before they can be affected by setting a value. + * + * @param newValue desired new value * @throws IllegalArgumentException if the value indicated does not fall - * within the allowable range + * within the allowable range */ public void setValue(float newValue) { @@ -225,113 +206,114 @@ public abstract class FloatControl extends Control { value = newValue; } - /** * Obtains this control's current value. + * * @return the current value */ public float getValue() { return value; } - /** * Obtains the maximum value permitted. + * * @return the maximum allowable value */ public float getMaximum() { return maximum; } - /** * Obtains the minimum value permitted. + * * @return the minimum allowable value */ public float getMinimum() { return minimum; } - /** - * Obtains the label for the units in which the control's values are expressed, - * such as "dB" or "frames per second." + * Obtains the label for the units in which the control's values are + * expressed, such as "dB" or "frames per second." + * * @return the units label, or a zero-length string if no label */ public String getUnits() { return units; } - /** - * Obtains the label for the minimum value, such as "Left" or "Off." - * @return the minimum value label, or a zero-length string if no label * has been set + * Obtains the label for the minimum value, such as "Left" or "Off". + * + * @return the minimum value label, or a zero-length string if no label has + * been set */ public String getMinLabel() { return minLabel; } - /** - * Obtains the label for the mid-point value, such as "Center" or "Default." - * @return the mid-point value label, or a zero-length string if no label * has been set + * Obtains the label for the mid-point value, such as "Center" or "Default". + * + * @return the mid-point value label, or a zero-length string if no label + * has been set */ public String getMidLabel() { return midLabel; } - /** - * Obtains the label for the maximum value, such as "Right" or "Full." - * @return the maximum value label, or a zero-length string if no label * has been set + * Obtains the label for the maximum value, such as "Right" or "Full". + * + * @return the maximum value label, or a zero-length string if no label has + * been set */ public String getMaxLabel() { return maxLabel; } - /** - * Obtains the resolution or granularity of the control, in the units - * that the control measures. - * The precision is the size of the increment between discrete valid values - * for this control, over the set of supported floating-point values. + * Obtains the resolution or granularity of the control, in the units that + * the control measures. The precision is the size of the increment between + * discrete valid values for this control, over the set of supported + * floating-point values. + * * @return the control's precision */ public float getPrecision() { return precision; } - /** - * Obtains the smallest time interval, in microseconds, over which the control's value can - * change during a shift. The update period is the inverse of the frequency with which - * the control updates its value during a shift. If the implementation does not support value shifting over - * time, it should set the control's value to the final value immediately - * and return -1 from this method. + * Obtains the smallest time interval, in microseconds, over which the + * control's value can change during a shift. The update period is the + * inverse of the frequency with which the control updates its value during + * a shift. If the implementation does not support value shifting over time, + * it should set the control's value to the final value immediately and + * return -1 from this method. * - * @return update period in microseconds, or -1 if shifting over time is unsupported + * @return update period in microseconds, or -1 if shifting over time is + * unsupported * @see #shift */ public int getUpdatePeriod() { return updatePeriod; } - /** - * Changes the control value from the initial value to the final - * value linearly over the specified time period, specified in microseconds. - * This method returns without blocking; it does not wait for the shift - * to complete. An implementation should complete the operation within the time - * specified. The default implementation simply changes the value - * to the final value immediately. - * - * @param from initial value at the beginning of the shift - * @param to final value after the shift - * @param microseconds maximum duration of the shift in microseconds + * Changes the control value from the initial value to the final value + * linearly over the specified time period, specified in microseconds. This + * method returns without blocking; it does not wait for the shift to + * complete. An implementation should complete the operation within the time + * specified. The default implementation simply changes the value to the + * final value immediately. * + * @param from initial value at the beginning of the shift + * @param to final value after the shift + * @param microseconds maximum duration of the shift in microseconds * @throws IllegalArgumentException if either {@code from} or {@code to} - * value does not fall within the allowable range - * + * value does not fall within the allowable range * @see #getUpdatePeriod */ public void shift(float from, float to, int microseconds) { @@ -347,12 +329,9 @@ public abstract class FloatControl extends Control { setValue(to); } - - // ABSTRACT METHOD IMPLEMENTATIONS: CONTROL - - /** - * Provides a string representation of the control + * Provides a string representation of the control. + * * @return a string description */ public String toString() { @@ -360,55 +339,45 @@ public abstract class FloatControl extends Control { " (range: " + minimum + " - " + maximum + ")"); } - - // INNER CLASSES - - /** - * An instance of the FloatControl.Type inner class identifies one kind of - * float control. Static instances are provided for the - * common types. + * An instance of the {@code FloatControl.Type} inner class identifies one + * kind of float control. Static instances are provided for the common + * types. * * @author Kara Kytle * @since 1.3 */ public static class Type extends Control.Type { - - // TYPE DEFINES - - - // GAIN TYPES - /** * Represents a control for the overall gain on a line. *

    * Gain is a quantity in decibels (dB) that is added to the intrinsic - * decibel level of the audio signal--that is, the level of - * the signal before it is altered by the gain control. A positive - * gain amplifies (boosts) the signal's volume, and a negative gain - * attenuates (cuts) it. + * decibel level of the audio signal--that is, the level of the signal + * before it is altered by the gain control. A positive gain amplifies + * (boosts) the signal's volume, and a negative gain attenuates(cuts)it. * The gain setting defaults to a value of 0.0 dB, meaning the signal's - * loudness is unaffected. Note that gain measures dB, not amplitude. + * loudness is unaffected. Note that gain measures dB, not amplitude. * The relationship between a gain in decibels and the corresponding * linear amplitude multiplier is: * - *

    linearScalar = pow(10.0, gainDB/20.0)
    + *
    {@code linearScalar = pow(10.0, gainDB/20.0)}
    *

    - * The FloatControl class has methods to impose a maximum and - * minimum allowable value for gain. However, because an audio signal might - * already be at a high amplitude, the maximum setting does not guarantee - * that the signal will be undistorted when the gain is applied to it (unless - * the maximum is zero or negative). To avoid numeric overflow from excessively - * large gain settings, a gain control can implement - * clipping, meaning that the signal's amplitude will be limited to the maximum - * value representable by its audio format, instead of wrapping around. + * The {@code FloatControl} class has methods to impose a maximum and + * minimum allowable value for gain. However, because an audio signal + * might already be at a high amplitude, the maximum setting does not + * guarantee that the signal will be undistorted when the gain is + * applied to it (unless the maximum is zero or negative). To avoid + * numeric overflow from excessively large gain settings, a gain control + * can implement clipping, meaning that the signal's amplitude will be + * limited to the maximum value representable by its audio format, + * instead of wrapping around. *

    - * These comments apply to gain controls in general, not just master gain controls. - * A line can have more than one gain control. For example, a mixer (which is - * itself a line) might have a master gain control, an auxiliary return control, - * a reverb return control, and, on each of its source lines, an individual aux - * send and reverb send. + * These comments apply to gain controls in general, not just master + * gain controls. A line can have more than one gain control. For + * example, a mixer (which is itself a line) might have a master gain + * control, an auxiliary return control, a reverb return control, and, + * on each of its source lines, an individual aux send and reverb send. * * @see #AUX_SEND * @see #AUX_RETURN @@ -435,9 +404,9 @@ public abstract class FloatControl extends Control { public static final Type AUX_RETURN = new Type("AUX Return"); /** - * Represents a control for the pre-reverb gain on a line. - * This control may be used to affect how much - * of a line's signal is directed to a mixer's internal reverberation unit. + * Represents a control for the pre-reverb gain on a line. This control + * may be used to affect how much of a line's signal is directed to a + * mixer's internal reverberation unit. * * @see #MASTER_GAIN * @see #REVERB_RETURN @@ -446,18 +415,15 @@ public abstract class FloatControl extends Control { public static final Type REVERB_SEND = new Type("Reverb Send"); /** - * Represents a control for the post-reverb gain on a line. - * This control may be used to control the relative amplitude - * of the signal returned from an internal reverberation unit. + * Represents a control for the post-reverb gain on a line. This control + * may be used to control the relative amplitude of the signal returned + * from an internal reverberation unit. * * @see #MASTER_GAIN * @see #REVERB_SEND */ public static final Type REVERB_RETURN = new Type("Reverb Return"); - - // VOLUME - /** * Represents a control for the volume on a line. */ @@ -466,64 +432,52 @@ public abstract class FloatControl extends Control { */ public static final Type VOLUME = new Type("Volume"); - - // PAN - /** - * Represents a control for the relative pan (left-right positioning) - * of the signal. The signal may be mono; the pan setting affects how - * it is distributed by the mixer in a stereo mix. The valid range of values is -1.0 - * (left channel only) to 1.0 (right channel - * only). The default is 0.0 (centered). + * Represents a control for the relative pan (left-right positioning) of + * the signal. The signal may be mono; the pan setting affects how it is + * distributed by the mixer in a stereo mix. The valid range of values + * is -1.0 (left channel only) to 1.0 (right channel only). The default + * is 0.0 (centered). * * @see #BALANCE */ public static final Type PAN = new Type("Pan"); - - // BALANCE - /** * Represents a control for the relative balance of a stereo signal - * between two stereo speakers. The valid range of values is -1.0 (left channel only) to 1.0 (right channel - * only). The default is 0.0 (centered). + * between two stereo speakers. The valid range of values is -1.0 (left + * channel only) to 1.0 (right channel only). The default is 0.0 + * (centered). * * @see #PAN */ public static final Type BALANCE = new Type("Balance"); - - // SAMPLE RATE - /** - * Represents a control that changes the sample rate of audio playback. The net effect - * of changing the sample rate depends on the relationship between - * the media's natural rate and the rate that is set via this control. - * The natural rate is the sample rate that is specified in the data line's - * AudioFormat object. For example, if the natural rate - * of the media is 11025 samples per second and the sample rate is set - * to 22050 samples per second, the media will play back at twice the - * normal speed. + * Represents a control that changes the sample rate of audio playback. + * The net effect of changing the sample rate depends on the + * relationship between the media's natural rate and the rate that is + * set via this control. The natural rate is the sample rate that is + * specified in the data line's {@code AudioFormat} object. For example, + * if the natural rate of the media is 11025 samples per second and the + * sample rate is set to 22050 samples per second, the media will play + * back at twice the normal speed. *

    - * Changing the sample rate with this control does not affect the data line's - * audio format. Also note that whenever you change a sound's sample rate, a - * change in the sound's pitch results. For example, doubling the sample - * rate has the effect of doubling the frequencies in the sound's spectrum, - * which raises the pitch by an octave. + * Changing the sample rate with this control does not affect the data + * line's audio format. Also note that whenever you change a sound's + * sample rate, a change in the sound's pitch results. For example, + * doubling the sample rate has the effect of doubling the frequencies + * in the sound's spectrum, which raises the pitch by an octave. */ public static final Type SAMPLE_RATE = new Type("Sample Rate"); - - // CONSTRUCTOR - /** * Constructs a new float control type. - * @param name the name of the new float control type + * + * @param name the name of the new float control type */ - protected Type(String name) { + protected Type(final String name) { super(name); } - - } // class Type - -} // class FloatControl + } +} diff --git a/jdk/src/share/classes/javax/sound/sampled/Line.java b/jdk/src/share/classes/javax/sound/sampled/Line.java index dfab63470cc..feb69fde185 100644 --- a/jdk/src/share/classes/javax/sound/sampled/Line.java +++ b/jdk/src/share/classes/javax/sound/sampled/Line.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 @@ -26,96 +26,90 @@ package javax.sound.sampled; /** - * The Line interface represents a mono or multi-channel - * audio feed. A line is an element of the digital audio - * "pipeline," such as a mixer, an input or output port, - * or a data path into or out of a mixer. + * The {@code Line} interface represents a mono or multi-channel audio feed. A + * line is an element of the digital audio "pipeline," such as a mixer, an input + * or output port, or a data path into or out of a mixer. *

    - * A line can have controls, such as gain, pan, and reverb. - * The controls themselves are instances of classes that extend the - * base {@link Control} class. - * The Line interface provides two accessor methods for - * obtaining the line's controls: {@link #getControls getControls} returns the - * entire set, and {@link #getControl getControl} returns a single control of - * specified type. + * A line can have controls, such as gain, pan, and reverb. The controls + * themselves are instances of classes that extend the base {@link Control} + * class. The {@code Line} interface provides two accessor methods for obtaining + * the line's controls: {@link #getControls getControls} returns the entire set, + * and {@link #getControl getControl} returns a single control of specified + * type. *

    - * Lines exist in various states at different times. When a line opens, it reserves system - * resources for itself, and when it closes, these resources are freed for - * other objects or applications. The {@link #isOpen()} method lets - * you discover whether a line is open or closed. - * An open line need not be processing data, however. Such processing is - * typically initiated by subinterface methods such as - * {@link SourceDataLine#write SourceDataLine.write} and - * {@link TargetDataLine#read TargetDataLine.read}. - *

    - * You can register an object to receive notifications whenever the line's - * state changes. The object must implement the {@link LineListener} - * interface, which consists of the single method - * {@link LineListener#update update}. - * This method will be invoked when a line opens and closes (and, if it's a - * {@link DataLine}, when it starts and stops). - *

    - * An object can be registered to listen to multiple lines. The event it - * receives in its update method will specify which line created - * the event, what type of event it was - * (OPEN, CLOSE, START, or STOP), - * and how many sample frames the line had processed at the time the event occurred. + * Lines exist in various states at different times. When a line opens, it + * reserves system resources for itself, and when it closes, these resources are + * freed for other objects or applications. The {@link #isOpen()} method lets + * you discover whether a line is open or closed. An open line need not be + * processing data, however. Such processing is typically initiated by + * subinterface methods such as + * {@link SourceDataLine#write SourceDataLine.write} and + * {@link TargetDataLine#read TargetDataLine.read}. + *

    + * You can register an object to receive notifications whenever the line's state + * changes. The object must implement the {@link LineListener} interface, which + * consists of the single method {@link LineListener#update update}. This method + * will be invoked when a line opens and closes (and, if it's a {@link DataLine} + * , when it starts and stops). + *

    + * An object can be registered to listen to multiple lines. The event it + * receives in its {@code update} method will specify which line created the + * event, what type of event it was ({@code OPEN}, {@code CLOSE}, {@code START}, + * or {@code STOP}), and how many sample frames the line had processed at the + * time the event occurred. *

    * Certain line operations, such as open and close, can generate security * exceptions if invoked by unprivileged code when the line is a shared audio * resource. * * @author Kara Kytle - * * @see LineEvent * @since 1.3 */ public interface Line extends AutoCloseable { /** - * Obtains the Line.Info object describing this - * line. + * Obtains the {@code Line.Info} object describing this line. + * * @return description of the line */ - public Line.Info getLineInfo(); + Line.Info getLineInfo(); /** - * Opens the line, indicating that it should acquire any required - * system resources and become operational. - * If this operation - * succeeds, the line is marked as open, and an OPEN event is dispatched - * to the line's listeners. + * Opens the line, indicating that it should acquire any required system + * resources and become operational. If this operation succeeds, the line is + * marked as open, and an {@code OPEN} event is dispatched to the line's + * listeners. *

    - * Note that some lines, once closed, cannot be reopened. Attempts - * to reopen such a line will always result in an LineUnavailableException. + * Note that some lines, once closed, cannot be reopened. Attempts to reopen + * such a line will always result in an {@code LineUnavailableException}. *

    - * Some types of lines have configurable properties that may affect - * resource allocation. For example, a DataLine must - * be opened with a particular format and buffer size. Such lines - * should provide a mechanism for configuring these properties, such - * as an additional open method or methods which allow - * an application to specify the desired settings. + * Some types of lines have configurable properties that may affect resource + * allocation. For example, a {@code DataLine} must be opened with a + * particular format and buffer size. Such lines should provide a mechanism + * for configuring these properties, such as an additional {@code open} + * method or methods which allow an application to specify the desired + * settings. *

    * This method takes no arguments, and opens the line with the current - * settings. For {@link SourceDataLine} and - * {@link TargetDataLine} objects, this means that the line is - * opened with default settings. For a {@link Clip}, however, - * the buffer size is determined when data is loaded. Since this method does not - * allow the application to specify any data to load, an IllegalArgumentException - * is thrown. Therefore, you should instead use one of the open methods - * provided in the Clip interface to load data into the Clip. + * settings. For {@link SourceDataLine} and {@link TargetDataLine} objects, + * this means that the line is opened with default settings. For a + * {@link Clip}, however, the buffer size is determined when data is loaded. + * Since this method does not allow the application to specify any data to + * load, an {@code IllegalArgumentException} is thrown. Therefore, you + * should instead use one of the {@code open} methods provided in the + * {@code Clip} interface to load data into the {@code Clip}. *

    - * For DataLine's, if the DataLine.Info - * object which was used to retrieve the line, specifies at least - * one fully qualified audio format, the last one will be used - * as the default format. - * - * @throws IllegalArgumentException if this method is called on a Clip instance. - * @throws LineUnavailableException if the line cannot be - * opened due to resource restrictions. - * @throws SecurityException if the line cannot be - * opened due to security restrictions. + * For {@code DataLine}'s, if the {@code DataLine.Info} object which was + * used to retrieve the line, specifies at least one fully qualified audio + * format, the last one will be used as the default format. * + * @throws IllegalArgumentException if this method is called on a Clip + * instance + * @throws LineUnavailableException if the line cannot be opened due to + * resource restrictions + * @throws SecurityException if the line cannot be opened due to security + * restrictions * @see #close * @see #isOpen * @see LineEvent @@ -123,133 +117,128 @@ public interface Line extends AutoCloseable { * @see Clip#open(AudioFormat, byte[], int, int) * @see Clip#open(AudioInputStream) */ - public void open() throws LineUnavailableException; - + void open() throws LineUnavailableException; /** - * Closes the line, indicating that any system resources - * in use by the line can be released. If this operation - * succeeds, the line is marked closed and a CLOSE event is dispatched - * to the line's listeners. - * @throws SecurityException if the line cannot be - * closed due to security restrictions. + * Closes the line, indicating that any system resources in use by the line + * can be released. If this operation succeeds, the line is marked closed + * and a {@code CLOSE} event is dispatched to the line's listeners. * + * @throws SecurityException if the line cannot be closed due to security + * restrictions * @see #open * @see #isOpen * @see LineEvent */ - public void close(); - - + @Override + void close(); /** - * Indicates whether the line is open, meaning that it has reserved - * system resources and is operational, although it might not currently be - * playing or capturing sound. - * @return true if the line is open, otherwise false + * Indicates whether the line is open, meaning that it has reserved system + * resources and is operational, although it might not currently be playing + * or capturing sound. * + * @return {@code true} if the line is open, otherwise {@code false} * @see #open() * @see #close() */ - public boolean isOpen(); - + boolean isOpen(); /** - * Obtains the set of controls associated with this line. - * Some controls may only be available when the line is open. - * If there are no controls, this method returns an array of length 0. + * Obtains the set of controls associated with this line. Some controls may + * only be available when the line is open. If there are no controls, this + * method returns an array of length 0. + * * @return the array of controls * @see #getControl */ - public Control[] getControls(); + Control[] getControls(); /** - * Indicates whether the line supports a control of the specified type. - * Some controls may only be available when the line is open. - * @param control the type of the control for which support is queried - * @return true if at least one control of the specified type is - * supported, otherwise false. + * Indicates whether the line supports a control of the specified type. Some + * controls may only be available when the line is open. + * + * @param control the type of the control for which support is queried + * @return {@code true} if at least one control of the specified type is + * supported, otherwise {@code false} */ - public boolean isControlSupported(Control.Type control); - + boolean isControlSupported(Control.Type control); /** - * Obtains a control of the specified type, - * if there is any. - * Some controls may only be available when the line is open. - * @param control the type of the requested control + * Obtains a control of the specified type, if there is any. Some controls + * may only be available when the line is open. + * + * @param control the type of the requested control * @return a control of the specified type - * @throws IllegalArgumentException if a control of the specified type - * is not supported + * @throws IllegalArgumentException if a control of the specified type is + * not supported * @see #getControls * @see #isControlSupported(Control.Type control) */ - public Control getControl(Control.Type control); - + Control getControl(Control.Type control); /** - * Adds a listener to this line. Whenever the line's status changes, the - * listener's update() method is called with a LineEvent object - * that describes the change. - * @param listener the object to add as a listener to this line + * Adds a listener to this line. Whenever the line's status changes, the + * listener's {@code update()} method is called with a {@code LineEvent} + * object that describes the change. + * + * @param listener the object to add as a listener to this line * @see #removeLineListener * @see LineListener#update * @see LineEvent */ - public void addLineListener(LineListener listener); - + void addLineListener(LineListener listener); /** * Removes the specified listener from this line's list of listeners. - * @param listener listener to remove + * + * @param listener listener to remove * @see #addLineListener */ - public void removeLineListener(LineListener listener); - + void removeLineListener(LineListener listener); /** - * A Line.Info object contains information about a line. - * The only information provided by Line.Info itself - * is the Java class of the line. - * A subclass of Line.Info adds other kinds of information - * about the line. This additional information depends on which Line - * subinterface is implemented by the kind of line that the Line.Info - * subclass describes. + * A {@code Line.Info} object contains information about a line. The only + * information provided by {@code Line.Info} itself is the Java class of the + * line. A subclass of {@code Line.Info} adds other kinds of information + * about the line. This additional information depends on which {@code Line} + * subinterface is implemented by the kind of line that the + * {@code Line.Info} subclass describes. *

    - * A Line.Info can be retrieved using various methods of - * the Line, Mixer, and AudioSystem - * interfaces. Other such methods let you pass a Line.Info as - * an argument, to learn whether lines matching the specified configuration - * are available and to obtain them. + * A {@code Line.Info} can be retrieved using various methods of the + * {@code Line}, {@code Mixer}, and {@code AudioSystem} interfaces. Other + * such methods let you pass a {@code Line.Info} as an argument, to learn + * whether lines matching the specified configuration are available and to + * obtain them. * * @author Kara Kytle - * - * @see Line#getLineInfo - * @see Mixer#getSourceLineInfo - * @see Mixer#getTargetLineInfo - * @see Mixer#getLine Mixer.getLine(Line.Info) - * @see Mixer#getSourceLineInfo(Line.Info) Mixer.getSourceLineInfo(Line.Info) - * @see Mixer#getSourceLineInfo(Line.Info) Mixer.getTargetLineInfo(Line.Info) - * @see Mixer#isLineSupported Mixer.isLineSupported(Line.Info) - * @see AudioSystem#getLine AudioSystem.getLine(Line.Info) - * @see AudioSystem#getSourceLineInfo AudioSystem.getSourceLineInfo(Line.Info) - * @see AudioSystem#getTargetLineInfo AudioSystem.getTargetLineInfo(Line.Info) - * @see AudioSystem#isLineSupported AudioSystem.isLineSupported(Line.Info) + * @see Line#getLineInfo() + * @see Mixer#getSourceLineInfo() + * @see Mixer#getTargetLineInfo() + * @see Mixer#getLine(Line.Info) + * @see Mixer#getSourceLineInfo(Line.Info) + * @see Mixer#getTargetLineInfo(Line.Info) + * @see Mixer#isLineSupported(Line.Info) + * @see AudioSystem#getLine(Line.Info) + * @see AudioSystem#getSourceLineInfo(Line.Info) + * @see AudioSystem#getTargetLineInfo(Line.Info) + * @see AudioSystem#isLineSupported(Line.Info) * @since 1.3 */ - public static class Info { + class Info { /** * The class of the line described by the info object. */ - private final Class lineClass; - + private final Class lineClass; /** - * Constructs an info object that describes a line of the specified class. - * This constructor is typically used by an application to + * Constructs an info object that describes a line of the specified + * class. This constructor is typically used by an application to * describe a desired line. - * @param lineClass the class of the line that the new Line.Info object describes + * + * @param lineClass the class of the line that the new Line.Info object + * describes */ public Info(Class lineClass) { @@ -260,33 +249,29 @@ public interface Line extends AutoCloseable { } } - - /** * Obtains the class of the line that this Line.Info object describes. + * * @return the described line's class */ public Class getLineClass() { return lineClass; } - /** - * Indicates whether the specified info object matches this one. - * To match, the specified object must be identical to or - * a special case of this one. The specified info object - * must be either an instance of the same class as this one, - * or an instance of a sub-type of this one. In addition, the - * attributes of the specified object must be compatible with the - * capabilities of this one. Specifically, the routing configuration - * for the specified info object must be compatible with that of this - * one. - * Subclasses may add other criteria to determine whether the two objects - * match. + * Indicates whether the specified info object matches this one. To + * match, the specified object must be identical to or a special case of + * this one. The specified info object must be either an instance of + * the same class as this one, or an instance of a sub-type of this one. + * In addition, the attributes of the specified object must be + * compatible with the capabilities of this one. Specifically, the + * routing configuration for the specified info object must be + * compatible with that of this one. Subclasses may add other criteria + * to determine whether the two objects match. * - * @param info the info object which is being compared to this one - * @return true if the specified object matches this one, - * false otherwise + * @param info the info object which is being compared to this one + * @return {@code true} if the specified object matches this one, + * {@code false} otherwise */ public boolean matches(Info info) { @@ -320,7 +305,6 @@ public interface Line extends AutoCloseable { return false; } - // this.isAssignableFrom(that) => this is same or super to that // => this is at least as general as that // => that may be subtype of this @@ -332,11 +316,12 @@ public interface Line extends AutoCloseable { return true; } - /** * Obtains a textual description of the line info. + * * @return a string description */ + @Override public String toString() { String fullPackagePath = "javax.sound.sampled."; @@ -353,7 +338,5 @@ public interface Line extends AutoCloseable { return finalString; } - - } // class Info - -} // interface Line + } +} diff --git a/jdk/src/share/classes/javax/sound/sampled/LineEvent.java b/jdk/src/share/classes/javax/sound/sampled/LineEvent.java index ff5b90f1ba1..035c38f74f5 100644 --- a/jdk/src/share/classes/javax/sound/sampled/LineEvent.java +++ b/jdk/src/share/classes/javax/sound/sampled/LineEvent.java @@ -25,61 +25,64 @@ package javax.sound.sampled; +import java.util.EventObject; + /** - * The LineEvent class encapsulates information that a line - * sends its listeners whenever the line opens, closes, starts, or stops. - * Each of these four state changes is represented by a corresponding - * type of event. A listener receives the event as a parameter to its - * {@link LineListener#update update} method. By querying the event, - * the listener can learn the type of event, the line responsible for - * the event, and how much data the line had processed when the event occurred. - * - *

    Although this class implements Serializable, attempts to - * serialize a LineEvent object will fail. + * The {@code LineEvent} class encapsulates information that a line sends its + * listeners whenever the line opens, closes, starts, or stops. Each of these + * four state changes is represented by a corresponding type of event. A + * listener receives the event as a parameter to its + * {@link LineListener#update update} method. By querying the event, the + * listener can learn the type of event, the line responsible for the event, and + * how much data the line had processed when the event occurred. + *

    + * Although this class implements Serializable, attempts to serialize a + * {@code LineEvent} object will fail. * * @author Kara Kytle - * * @see Line * @see LineListener#update * @since 1.3 * * @serial exclude */ -public class LineEvent extends java.util.EventObject { +public class LineEvent extends EventObject { + private static final long serialVersionUID = -1274246333383880410L; - // INSTANCE VARIABLES - /** - * The kind of line event (OPEN, CLOSE, - * START, or STOP). - * @see #getType + * The kind of line event ({@code OPEN}, {@code CLOSE}, {@code START}, or + * {@code STOP}). + * * @serial + * @see #getType */ private final Type type; /** * The media position when the event occurred, expressed in sample frames. - * Note that this field is only relevant to certain events generated by - * data lines, such as START and STOP. For - * events generated by lines that do not count sample frames, and for any - * other events for which this value is not known, the position value - * should be {@link AudioSystem#NOT_SPECIFIED}. + * Note that this field is only relevant to certain events generated by data + * lines, such as {@code START} and {@code STOP}. For events generated by + * lines that do not count sample frames, and for any other events for which + * this value is not known, the position value should be + * {@link AudioSystem#NOT_SPECIFIED}. + * * @serial * @see #getFramePosition */ private final long position; - /** - * Constructs a new event of the specified type, originating from the specified line. - * @param line the source of this event - * @param type the event type (OPEN, CLOSE, START, or STOP) - * @param position the number of sample frames that the line had already processed when the event occurred, - * or {@link AudioSystem#NOT_SPECIFIED} + * Constructs a new event of the specified type, originating from the + * specified line. * - * @throws IllegalArgumentException if line is - * null. + * @param line the source of this event + * @param type the event type ({@code OPEN}, {@code CLOSE}, {@code START}, + * or {@code STOP}) + * @param position the number of sample frames that the line had already + * processed when the event occurred, or + * {@link AudioSystem#NOT_SPECIFIED} + * @throws IllegalArgumentException if {@code line} is {@code null}. */ public LineEvent(Line line, Type type, long position) { @@ -90,6 +93,7 @@ public class LineEvent extends java.util.EventObject { /** * Obtains the audio line that is the source of this event. + * * @return the line responsible for this event */ public final Line getLine() { @@ -97,11 +101,11 @@ public class LineEvent extends java.util.EventObject { return (Line)getSource(); } - /** * Obtains the event's type. + * * @return this event's type ({@link Type#OPEN}, {@link Type#CLOSE}, - * {@link Type#START}, or {@link Type#STOP}) + * {@link Type#START}, or {@link Type#STOP}) */ public final Type getType() { @@ -109,21 +113,24 @@ public class LineEvent extends java.util.EventObject { } /** - * Obtains the position in the line's audio data when the event occurred, expressed in sample frames. - * For example, if a source line had already played back 14 sample frames at the time it was - * paused, the pause event would report the line's position as 14. The next frame to be processed - * would be frame number 14 using zero-based numbering, or 15 using one-based numbering. + * Obtains the position in the line's audio data when the event occurred, + * expressed in sample frames. For example, if a source line had already + * played back 14 sample frames at the time it was paused, the pause event + * would report the line's position as 14. The next frame to be processed + * would be frame number 14 using zero-based numbering, or 15 using + * one-based numbering. *

    - * Note that this field is relevant only to certain events generated by - * data lines, such as START and STOP. For - * events generated by lines that do not count sample frames, and for any - * other events for which this value is not known, the position value - * should be {@link AudioSystem#NOT_SPECIFIED}. + * Note that this field is relevant only to certain events generated by data + * lines, such as {@code START} and {@code STOP}. For events generated by + * lines that do not count sample frames, and for any other events for which + * this value is not known, the position value should be + * {@link AudioSystem#NOT_SPECIFIED}. * * @return the line's position as a sample frame number */ /* - * $$kk: 04.20.99: note to myself: should make sure our implementation is consistent with this. + * $$kk: 04.20.99: note to myself: should make sure our implementation is + * consistent with this. * which is a reasonable definition.... */ public final long getFramePosition() { @@ -132,10 +139,12 @@ public class LineEvent extends java.util.EventObject { } /** - * Obtains a string representation of the event. The contents of the string may vary - * between implementations of Java Sound. - * @return a string describing the event. + * Obtains a string representation of the event. The contents of the string + * may vary between implementations of Java Sound. + * + * @return a string describing the event */ + @Override public String toString() { String sType = ""; if (type != null) sType = type.toString()+" "; @@ -148,16 +157,15 @@ public class LineEvent extends java.util.EventObject { return new String(sType + "event from line " + sLine); } - /** - * The LineEvent.Type inner class identifies what kind of event occurred on a line. - * Static instances are provided for the common types (OPEN, CLOSE, START, and STOP). + * The LineEvent.Type inner class identifies what kind of event occurred on + * a line. Static instances are provided for the common types (OPEN, CLOSE, + * START, and STOP). * * @see LineEvent#getType() */ public static class Type { - /** * Type name. */ @@ -166,82 +174,84 @@ public class LineEvent extends java.util.EventObject { /** * Constructs a new event type. - * @param name name of the type + * + * @param name name of the type */ protected Type(String name) { this.name = name; } - //$$fb 2002-11-26: fix for 4695001: SPEC: description of equals() method contains typo + /** * Indicates whether the specified object is equal to this event type, - * returning true if the objects are identical. - * @param obj the reference object with which to compare - * @return true if this event type is the same as - * obj; false otherwise + * returning {@code true} if the objects are identical. + * + * @param obj the reference object with which to compare + * @return {@code true} if this event type is the same as {@code obj}; + * {@code false} otherwise */ + @Override public final boolean equals(Object obj) { return super.equals(obj); } - /** * Finalizes the hashcode method. */ + @Override public final int hashCode() { return super.hashCode(); } - /** * Returns the type name as the string representation. */ + @Override public String toString() { return name; } - // LINE EVENT TYPE DEFINES /** * A type of event that is sent when a line opens, reserving system * resources for itself. + * * @see #CLOSE * @see Line#open */ public static final Type OPEN = new Type("Open"); - /** * A type of event that is sent when a line closes, freeing the system * resources it had obtained when it was opened. + * * @see #OPEN * @see Line#close */ public static final Type CLOSE = new Type("Close"); - /** * A type of event that is sent when a line begins to engage in active * input or output of audio data in response to a * {@link DataLine#start start} request. + * * @see #STOP * @see DataLine#start */ public static final Type START = new Type("Start"); - /** - * A type of event that is sent when a line ceases active input or output - * of audio data in response to a {@link DataLine#stop stop} request, - * or because the end of media has been reached. + * A type of event that is sent when a line ceases active input or + * output of audio data in response to a {@link DataLine#stop stop} + * request, or because the end of media has been reached. + * * @see #START * @see DataLine#stop */ public static final Type STOP = new Type("Stop"); - /** * A type of event that is sent when a line ceases to engage in active * input or output of audio data because the end of media has been reached. @@ -255,7 +265,6 @@ public class LineEvent extends java.util.EventObject { */ //public static final Type EOM = new Type("EOM"); - /** * A type of event that is sent when a line begins to engage in active * input or output of audio data. Examples of when this happens are @@ -268,7 +277,6 @@ public class LineEvent extends java.util.EventObject { */ //public static final Type ACTIVE = new Type("ACTIVE"); - /** * A type of event that is sent when a line ceases active input or output * of audio data. @@ -276,7 +284,5 @@ public class LineEvent extends java.util.EventObject { * @see DataLine#stop */ //public static final Type INACTIVE = new Type("INACTIVE"); - - } // class Type - -} // class LineEvent + } +} diff --git a/jdk/src/share/classes/javax/sound/sampled/LineListener.java b/jdk/src/share/classes/javax/sound/sampled/LineListener.java index 57d6468007d..5d0434d6d86 100644 --- a/jdk/src/share/classes/javax/sound/sampled/LineListener.java +++ b/jdk/src/share/classes/javax/sound/sampled/LineListener.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,44 +25,27 @@ package javax.sound.sampled; - +import java.util.EventListener; /** - * Instances of classes that implement the LineListener interface can register to - * receive events when a line's status changes. + * Instances of classes that implement the {@code LineListener} interface can + * register to receive events when a line's status changes. * * @author Kara Kytle - * * @see Line * @see Line#addLineListener * @see Line#removeLineListener * @see LineEvent - * * @since 1.3 */ -/* - * Instances of classes that implement the LineListener interface can register to - * receive events when a line's status changes. - * - * @see Line - * @see Line#addLineListener - * @see Line#removeLineListener - * @see LineEvent - * - * @author Kara Kytle - */ -public interface LineListener extends java.util.EventListener { +public interface LineListener extends EventListener { /** - * Informs the listener that a line's state has changed. The listener can then invoke - * LineEvent methods to obtain information about the event. - * @param event a line event that describes the change + * Informs the listener that a line's state has changed. The listener can + * then invoke {@code LineEvent} methods to obtain information about the + * event. + * + * @param event a line event that describes the change */ - /* - * Informs the listener that a line's state has changed. The listener can then invoke - * LineEvent methods to obtain information about the event. - * @param event a line event that describes the change - */ - public void update(LineEvent event); - -} // interface LineListener + void update(LineEvent event); +} diff --git a/jdk/src/share/classes/javax/sound/sampled/LineUnavailableException.java b/jdk/src/share/classes/javax/sound/sampled/LineUnavailableException.java index 1e72f75061e..701d8ee499a 100644 --- a/jdk/src/share/classes/javax/sound/sampled/LineUnavailableException.java +++ b/jdk/src/share/classes/javax/sound/sampled/LineUnavailableException.java @@ -26,43 +26,32 @@ package javax.sound.sampled; /** - * A LineUnavailableException is an exception indicating that a - * line cannot be opened because it is unavailable. This situation - * arises most commonly when a requested line is already in use - * by another application. + * A {@code LineUnavailableException} is an exception indicating that a line + * cannot be opened because it is unavailable. This situation arises most + * commonly when a requested line is already in use by another application. * * @author Kara Kytle * @since 1.3 */ -/* - * A LinenavailableException is an exception indicating that a - * line annot be opened because it is unavailable. This situation - * arises most commonly when a line is requested when it is already in use - * by another application. - * - * @author Kara Kytle - */ - public class LineUnavailableException extends Exception { + private static final long serialVersionUID = -2046718279487432130L; /** - * Constructs a LineUnavailableException that has - * null as its error detail message. + * Constructs a {@code LineUnavailableException} that has {@code null} as + * its error detail message. */ public LineUnavailableException() { - super(); } /** - * Constructs a LineUnavailableException that has - * the specified detail message. + * Constructs a {@code LineUnavailableException} that has the specified + * detail message. * - * @param message a string containing the error detail message + * @param message a string containing the error detail message */ - public LineUnavailableException(String message) { - + public LineUnavailableException(final String message) { super(message); } } diff --git a/jdk/src/share/classes/javax/sound/sampled/Mixer.java b/jdk/src/share/classes/javax/sound/sampled/Mixer.java index 755ab913342..87784ec62f1 100644 --- a/jdk/src/share/classes/javax/sound/sampled/Mixer.java +++ b/jdk/src/share/classes/javax/sound/sampled/Mixer.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,30 +25,27 @@ package javax.sound.sampled; - /** - * A mixer is an audio device with one or more lines. It need not be - * designed for mixing audio signals. A mixer that actually mixes audio - * has multiple input (source) lines and at least one output (target) line. - * The former are often instances of classes that implement - * {@link SourceDataLine}, - * and the latter, {@link TargetDataLine}. {@link Port} - * objects, too, are either source lines or target lines. - * A mixer can accept prerecorded, loopable sound as input, by having - * some of its source lines be instances of objects that implement the - * {@link Clip} interface. + * A mixer is an audio device with one or more lines. It need not be designed + * for mixing audio signals. A mixer that actually mixes audio has multiple + * input (source) lines and at least one output (target) line. The former are + * often instances of classes that implement {@link SourceDataLine}, and the + * latter, {@link TargetDataLine}. {@link Port} objects, too, are either source + * lines or target lines. A mixer can accept prerecorded, loopable sound as + * input, by having some of its source lines be instances of objects that + * implement the {@link Clip} interface. *

    - * Through methods of the Line interface, which Mixer extends, - * a mixer might provide a set of controls that are global to the mixer. For example, - * the mixer can have a master gain control. These global controls are distinct - * from the controls belonging to each of the mixer's individual lines. + * Through methods of the {@code Line} interface, which {@code Mixer} extends, a + * mixer might provide a set of controls that are global to the mixer. For + * example, the mixer can have a master gain control. These global controls are + * distinct from the controls belonging to each of the mixer's individual lines. *

    - * Some mixers, especially - * those with internal digital mixing capabilities, may provide - * additional capabilities by implementing the DataLine interface. + * Some mixers, especially those with internal digital mixing capabilities, may + * provide additional capabilities by implementing the {@code DataLine} + * interface. *

    - * A mixer can support synchronization of its lines. When one line in - * a synchronized group is started or stopped, the other lines in the group + * A mixer can support synchronization of its lines. When one line in a + * synchronized group is started or stopped, the other lines in the group * automatically start or stop simultaneously with the explicitly affected one. * * @author Kara Kytle @@ -59,198 +56,201 @@ public interface Mixer extends Line { /** * Obtains information about this mixer, including the product's name, * version, vendor, etc. + * * @return a mixer info object that describes this mixer * @see Mixer.Info */ - public Info getMixerInfo(); - + Info getMixerInfo(); /** - * Obtains information about the set of source lines supported - * by this mixer. - * Some source lines may only be available when this mixer is open. - * @return array of Line.Info objects representing source lines - * for this mixer. If no source lines are supported, - * an array of length 0 is returned. + * Obtains information about the set of source lines supported by this + * mixer. Some source lines may only be available when this mixer is open. + * + * @return array of {@code Line.Info} objects representing source lines for + * this mixer. If no source lines are supported, an array of length + * 0 is returned. */ - public Line.Info[] getSourceLineInfo(); + Line.Info[] getSourceLineInfo(); /** - * Obtains information about the set of target lines supported - * by this mixer. - * Some target lines may only be available when this mixer is open. - * @return array of Line.Info objects representing target lines - * for this mixer. If no target lines are supported, - * an array of length 0 is returned. + * Obtains information about the set of target lines supported by this + * mixer. Some target lines may only be available when this mixer is open. + * + * @return array of {@code Line.Info} objects representing target lines for + * this mixer. If no target lines are supported, an array of length + * 0 is returned. */ - public Line.Info[] getTargetLineInfo(); - + Line.Info[] getTargetLineInfo(); /** - * Obtains information about source lines of a particular type supported - * by the mixer. - * Some source lines may only be available when this mixer is open. - * @param info a Line.Info object describing lines about which information - * is queried - * @return an array of Line.Info objects describing source lines matching - * the type requested. If no matching source lines are supported, an array of length 0 - * is returned. + * Obtains information about source lines of a particular type supported by + * the mixer. Some source lines may only be available when this mixer is + * open. + * + * @param info a {@code Line.Info} object describing lines about which + * information is queried + * @return an array of {@code Line.Info} objects describing source lines + * matching the type requested. If no matching source lines are + * supported, an array of length 0 is returned. */ - public Line.Info[] getSourceLineInfo(Line.Info info); - + Line.Info[] getSourceLineInfo(Line.Info info); /** - * Obtains information about target lines of a particular type supported - * by the mixer. - * Some target lines may only be available when this mixer is open. - * @param info a Line.Info object describing lines about which information - * is queried - * @return an array of Line.Info objects describing target lines matching - * the type requested. If no matching target lines are supported, an array of length 0 - * is returned. + * Obtains information about target lines of a particular type supported by + * the mixer. Some target lines may only be available when this mixer is + * open. + * + * @param info a {@code Line.Info} object describing lines about which + * information is queried + * @return an array of {@code Line.Info} objects describing target lines + * matching the type requested. If no matching target lines are + * supported, an array of length 0 is returned. */ - public Line.Info[] getTargetLineInfo(Line.Info info); - + Line.Info[] getTargetLineInfo(Line.Info info); /** - * Indicates whether the mixer supports a line (or lines) that match - * the specified Line.Info object. - * Some lines may only be supported when this mixer is open. - * @param info describes the line for which support is queried - * @return true if at least one matching line is - * supported, false otherwise + * Indicates whether the mixer supports a line (or lines) that match the + * specified {@code Line.Info} object. Some lines may only be supported when + * this mixer is open. + * + * @param info describes the line for which support is queried + * @return {@code true} if at least one matching line is supported, + * {@code false} otherwise */ - public boolean isLineSupported(Line.Info info); + boolean isLineSupported(Line.Info info); /** * Obtains a line that is available for use and that matches the description - * in the specified Line.Info object. + * in the specified {@code Line.Info} object. + *

    + * If a {@code DataLine} is requested, and {@code info} is an instance of + * {@code DataLine.Info} specifying at least one fully qualified audio + * format, the last one will be used as the default format of the returned + * {@code DataLine}. * - *

    If a DataLine is requested, and info - * is an instance of DataLine.Info specifying at - * least one fully qualified audio format, the last one - * will be used as the default format of the returned - * DataLine. - * - * @param info describes the desired line + * @param info describes the desired line * @return a line that is available for use and that matches the description - * in the specified {@code Line.Info} object - * @throws LineUnavailableException if a matching line - * is not available due to resource restrictions - * @throws IllegalArgumentException if this mixer does - * not support any lines matching the description - * @throws SecurityException if a matching line - * is not available due to security restrictions + * in the specified {@code Line.Info} object + * @throws LineUnavailableException if a matching line is not available due + * to resource restrictions + * @throws IllegalArgumentException if this mixer does not support any lines + * matching the description + * @throws SecurityException if a matching line is not available due to + * security restrictions */ - public Line getLine(Line.Info info) throws LineUnavailableException; + Line getLine(Line.Info info) throws LineUnavailableException; //$$fb 2002-04-12: fix for 4667258: behavior of Mixer.getMaxLines(Line.Info) method doesn't match the spec /** - * Obtains the approximate maximum number of lines of the requested type that can be open - * simultaneously on the mixer. + * Obtains the approximate maximum number of lines of the requested type + * that can be open simultaneously on the mixer. * - * Certain types of mixers do not have a hard bound and may allow opening more lines. - * Since certain lines are a shared resource, a mixer may not be able to open the maximum - * number of lines if another process has opened lines of this mixer. + * Certain types of mixers do not have a hard bound and may allow opening + * more lines. Since certain lines are a shared resource, a mixer may not be + * able to open the maximum number of lines if another process has opened + * lines of this mixer. * - * The requested type is any line that matches the description in - * the provided Line.Info object. For example, if the info - * object represents a speaker - * port, and the mixer supports exactly one speaker port, this method - * should return 1. If the info object represents a source data line - * and the mixer supports the use of 32 source data lines simultaneously, - * the return value should be 32. - * If there is no limit, this function returns AudioSystem.NOT_SPECIFIED. - * @param info a Line.Info that describes the line for which - * the number of supported instances is queried - * @return the maximum number of matching lines supported, or AudioSystem.NOT_SPECIFIED + * The requested type is any line that matches the description in the + * provided {@code Line.Info} object. For example, if the info object + * represents a speaker port, and the mixer supports exactly one speaker + * port, this method should return 1. If the info object represents a + * source data line and the mixer supports the use of 32 source data lines + * simultaneously, the return value should be 32. If there is no limit, this + * function returns {@code AudioSystem.NOT_SPECIFIED}. + * + * @param info a {@code Line.Info} that describes the line for which the + * number of supported instances is queried + * @return the maximum number of matching lines supported, or + * {@code AudioSystem.NOT_SPECIFIED} */ - public int getMaxLines(Line.Info info); - + int getMaxLines(Line.Info info); /** * Obtains the set of all source lines currently open to this mixer. * - * @return the source lines currently open to the mixer. - * If no source lines are currently open to this mixer, an - * array of length 0 is returned. - * @throws SecurityException if the matching lines - * are not available due to security restrictions + * @return the source lines currently open to the mixer. If no source lines + * are currently open to this mixer, an array of length 0 is + * returned. + * @throws SecurityException if the matching lines are not available due to + * security restrictions */ - public Line[] getSourceLines(); + Line[] getSourceLines(); /** * Obtains the set of all target lines currently open from this mixer. * - * @return target lines currently open from the mixer. - * If no target lines are currently open from this mixer, an - * array of length 0 is returned. - * @throws SecurityException if the matching lines - * are not available due to security restrictions + * @return target lines currently open from the mixer. If no target lines + * are currently open from this mixer, an array of length 0 is + * returned. + * @throws SecurityException if the matching lines are not available due to + * security restrictions */ - public Line[] getTargetLines(); + Line[] getTargetLines(); /** - * Synchronizes two or more lines. Any subsequent command that starts or stops - * audio playback or capture for one of these lines will exert the - * same effect on the other lines in the group, so that they start or stop playing or - * capturing data simultaneously. - * - * @param lines the lines that should be synchronized - * @param maintainSync true if the synchronization - * must be precisely maintained (i.e., the synchronization must be sample-accurate) - * at all times during operation of the lines , or false - * if precise synchronization is required only during start and stop operations + * Synchronizes two or more lines. Any subsequent command that starts or + * stops audio playback or capture for one of these lines will exert the + * same effect on the other lines in the group, so that they start or stop + * playing or capturing data simultaneously. * + * @param lines the lines that should be synchronized + * @param maintainSync {@code true} if the synchronization must be + * precisely maintained (i.e., the synchronization must be + * sample-accurate) at all times during operation of the lines, or + * {@code false} if precise synchronization is required only during + * start and stop operations * @throws IllegalArgumentException if the lines cannot be synchronized. - * This may occur if the lines are of different types or have different - * formats for which this mixer does not support synchronization, or if - * all lines specified do not belong to this mixer. + * This may occur if the lines are of different types or have + * different formats for which this mixer does not support + * synchronization, or if all lines specified do not belong to this + * mixer. */ - public void synchronize(Line[] lines, boolean maintainSync); + void synchronize(Line[] lines, boolean maintainSync); /** - * Releases synchronization for the specified lines. The array must - * be identical to one for which synchronization has already been - * established; otherwise an exception may be thrown. However, null - * may be specified, in which case all currently synchronized lines that belong - * to this mixer are unsynchronized. - * @param lines the synchronized lines for which synchronization should be - * released, or null for all this mixer's synchronized lines + * Releases synchronization for the specified lines. The array must be + * identical to one for which synchronization has already been established; + * otherwise an exception may be thrown. However, {@code null} may be + * specified, in which case all currently synchronized lines that belong to + * this mixer are unsynchronized. * + * @param lines the synchronized lines for which synchronization should be + * released, or {@code null} for all this mixer's synchronized + * lines * @throws IllegalArgumentException if the lines cannot be unsynchronized. - * This may occur if the argument specified does not exactly match a set - * of lines for which synchronization has already been established. + * This may occur if the argument specified does not exactly match + * a set of lines for which synchronization has already been + * established. */ - public void unsynchronize(Line[] lines); - + void unsynchronize(Line[] lines); /** - * Reports whether this mixer supports synchronization of the specified set of lines. + * Reports whether this mixer supports synchronization of the specified set + * of lines. * - * @param lines the set of lines for which synchronization support is queried - * @param maintainSync true if the synchronization - * must be precisely maintained (i.e., the synchronization must be sample-accurate) - * at all times during operation of the lines , or false - * if precise synchronization is required only during start and stop operations - * - * @return true if the lines can be synchronized, false - * otherwise + * @param lines the set of lines for which synchronization support is + * queried + * @param maintainSync {@code true} if the synchronization must be + * precisely maintained (i.e., the synchronization must be + * sample-accurate) at all times during operation of the lines, or + * {@code false} if precise synchronization is required only during + * start and stop operations + * @return {@code true} if the lines can be synchronized, {@code false} + * otherwise */ - public boolean isSynchronizationSupported(Line[] lines, boolean maintainSync); - + boolean isSynchronizationSupported(Line[] lines, boolean maintainSync); /** - * The Mixer.Info class represents information about an audio mixer, + * The {@code Mixer.Info} class represents information about an audio mixer, * including the product's name, version, and vendor, along with a textual - * description. This information may be retrieved through the - * {@link Mixer#getMixerInfo() getMixerInfo} - * method of the Mixer interface. + * description. This information may be retrieved through the + * {@link Mixer#getMixerInfo() getMixerInfo} method of the {@code Mixer} + * interface. * * @author Kara Kytle * @since 1.3 */ - public static class Info { + class Info { /** * Mixer name. @@ -273,13 +273,14 @@ public interface Mixer extends Line { private final String version; /** - * Constructs a mixer's info object, passing it the given - * textual information. - * @param name the name of the mixer - * @param vendor the company who manufactures or creates the hardware - * or software mixer - * @param description descriptive text about the mixer - * @param version version information for the mixer + * Constructs a mixer's info object, passing it the given textual + * information. + * + * @param name the name of the mixer + * @param vendor the company who manufactures or creates the + * hardware or software mixer + * @param description descriptive text about the mixer + * @param version version information for the mixer */ protected Info(String name, String vendor, String description, String version) { @@ -289,15 +290,16 @@ public interface Mixer extends Line { this.version = version; } - /** - * Indicates whether two info objects are equal, returning true if - * they are identical. - * @param obj the reference object with which to compare this info - * object - * @return true if this info object is the same as the - * obj argument; false otherwise + * Indicates whether two info objects are equal, returning {@code true} + * if they are identical. + * + * @param obj the reference object with which to compare this info + * object + * @return {@code true} if this info object is the same as the + * {@code obj} argument; {@code false} otherwise */ + @Override public final boolean equals(Object obj) { return super.equals(obj); } @@ -307,12 +309,14 @@ public interface Mixer extends Line { * * @return the hashcode for this object */ + @Override public final int hashCode() { return super.hashCode(); } /** * Obtains the name of the mixer. + * * @return a string that names the mixer */ public final String getName() { @@ -321,6 +325,7 @@ public interface Mixer extends Line { /** * Obtains the vendor of the mixer. + * * @return a string that names the mixer's vendor */ public final String getVendor() { @@ -329,6 +334,7 @@ public interface Mixer extends Line { /** * Obtains the description of the mixer. + * * @return a textual description of the mixer */ public final String getDescription() { @@ -337,6 +343,7 @@ public interface Mixer extends Line { /** * Obtains the version of the mixer. + * * @return textual version information for the mixer */ public final String getVersion() { @@ -345,10 +352,12 @@ public interface Mixer extends Line { /** * Provides a string representation of the mixer info. + * * @return a string describing the info object */ + @Override public final String toString() { return (name + ", version " + version); } - } // class Info + } } diff --git a/jdk/src/share/classes/javax/sound/sampled/Port.java b/jdk/src/share/classes/javax/sound/sampled/Port.java index 04b67a8fa3e..61f40c761a5 100644 --- a/jdk/src/share/classes/javax/sound/sampled/Port.java +++ b/jdk/src/share/classes/javax/sound/sampled/Port.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,41 +25,36 @@ package javax.sound.sampled; - /** * Ports are simple lines for input or output of audio to or from audio devices. - * Common examples of ports that act as source lines (mixer inputs) include the microphone, - * line input, and CD-ROM drive. Ports that act as target lines (mixer outputs) include the - * speaker, headphone, and line output. You can access port using a {@link Port.Info} - * object. + * Common examples of ports that act as source lines (mixer inputs) include the + * microphone, line input, and CD-ROM drive. Ports that act as target lines + * (mixer outputs) include the speaker, headphone, and line output. You can + * access port using a {@link Port.Info} object. * * @author Kara Kytle * @since 1.3 */ public interface Port extends Line { - - // INNER CLASSES - - /** - * The Port.Info class extends {@link Line.Info} - * with additional information specific to ports, including the port's name - * and whether it is a source or a target for its mixer. - * By definition, a port acts as either a source or a target to its mixer, - * but not both. (Audio input ports are sources; audio output ports are targets.) + * The {@code Port.Info} class extends {@code Line.Info} with additional + * information specific to ports, including the port's name and whether it + * is a source or a target for its mixer. By definition, a port acts as + * either a source or a target to its mixer, but not both. (Audio input + * ports are sources; audio output ports are targets.) *

    - * To learn what ports are available, you can retrieve port info objects through the - * {@link Mixer#getSourceLineInfo getSourceLineInfo} and - * {@link Mixer#getTargetLineInfo getTargetLineInfo} - * methods of the Mixer interface. Instances of the - * Port.Info class may also be constructed and used to obtain - * lines matching the parameters specified in the Port.Info object. + * To learn what ports are available, you can retrieve port info objects + * through the {@link Mixer#getSourceLineInfo getSourceLineInfo} and + * {@link Mixer#getTargetLineInfo getTargetLineInfo} methods of the + * {@code Mixer} interface. Instances of the {@code Port.Info} class may + * also be constructed and used to obtain lines matching the parameters + * specified in the {@code Port.Info} object. * * @author Kara Kytle * @since 1.3 */ - public static class Info extends Line.Info { + class Info extends Line.Info { // AUDIO PORT TYPE DEFINES @@ -68,7 +63,8 @@ public interface Port extends Line { // SOURCE PORTS /** - * A type of port that gets audio from a built-in microphone or a microphone jack. + * A type of port that gets audio from a built-in microphone or a + * microphone jack. */ public static final Info MICROPHONE = new Info(Port.class,"MICROPHONE", true); @@ -86,7 +82,8 @@ public interface Port extends Line { // TARGET PORTS /** - * A type of port that sends audio to a built-in speaker or a speaker jack. + * A type of port that sends audio to a built-in speaker or a speaker + * jack. */ public static final Info SPEAKER = new Info(Port.class,"SPEAKER", false); @@ -113,19 +110,16 @@ public interface Port extends Line { private String name; private boolean isSource; - - // CONSTRUCTOR - /** - * Constructs a port's info object from the information given. - * This constructor is typically used by an implementation - * of Java Sound to describe a supported line. + * Constructs a port's info object from the information given. This + * constructor is typically used by an implementation of Java Sound to + * describe a supported line. * - * @param lineClass the class of the port described by the info object. - * @param name the string that names the port - * @param isSource true if the port is a source port (such - * as a microphone), false if the port is a target port - * (such as a speaker). + * @param lineClass the class of the port described by the info object + * @param name the string that names the port + * @param isSource {@code true} if the port is a source port (such as a + * microphone), {@code false} if the port is a target port + * (such as a speaker) */ public Info(Class lineClass, String name, boolean isSource) { @@ -134,11 +128,9 @@ public interface Port extends Line { this.isSource = isSource; } - - // METHODS - /** * Obtains the name of the port. + * * @return the string that names the port */ public String getName() { @@ -147,20 +139,23 @@ public interface Port extends Line { /** * Indicates whether the port is a source or a target for its mixer. - * @return true if the port is a source port (such - * as a microphone), false if the port is a target port - * (such as a speaker). + * + * @return {@code true} if the port is a source port (such as a + * microphone), {@code false} if the port is a target port + * (such as a speaker) */ public boolean isSource() { return isSource; } /** - * Indicates whether this info object specified matches this one. - * To match, the match requirements of the superclass must be - * met and the types must be equal. - * @param info the info object for which the match is queried + * Indicates whether this info object specified matches this one. To + * match, the match requirements of the superclass must be met and the + * types must be equal. + * + * @param info the info object for which the match is queried */ + @Override public boolean matches(Line.Info info) { if (! (super.matches(info)) ) { @@ -178,31 +173,30 @@ public interface Port extends Line { return true; } - /** - * Finalizes the equals method + * Finalizes the equals method. */ + @Override public final boolean equals(Object obj) { return super.equals(obj); } /** - * Finalizes the hashCode method + * Finalizes the hashCode method. */ + @Override public final int hashCode() { return super.hashCode(); } - - /** - * Provides a String representation - * of the port. - * @return a string that describes the port + * Provides a {@code String} representation of the port. + * + * @return a string that describes the port */ + @Override public final String toString() { return (name + ((isSource == true) ? " source" : " target") + " port"); } - - } // class Info + } } diff --git a/jdk/src/share/classes/javax/sound/sampled/ReverbType.java b/jdk/src/share/classes/javax/sound/sampled/ReverbType.java index 7afd7aefe56..e308b0f9402 100644 --- a/jdk/src/share/classes/javax/sound/sampled/ReverbType.java +++ b/jdk/src/share/classes/javax/sound/sampled/ReverbType.java @@ -25,46 +25,41 @@ package javax.sound.sampled; - /** - * The ReverbType class provides methods for - * accessing various reverberation settings to be applied to - * an audio signal. + * The {@code ReverbType} class provides methods for accessing various + * reverberation settings to be applied to an audio signal. *

    - * Reverberation simulates the reflection of sound off of - * the walls, ceiling, and floor of a room. Depending on - * the size of the room, and how absorbent or reflective the materials in the - * room's surfaces are, the sound might bounce around for a - * long time before dying away. + * Reverberation simulates the reflection of sound off of the walls, ceiling, + * and floor of a room. Depending on the size of the room, and how absorbent or + * reflective the materials in the room's surfaces are, the sound might bounce + * around for a long time before dying away. *

    - * The reverberation parameters provided by ReverbType consist - * of the delay time and intensity of early reflections, the delay time and - * intensity of late reflections, and an overall decay time. - * Early reflections are the initial individual low-order reflections of the - * direct signal off the surfaces in the room. - * The late Reflections are the dense, high-order reflections that characterize - * the room's reverberation. - * The delay times for the start of these two reflection types give the listener - * a sense of the overall size and complexity of the room's shape and contents. - * The larger the room, the longer the reflection delay times. - * The early and late reflections' intensities define the gain (in decibels) of the reflected - * signals as compared to the direct signal. These intensities give the - * listener an impression of the absorptive nature of the surfaces and objects - * in the room. + * The reverberation parameters provided by {@code ReverbType} consist of the + * delay time and intensity of early reflections, the delay time and intensity + * of late reflections, and an overall decay time. Early reflections are the + * initial individual low-order reflections of the direct signal off the + * surfaces in the room. The late Reflections are the dense, high-order + * reflections that characterize the room's reverberation. The delay times for + * the start of these two reflection types give the listener a sense of the + * overall size and complexity of the room's shape and contents. The larger the + * room, the longer the reflection delay times. The early and late reflections' + * intensities define the gain (in decibels) of the reflected signals as + * compared to the direct signal. These intensities give the listener an + * impression of the absorptive nature of the surfaces and objects in the room. * The decay time defines how long the reverberation takes to exponentially - * decay until it is no longer perceptible ("effective zero"). - * The larger and less absorbent the surfaces, the longer the decay time. + * decay until it is no longer perceptible ("effective zero"). The larger and + * less absorbent the surfaces, the longer the decay time. *

    - * The set of parameters defined here may not include all aspects of reverberation - * as specified by some systems. For example, the Midi Manufacturer's Association - * (MMA) has an Interactive Audio Special Interest Group (IASIG), which has a - * 3-D Working Group that has defined a Level 2 Spec (I3DL2). I3DL2 - * supports filtering of reverberation and - * control of reverb density. These properties are not included in the JavaSound 1.0 - * definition of a reverb control. In such a case, the implementing system - * should either extend the defined reverb control to include additional - * parameters, or else interpret the system's additional capabilities in a way that fits - * the model described here. + * The set of parameters defined here may not include all aspects of + * reverberation as specified by some systems. For example, the Midi + * Manufacturer's Association (MMA) has an Interactive Audio Special Interest + * Group (IASIG), which has a 3-D Working Group that has defined a Level 2 Spec + * (I3DL2). I3DL2 supports filtering of reverberation and control of reverb + * density. These properties are not included in the JavaSound 1.0 definition of + * a reverb control. In such a case, the implementing system should either + * extend the defined reverb control to include additional parameters, or else + * interpret the system's additional capabilities in a way that fits the model + * described here. *

    * If implementing JavaSound on a I3DL2-compliant device: *

      @@ -72,8 +67,8 @@ package javax.sound.sampled; *
    • Density parameters are set to midway between minimum and maximum *
    *

    - * The following table shows what parameter values an implementation might use for a - * representative set of reverberation settings. + * The following table shows what parameter values an implementation might use + * for a representative set of reverberation settings. *

    * * Reverberation Types and Parameters @@ -142,7 +137,7 @@ package javax.sound.sampled; public class ReverbType { /** - * Descriptive name of the reverb type.. + * Descriptive name of the reverb type. */ private String name; @@ -167,20 +162,25 @@ public class ReverbType { private float lateReflectionIntensity; /** - * Total decay time + * Total decay time. */ private int decayTime; - /** * Constructs a new reverb type that has the specified reverberation * parameter values. - * @param name the name of the new reverb type, or a zero-length String - * @param earlyReflectionDelay the new type's early reflection delay time in microseconds - * @param earlyReflectionIntensity the new type's early reflection intensity in dB - * @param lateReflectionDelay the new type's late reflection delay time in microseconds - * @param lateReflectionIntensity the new type's late reflection intensity in dB - * @param decayTime the new type's decay time in microseconds + * + * @param name the name of the new reverb type, or a zero-length + * {@code String} + * @param earlyReflectionDelay the new type's early reflection delay time + * in microseconds + * @param earlyReflectionIntensity the new type's early reflection + * intensity in dB + * @param lateReflectionDelay the new type's late reflection delay time in + * microseconds + * @param lateReflectionIntensity the new type's late reflection intensity + * in dB + * @param decayTime the new type's decay time in microseconds */ protected ReverbType(String name, int earlyReflectionDelay, float earlyReflectionIntensity, int lateReflectionDelay, float lateReflectionIntensity, int decayTime) { @@ -192,9 +192,9 @@ public class ReverbType { this.decayTime = decayTime; } - /** * Obtains the name of this reverb type. + * * @return the name of this reverb type * @since 1.5 */ @@ -202,89 +202,88 @@ public class ReverbType { return name; } - /** - * Returns the early reflection delay time in microseconds. - * This is the amount of time between when the direct signal is - * heard and when the first early reflections are heard. - * @return early reflection delay time for this reverb type, in microseconds + * Returns the early reflection delay time in microseconds. This is the + * amount of time between when the direct signal is heard and when the first + * early reflections are heard. + * + * @return early reflection delay time for this reverb type, in microseconds */ public final int getEarlyReflectionDelay() { return earlyReflectionDelay; } - /** - * Returns the early reflection intensity in decibels. - * This is the amplitude attenuation of the first early reflections - * relative to the direct signal. - * @return early reflection intensity for this reverb type, in dB + * Returns the early reflection intensity in decibels. This is the amplitude + * attenuation of the first early reflections relative to the direct signal. + * + * @return early reflection intensity for this reverb type, in dB */ public final float getEarlyReflectionIntensity() { return earlyReflectionIntensity; } - /** - * Returns the late reflection delay time in microseconds. - * This is the amount of time between when the first early reflections - * are heard and when the first late reflections are heard. - * @return late reflection delay time for this reverb type, in microseconds + * Returns the late reflection delay time in microseconds. This is the + * amount of time between when the first early reflections are heard and + * when the first late reflections are heard. + * + * @return late reflection delay time for this reverb type, in microseconds */ public final int getLateReflectionDelay() { return lateReflectionDelay; } - /** - * Returns the late reflection intensity in decibels. - * This is the amplitude attenuation of the first late reflections - * relative to the direct signal. - * @return late reflection intensity for this reverb type, in dB + * Returns the late reflection intensity in decibels. This is the amplitude + * attenuation of the first late reflections relative to the direct signal. + * + * @return late reflection intensity for this reverb type, in dB */ public final float getLateReflectionIntensity() { return lateReflectionIntensity; } - /** - * Obtains the decay time, which is the amount of time over which the - * late reflections attenuate to effective zero. The effective zero - * value is implementation-dependent. - * @return the decay time of the late reflections, in microseconds + * Obtains the decay time, which is the amount of time over which the late + * reflections attenuate to effective zero. The effective zero value is + * implementation-dependent. + * + * @return the decay time of the late reflections, in microseconds */ public final int getDecayTime() { return decayTime; } - /** * Indicates whether the specified object is equal to this reverb type, - * returning true if the objects are identical. - * @param obj the reference object with which to compare - * @return true if this reverb type is the same as - * obj; false otherwise + * returning {@code true} if the objects are identical. + * + * @param obj the reference object with which to compare + * @return {@code true} if this reverb type is the same as {@code obj}; + * {@code false} otherwise */ + @Override public final boolean equals(Object obj) { return super.equals(obj); } - /** * Finalizes the hashcode method. */ + @Override public final int hashCode() { return super.hashCode(); } - /** - * Provides a String representation of the reverb type, - * including its name and its parameter settings. - * The exact contents of the string may vary between implementations of - * Java Sound. + * Provides a {@code String} representation of the reverb type, including + * its name and its parameter settings. The exact contents of the string may + * vary between implementations of Java Sound. + * * @return reverberation type name and description */ + @Override public final String toString() { //$$fb2001-07-20: fix for bug 4385060: The "name" attribute of class "ReverbType" is not accessible. @@ -295,5 +294,4 @@ public class ReverbType { " ns, late reflection intensity " + lateReflectionIntensity + " dB, decay time " + decayTime); } - -} // class ReverbType +} diff --git a/jdk/src/share/classes/javax/sound/sampled/SourceDataLine.java b/jdk/src/share/classes/javax/sound/sampled/SourceDataLine.java index 5cfbccf2ccd..7749b3a86fc 100644 --- a/jdk/src/share/classes/javax/sound/sampled/SourceDataLine.java +++ b/jdk/src/share/classes/javax/sound/sampled/SourceDataLine.java @@ -25,36 +25,35 @@ package javax.sound.sampled; - /** - * A source data line is a data line to which data may be written. It acts as - * a source to its mixer. An application writes audio bytes to a source data line, - * which handles the buffering of the bytes and delivers them to the mixer. - * The mixer may mix the samples with those from other sources and then deliver - * the mix to a target such as an output port (which may represent an audio output + * A source data line is a data line to which data may be written. It acts as a + * source to its mixer. An application writes audio bytes to a source data line, + * which handles the buffering of the bytes and delivers them to the mixer. The + * mixer may mix the samples with those from other sources and then deliver the + * mix to a target such as an output port (which may represent an audio output * device on a sound card). *

    * Note that the naming convention for this interface reflects the relationship - * between the line and its mixer. From the perspective of an application, - * a source data line may act as a target for audio data. + * between the line and its mixer. From the perspective of an application, a + * source data line may act as a target for audio data. *

    * A source data line can be obtained from a mixer by invoking the - * {@link Mixer#getLine getLine} method of Mixer with - * an appropriate {@link DataLine.Info} object. + * {@link Mixer#getLine getLine} method of {@code Mixer} with an appropriate + * {@link DataLine.Info} object. *

    - * The SourceDataLine interface provides a method for writing - * audio data to the data line's buffer. Applications that play or mix - * audio should write data to the source data line quickly enough to keep the - * buffer from underflowing (emptying), which could cause discontinuities in - * the audio that are perceived as clicks. Applications can use the - * {@link DataLine#available available} method defined in the - * DataLine interface to determine the amount of data currently - * queued in the data line's buffer. The amount of data which can be written - * to the buffer without blocking is the difference between the buffer size - * and the amount of queued data. If the delivery of audio output - * stops due to underflow, a {@link LineEvent.Type#STOP STOP} event is - * generated. A {@link LineEvent.Type#START START} event is generated - * when the audio output resumes. + * The {@code SourceDataLine} interface provides a method for writing audio data + * to the data line's buffer. Applications that play or mix audio should write + * data to the source data line quickly enough to keep the buffer from + * underflowing (emptying), which could cause discontinuities in the audio that + * are perceived as clicks. Applications can use the + * {@link DataLine#available available} method defined in the {@code DataLine} + * interface to determine the amount of data currently queued in the data line's + * buffer. The amount of data which can be written to the buffer without + * blocking is the difference between the buffer size and the amount of queued + * data. If the delivery of audio output stops due to underflow, a + * {@link LineEvent.Type#STOP STOP} event is generated. A + * {@link LineEvent.Type#START START} event is generated when the audio output + * resumes. * * @author Kara Kytle * @see Mixer @@ -64,138 +63,130 @@ package javax.sound.sampled; */ public interface SourceDataLine extends DataLine { - /** * Opens the line with the specified format and suggested buffer size, - * causing the line to acquire any required - * system resources and become operational. + * causing the line to acquire any required system resources and become + * operational. *

    * The buffer size is specified in bytes, but must represent an integral - * number of sample frames. Invoking this method with a requested buffer + * number of sample frames. Invoking this method with a requested buffer * size that does not meet this requirement may result in an - * IllegalArgumentException. The actual buffer size for the open line may - * differ from the requested buffer size. The value actually set may be - * queried by subsequently calling {@link DataLine#getBufferSize}. + * {@code IllegalArgumentException}. The actual buffer size for the open + * line may differ from the requested buffer size. The value actually set + * may be queried by subsequently calling {@link DataLine#getBufferSize}. *

    * If this operation succeeds, the line is marked as open, and an - * {@link LineEvent.Type#OPEN OPEN} event is dispatched to the - * line's listeners. + * {@link LineEvent.Type#OPEN OPEN} event is dispatched to the line's + * listeners. *

    - * Invoking this method on a line which is already open is illegal - * and may result in an IllegalStateException. + * Invoking this method on a line which is already open is illegal and may + * result in an {@code IllegalStateException}. *

    - * Note that some lines, once closed, cannot be reopened. Attempts - * to reopen such a line will always result in a - * LineUnavailableException. + * Note that some lines, once closed, cannot be reopened. Attempts to reopen + * such a line will always result in a {@code LineUnavailableException}. * - * @param format the desired audio format - * @param bufferSize the desired buffer size - * @throws LineUnavailableException if the line cannot be - * opened due to resource restrictions - * @throws IllegalArgumentException if the buffer size does not represent - * an integral number of sample frames, - * or if format is not fully specified or invalid + * @param format the desired audio format + * @param bufferSize the desired buffer size + * @throws LineUnavailableException if the line cannot be opened due to + * resource restrictions + * @throws IllegalArgumentException if the buffer size does not represent an + * integral number of sample frames, or if {@code format} is not + * fully specified or invalid * @throws IllegalStateException if the line is already open - * @throws SecurityException if the line cannot be - * opened due to security restrictions - * + * @throws SecurityException if the line cannot be opened due to security + * restrictions * @see #open(AudioFormat) * @see Line#open * @see Line#close * @see Line#isOpen * @see LineEvent */ - public void open(AudioFormat format, int bufferSize) throws LineUnavailableException; - + void open(AudioFormat format, int bufferSize) + throws LineUnavailableException; /** * Opens the line with the specified format, causing the line to acquire any * required system resources and become operational. - * *

    * The implementation chooses a buffer size, which is measured in bytes but - * which encompasses an integral number of sample frames. The buffer size + * which encompasses an integral number of sample frames. The buffer size * that the system has chosen may be queried by subsequently calling - * {@link DataLine#getBufferSize}. + * {@link DataLine#getBufferSize}. *

    * If this operation succeeds, the line is marked as open, and an - * {@link LineEvent.Type#OPEN OPEN} event is dispatched to the - * line's listeners. + * {@link LineEvent.Type#OPEN OPEN} event is dispatched to the line's + * listeners. *

    - * Invoking this method on a line which is already open is illegal - * and may result in an IllegalStateException. + * Invoking this method on a line which is already open is illegal and may + * result in an {@code IllegalStateException}. *

    - * Note that some lines, once closed, cannot be reopened. Attempts - * to reopen such a line will always result in a - * LineUnavailableException. + * Note that some lines, once closed, cannot be reopened. Attempts to reopen + * such a line will always result in a {@code LineUnavailableException}. * - * @param format the desired audio format - * @throws LineUnavailableException if the line cannot be - * opened due to resource restrictions - * @throws IllegalArgumentException if format - * is not fully specified or invalid + * @param format the desired audio format + * @throws LineUnavailableException if the line cannot be opened due to + * resource restrictions + * @throws IllegalArgumentException if {@code format} is not fully specified + * or invalid * @throws IllegalStateException if the line is already open - * @throws SecurityException if the line cannot be - * opened due to security restrictions - * + * @throws SecurityException if the line cannot be opened due to security + * restrictions * @see #open(AudioFormat, int) * @see Line#open * @see Line#close * @see Line#isOpen * @see LineEvent */ - public void open(AudioFormat format) throws LineUnavailableException; - + void open(AudioFormat format) throws LineUnavailableException; /** - * Writes audio data to the mixer via this source data line. The requested - * number of bytes of data are read from the specified array, - * starting at the given offset into the array, and written to the data - * line's buffer. If the caller attempts to write more data than can - * currently be written (see {@link DataLine#available available}), - * this method blocks until the requested amount of data has been written. - * This applies even if the requested amount of data to write is greater - * than the data line's buffer size. However, if the data line is closed, - * stopped, or flushed before the requested amount has been written, - * the method no longer blocks, but returns the number of bytes - * written thus far. + * Writes audio data to the mixer via this source data line. The requested + * number of bytes of data are read from the specified array, starting at + * the given offset into the array, and written to the data line's buffer. + * If the caller attempts to write more data than can currently be written + * (see {@link DataLine#available available}), this method blocks until the + * requested amount of data has been written. This applies even if the + * requested amount of data to write is greater than the data line's buffer + * size. However, if the data line is closed, stopped, or flushed before the + * requested amount has been written, the method no longer blocks, but + * returns the number of bytes written thus far. *

    - * The number of bytes that can be written without blocking can be ascertained - * using the {@link DataLine#available available} method of the - * DataLine interface. (While it is guaranteed that - * this number of bytes can be written without blocking, there is no guarantee - * that attempts to write additional data will block.) + * The number of bytes that can be written without blocking can be + * ascertained using the {@link DataLine#available available} method of the + * {@code DataLine} interface. (While it is guaranteed that this number of + * bytes can be written without blocking, there is no guarantee that + * attempts to write additional data will block.) *

    - * The number of bytes to write must represent an integral number of - * sample frames, such that: + * The number of bytes to write must represent an integral number of sample + * frames, such that: *
    - *

    [ bytes written ] % [frame size in bytes ] == 0
    + *
    {@code [ bytes written ] % [frame size in bytes ] == 0}
    *
    - * The return value will always meet this requirement. A request to write a - * number of bytes representing a non-integral number of sample frames cannot - * be fulfilled and may result in an IllegalArgumentException. + * The return value will always meet this requirement. A request to write a + * number of bytes representing a non-integral number of sample frames + * cannot be fulfilled and may result in an + * {@code IllegalArgumentException}. * - * @param b a byte array containing data to be written to the data line - * @param len the length, in bytes, of the valid data in the array - * (in other words, the requested amount of data to write, in bytes) - * @param off the offset from the beginning of the array, in bytes + * @param b a byte array containing data to be written to the data line + * @param len the length, in bytes, of the valid data in the array (in + * other words, the requested amount of data to write, in bytes) + * @param off the offset from the beginning of the array, in bytes * @return the number of bytes actually written * @throws IllegalArgumentException if the requested number of bytes does - * not represent an integral number of sample frames, - * or if len is negative - * @throws ArrayIndexOutOfBoundsException if off is negative, - * or off+len is greater than the length of the array - * b. - * + * not represent an integral number of sample frames, or if + * {@code len} is negative + * @throws ArrayIndexOutOfBoundsException if {@code off} is negative, or + * {@code off+len} is greater than the length of the array {@code b} * @see TargetDataLine#read * @see DataLine#available */ - public int write(byte[] b, int off, int len); + int write(byte[] b, int off, int len); /** * Obtains the number of sample frames of audio data that can be written to - * the mixer, via this data line, without blocking. Note that the return + * the mixer, via this data line, without blocking. Note that the return * value measures sample frames, not bytes. + * * @return the number of sample frames currently available for writing * @see TargetDataLine#availableRead */ diff --git a/jdk/src/share/classes/javax/sound/sampled/TargetDataLine.java b/jdk/src/share/classes/javax/sound/sampled/TargetDataLine.java index a6f14269240..acacdbcccae 100644 --- a/jdk/src/share/classes/javax/sound/sampled/TargetDataLine.java +++ b/jdk/src/share/classes/javax/sound/sampled/TargetDataLine.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 @@ -26,29 +26,28 @@ package javax.sound.sampled; /** - * A target data line is a type of {@link DataLine} from which - * audio data can be read. The most common example is a data line that gets - * its data from an audio capture device. (The device is implemented as a - * mixer that writes to the target data line.) + * A target data line is a type of {@link DataLine} from which audio data can be + * read. The most common example is a data line that gets its data from an audio + * capture device. (The device is implemented as a mixer that writes to the + * target data line.) *

    * Note that the naming convention for this interface reflects the relationship - * between the line and its mixer. From the perspective of an application, - * a target data line may act as a source for audio data. + * between the line and its mixer. From the perspective of an application, a + * target data line may act as a source for audio data. *

    * The target data line can be obtained from a mixer by invoking the - * {@link Mixer#getLine getLine} - * method of Mixer with an appropriate - * {@link DataLine.Info} object. + * {@link Mixer#getLine getLine} method of {@code Mixer} with an appropriate + * {@link DataLine.Info} object. *

    - * The TargetDataLine interface provides a method for reading the - * captured data from the target data line's buffer.Applications - * that record audio should read data from the target data line quickly enough - * to keep the buffer from overflowing, which could cause discontinuities in - * the captured data that are perceived as clicks. Applications can use the - * {@link DataLine#available available} method defined in the - * DataLine interface to determine the amount of data currently - * queued in the data line's buffer. If the buffer does overflow, - * the oldest queued data is discarded and replaced by new data. + * The {@code TargetDataLine} interface provides a method for reading the + * captured data from the target data line's buffer. Applications that record + * audio should read data from the target data line quickly enough to keep the + * buffer from overflowing, which could cause discontinuities in the captured + * data that are perceived as clicks. Applications can use the + * {@link DataLine#available available} method defined in the {@code DataLine} + * interface to determine the amount of data currently queued in the data line's + * buffer. If the buffer does overflow, the oldest queued data is discarded and + * replaced by new data. * * @author Kara Kytle * @see Mixer @@ -58,133 +57,126 @@ package javax.sound.sampled; */ public interface TargetDataLine extends DataLine { - /** * Opens the line with the specified format and requested buffer size, * causing the line to acquire any required system resources and become * operational. *

    * The buffer size is specified in bytes, but must represent an integral - * number of sample frames. Invoking this method with a requested buffer + * number of sample frames. Invoking this method with a requested buffer * size that does not meet this requirement may result in an - * IllegalArgumentException. The actual buffer size for the open line may - * differ from the requested buffer size. The value actually set may be - * queried by subsequently calling {@link DataLine#getBufferSize} + * {@code IllegalArgumentException}. The actual buffer size for the open + * line may differ from the requested buffer size. The value actually set + * may be queried by subsequently calling {@link DataLine#getBufferSize} *

    * If this operation succeeds, the line is marked as open, and an - * {@link LineEvent.Type#OPEN OPEN} event is dispatched to the - * line's listeners. + * {@link LineEvent.Type#OPEN OPEN} event is dispatched to the line's + * listeners. *

    - * Invoking this method on a line that is already open is illegal - * and may result in an IllegalStateException. + * Invoking this method on a line that is already open is illegal and may + * result in an {@code IllegalStateException}. *

    - * Some lines, once closed, cannot be reopened. Attempts - * to reopen such a line will always result in a - * LineUnavailableException. + * Some lines, once closed, cannot be reopened. Attempts to reopen such a + * line will always result in a {@code LineUnavailableException}. * - * @param format the desired audio format - * @param bufferSize the desired buffer size, in bytes. - * @throws LineUnavailableException if the line cannot be - * opened due to resource restrictions - * @throws IllegalArgumentException if the buffer size does not represent - * an integral number of sample frames, - * or if format is not fully specified or invalid + * @param format the desired audio format + * @param bufferSize the desired buffer size, in bytes + * @throws LineUnavailableException if the line cannot be opened due to + * resource restrictions + * @throws IllegalArgumentException if the buffer size does not represent an + * integral number of sample frames, or if {@code format} is not + * fully specified or invalid * @throws IllegalStateException if the line is already open - * @throws SecurityException if the line cannot be - * opened due to security restrictions - * + * @throws SecurityException if the line cannot be opened due to security + * restrictions * @see #open(AudioFormat) * @see Line#open * @see Line#close * @see Line#isOpen * @see LineEvent */ - public void open(AudioFormat format, int bufferSize) throws LineUnavailableException; - + void open(AudioFormat format, int bufferSize) throws LineUnavailableException; /** * Opens the line with the specified format, causing the line to acquire any * required system resources and become operational. - * *

    * The implementation chooses a buffer size, which is measured in bytes but - * which encompasses an integral number of sample frames. The buffer size - * that the system has chosen may be queried by subsequently calling {@link DataLine#getBufferSize} + * which encompasses an integral number of sample frames. The buffer size + * that the system has chosen may be queried by subsequently calling + * {@link DataLine#getBufferSize} *

    * If this operation succeeds, the line is marked as open, and an - * {@link LineEvent.Type#OPEN OPEN} event is dispatched to the - * line's listeners. + * {@link LineEvent.Type#OPEN OPEN} event is dispatched to the line's + * listeners. *

    - * Invoking this method on a line that is already open is illegal - * and may result in an IllegalStateException. + * Invoking this method on a line that is already open is illegal and may + * result in an {@code IllegalStateException}. *

    - * Some lines, once closed, cannot be reopened. Attempts - * to reopen such a line will always result in a - * LineUnavailableException. + * Some lines, once closed, cannot be reopened. Attempts to reopen such a + * line will always result in a {@code LineUnavailableException}. * - * @param format the desired audio format - * @throws LineUnavailableException if the line cannot be - * opened due to resource restrictions - * @throws IllegalArgumentException if format - * is not fully specified or invalid + * @param format the desired audio format + * @throws LineUnavailableException if the line cannot be opened due to + * resource restrictions + * @throws IllegalArgumentException if {@code format} is not fully specified + * or invalid * @throws IllegalStateException if the line is already open - * @throws SecurityException if the line cannot be - * opened due to security restrictions - * + * @throws SecurityException if the line cannot be opened due to security + * restrictions * @see #open(AudioFormat, int) * @see Line#open * @see Line#close * @see Line#isOpen * @see LineEvent */ - public void open(AudioFormat format) throws LineUnavailableException; - + void open(AudioFormat format) throws LineUnavailableException; /** - * Reads audio data from the data line's input buffer. The requested - * number of bytes is read into the specified array, starting at - * the specified offset into the array in bytes. This method blocks until - * the requested amount of data has been read. However, if the data line - * is closed, stopped, drained, or flushed before the requested amount has - * been read, the method no longer blocks, but returns the number of bytes - * read thus far. + * Reads audio data from the data line's input buffer. The requested number + * of bytes is read into the specified array, starting at the specified + * offset into the array in bytes. This method blocks until the requested + * amount of data has been read. However, if the data line is closed, + * stopped, drained, or flushed before the requested amount has been read, + * the method no longer blocks, but returns the number of bytes read thus + * far. *

    * The number of bytes that can be read without blocking can be ascertained - * using the {@link DataLine#available available} method of the - * DataLine interface. (While it is guaranteed that - * this number of bytes can be read without blocking, there is no guarantee - * that attempts to read additional data will block.) + * using the {@link DataLine#available available} method of the + * {@code DataLine} interface. (While it is guaranteed that this number of + * bytes can be read without blocking, there is no guarantee that attempts + * to read additional data will block.) *

    * The number of bytes to be read must represent an integral number of * sample frames, such that: *
    - *

    [ bytes read ] % [frame size in bytes ] == 0
    + *
    {@code [ bytes read ] % [frame size in bytes ] == 0}
    *
    - * The return value will always meet this requirement. A request to read a - * number of bytes representing a non-integral number of sample frames cannot - * be fulfilled and may result in an IllegalArgumentException. + * The return value will always meet this requirement. A request to read a + * number of bytes representing a non-integral number of sample frames + * cannot be fulfilled and may result in an IllegalArgumentException. * - * @param b a byte array that will contain the requested input data when - * this method returns - * @param off the offset from the beginning of the array, in bytes - * @param len the requested number of bytes to read + * @param b a byte array that will contain the requested input data when + * this method returns + * @param off the offset from the beginning of the array, in bytes + * @param len the requested number of bytes to read * @return the number of bytes actually read * @throws IllegalArgumentException if the requested number of bytes does - * not represent an integral number of sample frames. - * or if len is negative. - * @throws ArrayIndexOutOfBoundsException if off is negative, - * or off+len is greater than the length of the array - * b. + * not represent an integral number of sample frames, or if + * {@code len} is negative + * @throws ArrayIndexOutOfBoundsException if {@code off} is negative, or + * {@code off+len} is greater than the length of the array {@code b} * * @see SourceDataLine#write * @see DataLine#available */ - public int read(byte[] b, int off, int len); + int read(byte[] b, int off, int len); /** * Obtains the number of sample frames of audio data that can be read from - * the target data line without blocking. Note that the return value + * the target data line without blocking. Note that the return value * measures sample frames, not bytes. + * * @return the number of sample frames currently available for reading * @see SourceDataLine#availableWrite */ diff --git a/jdk/src/share/classes/javax/sound/sampled/UnsupportedAudioFileException.java b/jdk/src/share/classes/javax/sound/sampled/UnsupportedAudioFileException.java index 45acd480f35..31d68160995 100644 --- a/jdk/src/share/classes/javax/sound/sampled/UnsupportedAudioFileException.java +++ b/jdk/src/share/classes/javax/sound/sampled/UnsupportedAudioFileException.java @@ -26,33 +26,32 @@ package javax.sound.sampled; /** - * An UnsupportedAudioFileException is an exception indicating that an - * operation failed because a file did not contain valid data of a recognized file - * type and format. + * An {@code UnsupportedAudioFileException} is an exception indicating that an + * operation failed because a file did not contain valid data of a recognized + * file type and format. * * @author Kara Kytle * @since 1.3 */ public class UnsupportedAudioFileException extends Exception { + private static final long serialVersionUID = -139127412623160368L; /** - * Constructs a UnsupportedAudioFileException that has - * null as its error detail message. + * Constructs a {@code UnsupportedAudioFileException} that has {@code null} + * as its error detail message. */ public UnsupportedAudioFileException() { - super(); } /** - * Constructs a UnsupportedAudioFileException that has - * the specified detail message. + * Constructs a {@code UnsupportedAudioFileException} that has the specified + * detail message. * - * @param message a string containing the error detail message + * @param message a string containing the error detail message */ - public UnsupportedAudioFileException(String message) { - + public UnsupportedAudioFileException(final String message) { super(message); } } diff --git a/jdk/src/share/classes/javax/sound/sampled/spi/AudioFileReader.java b/jdk/src/share/classes/javax/sound/sampled/spi/AudioFileReader.java index cc476452126..daa75556785 100644 --- a/jdk/src/share/classes/javax/sound/sampled/spi/AudioFileReader.java +++ b/jdk/src/share/classes/javax/sound/sampled/spi/AudioFileReader.java @@ -108,7 +108,7 @@ public abstract class AudioFileReader { * @param stream the input stream from which the {@code AudioInputStream} * should be constructed * @return an {@code AudioInputStream} object based on the audio file data - * contained in the input stream. + * contained in the input stream * @throws UnsupportedAudioFileException if the stream does not point to * valid audio file data recognized by the system * @throws IOException if an I/O exception occurs diff --git a/jdk/src/share/classes/javax/sound/sampled/spi/FormatConversionProvider.java b/jdk/src/share/classes/javax/sound/sampled/spi/FormatConversionProvider.java index 7693087c9d9..8cb7fb68d5f 100644 --- a/jdk/src/share/classes/javax/sound/sampled/spi/FormatConversionProvider.java +++ b/jdk/src/share/classes/javax/sound/sampled/spi/FormatConversionProvider.java @@ -117,7 +117,7 @@ public abstract class FormatConversionProvider { * are supported for this source format, an array of length 0 is returned. * * @param sourceFormat format of the incoming data - * @return array of supported target format encodings. + * @return array of supported target format encodings */ public abstract Encoding[] getTargetEncodings(AudioFormat sourceFormat); @@ -150,7 +150,7 @@ public abstract class FormatConversionProvider { * * @param targetEncoding desired encoding of the stream after processing * @param sourceFormat format of the incoming data - * @return array of supported target formats. + * @return array of supported target formats */ public abstract AudioFormat[] getTargetFormats(Encoding targetEncoding, AudioFormat sourceFormat); @@ -187,7 +187,7 @@ public abstract class FormatConversionProvider { * @return stream from which processed data with the specified target * encoding may be read * @throws IllegalArgumentException if the format combination supplied is - * not supported. + * not supported */ public abstract AudioInputStream getAudioInputStream( Encoding targetEncoding, AudioInputStream sourceStream); @@ -202,7 +202,7 @@ public abstract class FormatConversionProvider { * @return stream from which processed data with the specified format may be * read * @throws IllegalArgumentException if the format combination supplied is - * not supported. + * not supported */ public abstract AudioInputStream getAudioInputStream( AudioFormat targetFormat, AudioInputStream sourceStream); diff --git a/jdk/src/share/classes/javax/sql/CommonDataSource.java b/jdk/src/share/classes/javax/sql/CommonDataSource.java index ac8728c2aca..9a63ddb0e1e 100644 --- a/jdk/src/share/classes/javax/sql/CommonDataSource.java +++ b/jdk/src/share/classes/javax/sql/CommonDataSource.java @@ -34,6 +34,7 @@ import java.util.logging.Logger; * Interface that defines the methods which are common between DataSource, * XADataSource and ConnectionPoolDataSource. * + * @since 1.6 */ public interface CommonDataSource { diff --git a/jdk/src/share/classes/javax/sql/rowset/BaseRowSet.java b/jdk/src/share/classes/javax/sql/rowset/BaseRowSet.java index b8d9d8ea6e8..a7fdf01932a 100644 --- a/jdk/src/share/classes/javax/sql/rowset/BaseRowSet.java +++ b/jdk/src/share/classes/javax/sql/rowset/BaseRowSet.java @@ -291,6 +291,8 @@ import javax.sql.rowset.serial.*; * extending class overrides and reimplements any BaseRowSet method and encounters * connectivity or underlying data source issues, that method may in addition throw an * SQLException object for that reason. +* +* @since 1.5 */ public abstract class BaseRowSet implements Serializable, Cloneable { diff --git a/jdk/src/share/classes/javax/sql/rowset/CachedRowSet.java b/jdk/src/share/classes/javax/sql/rowset/CachedRowSet.java index eafbfb7059b..adb1b02771b 100644 --- a/jdk/src/share/classes/javax/sql/rowset/CachedRowSet.java +++ b/jdk/src/share/classes/javax/sql/rowset/CachedRowSet.java @@ -626,6 +626,7 @@ import javax.sql.rowset.spi.*; * * * @author Jonathan Bruce + * @since 1.5 */ public interface CachedRowSet extends RowSet, Joinable { diff --git a/jdk/src/share/classes/javax/sql/rowset/FilteredRowSet.java b/jdk/src/share/classes/javax/sql/rowset/FilteredRowSet.java index 7570ae48cf9..d03d6c68461 100644 --- a/jdk/src/share/classes/javax/sql/rowset/FilteredRowSet.java +++ b/jdk/src/share/classes/javax/sql/rowset/FilteredRowSet.java @@ -122,6 +122,7 @@ import java.math.*; * synchronized with the data source. * * @author Jonathan Bruce + * @since 1.5 */ public interface FilteredRowSet extends WebRowSet { diff --git a/jdk/src/share/classes/javax/sql/rowset/JdbcRowSet.java b/jdk/src/share/classes/javax/sql/rowset/JdbcRowSet.java index 2e760ebea99..e46f58aff58 100644 --- a/jdk/src/share/classes/javax/sql/rowset/JdbcRowSet.java +++ b/jdk/src/share/classes/javax/sql/rowset/JdbcRowSet.java @@ -118,6 +118,7 @@ import java.io.*; * requirements of connected and disconnected RowSet objects. * * @author Jonathan Bruce + * @since 1.5 */ public interface JdbcRowSet extends RowSet, Joinable { diff --git a/jdk/src/share/classes/javax/sql/rowset/JoinRowSet.java b/jdk/src/share/classes/javax/sql/rowset/JoinRowSet.java index 501a8eef87d..774ac31158b 100644 --- a/jdk/src/share/classes/javax/sql/rowset/JoinRowSet.java +++ b/jdk/src/share/classes/javax/sql/rowset/JoinRowSet.java @@ -217,6 +217,7 @@ import javax.sql.rowset.*; * This method creates a copy that can be persisted to the data source. * * + * @since 1.5 */ public interface JoinRowSet extends WebRowSet { diff --git a/jdk/src/share/classes/javax/sql/rowset/Joinable.java b/jdk/src/share/classes/javax/sql/rowset/Joinable.java index 15a5b77d673..d78b13de6c7 100644 --- a/jdk/src/share/classes/javax/sql/rowset/Joinable.java +++ b/jdk/src/share/classes/javax/sql/rowset/Joinable.java @@ -129,6 +129,7 @@ import java.sql.SQLException; * * @see JoinRowSet * @author Jonathan Bruce + * @since 1.5 */ public interface Joinable { diff --git a/jdk/src/share/classes/javax/sql/rowset/Predicate.java b/jdk/src/share/classes/javax/sql/rowset/Predicate.java index f9fec9e49c8..a3f674d454d 100644 --- a/jdk/src/share/classes/javax/sql/rowset/Predicate.java +++ b/jdk/src/share/classes/javax/sql/rowset/Predicate.java @@ -97,6 +97,7 @@ import java.sql.*; * applications that use both column identification conventions. * * @author Jonathan Bruce, Amit Handa + * @since 1.5 * */ diff --git a/jdk/src/share/classes/javax/sql/rowset/RowSetMetaDataImpl.java b/jdk/src/share/classes/javax/sql/rowset/RowSetMetaDataImpl.java index b71270a18dc..b15a4df9dac 100644 --- a/jdk/src/share/classes/javax/sql/rowset/RowSetMetaDataImpl.java +++ b/jdk/src/share/classes/javax/sql/rowset/RowSetMetaDataImpl.java @@ -48,6 +48,8 @@ import java.lang.reflect.*; * Therefore, any RowSetMetaDataImpl method that retrieves information * is defined as having unspecified behavior when it is called * before the RowSet object contains data. + * + * @since 1.5 */ public class RowSetMetaDataImpl implements RowSetMetaData, Serializable { diff --git a/jdk/src/share/classes/javax/sql/rowset/RowSetWarning.java b/jdk/src/share/classes/javax/sql/rowset/RowSetWarning.java index c110834c2cf..ecdc9ad1b3a 100644 --- a/jdk/src/share/classes/javax/sql/rowset/RowSetWarning.java +++ b/jdk/src/share/classes/javax/sql/rowset/RowSetWarning.java @@ -50,6 +50,8 @@ import java.sql.SQLException; * The inherited methods getMessage, getSQLState, * and getErrorCode retrieve information contained in a * RowSetWarning object. + * + * @since 1.5 */ public class RowSetWarning extends SQLException { diff --git a/jdk/src/share/classes/javax/sql/rowset/WebRowSet.java b/jdk/src/share/classes/javax/sql/rowset/WebRowSet.java index 8fc37500491..f588f007955 100644 --- a/jdk/src/share/classes/javax/sql/rowset/WebRowSet.java +++ b/jdk/src/share/classes/javax/sql/rowset/WebRowSet.java @@ -408,6 +408,7 @@ import org.xml.sax.*; * @see javax.sql.rowset.CachedRowSet * @see javax.sql.rowset.FilteredRowSet * @see javax.sql.rowset.JoinRowSet + * @since 1.5 */ public interface WebRowSet extends CachedRowSet { diff --git a/jdk/src/share/classes/javax/sql/rowset/serial/SQLOutputImpl.java b/jdk/src/share/classes/javax/sql/rowset/serial/SQLOutputImpl.java index cf2824cfda9..136fff08d2a 100644 --- a/jdk/src/share/classes/javax/sql/rowset/serial/SQLOutputImpl.java +++ b/jdk/src/share/classes/javax/sql/rowset/serial/SQLOutputImpl.java @@ -52,6 +52,8 @@ import java.util.Vector; * to write data from the SQLData object to * the SQLOutputImpl output stream as the * representation of an SQL user-defined type. + * + * @since 1.5 */ public class SQLOutputImpl implements SQLOutput { diff --git a/jdk/src/share/classes/javax/sql/rowset/serial/SerialArray.java b/jdk/src/share/classes/javax/sql/rowset/serial/SerialArray.java index 1e0e440bcef..5715ea0463f 100644 --- a/jdk/src/share/classes/javax/sql/rowset/serial/SerialArray.java +++ b/jdk/src/share/classes/javax/sql/rowset/serial/SerialArray.java @@ -56,6 +56,7 @@ import java.util.Arrays; * SerialArray is to be used by more than one thread then access to the * SerialArray should be controlled by appropriate synchronization. * + * @since 1.5 */ public class SerialArray implements Array, Serializable, Cloneable { diff --git a/jdk/src/share/classes/javax/sql/rowset/serial/SerialBlob.java b/jdk/src/share/classes/javax/sql/rowset/serial/SerialBlob.java index 4c5a6b867a9..66652d2df85 100644 --- a/jdk/src/share/classes/javax/sql/rowset/serial/SerialBlob.java +++ b/jdk/src/share/classes/javax/sql/rowset/serial/SerialBlob.java @@ -58,6 +58,7 @@ import java.util.Arrays; * should be controlled by appropriate synchronization. * * @author Jonathan Bruce + * @since 1.5 */ public class SerialBlob implements Blob, Serializable, Cloneable { diff --git a/jdk/src/share/classes/javax/sql/rowset/serial/SerialClob.java b/jdk/src/share/classes/javax/sql/rowset/serial/SerialClob.java index a2177b2c153..7f994f5c41e 100644 --- a/jdk/src/share/classes/javax/sql/rowset/serial/SerialClob.java +++ b/jdk/src/share/classes/javax/sql/rowset/serial/SerialClob.java @@ -49,7 +49,9 @@ import java.util.Arrays; *

    A SerialClob is not safe for use by multiple concurrent threads. If a * SerialClob is to be used by more than one thread then access to the SerialClob * should be controlled by appropriate synchronization. + * * @author Jonathan Bruce + * @since 1.5 */ public class SerialClob implements Clob, Serializable, Cloneable { diff --git a/jdk/src/share/classes/javax/sql/rowset/serial/SerialDatalink.java b/jdk/src/share/classes/javax/sql/rowset/serial/SerialDatalink.java index 221502a868c..422fd25cba8 100644 --- a/jdk/src/share/classes/javax/sql/rowset/serial/SerialDatalink.java +++ b/jdk/src/share/classes/javax/sql/rowset/serial/SerialDatalink.java @@ -48,6 +48,8 @@ import java.net.URL; * A SerialDatalink is not safe for use by multiple concurrent threads. If a * SerialDatalink is to be used by more than one thread then access to the * SerialDatalink should be controlled by appropriate synchronization. + * + * @since 1.5 */ public class SerialDatalink implements Serializable, Cloneable { diff --git a/jdk/src/share/classes/javax/sql/rowset/serial/SerialException.java b/jdk/src/share/classes/javax/sql/rowset/serial/SerialException.java index e2d0c11b84c..2429b176bb8 100644 --- a/jdk/src/share/classes/javax/sql/rowset/serial/SerialException.java +++ b/jdk/src/share/classes/javax/sql/rowset/serial/SerialException.java @@ -32,6 +32,7 @@ import java.sql.SQLException; * SQL types such as BLOB, CLOB, STRUCT or ARRAY in * addition to SQL types such as DATALINK and JAVAOBJECT * + * @since 1.5 */ public class SerialException extends java.sql.SQLException { diff --git a/jdk/src/share/classes/javax/sql/rowset/serial/SerialJavaObject.java b/jdk/src/share/classes/javax/sql/rowset/serial/SerialJavaObject.java index 71f8c340cf4..7578c41d963 100644 --- a/jdk/src/share/classes/javax/sql/rowset/serial/SerialJavaObject.java +++ b/jdk/src/share/classes/javax/sql/rowset/serial/SerialJavaObject.java @@ -54,6 +54,7 @@ import sun.reflect.misc.ReflectUtil; * SerialJavaObject should be controlled by appropriate synchronization. * * @author Jonathan Bruce + * @since 1.5 */ public class SerialJavaObject implements Serializable, Cloneable { diff --git a/jdk/src/share/classes/javax/sql/rowset/serial/SerialRef.java b/jdk/src/share/classes/javax/sql/rowset/serial/SerialRef.java index 834fafe32b6..91d3dcd57a2 100644 --- a/jdk/src/share/classes/javax/sql/rowset/serial/SerialRef.java +++ b/jdk/src/share/classes/javax/sql/rowset/serial/SerialRef.java @@ -43,6 +43,7 @@ import java.util.*; * SerialRef is to be used by more than one thread then access to the SerialRef * should be controlled by appropriate synchronization. * + * @since 1.5 */ public class SerialRef implements Ref, Serializable, Cloneable { diff --git a/jdk/src/share/classes/javax/sql/rowset/serial/SerialStruct.java b/jdk/src/share/classes/javax/sql/rowset/serial/SerialStruct.java index 6eef84f3ef9..8937e3c48fc 100644 --- a/jdk/src/share/classes/javax/sql/rowset/serial/SerialStruct.java +++ b/jdk/src/share/classes/javax/sql/rowset/serial/SerialStruct.java @@ -57,6 +57,7 @@ import javax.sql.rowset.*; * SerialStruct is to be used by more than one thread then access to the * SerialStruct should be controlled by appropriate synchronization. * + * @since 1.5 */ public class SerialStruct implements Struct, Serializable, Cloneable { diff --git a/jdk/src/share/classes/javax/sql/rowset/spi/SyncFactory.java b/jdk/src/share/classes/javax/sql/rowset/spi/SyncFactory.java index a4b757941da..586e19fb8c3 100644 --- a/jdk/src/share/classes/javax/sql/rowset/spi/SyncFactory.java +++ b/jdk/src/share/classes/javax/sql/rowset/spi/SyncFactory.java @@ -200,6 +200,7 @@ import sun.reflect.misc.ReflectUtil; * @author Jonathan Bruce * @see javax.sql.rowset.spi.SyncProvider * @see javax.sql.rowset.spi.SyncFactoryException + * @since 1.5 */ public class SyncFactory { diff --git a/jdk/src/share/classes/javax/sql/rowset/spi/SyncFactoryException.java b/jdk/src/share/classes/javax/sql/rowset/spi/SyncFactoryException.java index c904c9eb5fc..31daba55880 100644 --- a/jdk/src/share/classes/javax/sql/rowset/spi/SyncFactoryException.java +++ b/jdk/src/share/classes/javax/sql/rowset/spi/SyncFactoryException.java @@ -35,6 +35,7 @@ import java.sql.SQLException; * @author Jonathan Bruce * @see javax.sql.rowset.spi.SyncFactory * @see javax.sql.rowset.spi.SyncFactoryException + * @since 1.5 */ public class SyncFactoryException extends java.sql.SQLException { diff --git a/jdk/src/share/classes/javax/sql/rowset/spi/SyncProvider.java b/jdk/src/share/classes/javax/sql/rowset/spi/SyncProvider.java index 6f1cc1620cb..14c605634bf 100644 --- a/jdk/src/share/classes/javax/sql/rowset/spi/SyncProvider.java +++ b/jdk/src/share/classes/javax/sql/rowset/spi/SyncProvider.java @@ -209,6 +209,7 @@ import javax.sql.*; * @author Jonathan Bruce * @see javax.sql.rowset.spi.SyncFactory * @see javax.sql.rowset.spi.SyncFactoryException + * @since 1.5 */ public abstract class SyncProvider { diff --git a/jdk/src/share/classes/javax/sql/rowset/spi/SyncProviderException.java b/jdk/src/share/classes/javax/sql/rowset/spi/SyncProviderException.java index 57f9930a678..795667ab8b7 100644 --- a/jdk/src/share/classes/javax/sql/rowset/spi/SyncProviderException.java +++ b/jdk/src/share/classes/javax/sql/rowset/spi/SyncProviderException.java @@ -61,6 +61,7 @@ import javax.sql.rowset.*; * @see javax.sql.rowset.spi.SyncFactory * @see javax.sql.rowset.spi.SyncResolver * @see javax.sql.rowset.spi.SyncFactoryException + * @since 1.5 */ public class SyncProviderException extends java.sql.SQLException { diff --git a/jdk/src/share/classes/javax/sql/rowset/spi/SyncResolver.java b/jdk/src/share/classes/javax/sql/rowset/spi/SyncResolver.java index 45fdfe02a53..4fee7df2f69 100644 --- a/jdk/src/share/classes/javax/sql/rowset/spi/SyncResolver.java +++ b/jdk/src/share/classes/javax/sql/rowset/spi/SyncResolver.java @@ -231,7 +231,9 @@ import java.sql.SQLException; * } * } * } + * * @author Jonathan Bruce + * @since 1.5 */ public interface SyncResolver extends RowSet { diff --git a/jdk/src/share/classes/javax/sql/rowset/spi/TransactionalWriter.java b/jdk/src/share/classes/javax/sql/rowset/spi/TransactionalWriter.java index fce96e85821..ae69b1e4ca6 100644 --- a/jdk/src/share/classes/javax/sql/rowset/spi/TransactionalWriter.java +++ b/jdk/src/share/classes/javax/sql/rowset/spi/TransactionalWriter.java @@ -44,6 +44,8 @@ import java.sql.Savepoint; * the CachedRowSet constant COMMIT_ON_ACCEPT_CHANGES * to false and use the commit and rollback * methods defined in this interface to manage transaction boundaries. + * + * @since 1.5 */ public interface TransactionalWriter extends RowSetWriter { diff --git a/jdk/src/share/classes/javax/sql/rowset/spi/XmlReader.java b/jdk/src/share/classes/javax/sql/rowset/spi/XmlReader.java index 9aad9cc3ac3..ba0ee8c9dce 100644 --- a/jdk/src/share/classes/javax/sql/rowset/spi/XmlReader.java +++ b/jdk/src/share/classes/javax/sql/rowset/spi/XmlReader.java @@ -46,6 +46,8 @@ import javax.sql.rowset.*; * rowset's xmlReader field. When the WebRowSet * object's readXml method is invoked, it in turn invokes * its XML reader's readXML method. + * + * @since 1.5 */ public interface XmlReader extends RowSetReader { diff --git a/jdk/src/share/classes/javax/sql/rowset/spi/XmlWriter.java b/jdk/src/share/classes/javax/sql/rowset/spi/XmlWriter.java index 80ab78f6b77..79811d86d83 100644 --- a/jdk/src/share/classes/javax/sql/rowset/spi/XmlWriter.java +++ b/jdk/src/share/classes/javax/sql/rowset/spi/XmlWriter.java @@ -44,6 +44,8 @@ import javax.sql.rowset.*; * Writing a WebRowSet object includes printing the * rowset's data, metadata, and properties, all with the * appropriate XML tags. + * + * @since 1.5 */ public interface XmlWriter extends RowSetWriter { diff --git a/jdk/src/share/classes/javax/swing/AbstractAction.java b/jdk/src/share/classes/javax/swing/AbstractAction.java index f8f15f4f992..1f0ef990243 100644 --- a/jdk/src/share/classes/javax/swing/AbstractAction.java +++ b/jdk/src/share/classes/javax/swing/AbstractAction.java @@ -55,6 +55,7 @@ import sun.security.action.GetPropertyAction; * * @author Georges Saab * @see Action + * @since 1.2 */ @SuppressWarnings("serial") // Same-version serialization only public abstract class AbstractAction implements Action, Cloneable, Serializable diff --git a/jdk/src/share/classes/javax/swing/AbstractButton.java b/jdk/src/share/classes/javax/swing/AbstractButton.java index f7eec138451..58f9e943c9f 100644 --- a/jdk/src/share/classes/javax/swing/AbstractButton.java +++ b/jdk/src/share/classes/javax/swing/AbstractButton.java @@ -71,6 +71,7 @@ import java.util.*; * Please see {@link java.beans.XMLEncoder}. * * @author Jeff Dinkins + * @since 1.2 */ @SuppressWarnings("serial") // Same-version serialization only public abstract class AbstractButton extends JComponent implements ItemSelectable, SwingConstants { @@ -947,6 +948,7 @@ public abstract class AbstractButton extends JComponent implements ItemSelectabl *

    * This is a JavaBeans bound property. * + * @param iconTextGap the space between icon and text if these properties are set. * @since 1.4 * @see #getIconTextGap * @beaninfo @@ -1337,6 +1339,7 @@ public abstract class AbstractButton extends JComponent implements ItemSelectabl * that of the Action. * * @param a the button's action + * @return the {@code PropertyChangeListener} * @since 1.3 * @see Action * @see #setAction @@ -2070,12 +2073,20 @@ public abstract class AbstractButton extends JComponent implements ItemSelectabl } } - + /** + * Returns {@code ActionListener} that is added to model. + * + * @return the {@code ActionListener} + */ protected ActionListener createActionListener() { return getHandler(); } - + /** + * Returns {@code ItemListener} that is added to model. + * + * @return the {@code ItemListener} + */ protected ItemListener createItemListener() { return getHandler(); } @@ -2148,7 +2159,7 @@ public abstract class AbstractButton extends JComponent implements ItemSelectabl return listenerList.getListeners(ItemListener.class); } - /** + /** * Returns an array (length 1) containing the label or * null if the button is not selected. * @@ -2164,6 +2175,12 @@ public abstract class AbstractButton extends JComponent implements ItemSelectabl return selectedObjects; } + /** + * Initialization of the {@code AbstractButton}. + * + * @param text the text of the button + * @param icon the Icon image to display on the button + */ protected void init(String text, Icon icon) { if(text != null) { setText(text); diff --git a/jdk/src/share/classes/javax/swing/AbstractListModel.java b/jdk/src/share/classes/javax/swing/AbstractListModel.java index 33145a51e8e..e4956670ee0 100644 --- a/jdk/src/share/classes/javax/swing/AbstractListModel.java +++ b/jdk/src/share/classes/javax/swing/AbstractListModel.java @@ -45,6 +45,7 @@ import java.util.EventListener; * @param the type of the elements of this model * * @author Hans Muller + * @since 1.2 */ @SuppressWarnings("serial") // Same-version serialization only public abstract class AbstractListModel implements ListModel, Serializable @@ -201,6 +202,7 @@ public abstract class AbstractListModel implements ListModel, Serializable * If no such listeners exist, * this method returns an empty array. * + * @param the type of {@code EventListener} class being requested * @param listenerType the type of listeners requested; * this parameter should specify an interface * that descends from java.util.EventListener diff --git a/jdk/src/share/classes/javax/swing/AbstractSpinnerModel.java b/jdk/src/share/classes/javax/swing/AbstractSpinnerModel.java index f46593c4946..a5e5d4a0339 100644 --- a/jdk/src/share/classes/javax/swing/AbstractSpinnerModel.java +++ b/jdk/src/share/classes/javax/swing/AbstractSpinnerModel.java @@ -131,6 +131,7 @@ public abstract class AbstractSpinnerModel implements SpinnerModel, Serializable * myAbstractSpinnerModel.getListeners(ChangeListener.class); * * + * @param the type of requested listeners * @param listenerType the type of listeners to return, e.g. ChangeListener.class * @return all of the objects receiving listenerType notifications * from this model diff --git a/jdk/src/share/classes/javax/swing/Action.java b/jdk/src/share/classes/javax/swing/Action.java index 7fc81b45539..b1ebbec40a8 100644 --- a/jdk/src/share/classes/javax/swing/Action.java +++ b/jdk/src/share/classes/javax/swing/Action.java @@ -210,6 +210,7 @@ import java.beans.*; * * @author Georges Saab * @see AbstractAction + * @since 1.2 */ public interface Action extends ActionListener { /** @@ -337,6 +338,9 @@ public interface Action extends ActionListener { /** * Gets one of this object's properties * using the associated key. + * + * @param key a {@code String} containing the key + * @return the {@code Object} value * @see #putValue */ public Object getValue(String key); diff --git a/jdk/src/share/classes/javax/swing/ActionMap.java b/jdk/src/share/classes/javax/swing/ActionMap.java index 6e9ce60ad9e..acec0fb7bb9 100644 --- a/jdk/src/share/classes/javax/swing/ActionMap.java +++ b/jdk/src/share/classes/javax/swing/ActionMap.java @@ -94,6 +94,9 @@ public class ActionMap implements Serializable { * for key. *

    In most instances, key will be * action.getValue(NAME). + * + * @param key a key + * @param action a binding for {@code key} */ public void put(Object key, Action action) { if (key == null) { @@ -113,6 +116,9 @@ public class ActionMap implements Serializable { /** * Returns the binding for key, messaging the * parent ActionMap if the binding is not locally defined. + * + * @param key a key + * @return the binding for {@code key} */ public Action get(Object key) { Action value = (arrayTable == null) ? null : @@ -130,6 +136,8 @@ public class ActionMap implements Serializable { /** * Removes the binding for key from this ActionMap. + * + * @param key a key */ public void remove(Object key) { if (arrayTable != null) { @@ -148,6 +156,8 @@ public class ActionMap implements Serializable { /** * Returns the Action names that are bound in this ActionMap. + * + * @return an array of the keys */ public Object[] keys() { if (arrayTable == null) { @@ -172,6 +182,8 @@ public class ActionMap implements Serializable { * Returns an array of the keys defined in this ActionMap and * its parent. This method differs from keys() in that * this method includes the keys defined in the parent. + * + * @return an array of the keys */ public Object[] allKeys() { int count = size(); diff --git a/jdk/src/share/classes/javax/swing/BorderFactory.java b/jdk/src/share/classes/javax/swing/BorderFactory.java index f821e76f8cc..9f2393cb91d 100644 --- a/jdk/src/share/classes/javax/swing/BorderFactory.java +++ b/jdk/src/share/classes/javax/swing/BorderFactory.java @@ -40,6 +40,7 @@ import javax.swing.border.*; * a section in The Java Tutorial. * * @author David Kloba + * @since 1.2 */ public class BorderFactory { diff --git a/jdk/src/share/classes/javax/swing/BoundedRangeModel.java b/jdk/src/share/classes/javax/swing/BoundedRangeModel.java index ea0a41119e2..bc6a84ac891 100644 --- a/jdk/src/share/classes/javax/swing/BoundedRangeModel.java +++ b/jdk/src/share/classes/javax/swing/BoundedRangeModel.java @@ -76,6 +76,7 @@ import javax.swing.event.*; * * @author Hans Muller * @see DefaultBoundedRangeModel + * @since 1.2 */ public interface BoundedRangeModel { diff --git a/jdk/src/share/classes/javax/swing/Box.java b/jdk/src/share/classes/javax/swing/Box.java index 9bf5474c746..d332214a3c5 100644 --- a/jdk/src/share/classes/javax/swing/Box.java +++ b/jdk/src/share/classes/javax/swing/Box.java @@ -75,6 +75,7 @@ import javax.accessibility.*; * @see BoxLayout * * @author Timothy Prinzing + * @since 1.2 */ @SuppressWarnings("serial") public class Box extends JComponent implements Accessible { diff --git a/jdk/src/share/classes/javax/swing/BoxLayout.java b/jdk/src/share/classes/javax/swing/BoxLayout.java index 8723a15f048..c3565fb1741 100644 --- a/jdk/src/share/classes/javax/swing/BoxLayout.java +++ b/jdk/src/share/classes/javax/swing/BoxLayout.java @@ -134,6 +134,7 @@ import java.io.PrintStream; * @see JComponent#getAlignmentY * * @author Timothy Prinzing + * @since 1.2 */ @SuppressWarnings("serial") public class BoxLayout implements LayoutManager2, Serializable { diff --git a/jdk/src/share/classes/javax/swing/ButtonGroup.java b/jdk/src/share/classes/javax/swing/ButtonGroup.java index 27b11ea3fc7..21c13a49cbb 100644 --- a/jdk/src/share/classes/javax/swing/ButtonGroup.java +++ b/jdk/src/share/classes/javax/swing/ButtonGroup.java @@ -64,6 +64,7 @@ import java.io.Serializable; * Please see {@link java.beans.XMLEncoder}. * * @author Jeff Dinkins + * @since 1.2 */ @SuppressWarnings("serial") public class ButtonGroup implements Serializable { @@ -167,9 +168,11 @@ public class ButtonGroup implements Serializable { } /** - * Returns whether a ButtonModel is selected. - * @return true if the button is selected, - * otherwise returns false + * Returns whether a {@code ButtonModel} is selected. + * + * @param m an isntance of {@code ButtonModel} + * @return {@code true} if the button is selected, + * otherwise returns {@code false} */ public boolean isSelected(ButtonModel m) { return (m == selection); diff --git a/jdk/src/share/classes/javax/swing/ButtonModel.java b/jdk/src/share/classes/javax/swing/ButtonModel.java index 1668c673b56..85ba48f6ba2 100644 --- a/jdk/src/share/classes/javax/swing/ButtonModel.java +++ b/jdk/src/share/classes/javax/swing/ButtonModel.java @@ -72,6 +72,7 @@ import javax.swing.event.*; * ActionEvent to be fired. * * @author Jeff Dinkins + * @since 1.2 */ public interface ButtonModel extends ItemSelectable { diff --git a/jdk/src/share/classes/javax/swing/CellEditor.java b/jdk/src/share/classes/javax/swing/CellEditor.java index 3211a788cb9..f1b625b7969 100644 --- a/jdk/src/share/classes/javax/swing/CellEditor.java +++ b/jdk/src/share/classes/javax/swing/CellEditor.java @@ -57,6 +57,7 @@ import javax.swing.event.*; * @see javax.swing.event.CellEditorListener * * @author Alan Chung + * @since 1.2 */ public interface CellEditor { diff --git a/jdk/src/share/classes/javax/swing/CellRendererPane.java b/jdk/src/share/classes/javax/swing/CellRendererPane.java index 33539284e2d..6050693eeeb 100644 --- a/jdk/src/share/classes/javax/swing/CellRendererPane.java +++ b/jdk/src/share/classes/javax/swing/CellRendererPane.java @@ -62,6 +62,7 @@ import javax.accessibility.*; * Please see {@link java.beans.XMLEncoder}. * * @author Hans Muller + * @since 1.2 */ @SuppressWarnings("serial") // Same-version serialization only public class CellRendererPane extends Container implements Accessible @@ -189,8 +190,12 @@ public class CellRendererPane extends Container implements Accessible // Accessibility support //////////////// + /** + * {@code AccessibleContext} associated with this {@code CellRendererPan} + */ protected AccessibleContext accessibleContext = null; + /** * Gets the AccessibleContext associated with this CellRendererPane. * For CellRendererPanes, the AccessibleContext takes the form of an diff --git a/jdk/src/share/classes/javax/swing/ComboBoxEditor.java b/jdk/src/share/classes/javax/swing/ComboBoxEditor.java index b043e6e310d..f7dd950471c 100644 --- a/jdk/src/share/classes/javax/swing/ComboBoxEditor.java +++ b/jdk/src/share/classes/javax/swing/ComboBoxEditor.java @@ -31,26 +31,48 @@ import java.awt.event.*; * The editor component used for JComboBox components. * * @author Arnaud Weber + * @since 1.2 */ public interface ComboBoxEditor { - /** Return the component that should be added to the tree hierarchy for - * this editor - */ + /** + * Returns the component that should be added to the tree hierarchy for + * this editor + * + * @return the component + */ public Component getEditorComponent(); - /** Set the item that should be edited. Cancel any editing if necessary **/ + /** + * Set the item that should be edited. Cancel any editing if necessary + * + * @param anObject an item + */ public void setItem(Object anObject); - /** Return the edited item **/ + /** + * Returns the edited item + * + * @return the edited item + */ public Object getItem(); - /** Ask the editor to start editing and to select everything **/ + /** + * Ask the editor to start editing and to select everything + */ public void selectAll(); - /** Add an ActionListener. An action event is generated when the edited item changes **/ + /** + * Add an ActionListener. An action event is generated when the edited item changes + * + * @param l an {@code ActionListener} + */ public void addActionListener(ActionListener l); - /** Remove an ActionListener **/ + /** + * Remove an ActionListener + * + * @param l an {@code ActionListener} + */ public void removeActionListener(ActionListener l); } diff --git a/jdk/src/share/classes/javax/swing/ComboBoxModel.java b/jdk/src/share/classes/javax/swing/ComboBoxModel.java index e7c3be9811b..50bd87d66f0 100644 --- a/jdk/src/share/classes/javax/swing/ComboBoxModel.java +++ b/jdk/src/share/classes/javax/swing/ComboBoxModel.java @@ -36,6 +36,7 @@ package javax.swing; * @param the type of the elements of this model * * @author Arnaud Weber + * @since 1.2 */ public interface ComboBoxModel extends ListModel { diff --git a/jdk/src/share/classes/javax/swing/ComponentInputMap.java b/jdk/src/share/classes/javax/swing/ComponentInputMap.java index da074d5c054..aa597565092 100644 --- a/jdk/src/share/classes/javax/swing/ComponentInputMap.java +++ b/jdk/src/share/classes/javax/swing/ComponentInputMap.java @@ -78,7 +78,9 @@ public class ComponentInputMap extends InputMap { } /** - * Returns the component the InputMap was created for. + * Returns the component the {@code InputMap} was created for. + * + * @return the component the {@code InputMap} was created for. */ public JComponent getComponent() { return component; diff --git a/jdk/src/share/classes/javax/swing/DebugGraphics.java b/jdk/src/share/classes/javax/swing/DebugGraphics.java index a41e9c62f55..53219b74c33 100644 --- a/jdk/src/share/classes/javax/swing/DebugGraphics.java +++ b/jdk/src/share/classes/javax/swing/DebugGraphics.java @@ -45,6 +45,7 @@ import java.text.AttributedCharacterIterator; * @see RepaintManager#setDoubleBufferingEnabled * * @author Dave Karlton + * @since 1.2 */ public class DebugGraphics extends Graphics { Graphics graphics; diff --git a/jdk/src/share/classes/javax/swing/DefaultBoundedRangeModel.java b/jdk/src/share/classes/javax/swing/DefaultBoundedRangeModel.java index 8d316ce28ac..b7b989e07fa 100644 --- a/jdk/src/share/classes/javax/swing/DefaultBoundedRangeModel.java +++ b/jdk/src/share/classes/javax/swing/DefaultBoundedRangeModel.java @@ -44,6 +44,7 @@ import java.util.EventListener; * @author David Kloba * @author Hans Muller * @see BoundedRangeModel + * @since 1.2 */ @SuppressWarnings("serial") // Same-version serialization only public class DefaultBoundedRangeModel implements BoundedRangeModel, Serializable diff --git a/jdk/src/share/classes/javax/swing/DefaultButtonModel.java b/jdk/src/share/classes/javax/swing/DefaultButtonModel.java index 2b0f150e42c..fe2ddd143cd 100644 --- a/jdk/src/share/classes/javax/swing/DefaultButtonModel.java +++ b/jdk/src/share/classes/javax/swing/DefaultButtonModel.java @@ -44,6 +44,7 @@ import javax.swing.event.*; * Please see {@link java.beans.XMLEncoder}. * * @author Jeff Dinkins + * @since 1.2 */ @SuppressWarnings("serial") // Same-version serialization only public class DefaultButtonModel implements ButtonModel, Serializable { @@ -477,6 +478,7 @@ public class DefaultButtonModel implements ButtonModel, Serializable { * If no such listeners exist, * this method returns an empty array. * + * @param the type of requested listeners * @param listenerType the type of listeners requested; * this parameter should specify an interface * that descends from java.util.EventListener diff --git a/jdk/src/share/classes/javax/swing/DefaultCellEditor.java b/jdk/src/share/classes/javax/swing/DefaultCellEditor.java index 1eea9e1fb3f..dfb9056e62c 100644 --- a/jdk/src/share/classes/javax/swing/DefaultCellEditor.java +++ b/jdk/src/share/classes/javax/swing/DefaultCellEditor.java @@ -49,6 +49,7 @@ import java.io.Serializable; * * @author Alan Chung * @author Philip Milne + * @since 1.2 */ @SuppressWarnings("serial") // Same-version serialization only public class DefaultCellEditor extends AbstractCellEditor @@ -352,6 +353,7 @@ public class DefaultCellEditor extends AbstractCellEditor * Returns true to indicate that editing has begun. * * @param anEvent the event + * @return true to indicate editing has begun */ public boolean startCellEditing(EventObject anEvent) { return true; diff --git a/jdk/src/share/classes/javax/swing/DefaultComboBoxModel.java b/jdk/src/share/classes/javax/swing/DefaultComboBoxModel.java index b42dc109b50..813ebd39ef1 100644 --- a/jdk/src/share/classes/javax/swing/DefaultComboBoxModel.java +++ b/jdk/src/share/classes/javax/swing/DefaultComboBoxModel.java @@ -35,6 +35,7 @@ import java.io.Serializable; * * @author Arnaud Weber * @author Tom Santos + * @since 1.2 */ @SuppressWarnings("serial") // Superclass is not serializable across versions public class DefaultComboBoxModel extends AbstractListModel implements MutableComboBoxModel, Serializable { diff --git a/jdk/src/share/classes/javax/swing/DefaultDesktopManager.java b/jdk/src/share/classes/javax/swing/DefaultDesktopManager.java index d140e98c5d7..ebee71521d9 100644 --- a/jdk/src/share/classes/javax/swing/DefaultDesktopManager.java +++ b/jdk/src/share/classes/javax/swing/DefaultDesktopManager.java @@ -46,6 +46,7 @@ import java.beans.PropertyVetoException; * @see JInternalFrame * @author David Kloba * @author Steve Wilson + * @since 1.2 */ @SuppressWarnings("serial") // No Interesting Non-Transient State public class DefaultDesktopManager implements DesktopManager, java.io.Serializable { @@ -461,7 +462,12 @@ public class DefaultDesktopManager implements DesktopManager, java.io.Serializab f.revalidate(); } - /** Convenience method to remove the desktopIcon of f is necessary. */ + /** + * Convenience method to remove the desktopIcon of f is necessary. + * + * @param f the {@code JInternalFrame} for which to remove the + * {@code desktopIcon} + */ protected void removeIconFor(JInternalFrame f) { JInternalFrame.JDesktopIcon di = f.getDesktopIcon(); Container c = di.getParent(); @@ -471,10 +477,13 @@ public class DefaultDesktopManager implements DesktopManager, java.io.Serializab } } - /** The iconifyFrame() code calls this to determine the proper bounds - * for the desktopIcon. - */ - + /** + * The {@code iconifyFrame()} code calls this to determine the proper bounds + * for the desktopIcon. + * + * @param f the {@code JInternalFrame} of interest + * @return a {@code Rectangle} containing bounds for the {@code desktopIcon} + */ protected Rectangle getBoundsForIconOf(JInternalFrame f) { // // Get the icon for this internal frame and its preferred size @@ -591,6 +600,9 @@ public class DefaultDesktopManager implements DesktopManager, java.io.Serializab /** * Sets that the component has been iconized and the bounds of the * desktopIcon are valid. + * + * @param f the {@code JInternalFrame} of interest + * @param value a {@code Boolean} signifying if component has been iconized */ protected void setWasIcon(JInternalFrame f, Boolean value) { if (value != null) { diff --git a/jdk/src/share/classes/javax/swing/DefaultFocusManager.java b/jdk/src/share/classes/javax/swing/DefaultFocusManager.java index 31240737791..502fc6c7f42 100644 --- a/jdk/src/share/classes/javax/swing/DefaultFocusManager.java +++ b/jdk/src/share/classes/javax/swing/DefaultFocusManager.java @@ -45,6 +45,7 @@ import java.util.Comparator; * * @author Arnaud Weber * @author David Mendenhall + * @since 1.2 */ @SuppressWarnings("serial") // Obsolete class public class DefaultFocusManager extends FocusManager { diff --git a/jdk/src/share/classes/javax/swing/DefaultListCellRenderer.java b/jdk/src/share/classes/javax/swing/DefaultListCellRenderer.java index e4968364cc0..3cc567480c1 100644 --- a/jdk/src/share/classes/javax/swing/DefaultListCellRenderer.java +++ b/jdk/src/share/classes/javax/swing/DefaultListCellRenderer.java @@ -69,6 +69,7 @@ import sun.swing.DefaultLookup; * * @author Philip Milne * @author Hans Muller + * @since 1.2 */ @SuppressWarnings("serial") // Same-version serialization only public class DefaultListCellRenderer extends JLabel diff --git a/jdk/src/share/classes/javax/swing/DefaultListModel.java b/jdk/src/share/classes/javax/swing/DefaultListModel.java index 063c18e2716..a4a826a0f5c 100644 --- a/jdk/src/share/classes/javax/swing/DefaultListModel.java +++ b/jdk/src/share/classes/javax/swing/DefaultListModel.java @@ -51,6 +51,7 @@ import javax.swing.event.*; * @param the type of the elements of this model * * @author Hans Muller + * @since 1.2 */ @SuppressWarnings("serial") // Same-version serialization only public class DefaultListModel extends AbstractListModel @@ -443,6 +444,7 @@ public class DefaultListModel extends AbstractListModel * (index < 0 || index >= size()). * * @param index index of element to return + * @return the element at the specified position in this list */ public E get(int index) { return delegate.elementAt(index); diff --git a/jdk/src/share/classes/javax/swing/DefaultListSelectionModel.java b/jdk/src/share/classes/javax/swing/DefaultListSelectionModel.java index f7b00bee086..671b1a412f0 100644 --- a/jdk/src/share/classes/javax/swing/DefaultListSelectionModel.java +++ b/jdk/src/share/classes/javax/swing/DefaultListSelectionModel.java @@ -48,6 +48,7 @@ import javax.swing.event.*; * @author Philip Milne * @author Hans Muller * @see ListSelectionModel + * @since 1.2 */ @SuppressWarnings("serial") // Same-version serialization only public class DefaultListSelectionModel implements ListSelectionModel, Cloneable, Serializable @@ -159,6 +160,9 @@ public class DefaultListSelectionModel implements ListSelectionModel, Cloneable, * Notifies ListSelectionListeners that the value * of the selection, in the closed interval firstIndex, * lastIndex, has changed. + * + * @param firstIndex the first index in the interval + * @param lastIndex the last index in the interval */ protected void fireValueChanged(int firstIndex, int lastIndex) { fireValueChanged(firstIndex, lastIndex, getValueIsAdjusting()); @@ -230,6 +234,7 @@ public class DefaultListSelectionModel implements ListSelectionModel, Cloneable, * If no such listeners exist, * this method returns an empty array. * + * @param the type of {@code EventListener} class being requested * @param listenerType the type of listeners requested; * this parameter should specify an interface * that descends from java.util.EventListener @@ -331,6 +336,8 @@ public class DefaultListSelectionModel implements ListSelectionModel, Cloneable, /** * Sets the value of the leadAnchorNotificationEnabled flag. + * + * @param flag boolean value for {@code leadAnchorNotificationEnabled} * @see #isLeadAnchorNotificationEnabled() */ public void setLeadAnchorNotificationEnabled(boolean flag) { diff --git a/jdk/src/share/classes/javax/swing/DefaultRowSorter.java b/jdk/src/share/classes/javax/swing/DefaultRowSorter.java index 5b9e94537fe..68264dc89f0 100644 --- a/jdk/src/share/classes/javax/swing/DefaultRowSorter.java +++ b/jdk/src/share/classes/javax/swing/DefaultRowSorter.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 @@ -712,6 +712,8 @@ public abstract class DefaultRowSorter extends RowSorter { * * @param column the index of the column to test, in terms of the * underlying model + * @return true if values are to be converted to strings before doing + * comparisons when sorting * @throws IndexOutOfBoundsException if column is not valid */ protected boolean useToString(int column) { diff --git a/jdk/src/share/classes/javax/swing/DefaultSingleSelectionModel.java b/jdk/src/share/classes/javax/swing/DefaultSingleSelectionModel.java index d5e5ab81e1d..75c522e79c9 100644 --- a/jdk/src/share/classes/javax/swing/DefaultSingleSelectionModel.java +++ b/jdk/src/share/classes/javax/swing/DefaultSingleSelectionModel.java @@ -42,6 +42,7 @@ import java.util.EventListener; * Please see {@link java.beans.XMLEncoder}. * * @author Dave Moore + * @since 1.2 */ @SuppressWarnings("serial") // Same-version serialization only public class DefaultSingleSelectionModel implements SingleSelectionModel, diff --git a/jdk/src/share/classes/javax/swing/DesktopManager.java b/jdk/src/share/classes/javax/swing/DesktopManager.java index 07e40a07b21..edcfaf4fabb 100644 --- a/jdk/src/share/classes/javax/swing/DesktopManager.java +++ b/jdk/src/share/classes/javax/swing/DesktopManager.java @@ -43,6 +43,7 @@ package javax.swing; * @see JInternalFrame.JDesktopIcon * * @author David Kloba + * @since 1.2 */ public interface DesktopManager { diff --git a/jdk/src/share/classes/javax/swing/FocusManager.java b/jdk/src/share/classes/javax/swing/FocusManager.java index 1e3a98b3622..45fc6b6e5b9 100644 --- a/jdk/src/share/classes/javax/swing/FocusManager.java +++ b/jdk/src/share/classes/javax/swing/FocusManager.java @@ -44,6 +44,7 @@ import java.awt.*; * * @author Arnaud Weber * @author David Mendenhall + * @since 1.2 */ public abstract class FocusManager extends DefaultKeyboardFocusManager { @@ -140,6 +141,7 @@ public abstract class FocusManager extends DefaultKeyboardFocusManager { * Returns whether the application has invoked * disableSwingFocusManager(). * + * @return {@code true} if focus manager is enabled. * @see #disableSwingFocusManager * @deprecated As of 1.4, replaced by * KeyboardFocusManager.getDefaultFocusTraversalPolicy() diff --git a/jdk/src/share/classes/javax/swing/GrayFilter.java b/jdk/src/share/classes/javax/swing/GrayFilter.java index d53f5d39c76..573edbedb63 100644 --- a/jdk/src/share/classes/javax/swing/GrayFilter.java +++ b/jdk/src/share/classes/javax/swing/GrayFilter.java @@ -36,6 +36,7 @@ import java.awt.image.*; * @author Jeff Dinkins * @author Tom Ball * @author Jim Graham + * @since 1.2 */ public class GrayFilter extends RGBImageFilter { private boolean brighter; diff --git a/jdk/src/share/classes/javax/swing/GroupLayout.java b/jdk/src/share/classes/javax/swing/GroupLayout.java index c6d0fc1fa54..45b25845674 100644 --- a/jdk/src/share/classes/javax/swing/GroupLayout.java +++ b/jdk/src/share/classes/javax/swing/GroupLayout.java @@ -670,6 +670,7 @@ public class GroupLayout implements LayoutManager2 { * @param resizable whether the group is resizable * @param anchorBaselineToTop whether the baseline is anchored to * the top or bottom of the group + * @return the {@code ParallelGroup} * @see #createBaselineGroup * @see ParallelGroup */ diff --git a/jdk/src/share/classes/javax/swing/Icon.java b/jdk/src/share/classes/javax/swing/Icon.java index f4e68840ab9..87c53684711 100644 --- a/jdk/src/share/classes/javax/swing/Icon.java +++ b/jdk/src/share/classes/javax/swing/Icon.java @@ -32,6 +32,7 @@ import java.awt.Component; * A small fixed size picture, typically used to decorate components. * * @see ImageIcon + * @since 1.2 */ public interface Icon diff --git a/jdk/src/share/classes/javax/swing/ImageIcon.java b/jdk/src/share/classes/javax/swing/ImageIcon.java index e286e936f11..8f7812e5919 100644 --- a/jdk/src/share/classes/javax/swing/ImageIcon.java +++ b/jdk/src/share/classes/javax/swing/ImageIcon.java @@ -65,6 +65,7 @@ import java.security.*; * * @author Jeff Dinkins * @author Lynn Monsanto + * @since 1.2 */ @SuppressWarnings("serial") // Same-version serialization only public class ImageIcon implements Icon, Serializable, Accessible { diff --git a/jdk/src/share/classes/javax/swing/InputMap.java b/jdk/src/share/classes/javax/swing/InputMap.java index 55af730c99a..87302b0b6e2 100644 --- a/jdk/src/share/classes/javax/swing/InputMap.java +++ b/jdk/src/share/classes/javax/swing/InputMap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2011, 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 @@ -32,15 +32,12 @@ import java.util.HashMap; import java.util.Set; /** - * InputMap provides a binding between an input event - * (currently only KeyStrokes are used) - * and an Object. InputMaps - * are usually used with an ActionMap, - * to determine an Action to perform - * when a key is pressed. - * An InputMap can have a parent - * that is searched for bindings not defined in the InputMap. - *

    As with ActionMap if you create a cycle, eg: + * {@code InputMap} provides a binding between an input event (currently only + * {@code KeyStroke}s are used) and an {@code Object}. {@code InputMap}s are + * usually used with an {@code ActionMap}, to determine an {@code Action} to + * perform when a key is pressed. An {@code InputMap} can have a parent that + * is searched for bindings not defined in the {@code InputMap}. + *

    As with {@code ActionMap} if you create a cycle, eg: *

      *   InputMap am = new InputMap();
      *   InputMap bm = new InputMap():
    @@ -61,34 +58,37 @@ public class InputMap implements Serializable {
     
     
         /**
    -     * Creates an InputMap with no parent and no mappings.
    +     * Creates an {@code InputMap} with no parent and no mappings.
          */
         public InputMap() {
         }
     
         /**
    -     * Sets this InputMap's parent.
    +     * Sets this {@code InputMap}'s parent.
          *
    -     * @param map  the InputMap that is the parent of this one
    +     * @param map the {@code InputMap} that is the parent of this one
          */
         public void setParent(InputMap map) {
             this.parent = map;
         }
     
         /**
    -     * Gets this InputMap's parent.
    +     * Gets this {@code InputMap}'s parent.
          *
    -     * @return map  the InputMap that is the parent of this one,
    -     *              or null if this InputMap has no parent
    +     * @return map the {@code InputMap} that is the parent of this one,
    +     *             or null if this {@code InputMap} has no parent
          */
         public InputMap getParent() {
             return parent;
         }
     
         /**
    -     * Adds a binding for keyStroke to actionMapKey.
    -     * If actionMapKey is null, this removes the current binding
    -     * for keyStroke.
    +     * Adds a binding for {@code keyStroke} to {@code actionMapKey}.
    +     * If {@code actionMapKey} is null, this removes the current binding
    +     * for {@code keyStroke}.
    +     *
    +     * @param keyStroke a {@code KeyStroke}
    +     * @param actionMapKey an action map key
          */
         public void put(KeyStroke keyStroke, Object actionMapKey) {
             if (keyStroke == null) {
    @@ -106,8 +106,11 @@ public class InputMap implements Serializable {
         }
     
         /**
    -     * Returns the binding for keyStroke, messaging the
    -     * parent InputMap if the binding is not locally defined.
    +     * Returns the binding for {@code keyStroke}, messaging the
    +     * parent {@code InputMap} if the binding is not locally defined.
    +     *
    +     * @param keyStroke the {@code KeyStroke} for which to get the binding
    +     * @return the binding for {@code keyStroke}
          */
         public Object get(KeyStroke keyStroke) {
             if (arrayTable == null) {
    @@ -131,8 +134,9 @@ public class InputMap implements Serializable {
         }
     
         /**
    -     * Removes the binding for key from this
    -     * InputMap.
    +     * Removes the binding for {@code key} from this {@code InputMap}.
    +     *
    +     * @param key the {@code KeyStroke} for which to remove the binding
          */
         public void remove(KeyStroke key) {
             if (arrayTable != null) {
    @@ -141,7 +145,7 @@ public class InputMap implements Serializable {
         }
     
         /**
    -     * Removes all the mappings from this InputMap.
    +     * Removes all the mappings from this {@code InputMap}.
          */
         public void clear() {
             if (arrayTable != null) {
    @@ -150,7 +154,10 @@ public class InputMap implements Serializable {
         }
     
         /**
    -     * Returns the KeyStrokes that are bound in this InputMap.
    +     * Returns the {@code KeyStroke}s that are bound in this {@code InputMap}.
    +     *
    +     * @return an array of the {@code KeyStroke}s that are bound in this
    +     *         {@code InputMap}
          */
         public KeyStroke[] keys() {
             if (arrayTable == null) {
    @@ -162,7 +169,9 @@ public class InputMap implements Serializable {
         }
     
         /**
    -     * Returns the number of KeyStroke bindings.
    +     * Returns the number of {@code KeyStroke} bindings.
    +     *
    +     * @return the number of {@code KeyStroke} bindings
          */
         public int size() {
             if (arrayTable == null) {
    @@ -172,9 +181,12 @@ public class InputMap implements Serializable {
         }
     
         /**
    -     * Returns an array of the KeyStrokes defined in this
    -     * InputMap and its parent. This differs from keys() in that
    -     * this method includes the keys defined in the parent.
    +     * Returns an array of the {@code KeyStroke}s defined in this
    +     * {@code InputMap} and its parent. This differs from {@code keys()}
    +     * in that this method includes the keys defined in the parent.
    +     *
    +     * @return an array of the {@code KeyStroke}s defined in this
    +     *         {@code InputMap} and its parent
          */
         public KeyStroke[] allKeys() {
             int             count = size();
    diff --git a/jdk/src/share/classes/javax/swing/JApplet.java b/jdk/src/share/classes/javax/swing/JApplet.java
    index 539458979d4..651d004660d 100644
    --- a/jdk/src/share/classes/javax/swing/JApplet.java
    +++ b/jdk/src/share/classes/javax/swing/JApplet.java
    @@ -89,6 +89,7 @@ import javax.accessibility.*;
      *    description: Swing's Applet subclass.
      *
      * @author Arnaud Weber
    + * @since 1.2
      */
     @SuppressWarnings("serial") // Same-version serialization only
     public class JApplet extends Applet implements Accessible,
    diff --git a/jdk/src/share/classes/javax/swing/JButton.java b/jdk/src/share/classes/javax/swing/JButton.java
    index 5823cf1bffa..937de3adad6 100644
    --- a/jdk/src/share/classes/javax/swing/JButton.java
    +++ b/jdk/src/share/classes/javax/swing/JButton.java
    @@ -74,6 +74,7 @@ import java.io.IOException;
      * description: An implementation of a \"push\" button.
      *
      * @author Jeff Dinkins
    + * @since 1.2
      */
     @SuppressWarnings("serial")
     public class JButton extends AbstractButton implements Accessible {
    diff --git a/jdk/src/share/classes/javax/swing/JCheckBox.java b/jdk/src/share/classes/javax/swing/JCheckBox.java
    index 53502645c72..400b8efae78 100644
    --- a/jdk/src/share/classes/javax/swing/JCheckBox.java
    +++ b/jdk/src/share/classes/javax/swing/JCheckBox.java
    @@ -74,6 +74,7 @@ import java.io.IOException;
      * description: A component which can be selected or deselected.
      *
      * @author Jeff Dinkins
    + * @since 1.2
      */
     @SuppressWarnings("serial") // Same-version serialization only
     public class JCheckBox extends JToggleButton implements Accessible {
    @@ -131,6 +132,7 @@ public class JCheckBox extends JToggleButton implements Accessible {
          * Creates a check box where properties are taken from the
          * Action supplied.
          *
    +     * @param a the {@code Action} used to specify the new check box
          * @since 1.3
          */
         public JCheckBox(Action a) {
    diff --git a/jdk/src/share/classes/javax/swing/JCheckBoxMenuItem.java b/jdk/src/share/classes/javax/swing/JCheckBoxMenuItem.java
    index 08eb53864c4..4aaa4417caa 100644
    --- a/jdk/src/share/classes/javax/swing/JCheckBoxMenuItem.java
    +++ b/jdk/src/share/classes/javax/swing/JCheckBoxMenuItem.java
    @@ -87,6 +87,7 @@ import javax.accessibility.*;
      *
      * @author Georges Saab
      * @author David Karlton
    + * @since 1.2
      */
     @SuppressWarnings("serial") // Same-version serialization only
     public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants,
    @@ -108,7 +109,7 @@ public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants,
         /**
          * Creates an initially unselected check box menu item with an icon.
          *
    -     * @param icon the icon of the CheckBoxMenuItem.
    +     * @param icon the icon of the {@code JCheckBoxMenuItem}.
          */
         public JCheckBoxMenuItem(Icon icon) {
             this(null, icon, false);
    @@ -117,7 +118,7 @@ public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants,
         /**
          * Creates an initially unselected check box menu item with text.
          *
    -     * @param text the text of the CheckBoxMenuItem
    +     * @param text the text of the {@code JCheckBoxMenuItem}
          */
         public JCheckBoxMenuItem(String text) {
             this(text, null, false);
    @@ -127,6 +128,7 @@ public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants,
          * Creates a menu item whose properties are taken from the
          * Action supplied.
          *
    +     * @param a the action of the {@code JCheckBoxMenuItem}
          * @since 1.3
          */
         public JCheckBoxMenuItem(Action a) {
    @@ -137,8 +139,8 @@ public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants,
         /**
          * Creates an initially unselected check box menu item with the specified text and icon.
          *
    -     * @param text the text of the CheckBoxMenuItem
    -     * @param icon the icon of the CheckBoxMenuItem
    +     * @param text the text of the {@code JCheckBoxMenuItem}
    +     * @param icon the icon of the {@code JCheckBoxMenuItem}
          */
         public JCheckBoxMenuItem(String text, Icon icon) {
             this(text, icon, false);
    diff --git a/jdk/src/share/classes/javax/swing/JColorChooser.java b/jdk/src/share/classes/javax/swing/JColorChooser.java
    index 09cbf6c5d80..a2aa8146c6b 100644
    --- a/jdk/src/share/classes/javax/swing/JColorChooser.java
    +++ b/jdk/src/share/classes/javax/swing/JColorChooser.java
    @@ -82,6 +82,7 @@ import sun.swing.SwingUtilities2;
      * @author James Gosling
      * @author Amy Fowler
      * @author Steve Wilson
    + * @since 1.2
      */
     @SuppressWarnings("serial") // Same-version serialization only
     public class JColorChooser extends JComponent implements Accessible {
    @@ -542,7 +543,7 @@ public class JColorChooser extends JComponent implements Accessible {
          * @return  a string representation of this JColorChooser
          */
         protected String paramString() {
    -        StringBuffer chooserPanelsString = new StringBuffer("");
    +        StringBuilder chooserPanelsString = new StringBuilder("");
             for (int i=0; i extends JComponent
    @@ -232,6 +233,13 @@ implements ItemSelectable,ListDataListener,ActionListener, Accessible {
             updateUI();
         }
     
    +    /**
    +     * Registers ancestor listener so that it will receive
    +     * {@code AncestorEvents} when it or any of its ancestors
    +     * move or are made visible or invisible.
    +     * Events are also sent when the component or its ancestors are added
    +     * or removed from the containment hierarchy.
    +     */
         protected void installAncestorListener() {
             addAncestorListener(new AncestorListener(){
                                     public void ancestorAdded(AncestorEvent event){ hidePopup();}
    @@ -812,6 +820,8 @@ implements ItemSelectable,ListDataListener,ActionListener, Accessible {
     
         /**
          * Sets the visibility of the popup.
    +     *
    +     * @param v if {@code true} shows the popup, otherwise, hides the popup.
          */
         public void setPopupVisible(boolean v) {
             getUI().setPopupVisible(this, v);
    @@ -1144,6 +1154,7 @@ implements ItemSelectable,ListDataListener,ActionListener, Accessible {
          * that of the Action.
          *
          * @param a the combobox's action
    +     * @return the {@code PropertyChangeListener}
          * @since 1.3
          * @see Action
          * @see #setAction
    @@ -1308,13 +1319,15 @@ implements ItemSelectable,ListDataListener,ActionListener, Accessible {
          * do not call or override.
          */
         public void actionPerformed(ActionEvent e) {
    -        Object newItem = getEditor().getItem();
    -        setPopupVisible(false);
    -        getModel().setSelectedItem(newItem);
    -        String oldCommand = getActionCommand();
    -        setActionCommand("comboBoxEdited");
    -        fireActionEvent();
    -        setActionCommand(oldCommand);
    +        ComboBoxEditor editor = getEditor();
    +        if ((editor != null) && (e != null) && (editor == e.getSource())) {
    +            setPopupVisible(false);
    +            getModel().setSelectedItem(editor.getItem());
    +            String oldCommand = getActionCommand();
    +            setActionCommand("comboBoxEdited");
    +            fireActionEvent();
    +            setActionCommand(oldCommand);
    +        }
         }
     
         /**
    @@ -1357,6 +1370,8 @@ implements ItemSelectable,ListDataListener,ActionListener, Accessible {
          *
          * @param keyChar a char, typically this is a keyboard key
          *                  typed by the user
    +     * @return {@code true} if there is an item corresponding to that character.
    +     *         Otherwise, returns {@code false}.
          */
         public boolean selectWithKeyChar(char keyChar) {
             int index;
    @@ -1443,6 +1458,7 @@ implements ItemSelectable,ListDataListener,ActionListener, Accessible {
          * selection. Typically, the first selection with a matching first
          * character becomes the selected item.
          *
    +     * @param aManager a key selection manager
          * @beaninfo
          *       expert: true
          *  description: The objects that changes the selection when a key is pressed.
    diff --git a/jdk/src/share/classes/javax/swing/JComponent.java b/jdk/src/share/classes/javax/swing/JComponent.java
    index 2d2745957e7..41dc5e54497 100644
    --- a/jdk/src/share/classes/javax/swing/JComponent.java
    +++ b/jdk/src/share/classes/javax/swing/JComponent.java
    @@ -63,6 +63,7 @@ import javax.swing.plaf.*;
     import static javax.swing.ClientPropertyKey.*;
     import javax.accessibility.*;
     
    +import sun.awt.SunToolkit;
     import sun.swing.SwingUtilities2;
     import sun.swing.UIClientPropertyKey;
     
    @@ -178,6 +179,7 @@ import sun.swing.UIClientPropertyKey;
      *
      * @author Hans Muller
      * @author Arnaud Weber
    + * @since 1.2
      */
     @SuppressWarnings("serial") // Same-version serialization only
     public abstract class JComponent extends Container implements Serializable,
    @@ -3678,8 +3680,8 @@ public abstract class JComponent extends Container implements Serializable,
             private volatile transient int propertyListenersCount = 0;
     
             /**
    -         * This field duplicates the one in java.awt.Component.AccessibleAWTComponent,
    -         * so it has been deprecated.
    +         * This field duplicates the function of the accessibleAWTFocusHandler field
    +         * in java.awt.Component.AccessibleAWTComponent, so it has been deprecated.
              */
             @Deprecated
             protected FocusListener accessibleFocusHandler = null;
    @@ -3737,14 +3739,10 @@ public abstract class JComponent extends Container implements Serializable,
              * @param listener  the PropertyChangeListener to be added
              */
             public void addPropertyChangeListener(PropertyChangeListener listener) {
    -            if (accessibleFocusHandler == null) {
    -                accessibleFocusHandler = new AccessibleFocusHandler();
    -            }
                 if (accessibleContainerHandler == null) {
                     accessibleContainerHandler = new AccessibleContainerHandler();
                 }
                 if (propertyListenersCount++ == 0) {
    -                JComponent.this.addFocusListener(accessibleFocusHandler);
                     JComponent.this.addContainerListener(accessibleContainerHandler);
                 }
                 super.addPropertyChangeListener(listener);
    @@ -3759,7 +3757,6 @@ public abstract class JComponent extends Container implements Serializable,
              */
             public void removePropertyChangeListener(PropertyChangeListener listener) {
                 if (--propertyListenersCount == 0) {
    -                JComponent.this.removeFocusListener(accessibleFocusHandler);
                     JComponent.this.removeContainerListener(accessibleContainerHandler);
                 }
                 super.removePropertyChangeListener(listener);
    @@ -4802,7 +4799,8 @@ public abstract class JComponent extends Container implements Serializable,
          * @see RepaintManager#addDirtyRegion
          */
         public void repaint(long tm, int x, int y, int width, int height) {
    -        RepaintManager.currentManager(this).addDirtyRegion(this, x, y, width, height);
    +        RepaintManager.currentManager(SunToolkit.targetToAppContext(this))
    +                      .addDirtyRegion(this, x, y, width, height);
         }
     
     
    @@ -4856,7 +4854,7 @@ public abstract class JComponent extends Container implements Serializable,
                 // which was causing some people grief.
                 return;
             }
    -        if (SwingUtilities.isEventDispatchThread()) {
    +        if (SunToolkit.isDispatchThreadForAppContext(this)) {
                 invalidate();
                 RepaintManager.currentManager(this).addInvalidComponent(this);
             }
    @@ -4870,15 +4868,12 @@ public abstract class JComponent extends Container implements Serializable,
                     }
                     setFlag(REVALIDATE_RUNNABLE_SCHEDULED, true);
                 }
    -            Runnable callRevalidate = new Runnable() {
    -                public void run() {
    -                    synchronized(JComponent.this) {
    -                        setFlag(REVALIDATE_RUNNABLE_SCHEDULED, false);
    -                    }
    -                    revalidate();
    +            SunToolkit.executeOnEventHandlerThread(this, () -> {
    +                synchronized(JComponent.this) {
    +                    setFlag(REVALIDATE_RUNNABLE_SCHEDULED, false);
                     }
    -            };
    -            SwingUtilities.invokeLater(callRevalidate);
    +                revalidate();
    +            });
             }
         }
     
    diff --git a/jdk/src/share/classes/javax/swing/JDesktopPane.java b/jdk/src/share/classes/javax/swing/JDesktopPane.java
    index 94f7db248e1..35d53d2d918 100644
    --- a/jdk/src/share/classes/javax/swing/JDesktopPane.java
    +++ b/jdk/src/share/classes/javax/swing/JDesktopPane.java
    @@ -85,6 +85,7 @@ import java.util.TreeSet;
      * @see DesktopManager
      *
      * @author David Kloba
    + * @since 1.2
      */
     @SuppressWarnings("serial") // Same-version serialization only
     public class JDesktopPane extends JLayeredPane implements Accessible
    diff --git a/jdk/src/share/classes/javax/swing/JDialog.java b/jdk/src/share/classes/javax/swing/JDialog.java
    index 12b978dbf46..ae0a3519e93 100644
    --- a/jdk/src/share/classes/javax/swing/JDialog.java
    +++ b/jdk/src/share/classes/javax/swing/JDialog.java
    @@ -94,6 +94,7 @@ import javax.accessibility.*;
      * @author David Kloba
      * @author James Gosling
      * @author Scott Violet
    + * @since 1.2
      */
     @SuppressWarnings("serial") // Same-version serialization only
     public class JDialog extends Dialog implements WindowConstants,
    @@ -647,6 +648,7 @@ public class JDialog extends Dialog implements WindowConstants,
             enableEvents(AWTEvent.KEY_EVENT_MASK | AWTEvent.WINDOW_EVENT_MASK);
             setLocale( JComponent.getDefaultLocale() );
             setRootPane(createRootPane());
    +        setBackground(UIManager.getColor("control"));
             setRootPaneCheckingEnabled(true);
             if (JDialog.isDefaultLookAndFeelDecorated()) {
                 boolean supportsWindowDecorations =
    diff --git a/jdk/src/share/classes/javax/swing/JEditorPane.java b/jdk/src/share/classes/javax/swing/JEditorPane.java
    index c1382125237..42951731ec1 100644
    --- a/jdk/src/share/classes/javax/swing/JEditorPane.java
    +++ b/jdk/src/share/classes/javax/swing/JEditorPane.java
    @@ -188,6 +188,7 @@ import javax.accessibility.*;
      * description: A text component to edit various types of content.
      *
      * @author  Timothy Prinzing
    + * @since 1.2
      */
     @SuppressWarnings("serial") // Same-version serialization only
     public class JEditorPane extends JTextComponent {
    @@ -679,8 +680,8 @@ public class JEditorPane extends JTextComponent {
                             }
                         });
                     }
    -                return (pageLoaded ? page : old);
                 }
    +            return (pageLoaded ? page : old);
             }
     
             /**
    @@ -965,7 +966,7 @@ public class JEditorPane extends JTextComponent {
             // The type could have optional info is part of it,
             // for example some charset info.  We need to strip that
             // of and save it.
    -        int parm = type.indexOf(";");
    +        int parm = type.indexOf(';');
             if (parm > -1) {
                 // Save the paramList.
                 String paramList = type.substring(parm);
    @@ -1250,11 +1251,12 @@ public class JEditorPane extends JTextComponent {
         }
     
         /**
    -     * Returns the currently registered EditorKit
    -     * class name for the type type.
    -     *
    -     * @param type  the non-null content type
    +     * Returns the currently registered {@code EditorKit} class name for the
    +     * type {@code type}.
          *
    +     * @param type  the non-{@code null} content type
    +     * @return a {@code String} containing the {@code EditorKit} class name
    +     *         for {@code type}
          * @since 1.3
          */
         public static String getEditorKitClassNameForContentType(String type) {
    diff --git a/jdk/src/share/classes/javax/swing/JFileChooser.java b/jdk/src/share/classes/javax/swing/JFileChooser.java
    index ac6374c2a40..bf690ddbb5b 100644
    --- a/jdk/src/share/classes/javax/swing/JFileChooser.java
    +++ b/jdk/src/share/classes/javax/swing/JFileChooser.java
    @@ -86,7 +86,7 @@ import java.lang.ref.WeakReference;
      * description: A component which allows for the interactive selection of a file.
      *
      * @author Jeff Dinkins
    - *
    + * @since 1.2
      */
     @SuppressWarnings("serial") // Superclass is not serializable across versions
     public class JFileChooser extends JComponent implements Accessible {
    @@ -330,6 +330,8 @@ public class JFileChooser extends JComponent implements Accessible {
         /**
          * Constructs a JFileChooser using the given
          * FileSystemView.
    +     *
    +     * @param fsv a {@code FileSystemView}
          */
         public JFileChooser(FileSystemView fsv) {
             this((File) null, fsv);
    @@ -339,6 +341,10 @@ public class JFileChooser extends JComponent implements Accessible {
         /**
          * Constructs a JFileChooser using the given current directory
          * and FileSystemView.
    +     *
    +     * @param currentDirectory a {@code File} object specifying the path to a
    +     *                         file or directory
    +     * @param fsv a {@code FileSystemView}
          */
         public JFileChooser(File currentDirectory, FileSystemView fsv) {
             setup(fsv);
    @@ -348,6 +354,10 @@ public class JFileChooser extends JComponent implements Accessible {
         /**
          * Constructs a JFileChooser using the given current directory
          * path and FileSystemView.
    +     *
    +     * @param currentDirectoryPath a {@code String} specifying the path to a file
    +     *                             or directory
    +     * @param fsv a {@code FileSystemView}
          */
         public JFileChooser(String currentDirectoryPath, FileSystemView fsv) {
             setup(fsv);
    @@ -360,6 +370,8 @@ public class JFileChooser extends JComponent implements Accessible {
     
         /**
          * Performs common constructor initialization and setup.
    +     *
    +     * @param view the {@code FileSystemView} used for setup
          */
         protected void setup(FileSystemView view) {
             installShowFilesListener();
    @@ -512,6 +524,8 @@ public class JFileChooser extends JComponent implements Accessible {
         /**
          * Returns a list of selected files if the file chooser is
          * set to allow multiple selection.
    +     *
    +     * @return an array of selected {@code File}s
          */
         public File[] getSelectedFiles() {
             if(selectedFiles == null) {
    @@ -525,6 +539,7 @@ public class JFileChooser extends JComponent implements Accessible {
          * Sets the list of selected files if the file chooser is
          * set to allow multiple selection.
          *
    +     * @param selectedFiles an array {@code File}s to be selected
          * @beaninfo
          *       bound: true
          * description: The list of selected files if the chooser is in multiple selection mode.
    @@ -971,6 +986,7 @@ public class JFileChooser extends JComponent implements Accessible {
         /**
          * Gets the string that goes in the JFileChooser's titlebar.
          *
    +     * @return the string from the {@code JFileChooser} window's title bar
          * @see #setDialogTitle
          */
         public String getDialogTitle() {
    @@ -1158,6 +1174,8 @@ public class JFileChooser extends JComponent implements Accessible {
          * Removes a filter from the list of user choosable file filters. Returns
          * true if the file filter was removed.
          *
    +     * @param f the file filter to be removed
    +     * @return true if the file filter was removed, false otherwise
          * @see #addChoosableFileFilter
          * @see #getChoosableFileFilters
          * @see #resetChoosableFileFilters
    @@ -1215,6 +1233,8 @@ public class JFileChooser extends JComponent implements Accessible {
         /**
          * Returns the AcceptAll file filter.
          * For example, on Microsoft Windows this would be All Files (*.*).
    +     *
    +     * @return the {@code AcceptAll} file filter
          */
         public FileFilter getAcceptAllFileFilter() {
             FileFilter filter = null;
    @@ -1240,8 +1260,10 @@ public class JFileChooser extends JComponent implements Accessible {
         * If false, the AcceptAll file filter is removed from
         * the list of available file filters.
         * If true, the AcceptAll file filter will become the
    -    * the actively used file filter.
    +    * actively used file filter.
         *
    +    * @param b a {@code boolean} which determines whether the {@code AcceptAll}
    +    *          file filter is an available choice in the choosable filter list
         * @beaninfo
         *   preferred: true
         *       bound: true
    @@ -1284,6 +1306,7 @@ public class JFileChooser extends JComponent implements Accessible {
          * any listeners that the accessory might have registered with the
          * file chooser.
          *
    +     * @param newAccessory the accessory component to be set
          * @beaninfo
          *   preferred: true
          *       bound: true
    @@ -1355,6 +1378,7 @@ public class JFileChooser extends JComponent implements Accessible {
          * Convenience call that determines if files are selectable based on the
          * current file selection mode.
          *
    +     * @return true if files are selectable, false otherwise
          * @see #setFileSelectionMode
          * @see #getFileSelectionMode
          */
    @@ -1366,6 +1390,7 @@ public class JFileChooser extends JComponent implements Accessible {
          * Convenience call that determines if directories are selectable based
          * on the current file selection mode.
          *
    +     * @return true if directories are selectable, false otherwise
          * @see #setFileSelectionMode
          * @see #getFileSelectionMode
          */
    @@ -1487,9 +1512,10 @@ public class JFileChooser extends JComponent implements Accessible {
         }
     
         /**
    -     * Sets the file view to used to retrieve UI information, such as
    +     * Sets the file view to be used to retrieve UI information, such as
          * the icon that represents a file or the type description of a file.
          *
    +     * @param fileView a {@code FileView} to be used to retrieve UI information
          * @beaninfo
          *   preferred: true
          *       bound: true
    @@ -1506,6 +1532,7 @@ public class JFileChooser extends JComponent implements Accessible {
         /**
          * Returns the current file view.
          *
    +     * @return the current file view
          * @see #setFileView
          */
         public FileView getFileView() {
    @@ -1765,6 +1792,8 @@ public class JFileChooser extends JComponent implements Accessible {
          * notification on this event type. The event instance
          * is lazily created using the command parameter.
          *
    +     * @param command a string that may specify a command associated with
    +     *                the event
          * @see EventListenerList
          */
         protected void fireActionPerformed(String command) {
    @@ -1973,6 +2002,9 @@ public class JFileChooser extends JComponent implements Accessible {
     // Accessibility support
     ////////////////
     
    +    /**
    +     * {@code AccessibleContext} associated with this {@code JFileChooser}
    +     */
         protected AccessibleContext accessibleContext = null;
     
         /**
    diff --git a/jdk/src/share/classes/javax/swing/JFrame.java b/jdk/src/share/classes/javax/swing/JFrame.java
    index c773a3b66a8..cc3b0807f96 100644
    --- a/jdk/src/share/classes/javax/swing/JFrame.java
    +++ b/jdk/src/share/classes/javax/swing/JFrame.java
    @@ -111,6 +111,7 @@ import javax.accessibility.*;
      * @author Jeff Dinkins
      * @author Georges Saab
      * @author David Kloba
    + * @since 1.2
      */
     @SuppressWarnings("serial") // Same-version serialization only
     public class JFrame  extends Frame implements WindowConstants,
    @@ -274,6 +275,8 @@ public class JFrame  extends Frame implements WindowConstants,
         /**
          * Called by the constructor methods to create the default
          * rootPane.
    +     *
    +     * @return a new {@code JRootPane}
          */
         protected JRootPane createRootPane() {
             JRootPane rp = new JRootPane();
    @@ -873,7 +876,9 @@ public class JFrame  extends Frame implements WindowConstants,
     // Accessibility support
     ////////////////
     
    -    /** The accessible context property. */
    +    /**
    +     * The accessible context property.
    +     */
         protected AccessibleContext accessibleContext = null;
     
         /**
    diff --git a/jdk/src/share/classes/javax/swing/JInternalFrame.java b/jdk/src/share/classes/javax/swing/JInternalFrame.java
    index e94854f9f12..3ecb82450d2 100644
    --- a/jdk/src/share/classes/javax/swing/JInternalFrame.java
    +++ b/jdk/src/share/classes/javax/swing/JInternalFrame.java
    @@ -104,6 +104,7 @@ import sun.swing.SwingUtilities2;
      *
      * @author David Kloba
      * @author Rich Schiavi
    + * @since 1.2
      * @beaninfo
      *      attribute: isContainer true
      *      attribute: containerDelegate getContentPane
    diff --git a/jdk/src/share/classes/javax/swing/JLabel.java b/jdk/src/share/classes/javax/swing/JLabel.java
    index af080be9564..2b0be80b1c7 100644
    --- a/jdk/src/share/classes/javax/swing/JLabel.java
    +++ b/jdk/src/share/classes/javax/swing/JLabel.java
    @@ -103,6 +103,7 @@ import java.util.*;
      * description: A component that displays a short string and an icon.
      *
      * @author Hans Muller
    + * @since 1.2
      */
     @SuppressWarnings("serial")
     public class JLabel extends JComponent implements SwingConstants, Accessible
    diff --git a/jdk/src/share/classes/javax/swing/JLayeredPane.java b/jdk/src/share/classes/javax/swing/JLayeredPane.java
    index 56685df9e66..ecb40a60bf5 100644
    --- a/jdk/src/share/classes/javax/swing/JLayeredPane.java
    +++ b/jdk/src/share/classes/javax/swing/JLayeredPane.java
    @@ -153,6 +153,7 @@ import javax.accessibility.*;
      * Please see {@link java.beans.XMLEncoder}.
      *
      * @author David Kloba
    + * @since 1.2
      */
     @SuppressWarnings("serial")
     public class JLayeredPane extends JComponent implements Accessible {
    diff --git a/jdk/src/share/classes/javax/swing/JList.java b/jdk/src/share/classes/javax/swing/JList.java
    index 8088396fcc3..808f9780c3f 100644
    --- a/jdk/src/share/classes/javax/swing/JList.java
    +++ b/jdk/src/share/classes/javax/swing/JList.java
    @@ -276,6 +276,7 @@ import static sun.swing.SwingUtilities2.Section.*;
      * description: A component which allows for the selection of one or more objects from a list.
      *
      * @author Hans Muller
    + * @since 1.2
      */
     @SuppressWarnings("serial") // Same-version serialization only
     public class JList extends JComponent implements Scrollable, Accessible
    diff --git a/jdk/src/share/classes/javax/swing/JMenu.java b/jdk/src/share/classes/javax/swing/JMenu.java
    index a9cec084d7e..02285e0047f 100644
    --- a/jdk/src/share/classes/javax/swing/JMenu.java
    +++ b/jdk/src/share/classes/javax/swing/JMenu.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
    @@ -108,6 +108,7 @@ import java.lang.ref.WeakReference;
      * @see JSeparator
      * @see JMenuBar
      * @see JPopupMenu
    + * @since 1.2
      */
     @SuppressWarnings("serial")
     public class JMenu extends JMenuItem implements Accessible,MenuElement
    @@ -607,16 +608,18 @@ public class JMenu extends JMenuItem implements Accessible,MenuElement
          * it to the end of this menu.
          *
          * @param s the string for the menu item to be added
    +     * @return the new {@code JMenuItem}
          */
         public JMenuItem add(String s) {
             return add(new JMenuItem(s));
         }
     
         /**
    -     * Creates a new menu item attached to the specified
    -     * Action object and appends it to the end of this menu.
    +     * Creates a new menu item attached to the specified {@code Action} object
    +     * and appends it to the end of this menu.
          *
    -     * @param a the Action for the menu item to be added
    +     * @param a the {@code Action} for the menu item to be added
    +     * @return the new {@code JMenuItem}
          * @see Action
          */
         public JMenuItem add(Action a) {
    @@ -652,8 +655,11 @@ public class JMenu extends JMenuItem implements Accessible,MenuElement
         }
     
         /**
    -     * Returns a properly configured PropertyChangeListener
    -     * which updates the control as changes to the Action occur.
    +     * Returns a properly configured {@code PropertyChangeListener}
    +     * which updates the control as changes to the {@code Action} occur.
    +     *
    +     * @param b a menu item for which to create a {@code PropertyChangeListener}
    +     * @return a {@code PropertyChangeListener} for {@code b}
          */
         protected PropertyChangeListener createActionChangeListener(JMenuItem b) {
             return b.createActionPropertyChangeListener0(b.getAction());
    @@ -713,6 +719,7 @@ public class JMenu extends JMenuItem implements Accessible,MenuElement
          * @param a the Action object for the menu item to add
          * @param pos an integer specifying the position at which to add the
          *               new menu item
    +     * @return the new menu item
          * @exception IllegalArgumentException if the value of
          *                  pos < 0
          */
    @@ -747,16 +754,16 @@ public class JMenu extends JMenuItem implements Accessible,MenuElement
         }
     
         /**
    -     * Returns the JMenuItem at the specified position.
    -     * If the component at pos is not a menu item,
    -     * null is returned.
    +     * Returns the {@code JMenuItem} at the specified position.
    +     * If the component at {@code pos} is not a menu item,
    +     * {@code null} is returned.
          * This method is included for AWT compatibility.
          *
    -     * @param pos    an integer specifying the position
    -     * @exception   IllegalArgumentException if the value of
    -     *                       pos < 0
    +     * @param pos  an integer specifying the position
          * @return  the menu item at the specified position; or null
          *          if the item as the specified position is not a menu item
    +     * @exception  IllegalArgumentException if the value of
    +     *             {@code pos} < 0
          */
         public JMenuItem getItem(int pos) {
             if (pos < 0) {
    @@ -974,6 +981,8 @@ public class JMenu extends JMenuItem implements Accessible,MenuElement
         /**
          * Returns the popupmenu associated with this menu.  If there is
          * no popupmenu, it will create one.
    +     *
    +     * @return the {@code JPopupMenu} associated with this menu
          */
         public JPopupMenu getPopupMenu() {
             ensurePopupMenuCreated();
    @@ -1158,6 +1167,8 @@ public class JMenu extends JMenuItem implements Accessible,MenuElement
             JPopupMenu popupMenu;
             /**
              *  Create the window listener for the specified popup.
    +         *
    +         * @param p the popup menu for which to create a listener
              * @since 1.4
              */
             public WinListener(JPopupMenu p) {
    diff --git a/jdk/src/share/classes/javax/swing/JMenuBar.java b/jdk/src/share/classes/javax/swing/JMenuBar.java
    index 7c7cc541be9..c8fcb6673c6 100644
    --- a/jdk/src/share/classes/javax/swing/JMenuBar.java
    +++ b/jdk/src/share/classes/javax/swing/JMenuBar.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
    @@ -88,6 +88,7 @@ import javax.accessibility.*;
      * @see JMenu
      * @see JPopupMenu
      * @see JMenuItem
    + * @since 1.2
      */
     @SuppressWarnings("serial")
     public class JMenuBar extends JComponent implements Accessible,MenuElement
    @@ -123,6 +124,8 @@ public class JMenuBar extends JComponent implements Accessible,MenuElement
     
         /**
          * Returns the menubar's current UI.
    +     *
    +     * @return a {@code MenuBarUI} which is the menubar's current L&F object
          * @see #setUI
          */
         public MenuBarUI getUI() {
    diff --git a/jdk/src/share/classes/javax/swing/JMenuItem.java b/jdk/src/share/classes/javax/swing/JMenuItem.java
    index 4ee5b67bc43..f63dd709a3e 100644
    --- a/jdk/src/share/classes/javax/swing/JMenuItem.java
    +++ b/jdk/src/share/classes/javax/swing/JMenuItem.java
    @@ -86,6 +86,7 @@ import javax.accessibility.*;
      * @see JMenu
      * @see JCheckBoxMenuItem
      * @see JRadioButtonMenuItem
    + * @since 1.2
      */
     @SuppressWarnings("serial")
     public class JMenuItem extends AbstractButton implements Accessible,MenuElement  {
    diff --git a/jdk/src/share/classes/javax/swing/JOptionPane.java b/jdk/src/share/classes/javax/swing/JOptionPane.java
    index 1594a0f6d7e..77fab724208 100644
    --- a/jdk/src/share/classes/javax/swing/JOptionPane.java
    +++ b/jdk/src/share/classes/javax/swing/JOptionPane.java
    @@ -310,6 +310,7 @@ import sun.awt.AWTAccessor;
      *
      * @author James Gosling
      * @author Scott Violet
    + * @since 1.2
      */
     @SuppressWarnings("serial") // Same-version serialization only
     public class JOptionPane extends JComponent implements Accessible
    @@ -435,6 +436,7 @@ public class JOptionPane extends JComponent implements Accessible
          * @exception HeadlessException if
          *   GraphicsEnvironment.isHeadless returns
          *   true
    +     * @return user's input
          * @see java.awt.GraphicsEnvironment#isHeadless
          */
         public static String showInputDialog(Object message)
    @@ -451,6 +453,7 @@ public class JOptionPane extends JComponent implements Accessible
          * @param message the Object to display
          * @param initialSelectionValue the value used to initialize the input
          *                 field
    +     * @return user's input
          * @since 1.4
          */
         public static String showInputDialog(Object message, Object initialSelectionValue) {
    @@ -469,6 +472,7 @@ public class JOptionPane extends JComponent implements Accessible
          * @exception HeadlessException if
          *    GraphicsEnvironment.isHeadless returns
          *    true
    +     * @return user's input
          * @see java.awt.GraphicsEnvironment#isHeadless
          */
         public static String showInputDialog(Component parentComponent,
    @@ -489,6 +493,7 @@ public class JOptionPane extends JComponent implements Accessible
          * @param message the Object to display
          * @param initialSelectionValue the value used to initialize the input
          *                 field
    +     * @return user's input
          * @since 1.4
          */
         public static String showInputDialog(Component parentComponent, Object message,
    @@ -515,6 +520,7 @@ public class JOptionPane extends JComponent implements Accessible
          *                  WARNING_MESSAGE,
          *                  QUESTION_MESSAGE,
          *                  or PLAIN_MESSAGE
    +     * @return user's input
          * @exception HeadlessException if
          *   GraphicsEnvironment.isHeadless returns
          *   true
    @@ -1348,6 +1354,7 @@ public class JOptionPane extends JComponent implements Accessible
          * @param parentComponent  the parent Component
          *          for the dialog
          * @param message  the Object to display
    +     * @return user's input
          */
         public static String showInternalInputDialog(Component parentComponent,
                                                      Object message) {
    @@ -1368,6 +1375,7 @@ public class JOptionPane extends JComponent implements Accessible
          * @param messageType the type of message that is to be displayed:
          *                    ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE,
          *                    QUESTION_MESSAGE, or PLAIN_MESSAGE
    +     * @return user's input
          */
         public static String showInternalInputDialog(Component parentComponent,
                                  Object message, String title, int messageType) {
    @@ -2246,6 +2254,8 @@ public class JOptionPane extends JComponent implements Accessible
          * 

    * This is a bound property. * + * @param newValue if true, an input component whose parent is {@code parentComponent} + * is provided to allow the user to input a value. * @see #setSelectionValues * @see #setInputValue * @beaninfo diff --git a/jdk/src/share/classes/javax/swing/JPanel.java b/jdk/src/share/classes/javax/swing/JPanel.java index 6211c8bcd29..293ca2237df 100644 --- a/jdk/src/share/classes/javax/swing/JPanel.java +++ b/jdk/src/share/classes/javax/swing/JPanel.java @@ -61,6 +61,7 @@ import java.io.IOException; * * @author Arnaud Weber * @author Steve Wilson + * @since 1.2 */ @SuppressWarnings("serial") // Same-version serialization only public class JPanel extends JComponent implements Accessible diff --git a/jdk/src/share/classes/javax/swing/JPasswordField.java b/jdk/src/share/classes/javax/swing/JPasswordField.java index a869d80c1f0..82b6457e8ec 100644 --- a/jdk/src/share/classes/javax/swing/JPasswordField.java +++ b/jdk/src/share/classes/javax/swing/JPasswordField.java @@ -73,6 +73,7 @@ import java.util.Arrays; * description: Allows the editing of a line of text but doesn't show the characters. * * @author Timothy Prinzing + * @since 1.2 */ @SuppressWarnings("serial") // Same-version serialization only public class JPasswordField extends JTextField { diff --git a/jdk/src/share/classes/javax/swing/JPopupMenu.java b/jdk/src/share/classes/javax/swing/JPopupMenu.java index 4112de64db0..3f2a57323a5 100644 --- a/jdk/src/share/classes/javax/swing/JPopupMenu.java +++ b/jdk/src/share/classes/javax/swing/JPopupMenu.java @@ -82,6 +82,7 @@ import java.applet.Applet; * @author Georges Saab * @author David Karlton * @author Arnaud Weber + * @since 1.2 */ @SuppressWarnings("serial") public class JPopupMenu extends JComponent implements Accessible,MenuElement { diff --git a/jdk/src/share/classes/javax/swing/JProgressBar.java b/jdk/src/share/classes/javax/swing/JProgressBar.java index b839018b1fd..5a3611131b8 100644 --- a/jdk/src/share/classes/javax/swing/JProgressBar.java +++ b/jdk/src/share/classes/javax/swing/JProgressBar.java @@ -128,6 +128,7 @@ import javax.swing.plaf.ProgressBarUI; * * @author Michael C. Albers * @author Kathy Walrath + * @since 1.2 */ @SuppressWarnings("serial") // Same-version serialization only public class JProgressBar extends JComponent implements SwingConstants, Accessible @@ -665,6 +666,7 @@ public class JProgressBar extends JComponent implements SwingConstants, Accessib * to the {@code ChangeListener}s that have been added directly to the * progress bar. * + * @return the instance of a custom {@code ChangeListener} implementation. * @see #changeListener * @see #fireStateChanged * @see javax.swing.event.ChangeListener diff --git a/jdk/src/share/classes/javax/swing/JRadioButton.java b/jdk/src/share/classes/javax/swing/JRadioButton.java index 41197072266..c5eaf6813bd 100644 --- a/jdk/src/share/classes/javax/swing/JRadioButton.java +++ b/jdk/src/share/classes/javax/swing/JRadioButton.java @@ -85,6 +85,7 @@ import java.io.IOException; * @see ButtonGroup * @see JCheckBox * @author Jeff Dinkins + * @since 1.2 */ @SuppressWarnings("serial") // Same-version serialization only public class JRadioButton extends JToggleButton implements Accessible { @@ -118,6 +119,7 @@ public class JRadioButton extends JToggleButton implements Accessible { * Creates a radiobutton where properties are taken from the * Action supplied. * + * @param a an {@code Action} * @since 1.3 */ public JRadioButton(Action a) { @@ -175,6 +177,8 @@ public class JRadioButton extends JToggleButton implements Accessible { * * @param text the string displayed on the radio button * @param icon the image that the button should display + * @param selected if {@code true}, the button is initially selected + * otherwise, the button is initially unselected */ public JRadioButton (String text, Icon icon, boolean selected) { super(text, icon, selected); diff --git a/jdk/src/share/classes/javax/swing/JRadioButtonMenuItem.java b/jdk/src/share/classes/javax/swing/JRadioButtonMenuItem.java index 5d49c6f464f..e1c219b4037 100644 --- a/jdk/src/share/classes/javax/swing/JRadioButtonMenuItem.java +++ b/jdk/src/share/classes/javax/swing/JRadioButtonMenuItem.java @@ -82,6 +82,7 @@ import javax.accessibility.*; * @author Georges Saab * @author David Karlton * @see ButtonGroup + * @since 1.2 */ @SuppressWarnings("serial") // Same-version serialization only public class JRadioButtonMenuItem extends JMenuItem implements Accessible { @@ -173,6 +174,8 @@ public class JRadioButtonMenuItem extends JMenuItem implements Accessible { * * @param text the string displayed on the radio button * @param icon the image that the button should display + * @param selected if {@code true}, the button is initially selected, + * otherwise, the button is initially unselected */ public JRadioButtonMenuItem(String text, Icon icon, boolean selected) { super(text, icon); diff --git a/jdk/src/share/classes/javax/swing/JRootPane.java b/jdk/src/share/classes/javax/swing/JRootPane.java index 8cab327305b..f9dea90da3e 100644 --- a/jdk/src/share/classes/javax/swing/JRootPane.java +++ b/jdk/src/share/classes/javax/swing/JRootPane.java @@ -197,6 +197,7 @@ import sun.security.action.GetBooleanAction; * Mixing Heavy and Light Components * * @author David Kloba + * @since 1.2 */ /// PENDING(klobad) Who should be opaque in this component? @SuppressWarnings("serial") diff --git a/jdk/src/share/classes/javax/swing/JScrollBar.java b/jdk/src/share/classes/javax/swing/JScrollBar.java index bdcee342e1f..230ba8081c7 100644 --- a/jdk/src/share/classes/javax/swing/JScrollBar.java +++ b/jdk/src/share/classes/javax/swing/JScrollBar.java @@ -77,6 +77,7 @@ import java.io.IOException; * description: A component that helps determine the visible content range of an area. * * @author David Kloba + * @since 1.2 */ @SuppressWarnings("serial") // Same-version serialization only public class JScrollBar extends JComponent implements Adjustable, Accessible @@ -149,6 +150,12 @@ public class JScrollBar extends JComponent implements Adjustable, Accessible * @see #setVisibleAmount * @see #setMinimum * @see #setMaximum + * + * @param orientation an orientation of the {@code JScrollBar} + * @param value an int giving the current value + * @param extent an int giving the amount by which the value can "jump" + * @param min an int giving the minimum value + * @param max an int giving the maximum value */ public JScrollBar(int orientation, int value, int extent, int min, int max) { @@ -172,6 +179,8 @@ public class JScrollBar extends JComponent implements Adjustable, Accessible * value = 0 * extent = 10 *

    + * + * @param orientation an orientation of the {@code JScrollBar} */ public JScrollBar(int orientation) { this(orientation, 0, 10, 0, 100); @@ -213,6 +222,7 @@ public class JScrollBar extends JComponent implements Adjustable, Accessible * Returns the delegate that implements the look and feel for * this component. * + * @return the scroll bar's current UI. * @see JComponent#setUI */ public ScrollBarUI getUI() { @@ -258,6 +268,7 @@ public class JScrollBar extends JComponent implements Adjustable, Accessible * Set the scrollbar's orientation to either VERTICAL or * HORIZONTAL. * + * @param orientation an orientation of the {@code JScrollBar} * @exception IllegalArgumentException if orientation is not one of VERTICAL, HORIZONTAL * @see #getOrientation * @beaninfo @@ -293,6 +304,8 @@ public class JScrollBar extends JComponent implements Adjustable, Accessible * Returns data model that handles the scrollbar's four * fundamental properties: minimum, maximum, value, extent. * + * @return the data model + * * @see #setModel */ public BoundedRangeModel getModel() { @@ -304,6 +317,7 @@ public class JScrollBar extends JComponent implements Adjustable, Accessible * Sets the model that handles the scrollbar's four * fundamental properties: minimum, maximum, value, extent. * + * @param newModel a new model * @see #getModel * @beaninfo * bound: true @@ -583,6 +597,8 @@ public class JScrollBar extends JComponent implements Adjustable, Accessible * scrollbar model will not generate ChangeEvents while * valueIsAdjusting is true. * + * @param b {@code true} if the upcoming changes to the value property are part of a series + * * @see #getValueIsAdjusting * @see BoundedRangeModel#setValueIsAdjusting * @beaninfo @@ -610,6 +626,10 @@ public class JScrollBar extends JComponent implements Adjustable, Accessible * minimum ≤ value ≤ value+extent ≤ maximum * * + * @param newValue an int giving the current value + * @param newExtent an int giving the amount by which the value can "jump" + * @param newMin an int giving the minimum value + * @param newMax an int giving the maximum value * * @see BoundedRangeModel#setRangeProperties * @see #setValue @@ -681,6 +701,10 @@ public class JScrollBar extends JComponent implements Adjustable, Accessible /** * Notify listeners that the scrollbar's model has changed. * + * @param id an integer indicating the type of event. + * @param type an integer indicating the adjustment type. + * @param value the current value of the adjustment + * * @see #addAdjustmentListener * @see EventListenerList */ diff --git a/jdk/src/share/classes/javax/swing/JScrollPane.java b/jdk/src/share/classes/javax/swing/JScrollPane.java index 444a1c22526..373523e936e 100644 --- a/jdk/src/share/classes/javax/swing/JScrollPane.java +++ b/jdk/src/share/classes/javax/swing/JScrollPane.java @@ -167,6 +167,7 @@ import java.beans.Transient; * description: A specialized container that manages a viewport, optional scrollbars and headers * * @author Hans Muller + * @since 1.2 */ @SuppressWarnings("serial") // Same-version serialization only public class JScrollPane extends JComponent implements ScrollPaneConstants, Accessible diff --git a/jdk/src/share/classes/javax/swing/JSeparator.java b/jdk/src/share/classes/javax/swing/JSeparator.java index 179c7fe91af..2614096679b 100644 --- a/jdk/src/share/classes/javax/swing/JSeparator.java +++ b/jdk/src/share/classes/javax/swing/JSeparator.java @@ -70,6 +70,7 @@ import java.io.IOException; * * @author Georges Saab * @author Jeff Shapiro + * @since 1.2 */ @SuppressWarnings("serial") public class JSeparator extends JComponent implements SwingConstants, Accessible diff --git a/jdk/src/share/classes/javax/swing/JSlider.java b/jdk/src/share/classes/javax/swing/JSlider.java index d75e1030634..a2524d9b244 100644 --- a/jdk/src/share/classes/javax/swing/JSlider.java +++ b/jdk/src/share/classes/javax/swing/JSlider.java @@ -77,6 +77,7 @@ import java.beans.*; * description: A component that supports selecting a integer value from a range. * * @author David Kloba + * @since 1.2 */ @SuppressWarnings("serial") // Same-version serialization only public class JSlider extends JComponent implements SwingConstants, Accessible { @@ -280,6 +281,8 @@ public class JSlider extends JComponent implements SwingConstants, Accessible { /** * Creates a horizontal slider using the specified * BoundedRangeModel. + * + * @param brm a {@code BoundedRangeModel} for the slider */ public JSlider(BoundedRangeModel brm) { @@ -362,6 +365,8 @@ public class JSlider extends JComponent implements SwingConstants, Accessible { * {@code fireStateChanged} method to forward {@code ChangeEvent}s * to the {@code ChangeListener}s that have been added directly to the * slider. + * + * @return a instance of new {@code ChangeListener} * @see #changeListener * @see #fireStateChanged * @see javax.swing.event.ChangeListener diff --git a/jdk/src/share/classes/javax/swing/JSplitPane.java b/jdk/src/share/classes/javax/swing/JSplitPane.java index 533d9a971af..072fefd8d3a 100644 --- a/jdk/src/share/classes/javax/swing/JSplitPane.java +++ b/jdk/src/share/classes/javax/swing/JSplitPane.java @@ -97,6 +97,7 @@ import java.io.IOException; * @see #resetToPreferredSizes * * @author Scott Violet + * @since 1.2 */ @SuppressWarnings("serial") // Same-version serialization only public class JSplitPane extends JComponent implements Accessible diff --git a/jdk/src/share/classes/javax/swing/JTabbedPane.java b/jdk/src/share/classes/javax/swing/JTabbedPane.java index e5c303489c6..96c050529fe 100644 --- a/jdk/src/share/classes/javax/swing/JTabbedPane.java +++ b/jdk/src/share/classes/javax/swing/JTabbedPane.java @@ -105,6 +105,7 @@ import java.io.IOException; * @author Amy Fowler * * @see SingleSelectionModel + * @since 1.2 */ @SuppressWarnings("serial") // Same-version serialization only public class JTabbedPane extends JComponent @@ -277,6 +278,7 @@ public class JTabbedPane extends JComponent * can override this to return a subclass of ModelListener or * another ChangeListener implementation. * + * @return a {@code ChangeListener} * @see #fireStateChanged */ protected ChangeListener createChangeListener() { @@ -422,6 +424,7 @@ public class JTabbedPane extends JComponent /** * Returns the model associated with this tabbedpane. * + * @return the {@code SingleSelectionModel} associated with this tabbedpane * @see #setModel */ public SingleSelectionModel getModel() { @@ -458,6 +461,8 @@ public class JTabbedPane extends JComponent /** * Returns the placement of the tabs for this tabbedpane. + * + * @return an {@code int} specifying the placement for the tabs * @see #setTabPlacement */ public int getTabPlacement() { @@ -506,6 +511,8 @@ public class JTabbedPane extends JComponent /** * Returns the policy used by the tabbedpane to layout the tabs when all the * tabs will not fit within a single run. + * + * @return an {@code int} specifying the policy used to layout the tabs * @see #setTabLayoutPolicy * @since 1.4 */ @@ -663,6 +670,7 @@ public class JTabbedPane extends JComponent * will automatically set the selectedIndex to the index * corresponding to the specified component. * + * @param c the selected {@code Component} for this {@code TabbedPane} * @exception IllegalArgumentException if component not found in tabbed * pane * @see #getSelectedComponent diff --git a/jdk/src/share/classes/javax/swing/JTable.java b/jdk/src/share/classes/javax/swing/JTable.java index 8d25315a03c..1c7f72c947d 100644 --- a/jdk/src/share/classes/javax/swing/JTable.java +++ b/jdk/src/share/classes/javax/swing/JTable.java @@ -212,6 +212,7 @@ import sun.swing.PrintingStatus; * @author Shannon Hickey (printing support) * @see javax.swing.table.DefaultTableModel * @see javax.swing.table.TableRowSorter + * @since 1.2 */ /* The first versions of the JTable, contained in Swing-0.1 through * Swing-0.4, were written by Alan Chung. @@ -864,6 +865,8 @@ public class JTable extends JComponent implements TableModelListener, Scrollable /** * Equivalent to new JScrollPane(aTable). * + * @param aTable a {@code JTable} to be used for the scroll pane + * @return a {@code JScrollPane} created using {@code aTable} * @deprecated As of Swing version 1.0.2, * replaced by new JScrollPane(aTable). */ @@ -1960,6 +1963,7 @@ public class JTable extends JComponent implements TableModelListener, Scrollable * JList. See the setSelectionMode method * in JList for details about the modes. * + * @param selectionMode the mode used by the row and column selection models * @see JList#setSelectionMode * @beaninfo * description: The selection mode used by the row and column selection models. @@ -2320,6 +2324,7 @@ public class JTable extends JComponent implements TableModelListener, Scrollable * Returns true if the specified index is in the valid range of rows, * and the row at that index is selected. * + * @param row a row in the row model * @return true if row is a valid index and the row at * that index is selected (where 0 is the first row) */ @@ -3173,6 +3178,8 @@ public class JTable extends JComponent implements TableModelListener, Scrollable /** * Sizes the table columns to fit the available space. + * + * @param lastColumnOnly determines whether to resize last column only * @deprecated As of Swing version 1.0.3, * replaced by doLayout(). * @see #doLayout @@ -6691,7 +6698,7 @@ public class JTable extends JComponent implements TableModelListener, Scrollable // Listeners to echo changes to the AccessiblePropertyChange mechanism - /* + /** * Describes a change in the accessible table model. */ protected class AccessibleJTableModelChange @@ -6736,6 +6743,8 @@ public class JTable extends JComponent implements TableModelListener, Scrollable /** * Track changes to the table contents + * + * @param e a {@code TableModelEvent} describing the event */ public void tableChanged(TableModelEvent e) { firePropertyChange(AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY, @@ -6763,6 +6772,8 @@ public class JTable extends JComponent implements TableModelListener, Scrollable /** * Track changes to the table contents (row insertions) + * + * @param e a {@code TableModelEvent} describing the event */ public void tableRowsInserted(TableModelEvent e) { firePropertyChange(AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY, @@ -6788,6 +6799,8 @@ public class JTable extends JComponent implements TableModelListener, Scrollable /** * Track changes to the table contents (row deletions) + * + * @param e a {@code TableModelEvent} describing the event */ public void tableRowsDeleted(TableModelEvent e) { firePropertyChange(AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY, @@ -7921,6 +7934,11 @@ public class JTable extends JComponent implements TableModelListener, Scrollable /** * Constructs an AccessibleJTableHeaderEntry. + * + * @param t a {@code JTable} + * @param r an {@code int} specifying a row + * @param c an {@code int} specifying a column + * @param i an {@code int} specifying the index to this cell * @since 1.4 */ public AccessibleJTableCell(JTable t, int r, int c, int i) { diff --git a/jdk/src/share/classes/javax/swing/JTextArea.java b/jdk/src/share/classes/javax/swing/JTextArea.java index a6af9e241fa..96fb6b33e31 100644 --- a/jdk/src/share/classes/javax/swing/JTextArea.java +++ b/jdk/src/share/classes/javax/swing/JTextArea.java @@ -123,6 +123,7 @@ import java.io.IOException; * @author Timothy Prinzing * @see JTextPane * @see JEditorPane + * @since 1.2 */ @SuppressWarnings("serial") // Same-version serialization only public class JTextArea extends JTextComponent { diff --git a/jdk/src/share/classes/javax/swing/JTextField.java b/jdk/src/share/classes/javax/swing/JTextField.java index f50f6aa9be9..0e39cdbc955 100644 --- a/jdk/src/share/classes/javax/swing/JTextField.java +++ b/jdk/src/share/classes/javax/swing/JTextField.java @@ -160,6 +160,7 @@ import java.io.Serializable; * @see #setActionCommand * @see JPasswordField * @see #addActionListener + * @since 1.2 */ @SuppressWarnings("serial") // Same-version serialization only public class JTextField extends JTextComponent implements SwingConstants { diff --git a/jdk/src/share/classes/javax/swing/JTextPane.java b/jdk/src/share/classes/javax/swing/JTextPane.java index 017f897177c..f9c2de42a65 100644 --- a/jdk/src/share/classes/javax/swing/JTextPane.java +++ b/jdk/src/share/classes/javax/swing/JTextPane.java @@ -78,6 +78,7 @@ import javax.swing.plaf.*; * * @author Timothy Prinzing * @see javax.swing.text.StyledEditorKit + * @since 1.2 */ @SuppressWarnings("serial") // Same-version serialization only public class JTextPane extends JEditorPane { diff --git a/jdk/src/share/classes/javax/swing/JToggleButton.java b/jdk/src/share/classes/javax/swing/JToggleButton.java index f2f9a0601e0..08ec0be8659 100644 --- a/jdk/src/share/classes/javax/swing/JToggleButton.java +++ b/jdk/src/share/classes/javax/swing/JToggleButton.java @@ -75,6 +75,7 @@ import java.io.IOException; * @see JRadioButton * @see JCheckBox * @author Jeff Dinkins + * @since 1.2 */ @SuppressWarnings("serial") // Same-version serialization only public class JToggleButton extends AbstractButton implements Accessible { @@ -140,6 +141,7 @@ public class JToggleButton extends AbstractButton implements Accessible { * Creates a toggle button where properties are taken from the * Action supplied. * + * @param a an instance of an {@code Action} * @since 1.3 */ public JToggleButton(Action a) { @@ -390,6 +392,9 @@ public class JToggleButton extends AbstractButton implements Accessible { protected class AccessibleJToggleButton extends AccessibleAbstractButton implements ItemListener { + /** + * Constructs {@code AccessibleJToggleButton} + */ public AccessibleJToggleButton() { super(); JToggleButton.this.addItemListener(this); diff --git a/jdk/src/share/classes/javax/swing/JToolBar.java b/jdk/src/share/classes/javax/swing/JToolBar.java index 0557e4b93f2..6fff218430f 100644 --- a/jdk/src/share/classes/javax/swing/JToolBar.java +++ b/jdk/src/share/classes/javax/swing/JToolBar.java @@ -85,6 +85,7 @@ import java.util.Hashtable; * @author Georges Saab * @author Jeff Shapiro * @see Action + * @since 1.2 */ @SuppressWarnings("serial") // Same-version serialization only public class JToolBar extends JComponent implements SwingConstants, Accessible @@ -161,6 +162,8 @@ public class JToolBar extends JComponent implements SwingConstants, Accessible /** * Returns the tool bar's current UI. + * + * @return the tool bar's current UI. * @see #setUI */ public ToolBarUI getUI() { @@ -555,7 +558,8 @@ public class JToolBar extends JComponent implements SwingConstants, Accessible * or null if the default * property change listener for the control is desired. * - * @return null + * @param b a {@code JButton} + * @return {@code null} */ protected PropertyChangeListener createActionChangeListener(JButton b) { return null; diff --git a/jdk/src/share/classes/javax/swing/JToolTip.java b/jdk/src/share/classes/javax/swing/JToolTip.java index e5409121421..dad092dc5fd 100644 --- a/jdk/src/share/classes/javax/swing/JToolTip.java +++ b/jdk/src/share/classes/javax/swing/JToolTip.java @@ -66,6 +66,7 @@ import java.util.Objects; * @see JComponent#createToolTip * @author Dave Moore * @author Rich Shiavi + * @since 1.2 */ @SuppressWarnings("serial") public class JToolTip extends JComponent implements Accessible { diff --git a/jdk/src/share/classes/javax/swing/JTree.java b/jdk/src/share/classes/javax/swing/JTree.java index 45c92ac8af0..dcdf7a58946 100644 --- a/jdk/src/share/classes/javax/swing/JTree.java +++ b/jdk/src/share/classes/javax/swing/JTree.java @@ -141,6 +141,7 @@ import static sun.swing.SwingUtilities2.Section.*; * @author Rob Davis * @author Ray Ryan * @author Scott Violet + * @since 1.2 */ @SuppressWarnings("serial") public class JTree extends JComponent implements Scrollable, Accessible @@ -986,6 +987,7 @@ public class JTree extends JComponent implements Scrollable, Accessible * or equal to 0 the height for each row is determined by the * renderer. * + * @return the height of each row */ public int getRowHeight() { @@ -1115,6 +1117,7 @@ public class JTree extends JComponent implements Scrollable, Accessible *

    * This is a bound property. * + * @param clickCount the number of mouse clicks to get a node expanded or closed * @since 1.3 * @beaninfo * bound: true @@ -1508,6 +1511,7 @@ public class JTree extends JComponent implements Scrollable, Accessible * is provided as an entry point for subclassers to add filtered * editing without having to resort to creating a new editor. * + * @param path a {@code TreePath} identifying a node * @return true if every parent node and the node itself is editable * @see #isEditable */ @@ -1984,6 +1988,8 @@ public class JTree extends JComponent implements Scrollable, Accessible /** * Returns true if the node identified by the path has ever been * expanded. + * + * @param path a {@code TreePath} identifying a node * @return true if the path has ever been expanded */ public boolean hasBeenExpanded(TreePath path) { @@ -2079,6 +2085,7 @@ public class JTree extends JComponent implements Scrollable, Accessible * which means it is either the root or all of its parents are expanded. * Otherwise, this method returns false. * + * @param path {@code TreePath} identifying a node * @return true if the node is viewable, otherwise false */ public boolean isVisible(TreePath path) { @@ -2472,6 +2479,7 @@ public class JTree extends JComponent implements Scrollable, Accessible * set the selection model to null, which forces an empty * selection model to be used. * + * @return the model for selections * @see #setSelectionModel */ public TreeSelectionModel getSelectionModel() { @@ -2817,6 +2825,7 @@ public class JTree extends JComponent implements Scrollable, Accessible * * @param path the TreePath indicating the node that was * expanded + * @throws ExpandVetoException if the expansion is prevented from occurring * @see EventListenerList */ public void fireTreeWillExpand(TreePath path) throws ExpandVetoException { @@ -2843,6 +2852,7 @@ public class JTree extends JComponent implements Scrollable, Accessible * * @param path the TreePath indicating the node that was * expanded + * @throws ExpandVetoException if the collapse is prevented from occurring * @see EventListenerList */ public void fireTreeWillCollapse(TreePath path) throws ExpandVetoException { @@ -3541,6 +3551,11 @@ public class JTree extends JComponent implements Scrollable, Accessible * path are marked EXPANDED, but path itself * is marked collapsed.

    * This will fail if a TreeWillExpandListener vetos it. + * + * @param path a {@code TreePath} identifying a node + * @param state if {@code true}, all parents of @{code path} and path are marked as expanded. + * Otherwise, all parents of {@code path} are marked EXPANDED, + * but {@code path} itself is marked collapsed. */ protected void setExpandedState(TreePath path, boolean state) { if(path != null) { @@ -3636,9 +3651,12 @@ public class JTree extends JComponent implements Scrollable, Accessible } /** - * Returns an Enumeration of TreePaths + * Returns an {@code Enumeration} of {@code TreePaths} * that have been expanded that - * are descendants of parent. + * are descendants of {@code parent}. + * + * @param parent a path + * @return the {@code Enumeration} of {@code TreePaths} */ protected Enumeration getDescendantToggledPaths(TreePath parent) @@ -3701,6 +3719,8 @@ public class JTree extends JComponent implements Scrollable, Accessible *

    * For more information on what expanded state means, see the * JTree description above. + * + * @return the instance of {@code TreeModelHandler} */ protected TreeModelListener createTreeModelListener() { return new TreeModelHandler(); @@ -3711,6 +3731,9 @@ public class JTree extends JComponent implements Scrollable, Accessible * path. If includePath is true and * path is selected, it will be removed from the selection. * + * @param path a path + * @param includePath is {@code true} and {@code path} is selected, + * it will be removed from the selection. * @return true if a descendant was selected * @since 1.3 */ @@ -3891,6 +3914,9 @@ public class JTree extends JComponent implements Scrollable, Accessible * elements are added is children, otherwise if children * is a hashtable all the key/value pairs are added in the order * Enumeration returns them. + * + * @param parent the parent node + * @param children the children */ public static void createChildren(DefaultMutableTreeNode parent, Object children) { @@ -4113,6 +4139,9 @@ public class JTree extends JComponent implements Scrollable, Accessible TreePath leadSelectionPath; Accessible leadSelectionAccessible; + /** + * Constructs {@code AccessibleJTree} + */ public AccessibleJTree() { // Add a tree model listener for JTree TreeModel model = JTree.this.getModel(); @@ -4551,7 +4580,11 @@ public class JTree extends JComponent implements Scrollable, Accessible private boolean isLeaf = false; /** - * Constructs an AccessibleJTreeNode + * Constructs an AccessibleJTreeNode + * + * @param t an instance of {@code JTree} + * @param p an instance of {@code TreePath} + * @param ap an instance of {@code Accessible} * @since 1.4 */ public AccessibleJTreeNode(JTree t, TreePath p, Accessible ap) { @@ -5183,6 +5216,11 @@ public class JTree extends JComponent implements Scrollable, Accessible } } + /** + * Returns the relative location of the node + * + * @return the relative location of the node + */ protected Point getLocationInJTree() { Rectangle r = tree.getPathBounds(path); if (r != null) { diff --git a/jdk/src/share/classes/javax/swing/JViewport.java b/jdk/src/share/classes/javax/swing/JViewport.java index 5b019699ee6..2875d95918d 100644 --- a/jdk/src/share/classes/javax/swing/JViewport.java +++ b/jdk/src/share/classes/javax/swing/JViewport.java @@ -97,6 +97,7 @@ import java.io.Serializable; * @author Hans Muller * @author Philip Milne * @see JScrollPane + * @since 1.2 */ @SuppressWarnings("serial") // Same-version serialization only public class JViewport extends JComponent implements Accessible diff --git a/jdk/src/share/classes/javax/swing/JWindow.java b/jdk/src/share/classes/javax/swing/JWindow.java index 4de51d23a5c..cf95a417fd5 100644 --- a/jdk/src/share/classes/javax/swing/JWindow.java +++ b/jdk/src/share/classes/javax/swing/JWindow.java @@ -89,6 +89,7 @@ import javax.accessibility.*; * description: A toplevel window which has no system border or controls. * * @author David Kloba + * @since 1.2 */ @SuppressWarnings("serial") public class JWindow extends Window implements Accessible, diff --git a/jdk/src/share/classes/javax/swing/KeyStroke.java b/jdk/src/share/classes/javax/swing/KeyStroke.java index e9f846c3d9c..24969f76aec 100644 --- a/jdk/src/share/classes/javax/swing/KeyStroke.java +++ b/jdk/src/share/classes/javax/swing/KeyStroke.java @@ -60,6 +60,7 @@ import java.awt.event.KeyEvent; * * @author Arnaud Weber * @author David Mendenhall + * @since 1.2 */ @SuppressWarnings("serial") // Same-version serialization only public class KeyStroke extends AWTKeyStroke { diff --git a/jdk/src/share/classes/javax/swing/ListCellRenderer.java b/jdk/src/share/classes/javax/swing/ListCellRenderer.java index 8f389412158..79cfa2ac348 100644 --- a/jdk/src/share/classes/javax/swing/ListCellRenderer.java +++ b/jdk/src/share/classes/javax/swing/ListCellRenderer.java @@ -85,6 +85,7 @@ import java.awt.Component; * @see DefaultListCellRenderer * * @author Hans Muller + * @since 1.2 */ public interface ListCellRenderer { diff --git a/jdk/src/share/classes/javax/swing/ListModel.java b/jdk/src/share/classes/javax/swing/ListModel.java index 84d4b9025b5..231fa10b121 100644 --- a/jdk/src/share/classes/javax/swing/ListModel.java +++ b/jdk/src/share/classes/javax/swing/ListModel.java @@ -39,6 +39,7 @@ import javax.swing.event.ListDataListener; * * @author Hans Muller * @see JList + * @since 1.2 */ public interface ListModel { diff --git a/jdk/src/share/classes/javax/swing/ListSelectionModel.java b/jdk/src/share/classes/javax/swing/ListSelectionModel.java index ed88544cd6a..c4d91a4b50d 100644 --- a/jdk/src/share/classes/javax/swing/ListSelectionModel.java +++ b/jdk/src/share/classes/javax/swing/ListSelectionModel.java @@ -41,6 +41,7 @@ import javax.swing.event.*; * @author Hans Muller * @author Philip Milne * @see DefaultListSelectionModel + * @since 1.2 */ public interface ListSelectionModel @@ -134,18 +135,25 @@ public interface ListSelectionModel /** * Returns the first selected index or -1 if the selection is empty. + * + * @return the first selected index or -1 if the selection is empty. */ int getMinSelectionIndex(); /** * Returns the last selected index or -1 if the selection is empty. + * + * @return the last selected index or -1 if the selection is empty. */ int getMaxSelectionIndex(); /** * Returns true if the specified index is selected. + * + * @param index an index + * @return {@code true} if the specified index is selected */ boolean isSelectedIndex(int index); @@ -158,6 +166,7 @@ public interface ListSelectionModel * indices specially, e.g. Windows95 displays the lead index with a * dotted yellow outline. * + * @return the anchor selection index * @see #getLeadSelectionIndex * @see #setSelectionInterval * @see #addSelectionInterval @@ -168,6 +177,7 @@ public interface ListSelectionModel /** * Set the anchor selection index. * + * @param index the anchor selection index * @see #getAnchorSelectionIndex */ void setAnchorSelectionIndex(int index); @@ -177,6 +187,7 @@ public interface ListSelectionModel * Return the second index argument from the most recent call to * setSelectionInterval(), addSelectionInterval() or removeSelectionInterval(). * + * @return the lead selection index. * @see #getAnchorSelectionIndex * @see #setSelectionInterval * @see #addSelectionInterval @@ -186,6 +197,7 @@ public interface ListSelectionModel /** * Set the lead selection index. * + * @param index the lead selection index * @see #getLeadSelectionIndex */ void setLeadSelectionIndex(int index); @@ -200,20 +212,30 @@ public interface ListSelectionModel /** * Returns true if no indices are selected. + * + * @return {@code true} if no indices are selected. */ boolean isSelectionEmpty(); /** - * Insert length indices beginning before/after index. This is typically + * Insert {@code length} indices beginning before/after {@code index}. This is typically * called to sync the selection model with a corresponding change * in the data model. + * + * @param index the beginning of the interval + * @param length the length of the interval + * @param before if {@code true}, interval inserts before the {@code index}, + * otherwise, interval inserts after the {@code index} */ void insertIndexInterval(int index, int length, boolean before); /** - * Remove the indices in the interval index0,index1 (inclusive) from + * Remove the indices in the interval {@code index0,index1} (inclusive) from * the selection model. This is typically called to sync the selection * model width a corresponding change in the data model. + * + * @param index0 the beginning of the interval + * @param index1 the end of the interval */ void removeIndexInterval(int index0, int index1); @@ -272,6 +294,7 @@ public interface ListSelectionModel * In this mode, there's no restriction on what can be selected. * * + * @param selectionMode the selection mode * @see #getSelectionMode * @throws IllegalArgumentException if the selection mode isn't * one of those allowed diff --git a/jdk/src/share/classes/javax/swing/LookAndFeel.java b/jdk/src/share/classes/javax/swing/LookAndFeel.java index 16f4308f263..30c4c83dfc9 100644 --- a/jdk/src/share/classes/javax/swing/LookAndFeel.java +++ b/jdk/src/share/classes/javax/swing/LookAndFeel.java @@ -147,6 +147,7 @@ import java.util.StringTokenizer; * * @author Tom Ball * @author Hans Muller + * @since 1.2 */ public abstract class LookAndFeel { diff --git a/jdk/src/share/classes/javax/swing/MenuElement.java b/jdk/src/share/classes/javax/swing/MenuElement.java index 7141da85223..4dc310b55bc 100644 --- a/jdk/src/share/classes/javax/swing/MenuElement.java +++ b/jdk/src/share/classes/javax/swing/MenuElement.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2003, 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 @@ -29,55 +29,66 @@ import java.awt.event.*; /** * Any component that can be placed into a menu should implement this interface. - * This interface is used by MenuSelectionManager + * This interface is used by {@code MenuSelectionManager} * to handle selection and navigation in menu hierarchies. * * @author Arnaud Weber + * @since 1.2 */ public interface MenuElement { /** - * Processes a mouse event. event is a MouseEvent - * with source being the receiving element's component. - * path is the path of the receiving element in the menu - * hierarchy including the receiving element itself. - * manager is the MenuSelectionManager - * for the menu hierarchy. - * This method should process the MouseEvent and change - * the menu selection if necessary - * by using MenuSelectionManager's API - * Note: you do not have to forward the event to sub-components. - * This is done automatically by the MenuSelectionManager. + * Processes a mouse event. {@code event} is a {@code MouseEvent} with + * source being the receiving element's component. {@code path} is the + * path of the receiving element in the menu hierarchy including the + * receiving element itself. {@code manager} is the + * {@code MenuSelectionManager}for the menu hierarchy. This method should + * process the {@code MouseEvent} and change the menu selection if necessary + * by using {@code MenuSelectionManager}'s API Note: you do not have to + * forward the event to sub-components. This is done automatically by the + * {@code MenuSelectionManager}. + * + * @param event a {@code MouseEvent} to be processed + * @param path the path of the receiving element in the menu hierarchy + * @param manager the {@code MenuSelectionManager} for the menu hierarchy */ - public void processMouseEvent(MouseEvent event,MenuElement path[],MenuSelectionManager manager); + public void processMouseEvent(MouseEvent event, MenuElement path[], MenuSelectionManager manager); /** * Process a key event. + * + * @param event a {@code KeyEvent} to be processed + * @param path the path of the receiving element in the menu hierarchy + * @param manager the {@code MenuSelectionManager} for the menu hierarchy */ - public void processKeyEvent(KeyEvent event,MenuElement path[],MenuSelectionManager manager); + public void processKeyEvent(KeyEvent event, MenuElement path[], MenuSelectionManager manager); /** - * Call by the MenuSelectionManager when the - * MenuElement is added or remove from - * the menu selection. + * Call by the {@code MenuSelectionManager} when the {@code MenuElement} is + * added or removed from the menu selection. + * + * @param isIncluded can be used to indicate if this {@code MenuElement} is + * active (if it is a menu) or is on the part of the menu path that + * changed (if it is a menu item). */ public void menuSelectionChanged(boolean isIncluded); /** - * This method should return an array containing the sub-elements for the receiving menu element + * This method should return an array containing the sub-elements for the + * receiving menu element. * - * @return an array of MenuElements + * @return an array of {@code MenuElement}s */ public MenuElement[] getSubElements(); /** - * This method should return the java.awt.Component used to paint the receiving element. - * The returned component will be used to convert events and detect if an event is inside - * a MenuElement's component. + * This method should return the {@code java.awt.Component} used to paint the + * receiving element. The returned component will be used to convert events + * and detect if an event is inside a {@code MenuElement}'s component. * - * @return the Component value + * @return the {@code Component} value */ public Component getComponent(); } diff --git a/jdk/src/share/classes/javax/swing/MenuSelectionManager.java b/jdk/src/share/classes/javax/swing/MenuSelectionManager.java index 67e35dc918e..dda2736eb49 100644 --- a/jdk/src/share/classes/javax/swing/MenuSelectionManager.java +++ b/jdk/src/share/classes/javax/swing/MenuSelectionManager.java @@ -36,6 +36,7 @@ import sun.swing.SwingUtilities2; * A MenuSelectionManager owns the selection in menu hierarchy. * * @author Arnaud Weber + * @since 1.2 */ public class MenuSelectionManager { private Vector selection = new Vector(); @@ -79,6 +80,7 @@ public class MenuSelectionManager { * generated is always "this". */ protected transient ChangeEvent changeEvent = null; + /** The collection of registered listeners */ protected EventListenerList listenerList = new EventListenerList(); /** @@ -476,7 +478,11 @@ public class MenuSelectionManager { } /** - * Return true if c is part of the currently used menu + * Return true if {@code c} is part of the currently used menu + * + * @param c a {@code Component} + * @return true if {@code c} is part of the currently used menu, + * false otherwise */ public boolean isComponentPartOfCurrentMenu(Component c) { if(selection.size() > 0) { diff --git a/jdk/src/share/classes/javax/swing/MultiUIDefaults.java b/jdk/src/share/classes/javax/swing/MultiUIDefaults.java index f4a30a1e3f5..79306b14b5d 100644 --- a/jdk/src/share/classes/javax/swing/MultiUIDefaults.java +++ b/jdk/src/share/classes/javax/swing/MultiUIDefaults.java @@ -190,18 +190,18 @@ class MultiUIDefaults extends UIDefaults @Override public synchronized String toString() { - StringBuffer buf = new StringBuffer(); - buf.append("{"); + StringBuilder sb = new StringBuilder(); + sb.append("{"); Enumeration keys = keys(); while (keys.hasMoreElements()) { Object key = keys.nextElement(); - buf.append(key + "=" + get(key) + ", "); + sb.append(key + "=" + get(key) + ", "); } - int length = buf.length(); + int length = sb.length(); if (length > 1) { - buf.delete(length-2, length); + sb.delete(length-2, length); } - buf.append("}"); - return buf.toString(); + sb.append("}"); + return sb.toString(); } } diff --git a/jdk/src/share/classes/javax/swing/MutableComboBoxModel.java b/jdk/src/share/classes/javax/swing/MutableComboBoxModel.java index 09fb03713fb..a98dea117a5 100644 --- a/jdk/src/share/classes/javax/swing/MutableComboBoxModel.java +++ b/jdk/src/share/classes/javax/swing/MutableComboBoxModel.java @@ -30,6 +30,7 @@ package javax.swing; * @param the type of the elements of this model * * @author Tom Santos + * @since 1.2 */ public interface MutableComboBoxModel extends ComboBoxModel { diff --git a/jdk/src/share/classes/javax/swing/OverlayLayout.java b/jdk/src/share/classes/javax/swing/OverlayLayout.java index 6f3735cd50f..b62bb5faf17 100644 --- a/jdk/src/share/classes/javax/swing/OverlayLayout.java +++ b/jdk/src/share/classes/javax/swing/OverlayLayout.java @@ -50,6 +50,7 @@ import java.io.Serializable; * Please see {@link java.beans.XMLEncoder}. * * @author Timothy Prinzing + * @since 1.2 */ @SuppressWarnings("serial") // Same-version serialization only public class OverlayLayout implements LayoutManager2,Serializable { diff --git a/jdk/src/share/classes/javax/swing/Painter.java b/jdk/src/share/classes/javax/swing/Painter.java index bd1b5a19d31..946819313cb 100644 --- a/jdk/src/share/classes/javax/swing/Painter.java +++ b/jdk/src/share/classes/javax/swing/Painter.java @@ -59,6 +59,7 @@ import java.awt.Graphics2D; *

    This interface makes no guarantees of threadsafety.

    * * @author rbair + * @since 1.7 */ public interface Painter { /** diff --git a/jdk/src/share/classes/javax/swing/PopupFactory.java b/jdk/src/share/classes/javax/swing/PopupFactory.java index 20b21c7a274..840d7d14962 100644 --- a/jdk/src/share/classes/javax/swing/PopupFactory.java +++ b/jdk/src/share/classes/javax/swing/PopupFactory.java @@ -25,10 +25,15 @@ package javax.swing; +import sun.awt.EmbeddedFrame; +import sun.awt.OSInfo; +import sun.swing.SwingAccessor; + import java.applet.Applet; import java.awt.*; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; +import java.security.AccessController; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -56,6 +61,16 @@ import static javax.swing.ClientPropertyKey.PopupFactory_FORCE_HEAVYWEIGHT_POPUP * @since 1.4 */ public class PopupFactory { + + static { + SwingAccessor.setPopupFactoryAccessor(new SwingAccessor.PopupFactoryAccessor() { + @Override + public Popup getHeavyWeightPopup(PopupFactory factory, Component owner, + Component contents, int ownerX, int ownerY) { + return factory.getPopup(owner, contents, ownerX, ownerY, HEAVY_WEIGHT_POPUP); + } + }); + } /** * The shared instanceof PopupFactory is per * AppContext. This is the key used in the @@ -226,7 +241,12 @@ public class PopupFactory { case MEDIUM_WEIGHT_POPUP: return getMediumWeightPopup(owner, contents, ownerX, ownerY); case HEAVY_WEIGHT_POPUP: - return getHeavyWeightPopup(owner, contents, ownerX, ownerY); + Popup popup = getHeavyWeightPopup(owner, contents, ownerX, ownerY); + if ((AccessController.doPrivileged(OSInfo.getOSTypeAction()) == + OSInfo.OSType.MACOSX) && (EmbeddedFrame.getAppletIfAncestorOf(owner) != null)) { + ((HeavyWeightPopup)popup).setCacheEnabled(false); + } + return popup; } return null; } @@ -294,6 +314,8 @@ public class PopupFactory { private static final Object heavyWeightPopupCacheKey = new StringBuffer("PopupFactory.heavyWeightPopupCache"); + private volatile boolean isCacheEnabled = true; + /** * Returns either a new or recycled Popup containing * the specified children. @@ -448,12 +470,23 @@ public class PopupFactory { } } + /** + * Enables or disables cache for current object. + */ + void setCacheEnabled(boolean enable) { + isCacheEnabled = enable; + } + // // Popup methods // public void hide() { super.hide(); - recycleHeavyWeightPopup(this); + if (isCacheEnabled) { + recycleHeavyWeightPopup(this); + } else { + this._dispose(); + } } /** diff --git a/jdk/src/share/classes/javax/swing/ProgressMonitor.java b/jdk/src/share/classes/javax/swing/ProgressMonitor.java index 889f30d734a..506b443b4f5 100644 --- a/jdk/src/share/classes/javax/swing/ProgressMonitor.java +++ b/jdk/src/share/classes/javax/swing/ProgressMonitor.java @@ -77,6 +77,7 @@ import javax.swing.text.*; * @see ProgressMonitorInputStream * @author James Gosling * @author Lynn Monsanto (accessibility) + * @since 1.2 */ public class ProgressMonitor implements Accessible { diff --git a/jdk/src/share/classes/javax/swing/ProgressMonitorInputStream.java b/jdk/src/share/classes/javax/swing/ProgressMonitorInputStream.java index 67fc068d15e..3edb0e1f35b 100644 --- a/jdk/src/share/classes/javax/swing/ProgressMonitorInputStream.java +++ b/jdk/src/share/classes/javax/swing/ProgressMonitorInputStream.java @@ -60,6 +60,7 @@ import java.awt.Component; * @see ProgressMonitor * @see JOptionPane * @author James Gosling + * @since 1.2 */ public class ProgressMonitorInputStream extends FilterInputStream { diff --git a/jdk/src/share/classes/javax/swing/Renderer.java b/jdk/src/share/classes/javax/swing/Renderer.java index e0c3d78305e..41203f29493 100644 --- a/jdk/src/share/classes/javax/swing/Renderer.java +++ b/jdk/src/share/classes/javax/swing/Renderer.java @@ -32,6 +32,7 @@ import java.awt.Component; * "rendering" (displaying) a value. * * @author Arnaud Weber + * @since 1.2 */ public interface Renderer { /** diff --git a/jdk/src/share/classes/javax/swing/RepaintManager.java b/jdk/src/share/classes/javax/swing/RepaintManager.java index c65c826eb45..c1340d17c5b 100644 --- a/jdk/src/share/classes/javax/swing/RepaintManager.java +++ b/jdk/src/share/classes/javax/swing/RepaintManager.java @@ -60,6 +60,7 @@ import sun.swing.SwingUtilities2.RepaintListener; * appropriate addDirtyRegion method. * * @author Arnaud Weber + * @since 1.2 */ public class RepaintManager { @@ -331,6 +332,7 @@ public class RepaintManager * for the event dispatching thread that will validate the components * first isValidateRoot() ancestor. * + * @param invalidComponent a component * @see JComponent#isValidateRoot * @see #removeInvalidComponent */ @@ -374,6 +376,7 @@ public class RepaintManager /** * Remove a component from the list of invalid components. * + * @param component a component * @see #addInvalidComponent */ public synchronized void removeInvalidComponent(JComponent component) { @@ -610,9 +613,13 @@ public class RepaintManager return false; } - /** Return the current dirty region for a component. - * Return an empty rectangle if the component is not - * dirty. + /** + * Return the current dirty region for a component. + * Return an empty rectangle if the component is not + * dirty. + * + * @param aComponent a component + * @return the region */ public Rectangle getDirtyRegion(JComponent aComponent) { RepaintManager delegate = getDelegate(aComponent); @@ -632,6 +639,8 @@ public class RepaintManager /** * Mark a component completely dirty. aComponent will be * completely painted during the next paintDirtyRegions() call. + * + * @param aComponent a component */ public void markCompletelyDirty(JComponent aComponent) { RepaintManager delegate = getDelegate(aComponent); @@ -645,6 +654,8 @@ public class RepaintManager /** * Mark a component completely clean. aComponent will not * get painted during the next paintDirtyRegions() call. + * + * @param aComponent a component */ public void markCompletelyClean(JComponent aComponent) { RepaintManager delegate = getDelegate(aComponent); @@ -662,6 +673,10 @@ public class RepaintManager * painted during the next paintDirtyRegions(). If computing dirty regions is * expensive for your component, use this method and avoid computing dirty region * if it return true. + * + * @param aComponent a component + * @return {@code true} if aComponent will be completely + * painted during the next paintDirtyRegions(). */ public boolean isCompletelyDirty(JComponent aComponent) { RepaintManager delegate = getDelegate(aComponent); @@ -975,20 +990,26 @@ public class RepaintManager * @return a String representation of this object */ public synchronized String toString() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); if(dirtyComponents != null) sb.append("" + dirtyComponents); return sb.toString(); } - /** + /** * Return the offscreen buffer that should be used as a double buffer with * the component c. * By default there is a double buffer per RepaintManager. * The buffer might be smaller than (proposedWidth,proposedHeight) * This happens when the maximum double buffer size as been set for the receiving * repaint manager. + * + * @param c the component + * @param proposedWidth the width of the buffer + * @param proposedHeight the height of the buffer + * + * @return the image */ public Image getOffscreenBuffer(Component c,int proposedWidth,int proposedHeight) { RepaintManager delegate = getDelegate(c); @@ -998,18 +1019,23 @@ public class RepaintManager return _getOffscreenBuffer(c, proposedWidth, proposedHeight); } - /** - * Return a volatile offscreen buffer that should be used as a - * double buffer with the specified component c. - * The image returned will be an instance of VolatileImage, or null - * if a VolatileImage object could not be instantiated. - * This buffer might be smaller than (proposedWidth,proposedHeight). - * This happens when the maximum double buffer size has been set for this - * repaint manager. - * - * @see java.awt.image.VolatileImage - * @since 1.4 - */ + /** + * Return a volatile offscreen buffer that should be used as a + * double buffer with the specified component c. + * The image returned will be an instance of VolatileImage, or null + * if a VolatileImage object could not be instantiated. + * This buffer might be smaller than (proposedWidth,proposedHeight). + * This happens when the maximum double buffer size has been set for this + * repaint manager. + * + * @param c the component + * @param proposedWidth the width of the buffer + * @param proposedHeight the height of the buffer + * + * @return the volatile image + * @see java.awt.image.VolatileImage + * @since 1.4 + */ public Image getVolatileOffscreenBuffer(Component c, int proposedWidth,int proposedHeight) { RepaintManager delegate = getDelegate(c); @@ -1104,7 +1130,11 @@ public class RepaintManager } - /** Set the maximum double buffer size. **/ + /** + * Set the maximum double buffer size. + * + * @param d the dimension + */ public void setDoubleBufferMaximumSize(Dimension d) { doubleBufferMaxSize = d; if (doubleBufferMaxSize == null) { diff --git a/jdk/src/share/classes/javax/swing/RootPaneContainer.java b/jdk/src/share/classes/javax/swing/RootPaneContainer.java index c728acb2e2a..76dc2286f87 100644 --- a/jdk/src/share/classes/javax/swing/RootPaneContainer.java +++ b/jdk/src/share/classes/javax/swing/RootPaneContainer.java @@ -77,6 +77,7 @@ import java.awt.Container; * @see JInternalFrame * * @author Hans Muller + * @since 1.2 */ public interface RootPaneContainer { @@ -132,6 +133,7 @@ public interface RootPaneContainer * Generally implemented with
          *    getRootPane().setLayeredPane(layeredPane);
    * + * @param layeredPane the layered pane * @exception java.awt.IllegalComponentStateException (a runtime * exception) if the layered pane parameter is null * @see #getLayeredPane @@ -162,6 +164,7 @@ public interface RootPaneContainer * Generally implemented with * getRootPane().setGlassPane(glassPane); * + * @param glassPane the glass pane * @see #getGlassPane * @see JRootPane#setGlassPane */ diff --git a/jdk/src/share/classes/javax/swing/RowFilter.java b/jdk/src/share/classes/javax/swing/RowFilter.java index 8201add8bdc..bdcdb15786b 100644 --- a/jdk/src/share/classes/javax/swing/RowFilter.java +++ b/jdk/src/share/classes/javax/swing/RowFilter.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 @@ -159,6 +159,8 @@ public abstract class RowFilter { * {@link java.util.regex.Pattern} for a complete description of * the supported regular-expression constructs. * + * @param the type of the model to which the {@code RowFilter} applies + * @param the type of the identifier passed to the {@code RowFilter} * @param regex the regular expression to filter on * @param indices the indices of the values to check. If not supplied all * values are evaluated @@ -186,6 +188,8 @@ public abstract class RowFilter { * RowFilter.dateFilter(ComparisonType.AFTER, new Date()); * * + * @param the type of the model to which the {@code RowFilter} applies + * @param the type of the identifier passed to the {@code RowFilter} * @param type the type of comparison to perform * @param date the date to compare against * @param indices the indices of the values to check. If not supplied all @@ -214,7 +218,10 @@ public abstract class RowFilter { * RowFilter.numberFilter(ComparisonType.EQUAL, 10); * * + * @param the type of the model to which the {@code RowFilter} applies + * @param the type of the identifier passed to the {@code RowFilter} * @param type the type of comparison to perform + * @param number a {@code Number} value to compare against * @param indices the indices of the values to check. If not supplied all * values are evaluated * @return a RowFilter implementing the specified criteria @@ -241,6 +248,8 @@ public abstract class RowFilter { * RowFilter<Object,Object> fooBarFilter = RowFilter.orFilter(filters); * * + * @param the type of the model to which the {@code RowFilter} applies + * @param the type of the identifier passed to the {@code RowFilter} * @param filters the RowFilters to test * @throws IllegalArgumentException if any of the filters * are null @@ -267,6 +276,8 @@ public abstract class RowFilter { * RowFilter<Object,Object> fooBarFilter = RowFilter.andFilter(filters); * * + * @param the type of the model the {@code RowFilter} applies to + * @param the type of the identifier passed to the {@code RowFilter} * @param filters the RowFilters to test * @return a RowFilter implementing the specified criteria * @throws IllegalArgumentException if any of the filters @@ -283,6 +294,8 @@ public abstract class RowFilter { * Returns a RowFilter that includes entries if the * supplied filter does not include the entry. * + * @param the type of the model to which the {@code RowFilter} applies + * @param the type of the identifier passed to the {@code RowFilter} * @param filter the RowFilter to negate * @return a RowFilter implementing the specified criteria * @throws IllegalArgumentException if filter is diff --git a/jdk/src/share/classes/javax/swing/ScrollPaneConstants.java b/jdk/src/share/classes/javax/swing/ScrollPaneConstants.java index 6fef77a1b4b..4f8c66f4ec6 100644 --- a/jdk/src/share/classes/javax/swing/ScrollPaneConstants.java +++ b/jdk/src/share/classes/javax/swing/ScrollPaneConstants.java @@ -30,6 +30,7 @@ package javax.swing; * Constants used with the JScrollPane component. * * @author Hans Muller + * @since 1.2 */ public interface ScrollPaneConstants { diff --git a/jdk/src/share/classes/javax/swing/ScrollPaneLayout.java b/jdk/src/share/classes/javax/swing/ScrollPaneLayout.java index 71eda4b9c9a..4d353253a3c 100644 --- a/jdk/src/share/classes/javax/swing/ScrollPaneLayout.java +++ b/jdk/src/share/classes/javax/swing/ScrollPaneLayout.java @@ -56,6 +56,7 @@ import java.io.Serializable; * @see JViewport * * @author Hans Muller + * @since 1.2 */ @SuppressWarnings("serial") // Same-version serialization only public class ScrollPaneLayout @@ -168,6 +169,8 @@ public class ScrollPaneLayout * }; * scrollpane.setLayout(mySPLayout): * + * + * @param sp an instance of the {@code JScrollPane} */ public void syncWithScrollPane(JScrollPane sp) { viewport = sp.getViewport(); @@ -1106,6 +1109,7 @@ public class ScrollPaneLayout * Returns the bounds of the border around the specified scroll pane's * viewport. * + * @param scrollpane an instance of the {@code JScrollPane} * @return the size and position of the viewport border * @deprecated As of JDK version Swing1.1 * replaced by JScrollPane.getViewportBorderBounds(). diff --git a/jdk/src/share/classes/javax/swing/Scrollable.java b/jdk/src/share/classes/javax/swing/Scrollable.java index cf2214bdbd2..c5956367fe6 100644 --- a/jdk/src/share/classes/javax/swing/Scrollable.java +++ b/jdk/src/share/classes/javax/swing/Scrollable.java @@ -39,6 +39,7 @@ import java.awt.Rectangle; * @see JScrollPane * @see JScrollBar * @author Hans Muller + * @since 1.2 */ public interface Scrollable { diff --git a/jdk/src/share/classes/javax/swing/SingleSelectionModel.java b/jdk/src/share/classes/javax/swing/SingleSelectionModel.java index becefe7c029..251b7c1d7e2 100644 --- a/jdk/src/share/classes/javax/swing/SingleSelectionModel.java +++ b/jdk/src/share/classes/javax/swing/SingleSelectionModel.java @@ -31,6 +31,7 @@ import javax.swing.event.*; * A model that supports at most one indexed selection. * * @author Dave Moore + * @since 1.2 */ public interface SingleSelectionModel { /** diff --git a/jdk/src/share/classes/javax/swing/SizeRequirements.java b/jdk/src/share/classes/javax/swing/SizeRequirements.java index d4a590bfd0f..a592ef6b563 100644 --- a/jdk/src/share/classes/javax/swing/SizeRequirements.java +++ b/jdk/src/share/classes/javax/swing/SizeRequirements.java @@ -92,6 +92,7 @@ import java.io.Serializable; * @see Component#getAlignmentY * * @author Timothy Prinzing + * @since 1.2 */ @SuppressWarnings("serial") // Same-version serialization only public class SizeRequirements implements Serializable { diff --git a/jdk/src/share/classes/javax/swing/SortingFocusTraversalPolicy.java b/jdk/src/share/classes/javax/swing/SortingFocusTraversalPolicy.java index 2c4850b8ff4..c542ebc48f8 100644 --- a/jdk/src/share/classes/javax/swing/SortingFocusTraversalPolicy.java +++ b/jdk/src/share/classes/javax/swing/SortingFocusTraversalPolicy.java @@ -100,6 +100,8 @@ public class SortingFocusTraversalPolicy /** * Constructs a SortingFocusTraversalPolicy with the specified Comparator. + * + * @param comparator the {@code Comparator} to sort by */ public SortingFocusTraversalPolicy(Comparator comparator) { this.comparator = comparator; diff --git a/jdk/src/share/classes/javax/swing/Spring.java b/jdk/src/share/classes/javax/swing/Spring.java index 75b2a510f00..366b95fec78 100644 --- a/jdk/src/share/classes/javax/swing/Spring.java +++ b/jdk/src/share/classes/javax/swing/Spring.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -547,9 +547,10 @@ public abstract class Spring { /** - * Returns -s: a spring running in the opposite direction to s. + * Returns {@code -s}: a spring running in the opposite direction to {@code s}. * - * @return -s: a spring running in the opposite direction to s + * @param s a {@code Spring} object + * @return {@code -s}: a spring running in the opposite direction to {@code s} * * @see Spring */ @@ -582,6 +583,8 @@ public abstract class Spring { * the values of s1 and s2 is exactly equal to * the value of s3. * + * @param s1 a {@code Spring} object + * @param s2 a {@code Spring} object * @return s1+s2: a spring representing s1 and s2 in series * * @see Spring @@ -591,11 +594,13 @@ public abstract class Spring { } /** - * Returns max(s1, s2): a spring whose value is always greater than (or equal to) - * the values of both s1 and s2. + * Returns {@code max(s1, s2)}: a spring whose value is always greater than (or equal to) + * the values of both {@code s1} and {@code s2}. * - * @return max(s1, s2): a spring whose value is always greater than (or equal to) - * the values of both s1 and s2 + * @param s1 a {@code Spring} object + * @param s2 a {@code Spring} object + * @return {@code max(s1, s2)}: a spring whose value is always greater than (or equal to) + * the values of both {@code s1} and {@code s2} * @see Spring */ public static Spring max(Spring s1, Spring s2) { diff --git a/jdk/src/share/classes/javax/swing/SwingConstants.java b/jdk/src/share/classes/javax/swing/SwingConstants.java index 1865fec54bf..390d2e6b828 100644 --- a/jdk/src/share/classes/javax/swing/SwingConstants.java +++ b/jdk/src/share/classes/javax/swing/SwingConstants.java @@ -31,6 +31,7 @@ package javax.swing; * * @author Jeff Dinkins * @author Ralph Kar (orientation support) + * @since 1.2 */ public interface SwingConstants { diff --git a/jdk/src/share/classes/javax/swing/SwingUtilities.java b/jdk/src/share/classes/javax/swing/SwingUtilities.java index 7042c31bb2a..fb7b2820fd2 100644 --- a/jdk/src/share/classes/javax/swing/SwingUtilities.java +++ b/jdk/src/share/classes/javax/swing/SwingUtilities.java @@ -49,6 +49,7 @@ import sun.awt.AppContext; * A collection of utility methods for Swing. * * @author unknown + * @since 1.2 */ public class SwingUtilities implements SwingConstants { @@ -103,15 +104,23 @@ public class SwingUtilities implements SwingConstants } /** - * Return true if a contains b + * Return {@code true} if @{code a} contains {@code b} + * + * @param a the first rectangle + * @param b the second rectangle + * + * @return {@code true} if @{code a} contains {@code b} */ - public static final boolean isRectangleContainingRectangle(Rectangle a,Rectangle b) { + public static boolean isRectangleContainingRectangle(Rectangle a,Rectangle b) { return b.x >= a.x && (b.x + b.width) <= (a.x + a.width) && b.y >= a.y && (b.y + b.height) <= (a.y + a.height); } /** - * Return the rectangle (0,0,bounds.width,bounds.height) for the component aComponent + * Return the rectangle (0,0,bounds.width,bounds.height) for the component {@code aComponent} + * + * @param aComponent a component + * @return the local bounds for the component {@code aComponent} */ public static Rectangle getLocalBounds(Component aComponent) { Rectangle b = new Rectangle(aComponent.getBounds()); @@ -165,6 +174,12 @@ public class SwingUtilities implements SwingConstants * root component coordinate system. * If both source and destination are {@code null}, return aPoint * without any conversion. + * + * @param source the source component + * @param aPoint the point + * @param destination the destination component + * + * @return the converted coordinate */ public static Point convertPoint(Component source,Point aPoint,Component destination) { Point p; @@ -196,6 +211,13 @@ public class SwingUtilities implements SwingConstants * root component coordinate system. * If both source and destination are {@code null}, return (x,y) * without any conversion. + * + * @param source the source component + * @param x the x-coordinate of the point + * @param y the y-coordinate of the point + * @param destination the destination component + * + * @return the converted coordinate */ public static Point convertPoint(Component source,int x, int y,Component destination) { Point point = new Point(x,y); @@ -211,6 +233,12 @@ public class SwingUtilities implements SwingConstants * root component coordinate system. * If both source and destination are {@code null}, return aRectangle * without any conversion. + * + * @param source the source component + * @param aRectangle a rectangle + * @param destination the destination component + * + * @return the converted rectangle */ public static Rectangle convertRectangle(Component source,Rectangle aRectangle,Component destination) { Point point = new Point(aRectangle.x,aRectangle.y); @@ -222,6 +250,12 @@ public class SwingUtilities implements SwingConstants * Convenience method for searching above comp in the * component hierarchy and returns the first object of class c it * finds. Can return {@code null}, if a class c cannot be found. + * + * @param c the class of a component + * @param comp the component + * + * @return the ancestor of the {@code comp}, + * or {@code null} if {@code c} cannot be found. */ public static Container getAncestorOfClass(Class c, Component comp) { @@ -238,6 +272,12 @@ public class SwingUtilities implements SwingConstants * Convenience method for searching above comp in the * component hierarchy and returns the first object of name it * finds. Can return {@code null}, if name cannot be found. + * + * @param name the name of a component + * @param comp the component + * + * @return the ancestor of the {@code comp}, + * or {@code null} if {@code name} cannot be found. */ public static Container getAncestorNamed(String name, Component comp) { if(comp == null || name == null) @@ -260,6 +300,8 @@ public class SwingUtilities implements SwingConstants * @param parent the root component to begin the search * @param x the x target location * @param y the y target location + * + * @return the deepest component */ public static Component getDeepestComponentAt(Component parent, int x, int y) { if (!parent.contains(x, y)) { @@ -297,6 +339,12 @@ public class SwingUtilities implements SwingConstants * to destination if destination is non-{@code null} * use the translateMouseEvent() method to translate a mouse event from * one component to another without changing the source. + * + * @param source the source component + * @param sourceEvent the source mouse event + * @param destination the destination component + * + * @return the new mouse event */ public static MouseEvent convertMouseEvent(Component source, MouseEvent sourceEvent, @@ -456,7 +504,11 @@ public class SwingUtilities implements SwingConstants } /** - * Return true if a component a descends from a component b + * Return {@code true} if a component {@code a} descends from a component {@code b} + * + * @param a the first component + * @param b the second component + * @return {@code true} if a component {@code a} descends from a component {@code b} */ public static boolean isDescendingFrom(Component a,Component b) { if(a == b) @@ -531,6 +583,12 @@ public class SwingUtilities implements SwingConstants * Convenience returning an array of rect representing the regions within * rectA that do not overlap with rectB. If the * two Rects do not overlap, returns an empty array + * + * @param rectA the first rectangle + * @param rectB the second rectangle + * + * @return an array of rectangles representing the regions within {@code rectA} + * that do not overlap with {@code rectB}. */ public static Rectangle[] computeDifference(Rectangle rectA,Rectangle rectB) { if (rectB == null || !rectA.intersects(rectB) || isRectangleContainingRectangle(rectB,rectA)) { @@ -841,6 +899,21 @@ public class SwingUtilities implements SwingConstants * relative to the viewR rectangle. * The JComponents orientation (LEADING/TRAILING) will also be taken * into account and translated into LEFT/RIGHT values accordingly. + * + * @param c the component + * @param fm the instance of {@code FontMetrics} + * @param text the text + * @param icon the icon + * @param verticalAlignment the vertical alignment + * @param horizontalAlignment the horizontal alignment + * @param verticalTextPosition the vertical text position + * @param horizontalTextPosition the horizontal text position + * @param viewR the available rectangle + * @param iconR the rectangle for the icon + * @param textR the rectangle for the text + * @param textIconGap the gap between text and icon + * + * @return the possibly clipped version of the compound labels string */ public static String layoutCompoundLabel(JComponent c, FontMetrics fm, @@ -910,6 +983,20 @@ public class SwingUtilities implements SwingConstants * values in horizontalTextPosition (they will default to RIGHT) and in * horizontalAlignment (they will default to CENTER). * Use the other version of layoutCompoundLabel() instead. + * + * @param fm the instance of {@code FontMetrics} + * @param text the text + * @param icon the icon + * @param verticalAlignment the vertical alignment + * @param horizontalAlignment the horizontal alignment + * @param verticalTextPosition the vertical text position + * @param horizontalTextPosition the horizontal text position + * @param viewR the available rectangle + * @param iconR the rectangle for the icon + * @param textR the rectangle for the text + * @param textIconGap the gap between text and icon + * + * @return the possibly clipped version of the compound labels string */ public static String layoutCompoundLabel( FontMetrics fm, @@ -1219,6 +1306,8 @@ public class SwingUtilities implements SwingConstants * A simple minded look and feel change: ask each node in the tree * to updateUI() -- that is, to initialize its UI property * with the current look and feel. + * + * @param c the component */ public static void updateComponentTreeUI(Component c) { updateComponentTreeUI0(c); @@ -1284,6 +1373,7 @@ public class SwingUtilities implements SwingConstants *

    * Unlike the rest of Swing, this method can be invoked from any thread. * + * @param doRun the instance of {@code Runnable} * @see #invokeAndWait */ public static void invokeLater(Runnable doRun) { @@ -1334,6 +1424,7 @@ public class SwingUtilities implements SwingConstants * As of 1.3 this method is just a cover for * java.awt.EventQueue.invokeAndWait(). * + * @param doRun the instance of {@code Runnable} * @exception InterruptedException if we're interrupted while waiting for * the event dispatching thread to finish executing * doRun.run() @@ -1374,6 +1465,7 @@ public class SwingUtilities implements SwingConstants * Component.AccessibleAWTComponent.getAccessibleIndexInParent() instead * of using this method. * + * @param c the component * @return -1 of this object does not have an accessible parent. * Otherwise, the index of the child in its accessible parent. */ @@ -1386,6 +1478,8 @@ public class SwingUtilities implements SwingConstants * local coordinate Point, if one exists. * Otherwise returns null. * + * @param c the component + * @param p the local coordinate * @return the Accessible at the specified location, * if it exists; otherwise null */ @@ -1431,6 +1525,7 @@ public class SwingUtilities implements SwingConstants * Component.AccessibleAWTComponent.getAccessibleIndexInParent() instead * of using this method. * + * @param c the component * @return an instance of AccessibleStateSet containing the current state * set of the object * @see AccessibleState @@ -1448,6 +1543,7 @@ public class SwingUtilities implements SwingConstants * Component.AccessibleAWTComponent.getAccessibleIndexInParent() instead * of using this method. * + * @param c the component * @return the number of accessible children in the object. */ public static int getAccessibleChildrenCount(Component c) { @@ -1461,6 +1557,7 @@ public class SwingUtilities implements SwingConstants * Component.AccessibleAWTComponent.getAccessibleIndexInParent() instead * of using this method. * + * @param c the component * @param i zero-based index of child * @return the nth Accessible child of the object */ @@ -1502,6 +1599,8 @@ public class SwingUtilities implements SwingConstants /** * If c is a JRootPane descendant return its JRootPane ancestor. * If c is a RootPaneContainer then return its JRootPane. + * + * @param c the component * @return the JRootPane for Component c or {@code null}. */ public static JRootPane getRootPane(Component c) { @@ -1519,6 +1618,8 @@ public class SwingUtilities implements SwingConstants /** * Returns the root component for the current component tree. + * + * @param c the component * @return the first ancestor of c that's a Window or the last Applet ancestor */ public static Component getRoot(Component c) { @@ -1616,6 +1717,14 @@ public class SwingUtilities implements SwingConstants * This will return true if action is non-{@code null} and * actionPerformed is invoked on it. * + * @param action an action + * @param ks a key stroke + * @param event a key event + * @param sender a sender + * @param modifiers action modifiers + * @return {@code true} if {@code action} is non-{@code null} and + * actionPerformed is invoked on it. + * * @since 1.3 */ public static boolean notifyAction(Action action, KeyStroke ks, @@ -1672,6 +1781,9 @@ public class SwingUtilities implements SwingConstants * to uiInputMap. If uiInputMap is {@code null}, * this removes any previously installed UI InputMap. * + * @param component a component + * @param type a type + * @param uiInputMap an {@code InputMap} * @since 1.3 */ public static void replaceUIInputMap(JComponent component, int type, @@ -1694,6 +1806,8 @@ public class SwingUtilities implements SwingConstants * to uiActionMap. If uiActionMap is {@code null}, * this removes any previously installed UI ActionMap. * + * @param component a component + * @param uiActionMap an {@code ActionMap} * @since 1.3 */ public static void replaceUIActionMap(JComponent component, @@ -1714,9 +1828,14 @@ public class SwingUtilities implements SwingConstants /** * Returns the InputMap provided by the UI for condition * condition in component component. - *

    This will return {@code null} if the UI has not installed a InputMap + *

    This will return {@code null} if the UI has not installed an InputMap * of the specified type. * + * @param component a component + * @param condition a condition + * @return the {@code ActionMap} provided by the UI for {@code condition} + * in the component, or {@code null} if the UI has not installed + * an InputMap of the specified type. * @since 1.3 */ public static InputMap getUIInputMap(JComponent component, int condition) { @@ -1736,6 +1855,9 @@ public class SwingUtilities implements SwingConstants * in component component. *

    This will return {@code null} if the UI has not installed an ActionMap. * + * @param component a component + * @return the {@code ActionMap} provided by the UI in the component, + * or {@code null} if the UI has not installed an ActionMap. * @since 1.3 */ public static ActionMap getUIActionMap(JComponent component) { diff --git a/jdk/src/share/classes/javax/swing/Timer.java b/jdk/src/share/classes/javax/swing/Timer.java index 5ef34add10e..2c25598b88c 100644 --- a/jdk/src/share/classes/javax/swing/Timer.java +++ b/jdk/src/share/classes/javax/swing/Timer.java @@ -145,6 +145,7 @@ import javax.swing.event.EventListenerList; * * * @author Dave Moore + * @since 1.2 */ @SuppressWarnings("serial") public class Timer implements Serializable diff --git a/jdk/src/share/classes/javax/swing/ToolTipManager.java b/jdk/src/share/classes/javax/swing/ToolTipManager.java index 6a3954f7ecc..b127284be09 100644 --- a/jdk/src/share/classes/javax/swing/ToolTipManager.java +++ b/jdk/src/share/classes/javax/swing/ToolTipManager.java @@ -49,6 +49,7 @@ import java.awt.*; * @see JComponent#createToolTip * @author Dave Moore * @author Rich Schiavi + * @since 1.2 */ public class ToolTipManager extends MouseAdapter implements MouseMotionListener { Timer enterTimer, exitTimer, insideTimer; diff --git a/jdk/src/share/classes/javax/swing/UIDefaults.java b/jdk/src/share/classes/javax/swing/UIDefaults.java index b6797bd232f..257c5e71a22 100644 --- a/jdk/src/share/classes/javax/swing/UIDefaults.java +++ b/jdk/src/share/classes/javax/swing/UIDefaults.java @@ -71,6 +71,7 @@ import sun.util.CoreResourceBundleControl; * * @see UIManager * @author Hans Muller + * @since 1.2 */ @SuppressWarnings("serial") // Same-version serialization only public class UIDefaults extends Hashtable diff --git a/jdk/src/share/classes/javax/swing/UIManager.java b/jdk/src/share/classes/javax/swing/UIManager.java index 026f8a7b80f..27f243b4d6c 100644 --- a/jdk/src/share/classes/javax/swing/UIManager.java +++ b/jdk/src/share/classes/javax/swing/UIManager.java @@ -173,6 +173,7 @@ import sun.awt.AWTAccessor; * * @author Thomas Ball * @author Hans Muller + * @since 1.2 */ @SuppressWarnings("serial") // Same-version serialization only public class UIManager implements Serializable @@ -1106,6 +1107,8 @@ public class UIManager implements Serializable * UI class is created or when the default look and feel is changed * on a component instance. *

    Note these are not the same as the installed look and feels. + * + * @param laf the {@code LookAndFeel} to be removed * @return true if the LookAndFeel was removed from the list * @see #removeAuxiliaryLookAndFeel * @see #getAuxiliaryLookAndFeels diff --git a/jdk/src/share/classes/javax/swing/UnsupportedLookAndFeelException.java b/jdk/src/share/classes/javax/swing/UnsupportedLookAndFeelException.java index 07b8e18c6ff..e28166cd2db 100644 --- a/jdk/src/share/classes/javax/swing/UnsupportedLookAndFeelException.java +++ b/jdk/src/share/classes/javax/swing/UnsupportedLookAndFeelException.java @@ -38,6 +38,7 @@ package javax.swing; * Please see {@link java.beans.XMLEncoder}. * * @author unattributed + * @since 1.2 */ @SuppressWarnings("serial") // Same-version serialization only public class UnsupportedLookAndFeelException extends Exception diff --git a/jdk/src/share/classes/javax/swing/ViewportLayout.java b/jdk/src/share/classes/javax/swing/ViewportLayout.java index 2aa83bede3e..f2a01f0771b 100644 --- a/jdk/src/share/classes/javax/swing/ViewportLayout.java +++ b/jdk/src/share/classes/javax/swing/ViewportLayout.java @@ -55,6 +55,7 @@ import java.io.Serializable; * Please see {@link java.beans.XMLEncoder}. * * @author Hans Muller + * @since 1.2 */ @SuppressWarnings("serial") // Same-version serialization only public class ViewportLayout implements LayoutManager, Serializable diff --git a/jdk/src/share/classes/javax/swing/WindowConstants.java b/jdk/src/share/classes/javax/swing/WindowConstants.java index 6b1fdb3c15b..9ed3eb84628 100644 --- a/jdk/src/share/classes/javax/swing/WindowConstants.java +++ b/jdk/src/share/classes/javax/swing/WindowConstants.java @@ -44,6 +44,7 @@ package javax.swing; * * * @author Amy Fowler + * @since 1.2 */ public interface WindowConstants { diff --git a/jdk/src/share/classes/javax/swing/event/AncestorEvent.java b/jdk/src/share/classes/javax/swing/event/AncestorEvent.java index a113ebe4c0b..d6f7ab08c28 100644 --- a/jdk/src/share/classes/javax/swing/event/AncestorEvent.java +++ b/jdk/src/share/classes/javax/swing/event/AncestorEvent.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 @@ -81,6 +81,8 @@ public class AncestorEvent extends AWTEvent { /** * Returns the ancestor that the event actually occurred on. + * + * @return the {@code Container} object specifying the ancestor component */ public Container getAncestor() { return ancestor; @@ -90,6 +92,8 @@ public class AncestorEvent extends AWTEvent { * Returns the parent of the ancestor the event actually occurred on. * This is most interesting in an ANCESTOR_REMOVED event, as * the ancestor may no longer be in the component hierarchy. + * + * @return the {@code Container} object specifying the ancestor's parent */ public Container getAncestorParent() { return ancestorParent; @@ -97,6 +101,8 @@ public class AncestorEvent extends AWTEvent { /** * Returns the component that the listener was added to. + * + * @return the {@code JComponent} on which the event occurred */ public JComponent getComponent() { return (JComponent)getSource(); diff --git a/jdk/src/share/classes/javax/swing/event/AncestorListener.java b/jdk/src/share/classes/javax/swing/event/AncestorListener.java index d0b07bdbfea..30dd3cfc4f1 100644 --- a/jdk/src/share/classes/javax/swing/event/AncestorListener.java +++ b/jdk/src/share/classes/javax/swing/event/AncestorListener.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 @@ -48,6 +48,9 @@ public interface AncestorListener extends EventListener { * if the source has actually become visible. For this to be true * all its parents must be visible and it must be in a hierarchy * rooted at a Window + * + * @param event an {@code AncestorEvent} signifying a change in an + * ancestor-component's display-status */ public void ancestorAdded(AncestorEvent event); @@ -58,11 +61,17 @@ public interface AncestorListener extends EventListener { * if the source has actually become invisible. For this to be true * at least one of its parents must by invisible or it is not in * a hierarchy rooted at a Window + * + * @param event an {@code AncestorEvent} signifying a change in an + * ancestor-component's display-status */ public void ancestorRemoved(AncestorEvent event); /** * Called when either the source or one of its ancestors is moved. + * + * @param event an {@code AncestorEvent} signifying a change in an + * ancestor-component's display-status */ public void ancestorMoved(AncestorEvent event); diff --git a/jdk/src/share/classes/javax/swing/event/CellEditorListener.java b/jdk/src/share/classes/javax/swing/event/CellEditorListener.java index fabeca11f62..817e6ea2441 100644 --- a/jdk/src/share/classes/javax/swing/event/CellEditorListener.java +++ b/jdk/src/share/classes/javax/swing/event/CellEditorListener.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 @@ -37,9 +37,17 @@ import java.util.EventListener; public interface CellEditorListener extends java.util.EventListener { - /** This tells the listeners the editor has ended editing */ + /** + * This tells the listeners the editor has ended editing + * + * @param e the {@code ChangeEvent} containing the source of the event + */ public void editingStopped(ChangeEvent e); - /** This tells the listeners the editor has canceled editing */ + /** + * This tells the listeners the editor has canceled editing + * + * @param e the {@code ChangeEvent} containing the source of the event + */ public void editingCanceled(ChangeEvent e); } diff --git a/jdk/src/share/classes/javax/swing/event/EventListenerList.java b/jdk/src/share/classes/javax/swing/event/EventListenerList.java index 9e145daa251..ccde0bfef76 100644 --- a/jdk/src/share/classes/javax/swing/event/EventListenerList.java +++ b/jdk/src/share/classes/javax/swing/event/EventListenerList.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 @@ -120,6 +120,8 @@ public class EventListenerList implements Serializable { * any such manipulation is necessary, it should be done * on a copy of the array returned rather than the array * itself. + * + * @return array of ListenerType-listener pairs */ public Object[] getListenerList() { return listenerList; @@ -127,6 +129,9 @@ public class EventListenerList implements Serializable { /** * Return an array of all the listeners of the given type. + * + * @param the type of {@code EventListener} to search for + * @param t the type of {@code EventListener} classes to be returned * @return all of the listeners of the specified type. * @exception ClassCastException if the supplied class * is not assignable to EventListener @@ -148,6 +153,8 @@ public class EventListenerList implements Serializable { /** * Returns the total number of listeners for this listener list. + * + * @return an integer count of total number of listeners */ public int getListenerCount() { return listenerList.length/2; @@ -156,6 +163,9 @@ public class EventListenerList implements Serializable { /** * Returns the total number of listeners of the supplied type * for this listener list. + * + * @param t the type of listeners to count + * @return the number of listeners of type {@code t} */ public int getListenerCount(Class t) { Object[] lList = listenerList; @@ -173,7 +183,9 @@ public class EventListenerList implements Serializable { /** * Adds the listener as a listener of the specified type. - * @param t the type of the listener to be added + * + * @param the type of {@code EventListener} to add + * @param t the type of the {@code EventListener} class to add * @param l the listener to be added */ public synchronized void add(Class t, T l) { @@ -206,6 +218,8 @@ public class EventListenerList implements Serializable { /** * Removes the listener as a listener of the specified type. + * + * @param the type of {@code EventListener} * @param t the type of the listener to be removed * @param l the listener to be removed */ diff --git a/jdk/src/share/classes/javax/swing/event/HyperlinkEvent.java b/jdk/src/share/classes/javax/swing/event/HyperlinkEvent.java index 848910188e9..bcd7ea60063 100644 --- a/jdk/src/share/classes/javax/swing/event/HyperlinkEvent.java +++ b/jdk/src/share/classes/javax/swing/event/HyperlinkEvent.java @@ -142,6 +142,8 @@ public class HyperlinkEvent extends EventObject { * This may be useful if a URL can't be formed * from the description, in which case the associated * URL would be null. + * + * @return the description of this link as a {@code String} */ public String getDescription() { return desc; diff --git a/jdk/src/share/classes/javax/swing/event/InternalFrameListener.java b/jdk/src/share/classes/javax/swing/event/InternalFrameListener.java index 151c4978630..433f20e6227 100644 --- a/jdk/src/share/classes/javax/swing/event/InternalFrameListener.java +++ b/jdk/src/share/classes/javax/swing/event/InternalFrameListener.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 @@ -42,6 +42,9 @@ import java.util.EventListener; public interface InternalFrameListener extends EventListener { /** * Invoked when a internal frame has been opened. + * + * @param e an {@code InternalFrameEvent} with information about the + * {@code JInteralFrame} that originated the event * @see javax.swing.JInternalFrame#show */ public void internalFrameOpened(InternalFrameEvent e); @@ -49,36 +52,54 @@ public interface InternalFrameListener extends EventListener { /** * Invoked when an internal frame is in the process of being closed. * The close operation can be overridden at this point. + * + * @param e an {@code InternalFrameEvent} with information about the + * {@code JInteralFrame} that originated the event * @see javax.swing.JInternalFrame#setDefaultCloseOperation */ public void internalFrameClosing(InternalFrameEvent e); /** * Invoked when an internal frame has been closed. + * + * @param e an {@code InternalFrameEvent} with information about the + * {@code JInteralFrame} that originated the event * @see javax.swing.JInternalFrame#setClosed */ public void internalFrameClosed(InternalFrameEvent e); /** * Invoked when an internal frame is iconified. + * + * @param e an {@code InternalFrameEvent} with information about the + * {@code JInteralFrame} that originated the event * @see javax.swing.JInternalFrame#setIcon */ public void internalFrameIconified(InternalFrameEvent e); /** * Invoked when an internal frame is de-iconified. + * + * @param e an {@code InternalFrameEvent} with information about the + * {@code JInteralFrame} that originated the event * @see javax.swing.JInternalFrame#setIcon */ public void internalFrameDeiconified(InternalFrameEvent e); /** * Invoked when an internal frame is activated. + * + * @param e an {@code InternalFrameEvent} with information about the + * {@code JInteralFrame} that originated the event * @see javax.swing.JInternalFrame#setSelected */ public void internalFrameActivated(InternalFrameEvent e); /** * Invoked when an internal frame is de-activated. + * + * @param e an {@code InternalFrameEvent} with information about the + * {@code JInteralFrame} that originated the event * @see javax.swing.JInternalFrame#setSelected */ public void internalFrameDeactivated(InternalFrameEvent e); diff --git a/jdk/src/share/classes/javax/swing/event/ListSelectionEvent.java b/jdk/src/share/classes/javax/swing/event/ListSelectionEvent.java index a5128f1e47c..735b5797088 100644 --- a/jdk/src/share/classes/javax/swing/event/ListSelectionEvent.java +++ b/jdk/src/share/classes/javax/swing/event/ListSelectionEvent.java @@ -63,6 +63,7 @@ public class ListSelectionEvent extends EventObject * {@code lastIndex}. The selection of at least one index within the range will * have changed. * + * @param source the {@code Object} on which the event initially occurred * @param firstIndex the first index in the range, <= lastIndex * @param lastIndex the last index in the range, >= firstIndex * @param isAdjusting whether or not this is one in a series of diff --git a/jdk/src/share/classes/javax/swing/event/MenuKeyListener.java b/jdk/src/share/classes/javax/swing/event/MenuKeyListener.java index 7caaf2a609f..3abcced7815 100644 --- a/jdk/src/share/classes/javax/swing/event/MenuKeyListener.java +++ b/jdk/src/share/classes/javax/swing/event/MenuKeyListener.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 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 @@ -37,16 +37,22 @@ public interface MenuKeyListener extends EventListener { /** * Invoked when a key has been typed. * This event occurs when a key press is followed by a key release. + * + * @param e a {@code MenuKeyEvent} */ void menuKeyTyped(MenuKeyEvent e); /** * Invoked when a key has been pressed. + * + * @param e a {@code MenuKeyEvent} */ void menuKeyPressed(MenuKeyEvent e); /** * Invoked when a key has been released. + * + * @param e a {@code MenuKeyEvent} */ void menuKeyReleased(MenuKeyEvent e); } diff --git a/jdk/src/share/classes/javax/swing/event/PopupMenuEvent.java b/jdk/src/share/classes/javax/swing/event/PopupMenuEvent.java index 0668371939f..4431dcc0642 100644 --- a/jdk/src/share/classes/javax/swing/event/PopupMenuEvent.java +++ b/jdk/src/share/classes/javax/swing/event/PopupMenuEvent.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 @@ -27,7 +27,7 @@ package javax.swing.event; import java.util.EventObject; /** - * PopupMenuEvent only contains the source of the event which is the JPoupMenu + * PopupMenuEvent only contains the source of the event which is the JPopupMenu * sending the event *

    * Warning: diff --git a/jdk/src/share/classes/javax/swing/event/PopupMenuListener.java b/jdk/src/share/classes/javax/swing/event/PopupMenuListener.java index 4f8b5223664..6f498733f27 100644 --- a/jdk/src/share/classes/javax/swing/event/PopupMenuListener.java +++ b/jdk/src/share/classes/javax/swing/event/PopupMenuListener.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 @@ -35,17 +35,23 @@ public interface PopupMenuListener extends EventListener { /** * This method is called before the popup menu becomes visible + * + * @param e a {@code PopupMenuEvent} containing the source of the event */ void popupMenuWillBecomeVisible(PopupMenuEvent e); /** * This method is called before the popup menu becomes invisible * Note that a JPopupMenu can become invisible any time + * + * @param e a {@code PopupMenuEvent} containing the source of the event */ void popupMenuWillBecomeInvisible(PopupMenuEvent e); /** * This method is called when the popup menu is canceled + * + * @param e a {@code PopupMenuEvent} containing the source of the event */ void popupMenuCanceled(PopupMenuEvent e); } diff --git a/jdk/src/share/classes/javax/swing/event/TableColumnModelEvent.java b/jdk/src/share/classes/javax/swing/event/TableColumnModelEvent.java index 1958ded5e39..7293238671b 100644 --- a/jdk/src/share/classes/javax/swing/event/TableColumnModelEvent.java +++ b/jdk/src/share/classes/javax/swing/event/TableColumnModelEvent.java @@ -83,9 +83,17 @@ public class TableColumnModelEvent extends java.util.EventObject // Querying Methods // - /** Returns the fromIndex. Valid for removed or moved events */ + /** + * Returns the fromIndex. Valid for removed or moved events + * + * @return int value for index from which the column was moved or removed + */ public int getFromIndex() { return fromIndex; }; - /** Returns the toIndex. Valid for add and moved events */ + /** + * Returns the toIndex. Valid for add and moved events + * + * @return int value of column's new index + */ public int getToIndex() { return toIndex; }; } diff --git a/jdk/src/share/classes/javax/swing/event/TableColumnModelListener.java b/jdk/src/share/classes/javax/swing/event/TableColumnModelListener.java index ccd6e5dd88d..deabfe7e8ba 100644 --- a/jdk/src/share/classes/javax/swing/event/TableColumnModelListener.java +++ b/jdk/src/share/classes/javax/swing/event/TableColumnModelListener.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 @@ -39,21 +39,39 @@ import java.util.EventListener; public interface TableColumnModelListener extends java.util.EventListener { - /** Tells listeners that a column was added to the model. */ + /** + * Tells listeners that a column was added to the model. + * + * @param e a {@code TableColumnModelEvent} + */ public void columnAdded(TableColumnModelEvent e); - /** Tells listeners that a column was removed from the model. */ + /** + * Tells listeners that a column was removed from the model. + * + * @param e a {@code TableColumnModelEvent} + */ public void columnRemoved(TableColumnModelEvent e); - /** Tells listeners that a column was repositioned. */ + /** + * Tells listeners that a column was repositioned. + * + * @param e a {@code TableColumnModelEvent} + */ public void columnMoved(TableColumnModelEvent e); - /** Tells listeners that a column was moved due to a margin change. */ + /** + * Tells listeners that a column was moved due to a margin change. + * + * @param e a {@code ChangeEvent} + */ public void columnMarginChanged(ChangeEvent e); /** * Tells listeners that the selection model of the * TableColumnModel changed. + * + * @param e a {@code ListSelectionEvent} */ public void columnSelectionChanged(ListSelectionEvent e); } diff --git a/jdk/src/share/classes/javax/swing/event/TableModelEvent.java b/jdk/src/share/classes/javax/swing/event/TableModelEvent.java index 0247f992a4d..bf6555c4aac 100644 --- a/jdk/src/share/classes/javax/swing/event/TableModelEvent.java +++ b/jdk/src/share/classes/javax/swing/event/TableModelEvent.java @@ -95,13 +95,15 @@ public class TableModelEvent extends java.util.EventObject // /** - * All row data in the table has changed, listeners should discard any state - * that was based on the rows and requery the TableModel - * to get the new row count and all the appropriate values. - * The JTable will repaint the entire visible region on - * receiving this event, querying the model for the cell values that are visible. - * The structure of the table ie, the column names, types and order - * have not changed. + * All row data in the table has changed, listeners should discard any state + * that was based on the rows and requery the TableModel + * to get the new row count and all the appropriate values. + * The JTable will repaint the entire visible region on + * receiving this event, querying the model for the cell values that are visible. + * The structure of the table ie, the column names, types and order + * have not changed. + * + * @param source the {@code TableModel} affected by this event */ public TableModelEvent(TableModel source) { // Use Integer.MAX_VALUE instead of getRowCount() in case rows were deleted. @@ -109,21 +111,28 @@ public class TableModelEvent extends java.util.EventObject } /** - * This row of data has been updated. - * To denote the arrival of a completely new table with a different structure - * use HEADER_ROW as the value for the row. - * When the JTable receives this event and its - * autoCreateColumnsFromModel - * flag is set it discards any TableColumns that it had and reallocates - * default ones in the order they appear in the model. This is the - * same as calling setModel(TableModel) on the JTable. + * This row of data has been updated. + * To denote the arrival of a completely new table with a different structure + * use HEADER_ROW as the value for the row. + * When the JTable receives this event and its + * autoCreateColumnsFromModel + * flag is set it discards any TableColumns that it had and reallocates + * default ones in the order they appear in the model. This is the + * same as calling setModel(TableModel) on the JTable. + * + * @param source the {@code TableModel} affected by this event + * @param row the row which has been updated */ public TableModelEvent(TableModel source, int row) { this(source, row, row, ALL_COLUMNS, UPDATE); } /** - * The data in rows [firstRow, lastRow] have been updated. + * The data in rows [firstRow, lastRow] have been updated. + * + * @param source the {@code TableModel} affected by this event + * @param firstRow the first row affected by this event + * @param lastRow the last row affected by this event */ public TableModelEvent(TableModel source, int firstRow, int lastRow) { this(source, firstRow, lastRow, ALL_COLUMNS, UPDATE); @@ -132,18 +141,32 @@ public class TableModelEvent extends java.util.EventObject /** * The cells in column column in the range * [firstRow, lastRow] have been updated. + * + * @param source the {@code TableModel} affected by this event + * @param firstRow the first row affected by this event + * @param lastRow the last row affected by this event + * @param column the column index of cells changed; {@code ALL_COLUMNS} + * signifies all cells in the specified range of rows are changed. */ public TableModelEvent(TableModel source, int firstRow, int lastRow, int column) { this(source, firstRow, lastRow, column, UPDATE); } /** - * The cells from (firstRow, column) to (lastRow, column) have been changed. - * The column refers to the column index of the cell in the model's - * co-ordinate system. When column is ALL_COLUMNS, all cells in the - * specified range of rows are considered changed. - *

    - * The type should be one of: INSERT, UPDATE and DELETE. + * The cells from (firstRow, column) to (lastRow, column) have been changed. + * The column refers to the column index of the cell in the model's + * co-ordinate system. When column is ALL_COLUMNS, all cells in the + * specified range of rows are considered changed. + *

    + * The type should be one of: INSERT, UPDATE and DELETE. + * + * @param source the {@code TableModel} affected by this event + * @param firstRow the first row affected by this event + * @param lastRow the last row affected by this event + * @param column the column index of cells changed; {@code ALL_COLUMNS} + * signifies all cells in the specified range of rows are changed. + * @param type the type of change signified by this even, @code INSERT}, + * {@code DELETE } or {@code UPDATE} */ public TableModelEvent(TableModel source, int firstRow, int lastRow, int column, int type) { super(source); @@ -157,23 +180,36 @@ public class TableModelEvent extends java.util.EventObject // Querying Methods // - /** Returns the first row that changed. HEADER_ROW means the meta data, + /** + * Returns the first row that changed. HEADER_ROW means the meta data, * ie. names, types and order of the columns. + * + * @return an integer signifying the first row changed */ public int getFirstRow() { return firstRow; }; - /** Returns the last row that changed. */ + /** + * Returns the last row that changed. + * + * @return an integer signifying the last row changed + */ public int getLastRow() { return lastRow; }; /** * Returns the column for the event. If the return * value is ALL_COLUMNS; it means every column in the specified * rows changed. + * + * @return an integer signifying which column is affected by this event */ public int getColumn() { return column; }; /** * Returns the type of event - one of: INSERT, UPDATE and DELETE. + * + * @return the type of change to a table model, an {@code INSERT} or + * {@code DELETE } of row(s) or column(s) or {@code UPDATE} + * to data */ public int getType() { return type; } } diff --git a/jdk/src/share/classes/javax/swing/event/TableModelListener.java b/jdk/src/share/classes/javax/swing/event/TableModelListener.java index 9dce6700238..e32c2ef84f5 100644 --- a/jdk/src/share/classes/javax/swing/event/TableModelListener.java +++ b/jdk/src/share/classes/javax/swing/event/TableModelListener.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 @@ -40,6 +40,9 @@ public interface TableModelListener extends java.util.EventListener /** * This fine grain notification tells listeners the exact range * of cells, rows, or columns that changed. + * + * @param e a {@code TableModelEvent} to notify listener that a table model + * has changed */ public void tableChanged(TableModelEvent e); } diff --git a/jdk/src/share/classes/javax/swing/event/TreeExpansionEvent.java b/jdk/src/share/classes/javax/swing/event/TreeExpansionEvent.java index 1e70200b2e7..7f8f37a1d5d 100644 --- a/jdk/src/share/classes/javax/swing/event/TreeExpansionEvent.java +++ b/jdk/src/share/classes/javax/swing/event/TreeExpansionEvent.java @@ -54,7 +54,7 @@ public class TreeExpansionEvent extends EventObject /** * Path to the value this event represents. */ - protected TreePath path; + protected TreePath path; /** * Constructs a TreeExpansionEvent object. @@ -71,6 +71,8 @@ public class TreeExpansionEvent extends EventObject /** * Returns the path to the value that has been expanded/collapsed. + * + * @return this event's {@code TreePath} object */ public TreePath getPath() { return path; } } diff --git a/jdk/src/share/classes/javax/swing/event/TreeExpansionListener.java b/jdk/src/share/classes/javax/swing/event/TreeExpansionListener.java index 915dcf942f9..a71ac4045c0 100644 --- a/jdk/src/share/classes/javax/swing/event/TreeExpansionListener.java +++ b/jdk/src/share/classes/javax/swing/event/TreeExpansionListener.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 @@ -41,12 +41,18 @@ import java.util.EventListener; public interface TreeExpansionListener extends EventListener { /** - * Called whenever an item in the tree has been expanded. - */ + * Called whenever an item in the tree has been expanded. + * + * @param event a {@code TreeExpansionEvent} containing a {@code TreePath} + * object for the expanded node + */ public void treeExpanded(TreeExpansionEvent event); /** - * Called whenever an item in the tree has been collapsed. - */ + * Called whenever an item in the tree has been collapsed. + * + * @param event a {@code TreeExpansionEvent} containing a {@code TreePath} + * object for the collapsed node + */ public void treeCollapsed(TreeExpansionEvent event); } diff --git a/jdk/src/share/classes/javax/swing/event/TreeModelEvent.java b/jdk/src/share/classes/javax/swing/event/TreeModelEvent.java index 8dbdfcb8d3c..7bd565d9314 100644 --- a/jdk/src/share/classes/javax/swing/event/TreeModelEvent.java +++ b/jdk/src/share/classes/javax/swing/event/TreeModelEvent.java @@ -292,24 +292,24 @@ public class TreeModelEvent extends EventObject { * @return a String representation of this object */ public String toString() { - StringBuffer retBuffer = new StringBuffer(); + StringBuilder sb = new StringBuilder(); - retBuffer.append(getClass().getName() + " " + - Integer.toString(hashCode())); + sb.append(getClass().getName() + " " + + Integer.toString(hashCode())); if(path != null) - retBuffer.append(" path " + path); + sb.append(" path " + path); if(childIndices != null) { - retBuffer.append(" indices [ "); + sb.append(" indices [ "); for(int counter = 0; counter < childIndices.length; counter++) - retBuffer.append(Integer.toString(childIndices[counter])+ " "); - retBuffer.append("]"); + sb.append(Integer.toString(childIndices[counter])+ " "); + sb.append("]"); } if(children != null) { - retBuffer.append(" children [ "); + sb.append(" children [ "); for(int counter = 0; counter < children.length; counter++) - retBuffer.append(children[counter] + " "); - retBuffer.append("]"); + sb.append(children[counter] + " "); + sb.append("]"); } - return retBuffer.toString(); + return sb.toString(); } } diff --git a/jdk/src/share/classes/javax/swing/event/TreeModelListener.java b/jdk/src/share/classes/javax/swing/event/TreeModelListener.java index d89c2a39ef0..22712810fda 100644 --- a/jdk/src/share/classes/javax/swing/event/TreeModelListener.java +++ b/jdk/src/share/classes/javax/swing/event/TreeModelListener.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 @@ -46,25 +46,26 @@ public interface TreeModelListener extends EventListener { * altered their children arrays, but other attributes have * changed and may affect presentation. Example: the name of a * file has changed, but it is in the same location in the file - * system.

    - *

    To indicate the root has changed, childIndices and children - * will be null.

    + * system. * - *

    Use e.getPath() - * to get the parent of the changed node(s). - * e.getChildIndices() - * returns the index(es) of the changed node(s).

    + *

    To indicate the root has changed, childIndices and children + * will be null. + * + *

    Use {@code e.getPath()} to get the parent of the changed node(s). + * {@code e.getChildIndices()} returns the index(es) of the changed node(s). + * + * @param e a {@code TreeModelEvent} describing changes to a tree model */ void treeNodesChanged(TreeModelEvent e); /** *

    Invoked after nodes have been inserted into the tree.

    * - *

    Use e.getPath() - * to get the parent of the new node(s). - * e.getChildIndices() - * returns the index(es) of the new node(s) - * in ascending order.

    + *

    Use {@code e.getPath()} to get the parent of the new node(s). + * {@code e.getChildIndices()} returns the index(es) of the new node(s) + * in ascending order. + * + * @param e a {@code TreeModelEvent} describing changes to a tree model */ void treeNodesInserted(TreeModelEvent e); @@ -74,11 +75,11 @@ public interface TreeModelListener extends EventListener { * invoked once for the root of the removed subtree, not once for * each individual set of siblings removed.

    * - *

    Use e.getPath() - * to get the former parent of the deleted node(s). - * e.getChildIndices() - * returns, in ascending order, the index(es) - * the node(s) had before being deleted.

    + *

    Use {@code e.getPath()} to get the former parent of the deleted + * node(s). {@code e.getChildIndices()} returns, in ascending order, the + * index(es) the node(s) had before being deleted. + * + * @param e a {@code TreeModelEvent} describing changes to a tree model */ void treeNodesRemoved(TreeModelEvent e); @@ -88,10 +89,10 @@ public interface TreeModelListener extends EventListener { * one and the first element does not identify the current root node * the first element should become the new root of the tree. * - *

    Use e.getPath() - * to get the path to the node. - * e.getChildIndices() - * returns null.

    + *

    Use {@code e.getPath()} to get the path to the node. + * {@code e.getChildIndices()} returns null. + * + * @param e a {@code TreeModelEvent} describing changes to a tree model */ void treeStructureChanged(TreeModelEvent e); diff --git a/jdk/src/share/classes/javax/swing/event/TreeSelectionEvent.java b/jdk/src/share/classes/javax/swing/event/TreeSelectionEvent.java index 792ce190509..32de1e9f517 100644 --- a/jdk/src/share/classes/javax/swing/event/TreeSelectionEvent.java +++ b/jdk/src/share/classes/javax/swing/event/TreeSelectionEvent.java @@ -62,12 +62,16 @@ public class TreeSelectionEvent extends EventObject protected TreePath newLeadSelectionPath; /** - * Represents a change in the selection of a TreeSelectionModel. - * paths identifies the paths that have been either added or + * Represents a change in the selection of a {@code TreeSelectionModel}. + * {@code paths} identifies the paths that have been either added or * removed from the selection. * * @param source source of event * @param paths the paths that have changed in the selection + * @param areNew a {@code boolean} array indicating whether the paths in + * {@code paths} are new to the selection + * @param oldLeadSelectionPath the previous lead selection path + * @param newLeadSelectionPath the new lead selection path */ public TreeSelectionEvent(Object source, TreePath[] paths, boolean[] areNew, TreePath oldLeadSelectionPath, @@ -81,14 +85,16 @@ public class TreeSelectionEvent extends EventObject } /** - * Represents a change in the selection of a TreeSelectionModel. - * path identifies the path that have been either added or + * Represents a change in the selection of a {@code TreeSelectionModel}. + * {@code path} identifies the path that has been either added or * removed from the selection. * * @param source source of event * @param path the path that has changed in the selection * @param isNew whether or not the path is new to the selection, false - * means path was removed from the selection. + * means path was removed from the selection. + * @param oldLeadSelectionPath the previous lead selection path + * @param newLeadSelectionPath the new lead selection path */ public TreeSelectionEvent(Object source, TreePath path, boolean isNew, TreePath oldLeadSelectionPath, @@ -104,8 +110,9 @@ public class TreeSelectionEvent extends EventObject } /** - * Returns the paths that have been added or removed from the - * selection. + * Returns the paths that have been added or removed from the selection. + * + * @return copy of the array of {@code TreePath} obects for this event. */ public TreePath[] getPaths() { @@ -120,6 +127,8 @@ public class TreeSelectionEvent extends EventObject /** * Returns the first path element. + * + * @return the first {@code TreePath} element represented by this event */ public TreePath getPath() { @@ -187,6 +196,8 @@ public class TreeSelectionEvent extends EventObject /** * Returns the path that was previously the lead path. + * + * @return a {@code TreePath} containing the old lead selection path */ public TreePath getOldLeadSelectionPath() { return oldLeadSelectionPath; @@ -194,6 +205,8 @@ public class TreeSelectionEvent extends EventObject /** * Returns the current lead path. + * + * @return a {@code TreePath} containing the new lead selection path */ public TreePath getNewLeadSelectionPath() { return newLeadSelectionPath; @@ -201,10 +214,14 @@ public class TreeSelectionEvent extends EventObject /** * Returns a copy of the receiver, but with the source being newSource. + * + * @param newSource source of event + * @return an {@code Object} which is a copy of this event with the source + * being the {@code newSource} provided */ public Object cloneWithSource(Object newSource) { // Fix for IE bug - crashing - return new TreeSelectionEvent(newSource, paths,areNew, + return new TreeSelectionEvent(newSource, paths, areNew, oldLeadSelectionPath, newLeadSelectionPath); } diff --git a/jdk/src/share/classes/javax/swing/event/TreeWillExpandListener.java b/jdk/src/share/classes/javax/swing/event/TreeWillExpandListener.java index 6fd170c862a..ad5691220ef 100644 --- a/jdk/src/share/classes/javax/swing/event/TreeWillExpandListener.java +++ b/jdk/src/share/classes/javax/swing/event/TreeWillExpandListener.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 @@ -41,11 +41,19 @@ import javax.swing.tree.ExpandVetoException; public interface TreeWillExpandListener extends EventListener { /** * Invoked whenever a node in the tree is about to be expanded. + * + * @param event a {@code TreeExpansionEvent} containing a {@code TreePath} + * object for the node + * @throws ExpandVetoException to signify expansion has been canceled */ public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException; /** * Invoked whenever a node in the tree is about to be collapsed. + * + * @param event a {@code TreeExpansionEvent} containing a {@code TreePath} + * object for the node + * @throws ExpandVetoException to signify collapse has been canceled */ public void treeWillCollapse(TreeExpansionEvent event) throws ExpandVetoException; } diff --git a/jdk/src/share/classes/javax/swing/event/UndoableEditListener.java b/jdk/src/share/classes/javax/swing/event/UndoableEditListener.java index ba95d93b980..9db6991eb1b 100644 --- a/jdk/src/share/classes/javax/swing/event/UndoableEditListener.java +++ b/jdk/src/share/classes/javax/swing/event/UndoableEditListener.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,6 +38,8 @@ public interface UndoableEditListener extends java.util.EventListener { /** * An undoable edit happened + * + * @param e an {@code UndoableEditEvent} object */ void undoableEditHappened(UndoableEditEvent e); } diff --git a/jdk/src/share/classes/javax/swing/plaf/basic/BasicFileChooserUI.java b/jdk/src/share/classes/javax/swing/plaf/basic/BasicFileChooserUI.java index b609dd2f2f0..e04b1c28e94 100644 --- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicFileChooserUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicFileChooserUI.java @@ -1322,8 +1322,8 @@ public class BasicFileChooserUI extends FileChooserUI { return null; } - StringBuffer plainBuf = new StringBuffer(); - StringBuffer htmlBuf = new StringBuffer(); + StringBuilder plainBuf = new StringBuilder(); + StringBuilder htmlBuf = new StringBuilder(); htmlBuf.append("\n\n

      \n"); diff --git a/jdk/src/share/classes/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java b/jdk/src/share/classes/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java index 33b38623425..3c4338fdc76 100644 --- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java +++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java @@ -380,15 +380,11 @@ public class BasicInternalFrameTitlePane extends JComponent InternalFrameEvent e = new InternalFrameEvent( frame, InternalFrameEvent.INTERNAL_FRAME_CLOSING); // Try posting event, unless there's a SecurityManager. - if (JInternalFrame.class.getClassLoader() == null) { - try { - Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(e); - return; - } catch (SecurityException se) { - // Use dispatchEvent instead. - } + try { + Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(e); + } catch (SecurityException se) { + frame.dispatchEvent(e); } - frame.dispatchEvent(e); } diff --git a/jdk/src/share/classes/javax/swing/plaf/basic/BasicListUI.java b/jdk/src/share/classes/javax/swing/plaf/basic/BasicListUI.java index c6f22cefb0b..29f9e77a592 100644 --- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicListUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicListUI.java @@ -2855,23 +2855,23 @@ public class BasicListUI extends ListUI return null; } - StringBuffer plainBuf = new StringBuffer(); - StringBuffer htmlBuf = new StringBuffer(); + StringBuilder plainStr = new StringBuilder(); + StringBuilder htmlStr = new StringBuilder(); - htmlBuf.append("\n\n
        \n"); + htmlStr.append("\n\n
          \n"); for (int i = 0; i < values.length; i++) { Object obj = values[i]; String val = ((obj == null) ? "" : obj.toString()); - plainBuf.append(val + "\n"); - htmlBuf.append("
        • " + val + "\n"); + plainStr.append(val + "\n"); + htmlStr.append("
        • " + val + "\n"); } // remove the last newline - plainBuf.deleteCharAt(plainBuf.length() - 1); - htmlBuf.append("
        \n\n"); + plainStr.deleteCharAt(plainStr.length() - 1); + htmlStr.append("
      \n\n"); - return new BasicTransferable(plainBuf.toString(), htmlBuf.toString()); + return new BasicTransferable(plainStr.toString(), htmlStr.toString()); } return null; diff --git a/jdk/src/share/classes/javax/swing/plaf/basic/BasicLookAndFeel.java b/jdk/src/share/classes/javax/swing/plaf/basic/BasicLookAndFeel.java index 6ed2265087e..8c1622a4f2a 100644 --- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicLookAndFeel.java +++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicLookAndFeel.java @@ -458,7 +458,7 @@ public abstract class BasicLookAndFeel extends LookAndFeel implements Serializab Integer fiveHundred = new Integer(500); // *** Shared Longs - Long oneThousand = new Long(1000); + Long oneThousand = 1000L; LazyValue dialogPlain12 = t -> new FontUIResource(Font.DIALOG, Font.PLAIN, 12); diff --git a/jdk/src/share/classes/javax/swing/plaf/basic/BasicTableUI.java b/jdk/src/share/classes/javax/swing/plaf/basic/BasicTableUI.java index a59c79dc622..538562b2dba 100644 --- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicTableUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicTableUI.java @@ -2182,29 +2182,29 @@ public class BasicTableUI extends TableUI return null; } - StringBuffer plainBuf = new StringBuffer(); - StringBuffer htmlBuf = new StringBuffer(); + StringBuilder plainStr = new StringBuilder(); + StringBuilder htmlStr = new StringBuilder(); - htmlBuf.append("\n\n\n"); + htmlStr.append("\n\n
      \n"); for (int row = 0; row < rows.length; row++) { - htmlBuf.append("\n"); + htmlStr.append("\n"); for (int col = 0; col < cols.length; col++) { Object obj = table.getValueAt(rows[row], cols[col]); String val = ((obj == null) ? "" : obj.toString()); - plainBuf.append(val + "\t"); - htmlBuf.append(" \n"); + plainStr.append(val + "\t"); + htmlStr.append(" \n"); } // we want a newline at the end of each line and not a tab - plainBuf.deleteCharAt(plainBuf.length() - 1).append("\n"); - htmlBuf.append("\n"); + plainStr.deleteCharAt(plainStr.length() - 1).append("\n"); + htmlStr.append("\n"); } // remove the last newline - plainBuf.deleteCharAt(plainBuf.length() - 1); - htmlBuf.append("
      " + val + "" + val + "
      \n\n"); + plainStr.deleteCharAt(plainStr.length() - 1); + htmlStr.append("\n\n"); - return new BasicTransferable(plainBuf.toString(), htmlBuf.toString()); + return new BasicTransferable(plainStr.toString(), htmlStr.toString()); } return null; diff --git a/jdk/src/share/classes/javax/swing/plaf/basic/BasicTreeUI.java b/jdk/src/share/classes/javax/swing/plaf/basic/BasicTreeUI.java index 208bd8aaab4..9c413983acb 100644 --- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicTreeUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicTreeUI.java @@ -3213,10 +3213,10 @@ public class BasicTreeUI extends TreeUI return null; } - StringBuffer plainBuf = new StringBuffer(); - StringBuffer htmlBuf = new StringBuffer(); + StringBuilder plainStr = new StringBuilder(); + StringBuilder htmlStr = new StringBuilder(); - htmlBuf.append("\n\n
        \n"); + htmlStr.append("\n\n
          \n"); TreeModel model = tree.getModel(); TreePath lastPath = null; @@ -3227,17 +3227,17 @@ public class BasicTreeUI extends TreeUI boolean leaf = model.isLeaf(node); String label = getDisplayString(path, true, leaf); - plainBuf.append(label + "\n"); - htmlBuf.append("
        • " + label + "\n"); + plainStr.append(label + "\n"); + htmlStr.append("
        • " + label + "\n"); } // remove the last newline - plainBuf.deleteCharAt(plainBuf.length() - 1); - htmlBuf.append("
        \n\n"); + plainStr.deleteCharAt(plainStr.length() - 1); + htmlStr.append("
      \n\n"); tree = null; - return new BasicTransferable(plainBuf.toString(), htmlBuf.toString()); + return new BasicTransferable(plainStr.toString(), htmlStr.toString()); } return null; diff --git a/jdk/src/share/classes/javax/swing/plaf/metal/MetalBorders.java b/jdk/src/share/classes/javax/swing/plaf/metal/MetalBorders.java index 8f1ee4fb4d3..a49a4a8bb48 100644 --- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalBorders.java +++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalBorders.java @@ -56,6 +56,9 @@ public class MetalBorders { static Object NO_BUTTON_ROLLOVER = new StringUIClientPropertyKey("NoButtonRollover"); + /** + * The class represents the 3D border. + */ @SuppressWarnings("serial") // Superclass is not serializable across versions public static class Flush3DBorder extends AbstractBorder implements UIResource{ public void paintBorder(Component c, Graphics g, int x, int y, @@ -73,9 +76,15 @@ public class MetalBorders { } } + /** + * The class represents the border of a {@code JButton}. + */ @SuppressWarnings("serial") // Superclass is not serializable across versions public static class ButtonBorder extends AbstractBorder implements UIResource { + /** + * The border insets. + */ protected static Insets borderInsets = new Insets( 3, 3, 3, 3 ); public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) { @@ -188,6 +197,9 @@ public class MetalBorders { } } + /** + * The class represents the border of a {@code JInternalFrame}. + */ @SuppressWarnings("serial") // Superclass is not serializable across versions public static class InternalFrameBorder extends AbstractBorder implements UIResource { private static final int corner = 14; @@ -470,6 +482,9 @@ public class MetalBorders { } } + /** + * The class represents the border of an option dialog. + */ @SuppressWarnings("serial") // Superclass is not serializable across versions public static class OptionDialogBorder extends AbstractBorder implements UIResource { int titleHeight = 0; @@ -532,8 +547,15 @@ public class MetalBorders { } } + /** + * The class represents the border of a {@code JMenuBar}. + */ @SuppressWarnings("serial") // Superclass is not serializable across versions public static class MenuBarBorder extends AbstractBorder implements UIResource { + + /** + * The border insets. + */ protected static Insets borderInsets = new Insets( 1, 0, 1, 0 ); public void paintBorder( Component c, Graphics g, int x, int y, int w, int h ) { @@ -569,8 +591,15 @@ public class MetalBorders { } } + /** + * The class represents the border of a {@code JMenuItem}. + */ @SuppressWarnings("serial") // Superclass is not serializable across versions public static class MenuItemBorder extends AbstractBorder implements UIResource { + + /** + * The border insets. + */ protected static Insets borderInsets = new Insets( 2, 2, 2, 2 ); public void paintBorder( Component c, Graphics g, int x, int y, int w, int h ) { @@ -617,8 +646,15 @@ public class MetalBorders { } } + /** + * The class represents the border of a {@code JPopupMenu}. + */ @SuppressWarnings("serial") // Superclass is not serializable across versions public static class PopupMenuBorder extends AbstractBorder implements UIResource { + + /** + * The border insets. + */ protected static Insets borderInsets = new Insets( 3, 1, 2, 1 ); public void paintBorder( Component c, Graphics g, int x, int y, int w, int h ) { @@ -642,6 +678,9 @@ public class MetalBorders { } } + /** + * The class represents the border of a rollover {@code Button}. + */ @SuppressWarnings("serial") // Superclass is not serializable across versions public static class RolloverButtonBorder extends ButtonBorder { @@ -693,9 +732,15 @@ public class MetalBorders { } } + /** + * The class represents the border of a {@code JToolBar}. + */ @SuppressWarnings("serial") // Superclass is not serializable across versions public static class ToolBarBorder extends AbstractBorder implements UIResource, SwingConstants { + /** + * The instance of {@code MetalBumps}. + */ protected MetalBumps bumps = new MetalBumps( 10, 10, MetalLookAndFeel.getControlHighlight(), MetalLookAndFeel.getControlDarkShadow(), @@ -779,7 +824,9 @@ public class MetalBorders { private static Border buttonBorder; /** - * Returns a border instance for a JButton + * Returns a border instance for a {@code JButton}. + * + * @return a border instance for a {@code JButton} * @since 1.3 */ public static Border getButtonBorder() { @@ -794,7 +841,9 @@ public class MetalBorders { private static Border textBorder; /** - * Returns a border instance for a text component + * Returns a border instance for a text component. + * + * @return a border instance for a text component * @since 1.3 */ public static Border getTextBorder() { @@ -809,7 +858,9 @@ public class MetalBorders { private static Border textFieldBorder; /** - * Returns a border instance for a JTextField + * Returns a border instance for a {@code JTextField}. + * + * @return a border instance for a {@code JTextField} * @since 1.3 */ public static Border getTextFieldBorder() { @@ -821,6 +872,9 @@ public class MetalBorders { return textFieldBorder; } + /** + * The class represents the border of a {@code JTestField}. + */ @SuppressWarnings("serial") // Superclass is not serializable across versions public static class TextFieldBorder extends Flush3DBorder { @@ -846,6 +900,9 @@ public class MetalBorders { } } + /** + * The class represents the border of a {@code JScrollPane}. + */ @SuppressWarnings("serial") // Superclass is not serializable across versions public static class ScrollPaneBorder extends AbstractBorder implements UIResource { public void paintBorder(Component c, Graphics g, int x, int y, @@ -892,7 +949,9 @@ public class MetalBorders { private static Border toggleButtonBorder; /** - * Returns a border instance for a JToggleButton + * Returns a border instance for a {@code JToggleButton}. + * + * @return a border instance for a {@code JToggleButton} * @since 1.3 */ public static Border getToggleButtonBorder() { @@ -942,6 +1001,10 @@ public class MetalBorders { */ @SuppressWarnings("serial") // Superclass is not serializable across versions public static class TableHeaderBorder extends javax.swing.border.AbstractBorder { + + /** + * The border insets. + */ protected Insets editorBorderInsets = new Insets( 2, 2, 2, 0 ); public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) { @@ -964,7 +1027,9 @@ public class MetalBorders { } /** - * Returns a border instance for a Desktop Icon + * Returns a border instance for a Desktop Icon. + * + * @return a border instance for a Desktop Icon * @since 1.3 */ public static Border getDesktopIconBorder() { diff --git a/jdk/src/share/classes/javax/swing/plaf/metal/MetalButtonUI.java b/jdk/src/share/classes/javax/swing/plaf/metal/MetalButtonUI.java index 233949e3df1..db31cc126a9 100644 --- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalButtonUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalButtonUI.java @@ -52,10 +52,22 @@ import javax.swing.plaf.*; */ @SuppressWarnings("serial") // Same-version serialization only public class MetalButtonUI extends BasicButtonUI { + // NOTE: These are not really needed, but at this point we can't pull // them. Their values are updated purely for historical reasons. + /** + * The color of the focused button. + */ protected Color focusColor; + + /** + * The color of the selected button. + */ protected Color selectColor; + + /** + * The color of the disabled color. + */ protected Color disabledTextColor; private static final Object METAL_BUTTON_UI_KEY = new Object(); @@ -63,6 +75,13 @@ public class MetalButtonUI extends BasicButtonUI { // ******************************** // Create PLAF // ******************************** + + /** + * Returns an instance of {@code MetalButtonUI}. + * + * @param c a component + * @return an instance of {@code MetalButtonUI} + */ public static ComponentUI createUI(JComponent c) { AppContext appContext = AppContext.getAppContext(); MetalButtonUI metalButtonUI = @@ -96,17 +115,33 @@ public class MetalButtonUI extends BasicButtonUI { // ******************************** // Default Accessors // ******************************** + + /** + * Returns the color of the selected button. + * + * @return the color of the selected button + */ protected Color getSelectColor() { selectColor = UIManager.getColor(getPropertyPrefix() + "select"); return selectColor; } + /** + * Returns the color of a disabled text. + * + * @return the color of a disabled text + */ protected Color getDisabledTextColor() { disabledTextColor = UIManager.getColor(getPropertyPrefix() + "disabledText"); return disabledTextColor; } + /** + * Returns the color of the focused button. + * + * @return the color of the focused button + */ protected Color getFocusColor() { focusColor = UIManager.getColor(getPropertyPrefix() + "focus"); return focusColor; diff --git a/jdk/src/share/classes/javax/swing/plaf/metal/MetalCheckBoxIcon.java b/jdk/src/share/classes/javax/swing/plaf/metal/MetalCheckBoxIcon.java index 0962c8e943a..c262f460fe7 100644 --- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalCheckBoxIcon.java +++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalCheckBoxIcon.java @@ -49,6 +49,11 @@ import javax.swing.plaf.*; @SuppressWarnings("serial") // Same-version serialization only public class MetalCheckBoxIcon implements Icon, UIResource, Serializable { + /** + * Returns the size of the control. + * + * @return the size of the control + */ protected int getControlSize() { return 13; } public void paintIcon(Component c, Graphics g, int x, int y) { @@ -91,6 +96,14 @@ public class MetalCheckBoxIcon implements Icon, UIResource, Serializable { } } + /** + * Paints {@code MetalCheckBoxIcon}. + * + * @param c a component + * @param g an instance of {@code Graphics} + * @param x an X coordinate + * @param y an Y coordinate + */ protected void drawCheck(Component c, Graphics g, int x, int y) { int controlSize = getControlSize(); g.fillRect( x+3, y+5, 2, controlSize-8 ); diff --git a/jdk/src/share/classes/javax/swing/plaf/metal/MetalCheckBoxUI.java b/jdk/src/share/classes/javax/swing/plaf/metal/MetalCheckBoxUI.java index b80ec636ac2..e18d44a37a0 100644 --- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalCheckBoxUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalCheckBoxUI.java @@ -67,6 +67,13 @@ public class MetalCheckBoxUI extends MetalRadioButtonUI { // ******************************** // Create PlAF // ******************************** + + /** + * Returns an instance of {@code MetalCheckBoxUI}. + * + * @param b a component + * @return a new instance of {@code MetalCheckBoxUI} + */ public static ComponentUI createUI(JComponent b) { AppContext appContext = AppContext.getAppContext(); MetalCheckBoxUI checkboxUI = diff --git a/jdk/src/share/classes/javax/swing/plaf/metal/MetalComboBoxButton.java b/jdk/src/share/classes/javax/swing/plaf/metal/MetalComboBoxButton.java index 6a6d1ed860e..15b889e9d34 100644 --- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalComboBoxButton.java +++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalComboBoxButton.java @@ -50,19 +50,72 @@ import java.io.Serializable; */ @SuppressWarnings("serial") // Same-version serialization only public class MetalComboBoxButton extends JButton { + + /** + * The instance of {@code JComboBox}. + */ protected JComboBox comboBox; + + /** + * The instance of {@code JList}. + */ protected JList listBox; + + /** + * The instance of {@code CellRendererPane}. + */ protected CellRendererPane rendererPane; + + /** + * The icon. + */ protected Icon comboIcon; + + /** + * The {@code iconOnly} value. + */ protected boolean iconOnly = false; + /** + * Returns the {@code JComboBox}. + * + * @return the {@code JComboBox} + */ public final JComboBox getComboBox() { return comboBox;} + + /** + * Sets the {@code JComboBox}. + * + * @param cb the {@code JComboBox} + */ public final void setComboBox( JComboBox cb ) { comboBox = cb;} + /** + * Returns the icon of the {@code JComboBox}. + * + * @return the icon of the {@code JComboBox} + */ public final Icon getComboIcon() { return comboIcon;} + + /** + * Sets the icon of the {@code JComboBox}. + * + * @param i the icon of the {@code JComboBox} + */ public final void setComboIcon( Icon i ) { comboIcon = i;} + /** + * Returns the {@code isIconOnly} value. + * + * @return the {@code isIconOnly} value + */ public final boolean isIconOnly() { return iconOnly;} + + /** + * If {@code isIconOnly} is {@code true} then only icon is painted. + * + * @param isIconOnly if {@code true} then only icon is painted + */ public final void setIconOnly( boolean isIconOnly ) { iconOnly = isIconOnly;} MetalComboBoxButton() { @@ -75,6 +128,14 @@ public class MetalComboBoxButton extends JButton { setModel( model ); } + /** + * Constructs a new instance of {@code MetalComboBoxButton}. + * + * @param cb an instance of {@code JComboBox} + * @param i an icon + * @param pane an instance of {@code CellRendererPane} + * @param list an instance of {@code JList} + */ public MetalComboBoxButton( JComboBox cb, Icon i, CellRendererPane pane, JList list ) { this(); @@ -85,6 +146,15 @@ public class MetalComboBoxButton extends JButton { setEnabled( comboBox.isEnabled() ); } + /** + * Constructs a new instance of {@code MetalComboBoxButton}. + * + * @param cb an instance of {@code JComboBox} + * @param i an icon + * @param onlyIcon if {@code true} only icon is painted + * @param pane an instance of {@code CellRendererPane} + * @param list an instance of {@code JList} + */ public MetalComboBoxButton( JComboBox cb, Icon i, boolean onlyIcon, CellRendererPane pane, JList list ) { this( cb, i, pane, list ); diff --git a/jdk/src/share/classes/javax/swing/plaf/metal/MetalComboBoxEditor.java b/jdk/src/share/classes/javax/swing/plaf/metal/MetalComboBoxEditor.java index 4c95250013b..e9f4aeb4c9d 100644 --- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalComboBoxEditor.java +++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalComboBoxEditor.java @@ -50,6 +50,9 @@ import javax.swing.plaf.basic.BasicComboBoxEditor; @SuppressWarnings("serial") // Same-version serialization only public class MetalComboBoxEditor extends BasicComboBoxEditor { + /** + * Constructs a new instance of {@code MetalComboBoxEditor}. + */ public MetalComboBoxEditor() { super(); //editor.removeFocusListener(this); diff --git a/jdk/src/share/classes/javax/swing/plaf/metal/MetalComboBoxUI.java b/jdk/src/share/classes/javax/swing/plaf/metal/MetalComboBoxUI.java index eb9afb93439..c95e6b5c6ce 100644 --- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalComboBoxUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalComboBoxUI.java @@ -54,6 +54,12 @@ import java.beans.*; @SuppressWarnings("serial") // Same-version serialization only public class MetalComboBoxUI extends BasicComboBoxUI { + /** + * Constructs an instance of {@code MetalComboBoxUI}. + * + * @param c a component + * @return an instance of {@code MetalComboBoxUI} + */ public static ComponentUI createUI(JComponent c) { return new MetalComboBoxUI(); } @@ -234,6 +240,7 @@ public class MetalComboBoxUI extends BasicComboBoxUI { * override. All the functionality of this method is in the * MetalPropertyChangeListener. * + * @param e an instance of {@code PropertyChangeEvent} * @deprecated As of Java 2 platform v1.4. */ @Deprecated @@ -251,11 +258,23 @@ public class MetalComboBoxUI extends BasicComboBoxUI { public void layoutContainer( Container parent ) { layoutComboBox( parent, this ); } + + /** + * Lays out the parent container. + * + * @param parent a container + */ public void superLayout( Container parent ) { super.layoutContainer( parent ); } } + /** + * Lays out the {@code JComboBox} in the {@code parent} container. + * + * @param parent a container + * @param manager an instance of {@code MetalComboBoxLayoutManager} + */ // This is here because of a bug in the compiler. // When a protected-inner-class-savvy compiler comes out we // should move this into MetalComboBoxLayoutManager. @@ -367,6 +386,11 @@ public class MetalComboBoxUI extends BasicComboBoxUI { @Deprecated public class MetalComboPopup extends BasicComboPopup { + /** + * Constructs a new instance of {@code MetalComboPopup}. + * + * @param cBox an instance of {@code JComboBox} + */ public MetalComboPopup( JComboBox cBox) { super( cBox ); } diff --git a/jdk/src/share/classes/javax/swing/plaf/metal/MetalDesktopIconUI.java b/jdk/src/share/classes/javax/swing/plaf/metal/MetalDesktopIconUI.java index 074a3b5eb79..ec3921b5671 100644 --- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalDesktopIconUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalDesktopIconUI.java @@ -48,10 +48,19 @@ public class MetalDesktopIconUI extends BasicDesktopIconUI TitleListener titleListener; private int width; + /** + * Constructs a new instance of {@code MetalDesktopIconUI}. + * + * @param c a component + * @return a new instance of {@code MetalDesktopIconUI} + */ public static ComponentUI createUI(JComponent c) { return new MetalDesktopIconUI(); } + /** + * Constructs a new instance of {@code MetalDesktopIconUI}. + */ public MetalDesktopIconUI() { } diff --git a/jdk/src/share/classes/javax/swing/plaf/metal/MetalFileChooserUI.java b/jdk/src/share/classes/javax/swing/plaf/metal/MetalFileChooserUI.java index 75c1041b95f..06fb070113b 100644 --- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalFileChooserUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalFileChooserUI.java @@ -138,13 +138,21 @@ public class MetalFileChooserUI extends BasicFileChooserUI { } } - // - // ComponentUI Interface Implementation methods - // + /** + * Constructs a new instance of {@code MetalFileChooserUI}. + * + * @param c a component + * @return a new instance of {@code MetalFileChooserUI} + */ public static ComponentUI createUI(JComponent c) { return new MetalFileChooserUI((JFileChooser) c); } + /** + * Constructs a new instance of {@code MetalFileChooserUI}. + * + * @param filechooser a {@code JFileChooser} + */ public MetalFileChooserUI(JFileChooser filechooser) { super(filechooser); } @@ -446,6 +454,11 @@ public class MetalFileChooserUI extends BasicFileChooserUI { groupLabels(new AlignedLabel[] { fileNameLabel, filesOfTypeLabel }); } + /** + * Returns the button panel. + * + * @return the button panel + */ protected JPanel getButtonPanel() { if (buttonPanel == null) { buttonPanel = new JPanel(); @@ -453,6 +466,11 @@ public class MetalFileChooserUI extends BasicFileChooserUI { return buttonPanel; } + /** + * Returns the bottom panel. + * + * @return the bottom panel + */ protected JPanel getBottomPanel() { if(bottomPanel == null) { bottomPanel = new JPanel(); @@ -503,20 +521,42 @@ public class MetalFileChooserUI extends BasicFileChooserUI { SwingUtilities.replaceUIActionMap(fc, actionMap); } + /** + * Returns an instance of {@code ActionMap}. + * + * @return an instance of {@code ActionMap} + */ protected ActionMap getActionMap() { return createActionMap(); } + /** + * Constructs an instance of {@code ActionMap}. + * + * @return an instance of {@code ActionMap} + */ protected ActionMap createActionMap() { ActionMap map = new ActionMapUIResource(); FilePane.addActionsToMap(map, filePane.getActions()); return map; } + /** + * Constructs a details view. + * + * @param fc a {@code JFileChooser} + * @return the list + */ protected JPanel createList(JFileChooser fc) { return filePane.createList(); } + /** + * Constructs a details view. + * + * @param fc a {@code JFileChooser} + * @return the details view + */ protected JPanel createDetailsView(JFileChooser fc) { return filePane.createDetailsView(); } @@ -533,7 +573,12 @@ public class MetalFileChooserUI extends BasicFileChooserUI { // Obsolete class, not used in this version. protected class SingleClickListener extends MouseAdapter { - public SingleClickListener(JList list) { + /** + * Constructs an instance of {@code SingleClickListener}. + * + * @param list an instance of {@code JList} + */ + public SingleClickListener(JList list) { } } @@ -618,20 +663,20 @@ public class MetalFileChooserUI extends BasicFileChooserUI { } private String fileNameString(File[] files) { - StringBuffer buf = new StringBuffer(); + StringBuilder sb = new StringBuilder(); for (int i = 0; files != null && i < files.length; i++) { if (i > 0) { - buf.append(" "); + sb.append(" "); } if (files.length > 1) { - buf.append("\""); + sb.append("\""); } - buf.append(fileNameString(files[i])); + sb.append(fileNameString(files[i])); if (files.length > 1) { - buf.append("\""); + sb.append("\""); } } - return buf.toString(); + return sb.toString(); } /* The following methods are used by the PropertyChange Listener */ @@ -788,11 +833,16 @@ public class MetalFileChooserUI extends BasicFileChooserUI { }; } - + /** + * Removes control buttons from bottom panel. + */ protected void removeControlButtons() { getBottomPanel().remove(getButtonPanel()); } + /** + * Adds control buttons to bottom panel. + */ protected void addControlButtons() { getBottomPanel().add(getButtonPanel()); } @@ -842,15 +892,31 @@ public class MetalFileChooserUI extends BasicFileChooserUI { } } + /** + * Returns the directory name. + * + * @return the directory name + */ public String getDirectoryName() { // PENDING(jeff) - get the name from the directory combobox return null; } + /** + * Sets the directory name. + * + * @param dirname the directory name + */ public void setDirectoryName(String dirname) { // PENDING(jeff) - set the name in the directory combobox } + /** + * Constructs a new instance of {@code DirectoryComboBoxRenderer}. + * + * @param fc a {@code JFileChooser} + * @return a new instance of {@code DirectoryComboBoxRenderer} + */ protected DirectoryComboBoxRenderer createDirectoryComboBoxRenderer(JFileChooser fc) { return new DirectoryComboBoxRenderer(); } @@ -906,9 +972,12 @@ public class MetalFileChooserUI extends BasicFileChooserUI { } - // - // DataModel for DirectoryComboxbox - // + /** + * Constructs a new instance of {@code DataModel} for {@code DirectoryComboBox}. + * + * @param fc a {@code JFileChooser} + * @return a new instance of {@code DataModel} for {@code DirectoryComboBox} + */ protected DirectoryComboBoxModel createDirectoryComboBoxModel(JFileChooser fc) { return new DirectoryComboBoxModel(); } @@ -924,6 +993,9 @@ public class MetalFileChooserUI extends BasicFileChooserUI { JFileChooser chooser = getFileChooser(); FileSystemView fsv = chooser.getFileSystemView(); + /** + * Constructs an instance of {@code DirectoryComboBoxModel}. + */ public DirectoryComboBoxModel() { // Add the current directory to the model, and make it the // selectedDirectory @@ -1017,6 +1089,12 @@ public class MetalFileChooserUI extends BasicFileChooserUI { } } + /** + * Returns the depth of {@code i}-th file. + * + * @param i an index + * @return the depth of {@code i}-th file + */ public int getDepth(int i) { return (depths != null && i >= 0 && i < depths.length) ? depths[i] : 0; } @@ -1039,9 +1117,11 @@ public class MetalFileChooserUI extends BasicFileChooserUI { } } - // - // Renderer for Types ComboBox - // + /** + * Constructs a {@code Renderer} for types {@code ComboBox}. + * + * @return a {@code Renderer} for types {@code ComboBox} + */ protected FilterComboBoxRenderer createFilterComboBoxRenderer() { return new FilterComboBoxRenderer(); } @@ -1065,9 +1145,11 @@ public class MetalFileChooserUI extends BasicFileChooserUI { } } - // - // DataModel for Types Comboxbox - // + /** + * Constructs a {@code DataModel} for types {@code ComboBox}. + * + * @return a {@code DataModel} for types {@code ComboBox} + */ protected FilterComboBoxModel createFilterComboBoxModel() { return new FilterComboBoxModel(); } @@ -1077,7 +1159,15 @@ public class MetalFileChooserUI extends BasicFileChooserUI { */ @SuppressWarnings("serial") // Same-version serialization only protected class FilterComboBoxModel extends AbstractListModel implements ComboBoxModel, PropertyChangeListener { + + /** + * An array of file filters. + */ protected FileFilter[] filters; + + /** + * Constructs an instance of {@code FilterComboBoxModel}. + */ protected FilterComboBoxModel() { super(); filters = getFileChooser().getChoosableFileFilters(); @@ -1142,6 +1232,11 @@ public class MetalFileChooserUI extends BasicFileChooserUI { } } + /** + * Invokes when {@code ListSelectionEvent} occurs. + * + * @param e an instance of {@code ListSelectionEvent} + */ public void valueChanged(ListSelectionEvent e) { JFileChooser fc = getFileChooser(); File f = fc.getSelectedFile(); @@ -1155,6 +1250,10 @@ public class MetalFileChooserUI extends BasicFileChooserUI { */ @SuppressWarnings("serial") // Superclass is not serializable across versions protected class DirectoryComboBoxAction extends AbstractAction { + + /** + * Constructs a new instance of {@code DirectoryComboBoxAction}. + */ protected DirectoryComboBoxAction() { super("DirectoryComboBoxAction"); } diff --git a/jdk/src/share/classes/javax/swing/plaf/metal/MetalIconFactory.java b/jdk/src/share/classes/javax/swing/plaf/metal/MetalIconFactory.java index e74882523d0..8cd0bd04ace 100644 --- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalIconFactory.java +++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalIconFactory.java @@ -90,10 +90,22 @@ public class MetalIconFactory implements Serializable { private static Icon oceanVerticalSliderThumb; // Constants + /** + * {@code DARK} is used for the property {@code Tree.expandedIcon}. + */ public static final boolean DARK = false; + + /** + * {@code LIGHT} is used for the property {@code Tree.collapsedIcon}. + */ public static final boolean LIGHT = true; // Accessor functions for Icons. Does the caching work. + /** + * Returns the instance of {@code FileChooserDetailViewIcon}. + * + * @return the instance of {@code FileChooserDetailViewIcon} + */ public static Icon getFileChooserDetailViewIcon() { if (fileChooserDetailViewIcon == null) { fileChooserDetailViewIcon = new FileChooserDetailViewIcon(); @@ -101,6 +113,11 @@ public class MetalIconFactory implements Serializable { return fileChooserDetailViewIcon; } + /** + * Returns the instance of {@code FileChooserHomeFolderIcon}. + * + * @return the instance of {@code FileChooserHomeFolderIcon} + */ public static Icon getFileChooserHomeFolderIcon() { if (fileChooserHomeFolderIcon == null) { fileChooserHomeFolderIcon = new FileChooserHomeFolderIcon(); @@ -108,6 +125,11 @@ public class MetalIconFactory implements Serializable { return fileChooserHomeFolderIcon; } + /** + * Returns the instance of {@code FileChooserListViewIcon}. + * + * @return the instance of {@code FileChooserListViewIcon} + */ public static Icon getFileChooserListViewIcon() { if (fileChooserListViewIcon == null) { fileChooserListViewIcon = new FileChooserListViewIcon(); @@ -115,6 +137,11 @@ public class MetalIconFactory implements Serializable { return fileChooserListViewIcon; } + /** + * Returns the instance of {@code FileChooserNewFolderIcon}. + * + * @return the instance of {@code FileChooserNewFolderIcon} + */ public static Icon getFileChooserNewFolderIcon() { if (fileChooserNewFolderIcon == null) { fileChooserNewFolderIcon = new FileChooserNewFolderIcon(); @@ -122,6 +149,11 @@ public class MetalIconFactory implements Serializable { return fileChooserNewFolderIcon; } + /** + * Returns the instance of {@code FileChooserUpFolderIcon}. + * + * @return the instance of {@code FileChooserUpFolderIcon} + */ public static Icon getFileChooserUpFolderIcon() { if (fileChooserUpFolderIcon == null) { fileChooserUpFolderIcon = new FileChooserUpFolderIcon(); @@ -129,14 +161,31 @@ public class MetalIconFactory implements Serializable { return fileChooserUpFolderIcon; } + /** + * Constructs a new instance of {@code InternalFrameAltMaximizeIcon}. + * + * @param size the size of the icon + * @return a new instance of {@code InternalFrameAltMaximizeIcon} + */ public static Icon getInternalFrameAltMaximizeIcon(int size) { return new InternalFrameAltMaximizeIcon(size); } + /** + * Constructs a new instance of {@code InternalFrameCloseIcon}. + * + * @param size the size of the icon + * @return a new instance of {@code InternalFrameCloseIcon} + */ public static Icon getInternalFrameCloseIcon(int size) { return new InternalFrameCloseIcon(size); } + /** + * Returns the instance of {@code InternalFrameDefaultMenuIcon}. + * + * @return the instance of {@code InternalFrameDefaultMenuIcon} + */ public static Icon getInternalFrameDefaultMenuIcon() { if (internalFrameDefaultMenuIcon == null) { internalFrameDefaultMenuIcon = new InternalFrameDefaultMenuIcon(); @@ -144,14 +193,31 @@ public class MetalIconFactory implements Serializable { return internalFrameDefaultMenuIcon; } + /** + * Constructs a new instance of {@code InternalFrameMaximizeIcon}. + * + * @param size the size of the icon + * @return a new instance of {@code InternalFrameMaximizeIcon} + */ public static Icon getInternalFrameMaximizeIcon(int size) { return new InternalFrameMaximizeIcon(size); } + /** + * Constructs a new instance of {@code InternalFrameMinimizeIcon}. + * + * @param size the size of the icon + * @return a new instance of {@code InternalFrameMinimizeIcon} + */ public static Icon getInternalFrameMinimizeIcon(int size) { return new InternalFrameMinimizeIcon(size); } + /** + * Returns the instance of {@code RadioButtonIcon}. + * + * @return the instance of {@code RadioButtonIcon} + */ public static Icon getRadioButtonIcon() { if (radioButtonIcon == null) { radioButtonIcon = new RadioButtonIcon(); @@ -161,6 +227,8 @@ public class MetalIconFactory implements Serializable { /** * Returns a checkbox icon. + * + * @return a checkbox icon * @since 1.3 */ public static Icon getCheckBoxIcon() { @@ -170,6 +238,11 @@ public class MetalIconFactory implements Serializable { return checkBoxIcon; } + /** + * Returns the instance of {@code TreeComputerIcon}. + * + * @return the instance of {@code TreeComputerIcon} + */ public static Icon getTreeComputerIcon() { if ( treeComputerIcon == null ) { treeComputerIcon = new TreeComputerIcon(); @@ -177,6 +250,11 @@ public class MetalIconFactory implements Serializable { return treeComputerIcon; } + /** + * Returns the instance of {@code TreeFloppyDriveIcon}. + * + * @return the instance of {@code TreeFloppyDriveIcon} + */ public static Icon getTreeFloppyDriveIcon() { if ( treeFloppyDriveIcon == null ) { treeFloppyDriveIcon = new TreeFloppyDriveIcon(); @@ -184,10 +262,20 @@ public class MetalIconFactory implements Serializable { return treeFloppyDriveIcon; } + /** + * Constructs a new instance of {@code TreeFolderIcon}. + * + * @return a new instance of {@code TreeFolderIcon} + */ public static Icon getTreeFolderIcon() { return new TreeFolderIcon(); } + /** + * Returns the instance of {@code TreeHardDriveIcon}. + * + * @return the instance of {@code TreeHardDriveIcon} + */ public static Icon getTreeHardDriveIcon() { if ( treeHardDriveIcon == null ) { treeHardDriveIcon = new TreeHardDriveIcon(); @@ -195,14 +283,30 @@ public class MetalIconFactory implements Serializable { return treeHardDriveIcon; } + /** + * Constructs a new instance of {@code TreeLeafIcon}. + * + * @return a new instance of {@code TreeLeafIcon} + */ public static Icon getTreeLeafIcon() { return new TreeLeafIcon(); } + /** + * Constructs a new instance of {@code TreeControlIcon}. + * + * @param isCollapsed if {@code true} the icon is collapsed + * @return a new instance of {@code TreeControlIcon} + */ public static Icon getTreeControlIcon( boolean isCollapsed ) { return new TreeControlIcon( isCollapsed ); } + /** + * Returns an icon to be used by {@code JMenu}. + * + * @return an icon to be used by {@code JMenu} + */ public static Icon getMenuArrowIcon() { if (menuArrowIcon == null) { menuArrowIcon = new MenuArrowIcon(); @@ -220,6 +324,11 @@ public class MetalIconFactory implements Serializable { return null; } + /** + * Returns an icon to be used by {@code JMenuItem}. + * + * @return an icon to be used by {@code JMenuItem} + */ public static Icon getMenuItemArrowIcon() { if (menuItemArrowIcon == null) { menuItemArrowIcon = new MenuItemArrowIcon(); @@ -227,6 +336,11 @@ public class MetalIconFactory implements Serializable { return menuItemArrowIcon; } + /** + * Returns an icon to be used by {@code JCheckBoxMenuItem}. + * + * @return an icon to be used by {@code JCheckBoxMenuItem} + */ public static Icon getCheckBoxMenuItemIcon() { if (checkBoxMenuItemIcon == null) { checkBoxMenuItemIcon = new CheckBoxMenuItemIcon(); @@ -234,6 +348,11 @@ public class MetalIconFactory implements Serializable { return checkBoxMenuItemIcon; } + /** + * Returns an icon to be used by {@code JRadioButtonMenuItem}. + * + * @return an icon to be used by {@code JRadioButtonMenuItem} + */ public static Icon getRadioButtonMenuItemIcon() { if (radioButtonMenuItemIcon == null) { radioButtonMenuItemIcon = new RadioButtonMenuItemIcon(); @@ -241,6 +360,11 @@ public class MetalIconFactory implements Serializable { return radioButtonMenuItemIcon; } + /** + * Returns a thumb icon to be used by horizontal slider. + * + * @return a thumb icon to be used by horizontal slider + */ public static Icon getHorizontalSliderThumbIcon() { if (MetalLookAndFeel.usingOcean()) { if (oceanHorizontalSliderThumb == null) { @@ -253,6 +377,11 @@ public class MetalIconFactory implements Serializable { return new HorizontalSliderThumbIcon(); } + /** + * Returns a thumb icon to be used by vertical slider. + * + * @return a thumb icon to be used by vertical slider + */ public static Icon getVerticalSliderThumbIcon() { if (MetalLookAndFeel.usingOcean()) { if (oceanVerticalSliderThumb == null) { @@ -1251,8 +1380,10 @@ public class MetalIconFactory implements Serializable { g.translate(x, y); // fill interior - g.setColor(interiorColor); - g.fillRect(2,2, 9,9); + if (c.isOpaque()) { + g.setColor(interiorColor); + g.fillRect(2, 2, 9, 9); + } // draw Dark Circle (start at top, go clockwise) g.setColor(darkCircle); @@ -1619,7 +1750,18 @@ public class MetalIconFactory implements Serializable { } + /** + * Returns a shift of the icon. + * + * @return a shift of the icon + */ public int getShift() { return 0; } + + /** + * Returns an additional height of the icon. + * + * @return an additional height of the icon + */ public int getAdditionalHeight() { return 0; } public int getIconWidth() { return folderIcon16Size.width; } @@ -1717,7 +1859,18 @@ public class MetalIconFactory implements Serializable { } + /** + * Returns a shift of the icon. + * + * @return a shift of the icon + */ public int getShift() { return 0; } + + /** + * Returns an additional height of the icon. + * + * @return an additional height of the icon + */ public int getAdditionalHeight() { return 0; } public int getIconWidth() { return fileIcon16Size.width; } @@ -1725,6 +1878,9 @@ public class MetalIconFactory implements Serializable { } + /** + * The class represents a tree leaf icon. + */ public static class TreeLeafIcon extends FileIcon16 { public int getShift() { return 2; } public int getAdditionalHeight() { return 4; } @@ -1746,12 +1902,20 @@ public class MetalIconFactory implements Serializable { */ @SuppressWarnings("serial") // Same-version serialization only public static class TreeControlIcon implements Icon, Serializable { - // This data member should not have been exposed. It's called - // isLight, but now it really means isCollapsed. Since we can't change - // any APIs... that's life. + + /** + * if {@code true} the icon is collapsed. + * NOTE: This data member should not have been exposed. It's called + * {@code isLight}, but now it really means {@code isCollapsed}. + * Since we can't change any APIs... that's life. + */ protected boolean isLight; - + /** + * Constructs an instance of {@code TreeControlIcon}. + * + * @param isCollapsed if {@code true} the icon is collapsed + */ public TreeControlIcon( boolean isCollapsed ) { isLight = isCollapsed; } @@ -1809,6 +1973,14 @@ public class MetalIconFactory implements Serializable { } } + /** + * Paints the {@code TreeControlIcon}. + * + * @param c a component + * @param g an instance of {@code Graphics} + * @param x an X coordinate + * @param y an Y coordinate + */ public void paintMe(Component c, Graphics g, int x, int y) { g.setColor( MetalLookAndFeel.getPrimaryControlInfo() ); @@ -1821,7 +1993,7 @@ public class MetalIconFactory implements Serializable { g.drawLine( xoff + 6, 4, xoff + 9, 4 ); // top g.drawLine( xoff + 10, 5, xoff + 10, 5 ); // top right dot g.drawLine( xoff + 11, 6, xoff + 11, 9 ); // right - g.drawLine( xoff + 10, 10, xoff + 10, 10 ); // botom right dot + g.drawLine( xoff + 10, 10, xoff + 10, 10 ); // bottom right dot g.drawLine( xoff + 6, 11, xoff + 9, 11 ); // bottom g.drawLine( xoff + 5, 10, xoff + 5, 10 ); // bottom left dot diff --git a/jdk/src/share/classes/javax/swing/plaf/metal/MetalInternalFrameTitlePane.java b/jdk/src/share/classes/javax/swing/plaf/metal/MetalInternalFrameTitlePane.java index bcf1abbcedc..b517b4ad3c8 100644 --- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalInternalFrameTitlePane.java +++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalInternalFrameTitlePane.java @@ -46,8 +46,19 @@ import javax.swing.plaf.basic.BasicInternalFrameTitlePane; @SuppressWarnings("serial") // Superclass is not serializable across versions public class MetalInternalFrameTitlePane extends BasicInternalFrameTitlePane { + /** + * The value {@code isPalette} + */ protected boolean isPalette = false; + + /** + * The palette close icon. + */ protected Icon paletteCloseIcon; + + /** + * The height of the palette title. + */ protected int paletteTitleHeight; private static final Border handyEmptyBorder = new EmptyBorder(0,0,0,0); @@ -94,6 +105,11 @@ public class MetalInternalFrameTitlePane extends BasicInternalFrameTitlePane { private Color activeBumpsShadow = MetalLookAndFeel. getPrimaryControlDarkShadow(); + /** + * Constructs a new instance of {@code MetalInternalFrameTitlePane} + * + * @param f an instance of {@code JInternalFrame} + */ public MetalInternalFrameTitlePane(JInternalFrame f) { super( f ); } @@ -307,6 +323,11 @@ public class MetalInternalFrameTitlePane extends BasicInternalFrameTitlePane { } } + /** + * Paints palette. + * + * @param g a instance of {@code Graphics} + */ public void paintPalette(Graphics g) { boolean leftToRight = MetalUtils.isLeftToRight(frame); @@ -471,6 +492,11 @@ public class MetalInternalFrameTitlePane extends BasicInternalFrameTitlePane { bumps.paintIcon(this, g, bumpXOffset, bumpYOffset); } + /** + * If {@code b} is {@code true}, sets palette icons. + * + * @param b if {@code true}, sets palette icons + */ public void setPalette(boolean b) { isPalette = b; diff --git a/jdk/src/share/classes/javax/swing/plaf/metal/MetalInternalFrameUI.java b/jdk/src/share/classes/javax/swing/plaf/metal/MetalInternalFrameUI.java index c8b75e88ac8..94daa93f3b0 100644 --- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalInternalFrameUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalInternalFrameUI.java @@ -47,6 +47,9 @@ public class MetalInternalFrameUI extends BasicInternalFrameUI { private static final Border handyEmptyBorder = new EmptyBorder(0,0,0,0); + /** + * The property {@code JInternalFrame.isPalette}. + */ protected static String IS_PALETTE = "JInternalFrame.isPalette"; private static String IS_PALETTE_KEY = "JInternalFrame.isPalette"; private static String FRAME_TYPE = "JInternalFrame.frameType"; @@ -54,10 +57,22 @@ public class MetalInternalFrameUI extends BasicInternalFrameUI { private static String PALETTE_FRAME = "palette"; private static String OPTION_DIALOG = "optionDialog"; + + /** + * Constructs a new {@code MetalInternalFrameUI} instance. + * + * @param b an internal frame + */ public MetalInternalFrameUI(JInternalFrame b) { super(b); } + /** + * Constructs a new {@code MetalInternalFrameUI} instance. + * + * @param c a component + * @return a new {@code MetalInternalFrameUI} instance + */ public static ComponentUI createUI(JComponent c) { return new MetalInternalFrameUI( (JInternalFrame) c); } @@ -152,6 +167,11 @@ public class MetalInternalFrameUI extends BasicInternalFrameUI { } } + /** + * If {@code isPalette} is {@code true}, sets palette border and title + * + * @param isPalette if {@code true}, sets palette border and title + */ // this should be deprecated - jcs public void setPalette(boolean isPalette) { if (isPalette) { diff --git a/jdk/src/share/classes/javax/swing/plaf/metal/MetalLabelUI.java b/jdk/src/share/classes/javax/swing/plaf/metal/MetalLabelUI.java index 6d62d1d640e..977b0789df6 100644 --- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalLabelUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalLabelUI.java @@ -56,6 +56,12 @@ public class MetalLabelUI extends BasicLabelUI private static final Object METAL_LABEL_UI_KEY = new Object(); + /** + * Returns an instance of {@code MetalLabelUI}. + * + * @param c a component + * @return an instance of {@code MetalLabelUI} + */ public static ComponentUI createUI(JComponent c) { if (System.getSecurityManager() != null) { AppContext appContext = AppContext.getAppContext(); diff --git a/jdk/src/share/classes/javax/swing/plaf/metal/MetalPopupMenuSeparatorUI.java b/jdk/src/share/classes/javax/swing/plaf/metal/MetalPopupMenuSeparatorUI.java index c32d2679f9c..7a22550febc 100644 --- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalPopupMenuSeparatorUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalPopupMenuSeparatorUI.java @@ -43,6 +43,12 @@ import javax.swing.plaf.*; public class MetalPopupMenuSeparatorUI extends MetalSeparatorUI { + /** + * Constructs a new {@code MetalPopupMenuSeparatorUI} instance. + * + * @param c a component + * @return a new {@code MetalPopupMenuSeparatorUI} instance + */ public static ComponentUI createUI( JComponent c ) { return new MetalPopupMenuSeparatorUI(); diff --git a/jdk/src/share/classes/javax/swing/plaf/metal/MetalProgressBarUI.java b/jdk/src/share/classes/javax/swing/plaf/metal/MetalProgressBarUI.java index aedede36688..42b0b3719a2 100644 --- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalProgressBarUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalProgressBarUI.java @@ -50,6 +50,12 @@ public class MetalProgressBarUI extends BasicProgressBarUI { private Rectangle innards; private Rectangle box; + /** + * Constructs an instance of {@code MetalProgressBarUI}. + * + * @param c a component + * @return an instance of {@code MetalProgressBarUI} + */ public static ComponentUI createUI(JComponent c) { return new MetalProgressBarUI(); } diff --git a/jdk/src/share/classes/javax/swing/plaf/metal/MetalRadioButtonUI.java b/jdk/src/share/classes/javax/swing/plaf/metal/MetalRadioButtonUI.java index 9b7beeacf98..660bfa84c8b 100644 --- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalRadioButtonUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalRadioButtonUI.java @@ -58,8 +58,19 @@ public class MetalRadioButtonUI extends BasicRadioButtonUI { private static final Object METAL_RADIO_BUTTON_UI_KEY = new Object(); + /** + * The color of the focused radio button. + */ protected Color focusColor; + + /** + * The color of the selected radio button. + */ protected Color selectColor; + + /** + * The color of a disabled text. + */ protected Color disabledTextColor; private boolean defaults_initialized = false; @@ -67,6 +78,13 @@ public class MetalRadioButtonUI extends BasicRadioButtonUI { // ******************************** // Create PlAF // ******************************** + + /** + * Returns an instance of {@code MetalRadioButtonUI}. + * + * @param c a component + * @return an instance of {@code MetalRadioButtonUI} + */ public static ComponentUI createUI(JComponent c) { AppContext appContext = AppContext.getAppContext(); MetalRadioButtonUI metalRadioButtonUI = @@ -100,14 +118,30 @@ public class MetalRadioButtonUI extends BasicRadioButtonUI { // ******************************** // Default Accessors // ******************************** + + /** + * Returns the color of the selected {@code JRadioButton}. + * + * @return the color of the selected {@code JRadioButton} + */ protected Color getSelectColor() { return selectColor; } + /** + * Returns the color of the disabled text. + * + * @return the color of the disabled text + */ protected Color getDisabledTextColor() { return disabledTextColor; } + /** + * Returns the color of the focused {@code JRadioButton}. + * + * @return the color of the focused {@code JRadioButton} + */ protected Color getFocusColor() { return focusColor; } diff --git a/jdk/src/share/classes/javax/swing/plaf/metal/MetalScrollBarUI.java b/jdk/src/share/classes/javax/swing/plaf/metal/MetalScrollBarUI.java index 6d410d88b71..cb4fbd72590 100644 --- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalScrollBarUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalScrollBarUI.java @@ -59,17 +59,42 @@ public class MetalScrollBarUI extends BasicScrollBarUI private static Color thumbShadow; private static Color thumbHighlightColor; - + /** + * The metal bumps. + */ protected MetalBumps bumps; + /** + * The increase button. + */ protected MetalScrollButton increaseButton; + + /** + * The decrease button. + */ protected MetalScrollButton decreaseButton; + /** + * The width of the scroll bar. + */ protected int scrollBarWidth; + /** + * The property {@code JScrollBar.isFreeStanding}. + */ public static final String FREE_STANDING_PROP = "JScrollBar.isFreeStanding"; + + /** + * The value of the property {@code JScrollBar.isFreeStanding}. + */ protected boolean isFreeStanding = true; + /** + * Constructs a new {@code MetalScrollBarUI} instance. + * + * @param c a component + * @return a new {@code MetalScrollBarUI} instance + */ public static ComponentUI createUI( JComponent c ) { return new MetalScrollBarUI(); diff --git a/jdk/src/share/classes/javax/swing/plaf/metal/MetalScrollButton.java b/jdk/src/share/classes/javax/swing/plaf/metal/MetalScrollButton.java index edd40950ec4..31a874326b1 100644 --- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalScrollButton.java +++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalScrollButton.java @@ -59,6 +59,13 @@ public class MetalScrollButton extends BasicArrowButton private int buttonWidth; + /** + * Constructs an instance of {@code MetalScrollButton}. + * + * @param direction the direction + * @param width the width + * @param freeStanding the free standing value + */ public MetalScrollButton( int direction, int width, boolean freeStanding ) { super( direction ); @@ -70,6 +77,11 @@ public class MetalScrollButton extends BasicArrowButton isFreeStanding = freeStanding; } + /** + * Sets the free standing value. + * + * @param freeStanding the free standing value + */ public void setFreeStanding( boolean freeStanding ) { isFreeStanding = freeStanding; @@ -115,14 +127,10 @@ public class MetalScrollButton extends BasicArrowButton g.setColor( arrowColor ); int startY = ((h+1) - arrowHeight) / 2; int startX = (w / 2); - // System.out.println( "startX :" + startX + " startY :"+startY); + for (int line = 0; line < arrowHeight; line++) { g.drawLine( startX-line, startY+line, startX +line+1, startY+line); } - /* g.drawLine( 7, 6, 8, 6 ); - g.drawLine( 6, 7, 9, 7 ); - g.drawLine( 5, 8, 10, 8 ); - g.drawLine( 4, 9, 11, 9 );*/ if (isEnabled) { g.setColor( highlightColor ); @@ -167,17 +175,10 @@ public class MetalScrollButton extends BasicArrowButton int startY = (((h+1) - arrowHeight) / 2)+ arrowHeight-1; int startX = (w / 2); - // System.out.println( "startX2 :" + startX + " startY2 :"+startY); - for (int line = 0; line < arrowHeight; line++) { g.drawLine( startX-line, startY-line, startX +line+1, startY-line); } - /* g.drawLine( 4, 5, 11, 5 ); - g.drawLine( 5, 6, 10, 6 ); - g.drawLine( 6, 7, 9, 7 ); - g.drawLine( 7, 8, 8, 8 ); */ - if (isEnabled) { g.setColor( highlightColor ); @@ -219,18 +220,10 @@ public class MetalScrollButton extends BasicArrowButton int startX = (((w+1) - arrowHeight) / 2) + arrowHeight-1; int startY = (h / 2); - //System.out.println( "startX2 :" + startX + " startY2 :"+startY); - for (int line = 0; line < arrowHeight; line++) { g.drawLine( startX-line, startY-line, startX -line, startY+line+1); } - -/* g.drawLine( 5, 4, 5, 11 ); - g.drawLine( 6, 5, 6, 10 ); - g.drawLine( 7, 6, 7, 9 ); - g.drawLine( 8, 7, 8, 8 );*/ - if (isEnabled) { g.setColor( highlightColor ); @@ -274,11 +267,6 @@ public class MetalScrollButton extends BasicArrowButton g.drawLine( startX+line, startY-line, startX +line, startY+line+1); } - /* g.drawLine( 6, 7, 6, 8 ); - g.drawLine( 7, 6, 7, 9 ); - g.drawLine( 8, 5, 8, 10 ); - g.drawLine( 9, 4, 9, 11 );*/ - if (isEnabled) { g.setColor( highlightColor ); @@ -341,6 +329,11 @@ public class MetalScrollButton extends BasicArrowButton return new Dimension( Integer.MAX_VALUE, Integer.MAX_VALUE ); } + /** + * Returns the width of the button. + * + * @return the width of the button + */ public int getButtonWidth() { return buttonWidth; } diff --git a/jdk/src/share/classes/javax/swing/plaf/metal/MetalScrollPaneUI.java b/jdk/src/share/classes/javax/swing/plaf/metal/MetalScrollPaneUI.java index ffc5fc4df1c..c65eb52a657 100644 --- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalScrollPaneUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalScrollPaneUI.java @@ -56,6 +56,12 @@ public class MetalScrollPaneUI extends BasicScrollPaneUI private PropertyChangeListener scrollBarSwapListener; + /** + * Constructs a new {@code MetalScrollPaneUI}. + * + * @param x a component + * @return a new {@code MetalScrollPaneUI} + */ public static ComponentUI createUI(JComponent x) { return new MetalScrollPaneUI(); } @@ -97,6 +103,7 @@ public class MetalScrollPaneUI extends BasicScrollPaneUI } /** + * @param scrollPane an instance of the {@code JScrollPane} * @deprecated - Replaced by {@link #uninstallListeners(JComponent)} */ @Deprecated @@ -136,6 +143,11 @@ public class MetalScrollPaneUI extends BasicScrollPaneUI } } + /** + * Returns a new {@code PropertyChangeListener} for scroll bar swap events. + * + * @return a new {@code PropertyChangeListener} for scroll bar swap events. + */ protected PropertyChangeListener createScrollBarSwapListener() { return new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { diff --git a/jdk/src/share/classes/javax/swing/plaf/metal/MetalSeparatorUI.java b/jdk/src/share/classes/javax/swing/plaf/metal/MetalSeparatorUI.java index 9de133b902d..58b6e69e6fb 100644 --- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalSeparatorUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalSeparatorUI.java @@ -53,6 +53,12 @@ import javax.swing.plaf.basic.BasicSeparatorUI; @SuppressWarnings("serial") // Same-version serialization only public class MetalSeparatorUI extends BasicSeparatorUI { + /** + * Constructs a new {@code MetalSeparatorUI} instance. + * + * @param c a component + * @return a new {@code MetalSeparatorUI} instance. + */ public static ComponentUI createUI( JComponent c ) { return new MetalSeparatorUI(); diff --git a/jdk/src/share/classes/javax/swing/plaf/metal/MetalSliderUI.java b/jdk/src/share/classes/javax/swing/plaf/metal/MetalSliderUI.java index 6e629938a65..bc21c7a5094 100644 --- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalSliderUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalSliderUI.java @@ -53,13 +53,42 @@ import javax.swing.plaf.*; @SuppressWarnings("serial") // Same-version serialization only public class MetalSliderUI extends BasicSliderUI { + /** + * The buffer of a tick. + */ protected final int TICK_BUFFER = 4; + + /** + * The value of the property {@code JSlider.isFilled}. + * By default, {@code false} if the property is not set, + * {@code true} for Ocean theme. + */ protected boolean filledSlider = false; + // NOTE: these next five variables are currently unused. + /** + * The color of a thumb + */ protected static Color thumbColor; + + /** + * The color of highlighting. + */ protected static Color highlightColor; + + /** + * The color of dark shadow. + */ protected static Color darkShadowColor; + + /** + * The width of a track. + */ protected static int trackWidth; + + /** + * The length of a tick. + */ protected static int tickLength; private int safeLength; @@ -80,13 +109,24 @@ public class MetalSliderUI extends BasicSliderUI { private static Icon SAFE_HORIZ_THUMB_ICON; private static Icon SAFE_VERT_THUMB_ICON; - + /** + * Property for {@code JSlider.isFilled}. + */ protected final String SLIDER_FILL = "JSlider.isFilled"; + /** + * Constructs a {@code MetalSliderUI} instance. + * + * @param c a component + * @return a {@code MetalSliderUI} instance + */ public static ComponentUI createUI(JComponent c) { return new MetalSliderUI(); } + /** + * Constructs a {@code MetalSliderUI} instance. + */ public MetalSliderUI() { super( null ); } @@ -126,10 +166,19 @@ public class MetalSliderUI extends BasicSliderUI { prepareFilledSliderField(); } + /** + * Constructs {@code MetalPropertyListener}. + * + * @param slider a {@code JSlider} + * @return the {@code MetalPropertyListener} + */ protected PropertyChangeListener createPropertyChangeListener( JSlider slider ) { return new MetalPropertyListener(); } + /** + * {@code PropertyListener} for {@code JSlider.isFilled}. + */ protected class MetalPropertyListener extends BasicSliderUI.PropertyChangeHandler { public void propertyChange( PropertyChangeEvent e ) { // listen for slider fill super.propertyChange( e ); @@ -485,6 +534,8 @@ public class MetalSliderUI extends BasicSliderUI { /** * Returns the shorter dimension of the track. + * + * @return the shorter dimension of the track */ protected int getTrackWidth() { // This strange calculation is here to keep the @@ -504,6 +555,8 @@ public class MetalSliderUI extends BasicSliderUI { /** * Returns the longer dimension of the slide bar. (The slide bar is only the * part that runs directly under the thumb) + * + * @return the longer dimension of the slide bar */ protected int getTrackLength() { if ( slider.getOrientation() == JSlider.HORIZONTAL ) { @@ -514,6 +567,8 @@ public class MetalSliderUI extends BasicSliderUI { /** * Returns the amount that the thumb goes past the slide bar. + * + * @return the amount that the thumb goes past the slide bar */ protected int getThumbOverhang() { return (int)(getThumbSize().getHeight()-getTrackWidth())/2; diff --git a/jdk/src/share/classes/javax/swing/plaf/metal/MetalSplitPaneUI.java b/jdk/src/share/classes/javax/swing/plaf/metal/MetalSplitPaneUI.java index d27ea2e4828..8d183126780 100644 --- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalSplitPaneUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalSplitPaneUI.java @@ -49,15 +49,20 @@ public class MetalSplitPaneUI extends BasicSplitPaneUI /** - * Creates a new MetalSplitPaneUI instance - */ + * Creates a new {@code MetalSplitPaneUI} instance + * + * @param x a component + * @return a new {@code MetalSplitPaneUI} instance + */ public static ComponentUI createUI(JComponent x) { return new MetalSplitPaneUI(); } /** - * Creates the default divider. - */ + * Creates the default divider. + * + * @return the default divider + */ public BasicSplitPaneDivider createDefaultDivider() { return new MetalSplitPaneDivider(this); } diff --git a/jdk/src/share/classes/javax/swing/plaf/metal/MetalTabbedPaneUI.java b/jdk/src/share/classes/javax/swing/plaf/metal/MetalTabbedPaneUI.java index 75dc959ca3d..76451154127 100644 --- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalTabbedPaneUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalTabbedPaneUI.java @@ -50,12 +50,27 @@ import javax.swing.plaf.basic.BasicTabbedPaneUI; @SuppressWarnings("serial") // Same-version serialization only public class MetalTabbedPaneUI extends BasicTabbedPaneUI { + /** + * The minimum width of a pane. + */ protected int minTabWidth = 40; // Background color for unselected tabs that don't have an explicitly // set color. private Color unselectedBackground; + + /** + * The color of tab's background. + */ protected Color tabAreaBackground; + + /** + * The color of the selected pane. + */ protected Color selectColor; + + /** + * The color of the highlight. + */ protected Color selectHighlight; private boolean tabsOpaque = true; @@ -65,6 +80,12 @@ public class MetalTabbedPaneUI extends BasicTabbedPaneUI { // Selected border color for ocean. private Color oceanSelectedBorderColor; + /** + * Constructs {@code MetalTabbedPaneUI}. + * + * @param x a component + * @return an instance of {@code MetalTabbedPaneUI} + */ public static ComponentUI createUI( JComponent x ) { return new MetalTabbedPaneUI(); } @@ -116,6 +137,19 @@ public class MetalTabbedPaneUI extends BasicTabbedPaneUI { } + /** + * Paints the top tab border. + * + * @param tabIndex a tab index + * @param g an instance of {@code Graphics} + * @param x an X coordinate + * @param y an Y coordinate + * @param w a width + * @param h a height + * @param btm bottom + * @param rght right + * @param isSelected a selection + */ protected void paintTopTabBorder( int tabIndex, Graphics g, int x, int y, int w, int h, int btm, int rght, @@ -286,6 +320,15 @@ public class MetalTabbedPaneUI extends BasicTabbedPaneUI { g.translate( -x, -y ); } + /** + * Returns {@code true} if the gap should be filled. + * + * @param currentRun the current run + * @param tabIndex the tab index + * @param x an X coordinate + * @param y an Y coordinate + * @return {@code true} if the gap should be filled + */ protected boolean shouldFillGap( int currentRun, int tabIndex, int x, int y ) { boolean result = false; @@ -322,6 +365,14 @@ public class MetalTabbedPaneUI extends BasicTabbedPaneUI { return result; } + /** + * Returns the color of the gap. + * + * @param currentRun the current run + * @param x an X coordinate + * @param y an Y coordinate + * @return the color of the gap + */ protected Color getColorForGap( int currentRun, int x, int y ) { final int shadowWidth = 4; int selectedIndex = tabPane.getSelectedIndex(); @@ -349,6 +400,19 @@ public class MetalTabbedPaneUI extends BasicTabbedPaneUI { return tabPane.getBackground(); } + /** + * Paints the left tab border. + * + * @param tabIndex a tab index + * @param g an instance of {@code Graphics} + * @param x an X coordinate + * @param y an Y coordinate + * @param w a width + * @param h a height + * @param btm bottom + * @param rght right + * @param isSelected a selection + */ protected void paintLeftTabBorder( int tabIndex, Graphics g, int x, int y, int w, int h, int btm, int rght, @@ -466,6 +530,19 @@ public class MetalTabbedPaneUI extends BasicTabbedPaneUI { } + /** + * Paints the bottom tab border. + * + * @param tabIndex a tab index + * @param g an instance of {@code Graphics} + * @param x an X coordinate + * @param y an Y coordinate + * @param w a width + * @param h a height + * @param btm bottom + * @param rght right + * @param isSelected a selection + */ protected void paintBottomTabBorder( int tabIndex, Graphics g, int x, int y, int w, int h, int btm, int rght, @@ -623,6 +700,19 @@ public class MetalTabbedPaneUI extends BasicTabbedPaneUI { g.translate( -x, -y ); } + /** + * Paints the right tab border. + * + * @param tabIndex a tab index + * @param g an instance of {@code Graphics} + * @param x an X coordinate + * @param y an Y coordinate + * @param w a width + * @param h a height + * @param btm bottom + * @param rght right + * @param isSelected a selection + */ protected void paintRightTabBorder( int tabIndex, Graphics g, int x, int y, int w, int h, int btm, int rght, @@ -806,9 +896,8 @@ public class MetalTabbedPaneUI extends BasicTabbedPaneUI { // Paint the background for the tab area if ( tabPane.isOpaque() ) { - Color bg = UIManager.getColor("TabbedPane.tabAreaBackground"); - if (bg != null) { - g.setColor(bg); + if (!c.isBackgroundSet() && (tabAreaBackground != null)) { + g.setColor(tabAreaBackground); } else { g.setColor( c.getBackground() ); @@ -843,6 +932,9 @@ public class MetalTabbedPaneUI extends BasicTabbedPaneUI { super.paint( g, c ); } + /** + * Paints highlights below tab. + */ protected void paintHighlightBelowTab( ) { } @@ -1159,7 +1251,13 @@ public class MetalTabbedPaneUI extends BasicTabbedPaneUI { return 0; } - // Don't rotate runs! + /** + * Returns {@code true} if tab runs should be rotated. + * + * @param tabPlacement a tab placement + * @param selectedRun a selected run + * @return {@code true} if tab runs should be rotated. + */ protected boolean shouldRotateTabRuns( int tabPlacement, int selectedRun ) { return false; } @@ -1201,6 +1299,9 @@ public class MetalTabbedPaneUI extends BasicTabbedPaneUI { */ public class TabbedPaneLayout extends BasicTabbedPaneUI.TabbedPaneLayout { + /** + * Constructs {@code TabbedPaneLayout}. + */ public TabbedPaneLayout() { MetalTabbedPaneUI.this.super(); } diff --git a/jdk/src/share/classes/javax/swing/plaf/metal/MetalTextFieldUI.java b/jdk/src/share/classes/javax/swing/plaf/metal/MetalTextFieldUI.java index 1eca55ed7d2..70db1ee921b 100644 --- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalTextFieldUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalTextFieldUI.java @@ -50,6 +50,12 @@ import javax.swing.plaf.basic.*; @SuppressWarnings("serial") // Same-version serialization only public class MetalTextFieldUI extends BasicTextFieldUI { + /** + * Constructs {@code MetalTextFieldUI}. + * + * @param c a component + * @return the instance of {@code MetalTextFieldUI} + */ public static ComponentUI createUI(JComponent c) { return new MetalTextFieldUI(); } diff --git a/jdk/src/share/classes/javax/swing/plaf/metal/MetalToggleButtonUI.java b/jdk/src/share/classes/javax/swing/plaf/metal/MetalToggleButtonUI.java index d0d902eecee..d8375cec460 100644 --- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalToggleButtonUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalToggleButtonUI.java @@ -60,8 +60,19 @@ public class MetalToggleButtonUI extends BasicToggleButtonUI { private static final Object METAL_TOGGLE_BUTTON_UI_KEY = new Object(); + /** + * The color of a focused toggle button. + */ protected Color focusColor; + + /** + * The color of a selected button. + */ protected Color selectColor; + + /** + * The color of a disabled text. + */ protected Color disabledTextColor; private boolean defaults_initialized = false; @@ -69,6 +80,13 @@ public class MetalToggleButtonUI extends BasicToggleButtonUI { // ******************************** // Create PLAF // ******************************** + + /** + * Constructs the {@code MetalToogleButtonUI}. + * + * @param b a component + * @return the {@code MetalToogleButtonUI}. + */ public static ComponentUI createUI(JComponent b) { AppContext appContext = AppContext.getAppContext(); MetalToggleButtonUI metalToggleButtonUI = @@ -101,14 +119,29 @@ public class MetalToggleButtonUI extends BasicToggleButtonUI { // ******************************** // Default Accessors // ******************************** + /** + * Returns the color of a selected button. + * + * @return the color of a selected button + */ protected Color getSelectColor() { return selectColor; } + /** + * Returns the color of a disabled text. + * + * @return the color of a disabled text + */ protected Color getDisabledTextColor() { return disabledTextColor; } + /** + * Returns the color of a focused toggle button. + * + * @return the color of a focused toggle button + */ protected Color getFocusColor() { return focusColor; } diff --git a/jdk/src/share/classes/javax/swing/plaf/metal/MetalToolBarUI.java b/jdk/src/share/classes/javax/swing/plaf/metal/MetalToolBarUI.java index 6fe5250cc18..b9899a3d877 100644 --- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalToolBarUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalToolBarUI.java @@ -158,6 +158,12 @@ public class MetalToolBarUI extends BasicToolBarUI return false; } + /** + * Constructs an instance of {@code MetalToolBarUI}. + * + * @param c a component + * @return an instance of {@code MetalToolBarUI} + */ public static ComponentUI createUI( JComponent c ) { return new MetalToolBarUI(); @@ -269,6 +275,11 @@ public class MetalToolBarUI extends BasicToolBarUI return new MetalDockingListener( toolBar ); } + /** + * Sets the offset of the mouse cursor inside the DragWindow. + * + * @param p the offset + */ protected void setDragOffset(Point p) { if (!GraphicsEnvironment.isHeadless()) { if (dragWindow == null) { @@ -346,17 +357,29 @@ public class MetalToolBarUI extends BasicToolBarUI } } - // No longer used. Cannot remove for compatibility reasons + /** + * No longer used. The class cannot be removed for compatibility reasons. + */ protected class MetalContainerListener extends BasicToolBarUI.ToolBarContListener {} - // No longer used. Cannot remove for compatibility reasons + /** + * No longer used. The class cannot be removed for compatibility reasons. + */ protected class MetalRolloverListener extends BasicToolBarUI.PropertyListener {} + /** + * {@code DockingListener} for {@code MetalToolBarUI}. + */ protected class MetalDockingListener extends DockingListener { private boolean pressedInBumps = false; + /** + * Constructs the {@code MetalDockingListener}. + * + * @param t an instance of {@code JToolBar} + */ public MetalDockingListener(JToolBar t) { super(t); } diff --git a/jdk/src/share/classes/javax/swing/plaf/metal/MetalToolTipUI.java b/jdk/src/share/classes/javax/swing/plaf/metal/MetalToolTipUI.java index 2a7a1b1e571..d851a162685 100644 --- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalToolTipUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalToolTipUI.java @@ -58,13 +58,26 @@ public class MetalToolTipUI extends BasicToolTipUI { private Font smallFont; // Refer to note in getAcceleratorString about this field. private JToolTip tip; + + /** + * The space between strings. + */ public static final int padSpaceBetweenStrings = 12; private String acceleratorDelimiter; + /** + * Constructs an instance of the {@code MetalToolTipUI}. + */ public MetalToolTipUI() { super(); } + /** + * Returns an instance of the {@code MetalToolTipUI}. + * + * @param c a component + * @return an instance of the {@code MetalToolTipUI}. + */ public static ComponentUI createUI(JComponent c) { return sharedInstance; } @@ -148,6 +161,12 @@ public class MetalToolTipUI extends BasicToolTipUI { return d; } + /** + * If the accelerator is hidden, the method returns {@code true}, + * otherwise, returns {@code false}. + * + * @return {@code true} if the accelerator is hidden. + */ protected boolean isAcceleratorHidden() { Boolean b = (Boolean)UIManager.get("ToolTip.hideAccelerator"); return b != null && b.booleanValue(); @@ -162,6 +181,11 @@ public class MetalToolTipUI extends BasicToolTipUI { return retValue; } + /** + * Returns the accelerator string. + * + * @return the accelerator string. + */ // NOTE: This requires the tip field to be set before this is invoked. // As MetalToolTipUI is shared between all JToolTips the tip field is // set appropriately before this is invoked. Unfortunately this means diff --git a/jdk/src/share/classes/javax/swing/plaf/metal/MetalTreeUI.java b/jdk/src/share/classes/javax/swing/plaf/metal/MetalTreeUI.java index dee9e022f55..0e333ba630f 100644 --- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalTreeUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalTreeUI.java @@ -93,20 +93,26 @@ public class MetalTreeUI extends BasicTreeUI { private int lineStyle = LEG_LINE_STYLE; private PropertyChangeListener lineStyleListener = new LineListener(); - // Boilerplate + /** + * Constructs the {@code MetalTreeUI}. + * + * @param x a component + * @return the instance of the {@code MetalTreeUI} + */ public static ComponentUI createUI(JComponent x) { return new MetalTreeUI(); } - public MetalTreeUI() - { + /** + * Constructs the {@code MetalTreeUI}. + */ + public MetalTreeUI() { super(); } - protected int getHorizontalLegBuffer() - { - return 3; - } + protected int getHorizontalLegBuffer() { + return 3; + } public void installUI( JComponent c ) { super.installUI( c ); @@ -123,24 +129,36 @@ public class MetalTreeUI extends BasicTreeUI { super.uninstallUI(c); } - /** this function converts between the string passed into the client property - * and the internal representation (currently and int) - * - */ + /** + * Converts between the string passed into the client property + * and the internal representation (currently and int) + * + * @param lineStyleFlag a flag + */ protected void decodeLineStyle(Object lineStyleFlag) { - if ( lineStyleFlag == null || - lineStyleFlag.equals(LEG_LINE_STYLE_STRING)){ - lineStyle = LEG_LINE_STYLE; // default case - } else { - if ( lineStyleFlag.equals(NO_STYLE_STRING) ) { - lineStyle = NO_LINE_STYLE; - } else if ( lineStyleFlag.equals(HORIZ_STYLE_STRING) ) { - lineStyle = HORIZ_LINE_STYLE; - } - } - + if ( lineStyleFlag == null || + lineStyleFlag.equals(LEG_LINE_STYLE_STRING)) { + lineStyle = LEG_LINE_STYLE; // default case + } else { + if ( lineStyleFlag.equals(NO_STYLE_STRING) ) { + lineStyle = NO_LINE_STYLE; + } else if ( lineStyleFlag.equals(HORIZ_STYLE_STRING) ) { + lineStyle = HORIZ_LINE_STYLE; + } + } } + /** + * Returns {@code true} if a point with X coordinate {@code mouseX} + * and Y coordinate {@code mouseY} is in expanded control. + * + * @param row a row + * @param rowLevel a row level + * @param mouseX X coordinate + * @param mouseY Y coordinate + * @return {@code true} if a point with X coordinate {@code mouseX} + * and Y coordinate {@code mouseY} is in expanded control. + */ protected boolean isLocationInExpandControl(int row, int rowLevel, int mouseX, int mouseY) { if(tree != null && !isLeaf(row)) { @@ -175,6 +193,12 @@ public class MetalTreeUI extends BasicTreeUI { } } + /** + * Paints the horizontal separators. + * + * @param g an instance of {@code Graphics} + * @param c a component + */ protected void paintHorizontalSeparators(Graphics g, JComponent c) { g.setColor( lineColor ); diff --git a/jdk/src/share/classes/javax/swing/plaf/multi/MultiButtonUI.java b/jdk/src/share/classes/javax/swing/plaf/multi/MultiButtonUI.java index 77fbf3129ac..e8b81e25ec2 100644 --- a/jdk/src/share/classes/javax/swing/plaf/multi/MultiButtonUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/multi/MultiButtonUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2001, 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 @@ -57,6 +57,8 @@ public class MultiButtonUI extends ButtonUI { * Returns the list of UIs associated with this multiplexing UI. This * allows processing of the UIs by an application aware of multiplexing * UIs on components. + * + * @return an array of the UI delegates */ public ComponentUI[] getUIs() { return MultiLookAndFeel.uisToArray(uis); @@ -98,6 +100,9 @@ public class MultiButtonUI extends ButtonUI { * Returns a multiplexing UI instance if any of the auxiliary * LookAndFeels supports this UI. Otherwise, just returns the * UI object obtained from the default LookAndFeel. + * + * @param a the component to create the UI for + * @return the UI delegate created */ public static ComponentUI createUI(JComponent a) { ComponentUI mui = new MultiButtonUI(); diff --git a/jdk/src/share/classes/javax/swing/plaf/multi/MultiColorChooserUI.java b/jdk/src/share/classes/javax/swing/plaf/multi/MultiColorChooserUI.java index bd15686032e..8881abbc8ba 100644 --- a/jdk/src/share/classes/javax/swing/plaf/multi/MultiColorChooserUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/multi/MultiColorChooserUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2001, 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 @@ -57,6 +57,8 @@ public class MultiColorChooserUI extends ColorChooserUI { * Returns the list of UIs associated with this multiplexing UI. This * allows processing of the UIs by an application aware of multiplexing * UIs on components. + * + * @return an array of the UI delegates */ public ComponentUI[] getUIs() { return MultiLookAndFeel.uisToArray(uis); @@ -98,6 +100,9 @@ public class MultiColorChooserUI extends ColorChooserUI { * Returns a multiplexing UI instance if any of the auxiliary * LookAndFeels supports this UI. Otherwise, just returns the * UI object obtained from the default LookAndFeel. + * + * @param a the component to create the UI for + * @return the UI delegate created */ public static ComponentUI createUI(JComponent a) { ComponentUI mui = new MultiColorChooserUI(); diff --git a/jdk/src/share/classes/javax/swing/plaf/multi/MultiComboBoxUI.java b/jdk/src/share/classes/javax/swing/plaf/multi/MultiComboBoxUI.java index 4008fd02c74..ee3cc9848a6 100644 --- a/jdk/src/share/classes/javax/swing/plaf/multi/MultiComboBoxUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/multi/MultiComboBoxUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2001, 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 @@ -58,6 +58,8 @@ public class MultiComboBoxUI extends ComboBoxUI { * Returns the list of UIs associated with this multiplexing UI. This * allows processing of the UIs by an application aware of multiplexing * UIs on components. + * + * @return an array of the UI delegates */ public ComponentUI[] getUIs() { return MultiLookAndFeel.uisToArray(uis); @@ -138,6 +140,9 @@ public class MultiComboBoxUI extends ComboBoxUI { * Returns a multiplexing UI instance if any of the auxiliary * LookAndFeels supports this UI. Otherwise, just returns the * UI object obtained from the default LookAndFeel. + * + * @param a the component to create the UI for + * @return the UI delegate created */ public static ComponentUI createUI(JComponent a) { ComponentUI mui = new MultiComboBoxUI(); diff --git a/jdk/src/share/classes/javax/swing/plaf/multi/MultiDesktopIconUI.java b/jdk/src/share/classes/javax/swing/plaf/multi/MultiDesktopIconUI.java index ba78eb789b1..a41a72931a1 100644 --- a/jdk/src/share/classes/javax/swing/plaf/multi/MultiDesktopIconUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/multi/MultiDesktopIconUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2001, 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 @@ -57,6 +57,8 @@ public class MultiDesktopIconUI extends DesktopIconUI { * Returns the list of UIs associated with this multiplexing UI. This * allows processing of the UIs by an application aware of multiplexing * UIs on components. + * + * @return an array of the UI delegates */ public ComponentUI[] getUIs() { return MultiLookAndFeel.uisToArray(uis); @@ -98,6 +100,9 @@ public class MultiDesktopIconUI extends DesktopIconUI { * Returns a multiplexing UI instance if any of the auxiliary * LookAndFeels supports this UI. Otherwise, just returns the * UI object obtained from the default LookAndFeel. + * + * @param a the component to create the UI for + * @return the UI delegate created */ public static ComponentUI createUI(JComponent a) { ComponentUI mui = new MultiDesktopIconUI(); diff --git a/jdk/src/share/classes/javax/swing/plaf/multi/MultiDesktopPaneUI.java b/jdk/src/share/classes/javax/swing/plaf/multi/MultiDesktopPaneUI.java index 53569defea5..7f99cfad12d 100644 --- a/jdk/src/share/classes/javax/swing/plaf/multi/MultiDesktopPaneUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/multi/MultiDesktopPaneUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2001, 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 @@ -57,6 +57,8 @@ public class MultiDesktopPaneUI extends DesktopPaneUI { * Returns the list of UIs associated with this multiplexing UI. This * allows processing of the UIs by an application aware of multiplexing * UIs on components. + * + * @return an array of the UI delegates */ public ComponentUI[] getUIs() { return MultiLookAndFeel.uisToArray(uis); @@ -98,6 +100,9 @@ public class MultiDesktopPaneUI extends DesktopPaneUI { * Returns a multiplexing UI instance if any of the auxiliary * LookAndFeels supports this UI. Otherwise, just returns the * UI object obtained from the default LookAndFeel. + * + * @param a the component to create the UI for + * @return the UI delegate created */ public static ComponentUI createUI(JComponent a) { ComponentUI mui = new MultiDesktopPaneUI(); diff --git a/jdk/src/share/classes/javax/swing/plaf/multi/MultiFileChooserUI.java b/jdk/src/share/classes/javax/swing/plaf/multi/MultiFileChooserUI.java index b76a6a8ae6b..b2ce34e1b6d 100644 --- a/jdk/src/share/classes/javax/swing/plaf/multi/MultiFileChooserUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/multi/MultiFileChooserUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2001, 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 @@ -62,6 +62,8 @@ public class MultiFileChooserUI extends FileChooserUI { * Returns the list of UIs associated with this multiplexing UI. This * allows processing of the UIs by an application aware of multiplexing * UIs on components. + * + * @return an array of the UI delegates */ public ComponentUI[] getUIs() { return MultiLookAndFeel.uisToArray(uis); @@ -181,6 +183,9 @@ public class MultiFileChooserUI extends FileChooserUI { * Returns a multiplexing UI instance if any of the auxiliary * LookAndFeels supports this UI. Otherwise, just returns the * UI object obtained from the default LookAndFeel. + * + * @param a the component to create the UI for + * @return the UI delegate created */ public static ComponentUI createUI(JComponent a) { ComponentUI mui = new MultiFileChooserUI(); diff --git a/jdk/src/share/classes/javax/swing/plaf/multi/MultiInternalFrameUI.java b/jdk/src/share/classes/javax/swing/plaf/multi/MultiInternalFrameUI.java index dd4509c550a..9b9085522ea 100644 --- a/jdk/src/share/classes/javax/swing/plaf/multi/MultiInternalFrameUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/multi/MultiInternalFrameUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2001, 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 @@ -57,6 +57,8 @@ public class MultiInternalFrameUI extends InternalFrameUI { * Returns the list of UIs associated with this multiplexing UI. This * allows processing of the UIs by an application aware of multiplexing * UIs on components. + * + * @return an array of the UI delegates */ public ComponentUI[] getUIs() { return MultiLookAndFeel.uisToArray(uis); @@ -98,6 +100,9 @@ public class MultiInternalFrameUI extends InternalFrameUI { * Returns a multiplexing UI instance if any of the auxiliary * LookAndFeels supports this UI. Otherwise, just returns the * UI object obtained from the default LookAndFeel. + * + * @param a the component to create the UI for + * @return the UI delegate created */ public static ComponentUI createUI(JComponent a) { ComponentUI mui = new MultiInternalFrameUI(); diff --git a/jdk/src/share/classes/javax/swing/plaf/multi/MultiLabelUI.java b/jdk/src/share/classes/javax/swing/plaf/multi/MultiLabelUI.java index 222b2218563..844cc6d7969 100644 --- a/jdk/src/share/classes/javax/swing/plaf/multi/MultiLabelUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/multi/MultiLabelUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2001, 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 @@ -57,6 +57,8 @@ public class MultiLabelUI extends LabelUI { * Returns the list of UIs associated with this multiplexing UI. This * allows processing of the UIs by an application aware of multiplexing * UIs on components. + * + * @return an array of the UI delegates */ public ComponentUI[] getUIs() { return MultiLookAndFeel.uisToArray(uis); @@ -98,6 +100,9 @@ public class MultiLabelUI extends LabelUI { * Returns a multiplexing UI instance if any of the auxiliary * LookAndFeels supports this UI. Otherwise, just returns the * UI object obtained from the default LookAndFeel. + * + * @param a the component to create the UI for + * @return the UI delegate created */ public static ComponentUI createUI(JComponent a) { ComponentUI mui = new MultiLabelUI(); diff --git a/jdk/src/share/classes/javax/swing/plaf/multi/MultiListUI.java b/jdk/src/share/classes/javax/swing/plaf/multi/MultiListUI.java index 48a05ac2df5..aa541be2cfd 100644 --- a/jdk/src/share/classes/javax/swing/plaf/multi/MultiListUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/multi/MultiListUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2001, 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 @@ -60,6 +60,8 @@ public class MultiListUI extends ListUI { * Returns the list of UIs associated with this multiplexing UI. This * allows processing of the UIs by an application aware of multiplexing * UIs on components. + * + * @return an array of the UI delegates */ public ComponentUI[] getUIs() { return MultiLookAndFeel.uisToArray(uis); @@ -146,6 +148,9 @@ public class MultiListUI extends ListUI { * Returns a multiplexing UI instance if any of the auxiliary * LookAndFeels supports this UI. Otherwise, just returns the * UI object obtained from the default LookAndFeel. + * + * @param a the component to create the UI for + * @return the UI delegate created */ public static ComponentUI createUI(JComponent a) { ComponentUI mui = new MultiListUI(); diff --git a/jdk/src/share/classes/javax/swing/plaf/multi/MultiMenuBarUI.java b/jdk/src/share/classes/javax/swing/plaf/multi/MultiMenuBarUI.java index b15797ef518..70596af4a4f 100644 --- a/jdk/src/share/classes/javax/swing/plaf/multi/MultiMenuBarUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/multi/MultiMenuBarUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2001, 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 @@ -57,6 +57,8 @@ public class MultiMenuBarUI extends MenuBarUI { * Returns the list of UIs associated with this multiplexing UI. This * allows processing of the UIs by an application aware of multiplexing * UIs on components. + * + * @return an array of the UI delegates */ public ComponentUI[] getUIs() { return MultiLookAndFeel.uisToArray(uis); @@ -98,6 +100,9 @@ public class MultiMenuBarUI extends MenuBarUI { * Returns a multiplexing UI instance if any of the auxiliary * LookAndFeels supports this UI. Otherwise, just returns the * UI object obtained from the default LookAndFeel. + * + * @param a the component to create the UI for + * @return the UI delegate created */ public static ComponentUI createUI(JComponent a) { ComponentUI mui = new MultiMenuBarUI(); diff --git a/jdk/src/share/classes/javax/swing/plaf/multi/MultiMenuItemUI.java b/jdk/src/share/classes/javax/swing/plaf/multi/MultiMenuItemUI.java index e4c27e6878e..0b9458e4513 100644 --- a/jdk/src/share/classes/javax/swing/plaf/multi/MultiMenuItemUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/multi/MultiMenuItemUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2001, 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 @@ -58,6 +58,8 @@ public class MultiMenuItemUI extends MenuItemUI { * Returns the list of UIs associated with this multiplexing UI. This * allows processing of the UIs by an application aware of multiplexing * UIs on components. + * + * @return an array of the UI delegates */ public ComponentUI[] getUIs() { return MultiLookAndFeel.uisToArray(uis); @@ -103,6 +105,9 @@ public class MultiMenuItemUI extends MenuItemUI { * Returns a multiplexing UI instance if any of the auxiliary * LookAndFeels supports this UI. Otherwise, just returns the * UI object obtained from the default LookAndFeel. + * + * @param a the component to create the UI for + * @return the UI delegate created */ public static ComponentUI createUI(JComponent a) { ComponentUI mui = new MultiMenuItemUI(); diff --git a/jdk/src/share/classes/javax/swing/plaf/multi/MultiOptionPaneUI.java b/jdk/src/share/classes/javax/swing/plaf/multi/MultiOptionPaneUI.java index 630b328c048..4e5408f5f04 100644 --- a/jdk/src/share/classes/javax/swing/plaf/multi/MultiOptionPaneUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/multi/MultiOptionPaneUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2001, 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 @@ -58,6 +58,8 @@ public class MultiOptionPaneUI extends OptionPaneUI { * Returns the list of UIs associated with this multiplexing UI. This * allows processing of the UIs by an application aware of multiplexing * UIs on components. + * + * @return an array of the UI delegates */ public ComponentUI[] getUIs() { return MultiLookAndFeel.uisToArray(uis); @@ -123,6 +125,9 @@ public class MultiOptionPaneUI extends OptionPaneUI { * Returns a multiplexing UI instance if any of the auxiliary * LookAndFeels supports this UI. Otherwise, just returns the * UI object obtained from the default LookAndFeel. + * + * @param a the component to create the UI for + * @return the UI delegate created */ public static ComponentUI createUI(JComponent a) { ComponentUI mui = new MultiOptionPaneUI(); diff --git a/jdk/src/share/classes/javax/swing/plaf/multi/MultiPanelUI.java b/jdk/src/share/classes/javax/swing/plaf/multi/MultiPanelUI.java index 4bdbe43b968..27799d9657a 100644 --- a/jdk/src/share/classes/javax/swing/plaf/multi/MultiPanelUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/multi/MultiPanelUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2001, 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 @@ -57,6 +57,8 @@ public class MultiPanelUI extends PanelUI { * Returns the list of UIs associated with this multiplexing UI. This * allows processing of the UIs by an application aware of multiplexing * UIs on components. + * + * @return an array of the UI delegates */ public ComponentUI[] getUIs() { return MultiLookAndFeel.uisToArray(uis); @@ -98,6 +100,9 @@ public class MultiPanelUI extends PanelUI { * Returns a multiplexing UI instance if any of the auxiliary * LookAndFeels supports this UI. Otherwise, just returns the * UI object obtained from the default LookAndFeel. + * + * @param a the component to create the UI for + * @return the UI delegate created */ public static ComponentUI createUI(JComponent a) { ComponentUI mui = new MultiPanelUI(); diff --git a/jdk/src/share/classes/javax/swing/plaf/multi/MultiPopupMenuUI.java b/jdk/src/share/classes/javax/swing/plaf/multi/MultiPopupMenuUI.java index 59002ea1566..d4c13051a91 100644 --- a/jdk/src/share/classes/javax/swing/plaf/multi/MultiPopupMenuUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/multi/MultiPopupMenuUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2006, 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 @@ -60,6 +60,8 @@ public class MultiPopupMenuUI extends PopupMenuUI { * Returns the list of UIs associated with this multiplexing UI. This * allows processing of the UIs by an application aware of multiplexing * UIs on components. + * + * @return an array of the UI delegates */ public ComponentUI[] getUIs() { return MultiLookAndFeel.uisToArray(uis); @@ -133,6 +135,9 @@ public class MultiPopupMenuUI extends PopupMenuUI { * Returns a multiplexing UI instance if any of the auxiliary * LookAndFeels supports this UI. Otherwise, just returns the * UI object obtained from the default LookAndFeel. + * + * @param a the component to create the UI for + * @return the UI delegate created */ public static ComponentUI createUI(JComponent a) { ComponentUI mui = new MultiPopupMenuUI(); diff --git a/jdk/src/share/classes/javax/swing/plaf/multi/MultiProgressBarUI.java b/jdk/src/share/classes/javax/swing/plaf/multi/MultiProgressBarUI.java index fd39d724a2b..6a1d01ec16b 100644 --- a/jdk/src/share/classes/javax/swing/plaf/multi/MultiProgressBarUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/multi/MultiProgressBarUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2001, 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 @@ -57,6 +57,8 @@ public class MultiProgressBarUI extends ProgressBarUI { * Returns the list of UIs associated with this multiplexing UI. This * allows processing of the UIs by an application aware of multiplexing * UIs on components. + * + * @return an array of the UI delegates */ public ComponentUI[] getUIs() { return MultiLookAndFeel.uisToArray(uis); @@ -98,6 +100,9 @@ public class MultiProgressBarUI extends ProgressBarUI { * Returns a multiplexing UI instance if any of the auxiliary * LookAndFeels supports this UI. Otherwise, just returns the * UI object obtained from the default LookAndFeel. + * + * @param a the component to create the UI for + * @return the UI delegate created */ public static ComponentUI createUI(JComponent a) { ComponentUI mui = new MultiProgressBarUI(); diff --git a/jdk/src/share/classes/javax/swing/plaf/multi/MultiRootPaneUI.java b/jdk/src/share/classes/javax/swing/plaf/multi/MultiRootPaneUI.java index 601f21129d0..46e60d7e319 100644 --- a/jdk/src/share/classes/javax/swing/plaf/multi/MultiRootPaneUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/multi/MultiRootPaneUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -58,6 +58,8 @@ public class MultiRootPaneUI extends RootPaneUI { * Returns the list of UIs associated with this multiplexing UI. This * allows processing of the UIs by an application aware of multiplexing * UIs on components. + * + * @return an array of the UI delegates */ public ComponentUI[] getUIs() { return MultiLookAndFeel.uisToArray(uis); @@ -99,6 +101,9 @@ public class MultiRootPaneUI extends RootPaneUI { * Returns a multiplexing UI instance if any of the auxiliary * LookAndFeels supports this UI. Otherwise, just returns the * UI object obtained from the default LookAndFeel. + * + * @param a the component to create the UI for + * @return the UI delegate created */ public static ComponentUI createUI(JComponent a) { ComponentUI mui = new MultiRootPaneUI(); diff --git a/jdk/src/share/classes/javax/swing/plaf/multi/MultiScrollBarUI.java b/jdk/src/share/classes/javax/swing/plaf/multi/MultiScrollBarUI.java index b372df70913..a7d5381435a 100644 --- a/jdk/src/share/classes/javax/swing/plaf/multi/MultiScrollBarUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/multi/MultiScrollBarUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2001, 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 @@ -57,6 +57,8 @@ public class MultiScrollBarUI extends ScrollBarUI { * Returns the list of UIs associated with this multiplexing UI. This * allows processing of the UIs by an application aware of multiplexing * UIs on components. + * + * @return an array of the UI delegates */ public ComponentUI[] getUIs() { return MultiLookAndFeel.uisToArray(uis); @@ -98,6 +100,9 @@ public class MultiScrollBarUI extends ScrollBarUI { * Returns a multiplexing UI instance if any of the auxiliary * LookAndFeels supports this UI. Otherwise, just returns the * UI object obtained from the default LookAndFeel. + * + * @param a the component to create the UI for + * @return the UI delegate created */ public static ComponentUI createUI(JComponent a) { ComponentUI mui = new MultiScrollBarUI(); diff --git a/jdk/src/share/classes/javax/swing/plaf/multi/MultiScrollPaneUI.java b/jdk/src/share/classes/javax/swing/plaf/multi/MultiScrollPaneUI.java index 1894a6309c0..f7b7c44289a 100644 --- a/jdk/src/share/classes/javax/swing/plaf/multi/MultiScrollPaneUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/multi/MultiScrollPaneUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2001, 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 @@ -57,6 +57,8 @@ public class MultiScrollPaneUI extends ScrollPaneUI { * Returns the list of UIs associated with this multiplexing UI. This * allows processing of the UIs by an application aware of multiplexing * UIs on components. + * + * @return an array of the UI delegates */ public ComponentUI[] getUIs() { return MultiLookAndFeel.uisToArray(uis); @@ -98,6 +100,9 @@ public class MultiScrollPaneUI extends ScrollPaneUI { * Returns a multiplexing UI instance if any of the auxiliary * LookAndFeels supports this UI. Otherwise, just returns the * UI object obtained from the default LookAndFeel. + * + * @param a the component to create the UI for + * @return the UI delegate created */ public static ComponentUI createUI(JComponent a) { ComponentUI mui = new MultiScrollPaneUI(); diff --git a/jdk/src/share/classes/javax/swing/plaf/multi/MultiSeparatorUI.java b/jdk/src/share/classes/javax/swing/plaf/multi/MultiSeparatorUI.java index 29f6a7fae26..d67cc0407a0 100644 --- a/jdk/src/share/classes/javax/swing/plaf/multi/MultiSeparatorUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/multi/MultiSeparatorUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2001, 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 @@ -57,6 +57,8 @@ public class MultiSeparatorUI extends SeparatorUI { * Returns the list of UIs associated with this multiplexing UI. This * allows processing of the UIs by an application aware of multiplexing * UIs on components. + * + * @return an array of the UI delegates */ public ComponentUI[] getUIs() { return MultiLookAndFeel.uisToArray(uis); @@ -98,6 +100,9 @@ public class MultiSeparatorUI extends SeparatorUI { * Returns a multiplexing UI instance if any of the auxiliary * LookAndFeels supports this UI. Otherwise, just returns the * UI object obtained from the default LookAndFeel. + * + * @param a the component to create the UI for + * @return the UI delegate created */ public static ComponentUI createUI(JComponent a) { ComponentUI mui = new MultiSeparatorUI(); diff --git a/jdk/src/share/classes/javax/swing/plaf/multi/MultiSliderUI.java b/jdk/src/share/classes/javax/swing/plaf/multi/MultiSliderUI.java index 8bc53ee81c1..65da1c18358 100644 --- a/jdk/src/share/classes/javax/swing/plaf/multi/MultiSliderUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/multi/MultiSliderUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2001, 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 @@ -57,6 +57,8 @@ public class MultiSliderUI extends SliderUI { * Returns the list of UIs associated with this multiplexing UI. This * allows processing of the UIs by an application aware of multiplexing * UIs on components. + * + * @return an array of the UI delegates */ public ComponentUI[] getUIs() { return MultiLookAndFeel.uisToArray(uis); @@ -96,8 +98,11 @@ public class MultiSliderUI extends SliderUI { /** * Returns a multiplexing UI instance if any of the auxiliary - * LookAndFeels supports this UI. Otherwise, just returns the + * LookAndFeels supports this UI. Otherwise, just returns the * UI object obtained from the default LookAndFeel. + * + * @param a the component to create the UI for + * @return the UI delegate created */ public static ComponentUI createUI(JComponent a) { ComponentUI mui = new MultiSliderUI(); diff --git a/jdk/src/share/classes/javax/swing/plaf/multi/MultiSpinnerUI.java b/jdk/src/share/classes/javax/swing/plaf/multi/MultiSpinnerUI.java index be2c9c0a277..2c0ce087dc9 100644 --- a/jdk/src/share/classes/javax/swing/plaf/multi/MultiSpinnerUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/multi/MultiSpinnerUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -58,6 +58,8 @@ public class MultiSpinnerUI extends SpinnerUI { * Returns the list of UIs associated with this multiplexing UI. This * allows processing of the UIs by an application aware of multiplexing * UIs on components. + * + * @return an array of the UI delegates */ public ComponentUI[] getUIs() { return MultiLookAndFeel.uisToArray(uis); @@ -99,6 +101,9 @@ public class MultiSpinnerUI extends SpinnerUI { * Returns a multiplexing UI instance if any of the auxiliary * LookAndFeels supports this UI. Otherwise, just returns the * UI object obtained from the default LookAndFeel. + * + * @param a the component to create the UI for + * @return the UI delegate created */ public static ComponentUI createUI(JComponent a) { ComponentUI mui = new MultiSpinnerUI(); diff --git a/jdk/src/share/classes/javax/swing/plaf/multi/MultiSplitPaneUI.java b/jdk/src/share/classes/javax/swing/plaf/multi/MultiSplitPaneUI.java index 5b637f723f3..6c0eb44f3e7 100644 --- a/jdk/src/share/classes/javax/swing/plaf/multi/MultiSplitPaneUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/multi/MultiSplitPaneUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2001, 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 @@ -58,6 +58,8 @@ public class MultiSplitPaneUI extends SplitPaneUI { * Returns the list of UIs associated with this multiplexing UI. This * allows processing of the UIs by an application aware of multiplexing * UIs on components. + * + * @return an array of the UI delegates */ public ComponentUI[] getUIs() { return MultiLookAndFeel.uisToArray(uis); @@ -171,6 +173,9 @@ public class MultiSplitPaneUI extends SplitPaneUI { * Returns a multiplexing UI instance if any of the auxiliary * LookAndFeels supports this UI. Otherwise, just returns the * UI object obtained from the default LookAndFeel. + * + * @param a the component to create the UI for + * @return the UI delegate created */ public static ComponentUI createUI(JComponent a) { ComponentUI mui = new MultiSplitPaneUI(); diff --git a/jdk/src/share/classes/javax/swing/plaf/multi/MultiTabbedPaneUI.java b/jdk/src/share/classes/javax/swing/plaf/multi/MultiTabbedPaneUI.java index 9624ccba1ce..c14f29125e2 100644 --- a/jdk/src/share/classes/javax/swing/plaf/multi/MultiTabbedPaneUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/multi/MultiTabbedPaneUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2001, 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 @@ -59,6 +59,8 @@ public class MultiTabbedPaneUI extends TabbedPaneUI { * Returns the list of UIs associated with this multiplexing UI. This * allows processing of the UIs by an application aware of multiplexing * UIs on components. + * + * @return an array of the UI delegates */ public ComponentUI[] getUIs() { return MultiLookAndFeel.uisToArray(uis); @@ -145,6 +147,9 @@ public class MultiTabbedPaneUI extends TabbedPaneUI { * Returns a multiplexing UI instance if any of the auxiliary * LookAndFeels supports this UI. Otherwise, just returns the * UI object obtained from the default LookAndFeel. + * + * @param a the component to create the UI for + * @return the UI delegate created */ public static ComponentUI createUI(JComponent a) { ComponentUI mui = new MultiTabbedPaneUI(); diff --git a/jdk/src/share/classes/javax/swing/plaf/multi/MultiTableHeaderUI.java b/jdk/src/share/classes/javax/swing/plaf/multi/MultiTableHeaderUI.java index 9b1695168a7..417e5dcbcef 100644 --- a/jdk/src/share/classes/javax/swing/plaf/multi/MultiTableHeaderUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/multi/MultiTableHeaderUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2001, 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 @@ -57,6 +57,8 @@ public class MultiTableHeaderUI extends TableHeaderUI { * Returns the list of UIs associated with this multiplexing UI. This * allows processing of the UIs by an application aware of multiplexing * UIs on components. + * + * @return an array of the UI delegates */ public ComponentUI[] getUIs() { return MultiLookAndFeel.uisToArray(uis); @@ -98,6 +100,9 @@ public class MultiTableHeaderUI extends TableHeaderUI { * Returns a multiplexing UI instance if any of the auxiliary * LookAndFeels supports this UI. Otherwise, just returns the * UI object obtained from the default LookAndFeel. + * + * @param a the component to create the UI for + * @return the UI delegate created */ public static ComponentUI createUI(JComponent a) { ComponentUI mui = new MultiTableHeaderUI(); diff --git a/jdk/src/share/classes/javax/swing/plaf/multi/MultiTableUI.java b/jdk/src/share/classes/javax/swing/plaf/multi/MultiTableUI.java index a281626617e..7a059e33b13 100644 --- a/jdk/src/share/classes/javax/swing/plaf/multi/MultiTableUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/multi/MultiTableUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2001, 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 @@ -57,6 +57,8 @@ public class MultiTableUI extends TableUI { * Returns the list of UIs associated with this multiplexing UI. This * allows processing of the UIs by an application aware of multiplexing * UIs on components. + * + * @return an array of the UI delegates */ public ComponentUI[] getUIs() { return MultiLookAndFeel.uisToArray(uis); @@ -98,6 +100,9 @@ public class MultiTableUI extends TableUI { * Returns a multiplexing UI instance if any of the auxiliary * LookAndFeels supports this UI. Otherwise, just returns the * UI object obtained from the default LookAndFeel. + * + * @param a the component to create the UI for + * @return the UI delegate created */ public static ComponentUI createUI(JComponent a) { ComponentUI mui = new MultiTableUI(); diff --git a/jdk/src/share/classes/javax/swing/plaf/multi/MultiTextUI.java b/jdk/src/share/classes/javax/swing/plaf/multi/MultiTextUI.java index 7c704a5971e..30dae8fdb69 100644 --- a/jdk/src/share/classes/javax/swing/plaf/multi/MultiTextUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/multi/MultiTextUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2006, 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 @@ -65,6 +65,8 @@ public class MultiTextUI extends TextUI { * Returns the list of UIs associated with this multiplexing UI. This * allows processing of the UIs by an application aware of multiplexing * UIs on components. + * + * @return an array of the UI delegates */ public ComponentUI[] getUIs() { return MultiLookAndFeel.uisToArray(uis); @@ -248,6 +250,9 @@ public class MultiTextUI extends TextUI { * Returns a multiplexing UI instance if any of the auxiliary * LookAndFeels supports this UI. Otherwise, just returns the * UI object obtained from the default LookAndFeel. + * + * @param a the component to create the UI for + * @return the UI delegate created */ public static ComponentUI createUI(JComponent a) { ComponentUI mui = new MultiTextUI(); diff --git a/jdk/src/share/classes/javax/swing/plaf/multi/MultiToolBarUI.java b/jdk/src/share/classes/javax/swing/plaf/multi/MultiToolBarUI.java index 1922c2679d4..172524e9c94 100644 --- a/jdk/src/share/classes/javax/swing/plaf/multi/MultiToolBarUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/multi/MultiToolBarUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2001, 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 @@ -57,6 +57,8 @@ public class MultiToolBarUI extends ToolBarUI { * Returns the list of UIs associated with this multiplexing UI. This * allows processing of the UIs by an application aware of multiplexing * UIs on components. + * + * @return an array of the UI delegates */ public ComponentUI[] getUIs() { return MultiLookAndFeel.uisToArray(uis); @@ -98,6 +100,9 @@ public class MultiToolBarUI extends ToolBarUI { * Returns a multiplexing UI instance if any of the auxiliary * LookAndFeels supports this UI. Otherwise, just returns the * UI object obtained from the default LookAndFeel. + * + * @param a the component to create the UI for + * @return the UI delegate created */ public static ComponentUI createUI(JComponent a) { ComponentUI mui = new MultiToolBarUI(); diff --git a/jdk/src/share/classes/javax/swing/plaf/multi/MultiToolTipUI.java b/jdk/src/share/classes/javax/swing/plaf/multi/MultiToolTipUI.java index c2848af6858..e6062120733 100644 --- a/jdk/src/share/classes/javax/swing/plaf/multi/MultiToolTipUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/multi/MultiToolTipUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2001, 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 @@ -57,6 +57,8 @@ public class MultiToolTipUI extends ToolTipUI { * Returns the list of UIs associated with this multiplexing UI. This * allows processing of the UIs by an application aware of multiplexing * UIs on components. + * + * @return an array of the UI delegates */ public ComponentUI[] getUIs() { return MultiLookAndFeel.uisToArray(uis); @@ -98,6 +100,9 @@ public class MultiToolTipUI extends ToolTipUI { * Returns a multiplexing UI instance if any of the auxiliary * LookAndFeels supports this UI. Otherwise, just returns the * UI object obtained from the default LookAndFeel. + * + * @param a the component to create the UI for + * @return the UI delegate created */ public static ComponentUI createUI(JComponent a) { ComponentUI mui = new MultiToolTipUI(); diff --git a/jdk/src/share/classes/javax/swing/plaf/multi/MultiTreeUI.java b/jdk/src/share/classes/javax/swing/plaf/multi/MultiTreeUI.java index 8cc13957303..0828ded9e03 100644 --- a/jdk/src/share/classes/javax/swing/plaf/multi/MultiTreeUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/multi/MultiTreeUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2001, 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 @@ -60,6 +60,8 @@ public class MultiTreeUI extends TreeUI { * Returns the list of UIs associated with this multiplexing UI. This * allows processing of the UIs by an application aware of multiplexing * UIs on components. + * + * @return an array of the UI delegates */ public ComponentUI[] getUIs() { return MultiLookAndFeel.uisToArray(uis); @@ -239,6 +241,9 @@ public class MultiTreeUI extends TreeUI { * Returns a multiplexing UI instance if any of the auxiliary * LookAndFeels supports this UI. Otherwise, just returns the * UI object obtained from the default LookAndFeel. + * + * @param a the component to create the UI for + * @return the UI delegate created */ public static ComponentUI createUI(JComponent a) { ComponentUI mui = new MultiTreeUI(); diff --git a/jdk/src/share/classes/javax/swing/plaf/multi/MultiViewportUI.java b/jdk/src/share/classes/javax/swing/plaf/multi/MultiViewportUI.java index 7f6c162b72b..fff9e2eaa0f 100644 --- a/jdk/src/share/classes/javax/swing/plaf/multi/MultiViewportUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/multi/MultiViewportUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2001, 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 @@ -57,6 +57,8 @@ public class MultiViewportUI extends ViewportUI { * Returns the list of UIs associated with this multiplexing UI. This * allows processing of the UIs by an application aware of multiplexing * UIs on components. + * + * @return an array of the UI delegates */ public ComponentUI[] getUIs() { return MultiLookAndFeel.uisToArray(uis); @@ -98,6 +100,9 @@ public class MultiViewportUI extends ViewportUI { * Returns a multiplexing UI instance if any of the auxiliary * LookAndFeels supports this UI. Otherwise, just returns the * UI object obtained from the default LookAndFeel. + * + * @param a the component to create the UI for + * @return the UI delegate created */ public static ComponentUI createUI(JComponent a) { ComponentUI mui = new MultiViewportUI(); diff --git a/jdk/src/share/classes/javax/swing/plaf/nimbus/AbstractRegionPainter.java b/jdk/src/share/classes/javax/swing/plaf/nimbus/AbstractRegionPainter.java index f10dfd4298f..c41d9247138 100644 --- a/jdk/src/share/classes/javax/swing/plaf/nimbus/AbstractRegionPainter.java +++ b/jdk/src/share/classes/javax/swing/plaf/nimbus/AbstractRegionPainter.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 @@ -31,6 +31,7 @@ import javax.swing.*; import javax.swing.plaf.UIResource; import javax.swing.Painter; import java.awt.print.PrinterGraphics; +import sun.reflect.misc.MethodUtil; /** * Convenient base class for defining Painter instances for rendering a @@ -420,6 +421,13 @@ public abstract class AbstractRegionPainter implements Painter { * @param property The name of a bean style property or client property * @param defaultColor The color to return if no color was obtained from * the component. + * @param saturationOffset additively modifies the HSB saturation component + * of the color returned (ignored if default color is returned). + * @param brightnessOffset additively modifies the HSB brightness component + * of the color returned (ignored if default color is returned). + * @param alphaOffset additively modifies the ARGB alpha component of the + * color returned (ignored if default color is returned). + * * @return The color that was obtained from the component or defaultColor */ protected final Color getComponentColor(JComponent c, String property, @@ -445,8 +453,8 @@ public abstract class AbstractRegionPainter implements Painter { } else { String s = "get" + Character.toUpperCase(property.charAt(0)) + property.substring(1); try { - Method method = c.getClass().getMethod(s); - color = (Color) method.invoke(c); + Method method = MethodUtil.getMethod(c.getClass(), s, null); + color = (Color) MethodUtil.invoke(method, c, null); } catch (Exception e) { //don't do anything, it just didn't work, that's all. //This could be a normal occurance if you use a property diff --git a/jdk/src/share/classes/javax/swing/plaf/nimbus/NimbusStyle.java b/jdk/src/share/classes/javax/swing/plaf/nimbus/NimbusStyle.java index e38a0789e3c..bcdae78da79 100644 --- a/jdk/src/share/classes/javax/swing/plaf/nimbus/NimbusStyle.java +++ b/jdk/src/share/classes/javax/swing/plaf/nimbus/NimbusStyle.java @@ -653,7 +653,7 @@ public final class NimbusStyle extends SynthStyle { // strip off the prefix, if there is one. String fullKey = key.toString(); - String partialKey = fullKey.substring(fullKey.indexOf(".") + 1); + String partialKey = fullKey.substring(fullKey.indexOf('.') + 1); Object obj = null; int xstate = getExtendedState(ctx, v); diff --git a/jdk/src/share/classes/javax/swing/plaf/nimbus/State.java b/jdk/src/share/classes/javax/swing/plaf/nimbus/State.java index 5903eb01769..8485914e963 100644 --- a/jdk/src/share/classes/javax/swing/plaf/nimbus/State.java +++ b/jdk/src/share/classes/javax/swing/plaf/nimbus/State.java @@ -179,35 +179,35 @@ public abstract class State{ } private static String toString(int state) { - StringBuffer buffer = new StringBuffer(); + StringBuilder sb = new StringBuilder(); if ((state & SynthConstants.DEFAULT) == SynthConstants.DEFAULT) { - buffer.append("Default"); + sb.append("Default"); } if ((state & SynthConstants.DISABLED) == SynthConstants.DISABLED) { - if (buffer.length() > 0) buffer.append("+"); - buffer.append("Disabled"); + if (sb.length() > 0) sb.append("+"); + sb.append("Disabled"); } if ((state & SynthConstants.ENABLED) == SynthConstants.ENABLED) { - if (buffer.length() > 0) buffer.append("+"); - buffer.append("Enabled"); + if (sb.length() > 0) sb.append("+"); + sb.append("Enabled"); } if ((state & SynthConstants.FOCUSED) == SynthConstants.FOCUSED) { - if (buffer.length() > 0) buffer.append("+"); - buffer.append("Focused"); + if (sb.length() > 0) sb.append("+"); + sb.append("Focused"); } if ((state & SynthConstants.MOUSE_OVER) == SynthConstants.MOUSE_OVER) { - if (buffer.length() > 0) buffer.append("+"); - buffer.append("MouseOver"); + if (sb.length() > 0) sb.append("+"); + sb.append("MouseOver"); } if ((state & SynthConstants.PRESSED) == SynthConstants.PRESSED) { - if (buffer.length() > 0) buffer.append("+"); - buffer.append("Pressed"); + if (sb.length() > 0) sb.append("+"); + sb.append("Pressed"); } if ((state & SynthConstants.SELECTED) == SynthConstants.SELECTED) { - if (buffer.length() > 0) buffer.append("+"); - buffer.append("Selected"); + if (sb.length() > 0) sb.append("+"); + sb.append("Selected"); } - return buffer.toString(); + return sb.toString(); } } } diff --git a/jdk/src/share/classes/javax/swing/plaf/synth/ParsedSynthStyle.java b/jdk/src/share/classes/javax/swing/plaf/synth/ParsedSynthStyle.java index 9d96110643b..3173b40ab6a 100644 --- a/jdk/src/share/classes/javax/swing/plaf/synth/ParsedSynthStyle.java +++ b/jdk/src/share/classes/javax/swing/plaf/synth/ParsedSynthStyle.java @@ -156,7 +156,7 @@ class ParsedSynthStyle extends DefaultSynthStyle { } public String toString() { - StringBuffer text = new StringBuffer(super.toString()); + StringBuilder text = new StringBuilder(super.toString()); if (_painters != null) { text.append(",painters=["); for (int i = 0; i < +_painters.length; i++) { @@ -208,7 +208,7 @@ class ParsedSynthStyle extends DefaultSynthStyle { } public String toString() { - StringBuffer text = new StringBuffer(super.toString()); + StringBuilder text = new StringBuilder(super.toString()); text.append(",painters=["); if (_painterInfo != null) { for (int i = 0; i < +_painterInfo.length; i++) { diff --git a/jdk/src/share/classes/javax/swing/plaf/synth/SynthButtonUI.java b/jdk/src/share/classes/javax/swing/plaf/synth/SynthButtonUI.java index 74e13aaa900..4bfa159602c 100644 --- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthButtonUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthButtonUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -138,9 +138,7 @@ public class SynthButtonUI extends BasicButtonUI implements } SynthContext getContext(JComponent c, int state) { - Region region = SynthLookAndFeel.getRegion(c); - return SynthContext.getContext(SynthContext.class, c, region, - style, state); + return SynthContext.getContext(c, style, state); } /** @@ -515,6 +513,13 @@ public class SynthButtonUI extends BasicButtonUI implements /** * Returns the Icon used in calculating the * preferred/minimum/maximum size. + * + * @param b specifies the {@code AbstractButton} + * used when calculating the preferred/minimum/maximum + * size. + * + * @return the Icon used in calculating the + * preferred/minimum/maximum size. */ protected Icon getSizingIcon(AbstractButton b) { Icon icon = getEnabledIcon(b, b.getIcon()); diff --git a/jdk/src/share/classes/javax/swing/plaf/synth/SynthColorChooserUI.java b/jdk/src/share/classes/javax/swing/plaf/synth/SynthColorChooserUI.java index 92566845636..72ab2b09a16 100644 --- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthColorChooserUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthColorChooserUI.java @@ -128,8 +128,7 @@ public class SynthColorChooserUI extends BasicColorChooserUI implements } private SynthContext getContext(JComponent c, int state) { - return SynthContext.getContext(SynthContext.class, c, - SynthLookAndFeel.getRegion(c), style, state); + return SynthContext.getContext(c, style, state); } private int getComponentState(JComponent c) { diff --git a/jdk/src/share/classes/javax/swing/plaf/synth/SynthComboBoxUI.java b/jdk/src/share/classes/javax/swing/plaf/synth/SynthComboBoxUI.java index b36b4cf4984..b50e0e4887d 100644 --- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthComboBoxUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthComboBoxUI.java @@ -208,8 +208,7 @@ public class SynthComboBoxUI extends BasicComboBoxUI implements } private SynthContext getContext(JComponent c, int state) { - return SynthContext.getContext(SynthContext.class, c, - SynthLookAndFeel.getRegion(c), style, state); + return SynthContext.getContext(c, style, state); } private int getComponentState(JComponent c) { diff --git a/jdk/src/share/classes/javax/swing/plaf/synth/SynthContext.java b/jdk/src/share/classes/javax/swing/plaf/synth/SynthContext.java index 6d89a4a06c8..64b6e536f79 100644 --- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthContext.java +++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthContext.java @@ -24,8 +24,9 @@ */ package javax.swing.plaf.synth; -import javax.swing.*; -import java.util.*; +import java.util.Queue; +import java.util.concurrent.ConcurrentLinkedQueue; +import javax.swing.JComponent; /** * An immutable transient object containing contextual information about @@ -39,59 +40,32 @@ import java.util.*; * @author Scott Violet */ public class SynthContext { - private static final Map> contextMap; + private static final Queue queue = new ConcurrentLinkedQueue<>(); private JComponent component; private Region region; private SynthStyle style; private int state; - - static { - contextMap = new HashMap>(); + static SynthContext getContext(JComponent c, SynthStyle style, int state) { + return getContext(c, SynthLookAndFeel.getRegion(c), style, state); } - - static SynthContext getContext(Class type, JComponent component, + static SynthContext getContext(JComponent component, Region region, SynthStyle style, int state) { - SynthContext context = null; - - synchronized(contextMap) { - List instances = contextMap.get(type); - - if (instances != null) { - int size = instances.size(); - - if (size > 0) { - context = instances.remove(size - 1); - } - } - } + SynthContext context = queue.poll(); if (context == null) { - try { - context = (SynthContext)type.newInstance(); - } catch (IllegalAccessException iae) { - } catch (InstantiationException ie) { - } + context = new SynthContext(); } context.reset(component, region, style, state); return context; } static void releaseContext(SynthContext context) { - synchronized(contextMap) { - List instances = contextMap.get(context.getClass()); - - if (instances == null) { - instances = new ArrayList(5); - contextMap.put(context.getClass(), instances); - } - instances.add(context); - } + queue.offer(context); } - SynthContext() { } diff --git a/jdk/src/share/classes/javax/swing/plaf/synth/SynthDesktopIconUI.java b/jdk/src/share/classes/javax/swing/plaf/synth/SynthDesktopIconUI.java index e10014100d9..8da1fe0cf3b 100644 --- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthDesktopIconUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthDesktopIconUI.java @@ -144,9 +144,7 @@ public class SynthDesktopIconUI extends BasicDesktopIconUI } private SynthContext getContext(JComponent c, int state) { - Region region = SynthLookAndFeel.getRegion(c); - return SynthContext.getContext(SynthContext.class, c, region, - style, state); + return SynthContext.getContext(c, style, state); } private int getComponentState(JComponent c) { diff --git a/jdk/src/share/classes/javax/swing/plaf/synth/SynthDesktopPaneUI.java b/jdk/src/share/classes/javax/swing/plaf/synth/SynthDesktopPaneUI.java index 40300565b9a..6259171317b 100644 --- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthDesktopPaneUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthDesktopPaneUI.java @@ -432,8 +432,7 @@ public class SynthDesktopPaneUI extends BasicDesktopPaneUI implements } private SynthContext getContext(JComponent c, int state) { - return SynthContext.getContext(SynthContext.class, c, - SynthLookAndFeel.getRegion(c), style, state); + return SynthContext.getContext(c, style, state); } private int getComponentState(JComponent c) { diff --git a/jdk/src/share/classes/javax/swing/plaf/synth/SynthEditorPaneUI.java b/jdk/src/share/classes/javax/swing/plaf/synth/SynthEditorPaneUI.java index 2ccf59268de..69489197d6a 100644 --- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthEditorPaneUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthEditorPaneUI.java @@ -139,8 +139,7 @@ public class SynthEditorPaneUI extends BasicEditorPaneUI implements SynthUI { } private SynthContext getContext(JComponent c, int state) { - return SynthContext.getContext(SynthContext.class, c, - SynthLookAndFeel.getRegion(c), style, state); + return SynthContext.getContext(c, style, state); } private int getComponentState(JComponent c) { diff --git a/jdk/src/share/classes/javax/swing/plaf/synth/SynthGraphicsUtils.java b/jdk/src/share/classes/javax/swing/plaf/synth/SynthGraphicsUtils.java index 9f68e956a48..8464dd25e49 100644 --- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthGraphicsUtils.java +++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthGraphicsUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -137,6 +137,9 @@ public class SynthGraphicsUtils { * @param iconR Rectangle to place icon bounds in * @param textR Rectangle to place text in * @param iconTextGap gap between icon and text + * + * @return by reference, the location to + * place the icon and text. */ public String layoutText(SynthContext ss, FontMetrics fm, String text, Icon icon, int hAlign, @@ -166,6 +169,8 @@ public class SynthGraphicsUtils { * @param font Font to use * @param metrics FontMetrics, may be ignored * @param text Text to get size of. + * + * @return the size of the passed in string. */ public int computeStringWidth(SynthContext ss, Font font, FontMetrics metrics, String text) { @@ -187,6 +192,8 @@ public class SynthGraphicsUtils { * @param iconTextGap gap between icon and text * @param mnemonicIndex Index into text to render the mnemonic at, -1 * indicates no mnemonic. + * + * @return the minimum size needed to properly render an icon and text. */ public Dimension getMinimumSize(SynthContext ss, Font font, String text, Icon icon, int hAlign, int vAlign, int hTextPosition, @@ -218,6 +225,8 @@ public class SynthGraphicsUtils { * @param iconTextGap gap between icon and text * @param mnemonicIndex Index into text to render the mnemonic at, -1 * indicates no mnemonic. + * + * @return the maximum size needed to properly render an icon and text. */ public Dimension getMaximumSize(SynthContext ss, Font font, String text, Icon icon, int hAlign, int vAlign, int hTextPosition, @@ -263,6 +272,8 @@ public class SynthGraphicsUtils { * @param iconTextGap gap between icon and text * @param mnemonicIndex Index into text to render the mnemonic at, -1 * indicates no mnemonic. + * + * @return the preferred size needed to properly render an icon and text. */ public Dimension getPreferredSize(SynthContext ss, Font font, String text, Icon icon, int hAlign, int vAlign, int hTextPosition, diff --git a/jdk/src/share/classes/javax/swing/plaf/synth/SynthInternalFrameTitlePane.java b/jdk/src/share/classes/javax/swing/plaf/synth/SynthInternalFrameTitlePane.java index abf490ce863..92ad059085d 100644 --- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthInternalFrameTitlePane.java +++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthInternalFrameTitlePane.java @@ -68,8 +68,7 @@ class SynthInternalFrameTitlePane extends BasicInternalFrameTitlePane } public SynthContext getContext(JComponent c, int state) { - return SynthContext.getContext(SynthContext.class, c, - SynthLookAndFeel.getRegion(c), style, state); + return SynthContext.getContext(c, style, state); } private Region getRegion(JComponent c) { diff --git a/jdk/src/share/classes/javax/swing/plaf/synth/SynthInternalFrameUI.java b/jdk/src/share/classes/javax/swing/plaf/synth/SynthInternalFrameUI.java index 34c94cdbc8f..c5c1ef7fdad 100644 --- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthInternalFrameUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthInternalFrameUI.java @@ -141,8 +141,7 @@ public class SynthInternalFrameUI extends BasicInternalFrameUI } private SynthContext getContext(JComponent c, int state) { - return SynthContext.getContext(SynthContext.class, c, - SynthLookAndFeel.getRegion(c), style, state); + return SynthContext.getContext(c, style, state); } private int getComponentState(JComponent c) { diff --git a/jdk/src/share/classes/javax/swing/plaf/synth/SynthLabelUI.java b/jdk/src/share/classes/javax/swing/plaf/synth/SynthLabelUI.java index 45031e99188..22e57e5e4a8 100644 --- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthLabelUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthLabelUI.java @@ -91,8 +91,7 @@ public class SynthLabelUI extends BasicLabelUI implements SynthUI { } private SynthContext getContext(JComponent c, int state) { - return SynthContext.getContext(SynthContext.class, c, - SynthLookAndFeel.getRegion(c), style, state); + return SynthContext.getContext(c, style, state); } private int getComponentState(JComponent c) { diff --git a/jdk/src/share/classes/javax/swing/plaf/synth/SynthListUI.java b/jdk/src/share/classes/javax/swing/plaf/synth/SynthListUI.java index 58a443acb44..6a36a58a14f 100644 --- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthListUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthListUI.java @@ -188,8 +188,7 @@ public class SynthListUI extends BasicListUI } private SynthContext getContext(JComponent c, int state) { - return SynthContext.getContext(SynthContext.class, c, - SynthLookAndFeel.getRegion(c), style, state); + return SynthContext.getContext(c, style, state); } private int getComponentState(JComponent c) { diff --git a/jdk/src/share/classes/javax/swing/plaf/synth/SynthMenuBarUI.java b/jdk/src/share/classes/javax/swing/plaf/synth/SynthMenuBarUI.java index 9c1f9cba227..1f096646495 100644 --- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthMenuBarUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthMenuBarUI.java @@ -116,8 +116,7 @@ public class SynthMenuBarUI extends BasicMenuBarUI } private SynthContext getContext(JComponent c, int state) { - return SynthContext.getContext(SynthContext.class, c, - SynthLookAndFeel.getRegion(c), style, state); + return SynthContext.getContext(c, style, state); } private int getComponentState(JComponent c) { diff --git a/jdk/src/share/classes/javax/swing/plaf/synth/SynthMenuItemUI.java b/jdk/src/share/classes/javax/swing/plaf/synth/SynthMenuItemUI.java index 19ac0a760b3..956f76f1fb3 100644 --- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthMenuItemUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthMenuItemUI.java @@ -170,8 +170,7 @@ public class SynthMenuItemUI extends BasicMenuItemUI implements } SynthContext getContext(JComponent c, int state) { - return SynthContext.getContext(SynthContext.class, c, - SynthLookAndFeel.getRegion(c), style, state); + return SynthContext.getContext(c, style, state); } SynthContext getContext(JComponent c, Region region) { @@ -179,8 +178,7 @@ public class SynthMenuItemUI extends BasicMenuItemUI implements } private SynthContext getContext(JComponent c, Region region, int state) { - return SynthContext.getContext(SynthContext.class, c, - region, accStyle, state); + return SynthContext.getContext(c, region, accStyle, state); } private int getComponentState(JComponent c) { diff --git a/jdk/src/share/classes/javax/swing/plaf/synth/SynthMenuUI.java b/jdk/src/share/classes/javax/swing/plaf/synth/SynthMenuUI.java index 3f53f461ecc..7bb66a25c93 100644 --- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthMenuUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthMenuUI.java @@ -170,9 +170,7 @@ public class SynthMenuUI extends BasicMenuUI } SynthContext getContext(JComponent c, int state) { - Region region = SynthLookAndFeel.getRegion(c); - return SynthContext.getContext(SynthContext.class, c, region, - style, state); + return SynthContext.getContext(c, style, state); } SynthContext getContext(JComponent c, Region region) { @@ -180,8 +178,7 @@ public class SynthMenuUI extends BasicMenuUI } private SynthContext getContext(JComponent c, Region region, int state) { - return SynthContext.getContext(SynthContext.class, c, - region, accStyle, state); + return SynthContext.getContext(c, region, accStyle, state); } private int getComponentState(JComponent c) { diff --git a/jdk/src/share/classes/javax/swing/plaf/synth/SynthOptionPaneUI.java b/jdk/src/share/classes/javax/swing/plaf/synth/SynthOptionPaneUI.java index 42d454cf8d9..de6f2a7135e 100644 --- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthOptionPaneUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthOptionPaneUI.java @@ -140,8 +140,7 @@ public class SynthOptionPaneUI extends BasicOptionPaneUI implements } private SynthContext getContext(JComponent c, int state) { - return SynthContext.getContext(SynthContext.class, c, - SynthLookAndFeel.getRegion(c), style, state); + return SynthContext.getContext(c, style, state); } private int getComponentState(JComponent c) { diff --git a/jdk/src/share/classes/javax/swing/plaf/synth/SynthPanelUI.java b/jdk/src/share/classes/javax/swing/plaf/synth/SynthPanelUI.java index ddfff5c1597..73f37ff530b 100644 --- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthPanelUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthPanelUI.java @@ -127,8 +127,7 @@ public class SynthPanelUI extends BasicPanelUI } private SynthContext getContext(JComponent c, int state) { - return SynthContext.getContext(SynthContext.class, c, - SynthLookAndFeel.getRegion(c), style, state); + return SynthContext.getContext(c, style, state); } private int getComponentState(JComponent c) { diff --git a/jdk/src/share/classes/javax/swing/plaf/synth/SynthParser.java b/jdk/src/share/classes/javax/swing/plaf/synth/SynthParser.java index ef38ae11387..a15bb509e78 100644 --- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthParser.java +++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthParser.java @@ -67,6 +67,7 @@ import org.xml.sax.SAXParseException; import org.xml.sax.helpers.DefaultHandler; import com.sun.beans.decoder.DocumentHandler; +import sun.reflect.misc.ReflectUtil; class SynthParser extends DefaultHandler { // @@ -648,7 +649,7 @@ class SynthParser extends DefaultHandler { } else { try { - typeClass = Class.forName(typeName.substring( + typeClass = ReflectUtil.forName(typeName.substring( 0, classIndex)); } catch (ClassNotFoundException cnfe) { throw new SAXException("Unknown class: " + diff --git a/jdk/src/share/classes/javax/swing/plaf/synth/SynthPopupMenuUI.java b/jdk/src/share/classes/javax/swing/plaf/synth/SynthPopupMenuUI.java index d228abab79a..cbb09f29212 100644 --- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthPopupMenuUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthPopupMenuUI.java @@ -123,8 +123,7 @@ public class SynthPopupMenuUI extends BasicPopupMenuUI } private SynthContext getContext(JComponent c, int state) { - return SynthContext.getContext(SynthContext.class, c, - SynthLookAndFeel.getRegion(c), style, state); + return SynthContext.getContext(c, style, state); } private int getComponentState(JComponent c) { diff --git a/jdk/src/share/classes/javax/swing/plaf/synth/SynthProgressBarUI.java b/jdk/src/share/classes/javax/swing/plaf/synth/SynthProgressBarUI.java index 1afc81bb1f4..c37ce490368 100644 --- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthProgressBarUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthProgressBarUI.java @@ -138,8 +138,7 @@ public class SynthProgressBarUI extends BasicProgressBarUI } private SynthContext getContext(JComponent c, int state) { - return SynthContext.getContext(SynthContext.class, c, - SynthLookAndFeel.getRegion(c), style, state); + return SynthContext.getContext(c, style, state); } private int getComponentState(JComponent c) { diff --git a/jdk/src/share/classes/javax/swing/plaf/synth/SynthRootPaneUI.java b/jdk/src/share/classes/javax/swing/plaf/synth/SynthRootPaneUI.java index 0d437de7613..1115fe35551 100644 --- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthRootPaneUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthRootPaneUI.java @@ -80,8 +80,7 @@ public class SynthRootPaneUI extends BasicRootPaneUI implements SynthUI { } private SynthContext getContext(JComponent c, int state) { - return SynthContext.getContext(SynthContext.class, c, - SynthLookAndFeel.getRegion(c), style, state); + return SynthContext.getContext(c, style, state); } private int getComponentState(JComponent c) { diff --git a/jdk/src/share/classes/javax/swing/plaf/synth/SynthScrollBarUI.java b/jdk/src/share/classes/javax/swing/plaf/synth/SynthScrollBarUI.java index d3e948d899c..498d69e1e86 100644 --- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthScrollBarUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthScrollBarUI.java @@ -185,8 +185,7 @@ public class SynthScrollBarUI extends BasicScrollBarUI } private SynthContext getContext(JComponent c, int state) { - return SynthContext.getContext(SynthContext.class, c, - SynthLookAndFeel.getRegion(c), style, state); + return SynthContext.getContext(c, style, state); } private SynthContext getContext(JComponent c, Region region) { @@ -199,8 +198,7 @@ public class SynthScrollBarUI extends BasicScrollBarUI if (region == Region.SCROLL_BAR_THUMB) { style = thumbStyle; } - return SynthContext.getContext(SynthContext.class, c, region, style, - state); + return SynthContext.getContext(c, region, style, state); } private int getComponentState(JComponent c, Region region) { diff --git a/jdk/src/share/classes/javax/swing/plaf/synth/SynthScrollPaneUI.java b/jdk/src/share/classes/javax/swing/plaf/synth/SynthScrollPaneUI.java index 6b261546408..6b3e29602de 100644 --- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthScrollPaneUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthScrollPaneUI.java @@ -211,8 +211,7 @@ public class SynthScrollPaneUI extends BasicScrollPaneUI } private SynthContext getContext(JComponent c, int state) { - return SynthContext.getContext(SynthContext.class, c, - SynthLookAndFeel.getRegion(c), style, state); + return SynthContext.getContext(c, style, state); } private int getComponentState(JComponent c) { diff --git a/jdk/src/share/classes/javax/swing/plaf/synth/SynthSeparatorUI.java b/jdk/src/share/classes/javax/swing/plaf/synth/SynthSeparatorUI.java index 7e759d4e3be..a222a428080 100644 --- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthSeparatorUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthSeparatorUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -78,6 +78,9 @@ public class SynthSeparatorUI extends SeparatorUI /** * Installs default setting. This method is called when a * {@code LookAndFeel} is installed. + * + * @param c specifies the {@code JSeparator} for the installed + * {@code LookAndFeel}. */ public void installDefaults(JSeparator c) { updateStyle(c); @@ -109,6 +112,9 @@ public class SynthSeparatorUI extends SeparatorUI /** * Uninstalls default setting. This method is called when a * {@code LookAndFeel} is uninstalled. + * + * @param c specifies the {@code JSeparator} for the (un)installed + * {@code LookAndFeel}. */ public void uninstallDefaults(JSeparator c) { SynthContext context = getContext(c, ENABLED); @@ -121,6 +127,9 @@ public class SynthSeparatorUI extends SeparatorUI /** * Installs listeners. This method is called when a * {@code LookAndFeel} is installed. + * + * @param c specifies the {@code JSeparator} for the installed + * {@code LookAndFeel}. */ public void installListeners(JSeparator c) { c.addPropertyChangeListener(this); @@ -129,6 +138,9 @@ public class SynthSeparatorUI extends SeparatorUI /** * Uninstalls listeners. This method is called when a * {@code LookAndFeel} is uninstalled. + * + * @param c specifies the {@code JSeparator} for the (un)installed + * {@code LookAndFeel}. */ public void uninstallListeners(JSeparator c) { c.removePropertyChangeListener(this); @@ -248,8 +260,7 @@ public class SynthSeparatorUI extends SeparatorUI } private SynthContext getContext(JComponent c, int state) { - return SynthContext.getContext(SynthContext.class, c, - SynthLookAndFeel.getRegion(c), style, state); + return SynthContext.getContext(c, style, state); } public void propertyChange(PropertyChangeEvent evt) { diff --git a/jdk/src/share/classes/javax/swing/plaf/synth/SynthSliderUI.java b/jdk/src/share/classes/javax/swing/plaf/synth/SynthSliderUI.java index 65d461264dc..5cc7cd48606 100644 --- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthSliderUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthSliderUI.java @@ -722,8 +722,7 @@ public class SynthSliderUI extends BasicSliderUI } private SynthContext getContext(JComponent c, int state) { - return SynthContext.getContext(SynthContext.class, c, - SynthLookAndFeel.getRegion(c), style, state); + return SynthContext.getContext(c, style, state); } private SynthContext getContext(JComponent c, Region subregion) { @@ -732,14 +731,13 @@ public class SynthSliderUI extends BasicSliderUI private SynthContext getContext(JComponent c, Region subregion, int state) { SynthStyle style = null; - Class klass = SynthContext.class; if (subregion == Region.SLIDER_TRACK) { style = sliderTrackStyle; } else if (subregion == Region.SLIDER_THUMB) { style = sliderThumbStyle; } - return SynthContext.getContext(klass, c, subregion, style, state); + return SynthContext.getContext(c, subregion, style, state); } private int getComponentState(JComponent c, Region region) { diff --git a/jdk/src/share/classes/javax/swing/plaf/synth/SynthSpinnerUI.java b/jdk/src/share/classes/javax/swing/plaf/synth/SynthSpinnerUI.java index d8bc4feea52..a1293dfdadd 100644 --- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthSpinnerUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthSpinnerUI.java @@ -278,8 +278,7 @@ public class SynthSpinnerUI extends BasicSpinnerUI } private SynthContext getContext(JComponent c, int state) { - return SynthContext.getContext(SynthContext.class, c, - SynthLookAndFeel.getRegion(c), style, state); + return SynthContext.getContext(c, style, state); } /** diff --git a/jdk/src/share/classes/javax/swing/plaf/synth/SynthSplitPaneUI.java b/jdk/src/share/classes/javax/swing/plaf/synth/SynthSplitPaneUI.java index 2c5031c03d6..f82ccb37fab 100644 --- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthSplitPaneUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthSplitPaneUI.java @@ -209,8 +209,7 @@ public class SynthSplitPaneUI extends BasicSplitPaneUI } private SynthContext getContext(JComponent c, int state) { - return SynthContext.getContext(SynthContext.class, c, - SynthLookAndFeel.getRegion(c), style, state); + return SynthContext.getContext(c, style, state); } SynthContext getContext(JComponent c, Region region) { @@ -219,11 +218,9 @@ public class SynthSplitPaneUI extends BasicSplitPaneUI private SynthContext getContext(JComponent c, Region region, int state) { if (region == Region.SPLIT_PANE_DIVIDER) { - return SynthContext.getContext(SynthContext.class, c, region, - dividerStyle, state); + return SynthContext.getContext(c, region, dividerStyle, state); } - return SynthContext.getContext(SynthContext.class, c, region, - style, state); + return SynthContext.getContext(c, region, style, state); } private int getComponentState(JComponent c, Region subregion) { diff --git a/jdk/src/share/classes/javax/swing/plaf/synth/SynthTabbedPaneUI.java b/jdk/src/share/classes/javax/swing/plaf/synth/SynthTabbedPaneUI.java index df09ba5fcfa..211e8a2c331 100644 --- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthTabbedPaneUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthTabbedPaneUI.java @@ -235,13 +235,11 @@ public class SynthTabbedPaneUI extends BasicTabbedPaneUI } private SynthContext getContext(JComponent c, int state) { - return SynthContext.getContext(SynthContext.class, c, - SynthLookAndFeel.getRegion(c),style, state); + return SynthContext.getContext(c, style, state); } private SynthContext getContext(JComponent c, Region subregion, int state){ SynthStyle style = null; - Class klass = SynthContext.class; if (subregion == Region.TABBED_PANE_TAB) { style = tabStyle; @@ -252,7 +250,7 @@ public class SynthTabbedPaneUI extends BasicTabbedPaneUI else if (subregion == Region.TABBED_PANE_CONTENT) { style = tabContentStyle; } - return SynthContext.getContext(klass, c, subregion, style, state); + return SynthContext.getContext(c, subregion, style, state); } /** diff --git a/jdk/src/share/classes/javax/swing/plaf/synth/SynthTableHeaderUI.java b/jdk/src/share/classes/javax/swing/plaf/synth/SynthTableHeaderUI.java index a988692a4aa..f09f86d6548 100644 --- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthTableHeaderUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthTableHeaderUI.java @@ -193,8 +193,7 @@ public class SynthTableHeaderUI extends BasicTableHeaderUI } private SynthContext getContext(JComponent c, int state) { - return SynthContext.getContext(SynthContext.class, c, - SynthLookAndFeel.getRegion(c), style, state); + return SynthContext.getContext(c, style, state); } /** diff --git a/jdk/src/share/classes/javax/swing/plaf/synth/SynthTableUI.java b/jdk/src/share/classes/javax/swing/plaf/synth/SynthTableUI.java index da49bddc4c2..194e9deee84 100644 --- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthTableUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthTableUI.java @@ -246,8 +246,7 @@ public class SynthTableUI extends BasicTableUI } private SynthContext getContext(JComponent c, int state) { - return SynthContext.getContext(SynthContext.class, c, - SynthLookAndFeel.getRegion(c), style, state); + return SynthContext.getContext(c, style, state); } // diff --git a/jdk/src/share/classes/javax/swing/plaf/synth/SynthTextAreaUI.java b/jdk/src/share/classes/javax/swing/plaf/synth/SynthTextAreaUI.java index 441698ce0a9..33214dad926 100644 --- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthTextAreaUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthTextAreaUI.java @@ -119,8 +119,7 @@ public class SynthTextAreaUI extends BasicTextAreaUI implements SynthUI { } private SynthContext getContext(JComponent c, int state) { - return SynthContext.getContext(SynthContext.class, c, - SynthLookAndFeel.getRegion(c), style, state); + return SynthContext.getContext(c, style, state); } /** diff --git a/jdk/src/share/classes/javax/swing/plaf/synth/SynthTextFieldUI.java b/jdk/src/share/classes/javax/swing/plaf/synth/SynthTextFieldUI.java index 7028a5a5999..6adb7538e88 100644 --- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthTextFieldUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthTextFieldUI.java @@ -157,8 +157,7 @@ public class SynthTextFieldUI extends BasicTextFieldUI implements SynthUI { } private SynthContext getContext(JComponent c, int state) { - return SynthContext.getContext(SynthContext.class, c, - SynthLookAndFeel.getRegion(c), style, state); + return SynthContext.getContext(c, style, state); } /** diff --git a/jdk/src/share/classes/javax/swing/plaf/synth/SynthToolBarUI.java b/jdk/src/share/classes/javax/swing/plaf/synth/SynthToolBarUI.java index f65fdd14dc1..51d2fefd17e 100644 --- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthToolBarUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthToolBarUI.java @@ -178,19 +178,17 @@ public class SynthToolBarUI extends BasicToolBarUI } private SynthContext getContext(JComponent c, int state) { - return SynthContext.getContext(SynthContext.class, c, - SynthLookAndFeel.getRegion(c), style, state); + return SynthContext.getContext(c, style, state); } private SynthContext getContext(JComponent c, Region region, SynthStyle style) { - return SynthContext.getContext(SynthContext.class, c, region, + return SynthContext.getContext(c, region, style, getComponentState(c, region)); } private SynthContext getContext(JComponent c, Region region, SynthStyle style, int state) { - return SynthContext.getContext(SynthContext.class, c, region, - style, state); + return SynthContext.getContext(c, region, style, state); } private int getComponentState(JComponent c, Region region) { diff --git a/jdk/src/share/classes/javax/swing/plaf/synth/SynthToolTipUI.java b/jdk/src/share/classes/javax/swing/plaf/synth/SynthToolTipUI.java index afd49f4a7e5..dc42debba7d 100644 --- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthToolTipUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthToolTipUI.java @@ -107,8 +107,7 @@ public class SynthToolTipUI extends BasicToolTipUI } private SynthContext getContext(JComponent c, int state) { - return SynthContext.getContext(SynthContext.class, c, - SynthLookAndFeel.getRegion(c), style, state); + return SynthContext.getContext(c, style, state); } private int getComponentState(JComponent c) { diff --git a/jdk/src/share/classes/javax/swing/plaf/synth/SynthTreeUI.java b/jdk/src/share/classes/javax/swing/plaf/synth/SynthTreeUI.java index a214532ed56..d8107879254 100644 --- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthTreeUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthTreeUI.java @@ -173,8 +173,7 @@ public class SynthTreeUI extends BasicTreeUI } private SynthContext getContext(JComponent c, int state) { - return SynthContext.getContext(SynthContext.class, c, - SynthLookAndFeel.getRegion(c), style, state); + return SynthContext.getContext(c, style, state); } private SynthContext getContext(JComponent c, Region region) { @@ -182,8 +181,7 @@ public class SynthTreeUI extends BasicTreeUI } private SynthContext getContext(JComponent c, Region region, int state) { - return SynthContext.getContext(SynthContext.class, c, - region, cellStyle, state); + return SynthContext.getContext(c, region, cellStyle, state); } private int getComponentState(JComponent c, Region region) { diff --git a/jdk/src/share/classes/javax/swing/plaf/synth/SynthViewportUI.java b/jdk/src/share/classes/javax/swing/plaf/synth/SynthViewportUI.java index 4c5a9b0cd88..dc3e6c6e1a1 100644 --- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthViewportUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthViewportUI.java @@ -141,8 +141,7 @@ public class SynthViewportUI extends ViewportUI } private SynthContext getContext(JComponent c, int state) { - return SynthContext.getContext(SynthContext.class, c, - getRegion(c), style, state); + return SynthContext.getContext(c, style, state); } private Region getRegion(JComponent c) { diff --git a/jdk/src/share/classes/javax/swing/table/DefaultTableColumnModel.java b/jdk/src/share/classes/javax/swing/table/DefaultTableColumnModel.java index 96193cb35fd..7e02789f837 100644 --- a/jdk/src/share/classes/javax/swing/table/DefaultTableColumnModel.java +++ b/jdk/src/share/classes/javax/swing/table/DefaultTableColumnModel.java @@ -716,6 +716,8 @@ public class DefaultTableColumnModel implements TableColumnModel, /** * Creates a new default list selection model. + * + * @return a newly created default list selection model. */ protected ListSelectionModel createSelectionModel() { return new DefaultListSelectionModel(); diff --git a/jdk/src/share/classes/javax/swing/table/DefaultTableModel.java b/jdk/src/share/classes/javax/swing/table/DefaultTableModel.java index 74b88c1160d..251738ae40d 100644 --- a/jdk/src/share/classes/javax/swing/table/DefaultTableModel.java +++ b/jdk/src/share/classes/javax/swing/table/DefaultTableModel.java @@ -335,6 +335,8 @@ public class DefaultTableModel extends AbstractTableModel implements Serializabl * * @see #setColumnCount * @since 1.3 + * + * @param rowCount number of rows in the model */ public void setRowCount(int rowCount) { setNumRows(rowCount); @@ -577,6 +579,9 @@ public class DefaultTableModel extends AbstractTableModel implements Serializabl * element going to row 0, etc. This method will send a * tableChanged notification message to all the listeners. * + * @param columnName identifier of the newly created column + * @param columnData new data to be added to the column + * * @see #addColumn(Object, Vector) */ public void addColumn(Object columnName, Object[] columnData) { diff --git a/jdk/src/share/classes/javax/swing/table/JTableHeader.java b/jdk/src/share/classes/javax/swing/table/JTableHeader.java index 3995cccc288..5e923b1356d 100644 --- a/jdk/src/share/classes/javax/swing/table/JTableHeader.java +++ b/jdk/src/share/classes/javax/swing/table/JTableHeader.java @@ -336,6 +336,10 @@ public class JTableHeader extends JComponent implements TableColumnModelListener * Returns the index of the column that point lies in, or -1 if it * lies out of bounds. * + * @param point if this point lies within a column, the index of + * that column will be returned; otherwise it is out of bounds + * and -1 is returned + * * @return the index of the column that point lies in, or -1 if it * lies out of bounds */ @@ -352,6 +356,8 @@ public class JTableHeader extends JComponent implements TableColumnModelListener * When the column parameter is out of bounds this method uses the * same conventions as the JTable method getCellRect. * + * @param column index of the column + * * @return the rectangle containing the header tile at column * @see JTable#getCellRect */ @@ -883,6 +889,10 @@ public class JTableHeader extends JComponent implements TableColumnModelListener /** * Constructs an AccessiblJTableHeaaderEntry * @since 1.4 + * + * @param c the column index + * @param p the parent JTableHeader + * @param t the table JTable */ public AccessibleJTableHeaderEntry(int c, JTableHeader p, JTable t) { parent = p; diff --git a/jdk/src/share/classes/javax/swing/table/TableCellRenderer.java b/jdk/src/share/classes/javax/swing/table/TableCellRenderer.java index 892220bc47c..585d9221482 100644 --- a/jdk/src/share/classes/javax/swing/table/TableCellRenderer.java +++ b/jdk/src/share/classes/javax/swing/table/TableCellRenderer.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 @@ -86,6 +86,9 @@ public interface TableCellRenderer { * drawing the header, the value of * row is -1 * @param column the column index of the cell being drawn + * + * @return the component used for drawing the cell. + * * @see javax.swing.JComponent#isPaintingForPrint() */ Component getTableCellRendererComponent(JTable table, Object value, diff --git a/jdk/src/share/classes/javax/swing/table/TableColumn.java b/jdk/src/share/classes/javax/swing/table/TableColumn.java index 713bf5483dc..1f116c47832 100644 --- a/jdk/src/share/classes/javax/swing/table/TableColumn.java +++ b/jdk/src/share/classes/javax/swing/table/TableColumn.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 @@ -201,6 +201,11 @@ public class TableColumn extends Object implements Serializable { * Cover method, using a default width of 75, a null * renderer and a null editor. * @see #TableColumn(int, int, TableCellRenderer, TableCellEditor) + * + * @param modelIndex the index of the column in the model + * that supplies the data for this column in the table; + * the model index remains the same even when columns + * are reordered in the view */ public TableColumn(int modelIndex) { this(modelIndex, 75, null, null); @@ -210,6 +215,12 @@ public class TableColumn extends Object implements Serializable { * Cover method, using a null renderer and a * null editor. * @see #TableColumn(int, int, TableCellRenderer, TableCellEditor) + * + * @param modelIndex the index of the column in the model + * that supplies the data for this column in the table; + * the model index remains the same even when columns + * are reordered in the view + * @param width this column's preferred width and initial width */ public TableColumn(int modelIndex, int width) { this(modelIndex, width, null, null); diff --git a/jdk/src/share/classes/javax/swing/table/TableColumnModel.java b/jdk/src/share/classes/javax/swing/table/TableColumnModel.java index b6c308c0ea7..eaaa8447ef7 100644 --- a/jdk/src/share/classes/javax/swing/table/TableColumnModel.java +++ b/jdk/src/share/classes/javax/swing/table/TableColumnModel.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 @@ -162,6 +162,9 @@ public interface TableColumnModel * model. If the column index for a given X coordinate in 2D space is * required, JTable.columnAtPoint can be used instead. * + * @param xPosition width from the start of the first column in + * the model. + * * @return the index of the column; or -1 if no column is found * @see javax.swing.JTable#columnAtPoint */ diff --git a/jdk/src/share/classes/javax/swing/text/AbstractDocument.java b/jdk/src/share/classes/javax/swing/text/AbstractDocument.java index a7a109f8c91..e42d549791a 100644 --- a/jdk/src/share/classes/javax/swing/text/AbstractDocument.java +++ b/jdk/src/share/classes/javax/swing/text/AbstractDocument.java @@ -1809,7 +1809,7 @@ public abstract class AbstractDocument implements Document, Serializable { if (getAttributeCount() > 0) { out.println(""); // dump the attributes - Enumeration names = attributes.getAttributeNames(); + Enumeration names = attributes.getAttributeNames(); while (names.hasMoreElements()) { Object name = names.nextElement(); indent(out, indentAmount + 1); @@ -2193,7 +2193,7 @@ public abstract class AbstractDocument implements Document, Serializable { * Enumeration. * @return the children of the receiver as an Enumeration */ - public abstract Enumeration children(); + public abstract Enumeration children(); // --- serialization --------------------------------------------- @@ -2456,7 +2456,7 @@ public abstract class AbstractDocument implements Document, Serializable { * Enumeration. * @return the children of the receiver */ - public Enumeration children() { + public Enumeration children() { if(nchildren == 0) return null; @@ -2610,7 +2610,7 @@ public abstract class AbstractDocument implements Document, Serializable { * Enumeration. * @return the children of the receiver */ - public Enumeration children() { + public Enumeration children() { return null; } diff --git a/jdk/src/share/classes/javax/swing/text/AbstractWriter.java b/jdk/src/share/classes/javax/swing/text/AbstractWriter.java index f2f7f746ee4..cfe619b801f 100644 --- a/jdk/src/share/classes/javax/swing/text/AbstractWriter.java +++ b/jdk/src/share/classes/javax/swing/text/AbstractWriter.java @@ -668,7 +668,7 @@ public abstract class AbstractWriter { */ protected void writeAttributes(AttributeSet attr) throws IOException { - Enumeration names = attr.getAttributeNames(); + Enumeration names = attr.getAttributeNames(); while (names.hasMoreElements()) { Object name = names.nextElement(); write(" " + name + "=" + attr.getAttribute(name)); diff --git a/jdk/src/share/classes/javax/swing/text/DateFormatter.java b/jdk/src/share/classes/javax/swing/text/DateFormatter.java index e935053bfc8..b82788fb6a2 100644 --- a/jdk/src/share/classes/javax/swing/text/DateFormatter.java +++ b/jdk/src/share/classes/javax/swing/text/DateFormatter.java @@ -108,8 +108,8 @@ public class DateFormatter extends InternationalFormatter { /** * Returns the field that will be adjusted by adjustValue. */ - Object getAdjustField(int start, Map attributes) { - Iterator attrs = attributes.keySet().iterator(); + Object getAdjustField(int start, Map attributes) { + Iterator attrs = attributes.keySet().iterator(); while (attrs.hasNext()) { Object key = attrs.next(); @@ -127,7 +127,7 @@ public class DateFormatter extends InternationalFormatter { * Adjusts the Date if FieldPosition identifies a known calendar * field. */ - Object adjustValue(Object value, Map attributes, Object key, + Object adjustValue(Object value, Map attributes, Object key, int direction) throws BadLocationException, ParseException { if (key != null) { diff --git a/jdk/src/share/classes/javax/swing/text/DefaultFormatter.java b/jdk/src/share/classes/javax/swing/text/DefaultFormatter.java index 0a4df2c0a1d..ee9cda6e85f 100644 --- a/jdk/src/share/classes/javax/swing/text/DefaultFormatter.java +++ b/jdk/src/share/classes/javax/swing/text/DefaultFormatter.java @@ -246,12 +246,12 @@ public class DefaultFormatter extends JFormattedTextField.AbstractFormatter } } if (vc != null) { - Constructor cons; + Constructor cons; try { ReflectUtil.checkPackageAccess(vc); SwingUtilities2.checkAccess(vc.getModifiers()); - cons = vc.getConstructor(new Class[]{String.class}); + cons = vc.getConstructor(new Class[]{String.class}); } catch (NoSuchMethodException nsme) { cons = null; diff --git a/jdk/src/share/classes/javax/swing/text/DefaultStyledDocument.java b/jdk/src/share/classes/javax/swing/text/DefaultStyledDocument.java index a5ce0633f74..78788cbfad1 100644 --- a/jdk/src/share/classes/javax/swing/text/DefaultStyledDocument.java +++ b/jdk/src/share/classes/javax/swing/text/DefaultStyledDocument.java @@ -1048,8 +1048,9 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc styleChangeListener = createStyleChangeListener(); } if (styleChangeListener != null && styles != null) { - Enumeration styleNames = styles.getStyleNames(); - Vector v = (Vector)listeningStyles.clone(); + Enumeration styleNames = styles.getStyleNames(); + @SuppressWarnings("unchecked") + Vector