diff --git a/.hgtags b/.hgtags index e0932dbadf5..1bd0c05f284 100644 --- a/.hgtags +++ b/.hgtags @@ -242,3 +242,5 @@ aaf663f591aba43ec942263b15ba62759ce26a1e jdk8-b116 f5b521ade7a35cea18df78ee86322207729f5611 jdk8-b118 87b743b2263cc53955266411b7797b365a0fb050 jdk8-b119 a1ee9743f4ee165eae59389a020f2552f895dac8 jdk8-b120 +13b877757b0b1c0d5813298df85364f41d7ba6fe jdk9-b00 +f130ca87de6637acae7d99fcd7a8573eea1cbaed jdk9-b01 diff --git a/.hgtags-top-repo b/.hgtags-top-repo index c697daef07b..6a7cb46c540 100644 --- a/.hgtags-top-repo +++ b/.hgtags-top-repo @@ -242,3 +242,5 @@ a4afb0a8d55ef75aef5b0d77b434070468fb89f8 jdk8-b117 0a6db1aac998cdc88e52f9adb97d40ca5b0f1da6 jdk8-b118 9e90215673be68a3e77a9e444e4232076373734d jdk8-b119 cd3825b2983045784d6fc6d1729c799b08215752 jdk8-b120 +1e1f86d5d4e22c15a9bf9f1581acddb8c59abae2 jdk9-b00 +50669e45cec4491de0d921d3118a3fe2e767020a jdk9-b01 diff --git a/.jcheck/conf b/.jcheck/conf index 6d0dbe48e36..5c6f62dc12c 100644 --- a/.jcheck/conf +++ b/.jcheck/conf @@ -1 +1 @@ -project=jdk8 +project=jdk9 diff --git a/Makefile b/Makefile index cd5f66b50cc..7fe922ba458 100644 --- a/Makefile +++ b/Makefile @@ -66,7 +66,7 @@ else # First, find out the valid targets # Run the makefile with an arbitrary SPEC using -p -q (quiet dry-run and dump rules) to find # available PHONY targets. Use this list as valid targets to pass on to the repeated calls. - all_phony_targets=$(filter-out $(global_targets) bundles bundles-only final-images-only, $(strip $(shell \ + all_phony_targets=$(filter-out $(global_targets), $(strip $(shell \ cd $(root_dir) && $(MAKE) -p -q FRC SPEC=$(firstword $(SPEC)) | \ grep ^.PHONY: | head -n 1 | cut -d " " -f 2-))) @@ -79,10 +79,6 @@ else endif endif -# Include this after a potential spec file has been included so that the bundles target -# has access to the spec variables. -include $(root_dir)/make/Jprt.gmk - # Here are "global" targets, i.e. targets that can be executed without specifying a single configuration. # If you addd more global targets, please update the variable global_targets in MakeHelpers. diff --git a/common/autoconf/boot-jdk.m4 b/common/autoconf/boot-jdk.m4 index 27652953114..a4805a92c03 100644 --- a/common/autoconf/boot-jdk.m4 +++ b/common/autoconf/boot-jdk.m4 @@ -324,8 +324,6 @@ AC_DEFUN_ONCE([BOOTJDK_SETUP_BOOT_JDK_ARGUMENTS], fi # When is adding -client something that speeds up the JVM? # ADD_JVM_ARG_IF_OK([-client],boot_jdk_jvmargs,[$JAVA]) - ADD_JVM_ARG_IF_OK([-XX:PermSize=32m],boot_jdk_jvmargs,[$JAVA]) - ADD_JVM_ARG_IF_OK([-XX:MaxPermSize=160m],boot_jdk_jvmargs,[$JAVA]) ADD_JVM_ARG_IF_OK([-XX:ThreadStackSize=$STACK_SIZE],boot_jdk_jvmargs,[$JAVA]) # Disable special log output when a debug build is used as Boot JDK... ADD_JVM_ARG_IF_OK([-XX:-PrintVMOptions -XX:-UnlockDiagnosticVMOptions -XX:-LogVMOutput],boot_jdk_jvmargs,[$JAVA]) diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index 13440958a83..43e26631193 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -3865,7 +3865,7 @@ fi #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1384422786 +DATE_WHEN_GENERATED=1389815815 ############################################################################### # @@ -11156,6 +11156,12 @@ fi as_fn_error $? "Update version must have a value" "$LINENO" 5 elif test "x$with_update_version" != x; then JDK_UPDATE_VERSION="$with_update_version" + # On macosx 10.7, it's not possible to set --with-update-version=0X due + # to a bug in expr (which reduces it to just X). To work around this, we + # always add a 0 to one digit update versions. + if test "${#JDK_UPDATE_VERSION}" = "1"; then + JDK_UPDATE_VERSION="0${JDK_UPDATE_VERSION}" + fi fi @@ -16068,36 +16074,6 @@ fi # When is adding -client something that speeds up the JVM? # ADD_JVM_ARG_IF_OK([-client],boot_jdk_jvmargs,[$JAVA]) - $ECHO "Check if jvm arg is ok: -XX:PermSize=32m" >&5 - $ECHO "Command: $JAVA -XX:PermSize=32m -version" >&5 - OUTPUT=`$JAVA -XX:PermSize=32m -version 2>&1` - FOUND_WARN=`$ECHO "$OUTPUT" | grep -i warn` - FOUND_VERSION=`$ECHO $OUTPUT | grep " version \""` - if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then - boot_jdk_jvmargs="$boot_jdk_jvmargs -XX:PermSize=32m" - JVM_ARG_OK=true - else - $ECHO "Arg failed:" >&5 - $ECHO "$OUTPUT" >&5 - JVM_ARG_OK=false - fi - - - $ECHO "Check if jvm arg is ok: -XX:MaxPermSize=160m" >&5 - $ECHO "Command: $JAVA -XX:MaxPermSize=160m -version" >&5 - OUTPUT=`$JAVA -XX:MaxPermSize=160m -version 2>&1` - FOUND_WARN=`$ECHO "$OUTPUT" | grep -i warn` - FOUND_VERSION=`$ECHO $OUTPUT | grep " version \""` - if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then - boot_jdk_jvmargs="$boot_jdk_jvmargs -XX:MaxPermSize=160m" - JVM_ARG_OK=true - else - $ECHO "Arg failed:" >&5 - $ECHO "$OUTPUT" >&5 - JVM_ARG_OK=false - fi - - $ECHO "Check if jvm arg is ok: -XX:ThreadStackSize=$STACK_SIZE" >&5 $ECHO "Command: $JAVA -XX:ThreadStackSize=$STACK_SIZE -version" >&5 OUTPUT=`$JAVA -XX:ThreadStackSize=$STACK_SIZE -version 2>&1` @@ -20011,9 +19987,9 @@ $as_echo "$PROPER_COMPILER_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, keeping CC" >&5 $as_echo "no, keeping CC" >&6; } - CC="$TEST_COMPILER" fi + COMPILER=$CC COMPILER_NAME=$COMPILER_NAME @@ -21590,9 +21566,9 @@ $as_echo "$PROPER_COMPILER_CXX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, keeping CXX" >&5 $as_echo "no, keeping CXX" >&6; } - CXX="$TEST_COMPILER" fi + COMPILER=$CXX COMPILER_NAME=$COMPILER_NAME @@ -29625,7 +29601,7 @@ fi fi CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DARCH='\"$OPENJDK_TARGET_CPU_LEGACY\"' -D$OPENJDK_TARGET_CPU_LEGACY" - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DRELEASE='\"$RELEASE\"'" + CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DRELEASE='\"\$(RELEASE)\"'" CCXXFLAGS_JDK="$CCXXFLAGS_JDK \ -I${JDK_OUTPUTDIR}/include \ diff --git a/common/autoconf/jdk-options.m4 b/common/autoconf/jdk-options.m4 index 4397fb81123..9db8c238030 100644 --- a/common/autoconf/jdk-options.m4 +++ b/common/autoconf/jdk-options.m4 @@ -105,7 +105,7 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_JVM_VARIANTS], fi # Replace the commas with AND for use in the build directory name. - ANDED_JVM_VARIANTS=`$ECHO "$JVM_VARIANTS" | $SED -e 's/^,//' -e 's/,$//' -e 's/,/AND/'` + ANDED_JVM_VARIANTS=`$ECHO "$JVM_VARIANTS" | $SED -e 's/^,//' -e 's/,$//' -e 's/,/AND/g'` COUNT_VARIANTS=`$ECHO "$JVM_VARIANTS" | $SED -e 's/server,/1/' -e 's/client,/1/' -e 's/minimal1,/1/' -e 's/kernel,/1/' -e 's/zero,/1/' -e 's/zeroshark,/1/'` if test "x$COUNT_VARIANTS" != "x,1"; then BUILDING_MULTIPLE_JVM_VARIANTS=yes @@ -423,6 +423,12 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_JDK_VERSION_NUMBERS], AC_MSG_ERROR([Update version must have a value]) elif test "x$with_update_version" != x; then JDK_UPDATE_VERSION="$with_update_version" + # On macosx 10.7, it's not possible to set --with-update-version=0X due + # to a bug in expr (which reduces it to just X). To work around this, we + # always add a 0 to one digit update versions. + if test "${#JDK_UPDATE_VERSION}" = "1"; then + JDK_UPDATE_VERSION="0${JDK_UPDATE_VERSION}" + fi fi AC_ARG_WITH(user-release-suffix, [AS_HELP_STRING([--with-user-release-suffix], diff --git a/common/autoconf/toolchain.m4 b/common/autoconf/toolchain.m4 index c7cb93f2736..84793969b92 100644 --- a/common/autoconf/toolchain.m4 +++ b/common/autoconf/toolchain.m4 @@ -166,8 +166,8 @@ AC_DEFUN([TOOLCHAIN_FIND_COMPILER], $1="$PROPER_COMPILER_$1" else AC_MSG_RESULT([no, keeping $1]) - $1="$TEST_COMPILER" fi + TOOLCHAIN_CHECK_COMPILER_VERSION([$1], [$COMPILER_NAME]) ]) @@ -936,7 +936,7 @@ AC_DEFUN_ONCE([TOOLCHAIN_SETUP_COMPILER_FLAGS_FOR_JDK], fi CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DARCH='\"$OPENJDK_TARGET_CPU_LEGACY\"' -D$OPENJDK_TARGET_CPU_LEGACY" - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DRELEASE='\"$RELEASE\"'" + CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DRELEASE='\"\$(RELEASE)\"'" CCXXFLAGS_JDK="$CCXXFLAGS_JDK \ -I${JDK_OUTPUTDIR}/include \ diff --git a/common/autoconf/version-numbers b/common/autoconf/version-numbers index f567f314a8d..2c7a517dea6 100644 --- a/common/autoconf/version-numbers +++ b/common/autoconf/version-numbers @@ -24,7 +24,7 @@ # JDK_MAJOR_VERSION=1 -JDK_MINOR_VERSION=8 +JDK_MINOR_VERSION=9 JDK_MICRO_VERSION=0 JDK_UPDATE_VERSION= LAUNCHER_NAME=openjdk diff --git a/corba/.hgtags b/corba/.hgtags index 23c23467b4d..914430fb54c 100644 --- a/corba/.hgtags +++ b/corba/.hgtags @@ -242,3 +242,5 @@ e53d1ee4d2ae898f1cf58688d45a5afe7c482173 jdk8-b117 d6820a414f182a011a53a29a52370c696cd58dab jdk8-b118 379fc7609beb7a3d85ebc0cc21a8a51c60d3c7d3 jdk8-b119 53fd772d28c8a9f0f43adfc06f75f6b3cfa93cb5 jdk8-b120 +a7d3638deb2f4e33217b1ecf889479e90f9e5b50 jdk9-b00 +79a8136b18c1c6848f500088f5a4b39f262f082d jdk9-b01 diff --git a/corba/.jcheck/conf b/corba/.jcheck/conf index 6d0dbe48e36..5c6f62dc12c 100644 --- a/corba/.jcheck/conf +++ b/corba/.jcheck/conf @@ -1 +1 @@ -project=jdk8 +project=jdk9 diff --git a/corba/src/share/classes/com/sun/corba/se/impl/corba/AnyImpl.java b/corba/src/share/classes/com/sun/corba/se/impl/corba/AnyImpl.java index 1b03be02dd1..0f3428ac029 100644 --- a/corba/src/share/classes/com/sun/corba/se/impl/corba/AnyImpl.java +++ b/corba/src/share/classes/com/sun/corba/se/impl/corba/AnyImpl.java @@ -82,11 +82,18 @@ public class AnyImpl extends Any super((ORB)orb); } - public org.omg.CORBA.portable.InputStream create_input_stream() - { - return new AnyInputStream( - (com.sun.corba.se.impl.encoding.EncapsInputStream) - super.create_input_stream()); + public org.omg.CORBA.portable.InputStream create_input_stream() { + final org.omg.CORBA.portable.InputStream is = super + .create_input_stream(); + AnyInputStream aIS = AccessController + .doPrivileged(new PrivilegedAction() { + @Override + public AnyInputStream run() { + return new AnyInputStream( + (com.sun.corba.se.impl.encoding.EncapsInputStream) is); + } + }); + return aIS; } } diff --git a/corba/src/share/classes/com/sun/corba/se/impl/encoding/EncapsInputStream.java b/corba/src/share/classes/com/sun/corba/se/impl/encoding/EncapsInputStream.java index da7e9165449..7853812f89d 100644 --- a/corba/src/share/classes/com/sun/corba/se/impl/encoding/EncapsInputStream.java +++ b/corba/src/share/classes/com/sun/corba/se/impl/encoding/EncapsInputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -36,11 +36,10 @@ import com.sun.corba.se.impl.encoding.OSFCodeSetRegistry; import com.sun.corba.se.impl.protocol.giopmsgheaders.Message; import com.sun.corba.se.spi.orb.ORB; - import com.sun.corba.se.spi.logging.CORBALogDomains; - import com.sun.corba.se.impl.logging.ORBUtilSystemException; +import sun.corba.EncapsInputStreamFactory; /** * Encapsulations are supposed to explicitly define their * code sets and GIOP version. The original resolution to issue 2784 @@ -148,7 +147,7 @@ public class EncapsInputStream extends CDRInputStream } public CDRInputStream dup() { - return new EncapsInputStream(this); + return EncapsInputStreamFactory.newEncapsInputStream(this); } protected CodeSetConversion.BTCConverter createCharBTCConverter() { diff --git a/corba/src/share/classes/com/sun/corba/se/impl/encoding/EncapsOutputStream.java b/corba/src/share/classes/com/sun/corba/se/impl/encoding/EncapsOutputStream.java index 5f1b0e8bde8..4f908dc8569 100644 --- a/corba/src/share/classes/com/sun/corba/se/impl/encoding/EncapsOutputStream.java +++ b/corba/src/share/classes/com/sun/corba/se/impl/encoding/EncapsOutputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -39,6 +39,8 @@ import com.sun.corba.se.impl.encoding.BufferManagerFactory; import com.sun.corba.se.impl.protocol.giopmsgheaders.Message; import com.sun.corba.se.impl.orbutil.ORBConstants; +import sun.corba.EncapsInputStreamFactory; + /** * Encapsulations are supposed to explicitly define their * code sets and GIOP version. The original resolution to issue 2784 @@ -107,11 +109,11 @@ public class EncapsOutputStream extends CDROutputStream public org.omg.CORBA.portable.InputStream create_input_stream() { freeInternalCaches(); - return new EncapsInputStream(orb(), - getByteBuffer(), - getSize(), - isLittleEndian(), - getGIOPVersion()); + return EncapsInputStreamFactory.newEncapsInputStream(orb(), + getByteBuffer(), + getSize(), + isLittleEndian(), + getGIOPVersion()); } protected CodeSetConversion.CTBConverter createCharCTBConverter() { diff --git a/corba/src/share/classes/com/sun/corba/se/impl/encoding/TypeCodeInputStream.java b/corba/src/share/classes/com/sun/corba/se/impl/encoding/TypeCodeInputStream.java index 0bce54b930e..ae91457f161 100644 --- a/corba/src/share/classes/com/sun/corba/se/impl/encoding/TypeCodeInputStream.java +++ b/corba/src/share/classes/com/sun/corba/se/impl/encoding/TypeCodeInputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 @@ -64,6 +64,8 @@ import com.sun.corba.se.impl.encoding.CDRInputStream; import com.sun.corba.se.impl.encoding.CDROutputStream; import com.sun.corba.se.impl.encoding.MarshalInputStream; +import sun.corba.EncapsInputStreamFactory; + public class TypeCodeInputStream extends EncapsInputStream implements TypeCodeReader { private Map typeMap = null; @@ -157,11 +159,13 @@ public class TypeCodeInputStream extends EncapsInputStream implements TypeCodeRe // create an encapsulation using the marshal buffer if (is instanceof CDRInputStream) { - encap = new TypeCodeInputStream((ORB)_orb, encapBuffer, encapBuffer.length, - ((CDRInputStream)is).isLittleEndian(), - ((CDRInputStream)is).getGIOPVersion()); + encap = EncapsInputStreamFactory.newTypeCodeInputStream((ORB) _orb, + encapBuffer, encapBuffer.length, + ((CDRInputStream) is).isLittleEndian(), + ((CDRInputStream) is).getGIOPVersion()); } else { - encap = new TypeCodeInputStream((ORB)_orb, encapBuffer, encapBuffer.length); + encap = EncapsInputStreamFactory.newTypeCodeInputStream((ORB) _orb, + encapBuffer, encapBuffer.length); } encap.setEnclosingInputStream(is); encap.makeEncapsulation(); diff --git a/corba/src/share/classes/com/sun/corba/se/impl/encoding/TypeCodeOutputStream.java b/corba/src/share/classes/com/sun/corba/se/impl/encoding/TypeCodeOutputStream.java index 94f6466013a..93f7c97c50d 100644 --- a/corba/src/share/classes/com/sun/corba/se/impl/encoding/TypeCodeOutputStream.java +++ b/corba/src/share/classes/com/sun/corba/se/impl/encoding/TypeCodeOutputStream.java @@ -61,6 +61,8 @@ import java.math.BigDecimal; import java.math.BigInteger; import java.nio.ByteBuffer; +import sun.corba.EncapsInputStreamFactory; + public final class TypeCodeOutputStream extends EncapsOutputStream { private OutputStream enclosure = null; @@ -77,9 +79,9 @@ public final class TypeCodeOutputStream extends EncapsOutputStream public org.omg.CORBA.portable.InputStream create_input_stream() { - //return new TypeCodeInputStream((ORB)orb(), getByteBuffer(), getIndex(), isLittleEndian()); - TypeCodeInputStream tcis - = new TypeCodeInputStream((ORB)orb(), getByteBuffer(), getIndex(), isLittleEndian(), getGIOPVersion()); + TypeCodeInputStream tcis = EncapsInputStreamFactory + .newTypeCodeInputStream((ORB) orb(), getByteBuffer(), + getIndex(), isLittleEndian(), getGIOPVersion()); //if (TypeCodeImpl.debug) { //System.out.println("Created TypeCodeInputStream " + tcis + " with no parent"); //tcis.printBuffer(); diff --git a/corba/src/share/classes/com/sun/corba/se/impl/interceptors/CDREncapsCodec.java b/corba/src/share/classes/com/sun/corba/se/impl/interceptors/CDREncapsCodec.java index 6f469e2dc7d..235b8956de1 100644 --- a/corba/src/share/classes/com/sun/corba/se/impl/interceptors/CDREncapsCodec.java +++ b/corba/src/share/classes/com/sun/corba/se/impl/interceptors/CDREncapsCodec.java @@ -33,6 +33,8 @@ import org.omg.CORBA.LocalObject; import com.sun.corba.se.spi.ior.iiop.GIOPVersion; import com.sun.corba.se.spi.logging.CORBALogDomains; +import sun.corba.EncapsInputStreamFactory; + import com.sun.corba.se.impl.corba.AnyImpl; import com.sun.corba.se.impl.encoding.EncapsInputStream; import com.sun.corba.se.impl.encoding.EncapsOutputStream; @@ -193,8 +195,9 @@ public final class CDREncapsCodec // it is turned into a FormatMismatch exception. try { - EncapsInputStream cdrIn = new EncapsInputStream( orb, data, - data.length, giopVersion ); + EncapsInputStream cdrIn = EncapsInputStreamFactory.newEncapsInputStream( orb, data, + data.length, giopVersion ); + cdrIn.consumeEndian(); diff --git a/corba/src/share/classes/com/sun/corba/se/impl/io/IIOPInputStream.java b/corba/src/share/classes/com/sun/corba/se/impl/io/IIOPInputStream.java index b8afc9ce839..e14b25ebb1b 100644 --- a/corba/src/share/classes/com/sun/corba/se/impl/io/IIOPInputStream.java +++ b/corba/src/share/classes/com/sun/corba/se/impl/io/IIOPInputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -370,7 +370,7 @@ public class IIOPInputStream * @exception IOException Any of the usual Input/Output related exceptions. * @since JDK1.1 */ - public final Object readObjectDelegate() throws IOException + public final synchronized Object readObjectDelegate() throws IOException { try { @@ -389,7 +389,7 @@ public class IIOPInputStream } } - final Object simpleReadObject(Class clz, + final synchronized Object simpleReadObject(Class clz, String repositoryID, com.sun.org.omg.SendingContext.CodeBase sender, int offset) @@ -461,7 +461,7 @@ public class IIOPInputStream return obj; } - public final void simpleSkipObject(String repositoryID, + public final synchronized void simpleSkipObject(String repositoryID, com.sun.org.omg.SendingContext.CodeBase sender) /* throws OptionalDataException, ClassNotFoundException, IOException */ { @@ -559,7 +559,7 @@ public class IIOPInputStream * objects. * @since JDK1.1 */ - public final void defaultReadObjectDelegate() + final synchronized void defaultReadObjectDelegate() /* throws IOException, ClassNotFoundException, NotActiveException */ { try { @@ -988,7 +988,7 @@ public class IIOPInputStream } } - private Object inputObject(Class clz, + private synchronized Object inputObject(Class clz, String repositoryID, com.sun.org.omg.SendingContext.CodeBase sender, int offset) @@ -1317,7 +1317,7 @@ public class IIOPInputStream * a form of custom marshaling. * */ - private Object inputObjectUsingFVD(Class clz, + private synchronized Object inputObjectUsingFVD(Class clz, String repositoryID, com.sun.org.omg.SendingContext.CodeBase sender, int offset) diff --git a/corba/src/share/classes/com/sun/corba/se/impl/io/InputStreamHook.java b/corba/src/share/classes/com/sun/corba/se/impl/io/InputStreamHook.java index f8dcbe5b6d8..f4198e386de 100644 --- a/corba/src/share/classes/com/sun/corba/se/impl/io/InputStreamHook.java +++ b/corba/src/share/classes/com/sun/corba/se/impl/io/InputStreamHook.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -201,7 +201,7 @@ public abstract class InputStreamHook extends ObjectInputStream readObjectState.endDefaultReadObject(this); } - public abstract void defaultReadObjectDelegate(); + abstract void defaultReadObjectDelegate(); abstract void readFields(java.util.Map fieldToValueMap) throws java.io.InvalidClassException, java.io.StreamCorruptedException, 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 a40b007bac5..1748397d065 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, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 diff --git a/corba/src/share/classes/com/sun/corba/se/impl/ior/EncapsulationUtility.java b/corba/src/share/classes/com/sun/corba/se/impl/ior/EncapsulationUtility.java index 1d0f3c457f4..63cdcae2bee 100644 --- a/corba/src/share/classes/com/sun/corba/se/impl/ior/EncapsulationUtility.java +++ b/corba/src/share/classes/com/sun/corba/se/impl/ior/EncapsulationUtility.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -47,6 +47,8 @@ import com.sun.corba.se.impl.encoding.CDROutputStream ; import com.sun.corba.se.impl.encoding.EncapsOutputStream ; import com.sun.corba.se.impl.encoding.EncapsInputStream ; +import sun.corba.EncapsInputStreamFactory; + /** * This static utility class contains various utility methods for reading and * writing CDR encapsulations. @@ -108,8 +110,8 @@ public class EncapsulationUtility static public InputStream getEncapsulationStream( InputStream is ) { byte[] data = readOctets( is ) ; - EncapsInputStream result = new EncapsInputStream( is.orb(), data, - data.length ) ; + EncapsInputStream result = EncapsInputStreamFactory.newEncapsInputStream( is.orb(), data, + data.length ) ; result.consumeEndian() ; return result ; } diff --git a/corba/src/share/classes/com/sun/corba/se/impl/ior/ObjectKeyFactoryImpl.java b/corba/src/share/classes/com/sun/corba/se/impl/ior/ObjectKeyFactoryImpl.java index 00840373662..d774994b977 100644 --- a/corba/src/share/classes/com/sun/corba/se/impl/ior/ObjectKeyFactoryImpl.java +++ b/corba/src/share/classes/com/sun/corba/se/impl/ior/ObjectKeyFactoryImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -49,6 +49,8 @@ import com.sun.corba.se.impl.ior.ObjectKeyImpl ; import com.sun.corba.se.impl.logging.IORSystemException ; import com.sun.corba.se.impl.encoding.EncapsInputStream ; +import sun.corba.EncapsInputStreamFactory; + /** Based on the magic and scid, return the appropriate * ObjectKeyTemplate. Expects to be called with a valid @@ -217,7 +219,7 @@ public class ObjectKeyFactoryImpl implements ObjectKeyFactory public ObjectKey create( byte[] key ) { OctetSeqHolder osh = new OctetSeqHolder() ; - EncapsInputStream is = new EncapsInputStream( orb, key, key.length ) ; + EncapsInputStream is = EncapsInputStreamFactory.newEncapsInputStream( orb, key, key.length ); ObjectKeyTemplate oktemp = create( is, fullKey, osh ) ; if (oktemp == null) diff --git a/corba/src/share/classes/com/sun/corba/se/impl/ior/ObjectKeyImpl.java b/corba/src/share/classes/com/sun/corba/se/impl/ior/ObjectKeyImpl.java index 614e035828d..ad2019a9559 100644 --- a/corba/src/share/classes/com/sun/corba/se/impl/ior/ObjectKeyImpl.java +++ b/corba/src/share/classes/com/sun/corba/se/impl/ior/ObjectKeyImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 diff --git a/corba/src/share/classes/com/sun/corba/se/impl/ior/iiop/IIOPProfileImpl.java b/corba/src/share/classes/com/sun/corba/se/impl/ior/iiop/IIOPProfileImpl.java index 4a7b0b921de..060dd3f338e 100644 --- a/corba/src/share/classes/com/sun/corba/se/impl/ior/iiop/IIOPProfileImpl.java +++ b/corba/src/share/classes/com/sun/corba/se/impl/ior/iiop/IIOPProfileImpl.java @@ -70,6 +70,8 @@ import com.sun.corba.se.impl.ior.EncapsulationUtility ; import com.sun.corba.se.impl.encoding.EncapsInputStream ; import com.sun.corba.se.impl.encoding.EncapsOutputStream ; +import sun.corba.EncapsInputStreamFactory; + import com.sun.corba.se.impl.util.JDKBridge; import com.sun.corba.se.impl.logging.IORSystemException; @@ -170,8 +172,8 @@ public class IIOPProfileImpl extends IdentifiableBase implements IIOPProfile throw wrapper.invalidTaggedProfile() ; } - EncapsInputStream istr = new EncapsInputStream((ORB)orb, profile.profile_data, - profile.profile_data.length); + EncapsInputStream istr = EncapsInputStreamFactory.newEncapsInputStream((ORB)orb, profile.profile_data, + profile.profile_data.length); istr.consumeEndian(); init( istr ) ; } diff --git a/corba/src/share/classes/com/sun/corba/se/impl/javax/rmi/CORBA/StubDelegateImpl.java b/corba/src/share/classes/com/sun/corba/se/impl/javax/rmi/CORBA/StubDelegateImpl.java index 6af71ee77cb..5ac8283265f 100644 --- a/corba/src/share/classes/com/sun/corba/se/impl/javax/rmi/CORBA/StubDelegateImpl.java +++ b/corba/src/share/classes/com/sun/corba/se/impl/javax/rmi/CORBA/StubDelegateImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 diff --git a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/RepIdDelegator.java b/corba/src/share/classes/com/sun/corba/se/impl/orbutil/RepIdDelegator.java index c2bc23cacac..32513609079 100644 --- a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/RepIdDelegator.java +++ b/corba/src/share/classes/com/sun/corba/se/impl/orbutil/RepIdDelegator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 diff --git a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_de.properties b/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_de.properties index b33670ea62f..edfff12bdd6 100644 --- a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_de.properties +++ b/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_de.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2000, 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 diff --git a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_es.properties b/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_es.properties index 12562891caa..74c6b3a40ca 100644 --- a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_es.properties +++ b/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_es.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2000, 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 diff --git a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_fr.properties b/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_fr.properties index b1b64f1f9f3..6071d09878f 100644 --- a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_fr.properties +++ b/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_fr.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2000, 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 diff --git a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_it.properties b/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_it.properties index 908f7a4e2cb..02f0f21731f 100644 --- a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_it.properties +++ b/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_it.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2000, 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 diff --git a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_ja.properties b/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_ja.properties index f067fd9de63..6efbbe9daa0 100644 --- a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_ja.properties +++ b/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_ja.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2000, 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 diff --git a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_ko.properties b/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_ko.properties index 794723ffa12..d824c67b82b 100644 --- a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_ko.properties +++ b/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_ko.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2000, 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 diff --git a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_pt_BR.properties b/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_pt_BR.properties index 81ca99db3d8..7ab191395b5 100644 --- a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_pt_BR.properties +++ b/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_pt_BR.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2000, 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 diff --git a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_sv.properties b/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_sv.properties index c11488e9f48..591f0b45fc7 100644 --- a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_sv.properties +++ b/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_sv.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2000, 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 diff --git a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_zh_CN.properties b/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_zh_CN.properties index 6dce9e6e827..7743117c56d 100644 --- a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_zh_CN.properties +++ b/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_zh_CN.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2000, 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 diff --git a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_zh_TW.properties b/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_zh_TW.properties index db797522663..17f0137e12d 100644 --- a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_zh_TW.properties +++ b/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_zh_TW.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2000, 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 diff --git a/corba/src/share/classes/com/sun/corba/se/impl/presentation/rmi/IDLNameTranslatorImpl.java b/corba/src/share/classes/com/sun/corba/se/impl/presentation/rmi/IDLNameTranslatorImpl.java index 86a47992a72..a9f1dd2d836 100644 --- a/corba/src/share/classes/com/sun/corba/se/impl/presentation/rmi/IDLNameTranslatorImpl.java +++ b/corba/src/share/classes/com/sun/corba/se/impl/presentation/rmi/IDLNameTranslatorImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 diff --git a/corba/src/share/classes/com/sun/corba/se/impl/presentation/rmi/InvocationHandlerFactoryImpl.java b/corba/src/share/classes/com/sun/corba/se/impl/presentation/rmi/InvocationHandlerFactoryImpl.java index 076ed1929ea..f0e25d3ab34 100644 --- a/corba/src/share/classes/com/sun/corba/se/impl/presentation/rmi/InvocationHandlerFactoryImpl.java +++ b/corba/src/share/classes/com/sun/corba/se/impl/presentation/rmi/InvocationHandlerFactoryImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/corba/src/share/classes/com/sun/corba/se/impl/presentation/rmi/StubFactoryDynamicBase.java b/corba/src/share/classes/com/sun/corba/se/impl/presentation/rmi/StubFactoryDynamicBase.java index f05d0ca0673..ae7c9f8d97d 100644 --- a/corba/src/share/classes/com/sun/corba/se/impl/presentation/rmi/StubFactoryDynamicBase.java +++ b/corba/src/share/classes/com/sun/corba/se/impl/presentation/rmi/StubFactoryDynamicBase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -25,6 +25,7 @@ package com.sun.corba.se.impl.presentation.rmi ; +import java.io.SerializablePermission; import java.lang.reflect.InvocationHandler ; import java.lang.reflect.Proxy ; @@ -38,11 +39,18 @@ public abstract class StubFactoryDynamicBase extends StubFactoryBase { protected final ClassLoader loader ; - public StubFactoryDynamicBase( PresentationManager.ClassData classData, - ClassLoader loader ) - { - super( classData ) ; + private static Void checkPermission() { + SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + sm.checkPermission(new SerializablePermission( + "enableSubclassImplementation")); + } + return null; + } + private StubFactoryDynamicBase(Void unused, + PresentationManager.ClassData classData, ClassLoader loader) { + super(classData); // this.loader must not be null, or the newProxyInstance call // will fail. if (loader == null) { @@ -55,5 +63,11 @@ public abstract class StubFactoryDynamicBase extends StubFactoryBase } } + public StubFactoryDynamicBase( PresentationManager.ClassData classData, + ClassLoader loader ) + { + this (checkPermission(), classData, loader); + } + public abstract org.omg.CORBA.Object makeStub() ; } diff --git a/corba/src/share/classes/com/sun/corba/se/impl/presentation/rmi/StubFactoryFactoryProxyImpl.java b/corba/src/share/classes/com/sun/corba/se/impl/presentation/rmi/StubFactoryFactoryProxyImpl.java index e3fe932f4e4..ae0587f76ad 100644 --- a/corba/src/share/classes/com/sun/corba/se/impl/presentation/rmi/StubFactoryFactoryProxyImpl.java +++ b/corba/src/share/classes/com/sun/corba/se/impl/presentation/rmi/StubFactoryFactoryProxyImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -25,14 +25,22 @@ package com.sun.corba.se.impl.presentation.rmi; +import java.security.AccessController; +import java.security.PrivilegedAction; import com.sun.corba.se.spi.presentation.rmi.PresentationManager ; public class StubFactoryFactoryProxyImpl extends StubFactoryFactoryDynamicBase { public PresentationManager.StubFactory makeDynamicStubFactory( - PresentationManager pm, PresentationManager.ClassData classData, - ClassLoader classLoader ) + PresentationManager pm, final PresentationManager.ClassData classData, + final ClassLoader classLoader ) { - return new StubFactoryProxyImpl( classData, classLoader ) ; + return AccessController + .doPrivileged(new PrivilegedAction() { + @Override + public StubFactoryProxyImpl run() { + return new StubFactoryProxyImpl(classData, classLoader); + } + }); } } diff --git a/corba/src/share/classes/com/sun/corba/se/impl/protocol/CorbaClientRequestDispatcherImpl.java b/corba/src/share/classes/com/sun/corba/se/impl/protocol/CorbaClientRequestDispatcherImpl.java index 1878596aca3..5c669dda9f9 100644 --- a/corba/src/share/classes/com/sun/corba/se/impl/protocol/CorbaClientRequestDispatcherImpl.java +++ b/corba/src/share/classes/com/sun/corba/se/impl/protocol/CorbaClientRequestDispatcherImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -115,6 +115,7 @@ import com.sun.corba.se.impl.util.JDKBridge; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ConcurrentHashMap; +import sun.corba.EncapsInputStreamFactory; /** * ClientDelegate is the RMI client-side subcontract or representation @@ -847,8 +848,8 @@ public class CorbaClientRequestDispatcherImpl } byte[] data = ((UnknownServiceContext)sc).getData(); EncapsInputStream in = - new EncapsInputStream((ORB)messageMediator.getBroker(), - data, data.length); + EncapsInputStreamFactory.newEncapsInputStream((ORB)messageMediator.getBroker(), + data, data.length); in.consumeEndian(); String msg = diff --git a/corba/src/share/classes/com/sun/corba/se/impl/protocol/SharedCDRClientRequestDispatcherImpl.java b/corba/src/share/classes/com/sun/corba/se/impl/protocol/SharedCDRClientRequestDispatcherImpl.java index 27002a37d50..9f9a5f65e27 100644 --- a/corba/src/share/classes/com/sun/corba/se/impl/protocol/SharedCDRClientRequestDispatcherImpl.java +++ b/corba/src/share/classes/com/sun/corba/se/impl/protocol/SharedCDRClientRequestDispatcherImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -36,7 +36,8 @@ import java.io.IOException; import java.util.Iterator; import java.rmi.RemoteException; import java.nio.ByteBuffer; - +import java.security.AccessController; +import java.security.PrivilegedAction; import javax.rmi.CORBA.Util; import javax.rmi.CORBA.Tie; @@ -111,6 +112,7 @@ import com.sun.corba.se.impl.protocol.giopmsgheaders.KeyAddr; import com.sun.corba.se.impl.protocol.giopmsgheaders.ProfileAddr; import com.sun.corba.se.impl.protocol.giopmsgheaders.ReferenceAddr; import com.sun.corba.se.impl.transport.CorbaContactInfoListIteratorImpl; +import com.sun.corba.se.impl.protocol.giopmsgheaders.Message; import com.sun.corba.se.impl.util.JDKBridge; /** @@ -156,10 +158,17 @@ public class SharedCDRClientRequestDispatcherImpl ByteBufferWithInfo bbwi = cdrOutputObject.getByteBufferWithInfo(); cdrOutputObject.getMessageHeader().setSize(bbwi.byteBuffer, bbwi.getSize()); - - CDRInputObject cdrInputObject = - new CDRInputObject(orb, null, bbwi.byteBuffer, - cdrOutputObject.getMessageHeader()); + final ORB inOrb = orb; + final ByteBuffer inBuffer = bbwi.byteBuffer; + final Message inMsg = cdrOutputObject.getMessageHeader(); + CDRInputObject cdrInputObject = AccessController + .doPrivileged(new PrivilegedAction() { + @Override + public CDRInputObject run() { + return new CDRInputObject(inOrb, null, inBuffer, + inMsg); + } + }); messageMediator.setInputObject(cdrInputObject); cdrInputObject.setMessageMediator(messageMediator); @@ -192,9 +201,17 @@ public class SharedCDRClientRequestDispatcherImpl cdrOutputObject = (CDROutputObject) messageMediator.getOutputObject(); bbwi = cdrOutputObject.getByteBufferWithInfo(); cdrOutputObject.getMessageHeader().setSize(bbwi.byteBuffer, bbwi.getSize()); - cdrInputObject = - new CDRInputObject(orb, null, bbwi.byteBuffer, - cdrOutputObject.getMessageHeader()); + final ORB inOrb2 = orb; + final ByteBuffer inBuffer2 = bbwi.byteBuffer; + final Message inMsg2 = cdrOutputObject.getMessageHeader(); + cdrInputObject = AccessController + .doPrivileged(new PrivilegedAction() { + @Override + public CDRInputObject run() { + return new CDRInputObject(inOrb2, null, inBuffer2, + inMsg2); + } + }); messageMediator.setInputObject(cdrInputObject); cdrInputObject.setMessageMediator(messageMediator); diff --git a/corba/src/share/classes/com/sun/corba/se/impl/resolver/INSURLOperationImpl.java b/corba/src/share/classes/com/sun/corba/se/impl/resolver/INSURLOperationImpl.java index fb56e001f54..91976a2b5a2 100644 --- a/corba/src/share/classes/com/sun/corba/se/impl/resolver/INSURLOperationImpl.java +++ b/corba/src/share/classes/com/sun/corba/se/impl/resolver/INSURLOperationImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,6 +36,8 @@ import java.util.Collections ; import org.omg.CosNaming.NamingContextExt ; import org.omg.CosNaming.NamingContextExtHelper ; +import sun.corba.EncapsInputStreamFactory; + import com.sun.corba.se.spi.ior.IOR; import com.sun.corba.se.spi.ior.IORTemplate; import com.sun.corba.se.spi.ior.ObjectKey; @@ -114,8 +116,8 @@ public class INSURLOperationImpl implements Operation buf[j] = (byte)((ORBUtility.hexOf(str.charAt(i)) << UN_SHIFT) & 0xF0); buf[j] |= (byte)(ORBUtility.hexOf(str.charAt(i+1)) & 0x0F); } - EncapsInputStream s = new EncapsInputStream(orb, buf, buf.length, - orb.getORBData().getGIOPVersion()); + EncapsInputStream s = EncapsInputStreamFactory.newEncapsInputStream(orb, buf, buf.length, + orb.getORBData().getGIOPVersion()); s.consumeEndian(); return s.read_Object() ; } diff --git a/corba/src/share/classes/com/sun/corba/se/impl/transport/DefaultSocketFactoryImpl.java b/corba/src/share/classes/com/sun/corba/se/impl/transport/DefaultSocketFactoryImpl.java index 63578b9c3d1..14536c6e291 100644 --- a/corba/src/share/classes/com/sun/corba/se/impl/transport/DefaultSocketFactoryImpl.java +++ b/corba/src/share/classes/com/sun/corba/se/impl/transport/DefaultSocketFactoryImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/corba/src/share/classes/com/sun/corba/se/spi/orbutil/proxy/CompositeInvocationHandlerImpl.java b/corba/src/share/classes/com/sun/corba/se/spi/orbutil/proxy/CompositeInvocationHandlerImpl.java index 271682a9f61..577f07e3774 100644 --- a/corba/src/share/classes/com/sun/corba/se/spi/orbutil/proxy/CompositeInvocationHandlerImpl.java +++ b/corba/src/share/classes/com/sun/corba/se/spi/orbutil/proxy/CompositeInvocationHandlerImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 diff --git a/corba/src/share/classes/com/sun/corba/se/spi/servicecontext/ServiceContexts.java b/corba/src/share/classes/com/sun/corba/se/spi/servicecontext/ServiceContexts.java index 13ff23435da..ea4569b1a14 100644 --- a/corba/src/share/classes/com/sun/corba/se/spi/servicecontext/ServiceContexts.java +++ b/corba/src/share/classes/com/sun/corba/se/spi/servicecontext/ServiceContexts.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -58,6 +58,9 @@ import com.sun.corba.se.impl.orbutil.ORBUtility ; import com.sun.corba.se.impl.util.Utility ; import com.sun.corba.se.impl.logging.ORBUtilSystemException ; +import sun.corba.EncapsInputStreamFactory; + + public class ServiceContexts { private static boolean isDebugging( OutputStream os ) { @@ -198,11 +201,11 @@ public class ServiceContexts { // Note: As of Jan 2001, no standard OMG or Sun service contexts // ship wchar data or are defined as using anything but GIOP 1.0 CDR. EncapsInputStream eis - = new EncapsInputStream(orb, - data, - data.length, - giopVersion, - codeBase); + = EncapsInputStreamFactory.newEncapsInputStream(orb, + data, + data.length, + giopVersion, + codeBase); eis.consumeEndian(); // Now the input stream passed to a ServiceContext diff --git a/corba/src/share/classes/com/sun/tools/corba/se/idl/idl_ja.prp b/corba/src/share/classes/com/sun/tools/corba/se/idl/idl_ja.prp index 80fbd04f9d8..25f662abd91 100644 --- a/corba/src/share/classes/com/sun/tools/corba/se/idl/idl_ja.prp +++ b/corba/src/share/classes/com/sun/tools/corba/se/idl/idl_ja.prp @@ -1,5 +1,5 @@ # -# Copyright (c) 1999, 2009, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1999, 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 diff --git a/corba/src/share/classes/com/sun/tools/corba/se/idl/idl_zh_CN.prp b/corba/src/share/classes/com/sun/tools/corba/se/idl/idl_zh_CN.prp index d1f86754a8d..aa2279cc099 100644 --- a/corba/src/share/classes/com/sun/tools/corba/se/idl/idl_zh_CN.prp +++ b/corba/src/share/classes/com/sun/tools/corba/se/idl/idl_zh_CN.prp @@ -1,5 +1,5 @@ # -# Copyright (c) 1999, 2009, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1999, 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 diff --git a/corba/src/share/classes/com/sun/tools/corba/se/idl/toJavaPortable/toJavaPortable_ja.prp b/corba/src/share/classes/com/sun/tools/corba/se/idl/toJavaPortable/toJavaPortable_ja.prp index 35ae4fdb054..52bb4f311cf 100644 --- a/corba/src/share/classes/com/sun/tools/corba/se/idl/toJavaPortable/toJavaPortable_ja.prp +++ b/corba/src/share/classes/com/sun/tools/corba/se/idl/toJavaPortable/toJavaPortable_ja.prp @@ -1,5 +1,5 @@ # -# Copyright (c) 1999, 2009, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1999, 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 diff --git a/corba/src/share/classes/com/sun/tools/corba/se/idl/toJavaPortable/toJavaPortable_zh_CN.prp b/corba/src/share/classes/com/sun/tools/corba/se/idl/toJavaPortable/toJavaPortable_zh_CN.prp index ee77a65bb3c..f436137378b 100644 --- a/corba/src/share/classes/com/sun/tools/corba/se/idl/toJavaPortable/toJavaPortable_zh_CN.prp +++ b/corba/src/share/classes/com/sun/tools/corba/se/idl/toJavaPortable/toJavaPortable_zh_CN.prp @@ -1,5 +1,5 @@ # -# Copyright (c) 1999, 2009, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1999, 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 diff --git a/corba/src/share/classes/javax/rmi/CORBA/Stub.java b/corba/src/share/classes/javax/rmi/CORBA/Stub.java index 227e28992b6..507b262a29c 100644 --- a/corba/src/share/classes/javax/rmi/CORBA/Stub.java +++ b/corba/src/share/classes/javax/rmi/CORBA/Stub.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/corba/src/share/classes/javax/rmi/CORBA/Util.java b/corba/src/share/classes/javax/rmi/CORBA/Util.java index 65df15f1a27..61d91c7673a 100644 --- a/corba/src/share/classes/javax/rmi/CORBA/Util.java +++ b/corba/src/share/classes/javax/rmi/CORBA/Util.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/corba/src/share/classes/javax/rmi/PortableRemoteObject.java b/corba/src/share/classes/javax/rmi/PortableRemoteObject.java index 951f06cb477..c1a9bafdcf2 100644 --- a/corba/src/share/classes/javax/rmi/PortableRemoteObject.java +++ b/corba/src/share/classes/javax/rmi/PortableRemoteObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/corba/src/share/classes/org/omg/CORBA_2_3/portable/InputStream.java b/corba/src/share/classes/org/omg/CORBA_2_3/portable/InputStream.java index 2d5e788a88b..90d9ea65286 100644 --- a/corba/src/share/classes/org/omg/CORBA_2_3/portable/InputStream.java +++ b/corba/src/share/classes/org/omg/CORBA_2_3/portable/InputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2000, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,6 +31,10 @@ package org.omg.CORBA_2_3.portable; +import java.io.SerializablePermission; +import java.security.AccessController; +import java.security.PrivilegedAction; + /** * InputStream provides for the reading of all of the mapped IDL types * from the stream. It extends org.omg.CORBA.portable.InputStream. This @@ -43,6 +47,43 @@ package org.omg.CORBA_2_3.portable; public abstract class InputStream extends org.omg.CORBA.portable.InputStream { + + private static final String ALLOW_SUBCLASS_PROP = "jdk.corba.allowInputStreamSubclass"; + + private static final boolean allowSubclass = AccessController.doPrivileged( + new PrivilegedAction() { + @Override + public Boolean run() { + String prop = System.getProperty(ALLOW_SUBCLASS_PROP); + return prop == null ? false : + (prop.equalsIgnoreCase("false") ? false : true); + } + }); + + private static Void checkPermission() { + SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + if (!allowSubclass) + sm.checkPermission(new + SerializablePermission("enableSubclassImplementation")); + } + return null; + } + + private InputStream(Void ignore) { } + + /** + * Create a new instance of this class. + * + * throw SecurityException if SecurityManager is installed and + * enableSubclassImplementation SerializablePermission + * is not granted or jdk.corba.allowOutputStreamSubclass system + * property is either not set or is set to 'false' + */ + public InputStream() { + this(checkPermission()); + } + /** * Unmarshalls a value type from the input stream. * @return the value type unmarshalled from the input stream diff --git a/corba/src/share/classes/sun/corba/EncapsInputStreamFactory.java b/corba/src/share/classes/sun/corba/EncapsInputStreamFactory.java new file mode 100644 index 00000000000..236a680cada --- /dev/null +++ b/corba/src/share/classes/sun/corba/EncapsInputStreamFactory.java @@ -0,0 +1,153 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package sun.corba; + +import java.nio.ByteBuffer; +import java.security.AccessController; +import java.security.PrivilegedAction; + + +import com.sun.corba.se.impl.encoding.EncapsInputStream; +import com.sun.corba.se.impl.encoding.TypeCodeInputStream; +import com.sun.corba.se.impl.protocol.giopmsgheaders.Message; +import com.sun.corba.se.pept.protocol.MessageMediator; +import com.sun.corba.se.spi.ior.iiop.GIOPVersion; +import com.sun.corba.se.spi.orb.ORB; +import com.sun.org.omg.SendingContext.CodeBase; + +public class EncapsInputStreamFactory { + + public static EncapsInputStream newEncapsInputStream( + final org.omg.CORBA.ORB orb, final byte[] buf, final int size, + final boolean littleEndian, final GIOPVersion version) { + return AccessController + .doPrivileged(new PrivilegedAction() { + @Override + public EncapsInputStream run() { + return new EncapsInputStream(orb, buf, size, + littleEndian, version); + } + }); + } + + public static EncapsInputStream newEncapsInputStream( + final org.omg.CORBA.ORB orb, final ByteBuffer byteBuffer, + final int size, final boolean littleEndian, + final GIOPVersion version) { + return AccessController + .doPrivileged(new PrivilegedAction() { + @Override + public EncapsInputStream run() { + return new EncapsInputStream(orb, byteBuffer, size, + littleEndian, version); + } + }); + } + + public static EncapsInputStream newEncapsInputStream( + final org.omg.CORBA.ORB orb, final byte[] data, final int size) { + return AccessController + .doPrivileged(new PrivilegedAction() { + @Override + public EncapsInputStream run() { + return new EncapsInputStream(orb, data, size); + } + }); + } + + public static EncapsInputStream newEncapsInputStream( + final EncapsInputStream eis) { + return AccessController + .doPrivileged(new PrivilegedAction() { + @Override + public EncapsInputStream run() { + return new EncapsInputStream(eis); + } + }); + } + + public static EncapsInputStream newEncapsInputStream( + final org.omg.CORBA.ORB orb, final byte[] data, final int size, + final GIOPVersion version) { + return AccessController + .doPrivileged(new PrivilegedAction() { + @Override + public EncapsInputStream run() { + return new EncapsInputStream(orb, data, size, version); + } + }); + } + + public static EncapsInputStream newEncapsInputStream( + final org.omg.CORBA.ORB orb, final byte[] data, final int size, + final GIOPVersion version, final CodeBase codeBase) { + return AccessController + .doPrivileged(new PrivilegedAction() { + @Override + public EncapsInputStream run() { + return new EncapsInputStream(orb, data, size, version, + codeBase); + } + }); + } + + public static TypeCodeInputStream newTypeCodeInputStream( + final org.omg.CORBA.ORB orb, final byte[] buf, final int size, + final boolean littleEndian, final GIOPVersion version) { + return AccessController + .doPrivileged(new PrivilegedAction() { + @Override + public TypeCodeInputStream run() { + return new TypeCodeInputStream(orb, buf, size, + littleEndian, version); + } + }); + } + + public static TypeCodeInputStream newTypeCodeInputStream( + final org.omg.CORBA.ORB orb, final ByteBuffer byteBuffer, + final int size, final boolean littleEndian, + final GIOPVersion version) { + return AccessController + .doPrivileged(new PrivilegedAction() { + @Override + public TypeCodeInputStream run() { + return new TypeCodeInputStream(orb, byteBuffer, size, + littleEndian, version); + } + }); + } + + public static TypeCodeInputStream newTypeCodeInputStream( + final org.omg.CORBA.ORB orb, final byte[] data, final int size) { + return AccessController + .doPrivileged(new PrivilegedAction() { + @Override + public TypeCodeInputStream run() { + return new TypeCodeInputStream(orb, data, size); + } + }); + } +} diff --git a/corba/src/share/classes/sun/rmi/rmic/iiop/CompoundType.java b/corba/src/share/classes/sun/rmi/rmic/iiop/CompoundType.java index eba506daf73..fcbbaccfd4a 100644 --- a/corba/src/share/classes/sun/rmi/rmic/iiop/CompoundType.java +++ b/corba/src/share/classes/sun/rmi/rmic/iiop/CompoundType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/hotspot/.hgtags b/hotspot/.hgtags index 88a3a61d941..7b9d7597d6e 100644 --- a/hotspot/.hgtags +++ b/hotspot/.hgtags @@ -402,3 +402,5 @@ b2426da30009cd3069d03de073f351e6432c7682 hs25-b61 ce42d815dd2130250acf6132b51b624001638f0d jdk8-b119 05fedd51e40da22c9460bf17c7185889e435db3d hs25-b62 fca262db9c4309f99d2f5542ab0780e45c2f1578 jdk8-b120 +ce2d7e46f3c7e41241f3b407705a4071323a11ab jdk9-b00 +050a626a88951140df874f7b163e304d07b6c296 jdk9-b01 diff --git a/hotspot/.jcheck/conf b/hotspot/.jcheck/conf index 6d0dbe48e36..5c6f62dc12c 100644 --- a/hotspot/.jcheck/conf +++ b/hotspot/.jcheck/conf @@ -1 +1 @@ -project=jdk8 +project=jdk9 diff --git a/hotspot/agent/make/Makefile b/hotspot/agent/make/Makefile index e00bbf2b36f..5efd67e649c 100644 --- a/hotspot/agent/make/Makefile +++ b/hotspot/agent/make/Makefile @@ -1,5 +1,5 @@ # -# Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2000, 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 diff --git a/hotspot/agent/src/os/linux/libproc.h b/hotspot/agent/src/os/linux/libproc.h index 4cde0c19d76..30bacaf07b9 100644 --- a/hotspot/agent/src/os/linux/libproc.h +++ b/hotspot/agent/src/os/linux/libproc.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 diff --git a/hotspot/agent/src/os/linux/salibelf.c b/hotspot/agent/src/os/linux/salibelf.c index 4c860a0fe08..1466119c0f9 100644 --- a/hotspot/agent/src/os/linux/salibelf.c +++ b/hotspot/agent/src/os/linux/salibelf.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 diff --git a/hotspot/agent/src/os/linux/symtab.c b/hotspot/agent/src/os/linux/symtab.c index f9fc33f14ec..7aae801ce20 100644 --- a/hotspot/agent/src/os/linux/symtab.c +++ b/hotspot/agent/src/os/linux/symtab.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -214,8 +214,10 @@ static int open_file_from_debug_link(const char *name, + 2); strcpy(debug_pathname, name); char *last_slash = strrchr(debug_pathname, '/'); - if (last_slash == NULL) + if (last_slash == NULL) { + free(debug_pathname); return -1; + } /* Look in the same directory as the object. */ strcpy(last_slash+1, debug_filename); diff --git a/hotspot/agent/src/os/solaris/proc/saproc.cpp b/hotspot/agent/src/os/solaris/proc/saproc.cpp index f2d148e7ec4..5a910d3a357 100644 --- a/hotspot/agent/src/os/solaris/proc/saproc.cpp +++ b/hotspot/agent/src/os/solaris/proc/saproc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 diff --git a/hotspot/agent/src/os/win32/windbg/sawindbg.cpp b/hotspot/agent/src/os/win32/windbg/sawindbg.cpp index 5dd64f9e5ae..a6a8b7af2e7 100644 --- a/hotspot/agent/src/os/win32/windbg/sawindbg.cpp +++ b/hotspot/agent/src/os/win32/windbg/sawindbg.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/CLHSDB.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/CLHSDB.java index 9e8d016dcc2..a5393107aa5 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/CLHSDB.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/CLHSDB.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/CommandProcessor.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/CommandProcessor.java index 354f0b906b3..e200826e467 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/CommandProcessor.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/CommandProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/HSDB.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/HSDB.java index d50cbaa5140..9ae362baa48 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/HSDB.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/HSDB.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/LinuxVtblAccess.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/LinuxVtblAccess.java index ae28eb3b283..d1badc37096 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/LinuxVtblAccess.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/LinuxVtblAccess.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/asm/Disassembler.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/asm/Disassembler.java index 9d351cb0917..993bf7bb477 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/asm/Disassembler.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/asm/Disassembler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciEnv.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciEnv.java index c1e6d503196..c0db13d1365 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciEnv.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciEnv.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -95,9 +95,15 @@ public class ciEnv extends VMObject { int entryBci = task.osrBci(); int compLevel = task.compLevel(); Klass holder = method.getMethodHolder(); - out.println("compile " + holder.getName().asString() + " " + - OopUtilities.escapeString(method.getName().asString()) + " " + - method.getSignature().asString() + " " + - entryBci + " " + compLevel); + out.print("compile " + holder.getName().asString() + " " + + OopUtilities.escapeString(method.getName().asString()) + " " + + method.getSignature().asString() + " " + + entryBci + " " + compLevel); + Compile compiler = compilerData(); + if (compiler != null) { + // Dump inlining data. + compiler.dumpInlineData(out); + } + out.println(); } } diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciMethod.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciMethod.java index d50e36c2a74..cdf21c946ac 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciMethod.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciMethod.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/NMethod.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/NMethod.java index 243a5397a0d..7c8d43a287a 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/NMethod.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/NMethod.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/compiler/CompileTask.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/compiler/CompileTask.java index 0a4273f3ef8..8a01fbbc35f 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/compiler/CompileTask.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/compiler/CompileTask.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/bsd/BsdAddress.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/bsd/BsdAddress.java index f25d50ff23c..bab70f28026 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/bsd/BsdAddress.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/bsd/BsdAddress.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/bsd/BsdDebugger.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/bsd/BsdDebugger.java index 34e848b4295..d7576d8ba07 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/bsd/BsdDebugger.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/bsd/BsdDebugger.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/linux/LinuxAddress.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/linux/LinuxAddress.java index cff29ce8edc..d350f09b4db 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/linux/LinuxAddress.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/linux/LinuxAddress.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/linux/LinuxDebuggerLocal.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/linux/LinuxDebuggerLocal.java index 5fffbd32377..f282a228df6 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/linux/LinuxDebuggerLocal.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/linux/LinuxDebuggerLocal.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/linux/LinuxOopHandle.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/linux/LinuxOopHandle.java index 99291aada29..4fd5bc1c7f2 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/linux/LinuxOopHandle.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/linux/LinuxOopHandle.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/linux/amd64/LinuxAMD64CFrame.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/linux/amd64/LinuxAMD64CFrame.java index cf8e073208b..dea4e09e56d 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/linux/amd64/LinuxAMD64CFrame.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/linux/amd64/LinuxAMD64CFrame.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/linux/x86/LinuxX86CFrame.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/linux/x86/LinuxX86CFrame.java index d2370c96319..53a2e26a84b 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/linux/x86/LinuxX86CFrame.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/linux/x86/LinuxX86CFrame.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/windbg/WindbgCDebugger.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/windbg/WindbgCDebugger.java index 04c4abbe0a9..ce219b986af 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/windbg/WindbgCDebugger.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/windbg/WindbgCDebugger.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/windbg/WindbgDebuggerLocal.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/windbg/WindbgDebuggerLocal.java index 22957a27deb..afe11938c42 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/windbg/WindbgDebuggerLocal.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/windbg/WindbgDebuggerLocal.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/windows/amd64/WindowsAMD64CFrame.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/windows/amd64/WindowsAMD64CFrame.java index fe4052f3512..69ad04da51b 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/windows/amd64/WindowsAMD64CFrame.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/windows/amd64/WindowsAMD64CFrame.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/windows/x86/WindowsX86CFrame.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/windows/x86/WindowsX86CFrame.java index 5c5f1f161e7..dbc8b71f35c 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/windows/x86/WindowsX86CFrame.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/windows/x86/WindowsX86CFrame.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/jdi/ArrayTypeImpl.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/jdi/ArrayTypeImpl.java index 245dbf82323..102cc79c2c4 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/jdi/ArrayTypeImpl.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/jdi/ArrayTypeImpl.java @@ -24,19 +24,29 @@ package sun.jvm.hotspot.jdi; -import com.sun.jdi.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Set; import sun.jvm.hotspot.oops.ArrayKlass; -import sun.jvm.hotspot.oops.InstanceKlass; -import sun.jvm.hotspot.oops.ObjArrayKlass; -import sun.jvm.hotspot.oops.TypeArrayKlass; -import sun.jvm.hotspot.oops.Klass; import sun.jvm.hotspot.oops.Instance; +import sun.jvm.hotspot.oops.InstanceKlass; +import sun.jvm.hotspot.oops.Klass; +import sun.jvm.hotspot.oops.ObjArrayKlass; import sun.jvm.hotspot.oops.Symbol; -import java.util.List; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.Map; +import sun.jvm.hotspot.oops.TypeArrayKlass; + +import com.sun.jdi.ArrayReference; +import com.sun.jdi.ArrayType; +import com.sun.jdi.ClassLoaderReference; +import com.sun.jdi.ClassNotLoadedException; +import com.sun.jdi.InterfaceType; +import com.sun.jdi.Method; +import com.sun.jdi.PrimitiveType; +import com.sun.jdi.ReferenceType; +import com.sun.jdi.Type; +import com.sun.jdi.VirtualMachine; public class ArrayTypeImpl extends ReferenceTypeImpl implements ArrayType { protected ArrayTypeImpl(VirtualMachine aVm, ArrayKlass aRef) { @@ -75,7 +85,8 @@ public class ArrayTypeImpl extends ReferenceTypeImpl implements ArrayType { } } - void addVisibleMethods(Map methodMap) { + @Override + void addVisibleMethods(Map methodMap, Set handledInterfaces) { // arrays don't have methods } diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/jdi/ClassTypeImpl.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/jdi/ClassTypeImpl.java index 755889d7c68..50a710e9122 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/jdi/ClassTypeImpl.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/jdi/ClassTypeImpl.java @@ -24,12 +24,30 @@ package sun.jvm.hotspot.jdi; -import com.sun.jdi.*; -import sun.jvm.hotspot.oops.Klass; +import java.lang.ref.SoftReference; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + import sun.jvm.hotspot.oops.InstanceKlass; -import java.util.*; -import java.lang.ref.SoftReference; +import com.sun.jdi.ClassNotLoadedException; +import com.sun.jdi.ClassType; +import com.sun.jdi.Field; +import com.sun.jdi.IncompatibleThreadStateException; +import com.sun.jdi.InterfaceType; +import com.sun.jdi.InvalidTypeException; +import com.sun.jdi.InvocationException; +import com.sun.jdi.Method; +import com.sun.jdi.ObjectReference; +import com.sun.jdi.ReferenceType; +import com.sun.jdi.ThreadReference; +import com.sun.jdi.Value; +import com.sun.jdi.VirtualMachine; public class ClassTypeImpl extends ReferenceTypeImpl implements ClassType @@ -195,22 +213,26 @@ public class ClassTypeImpl extends ReferenceTypeImpl return null; } - void addVisibleMethods(Map methodMap) { + @Override + void addVisibleMethods(Map methodMap, Set seenInterfaces) { /* * Add methods from * parent types first, so that the methods in this class will * overwrite them in the hash table */ - Iterator iter = interfaces().iterator(); + Iterator iter = interfaces().iterator(); while (iter.hasNext()) { InterfaceTypeImpl interfaze = (InterfaceTypeImpl)iter.next(); - interfaze.addVisibleMethods(methodMap); + if (!seenInterfaces.contains(interfaze)) { + interfaze.addVisibleMethods(methodMap, seenInterfaces); + seenInterfaces.add(interfaze); + } } ClassTypeImpl clazz = (ClassTypeImpl)superclass(); if (clazz != null) { - clazz.addVisibleMethods(methodMap); + clazz.addVisibleMethods(methodMap, seenInterfaces); } addToMethodMap(methodMap, methods()); diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/jdi/InterfaceTypeImpl.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/jdi/InterfaceTypeImpl.java index 5c4f2abcafb..4bc4201ef8a 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/jdi/InterfaceTypeImpl.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/jdi/InterfaceTypeImpl.java @@ -24,15 +24,22 @@ package sun.jvm.hotspot.jdi; -import com.sun.jdi.*; +import java.lang.ref.SoftReference; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + import sun.jvm.hotspot.oops.InstanceKlass; -import java.util.List; -import java.util.ArrayList; -import java.util.Map; -import java.util.Iterator; -import java.util.Collections; -import java.lang.ref.SoftReference; +import com.sun.jdi.ClassNotPreparedException; +import com.sun.jdi.ClassType; +import com.sun.jdi.InterfaceType; +import com.sun.jdi.Method; +import com.sun.jdi.ReferenceType; +import com.sun.jdi.VirtualMachine; public class InterfaceTypeImpl extends ReferenceTypeImpl implements InterfaceType { @@ -96,16 +103,20 @@ public class InterfaceTypeImpl extends ReferenceTypeImpl return implementors; } - void addVisibleMethods(Map methodMap) { + @Override + void addVisibleMethods(Map methodMap, Set seenInterfaces) { /* * Add methods from * parent types first, so that the methods in this class will * overwrite them in the hash table */ - Iterator iter = superinterfaces().iterator(); + Iterator iter = superinterfaces().iterator(); while (iter.hasNext()) { InterfaceTypeImpl interfaze = (InterfaceTypeImpl)iter.next(); - interfaze.addVisibleMethods(methodMap); + if (!seenInterfaces.contains(interfaze)) { + interfaze.addVisibleMethods(methodMap, seenInterfaces); + seenInterfaces.add(interfaze); + } } addToMethodMap(methodMap, methods()); diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/jdi/JVMTIThreadState.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/jdi/JVMTIThreadState.java index dbf09b29119..0dcb772f913 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/jdi/JVMTIThreadState.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/jdi/JVMTIThreadState.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/jdi/ReferenceTypeImpl.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/jdi/ReferenceTypeImpl.java index d3a2ea9d291..dd235f9ffef 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/jdi/ReferenceTypeImpl.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/jdi/ReferenceTypeImpl.java @@ -24,24 +24,45 @@ package sun.jvm.hotspot.jdi; -import java.io.*; - -import com.sun.jdi.*; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.lang.ref.SoftReference; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +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 sun.jvm.hotspot.memory.SystemDictionary; +import sun.jvm.hotspot.oops.ArrayKlass; +import sun.jvm.hotspot.oops.DefaultHeapVisitor; import sun.jvm.hotspot.oops.Instance; import sun.jvm.hotspot.oops.InstanceKlass; -import sun.jvm.hotspot.oops.ArrayKlass; import sun.jvm.hotspot.oops.JVMDIClassStatus; import sun.jvm.hotspot.oops.Klass; -import sun.jvm.hotspot.oops.ObjArray; import sun.jvm.hotspot.oops.Oop; import sun.jvm.hotspot.oops.Symbol; -import sun.jvm.hotspot.oops.DefaultHeapVisitor; import sun.jvm.hotspot.utilities.Assert; -import java.util.*; -import java.lang.ref.SoftReference; +import com.sun.jdi.AbsentInformationException; +import com.sun.jdi.ArrayType; +import com.sun.jdi.ClassLoaderReference; +import com.sun.jdi.ClassNotLoadedException; +import com.sun.jdi.ClassNotPreparedException; +import com.sun.jdi.ClassObjectReference; +import com.sun.jdi.Field; +import com.sun.jdi.InterfaceType; +import com.sun.jdi.Method; +import com.sun.jdi.ObjectReference; +import com.sun.jdi.PrimitiveType; +import com.sun.jdi.ReferenceType; +import com.sun.jdi.Type; +import com.sun.jdi.Value; +import com.sun.jdi.VirtualMachine; public abstract class ReferenceTypeImpl extends TypeImpl implements ReferenceType { @@ -421,7 +442,8 @@ implements ReferenceType { } } - abstract void addVisibleMethods(Map methodMap); + abstract void addVisibleMethods(Map methodMap, Set seenInterfaces); + public final List visibleMethods() throws ClassNotPreparedException { checkPrepared(); /* @@ -430,8 +452,8 @@ implements ReferenceType { * concatenation of name and signature. */ //System.out.println("jj: RTI: Calling addVisibleMethods for:" + this); - Map map = new HashMap(); - addVisibleMethods(map); + Map map = new HashMap(); + addVisibleMethods(map, new HashSet()); /* * ... but the hash map destroys order. Methods should be @@ -441,7 +463,7 @@ implements ReferenceType { */ //System.out.println("jj: RTI: Calling allMethods for:" + this); - List list = new ArrayList(allMethods()); + List list = new ArrayList(allMethods()); //System.out.println("jj: allMethods = " + jjstr(list)); //System.out.println("jj: map = " + map.toString()); //System.out.println("jj: map = " + jjstr(map.values())); diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/CMSCollector.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/CMSCollector.java index f28caad66e7..28205ae0b03 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/CMSCollector.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/CMSCollector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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 diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/DictionaryEntry.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/DictionaryEntry.java index 301410408d2..3d4a9f6392e 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/DictionaryEntry.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/DictionaryEntry.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/SymbolTable.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/SymbolTable.java index 3069cf6b377..7510d08bfd0 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/SymbolTable.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/SymbolTable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/ArrayKlass.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/ArrayKlass.java index 9530cdd977a..ba9422ca8ee 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/ArrayKlass.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/ArrayKlass.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java index 01104f59515..75aa05c3954 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/Klass.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/Klass.java index 19a3668c7f3..9e1561bd390 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/Klass.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/Klass.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/MethodCounters.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/MethodCounters.java index 854aa818c89..ec2cbbe9f4b 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/MethodCounters.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/MethodCounters.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/MethodData.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/MethodData.java index eb643483fe5..41c121468ea 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/MethodData.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/MethodData.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/ObjectHeap.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/ObjectHeap.java index e663ee8e18f..d550a935fa3 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/ObjectHeap.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/ObjectHeap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -364,7 +364,7 @@ public class ObjectHeap { } catch (AddressException e) { // This is okay at the top of these regions - } + } catch (UnknownOopException e) { // This is okay at the top of these regions } @@ -373,7 +373,7 @@ public class ObjectHeap { visitor.epilogue(); } - private void addLiveRegions(List input, List output) { + private void addLiveRegions(String name, List input, List output) { for (Iterator itr = input.iterator(); itr.hasNext();) { MemRegion reg = (MemRegion) itr.next(); Address top = reg.end(); @@ -386,6 +386,9 @@ public class ObjectHeap { } output.add(top); output.add(bottom); + if (DEBUG) { + System.err.println("Live region: " + name + ": " + bottom + ", " + top); + } } } @@ -395,7 +398,7 @@ public class ObjectHeap { } public void doSpace(Space s) { - addLiveRegions(s.getLiveRegions(), liveRegions); + addLiveRegions(s.toString(), s.getLiveRegions(), liveRegions); } private List liveRegions; } @@ -426,11 +429,11 @@ public class ObjectHeap { ParallelScavengeHeap psh = (ParallelScavengeHeap) heap; PSYoungGen youngGen = psh.youngGen(); // Add eden space - addLiveRegions(youngGen.edenSpace().getLiveRegions(), liveRegions); + addLiveRegions("eden", youngGen.edenSpace().getLiveRegions(), liveRegions); // Add from-space but not to-space - addLiveRegions(youngGen.fromSpace().getLiveRegions(), liveRegions); + addLiveRegions("from", youngGen.fromSpace().getLiveRegions(), liveRegions); PSOldGen oldGen = psh.oldGen(); - addLiveRegions(oldGen.objectSpace().getLiveRegions(), liveRegions); + addLiveRegions("old ", oldGen.objectSpace().getLiveRegions(), liveRegions); } else if (heap instanceof G1CollectedHeap) { G1CollectedHeap g1h = (G1CollectedHeap) heap; g1h.heapRegionIterate(lrc); @@ -451,23 +454,27 @@ public class ObjectHeap { if (VM.getVM().getUseTLAB()) { for (JavaThread thread = VM.getVM().getThreads().first(); thread != null; thread = thread.next()) { - if (thread.isJavaThread()) { - ThreadLocalAllocBuffer tlab = thread.tlab(); - if (tlab.start() != null) { - if ((tlab.top() == null) || (tlab.end() == null)) { - System.err.print("Warning: skipping invalid TLAB for thread "); + ThreadLocalAllocBuffer tlab = thread.tlab(); + if (tlab.start() != null) { + if ((tlab.top() == null) || (tlab.end() == null)) { + System.err.print("Warning: skipping invalid TLAB for thread "); + thread.printThreadIDOn(System.err); + System.err.println(); + } else { + if (DEBUG) { + System.err.print("TLAB for " + thread.getThreadName() + ", #"); thread.printThreadIDOn(System.err); - System.err.println(); - } else { - // Go from: - // - below start() to start() - // - start() to top() - // - end() and above - liveRegions.add(tlab.start()); - liveRegions.add(tlab.start()); - liveRegions.add(tlab.top()); - liveRegions.add(tlab.hardEnd()); + System.err.print(": "); + tlab.printOn(System.err); } + // Go from: + // - below start() to start() + // - start() to top() + // - end() and above + liveRegions.add(tlab.start()); + liveRegions.add(tlab.start()); + liveRegions.add(tlab.top()); + liveRegions.add(tlab.hardEnd()); } } } @@ -480,6 +487,15 @@ public class ObjectHeap { Assert.that(liveRegions.size() % 2 == 0, "Must have even number of region boundaries"); } + if (DEBUG) { + System.err.println("liveRegions:"); + for (int i = 0; i < liveRegions.size(); i += 2) { + Address bottom = (Address) liveRegions.get(i); + Address top = (Address) liveRegions.get(i+1); + System.err.println(" " + bottom + " - " + top); + } + } + return liveRegions; } diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/Compile.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/Compile.java index 9e4cfa73b09..6e06fb5ef18 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/Compile.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/Compile.java @@ -25,6 +25,7 @@ package sun.jvm.hotspot.opto; import java.util.*; +import java.io.PrintStream; import sun.jvm.hotspot.ci.*; import sun.jvm.hotspot.debugger.*; import sun.jvm.hotspot.runtime.*; @@ -92,4 +93,13 @@ public class Compile extends VMObject { } return null; } + + public void dumpInlineData(PrintStream out) { + InlineTree inlTree = ilt(); + if (inlTree != null) { + out.print(" inline " + inlTree.count()); + inlTree.dumpReplayData(out); + } + } + } diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/InlineTree.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/InlineTree.java index 4021e706e88..53f024183a8 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/InlineTree.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/InlineTree.java @@ -87,6 +87,11 @@ public class InlineTree extends VMObject { return GrowableArray.create(addr, inlineTreeConstructor); } + public int inlineLevel() { + JVMState jvms = callerJvms(); + return (jvms != null) ? jvms.depth() : 0; + } + public void printImpl(PrintStream st, int indent) { for (int i = 0; i < indent; i++) st.print(" "); st.printf(" @ %d ", callerBci()); @@ -101,4 +106,28 @@ public class InlineTree extends VMObject { public void print(PrintStream st) { printImpl(st, 2); } + + // Count number of nodes in this subtree + public int count() { + int result = 1; + GrowableArray subt = subtrees(); + for (int i = 0 ; i < subt.length(); i++) { + result += subt.at(i).count(); + } + return result; + } + + public void dumpReplayData(PrintStream out) { + out.printf(" %d %d ", inlineLevel(), callerBci()); + Method method = (Method)method().getMetadata(); + Klass holder = method.getMethodHolder(); + out.print(holder.getName().asString() + " " + + OopUtilities.escapeString(method.getName().asString()) + " " + + method.getSignature().asString()); + + GrowableArray subt = subtrees(); + for (int i = 0 ; i < subt.length(); i++) { + subt.at(i).dumpReplayData(out); + } + } } diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/JVMState.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/JVMState.java index 52996ee763e..65e0d7a98f8 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/JVMState.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/JVMState.java @@ -88,6 +88,10 @@ public class JVMState extends VMObject { return (int)bciField.getValue(getAddress()); } + public int depth() { + return (int)depthField.getValue(getAddress()); + } + public JVMState caller() { return create(callerField.getValue(getAddress())); } diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/PhaseCFG.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/PhaseCFG.java index 66344b553f6..4429754a5fe 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/PhaseCFG.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/PhaseCFG.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/ThreadLocalAllocBuffer.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/ThreadLocalAllocBuffer.java index 738dc94fa91..74530b8f101 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/ThreadLocalAllocBuffer.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/ThreadLocalAllocBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -109,6 +109,6 @@ public class ThreadLocalAllocBuffer extends VMObject { public void printOn(PrintStream tty) { tty.println(" [" + start() + "," + - top() + "," + end() + ")"); + top() + "," + end() + ",{" + hardEnd() + "})"); } } diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/VM.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/VM.java index 8088a49993c..29bf9efea7d 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/VM.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/VM.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/bsd_amd64/BsdAMD64JavaThreadPDAccess.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/bsd_amd64/BsdAMD64JavaThreadPDAccess.java index 03e35de5695..47571dfdf7d 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/bsd_amd64/BsdAMD64JavaThreadPDAccess.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/bsd_amd64/BsdAMD64JavaThreadPDAccess.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/FinalizerInfo.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/FinalizerInfo.java index 2a8ca2cfb7a..58819a0a7dd 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/FinalizerInfo.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/FinalizerInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/FlagDumper.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/FlagDumper.java index 37fa4c83c26..38244c3b84f 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/FlagDumper.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/FlagDumper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/HeapDumper.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/HeapDumper.java index e2da202acb9..1b93504313a 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/HeapDumper.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/HeapDumper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/HeapSummary.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/HeapSummary.java index f87457c3c3e..32c1358cbe2 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/HeapSummary.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/HeapSummary.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/JInfo.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/JInfo.java index bec93e65d9d..7469de28f40 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/JInfo.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/JInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/JSnap.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/JSnap.java index c2e5ed52f84..fc281406d86 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/JSnap.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/JSnap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/JStack.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/JStack.java index 52fb6654e70..b8609bcdbeb 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/JStack.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/JStack.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2005, Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/ObjectHistogram.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/ObjectHistogram.java index 6c6c555badf..ddedcae5394 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/ObjectHistogram.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/ObjectHistogram.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/PMap.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/PMap.java index e18aa76cfa6..43bcd593f30 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/PMap.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/PMap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/StackTrace.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/StackTrace.java index bbb0b081b2d..6f519a74b14 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/StackTrace.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/StackTrace.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/SysPropsDumper.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/SysPropsDumper.java index 01465574006..ada81adf58e 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/SysPropsDumper.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/SysPropsDumper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/Tool.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/Tool.java index 9fd86ccb347..d1da9cfbaaf 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/Tool.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/Tool.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/soql/JSDB.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/soql/JSDB.java index db6dc339394..bd7e4c4ce45 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/soql/JSDB.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/soql/JSDB.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/soql/SOQL.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/soql/SOQL.java index 67f5ed1e920..eceabd39a98 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/soql/SOQL.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/soql/SOQL.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/types/basic/BasicTypeDataBase.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/types/basic/BasicTypeDataBase.java index 12325863163..910e15e0f37 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/types/basic/BasicTypeDataBase.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/types/basic/BasicTypeDataBase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/ui/SAPanel.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ui/SAPanel.java index e1829a332da..9bc7e4b4e48 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/ui/SAPanel.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ui/SAPanel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2006, Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/AbstractHeapGraphWriter.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/AbstractHeapGraphWriter.java index 382d2477b52..5dbf8984158 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/AbstractHeapGraphWriter.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/AbstractHeapGraphWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/HeapGXLWriter.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/HeapGXLWriter.java index 47494e826b3..dbb95d392b4 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/HeapGXLWriter.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/HeapGXLWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/HeapHprofBinWriter.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/HeapHprofBinWriter.java index 6f66723db99..60df0ffe92b 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/HeapHprofBinWriter.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/HeapHprofBinWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaInstanceKlass.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaInstanceKlass.java index a76e5ddbf31..069a40326a2 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaInstanceKlass.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaInstanceKlass.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/soql/sa.js b/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/soql/sa.js index 4253740369b..a700f1bc6bd 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/soql/sa.js +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/soql/sa.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/hotspot/make/bsd/makefiles/adlc.make b/hotspot/make/bsd/makefiles/adlc.make index cf5c05e2ac7..e37e60ca97b 100644 --- a/hotspot/make/bsd/makefiles/adlc.make +++ b/hotspot/make/bsd/makefiles/adlc.make @@ -1,5 +1,5 @@ # -# Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1999, 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 diff --git a/hotspot/make/bsd/makefiles/gcc.make b/hotspot/make/bsd/makefiles/gcc.make index 840148e6321..8f708eab3df 100644 --- a/hotspot/make/bsd/makefiles/gcc.make +++ b/hotspot/make/bsd/makefiles/gcc.make @@ -260,14 +260,13 @@ ifeq ($(USE_CLANG), true) WARNINGS_ARE_ERRORS += -Wno-empty-body endif -WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef +WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef -Wunused-function -Wunused-value -ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0" +ifeq ($(USE_CLANG),) # Since GCC 4.3, -Wconversion has changed its meanings to warn these implicit # conversions which might affect the values. Only enable it in earlier versions. - WARNING_FLAGS = -Wunused-function - ifeq ($(USE_CLANG),) - WARNING_FLAGS += -Wconversion + ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0" + WARNINGS_FLAGS += -Wconversion endif endif diff --git a/hotspot/make/bsd/makefiles/mapfile-vers-debug b/hotspot/make/bsd/makefiles/mapfile-vers-debug index 9a8fc822bc4..d446cc81d84 100644 --- a/hotspot/make/bsd/makefiles/mapfile-vers-debug +++ b/hotspot/make/bsd/makefiles/mapfile-vers-debug @@ -242,11 +242,6 @@ _JVM_Yield _JVM_handle_bsd_signal - # debug _JVM - _JVM_AccessVMBooleanFlag - _JVM_AccessVMIntFlag - _JVM_VMBreakPoint - # miscellaneous functions _jio_fprintf _jio_printf diff --git a/hotspot/make/bsd/makefiles/minimal1.make b/hotspot/make/bsd/makefiles/minimal1.make index d045db79099..03845fd12b7 100644 --- a/hotspot/make/bsd/makefiles/minimal1.make +++ b/hotspot/make/bsd/makefiles/minimal1.make @@ -1,5 +1,5 @@ # -# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. +# 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 diff --git a/hotspot/make/hotspot.script b/hotspot/make/hotspot.script index c6259ba2eee..9177f6efef8 100644 --- a/hotspot/make/hotspot.script +++ b/hotspot/make/hotspot.script @@ -1,6 +1,6 @@ #!/bin/sh -# Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it diff --git a/hotspot/make/linux/makefiles/adlc.make b/hotspot/make/linux/makefiles/adlc.make index 7b808d9b2ae..8a866917b80 100644 --- a/hotspot/make/linux/makefiles/adlc.make +++ b/hotspot/make/linux/makefiles/adlc.make @@ -1,5 +1,5 @@ # -# Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1999, 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 diff --git a/hotspot/make/linux/makefiles/jsig.make b/hotspot/make/linux/makefiles/jsig.make index 1064a965249..6e13959482a 100644 --- a/hotspot/make/linux/makefiles/jsig.make +++ b/hotspot/make/linux/makefiles/jsig.make @@ -1,5 +1,5 @@ # -# Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2005, 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 diff --git a/hotspot/make/linux/makefiles/mapfile-vers-debug b/hotspot/make/linux/makefiles/mapfile-vers-debug index 68be2ffefb3..4936ba711f9 100644 --- a/hotspot/make/linux/makefiles/mapfile-vers-debug +++ b/hotspot/make/linux/makefiles/mapfile-vers-debug @@ -244,11 +244,6 @@ SUNWprivate_1.1 { JVM_Yield; JVM_handle_linux_signal; - # debug JVM - JVM_AccessVMBooleanFlag; - JVM_AccessVMIntFlag; - JVM_VMBreakPoint; - # miscellaneous functions jio_fprintf; jio_printf; diff --git a/hotspot/make/linux/makefiles/minimal1.make b/hotspot/make/linux/makefiles/minimal1.make index d045db79099..03845fd12b7 100644 --- a/hotspot/make/linux/makefiles/minimal1.make +++ b/hotspot/make/linux/makefiles/minimal1.make @@ -1,5 +1,5 @@ # -# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. +# 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 diff --git a/hotspot/make/linux/makefiles/saproc.make b/hotspot/make/linux/makefiles/saproc.make index 90c91136185..7e8f7c430f9 100644 --- a/hotspot/make/linux/makefiles/saproc.make +++ b/hotspot/make/linux/makefiles/saproc.make @@ -1,5 +1,5 @@ # -# Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2005, 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 diff --git a/hotspot/make/sa.files b/hotspot/make/sa.files index 44308c2a217..faad4dd109f 100644 --- a/hotspot/make/sa.files +++ b/hotspot/make/sa.files @@ -1,5 +1,5 @@ # -# Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2003, 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 diff --git a/hotspot/make/solaris/makefiles/adlc.make b/hotspot/make/solaris/makefiles/adlc.make index 642a7ca6136..88d9d2bc476 100644 --- a/hotspot/make/solaris/makefiles/adlc.make +++ b/hotspot/make/solaris/makefiles/adlc.make @@ -1,5 +1,5 @@ # -# Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1997, 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 diff --git a/hotspot/make/solaris/makefiles/gcc.make b/hotspot/make/solaris/makefiles/gcc.make index e946d65d256..fe65ad4f5bf 100644 --- a/hotspot/make/solaris/makefiles/gcc.make +++ b/hotspot/make/solaris/makefiles/gcc.make @@ -1,5 +1,5 @@ # -# Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it diff --git a/hotspot/make/solaris/makefiles/mapfile-vers-debug b/hotspot/make/solaris/makefiles/mapfile-vers-debug index 234d391b604..f6b63d5a4bf 100644 --- a/hotspot/make/solaris/makefiles/mapfile-vers-debug +++ b/hotspot/make/solaris/makefiles/mapfile-vers-debug @@ -28,10 +28,6 @@ SUNWprivate_1.1 { global: - # debug JVM - JVM_AccessVMBooleanFlag; - JVM_AccessVMIntFlag; - JVM_VMBreakPoint; # miscellaneous }; diff --git a/hotspot/make/windows/build_vm_def.sh b/hotspot/make/windows/build_vm_def.sh index fa82d26a81a..3d905198cb6 100644 --- a/hotspot/make/windows/build_vm_def.sh +++ b/hotspot/make/windows/build_vm_def.sh @@ -1,5 +1,5 @@ # -# Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2000, 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 diff --git a/hotspot/make/windows/makefiles/adlc.make b/hotspot/make/windows/makefiles/adlc.make index 7bcaef718fd..781e3ac4048 100644 --- a/hotspot/make/windows/makefiles/adlc.make +++ b/hotspot/make/windows/makefiles/adlc.make @@ -1,5 +1,5 @@ # -# Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1999, 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 diff --git a/hotspot/make/windows/makefiles/debug.make b/hotspot/make/windows/makefiles/debug.make index 14a07083434..f4e54fc52fb 100644 --- a/hotspot/make/windows/makefiles/debug.make +++ b/hotspot/make/windows/makefiles/debug.make @@ -1,5 +1,5 @@ # -# Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1997, 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 diff --git a/hotspot/make/windows/makefiles/product.make b/hotspot/make/windows/makefiles/product.make index 713ec0e54ca..c1ce35a163c 100644 --- a/hotspot/make/windows/makefiles/product.make +++ b/hotspot/make/windows/makefiles/product.make @@ -1,5 +1,5 @@ # -# Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2005, 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 diff --git a/hotspot/make/windows/makefiles/rules.make b/hotspot/make/windows/makefiles/rules.make index d728263171b..c5d565a2880 100644 --- a/hotspot/make/windows/makefiles/rules.make +++ b/hotspot/make/windows/makefiles/rules.make @@ -1,5 +1,5 @@ # -# Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2003, 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 diff --git a/hotspot/make/windows/makefiles/sa.make b/hotspot/make/windows/makefiles/sa.make index 5b5cc2d723c..2208da9e3d8 100644 --- a/hotspot/make/windows/makefiles/sa.make +++ b/hotspot/make/windows/makefiles/sa.make @@ -1,5 +1,5 @@ # -# Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2003, 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 @@ -94,7 +94,7 @@ SA_CFLAGS = -nologo $(MS_RUNTIME_OPTION) -W3 $(GX_OPTION) -Od -D "WIN32" -D "WIN SA_LD_FLAGS = bufferoverflowU.lib !endif !else -SA_CFLAGS = -nologo $(MS_RUNTIME_OPTION) -W3 -Gm $(GX_OPTION) -Od -D "WIN32" -D "_WINDOWS" -D "_DEBUG" -D "_CONSOLE" -D "_MBCS" -YX -FD -GZ -c +SA_CFLAGS = -nologo $(MS_RUNTIME_OPTION) -W3 $(GX_OPTION) -Od -D "WIN32" -D "_WINDOWS" -D "_DEBUG" -D "_CONSOLE" -D "_MBCS" -FD -RTC1 -c !if "$(ENABLE_FULL_DEBUG_SYMBOLS)" == "1" SA_CFLAGS = $(SA_CFLAGS) -ZI !endif diff --git a/hotspot/src/cpu/sparc/vm/assembler_sparc.hpp b/hotspot/src/cpu/sparc/vm/assembler_sparc.hpp index 3192a855569..ccbc43e5a92 100644 --- a/hotspot/src/cpu/sparc/vm/assembler_sparc.hpp +++ b/hotspot/src/cpu/sparc/vm/assembler_sparc.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/cpu/sparc/vm/assembler_sparc.inline.hpp b/hotspot/src/cpu/sparc/vm/assembler_sparc.inline.hpp index ade531a3f82..2e5ba210199 100644 --- a/hotspot/src/cpu/sparc/vm/assembler_sparc.inline.hpp +++ b/hotspot/src/cpu/sparc/vm/assembler_sparc.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/cpu/sparc/vm/c1_CodeStubs_sparc.cpp b/hotspot/src/cpu/sparc/vm/c1_CodeStubs_sparc.cpp index c6039055300..8584037f1ca 100644 --- a/hotspot/src/cpu/sparc/vm/c1_CodeStubs_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/c1_CodeStubs_sparc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 diff --git a/hotspot/src/cpu/sparc/vm/c1_FrameMap_sparc.cpp b/hotspot/src/cpu/sparc/vm/c1_FrameMap_sparc.cpp index e6e7212ed4a..87a95e5ec8c 100644 --- a/hotspot/src/cpu/sparc/vm/c1_FrameMap_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/c1_FrameMap_sparc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 diff --git a/hotspot/src/cpu/sparc/vm/c1_MacroAssembler_sparc.cpp b/hotspot/src/cpu/sparc/vm/c1_MacroAssembler_sparc.cpp index 6d10ab81aaf..3da6cd8cf21 100644 --- a/hotspot/src/cpu/sparc/vm/c1_MacroAssembler_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/c1_MacroAssembler_sparc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 diff --git a/hotspot/src/cpu/sparc/vm/c1_Runtime1_sparc.cpp b/hotspot/src/cpu/sparc/vm/c1_Runtime1_sparc.cpp index 742cacc226b..0b065201261 100644 --- a/hotspot/src/cpu/sparc/vm/c1_Runtime1_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/c1_Runtime1_sparc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 diff --git a/hotspot/src/cpu/sparc/vm/c1_globals_sparc.hpp b/hotspot/src/cpu/sparc/vm/c1_globals_sparc.hpp index c6cf521272d..57f871247b0 100644 --- a/hotspot/src/cpu/sparc/vm/c1_globals_sparc.hpp +++ b/hotspot/src/cpu/sparc/vm/c1_globals_sparc.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 diff --git a/hotspot/src/cpu/sparc/vm/c2_globals_sparc.hpp b/hotspot/src/cpu/sparc/vm/c2_globals_sparc.hpp index e4fe6bb00a4..fba1d414c36 100644 --- a/hotspot/src/cpu/sparc/vm/c2_globals_sparc.hpp +++ b/hotspot/src/cpu/sparc/vm/c2_globals_sparc.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 diff --git a/hotspot/src/cpu/sparc/vm/c2_init_sparc.cpp b/hotspot/src/cpu/sparc/vm/c2_init_sparc.cpp index 6ad04df863d..b4b3bbd45b9 100644 --- a/hotspot/src/cpu/sparc/vm/c2_init_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/c2_init_sparc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 diff --git a/hotspot/src/cpu/sparc/vm/disassembler_sparc.hpp b/hotspot/src/cpu/sparc/vm/disassembler_sparc.hpp index a1f576b26a7..069840975d2 100644 --- a/hotspot/src/cpu/sparc/vm/disassembler_sparc.hpp +++ b/hotspot/src/cpu/sparc/vm/disassembler_sparc.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/cpu/sparc/vm/frame_sparc.inline.hpp b/hotspot/src/cpu/sparc/vm/frame_sparc.inline.hpp index 774e8f3f0f5..61ef794abd0 100644 --- a/hotspot/src/cpu/sparc/vm/frame_sparc.inline.hpp +++ b/hotspot/src/cpu/sparc/vm/frame_sparc.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/cpu/sparc/vm/globalDefinitions_sparc.hpp b/hotspot/src/cpu/sparc/vm/globalDefinitions_sparc.hpp index cadaffe73c7..dd0319f0374 100644 --- a/hotspot/src/cpu/sparc/vm/globalDefinitions_sparc.hpp +++ b/hotspot/src/cpu/sparc/vm/globalDefinitions_sparc.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 diff --git a/hotspot/src/cpu/sparc/vm/globals_sparc.hpp b/hotspot/src/cpu/sparc/vm/globals_sparc.hpp index ecc6eb61524..63ab5efa808 100644 --- a/hotspot/src/cpu/sparc/vm/globals_sparc.hpp +++ b/hotspot/src/cpu/sparc/vm/globals_sparc.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 diff --git a/hotspot/src/cpu/sparc/vm/jni_sparc.h b/hotspot/src/cpu/sparc/vm/jni_sparc.h index 2b0ce0081c5..a7540600488 100644 --- a/hotspot/src/cpu/sparc/vm/jni_sparc.h +++ b/hotspot/src/cpu/sparc/vm/jni_sparc.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/cpu/sparc/vm/nativeInst_sparc.hpp b/hotspot/src/cpu/sparc/vm/nativeInst_sparc.hpp index aa362012dcf..29273e7fe61 100644 --- a/hotspot/src/cpu/sparc/vm/nativeInst_sparc.hpp +++ b/hotspot/src/cpu/sparc/vm/nativeInst_sparc.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/cpu/sparc/vm/register_sparc.hpp b/hotspot/src/cpu/sparc/vm/register_sparc.hpp index 423a424c936..7d0096ccf59 100644 --- a/hotspot/src/cpu/sparc/vm/register_sparc.hpp +++ b/hotspot/src/cpu/sparc/vm/register_sparc.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 diff --git a/hotspot/src/cpu/sparc/vm/sharedRuntime_sparc.cpp b/hotspot/src/cpu/sparc/vm/sharedRuntime_sparc.cpp index 4b6b1c7c00d..e35133122ab 100644 --- a/hotspot/src/cpu/sparc/vm/sharedRuntime_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/sharedRuntime_sparc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 diff --git a/hotspot/src/cpu/sparc/vm/sparc.ad b/hotspot/src/cpu/sparc/vm/sparc.ad index 9d3856245f2..19283874280 100644 --- a/hotspot/src/cpu/sparc/vm/sparc.ad +++ b/hotspot/src/cpu/sparc/vm/sparc.ad @@ -757,7 +757,7 @@ void verify_oops_warning(const MachNode *n, int ideal_op, int mem_op) { #endif -void emit_form3_mem_reg(CodeBuffer &cbuf, const MachNode* n, int primary, int tertiary, +void emit_form3_mem_reg(CodeBuffer &cbuf, PhaseRegAlloc* ra, const MachNode* n, int primary, int tertiary, int src1_enc, int disp32, int src2_enc, int dst_enc) { #ifdef ASSERT @@ -912,8 +912,14 @@ void emit_form3_mem_reg(CodeBuffer &cbuf, const MachNode* n, int primary, int te uint index = src2_enc; int disp = disp32; - if (src1_enc == R_SP_enc || src1_enc == R_FP_enc) + if (src1_enc == R_SP_enc || src1_enc == R_FP_enc) { disp += STACK_BIAS; + // Quick fix for JDK-8029668: check that stack offset fits, bailout if not + if (!Assembler::is_simm13(disp)) { + ra->C->record_method_not_compilable("unable to handle large constant offsets"); + return; + } + } // We should have a compiler bailout here rather than a guarantee. // Better yet would be some mechanism to handle variable-size matches correctly. @@ -1279,20 +1285,15 @@ static enum RC rc_class( OptoReg::Name reg ) { return rc_float; } -static int impl_helper( const MachNode *mach, CodeBuffer *cbuf, PhaseRegAlloc *ra_, bool do_size, bool is_load, int offset, int reg, int opcode, const char *op_str, int size, outputStream* st ) { - if( cbuf ) { - // Better yet would be some mechanism to handle variable-size matches correctly - if (!Assembler::is_simm13(offset + STACK_BIAS)) { - ra_->C->record_method_not_compilable("unable to handle large constant offsets"); - } else { - emit_form3_mem_reg(*cbuf, mach, opcode, -1, R_SP_enc, offset, 0, Matcher::_regEncode[reg]); - } +static int impl_helper(const MachNode* mach, CodeBuffer* cbuf, PhaseRegAlloc* ra, bool do_size, bool is_load, int offset, int reg, int opcode, const char *op_str, int size, outputStream* st ) { + if (cbuf) { + emit_form3_mem_reg(*cbuf, ra, mach, opcode, -1, R_SP_enc, offset, 0, Matcher::_regEncode[reg]); } #ifndef PRODUCT - else if( !do_size ) { - if( size != 0 ) st->print("\n\t"); - if( is_load ) st->print("%s [R_SP + #%d],R_%s\t! spill",op_str,offset,OptoReg::regname(reg)); - else st->print("%s R_%s,[R_SP + #%d]\t! spill",op_str,OptoReg::regname(reg),offset); + else if (!do_size) { + if (size != 0) st->print("\n\t"); + if (is_load) st->print("%s [R_SP + #%d],R_%s\t! spill",op_str,offset,OptoReg::regname(reg)); + else st->print("%s R_%s,[R_SP + #%d]\t! spill",op_str,OptoReg::regname(reg),offset); } #endif return size+4; @@ -2087,22 +2088,22 @@ encode %{ %} enc_class form3_mem_reg( memory mem, iRegI dst ) %{ - emit_form3_mem_reg(cbuf, this, $primary, $tertiary, + emit_form3_mem_reg(cbuf, ra_, this, $primary, $tertiary, $mem$$base, $mem$$disp, $mem$$index, $dst$$reg); %} enc_class simple_form3_mem_reg( memory mem, iRegI dst ) %{ - emit_form3_mem_reg(cbuf, this, $primary, -1, + emit_form3_mem_reg(cbuf, ra_, this, $primary, -1, $mem$$base, $mem$$disp, $mem$$index, $dst$$reg); %} enc_class form3_mem_prefetch_read( memory mem ) %{ - emit_form3_mem_reg(cbuf, this, $primary, -1, + emit_form3_mem_reg(cbuf, ra_, this, $primary, -1, $mem$$base, $mem$$disp, $mem$$index, 0/*prefetch function many-reads*/); %} enc_class form3_mem_prefetch_write( memory mem ) %{ - emit_form3_mem_reg(cbuf, this, $primary, -1, + emit_form3_mem_reg(cbuf, ra_, this, $primary, -1, $mem$$base, $mem$$disp, $mem$$index, 2/*prefetch function many-writes*/); %} @@ -2110,8 +2111,8 @@ encode %{ assert(Assembler::is_simm13($mem$$disp ), "need disp and disp+4"); assert(Assembler::is_simm13($mem$$disp+4), "need disp and disp+4"); guarantee($mem$$index == R_G0_enc, "double index?"); - emit_form3_mem_reg(cbuf, this, $primary, -1, $mem$$base, $mem$$disp+4, R_G0_enc, R_O7_enc ); - emit_form3_mem_reg(cbuf, this, $primary, -1, $mem$$base, $mem$$disp, R_G0_enc, $reg$$reg ); + emit_form3_mem_reg(cbuf, ra_, this, $primary, -1, $mem$$base, $mem$$disp+4, R_G0_enc, R_O7_enc ); + emit_form3_mem_reg(cbuf, ra_, this, $primary, -1, $mem$$base, $mem$$disp, R_G0_enc, $reg$$reg ); emit3_simm13( cbuf, Assembler::arith_op, $reg$$reg, Assembler::sllx_op3, $reg$$reg, 0x1020 ); emit3( cbuf, Assembler::arith_op, $reg$$reg, Assembler::or_op3, $reg$$reg, 0, R_O7_enc ); %} @@ -2121,14 +2122,14 @@ encode %{ assert(Assembler::is_simm13($mem$$disp+4), "need disp and disp+4"); guarantee($mem$$index == R_G0_enc, "double index?"); // Load long with 2 instructions - emit_form3_mem_reg(cbuf, this, $primary, -1, $mem$$base, $mem$$disp, R_G0_enc, $reg$$reg+0 ); - emit_form3_mem_reg(cbuf, this, $primary, -1, $mem$$base, $mem$$disp+4, R_G0_enc, $reg$$reg+1 ); + emit_form3_mem_reg(cbuf, ra_, this, $primary, -1, $mem$$base, $mem$$disp, R_G0_enc, $reg$$reg+0 ); + emit_form3_mem_reg(cbuf, ra_, this, $primary, -1, $mem$$base, $mem$$disp+4, R_G0_enc, $reg$$reg+1 ); %} //%%% form3_mem_plus_4_reg is a hack--get rid of it enc_class form3_mem_plus_4_reg( memory mem, iRegI dst ) %{ guarantee($mem$$disp, "cannot offset a reg-reg operand by 4"); - emit_form3_mem_reg(cbuf, this, $primary, -1, $mem$$base, $mem$$disp + 4, $mem$$index, $dst$$reg); + emit_form3_mem_reg(cbuf, ra_, this, $primary, -1, $mem$$base, $mem$$disp + 4, $mem$$index, $dst$$reg); %} enc_class form3_g0_rs2_rd_move( iRegI rs2, iRegI rd ) %{ diff --git a/hotspot/src/cpu/sparc/vm/stubGenerator_sparc.cpp b/hotspot/src/cpu/sparc/vm/stubGenerator_sparc.cpp index 612ae118ee4..b9911828174 100644 --- a/hotspot/src/cpu/sparc/vm/stubGenerator_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/stubGenerator_sparc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/cpu/sparc/vm/stubRoutines_sparc.cpp b/hotspot/src/cpu/sparc/vm/stubRoutines_sparc.cpp index da9e9040683..63fb86a1509 100644 --- a/hotspot/src/cpu/sparc/vm/stubRoutines_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/stubRoutines_sparc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/cpu/sparc/vm/stubRoutines_sparc.hpp b/hotspot/src/cpu/sparc/vm/stubRoutines_sparc.hpp index 1b23479a1f9..a94f5977f9d 100644 --- a/hotspot/src/cpu/sparc/vm/stubRoutines_sparc.hpp +++ b/hotspot/src/cpu/sparc/vm/stubRoutines_sparc.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/cpu/sparc/vm/vmStructs_sparc.hpp b/hotspot/src/cpu/sparc/vm/vmStructs_sparc.hpp index 11f829385b8..56805aed838 100644 --- a/hotspot/src/cpu/sparc/vm/vmStructs_sparc.hpp +++ b/hotspot/src/cpu/sparc/vm/vmStructs_sparc.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 diff --git a/hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp b/hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp index 84aff34fafd..bae7b3510cd 100644 --- a/hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/cpu/sparc/vm/vm_version_sparc.hpp b/hotspot/src/cpu/sparc/vm/vm_version_sparc.hpp index c8faa7836b6..b8d63f4f862 100644 --- a/hotspot/src/cpu/sparc/vm/vm_version_sparc.hpp +++ b/hotspot/src/cpu/sparc/vm/vm_version_sparc.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/cpu/x86/vm/bytecodeInterpreter_x86.cpp b/hotspot/src/cpu/x86/vm/bytecodeInterpreter_x86.cpp index 56129cc2d2e..3088400c801 100644 --- a/hotspot/src/cpu/x86/vm/bytecodeInterpreter_x86.cpp +++ b/hotspot/src/cpu/x86/vm/bytecodeInterpreter_x86.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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 diff --git a/hotspot/src/cpu/x86/vm/c1_CodeStubs_x86.cpp b/hotspot/src/cpu/x86/vm/c1_CodeStubs_x86.cpp index 1e0c3d9c55c..a6e7731bdd5 100644 --- a/hotspot/src/cpu/x86/vm/c1_CodeStubs_x86.cpp +++ b/hotspot/src/cpu/x86/vm/c1_CodeStubs_x86.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 diff --git a/hotspot/src/cpu/x86/vm/c1_FrameMap_x86.cpp b/hotspot/src/cpu/x86/vm/c1_FrameMap_x86.cpp index 8ef1bea5d83..f75eca72868 100644 --- a/hotspot/src/cpu/x86/vm/c1_FrameMap_x86.cpp +++ b/hotspot/src/cpu/x86/vm/c1_FrameMap_x86.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 diff --git a/hotspot/src/cpu/x86/vm/c1_FrameMap_x86.hpp b/hotspot/src/cpu/x86/vm/c1_FrameMap_x86.hpp index 2d1b5f1f3c7..ddd358cc5d9 100644 --- a/hotspot/src/cpu/x86/vm/c1_FrameMap_x86.hpp +++ b/hotspot/src/cpu/x86/vm/c1_FrameMap_x86.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 diff --git a/hotspot/src/cpu/x86/vm/c1_LinearScan_x86.cpp b/hotspot/src/cpu/x86/vm/c1_LinearScan_x86.cpp index baecb9df93d..12b01bfab42 100644 --- a/hotspot/src/cpu/x86/vm/c1_LinearScan_x86.cpp +++ b/hotspot/src/cpu/x86/vm/c1_LinearScan_x86.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 diff --git a/hotspot/src/cpu/x86/vm/c1_MacroAssembler_x86.cpp b/hotspot/src/cpu/x86/vm/c1_MacroAssembler_x86.cpp index 805fe5a48ca..0aeb8d7979a 100644 --- a/hotspot/src/cpu/x86/vm/c1_MacroAssembler_x86.cpp +++ b/hotspot/src/cpu/x86/vm/c1_MacroAssembler_x86.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 diff --git a/hotspot/src/cpu/x86/vm/c1_Runtime1_x86.cpp b/hotspot/src/cpu/x86/vm/c1_Runtime1_x86.cpp index 2f562bbd318..fd6302d21be 100644 --- a/hotspot/src/cpu/x86/vm/c1_Runtime1_x86.cpp +++ b/hotspot/src/cpu/x86/vm/c1_Runtime1_x86.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 diff --git a/hotspot/src/cpu/x86/vm/c1_globals_x86.hpp b/hotspot/src/cpu/x86/vm/c1_globals_x86.hpp index 13f3df82c29..2e99c41949f 100644 --- a/hotspot/src/cpu/x86/vm/c1_globals_x86.hpp +++ b/hotspot/src/cpu/x86/vm/c1_globals_x86.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 diff --git a/hotspot/src/cpu/x86/vm/c2_globals_x86.hpp b/hotspot/src/cpu/x86/vm/c2_globals_x86.hpp index a45bd9624e5..935c6a21f34 100644 --- a/hotspot/src/cpu/x86/vm/c2_globals_x86.hpp +++ b/hotspot/src/cpu/x86/vm/c2_globals_x86.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 diff --git a/hotspot/src/cpu/x86/vm/frame_x86.cpp b/hotspot/src/cpu/x86/vm/frame_x86.cpp index f0de7a44e76..4e83863a9f9 100644 --- a/hotspot/src/cpu/x86/vm/frame_x86.cpp +++ b/hotspot/src/cpu/x86/vm/frame_x86.cpp @@ -94,13 +94,6 @@ bool frame::safe_for_sender(JavaThread *thread) { // other generic buffer blobs are more problematic so we just assume they are // ok. adapter blobs never have a frame complete and are never ok. - // check for a valid frame_size, otherwise we are unlikely to get a valid sender_pc - - if (!Interpreter::contains(_pc) && _cb->frame_size() <= 0) { - //assert(0, "Invalid frame_size"); - return false; - } - if (!_cb->is_frame_complete_at(_pc)) { if (_cb->is_nmethod() || _cb->is_adapter_blob() || _cb->is_runtime_stub()) { return false; @@ -144,6 +137,11 @@ bool frame::safe_for_sender(JavaThread *thread) { // must be some sort of compiled/runtime frame // fp does not have to be safe (although it could be check for c1?) + // check for a valid frame_size, otherwise we are unlikely to get a valid sender_pc + if (_cb->frame_size() <= 0) { + return false; + } + sender_sp = _unextended_sp + _cb->frame_size(); // On Intel the return_address is always the word on the stack sender_pc = (address) *(sender_sp-1); diff --git a/hotspot/src/cpu/x86/vm/frame_x86.hpp b/hotspot/src/cpu/x86/vm/frame_x86.hpp index 0033077dde4..8c6a72c2e97 100644 --- a/hotspot/src/cpu/x86/vm/frame_x86.hpp +++ b/hotspot/src/cpu/x86/vm/frame_x86.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/cpu/x86/vm/frame_x86.inline.hpp b/hotspot/src/cpu/x86/vm/frame_x86.inline.hpp index 3c5c225c399..bb161c9d4ea 100644 --- a/hotspot/src/cpu/x86/vm/frame_x86.inline.hpp +++ b/hotspot/src/cpu/x86/vm/frame_x86.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/cpu/x86/vm/globalDefinitions_x86.hpp b/hotspot/src/cpu/x86/vm/globalDefinitions_x86.hpp index 0771794ff99..cfe52751d6b 100644 --- a/hotspot/src/cpu/x86/vm/globalDefinitions_x86.hpp +++ b/hotspot/src/cpu/x86/vm/globalDefinitions_x86.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 diff --git a/hotspot/src/cpu/x86/vm/register_definitions_x86.cpp b/hotspot/src/cpu/x86/vm/register_definitions_x86.cpp index f8a9407933b..8ed435dc3eb 100644 --- a/hotspot/src/cpu/x86/vm/register_definitions_x86.cpp +++ b/hotspot/src/cpu/x86/vm/register_definitions_x86.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 diff --git a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_32.cpp b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_32.cpp index 003e70b8066..719644cde05 100644 --- a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_32.cpp +++ b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_32.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 diff --git a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp index fbd344c57b5..6960f6de082 100644 --- a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp +++ b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 diff --git a/hotspot/src/cpu/x86/vm/templateInterpreter_x86.hpp b/hotspot/src/cpu/x86/vm/templateInterpreter_x86.hpp index ed2cef16e58..071defbab0d 100644 --- a/hotspot/src/cpu/x86/vm/templateInterpreter_x86.hpp +++ b/hotspot/src/cpu/x86/vm/templateInterpreter_x86.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/cpu/x86/vm/vmStructs_x86.hpp b/hotspot/src/cpu/x86/vm/vmStructs_x86.hpp index 847d08ed207..89cbc3b15a5 100644 --- a/hotspot/src/cpu/x86/vm/vmStructs_x86.hpp +++ b/hotspot/src/cpu/x86/vm/vmStructs_x86.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 diff --git a/hotspot/src/cpu/x86/vm/vtableStubs_x86_32.cpp b/hotspot/src/cpu/x86/vm/vtableStubs_x86_32.cpp index 3e7b4243510..73c2f3ca20d 100644 --- a/hotspot/src/cpu/x86/vm/vtableStubs_x86_32.cpp +++ b/hotspot/src/cpu/x86/vm/vtableStubs_x86_32.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/cpu/x86/vm/vtableStubs_x86_64.cpp b/hotspot/src/cpu/x86/vm/vtableStubs_x86_64.cpp index 4fc385f9737..089b368d015 100644 --- a/hotspot/src/cpu/x86/vm/vtableStubs_x86_64.cpp +++ b/hotspot/src/cpu/x86/vm/vtableStubs_x86_64.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 diff --git a/hotspot/src/cpu/zero/vm/assembler_zero.cpp b/hotspot/src/cpu/zero/vm/assembler_zero.cpp index 5438c9209b6..4a60af98fd4 100644 --- a/hotspot/src/cpu/zero/vm/assembler_zero.cpp +++ b/hotspot/src/cpu/zero/vm/assembler_zero.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright 2007, 2008, 2009 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * diff --git a/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp b/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp index 27c9af71f17..5142870244d 100644 --- a/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp +++ b/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright 2007, 2008, 2009, 2010, 2011 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * diff --git a/hotspot/src/cpu/zero/vm/entryFrame_zero.hpp b/hotspot/src/cpu/zero/vm/entryFrame_zero.hpp index 97b185c3aab..5c6be60bab4 100644 --- a/hotspot/src/cpu/zero/vm/entryFrame_zero.hpp +++ b/hotspot/src/cpu/zero/vm/entryFrame_zero.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright 2008, 2010 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * diff --git a/hotspot/src/cpu/zero/vm/frame_zero.cpp b/hotspot/src/cpu/zero/vm/frame_zero.cpp index c8623f9aade..4be75fdc3b3 100644 --- a/hotspot/src/cpu/zero/vm/frame_zero.cpp +++ b/hotspot/src/cpu/zero/vm/frame_zero.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright 2007, 2008, 2009, 2010, 2011 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * diff --git a/hotspot/src/cpu/zero/vm/frame_zero.inline.hpp b/hotspot/src/cpu/zero/vm/frame_zero.inline.hpp index 7f6ca09978c..8c968599864 100644 --- a/hotspot/src/cpu/zero/vm/frame_zero.inline.hpp +++ b/hotspot/src/cpu/zero/vm/frame_zero.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright 2007, 2008, 2009, 2010 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * diff --git a/hotspot/src/cpu/zero/vm/globals_zero.hpp b/hotspot/src/cpu/zero/vm/globals_zero.hpp index 9a304c7f3fb..fda6a191b44 100644 --- a/hotspot/src/cpu/zero/vm/globals_zero.hpp +++ b/hotspot/src/cpu/zero/vm/globals_zero.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright 2007, 2008, 2009, 2010, 2011 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * diff --git a/hotspot/src/cpu/zero/vm/icBuffer_zero.cpp b/hotspot/src/cpu/zero/vm/icBuffer_zero.cpp index bf2849b6ecc..9a82782ab3a 100644 --- a/hotspot/src/cpu/zero/vm/icBuffer_zero.cpp +++ b/hotspot/src/cpu/zero/vm/icBuffer_zero.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright 2007 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * diff --git a/hotspot/src/cpu/zero/vm/interp_masm_zero.hpp b/hotspot/src/cpu/zero/vm/interp_masm_zero.hpp index 97a105bea80..ccba37b249f 100644 --- a/hotspot/src/cpu/zero/vm/interp_masm_zero.hpp +++ b/hotspot/src/cpu/zero/vm/interp_masm_zero.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright 2007 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * diff --git a/hotspot/src/cpu/zero/vm/interpreter_zero.cpp b/hotspot/src/cpu/zero/vm/interpreter_zero.cpp index 371d65cf9bb..7172443db8f 100644 --- a/hotspot/src/cpu/zero/vm/interpreter_zero.cpp +++ b/hotspot/src/cpu/zero/vm/interpreter_zero.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright 2007, 2008, 2009, 2010, 2011 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * diff --git a/hotspot/src/cpu/zero/vm/jni_zero.h b/hotspot/src/cpu/zero/vm/jni_zero.h index 11157f4f06a..ecf743b65e1 100644 --- a/hotspot/src/cpu/zero/vm/jni_zero.h +++ b/hotspot/src/cpu/zero/vm/jni_zero.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright 2009 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * diff --git a/hotspot/src/cpu/zero/vm/nativeInst_zero.hpp b/hotspot/src/cpu/zero/vm/nativeInst_zero.hpp index 00599206126..559bde79ab6 100644 --- a/hotspot/src/cpu/zero/vm/nativeInst_zero.hpp +++ b/hotspot/src/cpu/zero/vm/nativeInst_zero.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright 2007 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * diff --git a/hotspot/src/cpu/zero/vm/register_zero.cpp b/hotspot/src/cpu/zero/vm/register_zero.cpp index f11bf829aa6..5d695430171 100644 --- a/hotspot/src/cpu/zero/vm/register_zero.cpp +++ b/hotspot/src/cpu/zero/vm/register_zero.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright 2007 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * diff --git a/hotspot/src/cpu/zero/vm/relocInfo_zero.cpp b/hotspot/src/cpu/zero/vm/relocInfo_zero.cpp index f50190829c0..a042bccfc14 100644 --- a/hotspot/src/cpu/zero/vm/relocInfo_zero.cpp +++ b/hotspot/src/cpu/zero/vm/relocInfo_zero.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright 2007, 2009, 2010, 2011 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * diff --git a/hotspot/src/cpu/zero/vm/sharedRuntime_zero.cpp b/hotspot/src/cpu/zero/vm/sharedRuntime_zero.cpp index 2c419b14822..a9ebd9a121c 100644 --- a/hotspot/src/cpu/zero/vm/sharedRuntime_zero.cpp +++ b/hotspot/src/cpu/zero/vm/sharedRuntime_zero.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright 2007, 2008, 2009, 2010, 2011 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * diff --git a/hotspot/src/cpu/zero/vm/sharkFrame_zero.hpp b/hotspot/src/cpu/zero/vm/sharkFrame_zero.hpp index 505241b147f..ff26fbccf86 100644 --- a/hotspot/src/cpu/zero/vm/sharkFrame_zero.hpp +++ b/hotspot/src/cpu/zero/vm/sharkFrame_zero.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright 2008, 2009 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * diff --git a/hotspot/src/cpu/zero/vm/stubGenerator_zero.cpp b/hotspot/src/cpu/zero/vm/stubGenerator_zero.cpp index 1203c315879..b88df23737b 100644 --- a/hotspot/src/cpu/zero/vm/stubGenerator_zero.cpp +++ b/hotspot/src/cpu/zero/vm/stubGenerator_zero.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright 2007, 2008, 2010 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * diff --git a/hotspot/src/cpu/zero/vm/vmStructs_zero.hpp b/hotspot/src/cpu/zero/vm/vmStructs_zero.hpp index 0bbc1f40f45..72783cf341a 100644 --- a/hotspot/src/cpu/zero/vm/vmStructs_zero.hpp +++ b/hotspot/src/cpu/zero/vm/vmStructs_zero.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright 2007 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * diff --git a/hotspot/src/cpu/zero/vm/vtableStubs_zero.cpp b/hotspot/src/cpu/zero/vm/vtableStubs_zero.cpp index 67f0ea88839..4e52a4ed125 100644 --- a/hotspot/src/cpu/zero/vm/vtableStubs_zero.cpp +++ b/hotspot/src/cpu/zero/vm/vtableStubs_zero.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright 2007 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * diff --git a/hotspot/src/os/bsd/dtrace/hotspot.d b/hotspot/src/os/bsd/dtrace/hotspot.d index 0e4802b5105..996e1d782e5 100644 --- a/hotspot/src/os/bsd/dtrace/hotspot.d +++ b/hotspot/src/os/bsd/dtrace/hotspot.d @@ -47,8 +47,8 @@ provider hotspot { probe mem__pool__gc__end( char*, uintptr_t, char*, uintptr_t, uintptr_t, uintptr_t, uintptr_t, uintptr_t); - probe thread__probe__start(char*, uintptr_t, uintptr_t, uintptr_t, uintptr_t); - probe thread__probe__stop(char*, uintptr_t, uintptr_t, uintptr_t, uintptr_t); + probe thread__start(char*, uintptr_t, uintptr_t, uintptr_t, uintptr_t); + probe thread__stop(char*, uintptr_t, uintptr_t, uintptr_t, uintptr_t); probe thread__sleep__begin(long long); probe thread__sleep__end(int); probe thread__yield(); @@ -68,7 +68,7 @@ provider hotspot { probe monitor__contended__entered(uintptr_t, uintptr_t, char*, uintptr_t); probe monitor__contended__exit(uintptr_t, uintptr_t, char*, uintptr_t); probe monitor__wait(uintptr_t, uintptr_t, char*, uintptr_t, uintptr_t); - probe monitor__probe__waited(uintptr_t, uintptr_t, char*, uintptr_t); + probe monitor__waited(uintptr_t, uintptr_t, char*, uintptr_t); probe monitor__notify(uintptr_t, uintptr_t, char*, uintptr_t); probe monitor__notifyAll(uintptr_t, uintptr_t, char*, uintptr_t); diff --git a/hotspot/src/os/bsd/dtrace/jvm_dtrace.c b/hotspot/src/os/bsd/dtrace/jvm_dtrace.c index 6cdad788572..36d8b61b19f 100644 --- a/hotspot/src/os/bsd/dtrace/jvm_dtrace.c +++ b/hotspot/src/os/bsd/dtrace/jvm_dtrace.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/hotspot/src/os/posix/vm/os_posix.hpp b/hotspot/src/os/posix/vm/os_posix.hpp index 16a065acf30..406baf17237 100644 --- a/hotspot/src/os/posix/vm/os_posix.hpp +++ b/hotspot/src/os/posix/vm/os_posix.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 diff --git a/hotspot/src/os/solaris/dtrace/jvm_dtrace.c b/hotspot/src/os/solaris/dtrace/jvm_dtrace.c index 6cdad788572..36d8b61b19f 100644 --- a/hotspot/src/os/solaris/dtrace/jvm_dtrace.c +++ b/hotspot/src/os/solaris/dtrace/jvm_dtrace.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/hotspot/src/os/solaris/vm/globals_solaris.hpp b/hotspot/src/os/solaris/vm/globals_solaris.hpp index 2abbe15a7fd..ba5458803e8 100644 --- a/hotspot/src/os/solaris/vm/globals_solaris.hpp +++ b/hotspot/src/os/solaris/vm/globals_solaris.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 diff --git a/hotspot/src/os/windows/vm/decoder_windows.hpp b/hotspot/src/os/windows/vm/decoder_windows.hpp index 2555e8c9b79..731b3a3f5dc 100644 --- a/hotspot/src/os/windows/vm/decoder_windows.hpp +++ b/hotspot/src/os/windows/vm/decoder_windows.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/hotspot/src/os_cpu/bsd_x86/vm/bsd_x86_32.s b/hotspot/src/os_cpu/bsd_x86/vm/bsd_x86_32.s index 3275996f0c7..3f6958ce385 100644 --- a/hotspot/src/os_cpu/bsd_x86/vm/bsd_x86_32.s +++ b/hotspot/src/os_cpu/bsd_x86/vm/bsd_x86_32.s @@ -1,5 +1,5 @@ # -# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. +# 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 diff --git a/hotspot/src/os_cpu/bsd_x86/vm/bsd_x86_64.s b/hotspot/src/os_cpu/bsd_x86/vm/bsd_x86_64.s index 2f70fce77a3..95cea3bf2a3 100644 --- a/hotspot/src/os_cpu/bsd_x86/vm/bsd_x86_64.s +++ b/hotspot/src/os_cpu/bsd_x86/vm/bsd_x86_64.s @@ -1,5 +1,5 @@ # -# Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. +# 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 diff --git a/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp b/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp index a1d7075af55..df24bcdc594 100644 --- a/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp +++ b/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 diff --git a/hotspot/src/os_cpu/bsd_x86/vm/vmStructs_bsd_x86.hpp b/hotspot/src/os_cpu/bsd_x86/vm/vmStructs_bsd_x86.hpp index b1460eddc0c..32d0fdc66a2 100644 --- a/hotspot/src/os_cpu/bsd_x86/vm/vmStructs_bsd_x86.hpp +++ b/hotspot/src/os_cpu/bsd_x86/vm/vmStructs_bsd_x86.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 diff --git a/hotspot/src/os_cpu/bsd_zero/vm/globals_bsd_zero.hpp b/hotspot/src/os_cpu/bsd_zero/vm/globals_bsd_zero.hpp index 44f72df22cf..e7b7f55d03d 100644 --- a/hotspot/src/os_cpu/bsd_zero/vm/globals_bsd_zero.hpp +++ b/hotspot/src/os_cpu/bsd_zero/vm/globals_bsd_zero.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright 2007, 2008, 2010 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * diff --git a/hotspot/src/os_cpu/bsd_zero/vm/os_bsd_zero.cpp b/hotspot/src/os_cpu/bsd_zero/vm/os_bsd_zero.cpp index 7903217291b..c857b552689 100644 --- a/hotspot/src/os_cpu/bsd_zero/vm/os_bsd_zero.cpp +++ b/hotspot/src/os_cpu/bsd_zero/vm/os_bsd_zero.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright 2007, 2008, 2009, 2010 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * diff --git a/hotspot/src/os_cpu/bsd_zero/vm/thread_bsd_zero.hpp b/hotspot/src/os_cpu/bsd_zero/vm/thread_bsd_zero.hpp index 983aea1a2a6..7afef93eda2 100644 --- a/hotspot/src/os_cpu/bsd_zero/vm/thread_bsd_zero.hpp +++ b/hotspot/src/os_cpu/bsd_zero/vm/thread_bsd_zero.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright 2007, 2008, 2009, 2010 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * diff --git a/hotspot/src/os_cpu/bsd_zero/vm/vmStructs_bsd_zero.hpp b/hotspot/src/os_cpu/bsd_zero/vm/vmStructs_bsd_zero.hpp index 6673f448f81..48e40a8e33f 100644 --- a/hotspot/src/os_cpu/bsd_zero/vm/vmStructs_bsd_zero.hpp +++ b/hotspot/src/os_cpu/bsd_zero/vm/vmStructs_bsd_zero.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright 2007 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * diff --git a/hotspot/src/os_cpu/linux_sparc/vm/globals_linux_sparc.hpp b/hotspot/src/os_cpu/linux_sparc/vm/globals_linux_sparc.hpp index 844279e41e0..b3a215d2b83 100644 --- a/hotspot/src/os_cpu/linux_sparc/vm/globals_linux_sparc.hpp +++ b/hotspot/src/os_cpu/linux_sparc/vm/globals_linux_sparc.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 diff --git a/hotspot/src/os_cpu/linux_sparc/vm/linux_sparc.s b/hotspot/src/os_cpu/linux_sparc/vm/linux_sparc.s index d7c2ce87414..33474ecd9c0 100644 --- a/hotspot/src/os_cpu/linux_sparc/vm/linux_sparc.s +++ b/hotspot/src/os_cpu/linux_sparc/vm/linux_sparc.s @@ -1,5 +1,5 @@ # -# Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2005, 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 diff --git a/hotspot/src/os_cpu/linux_sparc/vm/os_linux_sparc.cpp b/hotspot/src/os_cpu/linux_sparc/vm/os_linux_sparc.cpp index e7879bee690..5eaab2d5259 100644 --- a/hotspot/src/os_cpu/linux_sparc/vm/os_linux_sparc.cpp +++ b/hotspot/src/os_cpu/linux_sparc/vm/os_linux_sparc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 diff --git a/hotspot/src/os_cpu/linux_sparc/vm/vmStructs_linux_sparc.hpp b/hotspot/src/os_cpu/linux_sparc/vm/vmStructs_linux_sparc.hpp index 38bc63e6496..1e9280fe36c 100644 --- a/hotspot/src/os_cpu/linux_sparc/vm/vmStructs_linux_sparc.hpp +++ b/hotspot/src/os_cpu/linux_sparc/vm/vmStructs_linux_sparc.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 diff --git a/hotspot/src/os_cpu/linux_x86/vm/globals_linux_x86.hpp b/hotspot/src/os_cpu/linux_x86/vm/globals_linux_x86.hpp index 622928aa17b..4ecaeee3354 100644 --- a/hotspot/src/os_cpu/linux_x86/vm/globals_linux_x86.hpp +++ b/hotspot/src/os_cpu/linux_x86/vm/globals_linux_x86.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 diff --git a/hotspot/src/os_cpu/linux_x86/vm/linux_x86_32.s b/hotspot/src/os_cpu/linux_x86/vm/linux_x86_32.s index 7936cbf52bd..26cfa51e162 100644 --- a/hotspot/src/os_cpu/linux_x86/vm/linux_x86_32.s +++ b/hotspot/src/os_cpu/linux_x86/vm/linux_x86_32.s @@ -1,5 +1,5 @@ # -# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. +# 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 diff --git a/hotspot/src/os_cpu/linux_x86/vm/linux_x86_64.s b/hotspot/src/os_cpu/linux_x86/vm/linux_x86_64.s index fb688e7a7b6..89d98cb5837 100644 --- a/hotspot/src/os_cpu/linux_x86/vm/linux_x86_64.s +++ b/hotspot/src/os_cpu/linux_x86/vm/linux_x86_64.s @@ -1,5 +1,5 @@ # -# Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. +# 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 diff --git a/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp b/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp index 9a7605e696b..195982529ef 100644 --- a/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp +++ b/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 diff --git a/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.hpp b/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.hpp index fbca6909bb5..1ccfad76fe7 100644 --- a/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.hpp +++ b/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 diff --git a/hotspot/src/os_cpu/linux_x86/vm/vmStructs_linux_x86.hpp b/hotspot/src/os_cpu/linux_x86/vm/vmStructs_linux_x86.hpp index 828f992d8ba..897e48aa19f 100644 --- a/hotspot/src/os_cpu/linux_x86/vm/vmStructs_linux_x86.hpp +++ b/hotspot/src/os_cpu/linux_x86/vm/vmStructs_linux_x86.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 diff --git a/hotspot/src/os_cpu/linux_zero/vm/globals_linux_zero.hpp b/hotspot/src/os_cpu/linux_zero/vm/globals_linux_zero.hpp index 4e0be5c79f3..663f0ac45c6 100644 --- a/hotspot/src/os_cpu/linux_zero/vm/globals_linux_zero.hpp +++ b/hotspot/src/os_cpu/linux_zero/vm/globals_linux_zero.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright 2007, 2008, 2010 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * diff --git a/hotspot/src/os_cpu/linux_zero/vm/os_linux_zero.cpp b/hotspot/src/os_cpu/linux_zero/vm/os_linux_zero.cpp index 2618519e2a4..f5f44e0a77b 100644 --- a/hotspot/src/os_cpu/linux_zero/vm/os_linux_zero.cpp +++ b/hotspot/src/os_cpu/linux_zero/vm/os_linux_zero.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright 2007, 2008, 2009, 2010 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * diff --git a/hotspot/src/os_cpu/linux_zero/vm/vmStructs_linux_zero.hpp b/hotspot/src/os_cpu/linux_zero/vm/vmStructs_linux_zero.hpp index 34b82a96d79..fe0cc5e10a1 100644 --- a/hotspot/src/os_cpu/linux_zero/vm/vmStructs_linux_zero.hpp +++ b/hotspot/src/os_cpu/linux_zero/vm/vmStructs_linux_zero.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright 2007 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * diff --git a/hotspot/src/os_cpu/solaris_sparc/vm/globals_solaris_sparc.hpp b/hotspot/src/os_cpu/solaris_sparc/vm/globals_solaris_sparc.hpp index e0ed6961e3a..30c955debca 100644 --- a/hotspot/src/os_cpu/solaris_sparc/vm/globals_solaris_sparc.hpp +++ b/hotspot/src/os_cpu/solaris_sparc/vm/globals_solaris_sparc.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 diff --git a/hotspot/src/os_cpu/solaris_sparc/vm/solaris_sparc.il b/hotspot/src/os_cpu/solaris_sparc/vm/solaris_sparc.il index 47398351b39..16bd6902a3e 100644 --- a/hotspot/src/os_cpu/solaris_sparc/vm/solaris_sparc.il +++ b/hotspot/src/os_cpu/solaris_sparc/vm/solaris_sparc.il @@ -1,5 +1,5 @@ // -// Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2002, 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 diff --git a/hotspot/src/os_cpu/solaris_sparc/vm/solaris_sparc.s b/hotspot/src/os_cpu/solaris_sparc/vm/solaris_sparc.s index 39aaa77f664..a0f6ddff431 100644 --- a/hotspot/src/os_cpu/solaris_sparc/vm/solaris_sparc.s +++ b/hotspot/src/os_cpu/solaris_sparc/vm/solaris_sparc.s @@ -1,5 +1,5 @@ !! -!! Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved. +!! Copyright (c) 2005, 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 diff --git a/hotspot/src/os_cpu/solaris_sparc/vm/vmStructs_solaris_sparc.hpp b/hotspot/src/os_cpu/solaris_sparc/vm/vmStructs_solaris_sparc.hpp index 40d6ae735aa..08a5fb3980a 100644 --- a/hotspot/src/os_cpu/solaris_sparc/vm/vmStructs_solaris_sparc.hpp +++ b/hotspot/src/os_cpu/solaris_sparc/vm/vmStructs_solaris_sparc.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 diff --git a/hotspot/src/os_cpu/solaris_x86/vm/globals_solaris_x86.hpp b/hotspot/src/os_cpu/solaris_x86/vm/globals_solaris_x86.hpp index c1f656b99f8..e6329c28942 100644 --- a/hotspot/src/os_cpu/solaris_x86/vm/globals_solaris_x86.hpp +++ b/hotspot/src/os_cpu/solaris_x86/vm/globals_solaris_x86.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 diff --git a/hotspot/src/os_cpu/solaris_x86/vm/solaris_x86_32.s b/hotspot/src/os_cpu/solaris_x86/vm/solaris_x86_32.s index 19e790b6013..a48294ab909 100644 --- a/hotspot/src/os_cpu/solaris_x86/vm/solaris_x86_32.s +++ b/hotspot/src/os_cpu/solaris_x86/vm/solaris_x86_32.s @@ -1,5 +1,5 @@ // -// Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. +// 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 diff --git a/hotspot/src/os_cpu/solaris_x86/vm/solaris_x86_64.s b/hotspot/src/os_cpu/solaris_x86/vm/solaris_x86_64.s index 487b569e58c..9a3e03f175c 100644 --- a/hotspot/src/os_cpu/solaris_x86/vm/solaris_x86_64.s +++ b/hotspot/src/os_cpu/solaris_x86/vm/solaris_x86_64.s @@ -1,5 +1,5 @@ / -/ Copyright (c) 2004, 2005, Oracle and/or its affiliates. All rights reserved. +/ 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 diff --git a/hotspot/src/os_cpu/solaris_x86/vm/vmStructs_solaris_x86.hpp b/hotspot/src/os_cpu/solaris_x86/vm/vmStructs_solaris_x86.hpp index 523fdc7cc42..9304bb7242e 100644 --- a/hotspot/src/os_cpu/solaris_x86/vm/vmStructs_solaris_x86.hpp +++ b/hotspot/src/os_cpu/solaris_x86/vm/vmStructs_solaris_x86.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 diff --git a/hotspot/src/os_cpu/windows_x86/vm/globals_windows_x86.hpp b/hotspot/src/os_cpu/windows_x86/vm/globals_windows_x86.hpp index 10e0aaff747..de91c32ad33 100644 --- a/hotspot/src/os_cpu/windows_x86/vm/globals_windows_x86.hpp +++ b/hotspot/src/os_cpu/windows_x86/vm/globals_windows_x86.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 diff --git a/hotspot/src/os_cpu/windows_x86/vm/os_windows_x86.cpp b/hotspot/src/os_cpu/windows_x86/vm/os_windows_x86.cpp index 09735dae0c6..6178f1988e5 100644 --- a/hotspot/src/os_cpu/windows_x86/vm/os_windows_x86.cpp +++ b/hotspot/src/os_cpu/windows_x86/vm/os_windows_x86.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 diff --git a/hotspot/src/os_cpu/windows_x86/vm/os_windows_x86.hpp b/hotspot/src/os_cpu/windows_x86/vm/os_windows_x86.hpp index 22ffeb5dc34..1ac00b10455 100644 --- a/hotspot/src/os_cpu/windows_x86/vm/os_windows_x86.hpp +++ b/hotspot/src/os_cpu/windows_x86/vm/os_windows_x86.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 diff --git a/hotspot/src/os_cpu/windows_x86/vm/vmStructs_windows_x86.hpp b/hotspot/src/os_cpu/windows_x86/vm/vmStructs_windows_x86.hpp index a392b63632c..b629e23205a 100644 --- a/hotspot/src/os_cpu/windows_x86/vm/vmStructs_windows_x86.hpp +++ b/hotspot/src/os_cpu/windows_x86/vm/vmStructs_windows_x86.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 diff --git a/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/CallSite.java b/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/CallSite.java index c4a77c02aac..c36f4cae67d 100644 --- a/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/CallSite.java +++ b/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/CallSite.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 diff --git a/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/LogParser.java b/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/LogParser.java index de80e9a1043..c24a2103eb0 100644 --- a/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/LogParser.java +++ b/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/LogParser.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 diff --git a/hotspot/src/share/tools/ProjectCreator/WinGammaPlatformVC7.java b/hotspot/src/share/tools/ProjectCreator/WinGammaPlatformVC7.java index b7a99a652db..9afeb42d422 100644 --- a/hotspot/src/share/tools/ProjectCreator/WinGammaPlatformVC7.java +++ b/hotspot/src/share/tools/ProjectCreator/WinGammaPlatformVC7.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 diff --git a/hotspot/src/share/tools/hsdis/hsdis.c b/hotspot/src/share/tools/hsdis/hsdis.c index 162e2aba3e7..248acfaf37c 100644 --- a/hotspot/src/share/tools/hsdis/hsdis.c +++ b/hotspot/src/share/tools/hsdis/hsdis.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 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 diff --git a/hotspot/src/share/vm/adlc/adlc.hpp b/hotspot/src/share/vm/adlc/adlc.hpp index 8d48ed601af..18f98884c3c 100644 --- a/hotspot/src/share/vm/adlc/adlc.hpp +++ b/hotspot/src/share/vm/adlc/adlc.hpp @@ -38,6 +38,9 @@ #include "stdarg.h" #include +/* Make sure that we have the intptr_t and uintptr_t definitions */ +#ifdef _WIN32 + #if _MSC_VER >= 1300 using namespace std; #endif @@ -46,8 +49,6 @@ using namespace std; #define strdup _strdup #endif -/* Make sure that we have the intptr_t and uintptr_t definitions */ -#ifdef _WIN32 #ifndef _INTPTR_T_DEFINED #ifdef _WIN64 typedef __int64 intptr_t; @@ -65,6 +66,7 @@ typedef unsigned int uintptr_t; #endif #define _UINTPTR_T_DEFINED #endif + #endif // _WIN32 #if defined(LINUX) || defined(_ALLBSD_SOURCE) diff --git a/hotspot/src/share/vm/adlc/adlparse.cpp b/hotspot/src/share/vm/adlc/adlparse.cpp index 8704c68da69..0d5595c6c04 100644 --- a/hotspot/src/share/vm/adlc/adlparse.cpp +++ b/hotspot/src/share/vm/adlc/adlparse.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/adlc/archDesc.cpp b/hotspot/src/share/vm/adlc/archDesc.cpp index fd60e25acb7..97b8999d4a1 100644 --- a/hotspot/src/share/vm/adlc/archDesc.cpp +++ b/hotspot/src/share/vm/adlc/archDesc.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 1997, 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 @@ -43,32 +43,6 @@ char *toUpper(const char *str) { return result; } -// Utilities to characterize effect statements -static bool is_def(int usedef) { - switch(usedef) { - case Component::DEF: - case Component::USE_DEF: return true; break; - } - return false; -} - -static bool is_use(int usedef) { - switch(usedef) { - case Component::USE: - case Component::USE_DEF: - case Component::USE_KILL: return true; break; - } - return false; -} - -static bool is_kill(int usedef) { - switch(usedef) { - case Component::KILL: - case Component::USE_KILL: return true; break; - } - return false; -} - //---------------------------ChainList Methods------------------------------- ChainList::ChainList() { } diff --git a/hotspot/src/share/vm/adlc/dfa.cpp b/hotspot/src/share/vm/adlc/dfa.cpp index 6b15911a067..80ef1af3602 100644 --- a/hotspot/src/share/vm/adlc/dfa.cpp +++ b/hotspot/src/share/vm/adlc/dfa.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/adlc/dict2.cpp b/hotspot/src/share/vm/adlc/dict2.cpp index 24d7fcba023..f341a2b67b0 100644 --- a/hotspot/src/share/vm/adlc/dict2.cpp +++ b/hotspot/src/share/vm/adlc/dict2.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/hotspot/src/share/vm/adlc/formssel.cpp b/hotspot/src/share/vm/adlc/formssel.cpp index cfa9f5b6222..01aedd36a70 100644 --- a/hotspot/src/share/vm/adlc/formssel.cpp +++ b/hotspot/src/share/vm/adlc/formssel.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/hotspot/src/share/vm/adlc/formssel.hpp b/hotspot/src/share/vm/adlc/formssel.hpp index 3bc22b8e269..5f7c970e228 100644 --- a/hotspot/src/share/vm/adlc/formssel.hpp +++ b/hotspot/src/share/vm/adlc/formssel.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/hotspot/src/share/vm/adlc/main.cpp b/hotspot/src/share/vm/adlc/main.cpp index b0035cbe7ef..3ca5e61c6b4 100644 --- a/hotspot/src/share/vm/adlc/main.cpp +++ b/hotspot/src/share/vm/adlc/main.cpp @@ -29,7 +29,6 @@ static void usage(ArchDesc& AD); // Print usage message and exit static char *strip_ext(char *fname); // Strip off name extension static char *base_plus_suffix(const char* base, const char *suffix);// New concatenated string -static char *prefix_plus_base_plus_suffix(const char* prefix, const char* base, const char *suffix);// New concatenated string static int get_legal_text(FileBuff &fbuf, char **legal_text); // Get pointer to legal text ArchDesc* globalAD = NULL; // global reference to Architecture Description object diff --git a/hotspot/src/share/vm/adlc/output_c.cpp b/hotspot/src/share/vm/adlc/output_c.cpp index b8978591355..0d92a23119e 100644 --- a/hotspot/src/share/vm/adlc/output_c.cpp +++ b/hotspot/src/share/vm/adlc/output_c.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,23 +35,6 @@ static bool is_def(int usedef) { return false; } -static bool is_use(int usedef) { - switch(usedef) { - case Component::USE: - case Component::USE_DEF: - case Component::USE_KILL: return true; break; - } - return false; -} - -static bool is_kill(int usedef) { - switch(usedef) { - case Component::KILL: - case Component::USE_KILL: return true; break; - } - return false; -} - // Define an array containing the machine register names, strings. static void defineRegNames(FILE *fp, RegisterForm *registers) { if (registers) { diff --git a/hotspot/src/share/vm/adlc/output_h.cpp b/hotspot/src/share/vm/adlc/output_h.cpp index 0b01d06dc31..56ba9a582c2 100644 --- a/hotspot/src/share/vm/adlc/output_h.cpp +++ b/hotspot/src/share/vm/adlc/output_h.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/hotspot/src/share/vm/asm/assembler.cpp b/hotspot/src/share/vm/asm/assembler.cpp index ae3034bc969..0eadb5dc273 100644 --- a/hotspot/src/share/vm/asm/assembler.cpp +++ b/hotspot/src/share/vm/asm/assembler.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/asm/assembler.hpp b/hotspot/src/share/vm/asm/assembler.hpp index 8a9e2758a58..eb21a3d1503 100644 --- a/hotspot/src/share/vm/asm/assembler.hpp +++ b/hotspot/src/share/vm/asm/assembler.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/asm/codeBuffer.cpp b/hotspot/src/share/vm/asm/codeBuffer.cpp index f885c415332..7e585990091 100644 --- a/hotspot/src/share/vm/asm/codeBuffer.cpp +++ b/hotspot/src/share/vm/asm/codeBuffer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/asm/macroAssembler.hpp b/hotspot/src/share/vm/asm/macroAssembler.hpp index 96c6b01dc34..3a729d41dbf 100644 --- a/hotspot/src/share/vm/asm/macroAssembler.hpp +++ b/hotspot/src/share/vm/asm/macroAssembler.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/hotspot/src/share/vm/asm/macroAssembler.inline.hpp b/hotspot/src/share/vm/asm/macroAssembler.inline.hpp index e61fc37d96e..7fa323749d4 100644 --- a/hotspot/src/share/vm/asm/macroAssembler.inline.hpp +++ b/hotspot/src/share/vm/asm/macroAssembler.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/hotspot/src/share/vm/c1/c1_Canonicalizer.cpp b/hotspot/src/share/vm/c1/c1_Canonicalizer.cpp index f98edc6f563..932bfb30b95 100644 --- a/hotspot/src/share/vm/c1/c1_Canonicalizer.cpp +++ b/hotspot/src/share/vm/c1/c1_Canonicalizer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 diff --git a/hotspot/src/share/vm/c1/c1_Canonicalizer.hpp b/hotspot/src/share/vm/c1/c1_Canonicalizer.hpp index 43ce4a41c14..c1191830ed0 100644 --- a/hotspot/src/share/vm/c1/c1_Canonicalizer.hpp +++ b/hotspot/src/share/vm/c1/c1_Canonicalizer.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 diff --git a/hotspot/src/share/vm/c1/c1_CodeStubs.hpp b/hotspot/src/share/vm/c1/c1_CodeStubs.hpp index 5f4a04c5b6c..d3c5a0d8bbb 100644 --- a/hotspot/src/share/vm/c1/c1_CodeStubs.hpp +++ b/hotspot/src/share/vm/c1/c1_CodeStubs.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 diff --git a/hotspot/src/share/vm/c1/c1_Compilation.cpp b/hotspot/src/share/vm/c1/c1_Compilation.cpp index 574fda19401..404c4e336f3 100644 --- a/hotspot/src/share/vm/c1/c1_Compilation.cpp +++ b/hotspot/src/share/vm/c1/c1_Compilation.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 diff --git a/hotspot/src/share/vm/c1/c1_Compilation.hpp b/hotspot/src/share/vm/c1/c1_Compilation.hpp index 679ff609a84..8953d527d1d 100644 --- a/hotspot/src/share/vm/c1/c1_Compilation.hpp +++ b/hotspot/src/share/vm/c1/c1_Compilation.hpp @@ -259,6 +259,9 @@ class Compilation: public StackObj { } ciKlass* cha_exact_type(ciType* type); + + // Dump inlining replay data to the stream. + void dump_inline_data(outputStream* out) { /* do nothing now */ } }; diff --git a/hotspot/src/share/vm/c1/c1_Compiler.cpp b/hotspot/src/share/vm/c1/c1_Compiler.cpp index 0fb723c8a95..f673b236f19 100644 --- a/hotspot/src/share/vm/c1/c1_Compiler.cpp +++ b/hotspot/src/share/vm/c1/c1_Compiler.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, 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 @@ -43,7 +43,8 @@ #include "runtime/sharedRuntime.hpp" -Compiler::Compiler () {} +Compiler::Compiler() : AbstractCompiler(c1) { +} void Compiler::init_c1_runtime() { BufferBlob* buffer_blob = CompilerThread::current()->get_buffer_blob(); diff --git a/hotspot/src/share/vm/c1/c1_Compiler.hpp b/hotspot/src/share/vm/c1/c1_Compiler.hpp index fe95c8cd780..cae2f6122a2 100644 --- a/hotspot/src/share/vm/c1/c1_Compiler.hpp +++ b/hotspot/src/share/vm/c1/c1_Compiler.hpp @@ -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 @@ -42,8 +42,6 @@ class Compiler: public AbstractCompiler { // Name of this compiler virtual const char* name() { return "C1"; } - virtual bool is_c1() { return true; }; - // Missing feature tests virtual bool supports_native() { return true; } virtual bool supports_osr () { return true; } diff --git a/hotspot/src/share/vm/c1/c1_FrameMap.cpp b/hotspot/src/share/vm/c1/c1_FrameMap.cpp index f5eef6f0b3b..455cfe278ee 100644 --- a/hotspot/src/share/vm/c1/c1_FrameMap.cpp +++ b/hotspot/src/share/vm/c1/c1_FrameMap.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 diff --git a/hotspot/src/share/vm/c1/c1_FrameMap.hpp b/hotspot/src/share/vm/c1/c1_FrameMap.hpp index 98bb86f8f74..052621e8d66 100644 --- a/hotspot/src/share/vm/c1/c1_FrameMap.hpp +++ b/hotspot/src/share/vm/c1/c1_FrameMap.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 diff --git a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp index 1bfd4bad45d..8d7d4e36d2a 100644 --- a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp +++ b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp @@ -4338,11 +4338,15 @@ void GraphBuilder::print_stats() { #endif // PRODUCT void GraphBuilder::profile_call(ciMethod* callee, Value recv, ciKlass* known_holder, Values* obj_args, bool inlined) { - // A default method's holder is an interface - if (known_holder != NULL && known_holder->is_interface()) { - assert(known_holder->is_instance_klass() && ((ciInstanceKlass*)known_holder)->has_default_methods(), "should be default method"); - known_holder = NULL; + assert(known_holder == NULL || (known_holder->is_instance_klass() && + (!known_holder->is_interface() || + ((ciInstanceKlass*)known_holder)->has_default_methods())), "should be default method"); + if (known_holder != NULL) { + if (known_holder->exact_klass() == NULL) { + known_holder = compilation()->cha_exact_type(known_holder); + } } + append(new ProfileCall(method(), bci(), callee, recv, known_holder, obj_args, inlined)); } diff --git a/hotspot/src/share/vm/c1/c1_GraphBuilder.hpp b/hotspot/src/share/vm/c1/c1_GraphBuilder.hpp index ce83cb73fe2..c783878efa1 100644 --- a/hotspot/src/share/vm/c1/c1_GraphBuilder.hpp +++ b/hotspot/src/share/vm/c1/c1_GraphBuilder.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 diff --git a/hotspot/src/share/vm/c1/c1_IR.cpp b/hotspot/src/share/vm/c1/c1_IR.cpp index 13a7f790f6f..c377e56ecef 100644 --- a/hotspot/src/share/vm/c1/c1_IR.cpp +++ b/hotspot/src/share/vm/c1/c1_IR.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 diff --git a/hotspot/src/share/vm/c1/c1_IR.hpp b/hotspot/src/share/vm/c1/c1_IR.hpp index bc57300c1f0..ba1abee0d01 100644 --- a/hotspot/src/share/vm/c1/c1_IR.hpp +++ b/hotspot/src/share/vm/c1/c1_IR.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 diff --git a/hotspot/src/share/vm/c1/c1_Instruction.cpp b/hotspot/src/share/vm/c1/c1_Instruction.cpp index e5829611e66..99d00bdec27 100644 --- a/hotspot/src/share/vm/c1/c1_Instruction.cpp +++ b/hotspot/src/share/vm/c1/c1_Instruction.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 diff --git a/hotspot/src/share/vm/c1/c1_InstructionPrinter.hpp b/hotspot/src/share/vm/c1/c1_InstructionPrinter.hpp index 2ad20d3e65a..a3a91033d70 100644 --- a/hotspot/src/share/vm/c1/c1_InstructionPrinter.hpp +++ b/hotspot/src/share/vm/c1/c1_InstructionPrinter.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 diff --git a/hotspot/src/share/vm/c1/c1_LIRAssembler.cpp b/hotspot/src/share/vm/c1/c1_LIRAssembler.cpp index 9ae527054fe..5a49c0d2da7 100644 --- a/hotspot/src/share/vm/c1/c1_LIRAssembler.cpp +++ b/hotspot/src/share/vm/c1/c1_LIRAssembler.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -858,9 +858,7 @@ void LIR_Assembler::move_op(LIR_Opr src, LIR_Opr dest, BasicType type, LIR_Patch void LIR_Assembler::verify_oop_map(CodeEmitInfo* info) { #ifndef PRODUCT - if (VerifyOopMaps || VerifyOops) { - bool v = VerifyOops; - VerifyOops = true; + if (VerifyOops) { OopMapStream s(info->oop_map()); while (!s.is_done()) { OopMapValue v = s.current(); @@ -883,7 +881,6 @@ void LIR_Assembler::verify_oop_map(CodeEmitInfo* info) { s.next(); } - VerifyOops = v; } #endif } diff --git a/hotspot/src/share/vm/c1/c1_LinearScan.cpp b/hotspot/src/share/vm/c1/c1_LinearScan.cpp index 52dff2642c1..089058aa71f 100644 --- a/hotspot/src/share/vm/c1/c1_LinearScan.cpp +++ b/hotspot/src/share/vm/c1/c1_LinearScan.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 diff --git a/hotspot/src/share/vm/c1/c1_Optimizer.cpp b/hotspot/src/share/vm/c1/c1_Optimizer.cpp index 90667b46f39..f366462f60c 100644 --- a/hotspot/src/share/vm/c1/c1_Optimizer.cpp +++ b/hotspot/src/share/vm/c1/c1_Optimizer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 diff --git a/hotspot/src/share/vm/c1/c1_RangeCheckElimination.cpp b/hotspot/src/share/vm/c1/c1_RangeCheckElimination.cpp index 12cdce62fee..599cedb99d0 100644 --- a/hotspot/src/share/vm/c1/c1_RangeCheckElimination.cpp +++ b/hotspot/src/share/vm/c1/c1_RangeCheckElimination.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/hotspot/src/share/vm/c1/c1_RangeCheckElimination.hpp b/hotspot/src/share/vm/c1/c1_RangeCheckElimination.hpp index b022a81374b..f7b68af9862 100644 --- a/hotspot/src/share/vm/c1/c1_RangeCheckElimination.hpp +++ b/hotspot/src/share/vm/c1/c1_RangeCheckElimination.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/hotspot/src/share/vm/c1/c1_Runtime1.hpp b/hotspot/src/share/vm/c1/c1_Runtime1.hpp index e41f2f188dc..276ca44ffbe 100644 --- a/hotspot/src/share/vm/c1/c1_Runtime1.hpp +++ b/hotspot/src/share/vm/c1/c1_Runtime1.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 diff --git a/hotspot/src/share/vm/c1/c1_ValueMap.cpp b/hotspot/src/share/vm/c1/c1_ValueMap.cpp index 370afe46b93..fb52819facc 100644 --- a/hotspot/src/share/vm/c1/c1_ValueMap.cpp +++ b/hotspot/src/share/vm/c1/c1_ValueMap.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 diff --git a/hotspot/src/share/vm/c1/c1_ValueMap.hpp b/hotspot/src/share/vm/c1/c1_ValueMap.hpp index 1404aa0b8a8..e394118b1ce 100644 --- a/hotspot/src/share/vm/c1/c1_ValueMap.hpp +++ b/hotspot/src/share/vm/c1/c1_ValueMap.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 diff --git a/hotspot/src/share/vm/c1/c1_globals.cpp b/hotspot/src/share/vm/c1/c1_globals.cpp index 553b9aa4322..93e641ab698 100644 --- a/hotspot/src/share/vm/c1/c1_globals.cpp +++ b/hotspot/src/share/vm/c1/c1_globals.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 diff --git a/hotspot/src/share/vm/c1/c1_globals.hpp b/hotspot/src/share/vm/c1/c1_globals.hpp index c7136909c40..66476716d1c 100644 --- a/hotspot/src/share/vm/c1/c1_globals.hpp +++ b/hotspot/src/share/vm/c1/c1_globals.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -269,9 +269,6 @@ develop(bool, PrintNotLoaded, false, \ "Prints where classes are not loaded during code generation") \ \ - notproduct(bool, VerifyOopMaps, false, \ - "Adds oopmap verification code to the generated code") \ - \ develop(bool, PrintLIR, false, \ "print low-level IR") \ \ diff --git a/hotspot/src/share/vm/ci/bcEscapeAnalyzer.cpp b/hotspot/src/share/vm/ci/bcEscapeAnalyzer.cpp index e2fca4845b1..24b2830ed83 100644 --- a/hotspot/src/share/vm/ci/bcEscapeAnalyzer.cpp +++ b/hotspot/src/share/vm/ci/bcEscapeAnalyzer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 diff --git a/hotspot/src/share/vm/ci/bcEscapeAnalyzer.hpp b/hotspot/src/share/vm/ci/bcEscapeAnalyzer.hpp index 3c701b6a4e8..74a0d3106b7 100644 --- a/hotspot/src/share/vm/ci/bcEscapeAnalyzer.hpp +++ b/hotspot/src/share/vm/ci/bcEscapeAnalyzer.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 diff --git a/hotspot/src/share/vm/ci/ciArray.cpp b/hotspot/src/share/vm/ci/ciArray.cpp index fdcc63a0dec..56f57b360dd 100644 --- a/hotspot/src/share/vm/ci/ciArray.cpp +++ b/hotspot/src/share/vm/ci/ciArray.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 diff --git a/hotspot/src/share/vm/ci/ciArray.hpp b/hotspot/src/share/vm/ci/ciArray.hpp index c5c86265d61..d5ff40ba695 100644 --- a/hotspot/src/share/vm/ci/ciArray.hpp +++ b/hotspot/src/share/vm/ci/ciArray.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 diff --git a/hotspot/src/share/vm/ci/ciClassList.hpp b/hotspot/src/share/vm/ci/ciClassList.hpp index c3131f5ee67..ee82685a4df 100644 --- a/hotspot/src/share/vm/ci/ciClassList.hpp +++ b/hotspot/src/share/vm/ci/ciClassList.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 diff --git a/hotspot/src/share/vm/ci/ciConstant.hpp b/hotspot/src/share/vm/ci/ciConstant.hpp index 7a72a7de1e5..5af058f4e9b 100644 --- a/hotspot/src/share/vm/ci/ciConstant.hpp +++ b/hotspot/src/share/vm/ci/ciConstant.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 diff --git a/hotspot/src/share/vm/ci/ciEnv.cpp b/hotspot/src/share/vm/ci/ciEnv.cpp index 9cc86db9052..dcb3472802c 100644 --- a/hotspot/src/share/vm/ci/ciEnv.cpp +++ b/hotspot/src/share/vm/ci/ciEnv.cpp @@ -1147,6 +1147,33 @@ ciInstance* ciEnv::unloaded_ciinstance() { // Don't change thread state and acquire any locks. // Safe to call from VM error reporter. + +void ciEnv::dump_compile_data(outputStream* out) { + CompileTask* task = this->task(); + Method* method = task->method(); + int entry_bci = task->osr_bci(); + int comp_level = task->comp_level(); + out->print("compile %s %s %s %d %d", + method->klass_name()->as_quoted_ascii(), + method->name()->as_quoted_ascii(), + method->signature()->as_quoted_ascii(), + entry_bci, comp_level); + if (compiler_data() != NULL) { + if (is_c2_compile(comp_level)) { // C2 or Shark +#ifdef COMPILER2 + // Dump C2 inlining data. + ((Compile*)compiler_data())->dump_inline_data(out); +#endif + } else if (is_c1_compile(comp_level)) { // C1 +#ifdef COMPILER1 + // Dump C1 inlining data. + ((Compilation*)compiler_data())->dump_inline_data(out); +#endif + } + } + out->cr(); +} + void ciEnv::dump_replay_data_unsafe(outputStream* out) { ResourceMark rm; #if INCLUDE_JVMTI @@ -1160,16 +1187,7 @@ void ciEnv::dump_replay_data_unsafe(outputStream* out) { for (int i = 0; i < objects->length(); i++) { objects->at(i)->dump_replay_data(out); } - CompileTask* task = this->task(); - Method* method = task->method(); - int entry_bci = task->osr_bci(); - int comp_level = task->comp_level(); - // Klass holder = method->method_holder(); - out->print_cr("compile %s %s %s %d %d", - method->klass_name()->as_quoted_ascii(), - method->name()->as_quoted_ascii(), - method->signature()->as_quoted_ascii(), - entry_bci, comp_level); + dump_compile_data(out); out->flush(); } @@ -1179,3 +1197,45 @@ void ciEnv::dump_replay_data(outputStream* out) { dump_replay_data_unsafe(out); ) } + +void ciEnv::dump_replay_data(int compile_id) { + static char buffer[O_BUFLEN]; + int ret = jio_snprintf(buffer, O_BUFLEN, "replay_pid%p_compid%d.log", os::current_process_id(), compile_id); + if (ret > 0) { + int fd = open(buffer, O_RDWR | O_CREAT | O_TRUNC, 0666); + if (fd != -1) { + FILE* replay_data_file = os::open(fd, "w"); + if (replay_data_file != NULL) { + fileStream replay_data_stream(replay_data_file, /*need_close=*/true); + dump_replay_data(&replay_data_stream); + tty->print("# Compiler replay data is saved as: "); + tty->print_cr(buffer); + } else { + tty->print_cr("# Can't open file to dump replay data."); + } + } + } +} + +void ciEnv::dump_inline_data(int compile_id) { + static char buffer[O_BUFLEN]; + int ret = jio_snprintf(buffer, O_BUFLEN, "inline_pid%p_compid%d.log", os::current_process_id(), compile_id); + if (ret > 0) { + int fd = open(buffer, O_RDWR | O_CREAT | O_TRUNC, 0666); + if (fd != -1) { + FILE* inline_data_file = os::open(fd, "w"); + if (inline_data_file != NULL) { + fileStream replay_data_stream(inline_data_file, /*need_close=*/true); + GUARDED_VM_ENTRY( + MutexLocker ml(Compile_lock); + dump_compile_data(&replay_data_stream); + ) + replay_data_stream.flush(); + tty->print("# Compiler inline data is saved as: "); + tty->print_cr(buffer); + } else { + tty->print_cr("# Can't open file to dump inline data."); + } + } + } +} diff --git a/hotspot/src/share/vm/ci/ciEnv.hpp b/hotspot/src/share/vm/ci/ciEnv.hpp index b235f3b148b..5a0bd1f1352 100644 --- a/hotspot/src/share/vm/ci/ciEnv.hpp +++ b/hotspot/src/share/vm/ci/ciEnv.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -451,8 +451,11 @@ public: void metadata_do(void f(Metadata*)) { _factory->metadata_do(f); } // Dump the compilation replay data for the ciEnv to the stream. + void dump_replay_data(int compile_id); + void dump_inline_data(int compile_id); void dump_replay_data(outputStream* out); void dump_replay_data_unsafe(outputStream* out); + void dump_compile_data(outputStream* out); }; #endif // SHARE_VM_CI_CIENV_HPP diff --git a/hotspot/src/share/vm/ci/ciFlags.hpp b/hotspot/src/share/vm/ci/ciFlags.hpp index 87e19466f27..60d5632f4bb 100644 --- a/hotspot/src/share/vm/ci/ciFlags.hpp +++ b/hotspot/src/share/vm/ci/ciFlags.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 diff --git a/hotspot/src/share/vm/ci/ciInstance.cpp b/hotspot/src/share/vm/ci/ciInstance.cpp index 8b48b1b3706..f276a53fb5d 100644 --- a/hotspot/src/share/vm/ci/ciInstance.cpp +++ b/hotspot/src/share/vm/ci/ciInstance.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 diff --git a/hotspot/src/share/vm/ci/ciInstanceKlass.hpp b/hotspot/src/share/vm/ci/ciInstanceKlass.hpp index 34eb84ccfeb..41c42935a6a 100644 --- a/hotspot/src/share/vm/ci/ciInstanceKlass.hpp +++ b/hotspot/src/share/vm/ci/ciInstanceKlass.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 diff --git a/hotspot/src/share/vm/ci/ciKlass.cpp b/hotspot/src/share/vm/ci/ciKlass.cpp index 2a4a25acded..0cd20e5b904 100644 --- a/hotspot/src/share/vm/ci/ciKlass.cpp +++ b/hotspot/src/share/vm/ci/ciKlass.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 diff --git a/hotspot/src/share/vm/ci/ciKlass.hpp b/hotspot/src/share/vm/ci/ciKlass.hpp index 7e03c1ede61..8e6574b22fd 100644 --- a/hotspot/src/share/vm/ci/ciKlass.hpp +++ b/hotspot/src/share/vm/ci/ciKlass.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 diff --git a/hotspot/src/share/vm/ci/ciMethod.cpp b/hotspot/src/share/vm/ci/ciMethod.cpp index dd411642ad2..923331edee3 100644 --- a/hotspot/src/share/vm/ci/ciMethod.cpp +++ b/hotspot/src/share/vm/ci/ciMethod.cpp @@ -1357,15 +1357,21 @@ ciMethodBlocks *ciMethod::get_method_blocks() { #undef FETCH_FLAG_FROM_VM +void ciMethod::dump_name_as_ascii(outputStream* st) { + Method* method = get_Method(); + st->print("%s %s %s", + method->klass_name()->as_quoted_ascii(), + method->name()->as_quoted_ascii(), + method->signature()->as_quoted_ascii()); +} + void ciMethod::dump_replay_data(outputStream* st) { ResourceMark rm; Method* method = get_Method(); MethodCounters* mcs = method->method_counters(); - Klass* holder = method->method_holder(); - st->print_cr("ciMethod %s %s %s %d %d %d %d %d", - holder->name()->as_quoted_ascii(), - method->name()->as_quoted_ascii(), - method->signature()->as_quoted_ascii(), + st->print("ciMethod "); + dump_name_as_ascii(st); + st->print_cr(" %d %d %d %d %d", mcs == NULL ? 0 : mcs->invocation_counter()->raw_counter(), mcs == NULL ? 0 : mcs->backedge_counter()->raw_counter(), interpreter_invocation_count(), diff --git a/hotspot/src/share/vm/ci/ciMethod.hpp b/hotspot/src/share/vm/ci/ciMethod.hpp index 604babb00dd..d7ddba87b8e 100644 --- a/hotspot/src/share/vm/ci/ciMethod.hpp +++ b/hotspot/src/share/vm/ci/ciMethod.hpp @@ -310,10 +310,13 @@ class ciMethod : public ciMetadata { bool is_accessor () const; bool is_initializer () const; bool can_be_statically_bound() const { return _can_be_statically_bound; } - void dump_replay_data(outputStream* st); bool is_boxing_method() const; bool is_unboxing_method() const; + // Replay data methods + void dump_name_as_ascii(outputStream* st); + void dump_replay_data(outputStream* st); + // Print the bytecodes of this method. void print_codes_on(outputStream* st); void print_codes() { diff --git a/hotspot/src/share/vm/ci/ciMethodData.cpp b/hotspot/src/share/vm/ci/ciMethodData.cpp index e8b6ee6af5e..025146885db 100644 --- a/hotspot/src/share/vm/ci/ciMethodData.cpp +++ b/hotspot/src/share/vm/ci/ciMethodData.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 diff --git a/hotspot/src/share/vm/ci/ciMethodData.hpp b/hotspot/src/share/vm/ci/ciMethodData.hpp index 0eeb510e348..f1a7f2634e4 100644 --- a/hotspot/src/share/vm/ci/ciMethodData.hpp +++ b/hotspot/src/share/vm/ci/ciMethodData.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 diff --git a/hotspot/src/share/vm/ci/ciObjArrayKlass.cpp b/hotspot/src/share/vm/ci/ciObjArrayKlass.cpp index 91f2ebc42a0..2b035c2af0f 100644 --- a/hotspot/src/share/vm/ci/ciObjArrayKlass.cpp +++ b/hotspot/src/share/vm/ci/ciObjArrayKlass.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 diff --git a/hotspot/src/share/vm/ci/ciObjArrayKlass.hpp b/hotspot/src/share/vm/ci/ciObjArrayKlass.hpp index 7a45e867438..e50814c0f8e 100644 --- a/hotspot/src/share/vm/ci/ciObjArrayKlass.hpp +++ b/hotspot/src/share/vm/ci/ciObjArrayKlass.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 diff --git a/hotspot/src/share/vm/ci/ciObjectFactory.cpp b/hotspot/src/share/vm/ci/ciObjectFactory.cpp index a22fcf62c8c..d257e8ac467 100644 --- a/hotspot/src/share/vm/ci/ciObjectFactory.cpp +++ b/hotspot/src/share/vm/ci/ciObjectFactory.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 diff --git a/hotspot/src/share/vm/ci/ciObjectFactory.hpp b/hotspot/src/share/vm/ci/ciObjectFactory.hpp index ba3d88c1202..c1baca0ee62 100644 --- a/hotspot/src/share/vm/ci/ciObjectFactory.hpp +++ b/hotspot/src/share/vm/ci/ciObjectFactory.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 diff --git a/hotspot/src/share/vm/ci/ciReplay.cpp b/hotspot/src/share/vm/ci/ciReplay.cpp index 3c8ccf9bb87..e880815098d 100644 --- a/hotspot/src/share/vm/ci/ciReplay.cpp +++ b/hotspot/src/share/vm/ci/ciReplay.cpp @@ -24,6 +24,8 @@ #include "precompiled.hpp" #include "ci/ciMethodData.hpp" #include "ci/ciReplay.hpp" +#include "ci/ciSymbol.hpp" +#include "ci/ciKlass.hpp" #include "ci/ciUtilities.hpp" #include "compiler/compileBroker.hpp" #include "memory/allocation.inline.hpp" @@ -37,74 +39,107 @@ // ciReplay typedef struct _ciMethodDataRecord { - const char* klass; - const char* method; - const char* signature; - int state; - int current_mileage; - intptr_t* data; - int data_length; - char* orig_data; - int orig_data_length; - int oops_length; - jobject* oops_handles; - int* oops_offsets; + const char* _klass_name; + const char* _method_name; + const char* _signature; + + int _state; + int _current_mileage; + + intptr_t* _data; + char* _orig_data; + jobject* _oops_handles; + int* _oops_offsets; + int _data_length; + int _orig_data_length; + int _oops_length; } ciMethodDataRecord; typedef struct _ciMethodRecord { - const char* klass; - const char* method; - const char* signature; - int instructions_size; - int interpreter_invocation_count; - int interpreter_throwout_count; - int invocation_counter; - int backedge_counter; + const char* _klass_name; + const char* _method_name; + const char* _signature; + + int _instructions_size; + int _interpreter_invocation_count; + int _interpreter_throwout_count; + int _invocation_counter; + int _backedge_counter; } ciMethodRecord; -class CompileReplay; +typedef struct _ciInlineRecord { + const char* _klass_name; + const char* _method_name; + const char* _signature; + + int _inline_depth; + int _inline_bci; +} ciInlineRecord; + +class CompileReplay; static CompileReplay* replay_state; class CompileReplay : public StackObj { private: - FILE* stream; - Thread* thread; - Handle protection_domain; - Handle loader; + FILE* _stream; + Thread* _thread; + Handle _protection_domain; + Handle _loader; - GrowableArray ci_method_records; - GrowableArray ci_method_data_records; + GrowableArray _ci_method_records; + GrowableArray _ci_method_data_records; + + // Use pointer because we may need to return inline records + // without destroying them. + GrowableArray* _ci_inline_records; const char* _error_message; - char* bufptr; - char* buffer; - int buffer_length; - int buffer_end; - int line_no; + char* _bufptr; + char* _buffer; + int _buffer_length; + int _buffer_pos; + + // "compile" data + ciKlass* _iklass; + Method* _imethod; + int _entry_bci; + int _comp_level; public: CompileReplay(const char* filename, TRAPS) { - thread = THREAD; - loader = Handle(thread, SystemDictionary::java_system_loader()); - stream = fopen(filename, "rt"); - if (stream == NULL) { + _thread = THREAD; + _loader = Handle(_thread, SystemDictionary::java_system_loader()); + _protection_domain = Handle(); + + _stream = fopen(filename, "rt"); + if (_stream == NULL) { fprintf(stderr, "ERROR: Can't open replay file %s\n", filename); } - buffer_length = 32; - buffer = NEW_RESOURCE_ARRAY(char, buffer_length); + + _ci_inline_records = NULL; _error_message = NULL; + _buffer_length = 32; + _buffer = NEW_RESOURCE_ARRAY(char, _buffer_length); + _bufptr = _buffer; + _buffer_pos = 0; + + _imethod = NULL; + _iklass = NULL; + _entry_bci = 0; + _comp_level = 0; + test(); } ~CompileReplay() { - if (stream != NULL) fclose(stream); + if (_stream != NULL) fclose(_stream); } void test() { - strcpy(buffer, "1 2 foo 4 bar 0x9 \"this is it\""); - bufptr = buffer; + strcpy(_buffer, "1 2 foo 4 bar 0x9 \"this is it\""); + _bufptr = _buffer; assert(parse_int("test") == 1, "what"); assert(parse_int("test") == 2, "what"); assert(strcmp(parse_string(), "foo") == 0, "what"); @@ -115,18 +150,18 @@ class CompileReplay : public StackObj { } bool had_error() { - return _error_message != NULL || thread->has_pending_exception(); + return _error_message != NULL || _thread->has_pending_exception(); } bool can_replay() { - return !(stream == NULL || had_error()); + return !(_stream == NULL || had_error()); } void report_error(const char* msg) { _error_message = msg; - // Restore the buffer contents for error reporting - for (int i = 0; i < buffer_end; i++) { - if (buffer[i] == '\0') buffer[i] = ' '; + // Restore the _buffer contents for error reporting + for (int i = 0; i < _buffer_pos; i++) { + if (_buffer[i] == '\0') _buffer[i] = ' '; } } @@ -137,10 +172,10 @@ class CompileReplay : public StackObj { int v = 0; int read; - if (sscanf(bufptr, "%i%n", &v, &read) != 1) { + if (sscanf(_bufptr, "%i%n", &v, &read) != 1) { report_error(label); } else { - bufptr += read; + _bufptr += read; } return v; } @@ -152,31 +187,31 @@ class CompileReplay : public StackObj { intptr_t v = 0; int read; - if (sscanf(bufptr, INTPTR_FORMAT "%n", &v, &read) != 1) { + if (sscanf(_bufptr, INTPTR_FORMAT "%n", &v, &read) != 1) { report_error(label); } else { - bufptr += read; + _bufptr += read; } return v; } void skip_ws() { // Skip any leading whitespace - while (*bufptr == ' ' || *bufptr == '\t') { - bufptr++; + while (*_bufptr == ' ' || *_bufptr == '\t') { + _bufptr++; } } char* scan_and_terminate(char delim) { - char* str = bufptr; - while (*bufptr != delim && *bufptr != '\0') { - bufptr++; + char* str = _bufptr; + while (*_bufptr != delim && *_bufptr != '\0') { + _bufptr++; } - if (*bufptr != '\0') { - *bufptr++ = '\0'; + if (*_bufptr != '\0') { + *_bufptr++ = '\0'; } - if (bufptr == str) { + if (_bufptr == str) { // nothing here return NULL; } @@ -195,8 +230,8 @@ class CompileReplay : public StackObj { skip_ws(); - if (*bufptr == '"') { - bufptr++; + if (*_bufptr == '"') { + _bufptr++; return scan_and_terminate('"'); } else { return scan_and_terminate(' '); @@ -273,7 +308,12 @@ class CompileReplay : public StackObj { const char* str = parse_escaped_string(); Symbol* klass_name = SymbolTable::lookup(str, (int)strlen(str), CHECK_NULL); if (klass_name != NULL) { - Klass* k = SystemDictionary::resolve_or_fail(klass_name, loader, protection_domain, true, THREAD); + Klass* k = NULL; + if (_iklass != NULL) { + k = (Klass*)_iklass->find_klass(ciSymbol::make(klass_name->as_C_string()))->constant_encoding(); + } else { + k = SystemDictionary::resolve_or_fail(klass_name, _loader, _protection_domain, true, THREAD); + } if (HAS_PENDING_EXCEPTION) { oop throwable = PENDING_EXCEPTION; java_lang_Throwable::print(throwable, tty); @@ -289,7 +329,7 @@ class CompileReplay : public StackObj { // Lookup a klass Klass* resolve_klass(const char* klass, TRAPS) { Symbol* klass_name = SymbolTable::lookup(klass, (int)strlen(klass), CHECK_NULL); - return SystemDictionary::resolve_or_fail(klass_name, loader, protection_domain, true, CHECK_NULL); + return SystemDictionary::resolve_or_fail(klass_name, _loader, _protection_domain, true, CHECK_NULL); } // Parse the standard tuple of @@ -304,40 +344,45 @@ class CompileReplay : public StackObj { return m; } - // Process each line of the replay file executing each command until - // the file ends. - void process(TRAPS) { - line_no = 1; - int pos = 0; - int c = getc(stream); + int get_line(int c) { while(c != EOF) { - if (pos + 1 >= buffer_length) { - int newl = buffer_length * 2; - char* newb = NEW_RESOURCE_ARRAY(char, newl); - memcpy(newb, buffer, pos); - buffer = newb; - buffer_length = newl; + if (_buffer_pos + 1 >= _buffer_length) { + int new_length = _buffer_length * 2; + // Next call will throw error in case of OOM. + _buffer = REALLOC_RESOURCE_ARRAY(char, _buffer, _buffer_length, new_length); + _buffer_length = new_length; } if (c == '\n') { - // null terminate it, reset the pointer and process the line - buffer[pos] = '\0'; - buffer_end = pos++; - bufptr = buffer; - process_command(CHECK); - if (had_error()) { - tty->print_cr("Error while parsing line %d: %s\n", line_no, _error_message); - tty->print_cr("%s", buffer); - return; - } - pos = 0; - buffer_end = 0; - line_no++; + c = getc(_stream); // get next char + break; } else if (c == '\r') { // skip LF } else { - buffer[pos++] = c; + _buffer[_buffer_pos++] = c; } - c = getc(stream); + c = getc(_stream); + } + // null terminate it, reset the pointer + _buffer[_buffer_pos] = '\0'; // NL or EOF + _buffer_pos = 0; + _bufptr = _buffer; + return c; + } + + // Process each line of the replay file executing each command until + // the file ends. + void process(TRAPS) { + int line_no = 1; + int c = getc(_stream); + while(c != EOF) { + c = get_line(c); + process_command(CHECK); + if (had_error()) { + tty->print_cr("Error while parsing line %d: %s\n", line_no, _error_message); + tty->print_cr("%s", _buffer); + return; + } + line_no++; } } @@ -396,7 +441,37 @@ class CompileReplay : public StackObj { return true; } - // compile + // compile inline ... + void* process_inline(ciMethod* imethod, Method* m, int entry_bci, int comp_level, TRAPS) { + _imethod = m; + _iklass = imethod->holder(); + _entry_bci = entry_bci; + _comp_level = comp_level; + int line_no = 1; + int c = getc(_stream); + while(c != EOF) { + c = get_line(c); + // Expecting only lines with "compile" command in inline replay file. + char* cmd = parse_string(); + if (cmd == NULL || strcmp("compile", cmd) != 0) { + return NULL; + } + process_compile(CHECK_NULL); + if (had_error()) { + tty->print_cr("Error while parsing line %d: %s\n", line_no, _error_message); + tty->print_cr("%s", _buffer); + return NULL; + } + if (_ci_inline_records != NULL && _ci_inline_records->length() > 0) { + // Found inlining record for the requested method. + return _ci_inline_records; + } + line_no++; + } + return NULL; + } + + // compile inline ... void process_compile(TRAPS) { Method* method = parse_method(CHECK); if (had_error()) return; @@ -410,6 +485,43 @@ class CompileReplay : public StackObj { if (!is_valid_comp_level(comp_level)) { return; } + if (_imethod != NULL) { + // Replay Inlining + if (entry_bci != _entry_bci || comp_level != _comp_level) { + return; + } + const char* iklass_name = _imethod->method_holder()->name()->as_utf8(); + const char* imethod_name = _imethod->name()->as_utf8(); + const char* isignature = _imethod->signature()->as_utf8(); + const char* klass_name = method->method_holder()->name()->as_utf8(); + const char* method_name = method->name()->as_utf8(); + const char* signature = method->signature()->as_utf8(); + if (strcmp(iklass_name, klass_name) != 0 || + strcmp(imethod_name, method_name) != 0 || + strcmp(isignature, signature) != 0) { + return; + } + } + int inline_count = 0; + if (parse_tag_and_count("inline", inline_count)) { + // Record inlining data + _ci_inline_records = new GrowableArray(); + for (int i = 0; i < inline_count; i++) { + int depth = parse_int("inline_depth"); + int bci = parse_int("inline_bci"); + if (had_error()) { + break; + } + Method* inl_method = parse_method(CHECK); + if (had_error()) { + break; + } + new_ciInlineRecord(inl_method, bci, depth); + } + } + if (_imethod != NULL) { + return; // Replay Inlining + } Klass* k = method->method_holder(); ((InstanceKlass*)k)->initialize(THREAD); if (HAS_PENDING_EXCEPTION) { @@ -442,11 +554,11 @@ class CompileReplay : public StackObj { Method* method = parse_method(CHECK); if (had_error()) return; ciMethodRecord* rec = new_ciMethod(method); - rec->invocation_counter = parse_int("invocation_counter"); - rec->backedge_counter = parse_int("backedge_counter"); - rec->interpreter_invocation_count = parse_int("interpreter_invocation_count"); - rec->interpreter_throwout_count = parse_int("interpreter_throwout_count"); - rec->instructions_size = parse_int("instructions_size"); + rec->_invocation_counter = parse_int("invocation_counter"); + rec->_backedge_counter = parse_int("backedge_counter"); + rec->_interpreter_invocation_count = parse_int("interpreter_invocation_count"); + rec->_interpreter_throwout_count = parse_int("interpreter_throwout_count"); + rec->_instructions_size = parse_int("instructions_size"); } // ciMethodData orig # # ... data # # ... oops @@ -471,32 +583,32 @@ class CompileReplay : public StackObj { // collect and record all the needed information for later ciMethodDataRecord* rec = new_ciMethodData(method); - rec->state = parse_int("state"); - rec->current_mileage = parse_int("current_mileage"); + rec->_state = parse_int("state"); + rec->_current_mileage = parse_int("current_mileage"); - rec->orig_data = parse_data("orig", rec->orig_data_length); - if (rec->orig_data == NULL) { + rec->_orig_data = parse_data("orig", rec->_orig_data_length); + if (rec->_orig_data == NULL) { return; } - rec->data = parse_intptr_data("data", rec->data_length); - if (rec->data == NULL) { + rec->_data = parse_intptr_data("data", rec->_data_length); + if (rec->_data == NULL) { return; } - if (!parse_tag_and_count("oops", rec->oops_length)) { + if (!parse_tag_and_count("oops", rec->_oops_length)) { return; } - rec->oops_handles = NEW_RESOURCE_ARRAY(jobject, rec->oops_length); - rec->oops_offsets = NEW_RESOURCE_ARRAY(int, rec->oops_length); - for (int i = 0; i < rec->oops_length; i++) { + rec->_oops_handles = NEW_RESOURCE_ARRAY(jobject, rec->_oops_length); + rec->_oops_offsets = NEW_RESOURCE_ARRAY(int, rec->_oops_length); + for (int i = 0; i < rec->_oops_length; i++) { int offset = parse_int("offset"); if (had_error()) { return; } Klass* k = parse_klass(CHECK); - rec->oops_offsets[i] = offset; + rec->_oops_offsets[i] = offset; KlassHandle *kh = NEW_C_HEAP_OBJ(KlassHandle, mtCompiler); ::new ((void*)kh) KlassHandle(THREAD, k); - rec->oops_handles[i] = (jobject)kh; + rec->_oops_handles[i] = (jobject)kh; } } @@ -570,6 +682,9 @@ class CompileReplay : public StackObj { case JVM_CONSTANT_Utf8: case JVM_CONSTANT_Integer: case JVM_CONSTANT_Float: + case JVM_CONSTANT_MethodHandle: + case JVM_CONSTANT_MethodType: + case JVM_CONSTANT_InvokeDynamic: if (tag != cp->tag_at(i).value()) { report_error("tag mismatch: wrong class files?"); return; @@ -729,10 +844,10 @@ class CompileReplay : public StackObj { // Create and initialize a record for a ciMethod ciMethodRecord* new_ciMethod(Method* method) { ciMethodRecord* rec = NEW_RESOURCE_OBJ(ciMethodRecord); - rec->klass = method->method_holder()->name()->as_utf8(); - rec->method = method->name()->as_utf8(); - rec->signature = method->signature()->as_utf8(); - ci_method_records.append(rec); + rec->_klass_name = method->method_holder()->name()->as_utf8(); + rec->_method_name = method->name()->as_utf8(); + rec->_signature = method->signature()->as_utf8(); + _ci_method_records.append(rec); return rec; } @@ -741,11 +856,11 @@ class CompileReplay : public StackObj { const char* klass_name = method->method_holder()->name()->as_utf8(); const char* method_name = method->name()->as_utf8(); const char* signature = method->signature()->as_utf8(); - for (int i = 0; i < ci_method_records.length(); i++) { - ciMethodRecord* rec = ci_method_records.at(i); - if (strcmp(rec->klass, klass_name) == 0 && - strcmp(rec->method, method_name) == 0 && - strcmp(rec->signature, signature) == 0) { + for (int i = 0; i < _ci_method_records.length(); i++) { + ciMethodRecord* rec = _ci_method_records.at(i); + if (strcmp(rec->_klass_name, klass_name) == 0 && + strcmp(rec->_method_name, method_name) == 0 && + strcmp(rec->_signature, signature) == 0) { return rec; } } @@ -755,10 +870,10 @@ class CompileReplay : public StackObj { // Create and initialize a record for a ciMethodData ciMethodDataRecord* new_ciMethodData(Method* method) { ciMethodDataRecord* rec = NEW_RESOURCE_OBJ(ciMethodDataRecord); - rec->klass = method->method_holder()->name()->as_utf8(); - rec->method = method->name()->as_utf8(); - rec->signature = method->signature()->as_utf8(); - ci_method_data_records.append(rec); + rec->_klass_name = method->method_holder()->name()->as_utf8(); + rec->_method_name = method->name()->as_utf8(); + rec->_signature = method->signature()->as_utf8(); + _ci_method_data_records.append(rec); return rec; } @@ -767,25 +882,65 @@ class CompileReplay : public StackObj { const char* klass_name = method->method_holder()->name()->as_utf8(); const char* method_name = method->name()->as_utf8(); const char* signature = method->signature()->as_utf8(); - for (int i = 0; i < ci_method_data_records.length(); i++) { - ciMethodDataRecord* rec = ci_method_data_records.at(i); - if (strcmp(rec->klass, klass_name) == 0 && - strcmp(rec->method, method_name) == 0 && - strcmp(rec->signature, signature) == 0) { + for (int i = 0; i < _ci_method_data_records.length(); i++) { + ciMethodDataRecord* rec = _ci_method_data_records.at(i); + if (strcmp(rec->_klass_name, klass_name) == 0 && + strcmp(rec->_method_name, method_name) == 0 && + strcmp(rec->_signature, signature) == 0) { return rec; } } return NULL; } + // Create and initialize a record for a ciInlineRecord + ciInlineRecord* new_ciInlineRecord(Method* method, int bci, int depth) { + ciInlineRecord* rec = NEW_RESOURCE_OBJ(ciInlineRecord); + rec->_klass_name = method->method_holder()->name()->as_utf8(); + rec->_method_name = method->name()->as_utf8(); + rec->_signature = method->signature()->as_utf8(); + rec->_inline_bci = bci; + rec->_inline_depth = depth; + _ci_inline_records->append(rec); + return rec; + } + + // Lookup inlining data for a ciMethod + ciInlineRecord* find_ciInlineRecord(Method* method, int bci, int depth) { + if (_ci_inline_records != NULL) { + return find_ciInlineRecord(_ci_inline_records, method, bci, depth); + } + return NULL; + } + + static ciInlineRecord* find_ciInlineRecord(GrowableArray* records, + Method* method, int bci, int depth) { + if (records != NULL) { + const char* klass_name = method->method_holder()->name()->as_utf8(); + const char* method_name = method->name()->as_utf8(); + const char* signature = method->signature()->as_utf8(); + for (int i = 0; i < records->length(); i++) { + ciInlineRecord* rec = records->at(i); + if ((rec->_inline_bci == bci) && + (rec->_inline_depth == depth) && + (strcmp(rec->_klass_name, klass_name) == 0) && + (strcmp(rec->_method_name, method_name) == 0) && + (strcmp(rec->_signature, signature) == 0)) { + return rec; + } + } + } + return NULL; + } + const char* error_message() { return _error_message; } void reset() { _error_message = NULL; - ci_method_records.clear(); - ci_method_data_records.clear(); + _ci_method_records.clear(); + _ci_method_data_records.clear(); } // Take an ascii string contain \u#### escapes and convert it to utf8 @@ -845,6 +1000,37 @@ void ciReplay::replay(TRAPS) { vm_exit(exit_code); } +void* ciReplay::load_inline_data(ciMethod* method, int entry_bci, int comp_level) { + if (FLAG_IS_DEFAULT(InlineDataFile)) { + tty->print_cr("ERROR: no inline replay data file specified (use -XX:InlineDataFile=inline_pid12345.txt)."); + return NULL; + } + + VM_ENTRY_MARK; + // Load and parse the replay data + CompileReplay rp(InlineDataFile, THREAD); + if (!rp.can_replay()) { + tty->print_cr("ciReplay: !rp.can_replay()"); + return NULL; + } + void* data = rp.process_inline(method, method->get_Method(), entry_bci, comp_level, THREAD); + if (HAS_PENDING_EXCEPTION) { + oop throwable = PENDING_EXCEPTION; + CLEAR_PENDING_EXCEPTION; + java_lang_Throwable::print(throwable, tty); + tty->cr(); + java_lang_Throwable::print_stack_trace(throwable, tty); + tty->cr(); + return NULL; + } + + if (rp.had_error()) { + tty->print_cr("ciReplay: Failed on %s", rp.error_message()); + return NULL; + } + return data; +} + int ciReplay::replay_impl(TRAPS) { HandleMark hm; ResourceMark rm; @@ -890,7 +1076,6 @@ int ciReplay::replay_impl(TRAPS) { return exit_code; } - void ciReplay::initialize(ciMethodData* m) { if (replay_state == NULL) { return; @@ -909,28 +1094,28 @@ void ciReplay::initialize(ciMethodData* m) { method->print_name(tty); tty->cr(); } else { - m->_state = rec->state; - m->_current_mileage = rec->current_mileage; - if (rec->data_length != 0) { - assert(m->_data_size == rec->data_length * (int)sizeof(rec->data[0]), "must agree"); + m->_state = rec->_state; + m->_current_mileage = rec->_current_mileage; + if (rec->_data_length != 0) { + assert(m->_data_size == rec->_data_length * (int)sizeof(rec->_data[0]), "must agree"); // Write the correct ciObjects back into the profile data ciEnv* env = ciEnv::current(); - for (int i = 0; i < rec->oops_length; i++) { - KlassHandle *h = (KlassHandle *)rec->oops_handles[i]; - *(ciMetadata**)(rec->data + rec->oops_offsets[i]) = + for (int i = 0; i < rec->_oops_length; i++) { + KlassHandle *h = (KlassHandle *)rec->_oops_handles[i]; + *(ciMetadata**)(rec->_data + rec->_oops_offsets[i]) = env->get_metadata((*h)()); } // Copy the updated profile data into place as intptr_ts #ifdef _LP64 - Copy::conjoint_jlongs_atomic((jlong *)rec->data, (jlong *)m->_data, rec->data_length); + Copy::conjoint_jlongs_atomic((jlong *)rec->_data, (jlong *)m->_data, rec->_data_length); #else - Copy::conjoint_jints_atomic((jint *)rec->data, (jint *)m->_data, rec->data_length); + Copy::conjoint_jints_atomic((jint *)rec->_data, (jint *)m->_data, rec->_data_length); #endif } // copy in the original header - Copy::conjoint_jbytes(rec->orig_data, (char*)&m->_orig, rec->orig_data_length); + Copy::conjoint_jbytes(rec->_orig_data, (char*)&m->_orig, rec->_orig_data_length); } } @@ -939,12 +1124,38 @@ bool ciReplay::should_not_inline(ciMethod* method) { if (replay_state == NULL) { return false; } - VM_ENTRY_MARK; // ciMethod without a record shouldn't be inlined. return replay_state->find_ciMethodRecord(method->get_Method()) == NULL; } +bool ciReplay::should_inline(void* data, ciMethod* method, int bci, int inline_depth) { + if (data != NULL) { + GrowableArray* records = (GrowableArray*)data; + VM_ENTRY_MARK; + // Inline record are ordered by bci and depth. + return CompileReplay::find_ciInlineRecord(records, method->get_Method(), bci, inline_depth) != NULL; + } else if (replay_state != NULL) { + VM_ENTRY_MARK; + // Inline record are ordered by bci and depth. + return replay_state->find_ciInlineRecord(method->get_Method(), bci, inline_depth) != NULL; + } + return false; +} + +bool ciReplay::should_not_inline(void* data, ciMethod* method, int bci, int inline_depth) { + if (data != NULL) { + GrowableArray* records = (GrowableArray*)data; + VM_ENTRY_MARK; + // Inline record are ordered by bci and depth. + return CompileReplay::find_ciInlineRecord(records, method->get_Method(), bci, inline_depth) == NULL; + } else if (replay_state != NULL) { + VM_ENTRY_MARK; + // Inline record are ordered by bci and depth. + return replay_state->find_ciInlineRecord(method->get_Method(), bci, inline_depth) == NULL; + } + return false; +} void ciReplay::initialize(ciMethod* m) { if (replay_state == NULL) { @@ -965,14 +1176,14 @@ void ciReplay::initialize(ciMethod* m) { tty->cr(); } else { EXCEPTION_CONTEXT; - // m->_instructions_size = rec->instructions_size; + // m->_instructions_size = rec->_instructions_size; m->_instructions_size = -1; - m->_interpreter_invocation_count = rec->interpreter_invocation_count; - m->_interpreter_throwout_count = rec->interpreter_throwout_count; + m->_interpreter_invocation_count = rec->_interpreter_invocation_count; + m->_interpreter_throwout_count = rec->_interpreter_throwout_count; MethodCounters* mcs = method->get_method_counters(CHECK_AND_CLEAR); guarantee(mcs != NULL, "method counters allocation failed"); - mcs->invocation_counter()->_counter = rec->invocation_counter; - mcs->backedge_counter()->_counter = rec->backedge_counter; + mcs->invocation_counter()->_counter = rec->_invocation_counter; + mcs->backedge_counter()->_counter = rec->_backedge_counter; } } diff --git a/hotspot/src/share/vm/ci/ciReplay.hpp b/hotspot/src/share/vm/ci/ciReplay.hpp index 8fff3454d27..90c503a64d8 100644 --- a/hotspot/src/share/vm/ci/ciReplay.hpp +++ b/hotspot/src/share/vm/ci/ciReplay.hpp @@ -29,6 +29,73 @@ // ciReplay +// +// Replay compilation of a java method by using an information in replay file. +// Replay inlining decisions during compilation by using an information in inline file. +// +// NOTE: these replay functions only exist in debug version of VM. +// +// Replay compilation. +// ------------------- +// +// Replay data file replay.txt can be created by Serviceability Agent +// from a core file, see agent/doc/cireplay.html +// +// $ java -cp /lib/sa-jdi.jar sun.jvm.hotspot.CLHSDB +// hsdb> attach /bin/java ./core +// hsdb> threads +// t@10 Service Thread +// t@9 C2 CompilerThread0 +// t@8 Signal Dispatcher +// t@7 Finalizer +// t@6 Reference Handler +// t@2 main +// hsdb> dumpreplaydata t@9 > replay.txt +// hsdb> quit +// +// (Note: SA could be also used to extract app.jar and boot.jar files +// from core file to replay compilation if only core file is available) +// +// Replay data file replay_pid%p.log is also created when VM crashes +// in Compiler thread during compilation. It is controlled by +// DumpReplayDataOnError flag which is ON by default. +// +// Replay file replay_pid%p_compid%d.log can be created +// for the specified java method during normal execution using +// CompileCommand option DumpReplay: +// +// -XX:CompileCommand=option,Benchmark::test,DumpReplay +// +// In this case the file name has additional compilation id "_compid%d" +// because the method could be compiled several times. +// +// To replay compilation the replay file should be specified: +// +// -XX:+ReplayCompiles -XX:ReplayDataFile=replay_pid2133.log +// +// VM thread reads data from the file immediately after VM initialization +// and puts the compilation task on compile queue. After that it goes into +// wait state (BackgroundCompilation flag is set to false) since there is no +// a program to execute. VM exits when the compilation is finished. +// +// +// Replay inlining. +// ---------------- +// +// Replay inlining file inline_pid%p_compid%d.log is created for +// a specific java method during normal execution of a java program +// using CompileCommand option DumpInline: +// +// -XX:CompileCommand=option,Benchmark::test,DumpInline +// +// To replay inlining the replay file and the method should be specified: +// +// -XX:CompileCommand=option,Benchmark::test,ReplayInline -XX:InlineDataFile=inline_pid3244_compid6.log +// +// The difference from replay compilation is that replay inlining +// is performed during normal java program execution. +// + class ciReplay { CI_PACKAGE_ACCESS @@ -37,7 +104,11 @@ class ciReplay { static int replay_impl(TRAPS); public: + // Replay specified compilation and exit VM. static void replay(TRAPS); + // Load inlining decisions from file and use them + // during compilation of specified method. + static void* load_inline_data(ciMethod* method, int entry_bci, int comp_level); // These are used by the CI to fill in the cached data from the // replay file when replaying compiles. @@ -48,6 +119,8 @@ class ciReplay { static bool is_loaded(Klass* klass); static bool should_not_inline(ciMethod* method); + static bool should_inline(void* data, ciMethod* method, int bci, int inline_depth); + static bool should_not_inline(void* data, ciMethod* method, int bci, int inline_depth); #endif }; diff --git a/hotspot/src/share/vm/ci/ciStreams.hpp b/hotspot/src/share/vm/ci/ciStreams.hpp index 92a1a4adf88..091aa1bdf53 100644 --- a/hotspot/src/share/vm/ci/ciStreams.hpp +++ b/hotspot/src/share/vm/ci/ciStreams.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 diff --git a/hotspot/src/share/vm/ci/ciType.cpp b/hotspot/src/share/vm/ci/ciType.cpp index e74dd921804..15c884213bb 100644 --- a/hotspot/src/share/vm/ci/ciType.cpp +++ b/hotspot/src/share/vm/ci/ciType.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 diff --git a/hotspot/src/share/vm/ci/ciType.hpp b/hotspot/src/share/vm/ci/ciType.hpp index 25f79e01263..c3901e4b06f 100644 --- a/hotspot/src/share/vm/ci/ciType.hpp +++ b/hotspot/src/share/vm/ci/ciType.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 diff --git a/hotspot/src/share/vm/ci/ciTypeArray.cpp b/hotspot/src/share/vm/ci/ciTypeArray.cpp index 2d013e21c0e..15113348e21 100644 --- a/hotspot/src/share/vm/ci/ciTypeArray.cpp +++ b/hotspot/src/share/vm/ci/ciTypeArray.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 diff --git a/hotspot/src/share/vm/ci/ciTypeArrayKlass.hpp b/hotspot/src/share/vm/ci/ciTypeArrayKlass.hpp index b88aecb9c6c..607c00cc50b 100644 --- a/hotspot/src/share/vm/ci/ciTypeArrayKlass.hpp +++ b/hotspot/src/share/vm/ci/ciTypeArrayKlass.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 diff --git a/hotspot/src/share/vm/ci/ciTypeFlow.cpp b/hotspot/src/share/vm/ci/ciTypeFlow.cpp index b76dd3d0fe3..48bcaf369a9 100644 --- a/hotspot/src/share/vm/ci/ciTypeFlow.cpp +++ b/hotspot/src/share/vm/ci/ciTypeFlow.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 diff --git a/hotspot/src/share/vm/ci/ciUtilities.hpp b/hotspot/src/share/vm/ci/ciUtilities.hpp index 2032a8f35e1..bba611fc3b6 100644 --- a/hotspot/src/share/vm/ci/ciUtilities.hpp +++ b/hotspot/src/share/vm/ci/ciUtilities.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 diff --git a/hotspot/src/share/vm/classfile/bytecodeAssembler.cpp b/hotspot/src/share/vm/classfile/bytecodeAssembler.cpp index 77b6a9ea747..cbf3baf7945 100644 --- a/hotspot/src/share/vm/classfile/bytecodeAssembler.cpp +++ b/hotspot/src/share/vm/classfile/bytecodeAssembler.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/hotspot/src/share/vm/classfile/classFileStream.cpp b/hotspot/src/share/vm/classfile/classFileStream.cpp index 1c69dfb2ea6..27479acb64a 100644 --- a/hotspot/src/share/vm/classfile/classFileStream.cpp +++ b/hotspot/src/share/vm/classfile/classFileStream.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/classfile/classFileStream.hpp b/hotspot/src/share/vm/classfile/classFileStream.hpp index 19da924abf2..691ed808fec 100644 --- a/hotspot/src/share/vm/classfile/classFileStream.hpp +++ b/hotspot/src/share/vm/classfile/classFileStream.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/classfile/classLoaderData.cpp b/hotspot/src/share/vm/classfile/classLoaderData.cpp index 273e0184d8e..892ea92fb00 100644 --- a/hotspot/src/share/vm/classfile/classLoaderData.cpp +++ b/hotspot/src/share/vm/classfile/classLoaderData.cpp @@ -648,12 +648,12 @@ GrowableArray* ClassLoaderDataGraph::new_clds() { return array; } -#ifndef PRODUCT -// for debugging and hsfind(x) -bool ClassLoaderDataGraph::contains(address x) { - // I think we need the _metaspace_lock taken here because the class loader - // data graph could be changing while we are walking it (new entries added, - // new entries being unloaded, etc). +// For profiling and hsfind() only. Otherwise, this is unsafe (and slow). This +// is done lock free to avoid lock inversion problems. It is safe because +// new ClassLoaderData are added to the end of the CLDG, and only removed at +// safepoint. The _unloading list can be deallocated concurrently with CMS so +// this doesn't look in metaspace for classes that have been unloaded. +bool ClassLoaderDataGraph::contains(const void* x) { if (DumpSharedSpaces) { // There are only two metaspaces to worry about. ClassLoaderData* ncld = ClassLoaderData::the_null_class_loader_data(); @@ -670,16 +670,11 @@ bool ClassLoaderDataGraph::contains(address x) { } } - // Could also be on an unloading list which is okay, ie. still allocated - // for a little while. - for (ClassLoaderData* ucld = _unloading; ucld != NULL; ucld = ucld->next()) { - if (ucld->metaspace_or_null() != NULL && ucld->metaspace_or_null()->contains(x)) { - return true; - } - } + // Do not check unloading list because deallocation can be concurrent. return false; } +#ifndef PRODUCT bool ClassLoaderDataGraph::contains_loader_data(ClassLoaderData* loader_data) { for (ClassLoaderData* data = _head; data != NULL; data = data->next()) { if (loader_data == data) { diff --git a/hotspot/src/share/vm/classfile/classLoaderData.hpp b/hotspot/src/share/vm/classfile/classLoaderData.hpp index 2cb21801de5..9e76b50441f 100644 --- a/hotspot/src/share/vm/classfile/classLoaderData.hpp +++ b/hotspot/src/share/vm/classfile/classLoaderData.hpp @@ -90,9 +90,9 @@ class ClassLoaderDataGraph : public AllStatic { static void dump() { dump_on(tty); } static void verify(); -#ifndef PRODUCT // expensive test for pointer in metaspace for debugging - static bool contains(address x); + static bool contains(const void* x); +#ifndef PRODUCT static bool contains_loader_data(ClassLoaderData* loader_data); #endif diff --git a/hotspot/src/share/vm/classfile/classLoaderData.inline.hpp b/hotspot/src/share/vm/classfile/classLoaderData.inline.hpp index 018b6761c50..11014f25cbb 100644 --- a/hotspot/src/share/vm/classfile/classLoaderData.inline.hpp +++ b/hotspot/src/share/vm/classfile/classLoaderData.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/hotspot/src/share/vm/classfile/defaultMethods.cpp b/hotspot/src/share/vm/classfile/defaultMethods.cpp index 129eecbad3b..0ebeecc624b 100644 --- a/hotspot/src/share/vm/classfile/defaultMethods.cpp +++ b/hotspot/src/share/vm/classfile/defaultMethods.cpp @@ -349,6 +349,7 @@ class MethodFamily : public ResourceObj { } Symbol* generate_no_defaults_message(TRAPS) const; + Symbol* generate_method_message(Symbol *klass_name, Method* method, TRAPS) const; Symbol* generate_conflicts_message(GrowableArray* methods, TRAPS) const; public: @@ -414,21 +415,25 @@ class MethodFamily : public ResourceObj { } } - if (qualified_methods.length() == 0) { - _exception_message = generate_no_defaults_message(CHECK); + if (num_defaults == 0) { + if (qualified_methods.length() == 0) { + _exception_message = generate_no_defaults_message(CHECK); + } else { + assert(root != NULL, "Null root class"); + _exception_message = generate_method_message(root->name(), qualified_methods.at(0), CHECK); + } _exception_name = vmSymbols::java_lang_AbstractMethodError(); // If only one qualified method is default, select that } else if (num_defaults == 1) { _selected_target = qualified_methods.at(default_index); } else if (num_defaults > 1) { - _exception_message = generate_conflicts_message(&qualified_methods,CHECK); - _exception_name = vmSymbols::java_lang_IncompatibleClassChangeError(); + _exception_message = generate_conflicts_message(&qualified_methods,CHECK); + _exception_name = vmSymbols::java_lang_IncompatibleClassChangeError(); if (TraceDefaultMethods) { _exception_message->print_value_on(tty); tty->print_cr(""); } } - // leave abstract methods alone, they will be found via normal search path } bool contains_signature(Symbol* query) { @@ -486,6 +491,19 @@ Symbol* MethodFamily::generate_no_defaults_message(TRAPS) const { return SymbolTable::new_symbol("No qualifying defaults found", CHECK_NULL); } +Symbol* MethodFamily::generate_method_message(Symbol *klass_name, Method* method, TRAPS) const { + stringStream ss; + ss.print("Method "); + Symbol* name = method->name(); + Symbol* signature = method->signature(); + ss.write((const char*)klass_name->bytes(), klass_name->utf8_length()); + ss.print("."); + ss.write((const char*)name->bytes(), name->utf8_length()); + ss.write((const char*)signature->bytes(), signature->utf8_length()); + ss.print(" is abstract"); + return SymbolTable::new_symbol(ss.base(), (int)ss.size(), CHECK_NULL); +} + Symbol* MethodFamily::generate_conflicts_message(GrowableArray* methods, TRAPS) const { stringStream ss; ss.print("Conflicting default methods:"); @@ -1026,7 +1044,8 @@ static void merge_in_new_methods(InstanceKlass* klass, Array* merged_methods = MetadataFactory::new_array( klass->class_loader_data(), new_size, NULL, CHECK); - if (original_ordering != NULL && original_ordering->length() > 0) { + // original_ordering might be empty if this class has no methods of its own + if (JvmtiExport::can_maintain_original_method_order() || DumpSharedSpaces) { merged_ordering = MetadataFactory::new_array( klass->class_loader_data(), new_size, CHECK); } @@ -1053,6 +1072,8 @@ static void merge_in_new_methods(InstanceKlass* klass, merged_methods->at_put(i, orig_method); original_methods->at_put(orig_idx, NULL); if (merged_ordering->length() > 0) { + assert(original_ordering != NULL && original_ordering->length() > 0, + "should have original order information for this method"); merged_ordering->at_put(i, original_ordering->at(orig_idx)); } ++orig_idx; @@ -1081,13 +1102,14 @@ static void merge_in_new_methods(InstanceKlass* klass, // Replace klass methods with new merged lists klass->set_methods(merged_methods); klass->set_initial_method_idnum(new_size); + klass->set_method_ordering(merged_ordering); + // Free metadata ClassLoaderData* cld = klass->class_loader_data(); - if (original_methods ->length() > 0) { + if (original_methods->length() > 0) { MetadataFactory::free_array(cld, original_methods); } - if (original_ordering->length() > 0) { - klass->set_method_ordering(merged_ordering); + if (original_ordering != NULL && original_ordering->length() > 0) { MetadataFactory::free_array(cld, original_ordering); } } diff --git a/hotspot/src/share/vm/classfile/javaClasses.cpp b/hotspot/src/share/vm/classfile/javaClasses.cpp index 06e75ea25d7..d9bd3a4d713 100644 --- a/hotspot/src/share/vm/classfile/javaClasses.cpp +++ b/hotspot/src/share/vm/classfile/javaClasses.cpp @@ -3286,7 +3286,7 @@ void JavaClasses::compute_offsets() { sun_reflect_ConstantPool::compute_offsets(); sun_reflect_UnsafeStaticFieldAccessorImpl::compute_offsets(); } - if (JDK_Version::is_jdk18x_version()) + if (JDK_Version::is_gte_jdk18x_version()) java_lang_reflect_Parameter::compute_offsets(); // generated interpreter code wants to know about the offsets we just computed: diff --git a/hotspot/src/share/vm/classfile/systemDictionary.cpp b/hotspot/src/share/vm/classfile/systemDictionary.cpp index ee311b6a85f..f5c5c017dcd 100644 --- a/hotspot/src/share/vm/classfile/systemDictionary.cpp +++ b/hotspot/src/share/vm/classfile/systemDictionary.cpp @@ -1049,6 +1049,9 @@ Klass* SystemDictionary::parse_stream(Symbol* class_name, add_to_hierarchy(k, CHECK_NULL); // No exception, but can block // But, do not add to system dictionary. + + // compiled code dependencies need to be validated anyway + notice_modification(); } // Rewrite and patch constant pool here. diff --git a/hotspot/src/share/vm/classfile/vmSymbols.cpp b/hotspot/src/share/vm/classfile/vmSymbols.cpp index cc38c6d2cd6..855c6bdd773 100644 --- a/hotspot/src/share/vm/classfile/vmSymbols.cpp +++ b/hotspot/src/share/vm/classfile/vmSymbols.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/classfile/vmSymbols.hpp b/hotspot/src/share/vm/classfile/vmSymbols.hpp index 9a06792793a..58485959f66 100644 --- a/hotspot/src/share/vm/classfile/vmSymbols.hpp +++ b/hotspot/src/share/vm/classfile/vmSymbols.hpp @@ -654,9 +654,9 @@ do_intrinsic(_addExactI, java_lang_Math, addExact_name, int2_int_signature, F_S) \ do_intrinsic(_addExactL, java_lang_Math, addExact_name, long2_long_signature, F_S) \ do_intrinsic(_decrementExactI, java_lang_Math, decrementExact_name, int_int_signature, F_S) \ - do_intrinsic(_decrementExactL, java_lang_Math, decrementExact_name, long2_long_signature, F_S) \ + do_intrinsic(_decrementExactL, java_lang_Math, decrementExact_name, long_long_signature, F_S) \ do_intrinsic(_incrementExactI, java_lang_Math, incrementExact_name, int_int_signature, F_S) \ - do_intrinsic(_incrementExactL, java_lang_Math, incrementExact_name, long2_long_signature, F_S) \ + do_intrinsic(_incrementExactL, java_lang_Math, incrementExact_name, long_long_signature, F_S) \ do_intrinsic(_multiplyExactI, java_lang_Math, multiplyExact_name, int2_int_signature, F_S) \ do_intrinsic(_multiplyExactL, java_lang_Math, multiplyExact_name, long2_long_signature, F_S) \ do_intrinsic(_negateExactI, java_lang_Math, negateExact_name, int_int_signature, F_S) \ diff --git a/hotspot/src/share/vm/code/compiledIC.cpp b/hotspot/src/share/vm/code/compiledIC.cpp index 489e649fadc..251a4c79c43 100644 --- a/hotspot/src/share/vm/code/compiledIC.cpp +++ b/hotspot/src/share/vm/code/compiledIC.cpp @@ -418,7 +418,7 @@ void CompiledIC::compute_monomorphic_entry(methodHandle method, TRAPS) { nmethod* method_code = method->code(); address entry = NULL; - if (method_code != NULL) { + if (method_code != NULL && method_code->is_in_use()) { // Call to compiled code if (static_bound || is_optimized) { entry = method_code->verified_entry_point(); @@ -545,7 +545,7 @@ void CompiledStaticCall::set(const StaticCallInfo& info) { void CompiledStaticCall::compute_entry(methodHandle m, StaticCallInfo& info) { nmethod* m_code = m->code(); info._callee = m; - if (m_code != NULL) { + if (m_code != NULL && m_code->is_in_use()) { info._to_interpreter = false; info._entry = m_code->verified_entry_point(); } else { diff --git a/hotspot/src/share/vm/code/compiledIC.hpp b/hotspot/src/share/vm/code/compiledIC.hpp index 598cbe949e2..0d522af63fe 100644 --- a/hotspot/src/share/vm/code/compiledIC.hpp +++ b/hotspot/src/share/vm/code/compiledIC.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/code/compressedStream.cpp b/hotspot/src/share/vm/code/compressedStream.cpp index 82b05fc03f9..1716ffac651 100644 --- a/hotspot/src/share/vm/code/compressedStream.cpp +++ b/hotspot/src/share/vm/code/compressedStream.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/code/debugInfo.hpp b/hotspot/src/share/vm/code/debugInfo.hpp index 7a4f7e2d41d..cf0a9a6d39f 100644 --- a/hotspot/src/share/vm/code/debugInfo.hpp +++ b/hotspot/src/share/vm/code/debugInfo.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/code/dependencies.cpp b/hotspot/src/share/vm/code/dependencies.cpp index 4419bdd986c..b4a3aee7f54 100644 --- a/hotspot/src/share/vm/code/dependencies.cpp +++ b/hotspot/src/share/vm/code/dependencies.cpp @@ -655,8 +655,6 @@ inline Metadata* Dependencies::DepStream::recorded_metadata_at(int i) { } else { o = _deps->oop_recorder()->metadata_at(i); } - assert(o == NULL || o->is_metaspace_object(), - err_msg("Should be metadata " PTR_FORMAT, o)); return o; } diff --git a/hotspot/src/share/vm/code/icBuffer.hpp b/hotspot/src/share/vm/code/icBuffer.hpp index 47db2d6b269..471706aaa6d 100644 --- a/hotspot/src/share/vm/code/icBuffer.hpp +++ b/hotspot/src/share/vm/code/icBuffer.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/code/nmethod.cpp b/hotspot/src/share/vm/code/nmethod.cpp index 68718499a00..b9dd9903440 100644 --- a/hotspot/src/share/vm/code/nmethod.cpp +++ b/hotspot/src/share/vm/code/nmethod.cpp @@ -459,7 +459,7 @@ const char* nmethod::compile_kind() const { // Fill in default values for various flag fields void nmethod::init_defaults() { - _state = alive; + _state = in_use; _marked_for_reclamation = 0; _has_flushed_dependencies = 0; _has_unsafe_access = 0; @@ -1660,8 +1660,8 @@ void nmethod::do_unloading(BoolObjectClosure* is_alive, bool unloading_occurred) 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; - } + continue; + } } else { Metadata* ic_oop = ic->cached_metadata(); if (ic_oop != NULL) { @@ -1677,8 +1677,8 @@ void nmethod::do_unloading(BoolObjectClosure* is_alive, bool unloading_occurred) ShouldNotReachHere(); } } - } - ic->set_to_clean(); + } + ic->set_to_clean(); } } } @@ -2393,8 +2393,8 @@ void nmethod::verify() { void nmethod::verify_interrupt_point(address call_site) { // Verify IC only when nmethod installation is finished. - bool is_installed = (method()->code() == this) // nmethod is in state 'alive' and installed - || !this->is_in_use(); // nmethod is installed, but not in 'alive' state + bool is_installed = (method()->code() == this) // nmethod is in state 'in_use' and installed + || !this->is_in_use(); // nmethod is installed, but not in 'in_use' state if (is_installed) { Thread *cur = Thread::current(); if (CompiledIC_lock->owner() == cur || diff --git a/hotspot/src/share/vm/code/nmethod.hpp b/hotspot/src/share/vm/code/nmethod.hpp index 538bcf77837..4e1afcc046b 100644 --- a/hotspot/src/share/vm/code/nmethod.hpp +++ b/hotspot/src/share/vm/code/nmethod.hpp @@ -184,11 +184,12 @@ class nmethod : public CodeBlob { bool _oops_are_stale; // indicates that it's no longer safe to access oops section #endif - enum { alive = 0, - not_entrant = 1, // uncommon trap has happened but activations may still exist - zombie = 2, - unloaded = 3 }; - + enum { in_use = 0, // executable nmethod + not_entrant = 1, // marked for deoptimization but activations may still exist, + // will be transformed to zombie when all activations are gone + zombie = 2, // no activations exist, nmethod is ready for purge + unloaded = 3 }; // there should be no activations, should not be called, + // will be transformed to zombie immediately jbyte _scavenge_root_state; @@ -407,8 +408,8 @@ class nmethod : public CodeBlob { address verified_entry_point() const { return _verified_entry_point; } // if klass is correct // flag accessing and manipulation - bool is_in_use() const { return _state == alive; } - bool is_alive() const { return _state == alive || _state == not_entrant; } + bool is_in_use() const { return _state == in_use; } + bool is_alive() const { return _state == in_use || _state == not_entrant; } bool is_not_entrant() const { return _state == not_entrant; } bool is_zombie() const { return _state == zombie; } bool is_unloaded() const { return _state == unloaded; } diff --git a/hotspot/src/share/vm/code/relocInfo.cpp b/hotspot/src/share/vm/code/relocInfo.cpp index 4fe6a2e4949..b5cf45e68b6 100644 --- a/hotspot/src/share/vm/code/relocInfo.cpp +++ b/hotspot/src/share/vm/code/relocInfo.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/code/scopeDesc.hpp b/hotspot/src/share/vm/code/scopeDesc.hpp index 3a1921406b5..7330f6edbd6 100644 --- a/hotspot/src/share/vm/code/scopeDesc.hpp +++ b/hotspot/src/share/vm/code/scopeDesc.hpp @@ -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 @@ -86,8 +86,6 @@ class ScopeDesc : public ResourceObj { // Tells whether sender() returns NULL bool is_top() const; - // Tells whether sd is equal to this - bool is_equal(ScopeDesc* sd) const; private: // Alternative constructor diff --git a/hotspot/src/share/vm/code/stubs.cpp b/hotspot/src/share/vm/code/stubs.cpp index a826a3550d3..9044c5f8e73 100644 --- a/hotspot/src/share/vm/code/stubs.cpp +++ b/hotspot/src/share/vm/code/stubs.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/code/stubs.hpp b/hotspot/src/share/vm/code/stubs.hpp index 233f43e2dae..045782f397c 100644 --- a/hotspot/src/share/vm/code/stubs.hpp +++ b/hotspot/src/share/vm/code/stubs.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/compiler/abstractCompiler.cpp b/hotspot/src/share/vm/compiler/abstractCompiler.cpp index 3f452a1b53b..0e9c3cf16ee 100644 --- a/hotspot/src/share/vm/compiler/abstractCompiler.cpp +++ b/hotspot/src/share/vm/compiler/abstractCompiler.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2007, 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 diff --git a/hotspot/src/share/vm/compiler/abstractCompiler.hpp b/hotspot/src/share/vm/compiler/abstractCompiler.hpp index d150e8e8085..67f7c95b03d 100644 --- a/hotspot/src/share/vm/compiler/abstractCompiler.hpp +++ b/hotspot/src/share/vm/compiler/abstractCompiler.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, 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 @@ -40,8 +40,19 @@ class AbstractCompiler : public CHeapObj { // This thread will initialize the compiler runtime. bool should_perform_init(); + // The (closed set) of concrete compiler classes. + enum Type { + none, + c1, + c2, + shark + }; + + private: + Type _type; + public: - AbstractCompiler() : _compiler_state(uninitialized), _num_compiler_threads(0) {} + AbstractCompiler(Type type) : _type(type), _compiler_state(uninitialized), _num_compiler_threads(0) {} // This function determines the compiler thread that will perform the // shutdown of the corresponding compiler runtime. @@ -54,27 +65,11 @@ class AbstractCompiler : public CHeapObj { virtual bool supports_native() { return true; } virtual bool supports_osr () { return true; } virtual bool can_compile_method(methodHandle method) { return true; } -#if defined(TIERED) || ( !defined(COMPILER1) && !defined(COMPILER2) && !defined(SHARK)) - virtual bool is_c1 () { return false; } - virtual bool is_c2 () { return false; } - virtual bool is_shark() { return false; } -#else -#ifdef COMPILER1 - bool is_c1 () { return true; } - bool is_c2 () { return false; } - bool is_shark() { return false; } -#endif // COMPILER1 -#ifdef COMPILER2 - bool is_c1 () { return false; } - bool is_c2 () { return true; } - bool is_shark() { return false; } -#endif // COMPILER2 -#ifdef SHARK - bool is_c1 () { return false; } - bool is_c2 () { return false; } - bool is_shark() { return true; } -#endif // SHARK -#endif // TIERED + + // Compiler type queries. + bool is_c1() { return _type == c1; } + bool is_c2() { return _type == c2; } + bool is_shark() { return _type == shark; } // Customization virtual void initialize () = 0; diff --git a/hotspot/src/share/vm/compiler/compileBroker.cpp b/hotspot/src/share/vm/compiler/compileBroker.cpp index f8fa26ff8c2..a6c9117e946 100644 --- a/hotspot/src/share/vm/compiler/compileBroker.cpp +++ b/hotspot/src/share/vm/compiler/compileBroker.cpp @@ -132,9 +132,9 @@ volatile jint CompileBroker::_should_compile_new_jobs = run_compilation; // The installed compiler(s) AbstractCompiler* CompileBroker::_compilers[2]; -// These counters are used for assigning id's to each compilation -uint CompileBroker::_compilation_id = 0; -uint CompileBroker::_osr_compilation_id = 0; +// These counters are used to assign an unique ID to each compilation. +volatile jint CompileBroker::_compilation_id = 0; +volatile jint CompileBroker::_osr_compilation_id = 0; // Debugging information int CompileBroker::_last_compile_type = no_compile; @@ -1158,7 +1158,7 @@ void CompileBroker::compile_method_base(methodHandle method, // We now know that this compilation is not pending, complete, // or prohibited. Assign a compile_id to this compilation // and check to see if it is in our [Start..Stop) range. - uint compile_id = assign_compile_id(method, osr_bci); + int compile_id = assign_compile_id(method, osr_bci); if (compile_id == 0) { // The compilation falls outside the allowed range. return; @@ -1305,18 +1305,12 @@ nmethod* CompileBroker::compile_method(methodHandle method, int osr_bci, // do the compilation if (method->is_native()) { if (!PreferInterpreterNativeStubs || method->is_method_handle_intrinsic()) { - // Acquire our lock. - int compile_id; - { - MutexLocker locker(MethodCompileQueue_lock, THREAD); - compile_id = assign_compile_id(method, standard_entry_bci); - } // To properly handle the appendix argument for out-of-line calls we are using a small trampoline that // pops off the appendix argument and jumps to the target (see gen_special_dispatch in SharedRuntime). // // Since normal compiled-to-compiled calls are not able to handle such a thing we MUST generate an adapter // in this case. If we can't generate one and use it we can not execute the out-of-line method handle calls. - (void) AdapterHandlerLibrary::create_native_wrapper(method, compile_id); + AdapterHandlerLibrary::create_native_wrapper(method); } else { return NULL; } @@ -1419,27 +1413,28 @@ bool CompileBroker::compilation_is_prohibited(methodHandle method, int osr_bci, return false; } - -// ------------------------------------------------------------------ -// CompileBroker::assign_compile_id -// -// Assign a serialized id number to this compilation request. If the -// number falls out of the allowed range, return a 0. OSR -// compilations may be numbered separately from regular compilations -// if certain debugging flags are used. -uint CompileBroker::assign_compile_id(methodHandle method, int osr_bci) { - assert(MethodCompileQueue_lock->owner() == Thread::current(), - "must hold the compilation queue lock"); +/** + * Generate serialized IDs for compilation requests. If certain debugging flags are used + * and the ID is not within the specified range, the method is not compiled and 0 is returned. + * The function also allows to generate separate compilation IDs for OSR compilations. + */ +int CompileBroker::assign_compile_id(methodHandle method, int osr_bci) { +#ifdef ASSERT bool is_osr = (osr_bci != standard_entry_bci); - uint id; - if (CICountOSR && is_osr) { - id = ++_osr_compilation_id; - if ((uint)CIStartOSR <= id && id < (uint)CIStopOSR) { + int id; + if (method->is_native()) { + assert(!is_osr, "can't be osr"); + // Adapters, native wrappers and method handle intrinsics + // should be generated always. + return Atomic::add(1, &_compilation_id); + } else if (CICountOSR && is_osr) { + id = Atomic::add(1, &_osr_compilation_id); + if (CIStartOSR <= id && id < CIStopOSR) { return id; } } else { - id = ++_compilation_id; - if ((uint)CIStart <= id && id < (uint)CIStop) { + id = Atomic::add(1, &_compilation_id); + if (CIStart <= id && id < CIStop) { return id; } } @@ -1447,6 +1442,11 @@ uint CompileBroker::assign_compile_id(methodHandle method, int osr_bci) { // Method was not in the appropriate compilation range. method->set_not_compilable_quietly(); return 0; +#else + // CICountOSR is a develop flag and set to 'false' by default. In a product built, + // only _compilation_id is incremented. + return Atomic::add(1, &_compilation_id); +#endif } diff --git a/hotspot/src/share/vm/compiler/compileBroker.hpp b/hotspot/src/share/vm/compiler/compileBroker.hpp index a74afb3065f..75cbcafaac0 100644 --- a/hotspot/src/share/vm/compiler/compileBroker.hpp +++ b/hotspot/src/share/vm/compiler/compileBroker.hpp @@ -246,6 +246,8 @@ class CompileBroker: AllStatic { // Compile type Information for print_last_compile() and CompilerCounters enum { no_compile, normal_compile, osr_compile, native_compile }; + static int assign_compile_id (methodHandle method, int osr_bci); + private: static bool _initialized; @@ -258,9 +260,8 @@ class CompileBroker: AllStatic { static AbstractCompiler* _compilers[2]; // These counters are used for assigning id's to each compilation - static uint _compilation_id; - static uint _osr_compilation_id; - static uint _native_compilation_id; + static volatile jint _compilation_id; + static volatile jint _osr_compilation_id; static int _last_compile_type; static int _last_compile_level; @@ -321,7 +322,6 @@ class CompileBroker: AllStatic { static void init_compiler_threads(int c1_compiler_count, int c2_compiler_count); static bool compilation_is_complete (methodHandle method, int osr_bci, int comp_level); static bool compilation_is_prohibited(methodHandle method, int osr_bci, int comp_level); - static uint assign_compile_id (methodHandle method, int osr_bci); static bool is_compile_blocking (methodHandle method, int osr_bci); static void preload_classes (methodHandle method, TRAPS); diff --git a/hotspot/src/share/vm/compiler/compileLog.cpp b/hotspot/src/share/vm/compiler/compileLog.cpp index 2cce602f3ed..bff35b17392 100644 --- a/hotspot/src/share/vm/compiler/compileLog.cpp +++ b/hotspot/src/share/vm/compiler/compileLog.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 diff --git a/hotspot/src/share/vm/compiler/compileLog.hpp b/hotspot/src/share/vm/compiler/compileLog.hpp index 8b740f9f2a2..d0fe07be91f 100644 --- a/hotspot/src/share/vm/compiler/compileLog.hpp +++ b/hotspot/src/share/vm/compiler/compileLog.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 diff --git a/hotspot/src/share/vm/compiler/compilerOracle.cpp b/hotspot/src/share/vm/compiler/compilerOracle.cpp index 8b9141269cc..cb5068dc4c6 100644 --- a/hotspot/src/share/vm/compiler/compilerOracle.cpp +++ b/hotspot/src/share/vm/compiler/compilerOracle.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/hotspot/src/share/vm/compiler/disassembler.cpp b/hotspot/src/share/vm/compiler/disassembler.cpp index 070e0321e08..8495210c384 100644 --- a/hotspot/src/share/vm/compiler/disassembler.cpp +++ b/hotspot/src/share/vm/compiler/disassembler.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 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 diff --git a/hotspot/src/share/vm/compiler/disassembler.hpp b/hotspot/src/share/vm/compiler/disassembler.hpp index c81666ec25d..639fe69c2ea 100644 --- a/hotspot/src/share/vm/compiler/disassembler.hpp +++ b/hotspot/src/share/vm/compiler/disassembler.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 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 diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/adaptiveFreeList.cpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/adaptiveFreeList.cpp index cfba2376ea8..501f15fb3ad 100644 --- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/adaptiveFreeList.cpp +++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/adaptiveFreeList.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/adaptiveFreeList.hpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/adaptiveFreeList.hpp index 7215119aef5..b628cd7f1b4 100644 --- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/adaptiveFreeList.hpp +++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/adaptiveFreeList.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.hpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.hpp index d26959f3d9f..378c5e66436 100644 --- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.hpp +++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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 diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsOopClosures.hpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsOopClosures.hpp index f7730287b94..b910dd6e367 100644 --- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsOopClosures.hpp +++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsOopClosures.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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 diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp index 74c97e8df9d..e625d3a18e6 100644 --- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp +++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.cpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.cpp index f8b0ccb90fe..29939dd86e7 100644 --- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.cpp +++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.hpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.hpp index 5c3f01583ad..cbb59df0e77 100644 --- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.hpp +++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 diff --git a/hotspot/src/share/vm/gc_implementation/g1/collectionSetChooser.cpp b/hotspot/src/share/vm/gc_implementation/g1/collectionSetChooser.cpp index ed4b807fb4a..07b92d0fbe5 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/collectionSetChooser.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/collectionSetChooser.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 diff --git a/hotspot/src/share/vm/gc_implementation/g1/collectionSetChooser.hpp b/hotspot/src/share/vm/gc_implementation/g1/collectionSetChooser.hpp index e9f6f8225af..e177fd1e6ae 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/collectionSetChooser.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/collectionSetChooser.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 diff --git a/hotspot/src/share/vm/gc_implementation/g1/concurrentG1Refine.cpp b/hotspot/src/share/vm/gc_implementation/g1/concurrentG1Refine.cpp index f0b4da8a885..2a6acd4a7ee 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/concurrentG1Refine.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentG1Refine.cpp @@ -27,6 +27,7 @@ #include "gc_implementation/g1/concurrentG1RefineThread.hpp" #include "gc_implementation/g1/g1CollectedHeap.inline.hpp" #include "gc_implementation/g1/g1HotCardCache.hpp" +#include "runtime/java.hpp" ConcurrentG1Refine::ConcurrentG1Refine(G1CollectedHeap* g1h) : _threads(NULL), _n_threads(0), @@ -62,6 +63,10 @@ ConcurrentG1Refine::ConcurrentG1Refine(G1CollectedHeap* g1h) : for (int i = _n_threads - 1; i >= 0; i--) { ConcurrentG1RefineThread* t = new ConcurrentG1RefineThread(this, next, worker_id_offset, i); assert(t != NULL, "Conc refine should have been created"); + if (t->osthread() == NULL) { + vm_shutdown_during_initialization("Could not create ConcurrentG1RefineThread"); + } + assert(t->cg1r() == this, "Conc refine thread should refer to this"); _threads[i] = t; next = t; diff --git a/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp b/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp index 282dd722228..4e458312666 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp @@ -553,6 +553,9 @@ ConcurrentMark::ConcurrentMark(G1CollectedHeap* g1h, ReservedSpace heap_rs) : _cmThread = new ConcurrentMarkThread(this); assert(cmThread() != NULL, "CM Thread should have been created"); assert(cmThread()->cm() != NULL, "CM Thread should refer to this cm"); + if (_cmThread->osthread() == NULL) { + vm_shutdown_during_initialization("Could not create ConcurrentMarkThread"); + } assert(CGC_lock != NULL, "Where's the CGC_lock?"); assert(_markBitMap1.covers(heap_rs), "_markBitMap1 inconsistency"); diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1AllocRegion.hpp b/hotspot/src/share/vm/gc_implementation/g1/g1AllocRegion.hpp index 7823f77e643..3f6e040bf54 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1AllocRegion.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1AllocRegion.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.cpp index 8fe07693d77..c35681f959c 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp index 5ae273b26bd..775f6465d66 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp @@ -2376,25 +2376,6 @@ size_t G1CollectedHeap::recalculate_used() const { return blk.result(); } -size_t G1CollectedHeap::unsafe_max_alloc() { - if (free_regions() > 0) return HeapRegion::GrainBytes; - // otherwise, is there space in the current allocation region? - - // We need to store the current allocation region in a local variable - // here. The problem is that this method doesn't take any locks and - // there may be other threads which overwrite the current allocation - // region field. attempt_allocation(), for example, sets it to NULL - // and this can happen *after* the NULL check here but before the call - // to free(), resulting in a SIGSEGV. Note that this doesn't appear - // to be a problem in the optimized build, since the two loads of the - // current allocation region field are optimized away. - HeapRegion* hr = _mutator_alloc_region.get(); - if (hr == NULL) { - return 0; - } - return hr->free(); -} - bool G1CollectedHeap::should_do_concurrent_full_gc(GCCause::Cause cause) { switch (cause) { case GCCause::_gc_locker: return GCLockerInvokesConcurrent; diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp index 69aa3255605..072013efb64 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp @@ -1183,15 +1183,6 @@ public: // end fields defining the extent of the contiguous allocation region.) // But G1CollectedHeap doesn't yet support this. - // Return an estimate of the maximum allocation that could be performed - // without triggering any collection or expansion activity. In a - // generational collector, for example, this is probably the largest - // allocation that could be supported (without expansion) in the youngest - // generation. It is "unsafe" because no locks are taken; the result - // should be treated as an approximation, not a guarantee, for use in - // heuristic resizing decisions. - virtual size_t unsafe_max_alloc(); - virtual bool is_maximal_no_gc() const { return _g1_storage.uncommitted_size() == 0; } 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 d309e609f4a..498e65f9b8d 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.inline.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1EvacFailure.hpp b/hotspot/src/share/vm/gc_implementation/g1/g1EvacFailure.hpp index 1333f287047..eb64b87126b 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1EvacFailure.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1EvacFailure.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1MonitoringSupport.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1MonitoringSupport.cpp index 01bb43bef45..8bbe4ff94ca 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1MonitoringSupport.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1MonitoringSupport.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1SATBCardTableModRefBS.hpp b/hotspot/src/share/vm/gc_implementation/g1/g1SATBCardTableModRefBS.hpp index a943c9f6db3..0d82c305c24 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1SATBCardTableModRefBS.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1SATBCardTableModRefBS.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 diff --git a/hotspot/src/share/vm/gc_implementation/g1/heapRegionRemSet.hpp b/hotspot/src/share/vm/gc_implementation/g1/heapRegionRemSet.hpp index e40f6195a12..068f64f412e 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/heapRegionRemSet.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegionRemSet.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 diff --git a/hotspot/src/share/vm/gc_implementation/g1/heapRegionSeq.cpp b/hotspot/src/share/vm/gc_implementation/g1/heapRegionSeq.cpp index eaa8e10f38d..c7b42b5cdc4 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/heapRegionSeq.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegionSeq.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 diff --git a/hotspot/src/share/vm/gc_implementation/g1/heapRegionSeq.hpp b/hotspot/src/share/vm/gc_implementation/g1/heapRegionSeq.hpp index b0c3eb48a0b..f58c4f94711 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/heapRegionSeq.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegionSeq.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 diff --git a/hotspot/src/share/vm/gc_implementation/g1/heapRegionSeq.inline.hpp b/hotspot/src/share/vm/gc_implementation/g1/heapRegionSeq.inline.hpp index 96588dea042..0ee93e45b6e 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/heapRegionSeq.inline.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegionSeq.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 diff --git a/hotspot/src/share/vm/gc_implementation/g1/ptrQueue.cpp b/hotspot/src/share/vm/gc_implementation/g1/ptrQueue.cpp index 8841f011e4a..aa8718e9952 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/ptrQueue.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/ptrQueue.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 diff --git a/hotspot/src/share/vm/gc_implementation/g1/ptrQueue.hpp b/hotspot/src/share/vm/gc_implementation/g1/ptrQueue.hpp index e39e38277c7..37f0d6562f8 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/ptrQueue.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/ptrQueue.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 diff --git a/hotspot/src/share/vm/gc_implementation/g1/sparsePRT.cpp b/hotspot/src/share/vm/gc_implementation/g1/sparsePRT.cpp index a08e8a9801e..627c6803902 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/sparsePRT.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/sparsePRT.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 diff --git a/hotspot/src/share/vm/gc_implementation/g1/sparsePRT.hpp b/hotspot/src/share/vm/gc_implementation/g1/sparsePRT.hpp index 6e821f73bbc..86d5db16298 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/sparsePRT.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/sparsePRT.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 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 9268eb78ef4..2e4ed2dfb4a 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/vmStructs_g1.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/vmStructs_g1.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/hotspot/src/share/vm/gc_implementation/parNew/parCardTableModRefBS.cpp b/hotspot/src/share/vm/gc_implementation/parNew/parCardTableModRefBS.cpp index 047c463d39e..dd975440033 100644 --- a/hotspot/src/share/vm/gc_implementation/parNew/parCardTableModRefBS.cpp +++ b/hotspot/src/share/vm/gc_implementation/parNew/parCardTableModRefBS.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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 diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/adjoiningGenerations.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/adjoiningGenerations.cpp index 90bf630fe36..ee9ce8b89d4 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/adjoiningGenerations.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/adjoiningGenerations.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/adjoiningGenerations.hpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/adjoiningGenerations.hpp index 950baa1d53f..e80877e2606 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/adjoiningGenerations.hpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/adjoiningGenerations.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/asPSOldGen.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/asPSOldGen.cpp index 9d2e8182e06..829cb3cfe47 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/asPSOldGen.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/asPSOldGen.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/asPSOldGen.hpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/asPSOldGen.hpp index eaa1f2b5509..56f215230bb 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/asPSOldGen.hpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/asPSOldGen.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/asPSYoungGen.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/asPSYoungGen.cpp index 105772487c0..af5893bcc7b 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/asPSYoungGen.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/asPSYoungGen.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/gcTaskThread.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/gcTaskThread.cpp index 234d5981a24..d8ee14c283d 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/gcTaskThread.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/gcTaskThread.cpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/objectStartArray.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/objectStartArray.cpp index a7713b4dcfa..8dfcf1889e7 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/objectStartArray.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/objectStartArray.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp index f93f2e8991f..6a46f9fd13f 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp @@ -484,10 +484,6 @@ void ParallelScavengeHeap::ensure_parsability(bool retire_tlabs) { young_gen()->eden_space()->ensure_parsability(); } -size_t ParallelScavengeHeap::unsafe_max_alloc() { - return young_gen()->eden_space()->free_in_bytes(); -} - size_t ParallelScavengeHeap::tlab_capacity(Thread* thr) const { return young_gen()->eden_space()->tlab_capacity(thr); } diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.hpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.hpp index 51f40d8c62b..d4c2a1e72e7 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.hpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.hpp @@ -184,8 +184,6 @@ class ParallelScavengeHeap : public CollectedHeap { void accumulate_statistics_all_tlabs(); void resize_all_tlabs(); - size_t unsafe_max_alloc(); - bool supports_tlab_allocation() const { return true; } size_t tlab_capacity(Thread* thr) const; diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/pcTasks.hpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/pcTasks.hpp index f966ccf23e2..f530945e350 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/pcTasks.hpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/pcTasks.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.hpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.hpp index 7d96afbb4df..68b3de470ea 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.hpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweepDecorator.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweepDecorator.cpp index 820696af085..ee43825614b 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweepDecorator.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweepDecorator.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psOldGen.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psOldGen.cpp index 2cb3b35e091..5e970eed4c4 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psOldGen.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psOldGen.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psOldGen.hpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psOldGen.hpp index cf8f574ddfd..90fa0d5632d 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psOldGen.hpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psOldGen.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp index 8e9dd8ddd72..8b4f0bd46f1 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp @@ -2433,20 +2433,6 @@ void PSParallelCompact::marking_phase(ParCompactionManager* cm, _gc_tracer.report_object_count_after_gc(is_alive_closure()); } -void PSParallelCompact::follow_klass(ParCompactionManager* cm, Klass* klass) { - ClassLoaderData* cld = klass->class_loader_data(); - // The actual processing of the klass is done when we - // traverse the list of Klasses in the class loader data. - PSParallelCompact::follow_class_loader(cm, cld); -} - -void PSParallelCompact::adjust_klass(ParCompactionManager* cm, Klass* klass) { - ClassLoaderData* cld = klass->class_loader_data(); - // The actual processing of the klass is done when we - // traverse the list of Klasses in the class loader data. - PSParallelCompact::adjust_class_loader(cm, cld); -} - void PSParallelCompact::follow_class_loader(ParCompactionManager* cm, ClassLoaderData* cld) { PSParallelCompact::MarkAndPushClosure mark_and_push_closure(cm); @@ -2455,13 +2441,6 @@ void PSParallelCompact::follow_class_loader(ParCompactionManager* cm, cld->oops_do(&mark_and_push_closure, &follow_klass_closure, true); } -void PSParallelCompact::adjust_class_loader(ParCompactionManager* cm, - ClassLoaderData* cld) { - cld->oops_do(PSParallelCompact::adjust_pointer_closure(), - PSParallelCompact::adjust_klass_closure(), - true); -} - // This should be moved to the shared markSweep code! class PSAlwaysTrueClosure: public BoolObjectClosure { public: diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.hpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.hpp index 2ba4eb45f5c..0f1b77b92f2 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.hpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.hpp @@ -1200,13 +1200,10 @@ class PSParallelCompact : AllStatic { T* p); template static inline void adjust_pointer(T* p); - static void follow_klass(ParCompactionManager* cm, Klass* klass); - static void adjust_klass(ParCompactionManager* cm, Klass* klass); + static inline void follow_klass(ParCompactionManager* cm, Klass* klass); static void follow_class_loader(ParCompactionManager* cm, ClassLoaderData* klass); - static void adjust_class_loader(ParCompactionManager* cm, - ClassLoaderData* klass); // Compaction support. // Return true if p is in the range [beg_addr, end_addr). @@ -1380,6 +1377,11 @@ inline void PSParallelCompact::adjust_pointer(T* p) { } } +inline void PSParallelCompact::follow_klass(ParCompactionManager* cm, Klass* klass) { + oop holder = klass->klass_holder(); + PSParallelCompact::mark_and_push(cm, &holder); +} + template inline void PSParallelCompact::KeepAliveClosure::do_oop_work(T* p) { mark_and_push(_compaction_manager, p); diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp index 66b23c4dbe8..8f47d582fd6 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp @@ -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 @@ -466,10 +466,12 @@ bool PSScavenge::invoke_no_policy() { } } - GCTraceTime tm("StringTable", false, false, &_gc_timer); - // Unlink any dead interned Strings and process the remaining live ones. - PSScavengeRootsClosure root_closure(promotion_manager); - StringTable::unlink_or_oops_do(&_is_alive_closure, &root_closure); + { + GCTraceTime tm("StringTable", false, false, &_gc_timer); + // Unlink any dead interned Strings and process the remaining live ones. + PSScavengeRootsClosure root_closure(promotion_manager); + StringTable::unlink_or_oops_do(&_is_alive_closure, &root_closure); + } // Finally, flush the promotion_manager's labs, and deallocate its stacks. promotion_failure_occurred = PSPromotionManager::post_scavenge(_gc_tracer); diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psTasks.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psTasks.cpp index 00e466a3ea4..6470281a992 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psTasks.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psTasks.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psTasks.hpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psTasks.hpp index 7ae1f8a0c28..24be15a4912 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psTasks.hpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psTasks.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psYoungGen.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psYoungGen.cpp index c1f5c298794..74ac4477c96 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psYoungGen.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psYoungGen.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 diff --git a/hotspot/src/share/vm/gc_implementation/shared/allocationStats.cpp b/hotspot/src/share/vm/gc_implementation/shared/allocationStats.cpp index 7cc37fd9453..1cbfb120aa4 100644 --- a/hotspot/src/share/vm/gc_implementation/shared/allocationStats.cpp +++ b/hotspot/src/share/vm/gc_implementation/shared/allocationStats.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 diff --git a/hotspot/src/share/vm/gc_implementation/shared/concurrentGCThread.hpp b/hotspot/src/share/vm/gc_implementation/shared/concurrentGCThread.hpp index 6530d23b624..4172a95cced 100644 --- a/hotspot/src/share/vm/gc_implementation/shared/concurrentGCThread.hpp +++ b/hotspot/src/share/vm/gc_implementation/shared/concurrentGCThread.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 diff --git a/hotspot/src/share/vm/gc_implementation/shared/gSpaceCounters.cpp b/hotspot/src/share/vm/gc_implementation/shared/gSpaceCounters.cpp index 506322de521..b1ae78d3087 100644 --- a/hotspot/src/share/vm/gc_implementation/shared/gSpaceCounters.cpp +++ b/hotspot/src/share/vm/gc_implementation/shared/gSpaceCounters.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 diff --git a/hotspot/src/share/vm/gc_implementation/shared/gSpaceCounters.hpp b/hotspot/src/share/vm/gc_implementation/shared/gSpaceCounters.hpp index c54e773c364..7a5fdf9ee57 100644 --- a/hotspot/src/share/vm/gc_implementation/shared/gSpaceCounters.hpp +++ b/hotspot/src/share/vm/gc_implementation/shared/gSpaceCounters.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 diff --git a/hotspot/src/share/vm/gc_implementation/shared/gcAdaptivePolicyCounters.hpp b/hotspot/src/share/vm/gc_implementation/shared/gcAdaptivePolicyCounters.hpp index 5024ab9e7ab..70e657d2947 100644 --- a/hotspot/src/share/vm/gc_implementation/shared/gcAdaptivePolicyCounters.hpp +++ b/hotspot/src/share/vm/gc_implementation/shared/gcAdaptivePolicyCounters.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/hotspot/src/share/vm/gc_implementation/shared/immutableSpace.cpp b/hotspot/src/share/vm/gc_implementation/shared/immutableSpace.cpp index c844a3e596d..b1563ac8686 100644 --- a/hotspot/src/share/vm/gc_implementation/shared/immutableSpace.cpp +++ b/hotspot/src/share/vm/gc_implementation/shared/immutableSpace.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 diff --git a/hotspot/src/share/vm/gc_implementation/shared/isGCActiveMark.hpp b/hotspot/src/share/vm/gc_implementation/shared/isGCActiveMark.hpp index c56cbafeb2e..dc1041b28dd 100644 --- a/hotspot/src/share/vm/gc_implementation/shared/isGCActiveMark.hpp +++ b/hotspot/src/share/vm/gc_implementation/shared/isGCActiveMark.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 diff --git a/hotspot/src/share/vm/gc_implementation/shared/markSweep.inline.hpp b/hotspot/src/share/vm/gc_implementation/shared/markSweep.inline.hpp index e70e3af1bc1..270d9de71bf 100644 --- a/hotspot/src/share/vm/gc_implementation/shared/markSweep.inline.hpp +++ b/hotspot/src/share/vm/gc_implementation/shared/markSweep.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 diff --git a/hotspot/src/share/vm/gc_implementation/shared/mutableNUMASpace.cpp b/hotspot/src/share/vm/gc_implementation/shared/mutableNUMASpace.cpp index d3d758b79bd..ba7d00d68ba 100644 --- a/hotspot/src/share/vm/gc_implementation/shared/mutableNUMASpace.cpp +++ b/hotspot/src/share/vm/gc_implementation/shared/mutableNUMASpace.cpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/hotspot/src/share/vm/gc_implementation/shared/mutableNUMASpace.hpp b/hotspot/src/share/vm/gc_implementation/shared/mutableNUMASpace.hpp index 5621c077c38..c79f2465ac1 100644 --- a/hotspot/src/share/vm/gc_implementation/shared/mutableNUMASpace.hpp +++ b/hotspot/src/share/vm/gc_implementation/shared/mutableNUMASpace.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/hotspot/src/share/vm/gc_implementation/shared/mutableSpace.cpp b/hotspot/src/share/vm/gc_implementation/shared/mutableSpace.cpp index d50edac13ca..7e5b5a81125 100644 --- a/hotspot/src/share/vm/gc_implementation/shared/mutableSpace.cpp +++ b/hotspot/src/share/vm/gc_implementation/shared/mutableSpace.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 diff --git a/hotspot/src/share/vm/gc_implementation/shared/parGCAllocBuffer.hpp b/hotspot/src/share/vm/gc_implementation/shared/parGCAllocBuffer.hpp index aced447c9a1..80a4a223cbd 100644 --- a/hotspot/src/share/vm/gc_implementation/shared/parGCAllocBuffer.hpp +++ b/hotspot/src/share/vm/gc_implementation/shared/parGCAllocBuffer.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 diff --git a/hotspot/src/share/vm/gc_implementation/shared/spaceCounters.cpp b/hotspot/src/share/vm/gc_implementation/shared/spaceCounters.cpp index f606e99e9a1..5a20c0dd4b9 100644 --- a/hotspot/src/share/vm/gc_implementation/shared/spaceCounters.cpp +++ b/hotspot/src/share/vm/gc_implementation/shared/spaceCounters.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 diff --git a/hotspot/src/share/vm/gc_implementation/shared/spaceCounters.hpp b/hotspot/src/share/vm/gc_implementation/shared/spaceCounters.hpp index 17302d420b2..e02bc28da34 100644 --- a/hotspot/src/share/vm/gc_implementation/shared/spaceCounters.hpp +++ b/hotspot/src/share/vm/gc_implementation/shared/spaceCounters.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 diff --git a/hotspot/src/share/vm/gc_interface/collectedHeap.hpp b/hotspot/src/share/vm/gc_interface/collectedHeap.hpp index 1e60ed116d8..1563b9ef743 100644 --- a/hotspot/src/share/vm/gc_interface/collectedHeap.hpp +++ b/hotspot/src/share/vm/gc_interface/collectedHeap.hpp @@ -389,15 +389,6 @@ class CollectedHeap : public CHeapObj { // allocation from them and necessitating allocation of new TLABs. virtual void ensure_parsability(bool retire_tlabs); - // Return an estimate of the maximum allocation that could be performed - // without triggering any collection or expansion activity. In a - // generational collector, for example, this is probably the largest - // allocation that could be supported (without expansion) in the youngest - // generation. It is "unsafe" because no locks are taken; the result - // should be treated as an approximation, not a guarantee, for use in - // heuristic resizing decisions. - virtual size_t unsafe_max_alloc() = 0; - // Section on thread-local allocation buffers (TLABs) // If the heap supports thread-local allocation buffers, it should override // the following methods: diff --git a/hotspot/src/share/vm/gc_interface/collectedHeap.inline.hpp b/hotspot/src/share/vm/gc_interface/collectedHeap.inline.hpp index d17b82f2158..0bf322f82dd 100644 --- a/hotspot/src/share/vm/gc_interface/collectedHeap.inline.hpp +++ b/hotspot/src/share/vm/gc_interface/collectedHeap.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 diff --git a/hotspot/src/share/vm/gc_interface/gcCause.cpp b/hotspot/src/share/vm/gc_interface/gcCause.cpp index e7e7e43f440..2588621aa6b 100644 --- a/hotspot/src/share/vm/gc_interface/gcCause.cpp +++ b/hotspot/src/share/vm/gc_interface/gcCause.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 diff --git a/hotspot/src/share/vm/gc_interface/gcCause.hpp b/hotspot/src/share/vm/gc_interface/gcCause.hpp index 06f11882c95..809bab4c46d 100644 --- a/hotspot/src/share/vm/gc_interface/gcCause.hpp +++ b/hotspot/src/share/vm/gc_interface/gcCause.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 diff --git a/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp b/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp index 538b836f08a..16e8dabba5c 100644 --- a/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp +++ b/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 diff --git a/hotspot/src/share/vm/interpreter/cppInterpreter.hpp b/hotspot/src/share/vm/interpreter/cppInterpreter.hpp index 71f78840b95..0e05c34601e 100644 --- a/hotspot/src/share/vm/interpreter/cppInterpreter.hpp +++ b/hotspot/src/share/vm/interpreter/cppInterpreter.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/interpreter/interpreter.hpp b/hotspot/src/share/vm/interpreter/interpreter.hpp index 1fb4ac5c8ce..cc26b378d73 100644 --- a/hotspot/src/share/vm/interpreter/interpreter.hpp +++ b/hotspot/src/share/vm/interpreter/interpreter.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/interpreter/linkResolver.cpp b/hotspot/src/share/vm/interpreter/linkResolver.cpp index 573ccc1cf62..b63e03bdcf6 100644 --- a/hotspot/src/share/vm/interpreter/linkResolver.cpp +++ b/hotspot/src/share/vm/interpreter/linkResolver.cpp @@ -242,8 +242,20 @@ void LinkResolver::resolve_klass(KlassHandle& result, constantPoolHandle pool, i // Look up method in klasses, including static methods // Then look up local default methods -void LinkResolver::lookup_method_in_klasses(methodHandle& result, KlassHandle klass, Symbol* name, Symbol* signature, bool checkpolymorphism, TRAPS) { +void LinkResolver::lookup_method_in_klasses(methodHandle& result, KlassHandle klass, Symbol* name, Symbol* signature, bool checkpolymorphism, bool in_imethod_resolve, TRAPS) { Method* result_oop = klass->uncached_lookup_method(name, signature); + + // JDK 8, JVMS 5.4.3.4: Interface method resolution should + // ignore static and non-public methods of java.lang.Object, + // like clone, finalize, registerNatives. + if (in_imethod_resolve && + result_oop != NULL && + klass->is_interface() && + (result_oop->is_static() || !result_oop->is_public()) && + result_oop->method_holder() == SystemDictionary::Object_klass()) { + result_oop = NULL; + } + if (result_oop == NULL) { Array* default_methods = InstanceKlass::cast(klass())->default_methods(); if (default_methods != NULL) { @@ -288,7 +300,7 @@ int LinkResolver::vtable_index_of_interface_method(KlassHandle klass, Symbol* signature = resolved_method->signature(); // First check in default method array - if (!resolved_method->is_abstract() && + if (!resolved_method->is_abstract() && (InstanceKlass::cast(klass())->default_methods() != NULL)) { int index = InstanceKlass::find_method_index(InstanceKlass::cast(klass())->default_methods(), name, signature); if (index >= 0 ) { @@ -306,7 +318,11 @@ int LinkResolver::vtable_index_of_interface_method(KlassHandle klass, void LinkResolver::lookup_method_in_interfaces(methodHandle& result, KlassHandle klass, Symbol* name, Symbol* signature, TRAPS) { InstanceKlass *ik = InstanceKlass::cast(klass()); - result = methodHandle(THREAD, ik->lookup_method_in_all_interfaces(name, signature)); + + // Specify 'true' in order to skip default methods when searching the + // interfaces. Function lookup_method_in_klasses() already looked for + // the method in the default methods table. + result = methodHandle(THREAD, ik->lookup_method_in_all_interfaces(name, signature, true)); } void LinkResolver::lookup_polymorphic_method(methodHandle& result, @@ -420,28 +436,18 @@ void LinkResolver::check_method_accessability(KlassHandle ref_klass, AccessFlags flags = sel_method->access_flags(); - // Special case #1: arrays always override "clone". JVMS 2.15. + // Special case: arrays always override "clone". JVMS 2.15. // If the resolved klass is an array class, and the declaring class // is java.lang.Object and the method is "clone", set the flags // to public. - // Special case #2: If the resolved klass is an interface, and - // the declaring class is java.lang.Object, and the method is - // "clone" or "finalize", set the flags to public. If the - // resolved interface does not contain "clone" or "finalize" - // methods, the method/interface method resolution looks to - // the interface's super class, java.lang.Object. With JDK 8 - // interface accessability check requirement, special casing - // this scenario is necessary to avoid an IAE. // - // We'll check for each method name first and then java.lang.Object - // to best short-circuit out of these tests. - if (((sel_method->name() == vmSymbols::clone_name() && - (resolved_klass->oop_is_array() || resolved_klass->is_interface())) || - (sel_method->name() == vmSymbols::finalize_method_name() && - resolved_klass->is_interface())) && - sel_klass() == SystemDictionary::Object_klass()) { + // We'll check for the method name first, as that's most likely + // to be false (so we'll short-circuit out of these tests). + if (sel_method->name() == vmSymbols::clone_name() && + sel_klass() == SystemDictionary::Object_klass() && + resolved_klass->oop_is_array()) { // We need to change "protected" to "public". - assert(flags.is_protected(), "clone or finalize not protected?"); + assert(flags.is_protected(), "clone not protected?"); jint new_flags = flags.as_int(); new_flags = new_flags & (~JVM_ACC_PROTECTED); new_flags = new_flags | JVM_ACC_PUBLIC; @@ -531,7 +537,7 @@ void LinkResolver::resolve_method(methodHandle& resolved_method, KlassHandle res } // 2. lookup method in resolved klass and its super klasses - lookup_method_in_klasses(resolved_method, resolved_klass, method_name, method_signature, true, CHECK); + lookup_method_in_klasses(resolved_method, resolved_klass, method_name, method_signature, true, false, CHECK); if (resolved_method.is_null()) { // not found in the class hierarchy // 3. lookup method in all the interfaces implemented by the resolved klass @@ -618,7 +624,7 @@ void LinkResolver::resolve_interface_method(methodHandle& resolved_method, bool check_access, bool nostatics, TRAPS) { - // check if klass is interface + // check if klass is interface if (!resolved_klass->is_interface()) { ResourceMark rm(THREAD); char buf[200]; @@ -628,7 +634,7 @@ void LinkResolver::resolve_interface_method(methodHandle& resolved_method, // lookup method in this interface or its super, java.lang.Object // JDK8: also look for static methods - lookup_method_in_klasses(resolved_method, resolved_klass, method_name, method_signature, false, CHECK); + lookup_method_in_klasses(resolved_method, resolved_klass, method_name, method_signature, false, true, CHECK); if (resolved_method.is_null()) { // lookup method in all the super-interfaces @@ -943,8 +949,17 @@ void LinkResolver::linktime_resolve_special_method(methodHandle& resolved_method Klass *klass_to_check = !InstanceKlass::cast(current_klass())->is_anonymous() ? current_klass() : InstanceKlass::cast(current_klass())->host_klass(); + // As of the fix for 4486457 we disable verification for all of the + // dynamically-generated bytecodes associated with the 1.4 + // reflection implementation, not just those associated with + // sun/reflect/SerializationConstructorAccessor. + bool is_reflect = JDK_Version::is_gte_jdk14x_version() && + UseNewReflection && + klass_to_check->is_subclass_of( + SystemDictionary::reflect_MagicAccessorImpl_klass()); - if (!InstanceKlass::cast(klass_to_check)->is_same_or_direct_interface(resolved_klass())) { + if (!is_reflect && + !InstanceKlass::cast(klass_to_check)->is_same_or_direct_interface(resolved_klass())) { ResourceMark rm(THREAD); char buf[200]; jio_snprintf(buf, sizeof(buf), @@ -1276,8 +1291,11 @@ void LinkResolver::runtime_resolve_interface_method(CallInfo& result, methodHand resolved_klass()->external_name()); THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); } + // do lookup based on receiver klass methodHandle sel_method; + // This search must match the linktime preparation search for itable initialization + // to correctly enforce loader constraints for interface method inheritance lookup_instance_method_in_klasses(sel_method, recv_klass, resolved_method->name(), resolved_method->signature(), CHECK); diff --git a/hotspot/src/share/vm/interpreter/linkResolver.hpp b/hotspot/src/share/vm/interpreter/linkResolver.hpp index 4b13de8789f..f598380591b 100644 --- a/hotspot/src/share/vm/interpreter/linkResolver.hpp +++ b/hotspot/src/share/vm/interpreter/linkResolver.hpp @@ -124,7 +124,7 @@ class LinkResolver: AllStatic { friend class klassItable; private: - static void lookup_method_in_klasses (methodHandle& result, KlassHandle klass, Symbol* name, Symbol* signature, bool checkpolymorphism, TRAPS); + static void lookup_method_in_klasses (methodHandle& result, KlassHandle klass, Symbol* name, Symbol* signature, bool checkpolymorphism, bool in_imethod_resolve, TRAPS); static void lookup_instance_method_in_klasses (methodHandle& result, KlassHandle klass, Symbol* name, Symbol* signature, TRAPS); static void lookup_method_in_interfaces (methodHandle& result, KlassHandle klass, Symbol* name, Symbol* signature, TRAPS); static void lookup_polymorphic_method (methodHandle& result, KlassHandle klass, Symbol* name, Symbol* signature, diff --git a/hotspot/src/share/vm/interpreter/templateInterpreter.hpp b/hotspot/src/share/vm/interpreter/templateInterpreter.hpp index 838e2e08473..48e0e217091 100644 --- a/hotspot/src/share/vm/interpreter/templateInterpreter.hpp +++ b/hotspot/src/share/vm/interpreter/templateInterpreter.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/interpreter/templateInterpreterGenerator.hpp b/hotspot/src/share/vm/interpreter/templateInterpreterGenerator.hpp index a80caa96409..ee1b0f5acc5 100644 --- a/hotspot/src/share/vm/interpreter/templateInterpreterGenerator.hpp +++ b/hotspot/src/share/vm/interpreter/templateInterpreterGenerator.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/interpreter/templateTable.hpp b/hotspot/src/share/vm/interpreter/templateTable.hpp index 11c875ef32d..d636465a29d 100644 --- a/hotspot/src/share/vm/interpreter/templateTable.hpp +++ b/hotspot/src/share/vm/interpreter/templateTable.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/memory/allocation.cpp b/hotspot/src/share/vm/memory/allocation.cpp index 36c0d06c3fd..98410227a86 100644 --- a/hotspot/src/share/vm/memory/allocation.cpp +++ b/hotspot/src/share/vm/memory/allocation.cpp @@ -71,9 +71,8 @@ bool MetaspaceObj::is_shared() const { return MetaspaceShared::is_in_shared_space(this); } - bool MetaspaceObj::is_metaspace_object() const { - return Metaspace::contains((void*)this); + return ClassLoaderDataGraph::contains((void*)this); } void MetaspaceObj::print_address_on(outputStream* st) const { @@ -140,7 +139,7 @@ void ResourceObj::operator delete [](void* p) { void ResourceObj::set_allocation_type(address res, allocation_type type) { // Set allocation type in the resource object uintptr_t allocation = (uintptr_t)res; - assert((allocation & allocation_mask) == 0, "address should be aligned to 4 bytes at least"); + assert((allocation & allocation_mask) == 0, err_msg("address should be aligned to 4 bytes at least: " PTR_FORMAT, res)); assert(type <= allocation_mask, "incorrect allocation type"); ResourceObj* resobj = (ResourceObj *)res; resobj->_allocation_t[0] = ~(allocation + type); diff --git a/hotspot/src/share/vm/memory/allocation.hpp b/hotspot/src/share/vm/memory/allocation.hpp index 739753311c5..590b74f5ddf 100644 --- a/hotspot/src/share/vm/memory/allocation.hpp +++ b/hotspot/src/share/vm/memory/allocation.hpp @@ -264,7 +264,7 @@ class ClassLoaderData; class MetaspaceObj { public: - bool is_metaspace_object() const; // more specific test but slower + bool is_metaspace_object() const; bool is_shared() const; void print_address_on(outputStream* st) const; // nonvirtual address printing diff --git a/hotspot/src/share/vm/memory/binaryTreeDictionary.hpp b/hotspot/src/share/vm/memory/binaryTreeDictionary.hpp index 460a4ea29e1..23d7fe0ae24 100644 --- a/hotspot/src/share/vm/memory/binaryTreeDictionary.hpp +++ b/hotspot/src/share/vm/memory/binaryTreeDictionary.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 diff --git a/hotspot/src/share/vm/memory/blockOffsetTable.cpp b/hotspot/src/share/vm/memory/blockOffsetTable.cpp index 841794a0164..c0b35cdde0f 100644 --- a/hotspot/src/share/vm/memory/blockOffsetTable.cpp +++ b/hotspot/src/share/vm/memory/blockOffsetTable.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 diff --git a/hotspot/src/share/vm/memory/defNewGeneration.cpp b/hotspot/src/share/vm/memory/defNewGeneration.cpp index f5fdb4427ce..51c672e4e7c 100644 --- a/hotspot/src/share/vm/memory/defNewGeneration.cpp +++ b/hotspot/src/share/vm/memory/defNewGeneration.cpp @@ -667,9 +667,6 @@ void DefNewGeneration::collect(bool full, // for full GC's. AdaptiveSizePolicy* size_policy = gch->gen_policy()->size_policy(); size_policy->reset_gc_overhead_limit_count(); - if (PrintGC && !PrintGCDetails) { - gch->print_heap_change(gch_prev_used); - } assert(!gch->incremental_collection_failed(), "Should be clear"); } else { assert(_promo_failure_scan_stack.is_empty(), "post condition"); @@ -695,6 +692,9 @@ void DefNewGeneration::collect(bool full, // Reset the PromotionFailureALot counters. NOT_PRODUCT(Universe::heap()->reset_promotion_should_fail();) } + if (PrintGC && !PrintGCDetails) { + gch->print_heap_change(gch_prev_used); + } // set new iteration safe limit for the survivor spaces from()->set_concurrent_iteration_safe_limit(from()->top()); to()->set_concurrent_iteration_safe_limit(to()->top()); diff --git a/hotspot/src/share/vm/memory/freeBlockDictionary.cpp b/hotspot/src/share/vm/memory/freeBlockDictionary.cpp index 7cb2b17b57b..915ec206395 100644 --- a/hotspot/src/share/vm/memory/freeBlockDictionary.cpp +++ b/hotspot/src/share/vm/memory/freeBlockDictionary.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 diff --git a/hotspot/src/share/vm/memory/freeList.cpp b/hotspot/src/share/vm/memory/freeList.cpp index 78785e8809f..1d521885925 100644 --- a/hotspot/src/share/vm/memory/freeList.cpp +++ b/hotspot/src/share/vm/memory/freeList.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 diff --git a/hotspot/src/share/vm/memory/freeList.hpp b/hotspot/src/share/vm/memory/freeList.hpp index e69c8a32f0e..e971471f9c7 100644 --- a/hotspot/src/share/vm/memory/freeList.hpp +++ b/hotspot/src/share/vm/memory/freeList.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 diff --git a/hotspot/src/share/vm/memory/gcLocker.cpp b/hotspot/src/share/vm/memory/gcLocker.cpp index 1b0c94ee171..09fb73bb035 100644 --- a/hotspot/src/share/vm/memory/gcLocker.cpp +++ b/hotspot/src/share/vm/memory/gcLocker.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/memory/gcLocker.hpp b/hotspot/src/share/vm/memory/gcLocker.hpp index 45b8a8f89e7..60bebdf0fa4 100644 --- a/hotspot/src/share/vm/memory/gcLocker.hpp +++ b/hotspot/src/share/vm/memory/gcLocker.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/memory/genCollectedHeap.cpp b/hotspot/src/share/vm/memory/genCollectedHeap.cpp index aa6f24bd23e..49c5965a89b 100644 --- a/hotspot/src/share/vm/memory/genCollectedHeap.cpp +++ b/hotspot/src/share/vm/memory/genCollectedHeap.cpp @@ -673,10 +673,6 @@ HeapWord** GenCollectedHeap::end_addr() const { return _gens[0]->end_addr(); } -size_t GenCollectedHeap::unsafe_max_alloc() { - return _gens[0]->unsafe_max_alloc_nogc(); -} - // public collection interfaces void GenCollectedHeap::collect(GCCause::Cause cause) { diff --git a/hotspot/src/share/vm/memory/genCollectedHeap.hpp b/hotspot/src/share/vm/memory/genCollectedHeap.hpp index 5cd8a71280a..b80fd718bd8 100644 --- a/hotspot/src/share/vm/memory/genCollectedHeap.hpp +++ b/hotspot/src/share/vm/memory/genCollectedHeap.hpp @@ -166,14 +166,6 @@ public: HeapWord** top_addr() const; HeapWord** end_addr() const; - // Return an estimate of the maximum allocation that could be performed - // without triggering any collection activity. In a generational - // collector, for example, this is probably the largest allocation that - // could be supported in the youngest generation. It is "unsafe" because - // no locks are taken; the result should be treated as an approximation, - // not a guarantee. - size_t unsafe_max_alloc(); - // Does this heap support heap inspection? (+PrintClassHistogram) virtual bool supports_heap_inspection() const { return true; } diff --git a/hotspot/src/share/vm/memory/genRemSet.cpp b/hotspot/src/share/vm/memory/genRemSet.cpp index c496deafc03..bb3149f5a85 100644 --- a/hotspot/src/share/vm/memory/genRemSet.cpp +++ b/hotspot/src/share/vm/memory/genRemSet.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 diff --git a/hotspot/src/share/vm/memory/genRemSet.hpp b/hotspot/src/share/vm/memory/genRemSet.hpp index 44a43540769..a275320c8da 100644 --- a/hotspot/src/share/vm/memory/genRemSet.hpp +++ b/hotspot/src/share/vm/memory/genRemSet.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 diff --git a/hotspot/src/share/vm/memory/generation.hpp b/hotspot/src/share/vm/memory/generation.hpp index 290cce583a0..e3bceb4446c 100644 --- a/hotspot/src/share/vm/memory/generation.hpp +++ b/hotspot/src/share/vm/memory/generation.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/memory/generationSpec.cpp b/hotspot/src/share/vm/memory/generationSpec.cpp index d97a56fbbcc..128387cc952 100644 --- a/hotspot/src/share/vm/memory/generationSpec.cpp +++ b/hotspot/src/share/vm/memory/generationSpec.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 diff --git a/hotspot/src/share/vm/memory/heap.hpp b/hotspot/src/share/vm/memory/heap.hpp index 725592e67be..29e76d7dc62 100644 --- a/hotspot/src/share/vm/memory/heap.hpp +++ b/hotspot/src/share/vm/memory/heap.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/memory/iterator.cpp b/hotspot/src/share/vm/memory/iterator.cpp index 545ab921363..f69eb4ed75d 100644 --- a/hotspot/src/share/vm/memory/iterator.cpp +++ b/hotspot/src/share/vm/memory/iterator.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/memory/iterator.hpp b/hotspot/src/share/vm/memory/iterator.hpp index e590a3e9be2..dd98234d31e 100644 --- a/hotspot/src/share/vm/memory/iterator.hpp +++ b/hotspot/src/share/vm/memory/iterator.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/memory/metachunk.hpp b/hotspot/src/share/vm/memory/metachunk.hpp index 3bd4d15bca8..e873dc6a32c 100644 --- a/hotspot/src/share/vm/memory/metachunk.hpp +++ b/hotspot/src/share/vm/memory/metachunk.hpp @@ -143,6 +143,8 @@ class Metachunk : public Metabase { void set_is_tagged_free(bool v) { _is_tagged_free = v; } #endif + bool contains(const void* ptr) { return bottom() <= ptr && ptr < _top; } + NOT_PRODUCT(void mangle();) void print_on(outputStream* st) const; diff --git a/hotspot/src/share/vm/memory/metaspace.cpp b/hotspot/src/share/vm/memory/metaspace.cpp index 826dde3838c..5a7e4ec2fb1 100644 --- a/hotspot/src/share/vm/memory/metaspace.cpp +++ b/hotspot/src/share/vm/memory/metaspace.cpp @@ -287,7 +287,7 @@ class VirtualSpaceNode : public CHeapObj { VirtualSpace* virtual_space() const { return (VirtualSpace*) &_virtual_space; } // Returns true if "word_size" is available in the VirtualSpace - bool is_available(size_t word_size) { return _top + word_size <= end(); } + bool is_available(size_t word_size) { return word_size <= pointer_delta(end(), _top, sizeof(MetaWord)); } MetaWord* top() const { return _top; } void inc_top(size_t word_size) { _top += word_size; } @@ -513,8 +513,6 @@ class VirtualSpaceList : public CHeapObj { // Unlink empty VirtualSpaceNodes and free it. void purge(ChunkManager* chunk_manager); - bool contains(const void *ptr); - void print_on(outputStream* st) const; class VirtualSpaceListIterator : public StackObj { @@ -558,7 +556,7 @@ class SpaceManager : public CHeapObj { private: - // protects allocations and contains. + // protects allocations Mutex* const _lock; // Type of metadata allocated. @@ -595,7 +593,11 @@ class SpaceManager : public CHeapObj { private: // Accessors Metachunk* chunks_in_use(ChunkIndex index) const { return _chunks_in_use[index]; } - void set_chunks_in_use(ChunkIndex index, Metachunk* v) { _chunks_in_use[index] = v; } + void set_chunks_in_use(ChunkIndex index, Metachunk* v) { + // ensure lock-free iteration sees fully initialized node + OrderAccess::storestore(); + _chunks_in_use[index] = v; + } BlockFreelist* block_freelists() const { return (BlockFreelist*) &_block_freelists; @@ -708,6 +710,8 @@ class SpaceManager : public CHeapObj { void print_on(outputStream* st) const; void locked_print_chunks_in_use_on(outputStream* st) const; + bool contains(const void *ptr); + void verify(); void verify_chunk_size(Metachunk* chunk); NOT_PRODUCT(void mangle_freed_chunks();) @@ -1159,8 +1163,6 @@ bool VirtualSpaceList::create_new_virtual_space(size_t vs_word_size) { } else { assert(new_entry->reserved_words() == vs_word_size, "Reserved memory size differs from requested memory size"); - // ensure lock-free iteration sees fully initialized node - OrderAccess::storestore(); link_vs(new_entry); return true; } @@ -1287,19 +1289,6 @@ void VirtualSpaceList::print_on(outputStream* st) const { } } -bool VirtualSpaceList::contains(const void *ptr) { - VirtualSpaceNode* list = virtual_space_list(); - VirtualSpaceListIterator iter(list); - while (iter.repeat()) { - VirtualSpaceNode* node = iter.get_next(); - if (node->reserved()->contains(ptr)) { - return true; - } - } - return false; -} - - // MetaspaceGC methods // VM_CollectForMetadataAllocation is the vm operation used to GC. @@ -2392,6 +2381,21 @@ MetaWord* SpaceManager::allocate_work(size_t word_size) { return result; } +// This function looks at the chunks in the metaspace without locking. +// The chunks are added with store ordering and not deleted except for at +// unloading time. +bool SpaceManager::contains(const void *ptr) { + for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) + { + Metachunk* curr = chunks_in_use(i); + while (curr != NULL) { + if (curr->contains(ptr)) return true; + curr = curr->next(); + } + } + return false; +} + void SpaceManager::verify() { // If there are blocks in the dictionary, then // verfication of chunks does not work since @@ -3463,17 +3467,12 @@ void Metaspace::print_on(outputStream* out) const { } } -bool Metaspace::contains(const void * ptr) { - if (MetaspaceShared::is_in_shared_space(ptr)) { - return true; +bool Metaspace::contains(const void* ptr) { + if (vsm()->contains(ptr)) return true; + if (using_class_space()) { + return class_vsm()->contains(ptr); } - // This is checked while unlocked. As long as the virtualspaces are added - // at the end, the pointer will be in one of them. The virtual spaces - // aren't deleted presently. When they are, some sort of locking might - // be needed. Note, locking this can cause inversion problems with the - // caller in MetaspaceObj::is_metadata() function. - return space_list()->contains(ptr) || - (using_class_space() && class_space_list()->contains(ptr)); + return false; } void Metaspace::verify() { @@ -3641,10 +3640,82 @@ class TestVirtualSpaceNodeTest { } } + +#define assert_is_available_positive(word_size) \ + assert(vsn.is_available(word_size), \ + err_msg(#word_size ": " PTR_FORMAT " bytes were not available in " \ + "VirtualSpaceNode [" PTR_FORMAT ", " PTR_FORMAT ")", \ + (uintptr_t)(word_size * BytesPerWord), vsn.bottom(), vsn.end())); + +#define assert_is_available_negative(word_size) \ + assert(!vsn.is_available(word_size), \ + err_msg(#word_size ": " PTR_FORMAT " bytes should not be available in " \ + "VirtualSpaceNode [" PTR_FORMAT ", " PTR_FORMAT ")", \ + (uintptr_t)(word_size * BytesPerWord), vsn.bottom(), vsn.end())); + + static void test_is_available_positive() { + // Reserve some memory. + VirtualSpaceNode vsn(os::vm_allocation_granularity()); + assert(vsn.initialize(), "Failed to setup VirtualSpaceNode"); + + // Commit some memory. + size_t commit_word_size = os::vm_allocation_granularity() / BytesPerWord; + bool expanded = vsn.expand_by(commit_word_size, commit_word_size); + assert(expanded, "Failed to commit"); + + // Check that is_available accepts the committed size. + assert_is_available_positive(commit_word_size); + + // Check that is_available accepts half the committed size. + size_t expand_word_size = commit_word_size / 2; + assert_is_available_positive(expand_word_size); + } + + static void test_is_available_negative() { + // Reserve some memory. + VirtualSpaceNode vsn(os::vm_allocation_granularity()); + assert(vsn.initialize(), "Failed to setup VirtualSpaceNode"); + + // Commit some memory. + size_t commit_word_size = os::vm_allocation_granularity() / BytesPerWord; + bool expanded = vsn.expand_by(commit_word_size, commit_word_size); + assert(expanded, "Failed to commit"); + + // Check that is_available doesn't accept a too large size. + size_t two_times_commit_word_size = commit_word_size * 2; + assert_is_available_negative(two_times_commit_word_size); + } + + static void test_is_available_overflow() { + // Reserve some memory. + VirtualSpaceNode vsn(os::vm_allocation_granularity()); + assert(vsn.initialize(), "Failed to setup VirtualSpaceNode"); + + // Commit some memory. + size_t commit_word_size = os::vm_allocation_granularity() / BytesPerWord; + bool expanded = vsn.expand_by(commit_word_size, commit_word_size); + assert(expanded, "Failed to commit"); + + // Calculate a size that will overflow the virtual space size. + void* virtual_space_max = (void*)(uintptr_t)-1; + size_t bottom_to_max = pointer_delta(virtual_space_max, vsn.bottom(), 1); + size_t overflow_size = bottom_to_max + BytesPerWord; + size_t overflow_word_size = overflow_size / BytesPerWord; + + // Check that is_available can handle the overflow. + assert_is_available_negative(overflow_word_size); + } + + static void test_is_available() { + TestVirtualSpaceNodeTest::test_is_available_positive(); + TestVirtualSpaceNodeTest::test_is_available_negative(); + TestVirtualSpaceNodeTest::test_is_available_overflow(); + } }; void TestVirtualSpaceNode_test() { TestVirtualSpaceNodeTest::test(); + TestVirtualSpaceNodeTest::test_is_available(); } #endif diff --git a/hotspot/src/share/vm/memory/metaspace.hpp b/hotspot/src/share/vm/memory/metaspace.hpp index c22d2170761..96427cb9833 100644 --- a/hotspot/src/share/vm/memory/metaspace.hpp +++ b/hotspot/src/share/vm/memory/metaspace.hpp @@ -225,7 +225,7 @@ class Metaspace : public CHeapObj { MetaWord* expand_and_allocate(size_t size, MetadataType mdtype); - static bool contains(const void *ptr); + bool contains(const void* ptr); void dump(outputStream* const out) const; // Free empty virtualspaces diff --git a/hotspot/src/share/vm/memory/metaspaceCounters.cpp b/hotspot/src/share/vm/memory/metaspaceCounters.cpp index 60e26b8c714..3ad462d081d 100644 --- a/hotspot/src/share/vm/memory/metaspaceCounters.cpp +++ b/hotspot/src/share/vm/memory/metaspaceCounters.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/hotspot/src/share/vm/memory/metaspaceCounters.hpp b/hotspot/src/share/vm/memory/metaspaceCounters.hpp index 0fa991291a1..4db551a1e34 100644 --- a/hotspot/src/share/vm/memory/metaspaceCounters.hpp +++ b/hotspot/src/share/vm/memory/metaspaceCounters.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/hotspot/src/share/vm/memory/sharedHeap.hpp b/hotspot/src/share/vm/memory/sharedHeap.hpp index cd810c036d4..f5d9e05f0cf 100644 --- a/hotspot/src/share/vm/memory/sharedHeap.hpp +++ b/hotspot/src/share/vm/memory/sharedHeap.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 diff --git a/hotspot/src/share/vm/memory/space.cpp b/hotspot/src/share/vm/memory/space.cpp index 7eb462ecccc..8f844df81f1 100644 --- a/hotspot/src/share/vm/memory/space.cpp +++ b/hotspot/src/share/vm/memory/space.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/memory/space.hpp b/hotspot/src/share/vm/memory/space.hpp index eb1e209a850..04efc7da593 100644 --- a/hotspot/src/share/vm/memory/space.hpp +++ b/hotspot/src/share/vm/memory/space.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/memory/specialized_oop_closures.hpp b/hotspot/src/share/vm/memory/specialized_oop_closures.hpp index 2aed587f054..24986b95089 100644 --- a/hotspot/src/share/vm/memory/specialized_oop_closures.hpp +++ b/hotspot/src/share/vm/memory/specialized_oop_closures.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 diff --git a/hotspot/src/share/vm/memory/tenuredGeneration.cpp b/hotspot/src/share/vm/memory/tenuredGeneration.cpp index ac1e9316409..a18d6813e2f 100644 --- a/hotspot/src/share/vm/memory/tenuredGeneration.cpp +++ b/hotspot/src/share/vm/memory/tenuredGeneration.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 diff --git a/hotspot/src/share/vm/memory/tenuredGeneration.hpp b/hotspot/src/share/vm/memory/tenuredGeneration.hpp index e6e9b79873c..94a4330aca1 100644 --- a/hotspot/src/share/vm/memory/tenuredGeneration.hpp +++ b/hotspot/src/share/vm/memory/tenuredGeneration.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 diff --git a/hotspot/src/share/vm/oops/arrayKlass.cpp b/hotspot/src/share/vm/oops/arrayKlass.cpp index 6e04c3ac145..9e40206c253 100644 --- a/hotspot/src/share/vm/oops/arrayKlass.cpp +++ b/hotspot/src/share/vm/oops/arrayKlass.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/oops/arrayOop.hpp b/hotspot/src/share/vm/oops/arrayOop.hpp index 0e5ceffe35a..0cc8f2e448d 100644 --- a/hotspot/src/share/vm/oops/arrayOop.hpp +++ b/hotspot/src/share/vm/oops/arrayOop.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/oops/compiledICHolder.cpp b/hotspot/src/share/vm/oops/compiledICHolder.cpp index 2b2cd2ae646..72268079296 100644 --- a/hotspot/src/share/vm/oops/compiledICHolder.cpp +++ b/hotspot/src/share/vm/oops/compiledICHolder.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/hotspot/src/share/vm/oops/fieldInfo.hpp b/hotspot/src/share/vm/oops/fieldInfo.hpp index 6763c42d127..40a192bdcc0 100644 --- a/hotspot/src/share/vm/oops/fieldInfo.hpp +++ b/hotspot/src/share/vm/oops/fieldInfo.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/hotspot/src/share/vm/oops/generateOopMap.cpp b/hotspot/src/share/vm/oops/generateOopMap.cpp index 9a9dc23d4e8..2207e8c814e 100644 --- a/hotspot/src/share/vm/oops/generateOopMap.cpp +++ b/hotspot/src/share/vm/oops/generateOopMap.cpp @@ -1863,11 +1863,8 @@ void GenerateOopMap::do_ldc(int bci) { constantTag tag = cp->tag_at(ldc.pool_index()); // idx is index in resolved_references BasicType bt = ldc.result_type(); CellTypeState cts; - if (tag.is_klass() || - tag.is_unresolved_klass() || - tag.is_string() || - tag.is_method_handle() || - tag.is_method_type()) { + if (tag.basic_type() == T_OBJECT) { + assert(!tag.is_string_index() && !tag.is_klass_index(), "Unexpected index tag"); assert(bt == T_OBJECT, "Guard is incorrect"); cts = CellTypeState::make_line_ref(bci); } else { diff --git a/hotspot/src/share/vm/oops/instanceClassLoaderKlass.cpp b/hotspot/src/share/vm/oops/instanceClassLoaderKlass.cpp index 507206fc854..a92167a9a7d 100644 --- a/hotspot/src/share/vm/oops/instanceClassLoaderKlass.cpp +++ b/hotspot/src/share/vm/oops/instanceClassLoaderKlass.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -150,10 +150,6 @@ void InstanceClassLoaderKlass::oop_push_contents(PSPromotionManager* pm, oop obj int InstanceClassLoaderKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) { InstanceKlass::oop_update_pointers(cm, obj); - ClassLoaderData * const loader_data = java_lang_ClassLoader::loader_data(obj); - if (loader_data != NULL) { - PSParallelCompact::adjust_class_loader(cm, loader_data); - } return size_helper(); } #endif // INCLUDE_ALL_GCS diff --git a/hotspot/src/share/vm/oops/instanceClassLoaderKlass.hpp b/hotspot/src/share/vm/oops/instanceClassLoaderKlass.hpp index d93f2a5c32a..309ebf96c19 100644 --- a/hotspot/src/share/vm/oops/instanceClassLoaderKlass.hpp +++ b/hotspot/src/share/vm/oops/instanceClassLoaderKlass.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/hotspot/src/share/vm/oops/instanceKlass.cpp b/hotspot/src/share/vm/oops/instanceKlass.cpp index 77be5307db6..a6ca58c42c1 100644 --- a/hotspot/src/share/vm/oops/instanceKlass.cpp +++ b/hotspot/src/share/vm/oops/instanceKlass.cpp @@ -1498,13 +1498,18 @@ int InstanceKlass::find_method_by_name( return -1; } -// lookup_method searches both the local methods array and all superclasses methods arrays +// uncached_lookup_method searches both the local class methods array and all +// superclasses methods arrays, skipping any overpass methods in superclasses. Method* InstanceKlass::uncached_lookup_method(Symbol* name, Symbol* signature) const { Klass* klass = const_cast(this); + bool dont_ignore_overpasses = true; // For the class being searched, find its overpasses. while (klass != NULL) { Method* method = InstanceKlass::cast(klass)->find_method(name, signature); - if (method != NULL) return method; + if ((method != NULL) && (dont_ignore_overpasses || !method->is_overpass())) { + return method; + } klass = InstanceKlass::cast(klass)->super(); + dont_ignore_overpasses = false; // Ignore overpass methods in all superclasses. } return NULL; } @@ -1519,7 +1524,7 @@ Method* InstanceKlass::lookup_method_in_ordered_interfaces(Symbol* name, } // Look up interfaces if (m == NULL) { - m = lookup_method_in_all_interfaces(name, signature); + m = lookup_method_in_all_interfaces(name, signature, false); } return m; } @@ -1528,14 +1533,16 @@ Method* InstanceKlass::lookup_method_in_ordered_interfaces(Symbol* name, // Do NOT return private or static methods, new in JDK8 which are not externally visible // They should only be found in the initial InterfaceMethodRef Method* InstanceKlass::lookup_method_in_all_interfaces(Symbol* name, - Symbol* signature) const { + Symbol* signature, + bool skip_default_methods) const { Array* all_ifs = transitive_interfaces(); int num_ifs = all_ifs->length(); InstanceKlass *ik = NULL; for (int i = 0; i < num_ifs; i++) { ik = InstanceKlass::cast(all_ifs->at(i)); Method* m = ik->lookup_method(name, signature); - if (m != NULL && m->is_public() && !m->is_static()) { + if (m != NULL && m->is_public() && !m->is_static() && + (!skip_default_methods || !m->is_default_method())) { return m; } } @@ -2199,7 +2206,6 @@ int InstanceKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) { obj, \ PSParallelCompact::adjust_pointer(p), \ assert_is_in) - obj->update_header(cm); return size; } diff --git a/hotspot/src/share/vm/oops/instanceKlass.hpp b/hotspot/src/share/vm/oops/instanceKlass.hpp index 84cc0046a95..2b7a73a3189 100644 --- a/hotspot/src/share/vm/oops/instanceKlass.hpp +++ b/hotspot/src/share/vm/oops/instanceKlass.hpp @@ -525,7 +525,8 @@ class InstanceKlass: public Klass { // lookup a method in all the interfaces that this class implements // (returns NULL if not found) - Method* lookup_method_in_all_interfaces(Symbol* name, Symbol* signature) const; + Method* lookup_method_in_all_interfaces(Symbol* name, Symbol* signature, bool skip_default_methods) const; + // lookup a method in local defaults then in all interfaces // (returns NULL if not found) Method* lookup_method_in_ordered_interfaces(Symbol* name, Symbol* signature) const; diff --git a/hotspot/src/share/vm/oops/instanceMirrorKlass.cpp b/hotspot/src/share/vm/oops/instanceMirrorKlass.cpp index 825633247d1..70c2ca19132 100644 --- a/hotspot/src/share/vm/oops/instanceMirrorKlass.cpp +++ b/hotspot/src/share/vm/oops/instanceMirrorKlass.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -155,8 +155,13 @@ void InstanceMirrorKlass::oop_follow_contents(oop obj) { // Follow the klass field in the mirror. Klass* klass = java_lang_Class::as_Klass(obj); if (klass != NULL) { - // For anonymous classes we need to handle the class loader data, - // otherwise it won't be claimed and can be unloaded. + // An anonymous class doesn't have its own class loader, so the call + // to follow_klass will mark and push its java mirror instead of the + // class loader. When handling the java mirror for an anonymous class + // we need to make sure its class loader data is claimed, this is done + // by calling follow_class_loader explicitly. For non-anonymous classes + // the call to follow_class_loader is made when the class loader itself + // is handled. if (klass->oop_is_instance() && InstanceKlass::cast(klass)->is_anonymous()) { MarkSweep::follow_class_loader(klass->class_loader_data()); } else { @@ -183,7 +188,18 @@ void InstanceMirrorKlass::oop_follow_contents(ParCompactionManager* cm, // Follow the klass field in the mirror. Klass* klass = java_lang_Class::as_Klass(obj); if (klass != NULL) { - PSParallelCompact::follow_klass(cm, klass); + // An anonymous class doesn't have its own class loader, so the call + // to follow_klass will mark and push its java mirror instead of the + // class loader. When handling the java mirror for an anonymous class + // we need to make sure its class loader data is claimed, this is done + // by calling follow_class_loader explicitly. For non-anonymous classes + // the call to follow_class_loader is made when the class loader itself + // is handled. + if (klass->oop_is_instance() && InstanceKlass::cast(klass)->is_anonymous()) { + PSParallelCompact::follow_class_loader(cm, klass->class_loader_data()); + } else { + PSParallelCompact::follow_klass(cm, klass); + } } else { // If klass is NULL then this a mirror for a primitive type. // We don't have to follow them, since they are handled as strong @@ -332,17 +348,6 @@ int InstanceMirrorKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) int size = oop_size(obj); InstanceKlass::oop_update_pointers(cm, obj); - // Follow the klass field in the mirror. - Klass* klass = java_lang_Class::as_Klass(obj); - if (klass != NULL) { - PSParallelCompact::adjust_klass(cm, klass); - } else { - // If klass is NULL then this a mirror for a primitive type. - // We don't have to follow them, since they are handled as strong - // roots in Universe::oops_do. - assert(java_lang_Class::is_primitive(obj), "Sanity check"); - } - InstanceMirrorKlass_OOP_ITERATE( \ start_of_static_fields(obj), java_lang_Class::static_oop_field_count(obj),\ PSParallelCompact::adjust_pointer(p), \ diff --git a/hotspot/src/share/vm/oops/instanceOop.hpp b/hotspot/src/share/vm/oops/instanceOop.hpp index bdac1992e6f..5186aa3b817 100644 --- a/hotspot/src/share/vm/oops/instanceOop.hpp +++ b/hotspot/src/share/vm/oops/instanceOop.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/oops/instanceRefKlass.hpp b/hotspot/src/share/vm/oops/instanceRefKlass.hpp index d8771608f73..3140977b471 100644 --- a/hotspot/src/share/vm/oops/instanceRefKlass.hpp +++ b/hotspot/src/share/vm/oops/instanceRefKlass.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/oops/klass.cpp b/hotspot/src/share/vm/oops/klass.cpp index 22b570bbff3..bf5dae0606d 100644 --- a/hotspot/src/share/vm/oops/klass.cpp +++ b/hotspot/src/share/vm/oops/klass.cpp @@ -376,8 +376,6 @@ void Klass::append_to_sibling_list() { } bool Klass::is_loader_alive(BoolObjectClosure* is_alive) { - assert(ClassLoaderDataGraph::contains((address)this), "is in the metaspace"); - #ifdef ASSERT // The class is alive iff the class loader is alive. oop loader = class_loader(); diff --git a/hotspot/src/share/vm/oops/klassPS.hpp b/hotspot/src/share/vm/oops/klassPS.hpp index 5fb17b6e801..a92f8738a78 100644 --- a/hotspot/src/share/vm/oops/klassPS.hpp +++ b/hotspot/src/share/vm/oops/klassPS.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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 diff --git a/hotspot/src/share/vm/oops/klassVtable.cpp b/hotspot/src/share/vm/oops/klassVtable.cpp index 509c7885360..a7fc062b71e 100644 --- a/hotspot/src/share/vm/oops/klassVtable.cpp +++ b/hotspot/src/share/vm/oops/klassVtable.cpp @@ -622,7 +622,7 @@ bool klassVtable::needs_new_vtable_entry(methodHandle target_method, // this check for all access permissions. InstanceKlass *sk = InstanceKlass::cast(super); if (sk->has_miranda_methods()) { - if (sk->lookup_method_in_all_interfaces(name, signature) != NULL) { + if (sk->lookup_method_in_all_interfaces(name, signature, false) != NULL) { return false; // found a matching miranda; we do not need a new entry } } @@ -743,7 +743,7 @@ void klassVtable::add_new_mirandas_to_lists( if (is_miranda(im, class_methods, default_methods, super)) { // is it a miranda at all? InstanceKlass *sk = InstanceKlass::cast(super); // check if it is a duplicate of a super's miranda - if (sk->lookup_method_in_all_interfaces(im->name(), im->signature()) == NULL) { + if (sk->lookup_method_in_all_interfaces(im->name(), im->signature(), false) == NULL) { new_mirandas->append(im); } if (all_mirandas != NULL) { @@ -1085,6 +1085,8 @@ void klassItable::initialize_itable_for_interface(int method_table_offset, Klass Method* m = methods->at(i); methodHandle target; if (m->has_itable_index()) { + // This search must match the runtime resolution, i.e. selection search for invokeinterface + // to correctly enforce loader constraints for interface method inheritance LinkResolver::lookup_instance_method_in_klasses(target, _klass, m->name(), m->signature(), CHECK); } if (target == NULL || !target->is_public() || target->is_abstract()) { diff --git a/hotspot/src/share/vm/oops/objArrayKlass.cpp b/hotspot/src/share/vm/oops/objArrayKlass.cpp index 94c990a728e..7294ebe9adb 100644 --- a/hotspot/src/share/vm/oops/objArrayKlass.cpp +++ b/hotspot/src/share/vm/oops/objArrayKlass.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -587,7 +587,6 @@ int ObjArrayKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) { assert (obj->is_objArray(), "obj must be obj array"); objArrayOop a = objArrayOop(obj); int size = a->object_size(); - a->update_header(cm); ObjArrayKlass_OOP_ITERATE(a, p, PSParallelCompact::adjust_pointer(p)) return size; } diff --git a/hotspot/src/share/vm/oops/objArrayKlass.hpp b/hotspot/src/share/vm/oops/objArrayKlass.hpp index d56a3de846d..af06fd42084 100644 --- a/hotspot/src/share/vm/oops/objArrayKlass.hpp +++ b/hotspot/src/share/vm/oops/objArrayKlass.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/oops/objArrayKlass.inline.hpp b/hotspot/src/share/vm/oops/objArrayKlass.inline.hpp index 23e809a7e0f..e082df55ab4 100644 --- a/hotspot/src/share/vm/oops/objArrayKlass.inline.hpp +++ b/hotspot/src/share/vm/oops/objArrayKlass.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/hotspot/src/share/vm/oops/oop.hpp b/hotspot/src/share/vm/oops/oop.hpp index 66a62eaab23..350c0fc6131 100644 --- a/hotspot/src/share/vm/oops/oop.hpp +++ b/hotspot/src/share/vm/oops/oop.hpp @@ -328,11 +328,6 @@ class oopDesc { // return the size of this oop. This is used by the MarkSweep collector. int adjust_pointers(); -#if INCLUDE_ALL_GCS - // Parallel old - void update_header(ParCompactionManager* cm); -#endif // INCLUDE_ALL_GCS - // mark-sweep support void follow_body(int begin, int end); diff --git a/hotspot/src/share/vm/oops/oop.pcgc.inline.hpp b/hotspot/src/share/vm/oops/oop.pcgc.inline.hpp index d8e40477f79..596bbc6d123 100644 --- a/hotspot/src/share/vm/oops/oop.pcgc.inline.hpp +++ b/hotspot/src/share/vm/oops/oop.pcgc.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -80,8 +80,4 @@ inline oop oopDesc::forward_to_atomic(oop p) { return forwardee(); } -inline void oopDesc::update_header(ParCompactionManager* cm) { - PSParallelCompact::adjust_klass(cm, klass()); -} - #endif // SHARE_VM_OOPS_OOP_PCGC_INLINE_HPP diff --git a/hotspot/src/share/vm/oops/oop.psgc.inline.hpp b/hotspot/src/share/vm/oops/oop.psgc.inline.hpp index ea184f36339..b959ad531be 100644 --- a/hotspot/src/share/vm/oops/oop.psgc.inline.hpp +++ b/hotspot/src/share/vm/oops/oop.psgc.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 diff --git a/hotspot/src/share/vm/oops/typeArrayKlass.cpp b/hotspot/src/share/vm/oops/typeArrayKlass.cpp index 56863a02469..8d9c6728cf8 100644 --- a/hotspot/src/share/vm/oops/typeArrayKlass.cpp +++ b/hotspot/src/share/vm/oops/typeArrayKlass.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/oops/typeArrayKlass.hpp b/hotspot/src/share/vm/oops/typeArrayKlass.hpp index f8bf2ac74c0..cf363fc76c2 100644 --- a/hotspot/src/share/vm/oops/typeArrayKlass.hpp +++ b/hotspot/src/share/vm/oops/typeArrayKlass.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/opto/block.cpp b/hotspot/src/share/vm/opto/block.cpp index fade19bdb6b..f25e5480e43 100644 --- a/hotspot/src/share/vm/opto/block.cpp +++ b/hotspot/src/share/vm/opto/block.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/opto/block.hpp b/hotspot/src/share/vm/opto/block.hpp index e1574691849..dbb3cfb5039 100644 --- a/hotspot/src/share/vm/opto/block.hpp +++ b/hotspot/src/share/vm/opto/block.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/opto/buildOopMap.cpp b/hotspot/src/share/vm/opto/buildOopMap.cpp index e63be38ed11..9f2dd674e2f 100644 --- a/hotspot/src/share/vm/opto/buildOopMap.cpp +++ b/hotspot/src/share/vm/opto/buildOopMap.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 diff --git a/hotspot/src/share/vm/opto/bytecodeInfo.cpp b/hotspot/src/share/vm/opto/bytecodeInfo.cpp index 1e875c42c50..4b3f39f0893 100644 --- a/hotspot/src/share/vm/opto/bytecodeInfo.cpp +++ b/hotspot/src/share/vm/opto/bytecodeInfo.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -50,7 +50,10 @@ InlineTree::InlineTree(Compile* c, _subtrees(c->comp_arena(), 2, 0, NULL), _msg(NULL) { - NOT_PRODUCT(_count_inlines = 0;) +#ifndef PRODUCT + _count_inlines = 0; + _forced_inline = false; +#endif if (_caller_jvms != NULL) { // Keep a private copy of the caller_jvms: _caller_jvms = new (C) JVMState(caller_jvms->method(), caller_tree->caller_jvms()); @@ -81,7 +84,10 @@ InlineTree::InlineTree(Compile* c, ciMethod* callee_method, JVMState* caller_jvm _count_inline_bcs(method()->code_size()), _msg(NULL) { - NOT_PRODUCT(_count_inlines = 0;) +#ifndef PRODUCT + _count_inlines = 0; + _forced_inline = false; +#endif assert(!UseOldInlining, "do not use for old stuff"); } @@ -128,9 +134,19 @@ bool InlineTree::should_inline(ciMethod* callee_method, ciMethod* caller_method, tty->print_cr("Inlined method is hot: "); } set_msg("force inline by CompilerOracle"); + _forced_inline = true; return true; } +#ifndef PRODUCT + int inline_depth = inline_level()+1; + if (ciReplay::should_inline(C->replay_inline_data(), callee_method, caller_bci, inline_depth)) { + set_msg("force inline by ciReplay"); + _forced_inline = true; + return true; + } +#endif + int size = callee_method->code_size_for_inlining(); // Check for too many throws (and not too huge) @@ -264,6 +280,18 @@ bool InlineTree::should_not_inline(ciMethod *callee_method, } #ifndef PRODUCT + int caller_bci = jvms->bci(); + int inline_depth = inline_level()+1; + if (ciReplay::should_inline(C->replay_inline_data(), callee_method, caller_bci, inline_depth)) { + set_msg("force inline by ciReplay"); + return false; + } + + if (ciReplay::should_not_inline(C->replay_inline_data(), callee_method, caller_bci, inline_depth)) { + set_msg("disallowed by ciReplay"); + return true; + } + if (ciReplay::should_not_inline(callee_method)) { set_msg("disallowed by ciReplay"); return true; @@ -343,6 +371,7 @@ bool InlineTree::try_to_inline(ciMethod* callee_method, ciMethod* caller_method, } } + _forced_inline = false; // Reset if (!should_inline(callee_method, caller_method, caller_bci, profile, wci_result)) { return false; @@ -373,10 +402,10 @@ bool InlineTree::try_to_inline(ciMethod* callee_method, ciMethod* caller_method, if ((!UseInterpreter || CompileTheWorld) && is_init_with_ea(callee_method, caller_method, C)) { - // Escape Analysis stress testing when running Xcomp or CTW: // inline constructors even if they are not reached. - + } else if (forced_inline()) { + // Inlining was forced by CompilerOracle or ciReplay } else if (profile.count() == 0) { // don't inline unreached call sites set_msg("call site not reached"); @@ -700,12 +729,28 @@ InlineTree* InlineTree::find_subtree_from_root(InlineTree* root, JVMState* jvms, return iltp; } +// Count number of nodes in this subtree +int InlineTree::count() const { + int result = 1; + for (int i = 0 ; i < _subtrees.length(); i++) { + result += _subtrees.at(i)->count(); + } + return result; +} + +void InlineTree::dump_replay_data(outputStream* out) { + out->print(" %d %d ", inline_level(), caller_bci()); + method()->dump_name_as_ascii(out); + for (int i = 0 ; i < _subtrees.length(); i++) { + _subtrees.at(i)->dump_replay_data(out); + } +} #ifndef PRODUCT void InlineTree::print_impl(outputStream* st, int indent) const { for (int i = 0; i < indent; i++) st->print(" "); - st->print(" @ %d ", caller_bci()); + st->print(" @ %d", caller_bci()); method()->print_short_name(st); st->cr(); diff --git a/hotspot/src/share/vm/opto/c2compiler.cpp b/hotspot/src/share/vm/opto/c2compiler.cpp index 91653bd3ce3..7fa7918263e 100644 --- a/hotspot/src/share/vm/opto/c2compiler.cpp +++ b/hotspot/src/share/vm/opto/c2compiler.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 diff --git a/hotspot/src/share/vm/opto/c2compiler.hpp b/hotspot/src/share/vm/opto/c2compiler.hpp index 48ccc1b5105..0a6b519e2e3 100644 --- a/hotspot/src/share/vm/opto/c2compiler.hpp +++ b/hotspot/src/share/vm/opto/c2compiler.hpp @@ -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 @@ -32,13 +32,11 @@ class C2Compiler : public AbstractCompiler { static bool init_c2_runtime(); public: + C2Compiler() : AbstractCompiler(c2) {} + // Name const char *name() { return "C2"; } -#ifdef TIERED - virtual bool is_c2() { return true; }; -#endif // TIERED - void initialize(); // Compilation entry point for methods diff --git a/hotspot/src/share/vm/opto/callGenerator.cpp b/hotspot/src/share/vm/opto/callGenerator.cpp index adc27ac02e4..6e9c98d3436 100644 --- a/hotspot/src/share/vm/opto/callGenerator.cpp +++ b/hotspot/src/share/vm/opto/callGenerator.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 diff --git a/hotspot/src/share/vm/opto/callnode.cpp b/hotspot/src/share/vm/opto/callnode.cpp index 594b650decb..3c07fc9a62a 100644 --- a/hotspot/src/share/vm/opto/callnode.cpp +++ b/hotspot/src/share/vm/opto/callnode.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/opto/chaitin.cpp b/hotspot/src/share/vm/opto/chaitin.cpp index 492bf384f2f..47fa4ba6b5b 100644 --- a/hotspot/src/share/vm/opto/chaitin.cpp +++ b/hotspot/src/share/vm/opto/chaitin.cpp @@ -1682,9 +1682,21 @@ Node *PhaseChaitin::find_base_for_derived( Node **derived_base_map, Node *derive // (where top() node is placed). base->init_req(0, _cfg.get_root_node()); Block *startb = _cfg.get_block_for_node(C->top()); - startb->insert_node(base, startb->find_node(C->top())); + uint node_pos = startb->find_node(C->top()); + startb->insert_node(base, node_pos); _cfg.map_node_to_block(base, startb); assert(_lrg_map.live_range_id(base) == 0, "should not have LRG yet"); + + // The loadConP0 might have projection nodes depending on architecture + // Add the projection nodes to the CFG + for (DUIterator_Fast imax, i = base->fast_outs(imax); i < imax; i++) { + Node* use = base->fast_out(i); + if (use->is_MachProj()) { + startb->insert_node(use, ++node_pos); + _cfg.map_node_to_block(use, startb); + new_lrg(use, maxlrg++); + } + } } if (_lrg_map.live_range_id(base) == 0) { new_lrg(base, maxlrg++); diff --git a/hotspot/src/share/vm/opto/chaitin.hpp b/hotspot/src/share/vm/opto/chaitin.hpp index da98d16e29c..b188cc9bbf8 100644 --- a/hotspot/src/share/vm/opto/chaitin.hpp +++ b/hotspot/src/share/vm/opto/chaitin.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/opto/classes.cpp b/hotspot/src/share/vm/opto/classes.cpp index 78529511f31..dadc72726e3 100644 --- a/hotspot/src/share/vm/opto/classes.cpp +++ b/hotspot/src/share/vm/opto/classes.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/opto/classes.hpp b/hotspot/src/share/vm/opto/classes.hpp index 002d2db636d..7390c915da9 100644 --- a/hotspot/src/share/vm/opto/classes.hpp +++ b/hotspot/src/share/vm/opto/classes.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/opto/coalesce.hpp b/hotspot/src/share/vm/opto/coalesce.hpp index 3a361b25f11..41d4d8fe3e2 100644 --- a/hotspot/src/share/vm/opto/coalesce.hpp +++ b/hotspot/src/share/vm/opto/coalesce.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/opto/compile.cpp b/hotspot/src/share/vm/opto/compile.cpp index 99d3cec271b..ba8debaaeea 100644 --- a/hotspot/src/share/vm/opto/compile.cpp +++ b/hotspot/src/share/vm/opto/compile.cpp @@ -25,6 +25,7 @@ #include "precompiled.hpp" #include "asm/macroAssembler.hpp" #include "asm/macroAssembler.inline.hpp" +#include "ci/ciReplay.hpp" #include "classfile/systemDictionary.hpp" #include "code/exceptionHandlerTable.hpp" #include "code/nmethod.hpp" @@ -647,6 +648,7 @@ Compile::Compile( ciEnv* ci_env, C2Compiler* compiler, ciMethod* target, int osr _printer(IdealGraphPrinter::printer()), #endif _congraph(NULL), + _replay_inline_data(NULL), _late_inlines(comp_arena(), 2, 0, NULL), _string_late_inlines(comp_arena(), 2, 0, NULL), _boxing_late_inlines(comp_arena(), 2, 0, NULL), @@ -680,6 +682,10 @@ Compile::Compile( ciEnv* ci_env, C2Compiler* compiler, ciMethod* target, int osr } set_print_assembly(print_opto_assembly); set_parsed_irreducible_loop(false); + + if (method()->has_option("ReplayInline")) { + _replay_inline_data = ciReplay::load_inline_data(method(), entry_bci(), ci_env->comp_level()); + } #endif set_print_inlining(PrintInlining || method()->has_option("PrintInlining") NOT_PRODUCT( || PrintOptoInlining)); set_print_intrinsics(PrintIntrinsics || method()->has_option("PrintIntrinsics")); @@ -849,6 +855,15 @@ Compile::Compile( ciEnv* ci_env, C2Compiler* compiler, ciMethod* target, int osr #endif NOT_PRODUCT( verify_barriers(); ) + + // Dump compilation data to replay it. + if (method()->has_option("DumpReplay")) { + env()->dump_replay_data(_compile_id); + } + if (method()->has_option("DumpInline") && (ilt() != NULL)) { + env()->dump_inline_data(_compile_id); + } + // Now that we know the size of all the monitors we can add a fixed slot // for the original deopt pc. @@ -938,6 +953,7 @@ Compile::Compile( ciEnv* ci_env, _dead_node_list(comp_arena()), _dead_node_count(0), _congraph(NULL), + _replay_inline_data(NULL), _number_of_mh_late_inlines(0), _inlining_progress(false), _inlining_incrementally(false), @@ -3757,6 +3773,16 @@ void Compile::dump_inlining() { } } +// Dump inlining replay data to the stream. +// Don't change thread state and acquire any locks. +void Compile::dump_inline_data(outputStream* out) { + InlineTree* inl_tree = ilt(); + if (inl_tree != NULL) { + out->print(" inline %d", inl_tree->count()); + inl_tree->dump_replay_data(out); + } +} + int Compile::cmp_expensive_nodes(Node* n1, Node* n2) { if (n1->Opcode() < n2->Opcode()) return -1; else if (n1->Opcode() > n2->Opcode()) return 1; diff --git a/hotspot/src/share/vm/opto/compile.hpp b/hotspot/src/share/vm/opto/compile.hpp index d248d9d6c23..88581238b1e 100644 --- a/hotspot/src/share/vm/opto/compile.hpp +++ b/hotspot/src/share/vm/opto/compile.hpp @@ -431,6 +431,8 @@ class Compile : public Phase { // Are we within a PreserveJVMState block? int _preserve_jvm_state; + void* _replay_inline_data; // Pointer to data loaded from file + public: outputStream* print_inlining_stream() const { @@ -465,6 +467,11 @@ class Compile : public Phase { print_inlining_stream()->print(ss.as_string()); } + void* replay_inline_data() const { return _replay_inline_data; } + + // Dump inlining replay data to the stream. + void dump_inline_data(outputStream* out); + private: // Matching, CFG layout, allocation, code generation PhaseCFG* _cfg; // Results of CFG finding diff --git a/hotspot/src/share/vm/opto/connode.cpp b/hotspot/src/share/vm/opto/connode.cpp index b59025ad4f3..948ff7b4632 100644 --- a/hotspot/src/share/vm/opto/connode.cpp +++ b/hotspot/src/share/vm/opto/connode.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/opto/doCall.cpp b/hotspot/src/share/vm/opto/doCall.cpp index 6768968bebd..223f7da3655 100644 --- a/hotspot/src/share/vm/opto/doCall.cpp +++ b/hotspot/src/share/vm/opto/doCall.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/hotspot/src/share/vm/opto/domgraph.cpp b/hotspot/src/share/vm/opto/domgraph.cpp index 5e1886c24f0..a7fa0532763 100644 --- a/hotspot/src/share/vm/opto/domgraph.cpp +++ b/hotspot/src/share/vm/opto/domgraph.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/opto/escape.cpp b/hotspot/src/share/vm/opto/escape.cpp index 50afded6a92..028aa2467f2 100644 --- a/hotspot/src/share/vm/opto/escape.cpp +++ b/hotspot/src/share/vm/opto/escape.cpp @@ -1579,9 +1579,20 @@ void ConnectionGraph::adjust_scalar_replaceable_state(JavaObjectNode* jobj) { jobj->set_scalar_replaceable(false); return; } + // 2. An object is not scalar replaceable if the field into which it is + // stored has multiple bases one of which is null. + if (field->base_count() > 1) { + for (BaseIterator i(field); i.has_next(); i.next()) { + PointsToNode* base = i.get(); + if (base == null_obj) { + jobj->set_scalar_replaceable(false); + return; + } + } + } } assert(use->is_Field() || use->is_LocalVar(), "sanity"); - // 2. An object is not scalar replaceable if it is merged with other objects. + // 3. An object is not scalar replaceable if it is merged with other objects. for (EdgeIterator j(use); j.has_next(); j.next()) { PointsToNode* ptn = j.get(); if (ptn->is_JavaObject() && ptn != jobj) { @@ -1600,13 +1611,13 @@ void ConnectionGraph::adjust_scalar_replaceable_state(JavaObjectNode* jobj) { FieldNode* field = j.get()->as_Field(); int offset = field->as_Field()->offset(); - // 3. An object is not scalar replaceable if it has a field with unknown + // 4. An object is not scalar replaceable if it has a field with unknown // offset (array's element is accessed in loop). if (offset == Type::OffsetBot) { jobj->set_scalar_replaceable(false); return; } - // 4. Currently an object is not scalar replaceable if a LoadStore node + // 5. Currently an object is not scalar replaceable if a LoadStore node // access its field since the field value is unknown after it. // Node* n = field->ideal_node(); @@ -1617,7 +1628,7 @@ void ConnectionGraph::adjust_scalar_replaceable_state(JavaObjectNode* jobj) { } } - // 5. Or the address may point to more then one object. This may produce + // 6. Or the address may point to more then one object. This may produce // the false positive result (set not scalar replaceable) // since the flow-insensitive escape analysis can't separate // the case when stores overwrite the field's value from the case diff --git a/hotspot/src/share/vm/opto/gcm.cpp b/hotspot/src/share/vm/opto/gcm.cpp index db60d4d1e60..6d7164347b4 100644 --- a/hotspot/src/share/vm/opto/gcm.cpp +++ b/hotspot/src/share/vm/opto/gcm.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/opto/generateOptoStub.cpp b/hotspot/src/share/vm/opto/generateOptoStub.cpp index 9b64d1f10e2..6721c9dcda2 100644 --- a/hotspot/src/share/vm/opto/generateOptoStub.cpp +++ b/hotspot/src/share/vm/opto/generateOptoStub.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 diff --git a/hotspot/src/share/vm/opto/graphKit.cpp b/hotspot/src/share/vm/opto/graphKit.cpp index 8c5e05c3ac7..c30cdc12c82 100644 --- a/hotspot/src/share/vm/opto/graphKit.cpp +++ b/hotspot/src/share/vm/opto/graphKit.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 diff --git a/hotspot/src/share/vm/opto/graphKit.hpp b/hotspot/src/share/vm/opto/graphKit.hpp index 75e01784e4c..cfd943698c4 100644 --- a/hotspot/src/share/vm/opto/graphKit.hpp +++ b/hotspot/src/share/vm/opto/graphKit.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 diff --git a/hotspot/src/share/vm/opto/idealKit.cpp b/hotspot/src/share/vm/opto/idealKit.cpp index 90eff2bb5d7..504af59e05a 100644 --- a/hotspot/src/share/vm/opto/idealKit.cpp +++ b/hotspot/src/share/vm/opto/idealKit.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 diff --git a/hotspot/src/share/vm/opto/idealKit.hpp b/hotspot/src/share/vm/opto/idealKit.hpp index 16833c0cbfe..132a310d5d4 100644 --- a/hotspot/src/share/vm/opto/idealKit.hpp +++ b/hotspot/src/share/vm/opto/idealKit.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 diff --git a/hotspot/src/share/vm/opto/ifg.cpp b/hotspot/src/share/vm/opto/ifg.cpp index 89ed5b33102..52a6cecce90 100644 --- a/hotspot/src/share/vm/opto/ifg.cpp +++ b/hotspot/src/share/vm/opto/ifg.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/hotspot/src/share/vm/opto/ifnode.cpp b/hotspot/src/share/vm/opto/ifnode.cpp index 029a9f64adc..6e61a1f98bc 100644 --- a/hotspot/src/share/vm/opto/ifnode.cpp +++ b/hotspot/src/share/vm/opto/ifnode.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 diff --git a/hotspot/src/share/vm/opto/lcm.cpp b/hotspot/src/share/vm/opto/lcm.cpp index c497abdb578..bdf076aa341 100644 --- a/hotspot/src/share/vm/opto/lcm.cpp +++ b/hotspot/src/share/vm/opto/lcm.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/hotspot/src/share/vm/opto/live.cpp b/hotspot/src/share/vm/opto/live.cpp index 02bbb1b97ab..787f5ab88c3 100644 --- a/hotspot/src/share/vm/opto/live.cpp +++ b/hotspot/src/share/vm/opto/live.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/opto/live.hpp b/hotspot/src/share/vm/opto/live.hpp index e449bb3f3a6..343c5c6f727 100644 --- a/hotspot/src/share/vm/opto/live.hpp +++ b/hotspot/src/share/vm/opto/live.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/opto/loopPredicate.cpp b/hotspot/src/share/vm/opto/loopPredicate.cpp index 411226acffa..2fbfba0f48c 100644 --- a/hotspot/src/share/vm/opto/loopPredicate.cpp +++ b/hotspot/src/share/vm/opto/loopPredicate.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/hotspot/src/share/vm/opto/loopTransform.cpp b/hotspot/src/share/vm/opto/loopTransform.cpp index 75f35b7d896..af31a9ce1fb 100644 --- a/hotspot/src/share/vm/opto/loopTransform.cpp +++ b/hotspot/src/share/vm/opto/loopTransform.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 diff --git a/hotspot/src/share/vm/opto/loopnode.hpp b/hotspot/src/share/vm/opto/loopnode.hpp index 6d4933893bb..59915ffed6f 100644 --- a/hotspot/src/share/vm/opto/loopnode.hpp +++ b/hotspot/src/share/vm/opto/loopnode.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/hotspot/src/share/vm/opto/loopopts.cpp b/hotspot/src/share/vm/opto/loopopts.cpp index a7bf3ad28e8..ba19f7493cc 100644 --- a/hotspot/src/share/vm/opto/loopopts.cpp +++ b/hotspot/src/share/vm/opto/loopopts.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 diff --git a/hotspot/src/share/vm/opto/macro.cpp b/hotspot/src/share/vm/opto/macro.cpp index 06bf9e608c0..325b014ea08 100644 --- a/hotspot/src/share/vm/opto/macro.cpp +++ b/hotspot/src/share/vm/opto/macro.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 diff --git a/hotspot/src/share/vm/opto/macro.hpp b/hotspot/src/share/vm/opto/macro.hpp index 7a72316dfc8..5e2e97c7e3c 100644 --- a/hotspot/src/share/vm/opto/macro.hpp +++ b/hotspot/src/share/vm/opto/macro.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 diff --git a/hotspot/src/share/vm/opto/matcher.hpp b/hotspot/src/share/vm/opto/matcher.hpp index 1131d09f1d5..f840d0c6edc 100644 --- a/hotspot/src/share/vm/opto/matcher.hpp +++ b/hotspot/src/share/vm/opto/matcher.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/opto/memnode.cpp b/hotspot/src/share/vm/opto/memnode.cpp index 49694b6e92e..14d347b8e69 100644 --- a/hotspot/src/share/vm/opto/memnode.cpp +++ b/hotspot/src/share/vm/opto/memnode.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -2071,6 +2071,11 @@ const Type *LoadNode::klass_value_common( PhaseTransform *phase ) const { if (t != NULL) { // constant oop => constant klass if (offset == java_lang_Class::array_klass_offset_in_bytes()) { + if (t->is_void()) { + // We cannot create a void array. Since void is a primitive type return null + // klass. Users of this result need to do a null check on the returned klass. + return TypePtr::NULL_PTR; + } return TypeKlassPtr::make(ciArrayKlass::make(t)); } if (!t->is_klass()) { diff --git a/hotspot/src/share/vm/opto/memnode.hpp b/hotspot/src/share/vm/opto/memnode.hpp index 88a05ad134d..3a35be5dba3 100644 --- a/hotspot/src/share/vm/opto/memnode.hpp +++ b/hotspot/src/share/vm/opto/memnode.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/opto/multnode.cpp b/hotspot/src/share/vm/opto/multnode.cpp index bb3357abcf0..106a0086c63 100644 --- a/hotspot/src/share/vm/opto/multnode.cpp +++ b/hotspot/src/share/vm/opto/multnode.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/opto/multnode.hpp b/hotspot/src/share/vm/opto/multnode.hpp index e3866c8b9a1..6a0aea721b8 100644 --- a/hotspot/src/share/vm/opto/multnode.hpp +++ b/hotspot/src/share/vm/opto/multnode.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/opto/node.cpp b/hotspot/src/share/vm/opto/node.cpp index 1df5eb51a8c..06e74b6d0f2 100644 --- a/hotspot/src/share/vm/opto/node.cpp +++ b/hotspot/src/share/vm/opto/node.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/opto/optoreg.hpp b/hotspot/src/share/vm/opto/optoreg.hpp index a21311b9c6d..0d45c7a50ab 100644 --- a/hotspot/src/share/vm/opto/optoreg.hpp +++ b/hotspot/src/share/vm/opto/optoreg.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/hotspot/src/share/vm/opto/output.cpp b/hotspot/src/share/vm/opto/output.cpp index 6232c41f0b1..f362669b5ec 100644 --- a/hotspot/src/share/vm/opto/output.cpp +++ b/hotspot/src/share/vm/opto/output.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/hotspot/src/share/vm/opto/output.hpp b/hotspot/src/share/vm/opto/output.hpp index 5fb68c6828a..6758d180689 100644 --- a/hotspot/src/share/vm/opto/output.hpp +++ b/hotspot/src/share/vm/opto/output.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 diff --git a/hotspot/src/share/vm/opto/parse.hpp b/hotspot/src/share/vm/opto/parse.hpp index f60e6a540ea..6da027ee65f 100644 --- a/hotspot/src/share/vm/opto/parse.hpp +++ b/hotspot/src/share/vm/opto/parse.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -141,6 +141,13 @@ public: GrowableArray subtrees() { return _subtrees; } void print_value_on(outputStream* st) const PRODUCT_RETURN; + + bool _forced_inline; // Inlining was forced by CompilerOracle or ciReplay + bool forced_inline() const { return _forced_inline; } + // Count number of nodes in this subtree + int count() const; + // Dump inlining replay data to the stream. + void dump_replay_data(outputStream* out); }; diff --git a/hotspot/src/share/vm/opto/parse1.cpp b/hotspot/src/share/vm/opto/parse1.cpp index 808f64d2d9a..de7188ff871 100644 --- a/hotspot/src/share/vm/opto/parse1.cpp +++ b/hotspot/src/share/vm/opto/parse1.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/opto/parse2.cpp b/hotspot/src/share/vm/opto/parse2.cpp index 74119ef9f51..75746213087 100644 --- a/hotspot/src/share/vm/opto/parse2.cpp +++ b/hotspot/src/share/vm/opto/parse2.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/hotspot/src/share/vm/opto/phase.cpp b/hotspot/src/share/vm/opto/phase.cpp index 5359301575d..24fdb45ca7c 100644 --- a/hotspot/src/share/vm/opto/phase.cpp +++ b/hotspot/src/share/vm/opto/phase.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/opto/phase.hpp b/hotspot/src/share/vm/opto/phase.hpp index 582a126db36..1bc68a130f5 100644 --- a/hotspot/src/share/vm/opto/phase.hpp +++ b/hotspot/src/share/vm/opto/phase.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/opto/phaseX.cpp b/hotspot/src/share/vm/opto/phaseX.cpp index 15b9b778883..3e6ab4eafff 100644 --- a/hotspot/src/share/vm/opto/phaseX.cpp +++ b/hotspot/src/share/vm/opto/phaseX.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/opto/phaseX.hpp b/hotspot/src/share/vm/opto/phaseX.hpp index 7f39e538154..d03d47d95bc 100644 --- a/hotspot/src/share/vm/opto/phaseX.hpp +++ b/hotspot/src/share/vm/opto/phaseX.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/opto/postaloc.cpp b/hotspot/src/share/vm/opto/postaloc.cpp index 2ad809d1a58..86078979af1 100644 --- a/hotspot/src/share/vm/opto/postaloc.cpp +++ b/hotspot/src/share/vm/opto/postaloc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/hotspot/src/share/vm/opto/reg_split.cpp b/hotspot/src/share/vm/opto/reg_split.cpp index 842048f46f5..cfcecadd338 100644 --- a/hotspot/src/share/vm/opto/reg_split.cpp +++ b/hotspot/src/share/vm/opto/reg_split.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 diff --git a/hotspot/src/share/vm/opto/regalloc.cpp b/hotspot/src/share/vm/opto/regalloc.cpp index 7ac02165662..a4844367e43 100644 --- a/hotspot/src/share/vm/opto/regalloc.cpp +++ b/hotspot/src/share/vm/opto/regalloc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 diff --git a/hotspot/src/share/vm/opto/regalloc.hpp b/hotspot/src/share/vm/opto/regalloc.hpp index 9bea94be5de..3aea8194783 100644 --- a/hotspot/src/share/vm/opto/regalloc.hpp +++ b/hotspot/src/share/vm/opto/regalloc.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 diff --git a/hotspot/src/share/vm/opto/subnode.cpp b/hotspot/src/share/vm/opto/subnode.cpp index 4e2c8b7aef6..fcbead264af 100644 --- a/hotspot/src/share/vm/opto/subnode.cpp +++ b/hotspot/src/share/vm/opto/subnode.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/opto/subnode.hpp b/hotspot/src/share/vm/opto/subnode.hpp index 47eb5c65c05..56ee308d982 100644 --- a/hotspot/src/share/vm/opto/subnode.hpp +++ b/hotspot/src/share/vm/opto/subnode.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/hotspot/src/share/vm/opto/superword.cpp b/hotspot/src/share/vm/opto/superword.cpp index 90f24189fe4..96c81bd999c 100644 --- a/hotspot/src/share/vm/opto/superword.cpp +++ b/hotspot/src/share/vm/opto/superword.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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 diff --git a/hotspot/src/share/vm/opto/superword.hpp b/hotspot/src/share/vm/opto/superword.hpp index 050d7588c3d..5081586474d 100644 --- a/hotspot/src/share/vm/opto/superword.hpp +++ b/hotspot/src/share/vm/opto/superword.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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 diff --git a/hotspot/src/share/vm/opto/type.cpp b/hotspot/src/share/vm/opto/type.cpp index 3f628195f78..83806a3235b 100644 --- a/hotspot/src/share/vm/opto/type.cpp +++ b/hotspot/src/share/vm/opto/type.cpp @@ -3812,17 +3812,17 @@ const Type *TypeAryPtr::xmeet_helper(const Type *t) const { tary = TypeAry::make(Type::BOTTOM, tary->_size, tary->_stable); } } else // Non integral arrays. - // Must fall to bottom if exact klasses in upper lattice - // are not equal or super klass is exact. - if ( above_centerline(ptr) && klass() != tap->klass() && - // meet with top[] and bottom[] are processed further down: - tap ->_klass != NULL && this->_klass != NULL && - // both are exact and not equal: - ((tap ->_klass_is_exact && this->_klass_is_exact) || - // 'tap' is exact and super or unrelated: - (tap ->_klass_is_exact && !tap->klass()->is_subtype_of(klass())) || - // 'this' is exact and super or unrelated: - (this->_klass_is_exact && !klass()->is_subtype_of(tap->klass())))) { + // Must fall to bottom if exact klasses in upper lattice + // are not equal or super klass is exact. + if ((above_centerline(ptr) || ptr == Constant) && klass() != tap->klass() && + // meet with top[] and bottom[] are processed further down: + tap->_klass != NULL && this->_klass != NULL && + // both are exact and not equal: + ((tap->_klass_is_exact && this->_klass_is_exact) || + // 'tap' is exact and super or unrelated: + (tap->_klass_is_exact && !tap->klass()->is_subtype_of(klass())) || + // 'this' is exact and super or unrelated: + (this->_klass_is_exact && !klass()->is_subtype_of(tap->klass())))) { tary = TypeAry::make(Type::BOTTOM, tary->_size, tary->_stable); return make(NotNull, NULL, tary, lazy_klass, false, off, InstanceBot); } diff --git a/hotspot/src/share/vm/precompiled/precompiled.hpp b/hotspot/src/share/vm/precompiled/precompiled.hpp index d4be22e6cd0..4026c0eb29f 100644 --- a/hotspot/src/share/vm/precompiled/precompiled.hpp +++ b/hotspot/src/share/vm/precompiled/precompiled.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/hotspot/src/share/vm/prims/forte.cpp b/hotspot/src/share/vm/prims/forte.cpp index 4b1fbebc137..ae09d1161d2 100644 --- a/hotspot/src/share/vm/prims/forte.cpp +++ b/hotspot/src/share/vm/prims/forte.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -613,7 +613,7 @@ void AsyncGetCallTrace(ASGCT_CallTrace *trace, jint depth, void* ucontext) { #ifdef __APPLE__ // XXXDARWIN: Link errors occur even when __attribute__((weak_import)) // is added -#define collector_func_load(x0,x1,x2,x3,x4,x5,x6) (0) +#define collector_func_load(x0,x1,x2,x3,x4,x5,x6) ((void) 0) #else void collector_func_load(char* name, void* null_argument_1, diff --git a/hotspot/src/share/vm/prims/jni.cpp b/hotspot/src/share/vm/prims/jni.cpp index ab24446baf1..449ed679847 100644 --- a/hotspot/src/share/vm/prims/jni.cpp +++ b/hotspot/src/share/vm/prims/jni.cpp @@ -1804,34 +1804,34 @@ JNI_END // the runtime type of subword integral basic types is integer DEFINE_CALLMETHODV(jboolean, Boolean, T_BOOLEAN - , HOTSPOT_JNI_CALLBOOLEANMETHOD_ENTRY(env, obj, (uintptr_t)methodID), - HOTSPOT_JNI_CALLBOOLEANMETHOD_RETURN(_ret_ref)) + , HOTSPOT_JNI_CALLBOOLEANMETHODV_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLBOOLEANMETHODV_RETURN(_ret_ref)) DEFINE_CALLMETHODV(jbyte, Byte, T_BYTE - , HOTSPOT_JNI_CALLBYTEMETHOD_ENTRY(env, obj, (uintptr_t)methodID), - HOTSPOT_JNI_CALLBYTEMETHOD_RETURN(_ret_ref)) + , HOTSPOT_JNI_CALLBYTEMETHODV_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLBYTEMETHODV_RETURN(_ret_ref)) DEFINE_CALLMETHODV(jchar, Char, T_CHAR - , HOTSPOT_JNI_CALLCHARMETHOD_ENTRY(env, obj, (uintptr_t)methodID), - HOTSPOT_JNI_CALLCHARMETHOD_RETURN(_ret_ref)) + , HOTSPOT_JNI_CALLCHARMETHODV_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLCHARMETHODV_RETURN(_ret_ref)) DEFINE_CALLMETHODV(jshort, Short, T_SHORT - , HOTSPOT_JNI_CALLSHORTMETHOD_ENTRY(env, obj, (uintptr_t)methodID), - HOTSPOT_JNI_CALLSHORTMETHOD_RETURN(_ret_ref)) + , HOTSPOT_JNI_CALLSHORTMETHODV_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLSHORTMETHODV_RETURN(_ret_ref)) DEFINE_CALLMETHODV(jobject, Object, T_OBJECT - , HOTSPOT_JNI_CALLOBJECTMETHOD_ENTRY(env, obj, (uintptr_t)methodID), - HOTSPOT_JNI_CALLOBJECTMETHOD_RETURN(_ret_ref)) + , HOTSPOT_JNI_CALLOBJECTMETHODV_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLOBJECTMETHODV_RETURN(_ret_ref)) DEFINE_CALLMETHODV(jint, Int, T_INT, - HOTSPOT_JNI_CALLINTMETHOD_ENTRY(env, obj, (uintptr_t)methodID), - HOTSPOT_JNI_CALLINTMETHOD_RETURN(_ret_ref)) + HOTSPOT_JNI_CALLINTMETHODV_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLINTMETHODV_RETURN(_ret_ref)) DEFINE_CALLMETHODV(jlong, Long, T_LONG - , HOTSPOT_JNI_CALLLONGMETHOD_ENTRY(env, obj, (uintptr_t)methodID), - HOTSPOT_JNI_CALLLONGMETHOD_RETURN(_ret_ref)) + , HOTSPOT_JNI_CALLLONGMETHODV_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLLONGMETHODV_RETURN(_ret_ref)) // Float and double probes don't return value because dtrace doesn't currently support it DEFINE_CALLMETHODV(jfloat, Float, T_FLOAT - , HOTSPOT_JNI_CALLFLOATMETHOD_ENTRY(env, obj, (uintptr_t)methodID), - HOTSPOT_JNI_CALLFLOATMETHOD_RETURN()) + , HOTSPOT_JNI_CALLFLOATMETHODV_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLFLOATMETHODV_RETURN()) DEFINE_CALLMETHODV(jdouble, Double, T_DOUBLE - , HOTSPOT_JNI_CALLDOUBLEMETHOD_ENTRY(env, obj, (uintptr_t)methodID), - HOTSPOT_JNI_CALLDOUBLEMETHOD_RETURN()) + , HOTSPOT_JNI_CALLDOUBLEMETHODV_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLDOUBLEMETHODV_RETURN()) #define DEFINE_CALLMETHODA(ResultType, Result, Tag \ , EntryProbe, ReturnProbe) \ @@ -1856,34 +1856,34 @@ JNI_END // the runtime type of subword integral basic types is integer DEFINE_CALLMETHODA(jboolean, Boolean, T_BOOLEAN - , HOTSPOT_JNI_CALLBOOLEANMETHOD_ENTRY(env, obj, (uintptr_t)methodID), - HOTSPOT_JNI_CALLBOOLEANMETHOD_RETURN(_ret_ref)) + , HOTSPOT_JNI_CALLBOOLEANMETHODA_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLBOOLEANMETHODA_RETURN(_ret_ref)) DEFINE_CALLMETHODA(jbyte, Byte, T_BYTE - , HOTSPOT_JNI_CALLBYTEMETHOD_ENTRY(env, obj, (uintptr_t)methodID), - HOTSPOT_JNI_CALLBYTEMETHOD_RETURN(_ret_ref)) + , HOTSPOT_JNI_CALLBYTEMETHODA_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLBYTEMETHODA_RETURN(_ret_ref)) DEFINE_CALLMETHODA(jchar, Char, T_CHAR - , HOTSPOT_JNI_CALLCHARMETHOD_ENTRY(env, obj, (uintptr_t)methodID), - HOTSPOT_JNI_CALLCHARMETHOD_RETURN(_ret_ref)) + , HOTSPOT_JNI_CALLCHARMETHODA_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLCHARMETHODA_RETURN(_ret_ref)) DEFINE_CALLMETHODA(jshort, Short, T_SHORT - , HOTSPOT_JNI_CALLSHORTMETHOD_ENTRY(env, obj, (uintptr_t)methodID), - HOTSPOT_JNI_CALLSHORTMETHOD_RETURN(_ret_ref)) + , HOTSPOT_JNI_CALLSHORTMETHODA_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLSHORTMETHODA_RETURN(_ret_ref)) DEFINE_CALLMETHODA(jobject, Object, T_OBJECT - , HOTSPOT_JNI_CALLOBJECTMETHOD_ENTRY(env, obj, (uintptr_t)methodID), - HOTSPOT_JNI_CALLOBJECTMETHOD_RETURN(_ret_ref)) + , HOTSPOT_JNI_CALLOBJECTMETHODA_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLOBJECTMETHODA_RETURN(_ret_ref)) DEFINE_CALLMETHODA(jint, Int, T_INT, - HOTSPOT_JNI_CALLINTMETHOD_ENTRY(env, obj, (uintptr_t)methodID), - HOTSPOT_JNI_CALLINTMETHOD_RETURN(_ret_ref)) + HOTSPOT_JNI_CALLINTMETHODA_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLINTMETHODA_RETURN(_ret_ref)) DEFINE_CALLMETHODA(jlong, Long, T_LONG - , HOTSPOT_JNI_CALLLONGMETHOD_ENTRY(env, obj, (uintptr_t)methodID), - HOTSPOT_JNI_CALLLONGMETHOD_RETURN(_ret_ref)) + , HOTSPOT_JNI_CALLLONGMETHODA_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLLONGMETHODA_RETURN(_ret_ref)) // Float and double probes don't return value because dtrace doesn't currently support it DEFINE_CALLMETHODA(jfloat, Float, T_FLOAT - , HOTSPOT_JNI_CALLFLOATMETHOD_ENTRY(env, obj, (uintptr_t)methodID), - HOTSPOT_JNI_CALLFLOATMETHOD_RETURN()) + , HOTSPOT_JNI_CALLFLOATMETHODA_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLFLOATMETHODA_RETURN()) DEFINE_CALLMETHODA(jdouble, Double, T_DOUBLE - , HOTSPOT_JNI_CALLDOUBLEMETHOD_ENTRY(env, obj, (uintptr_t)methodID), - HOTSPOT_JNI_CALLDOUBLEMETHOD_RETURN()) + , HOTSPOT_JNI_CALLDOUBLEMETHODA_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLDOUBLEMETHODA_RETURN()) DT_VOID_RETURN_MARK_DECL(CallVoidMethod, HOTSPOT_JNI_CALLVOIDMETHOD_RETURN()); DT_VOID_RETURN_MARK_DECL(CallVoidMethodV, HOTSPOT_JNI_CALLVOIDMETHODV_RETURN()); @@ -3145,7 +3145,7 @@ JNI_ENTRY(void, jni_SetStatic##Result##Field(JNIEnv *env, jclass clazz, jfieldID JNI_END DEFINE_SETSTATICFIELD(jboolean, bool, Boolean, 'Z', z - , HOTSPOT_JNI_SETBOOLEANFIELD_ENTRY(env, clazz, (uintptr_t)fieldID, value), + , HOTSPOT_JNI_SETSTATICBOOLEANFIELD_ENTRY(env, clazz, (uintptr_t)fieldID, value), HOTSPOT_JNI_SETBOOLEANFIELD_RETURN()) DEFINE_SETSTATICFIELD(jbyte, byte, Byte, 'B', b , HOTSPOT_JNI_SETSTATICBYTEFIELD_ENTRY(env, clazz, (uintptr_t) fieldID, value), diff --git a/hotspot/src/share/vm/prims/jniCheck.cpp b/hotspot/src/share/vm/prims/jniCheck.cpp index b829d14dd23..4313b4bf0ac 100644 --- a/hotspot/src/share/vm/prims/jniCheck.cpp +++ b/hotspot/src/share/vm/prims/jniCheck.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 diff --git a/hotspot/src/share/vm/prims/jvm.cpp b/hotspot/src/share/vm/prims/jvm.cpp index a757e194827..1059783eb05 100644 --- a/hotspot/src/share/vm/prims/jvm.cpp +++ b/hotspot/src/share/vm/prims/jvm.cpp @@ -3971,40 +3971,6 @@ jclass find_class_from_class_loader(JNIEnv* env, Symbol* name, jboolean init, Ha } -// Internal SQE debugging support /////////////////////////////////////////////////////////// - -#ifndef PRODUCT - -extern "C" { - JNIEXPORT jboolean JNICALL JVM_AccessVMBooleanFlag(const char* name, jboolean* value, jboolean is_get); - JNIEXPORT jboolean JNICALL JVM_AccessVMIntFlag(const char* name, jint* value, jboolean is_get); - JNIEXPORT void JNICALL JVM_VMBreakPoint(JNIEnv *env, jobject obj); -} - -JVM_LEAF(jboolean, JVM_AccessVMBooleanFlag(const char* name, jboolean* value, jboolean is_get)) - JVMWrapper("JVM_AccessBoolVMFlag"); - return is_get ? CommandLineFlags::boolAt((char*) name, (bool*) value) : CommandLineFlags::boolAtPut((char*) name, (bool*) value, Flag::INTERNAL); -JVM_END - -JVM_LEAF(jboolean, JVM_AccessVMIntFlag(const char* name, jint* value, jboolean is_get)) - JVMWrapper("JVM_AccessVMIntFlag"); - intx v; - jboolean result = is_get ? CommandLineFlags::intxAt((char*) name, &v) : CommandLineFlags::intxAtPut((char*) name, &v, Flag::INTERNAL); - *value = (jint)v; - return result; -JVM_END - - -JVM_ENTRY(void, JVM_VMBreakPoint(JNIEnv *env, jobject obj)) - JVMWrapper("JVM_VMBreakPoint"); - oop the_obj = JNIHandles::resolve(obj); - BREAKPOINT; -JVM_END - - -#endif - - // Method /////////////////////////////////////////////////////////////////////////////////////////// JVM_ENTRY(jobject, JVM_InvokeMethod(JNIEnv *env, jobject method, jobject obj, jobjectArray args0)) diff --git a/hotspot/src/share/vm/prims/jvm_misc.hpp b/hotspot/src/share/vm/prims/jvm_misc.hpp index 266ed8690db..39b2d7199d4 100644 --- a/hotspot/src/share/vm/prims/jvm_misc.hpp +++ b/hotspot/src/share/vm/prims/jvm_misc.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/hotspot/src/share/vm/prims/jvmtiClassFileReconstituter.cpp b/hotspot/src/share/vm/prims/jvmtiClassFileReconstituter.cpp index c931e3f8e78..95129c06b9a 100644 --- a/hotspot/src/share/vm/prims/jvmtiClassFileReconstituter.cpp +++ b/hotspot/src/share/vm/prims/jvmtiClassFileReconstituter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 diff --git a/hotspot/src/share/vm/prims/jvmtiClassFileReconstituter.hpp b/hotspot/src/share/vm/prims/jvmtiClassFileReconstituter.hpp index d9d475b11ad..4170cf9155d 100644 --- a/hotspot/src/share/vm/prims/jvmtiClassFileReconstituter.hpp +++ b/hotspot/src/share/vm/prims/jvmtiClassFileReconstituter.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 diff --git a/hotspot/src/share/vm/prims/jvmtiEnter.xsl b/hotspot/src/share/vm/prims/jvmtiEnter.xsl index f31bd5143b7..ff609eee2f9 100644 --- a/hotspot/src/share/vm/prims/jvmtiEnter.xsl +++ b/hotspot/src/share/vm/prims/jvmtiEnter.xsl @@ -1,6 +1,6 @@ NO --> Is Dual-Mode ? --> NO --> Exit(with error) - * | | - * | | - * | \|/ - * | YES - * | | - * | | - * | \|/ - * | CheckJvmType - * | (removes -client, -server etc.) - * | | - * | | - * \|/ \|/ - * YES Find the desired executable/library - * | | - * | | - * \|/ \|/ - * CheckJvmType RequiresSetenv + * Have Desired Model ? --> NO --> Exit(with error) + * | + * | + * \|/ + * YES + * | + * | + * \|/ + * CheckJvmType * (removes -client, -server, etc.) * | * | @@ -155,24 +137,24 @@ * \|/ * RequiresSetenv * Is LD_LIBRARY_PATH - * and friends set ? --> NO --> Have Desired Model ? NO --> Re-exec --> Main + * and friends set ? --> NO --> Have Desired Model ? NO --> Error/Exit * YES YES --> Continue * | * | * \|/ - * Path is desired JRE ? YES --> Have Desired Model ? NO --> Re-exec --> Main + * Path is desired JRE ? YES --> Have Desired Model ? NO --> Error/Exit * NO YES --> Continue * | * | * \|/ * Paths have well known - * jvm paths ? --> NO --> Have Desired Model ? NO --> Re-exec --> Main + * jvm paths ? --> NO --> Have Desired Model ? NO --> Error/Exit * YES YES --> Continue * | * | * \|/ * Does libjvm.so exit - * in any of them ? --> NO --> Have Desired Model ? NO --> Re-exec --> Main + * in any of them ? --> NO --> Have Desired Model ? NO --> Error/Exit * YES YES --> Continue * | * | @@ -188,8 +170,6 @@ * Main */ -#define GetArch() GetArchPath(CURRENT_DATA_MODEL) - /* Store the name of the executable once computed */ static char *execname = NULL; @@ -201,21 +181,6 @@ GetExecName() { return execname; } -const char * -GetArchPath(int nbits) -{ - switch(nbits) { -#ifdef DUAL_MODE - case 32: - return LIBARCH32NAME; - case 64: - return LIBARCH64NAME; -#endif /* DUAL_MODE */ - default: - return LIBARCHNAME; - } -} - #ifdef SETENV_REQUIRED static jboolean JvmExists(const char *path) { @@ -228,10 +193,10 @@ JvmExists(const char *path) { return JNI_FALSE; } /* - * contains a lib/$LIBARCH/{server,client}/libjvm.so ? + * contains a lib/$LIBARCHNAME/{server,client}/libjvm.so ? */ static jboolean -ContainsLibJVM(int wanted, const char *env) { +ContainsLibJVM(const char *env) { char clientPattern[PATH_MAX + 1]; char serverPattern[PATH_MAX + 1]; char *envpath; @@ -245,8 +210,8 @@ ContainsLibJVM(int wanted, const char *env) { } /* the usual suspects */ - JLI_Snprintf(clientPattern, PATH_MAX, "lib/%s/client", GetArchPath(wanted)); - JLI_Snprintf(serverPattern, PATH_MAX, "lib/%s/server", GetArchPath(wanted)); + JLI_Snprintf(clientPattern, PATH_MAX, "lib/%s/client", LIBARCHNAME); + JLI_Snprintf(serverPattern, PATH_MAX, "lib/%s/server", LIBARCHNAME); /* to optimize for time, test if any of our usual suspects are present. */ clientPatternFound = JLI_StrStr(env, clientPattern) != NULL; @@ -281,17 +246,20 @@ ContainsLibJVM(int wanted, const char *env) { * Test whether the environment variable needs to be set, see flowchart. */ static jboolean -RequiresSetenv(int wanted, const char *jvmpath) { +RequiresSetenv(const char *jvmpath) { char jpath[PATH_MAX + 1]; char *llp; char *dmllp = NULL; char *p; /* a utility pointer */ +#ifdef AIX + /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */ + return JNI_TRUE; +#endif + llp = getenv("LD_LIBRARY_PATH"); #ifdef __solaris__ - dmllp = (CURRENT_DATA_MODEL == 32) - ? getenv("LD_LIBRARY_PATH_32") - : getenv("LD_LIBRARY_PATH_64"); + dmllp = getenv("LD_LIBRARY_PATH_64"); #endif /* __solaris__ */ /* no environment variable is a good environment variable */ if (llp == NULL && dmllp == NULL) { @@ -330,10 +298,10 @@ RequiresSetenv(int wanted, const char *jvmpath) { } /* scrutinize all the paths further */ - if (llp != NULL && ContainsLibJVM(wanted, llp)) { + if (llp != NULL && ContainsLibJVM(llp)) { return JNI_TRUE; } - if (dmllp != NULL && ContainsLibJVM(wanted, dmllp)) { + if (dmllp != NULL && ContainsLibJVM(dmllp)) { return JNI_TRUE; } return JNI_FALSE; @@ -349,10 +317,8 @@ CreateExecutionEnvironment(int *pargc, char ***pargv, * First, determine if we are running the desired data model. If we * are running the desired data model, all the error messages * associated with calling GetJREPath, ReadKnownVMs, etc. should be - * output. However, if we are not running the desired data model, - * some of the errors should be suppressed since it is more - * informative to issue an error message based on whether or not the - * os/processor combination has dual mode capabilities. + * output, otherwise we simply exit with an error, as we no longer + * support dual data models. */ jboolean jvmpathExists; @@ -361,16 +327,17 @@ CreateExecutionEnvironment(int *pargc, char ***pargv, /* Check data model flags, and exec process, if needed */ { - char *arch = (char *)GetArch(); /* like sparc or sparcv9 */ + char *arch = LIBARCHNAME; /* like sparc or sparcv9 */ char * jvmtype = NULL; int argc = *pargc; char **argv = *pargv; int running = CURRENT_DATA_MODEL; - - int wanted = running; /* What data mode is being - asked for? Current model is - fine unless another model - is asked for */ + /* + * As of jdk9, there is no support for dual mode operations, however + * for legacy error reporting purposes and until -d options are supported + * we need this. + */ + int wanted = running; #ifdef SETENV_REQUIRED jboolean mustsetenv = JNI_FALSE; char *runpath = NULL; /* existing effective LD_LIBRARY_PATH setting */ @@ -473,7 +440,7 @@ CreateExecutionEnvironment(int *pargc, char ***pargv, * we return back, otherwise proceed to set the environment. */ #ifdef SETENV_REQUIRED - mustsetenv = RequiresSetenv(wanted, jvmpath); + mustsetenv = RequiresSetenv(jvmpath); JLI_TraceLauncher("mustsetenv: %s\n", mustsetenv ? "TRUE" : "FALSE"); if (mustsetenv == JNI_FALSE) { @@ -481,47 +448,13 @@ CreateExecutionEnvironment(int *pargc, char ***pargv, return; } #else - JLI_MemFree(newargv); - return; + JLI_MemFree(newargv); + return; #endif /* SETENV_REQUIRED */ - } else { /* do the same speculatively or exit */ -#ifdef DUAL_MODE - if (running != wanted) { - /* Find out where the JRE is that we will be using. */ - if (!GetJREPath(jrepath, so_jrepath, GetArchPath(wanted), JNI_TRUE)) { - /* give up and let other code report error message */ - JLI_ReportErrorMessage(JRE_ERROR2, wanted); - exit(1); - } - JLI_Snprintf(jvmcfg, so_jvmcfg, "%s%slib%s%s%sjvm.cfg", - jrepath, FILESEP, FILESEP, GetArchPath(wanted), FILESEP); - /* - * Read in jvm.cfg for target data model and process vm - * selection options. - */ - if (ReadKnownVMs(jvmcfg, JNI_TRUE) < 1) { - /* give up and let other code report error message */ - JLI_ReportErrorMessage(JRE_ERROR2, wanted); - exit(1); - } - jvmpath[0] = '\0'; - jvmtype = CheckJvmType(pargc, pargv, JNI_TRUE); - if (JLI_StrCmp(jvmtype, "ERROR") == 0) { - JLI_ReportErrorMessage(CFG_ERROR9); - exit(4); - } - - /* exec child can do error checking on the existence of the path */ - jvmpathExists = GetJVMPath(jrepath, jvmtype, jvmpath, so_jvmpath, GetArchPath(wanted), 0); -#ifdef SETENV_REQUIRED - mustsetenv = RequiresSetenv(wanted, jvmpath); -#endif /* SETENV_REQUIRED */ - } -#else /* ! DUALMODE */ + } else { /* do the same speculatively or exit */ JLI_ReportErrorMessage(JRE_ERROR2, wanted); exit(1); -#endif /* DUAL_MODE */ - } + } #ifdef SETENV_REQUIRED if (mustsetenv) { /* @@ -545,10 +478,6 @@ CreateExecutionEnvironment(int *pargc, char ***pargv, * * 2. LD_LIBRARY_PATH_64 -- overrides and replaces LD_LIBRARY_PATH * for 64-bit binaries. - * - * 3. LD_LIBRARY_PATH_32 -- overrides and replaces LD_LIBRARY_PATH - * for 32-bit binaries. - * * The vm uses LD_LIBRARY_PATH to set the java.library.path system * property. To shield the vm from the complication of multiple * LD_LIBRARY_PATH variables, if the appropriate data model @@ -561,21 +490,9 @@ CreateExecutionEnvironment(int *pargc, char ***pargv, switch (wanted) { case 0: - if (running == 32) { - dmpath = getenv("LD_LIBRARY_PATH_32"); - wanted = 32; - } else { - dmpath = getenv("LD_LIBRARY_PATH_64"); - wanted = 64; - } - break; - - case 32: - dmpath = getenv("LD_LIBRARY_PATH_32"); - break; - case 64: dmpath = getenv("LD_LIBRARY_PATH_64"); + wanted = 64; break; default: @@ -598,7 +515,7 @@ CreateExecutionEnvironment(int *pargc, char ***pargv, * If not on Solaris, assume only a single LD_LIBRARY_PATH * variable. */ - runpath = getenv("LD_LIBRARY_PATH"); + runpath = getenv(LD_LIBRARY_PATH); #endif /* __solaris__ */ /* runpath contains current effective LD_LIBRARY_PATH setting */ @@ -606,8 +523,12 @@ CreateExecutionEnvironment(int *pargc, char ***pargv, jvmpath = JLI_StringDup(jvmpath); new_runpath = JLI_MemAlloc(((runpath != NULL) ? JLI_StrLen(runpath) : 0) + 2 * JLI_StrLen(jrepath) + 2 * JLI_StrLen(arch) + +#ifdef AIX + /* On AIX we additionally need 'jli' in the path because ld doesn't support $ORIGIN. */ + JLI_StrLen(jrepath) + JLI_StrLen(arch) + JLI_StrLen("/lib//jli:") + +#endif JLI_StrLen(jvmpath) + 52); - newpath = new_runpath + JLI_StrLen("LD_LIBRARY_PATH="); + newpath = new_runpath + JLI_StrLen(LD_LIBRARY_PATH "="); /* @@ -619,18 +540,19 @@ CreateExecutionEnvironment(int *pargc, char ***pargv, if (lastslash) *lastslash = '\0'; - sprintf(new_runpath, "LD_LIBRARY_PATH=" + sprintf(new_runpath, LD_LIBRARY_PATH "=" "%s:" "%s/lib/%s:" +#ifdef AIX + "%s/lib/%s/jli:" /* Needed on AIX because ld doesn't support $ORIGIN. */ +#endif "%s/../lib/%s", jvmpath, -#ifdef DUAL_MODE - jrepath, GetArchPath(wanted), - jrepath, GetArchPath(wanted) -#else /* !DUAL_MODE */ jrepath, arch, +#ifdef AIX + jrepath, arch, +#endif jrepath, arch -#endif /* DUAL_MODE */ ); @@ -681,7 +603,7 @@ CreateExecutionEnvironment(int *pargc, char ***pargv, * in the environment for the exec'ed child. */ if (dmpath != NULL) - (void)UnsetEnv((wanted == 32) ? "LD_LIBRARY_PATH_32" : "LD_LIBRARY_PATH_64"); + (void)UnsetEnv("LD_LIBRARY_PATH_64"); #endif /* __solaris */ newenvp = environ; @@ -689,34 +611,6 @@ CreateExecutionEnvironment(int *pargc, char ***pargv, #endif /* SETENV_REQUIRED */ { char *newexec = execname; -#ifdef DUAL_MODE - /* - * If the data model is being changed, the path to the - * executable must be updated accordingly; the executable name - * and directory the executable resides in are separate. In the - * case of 32 => 64, the new bits are assumed to reside in, e.g. - * "olddir/LIBARCH64NAME/execname"; in the case of 64 => 32, - * the bits are assumed to be in "olddir/../execname". For example, - * - * olddir/sparcv9/execname - * olddir/amd64/execname - * - * for Solaris SPARC and Linux amd64, respectively. - */ - - if (running != wanted) { - char *oldexec = JLI_StrCpy(JLI_MemAlloc(JLI_StrLen(execname) + 1), execname); - char *olddir = oldexec; - char *oldbase = JLI_StrRChr(oldexec, '/'); - - - newexec = JLI_MemAlloc(JLI_StrLen(execname) + 20); - *oldbase++ = 0; - sprintf(newexec, "%s/%s/%s", olddir, - ((wanted == 64) ? LIBARCH64NAME : ".."), oldbase); - argv[0] = newexec; - } -#endif /* DUAL_MODE */ JLI_TraceLauncher("TRACER_MARKER:About to EXEC\n"); (void) fflush(stdout); (void) fflush(stderr); @@ -730,20 +624,6 @@ CreateExecutionEnvironment(int *pargc, char ***pargv, execv(newexec, argv); #endif /* SETENV_REQUIRED */ JLI_ReportErrorMessageSys(JRE_ERROR4, newexec); - -#ifdef DUAL_MODE - if (running != wanted) { - JLI_ReportErrorMessage(JRE_ERROR5, wanted, running); -#ifdef __solaris__ -#ifdef __sparc - JLI_ReportErrorMessage(JRE_ERROR6); -#else /* ! __sparc__ */ - JLI_ReportErrorMessage(JRE_ERROR7); -#endif /* __sparc */ -#endif /* __solaris__ */ - } -#endif /* DUAL_MODE */ - } exit(1); } @@ -961,12 +841,12 @@ void* SplashProcAddress(const char* name) { char jrePath[MAXPATHLEN]; char splashPath[MAXPATHLEN]; - if (!GetJREPath(jrePath, sizeof(jrePath), GetArch(), JNI_FALSE)) { + if (!GetJREPath(jrePath, sizeof(jrePath), LIBARCHNAME, JNI_FALSE)) { JLI_ReportErrorMessage(JRE_ERROR1); return NULL; } ret = JLI_Snprintf(splashPath, sizeof(splashPath), "%s/lib/%s/%s", - jrePath, GetArch(), SPLASHSCREEN_SO); + jrePath, LIBARCHNAME, SPLASHSCREEN_SO); if (ret >= (int) sizeof(splashPath)) { JLI_ReportErrorMessage(JRE_ERROR11); @@ -1000,7 +880,7 @@ void SplashFreeLibrary() { int ContinueInNewThread0(int (JNICALL *continuation)(void *), jlong stack_size, void * args) { int rslt; -#ifdef __linux__ +#ifndef __solaris__ pthread_t tid; pthread_attr_t attr; pthread_attr_init(&attr); @@ -1025,7 +905,7 @@ ContinueInNewThread0(int (JNICALL *continuation)(void *), jlong stack_size, void } pthread_attr_destroy(&attr); -#else /* ! __linux__ */ +#else /* __solaris__ */ thread_t tid; long flags = 0; if (thr_create(NULL, stack_size, (void *(*)(void *))continuation, args, flags, &tid) == 0) { @@ -1036,7 +916,7 @@ ContinueInNewThread0(int (JNICALL *continuation)(void *), jlong stack_size, void /* See above. Continue in current thread if thr_create() failed */ rslt = continuation(args); } -#endif /* __linux__ */ +#endif /* !__solaris__ */ return rslt; } diff --git a/jdk/src/solaris/bin/java_md_solinux.h b/jdk/src/solaris/bin/java_md_solinux.h index a9e4438a5e2..3f1dc115b4d 100644 --- a/jdk/src/solaris/bin/java_md_solinux.h +++ b/jdk/src/solaris/bin/java_md_solinux.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -45,23 +45,19 @@ extern char **environ; * A collection of useful strings. One should think of these as #define * entries, but actual strings can be more efficient (with many compilers). */ -#ifdef __linux__ -static const char *system_dir = "/usr/java"; -static const char *user_dir = "/java"; -#else /* Solaris */ +#ifdef __solaris__ static const char *system_dir = "/usr/jdk"; static const char *user_dir = "/jdk"; +#else /* !__solaris__, i.e. Linux, AIX,.. */ +static const char *system_dir = "/usr/java"; +static const char *user_dir = "/java"; #endif #include -#ifdef __linux__ -#include -#else +#ifdef __solaris__ #include +#else +#include #endif -#define JVM_DLL "libjvm.so" -#define JAVA_DLL "libjava.so" -#define LD_LIBRARY_PATH "LD_LIBRARY_PATH" - #endif /* JAVA_MD_SOLINUX_H */ diff --git a/jdk/src/solaris/bin/ppc64/jvm.cfg b/jdk/src/solaris/bin/ppc64/jvm.cfg new file mode 100644 index 00000000000..2fc1214175b --- /dev/null +++ b/jdk/src/solaris/bin/ppc64/jvm.cfg @@ -0,0 +1,33 @@ +# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# +# List of JVMs that can be used as an option to java, javac, etc. +# Order is important -- first in this list is the default JVM. +# NOTE that this both this file and its format are UNSUPPORTED and +# WILL GO AWAY in a future release. +# +# You may also select a JVM in an arbitrary location with the +# "-XXaltjvm=" option, but that too is unsupported +# and may not be available in a future release. +# +-server KNOWN diff --git a/jdk/src/solaris/classes/java/lang/UNIXProcess.java.aix b/jdk/src/solaris/classes/java/lang/UNIXProcess.java.aix new file mode 100644 index 00000000000..24216461657 --- /dev/null +++ b/jdk/src/solaris/classes/java/lang/UNIXProcess.java.aix @@ -0,0 +1,504 @@ +/* + * Copyright (c) 1995, 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 java.lang; + +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.ByteArrayInputStream; +import java.io.FileDescriptor; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.Arrays; +import java.util.concurrent.Executors; +import java.util.concurrent.Executor; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.TimeUnit; +import java.security.AccessController; +import static java.security.AccessController.doPrivileged; +import java.security.PrivilegedAction; +import java.security.PrivilegedActionException; +import java.security.PrivilegedExceptionAction; + +/** + * java.lang.Process subclass in the UNIX environment. + * + * @author Mario Wolczko and Ross Knippel. + * @author Konstantin Kladko (ported to Linux) + * @author Martin Buchholz + * @author Volker Simonis (ported to AIX) + */ +final class UNIXProcess extends Process { + private static final sun.misc.JavaIOFileDescriptorAccess fdAccess + = sun.misc.SharedSecrets.getJavaIOFileDescriptorAccess(); + + private final int pid; + private int exitcode; + private boolean hasExited; + + private /* final */ OutputStream stdin; + private /* final */ InputStream stdout; + private /* final */ InputStream stderr; + + private static enum LaunchMechanism { + FORK(1), + POSIX_SPAWN(2); + + private int value; + LaunchMechanism(int x) {value = x;} + }; + + /* On AIX, the default is to spawn */ + private static final LaunchMechanism launchMechanism; + private static byte[] helperpath; + + private static byte[] toCString(String s) { + if (s == null) + return null; + byte[] bytes = s.getBytes(); + byte[] result = new byte[bytes.length + 1]; + System.arraycopy(bytes, 0, + result, 0, + bytes.length); + result[result.length-1] = (byte)0; + return result; + } + + static { + launchMechanism = AccessController.doPrivileged( + new PrivilegedAction() + { + public LaunchMechanism run() { + String javahome = System.getProperty("java.home"); + String osArch = System.getProperty("os.arch"); + + helperpath = toCString(javahome + "/lib/" + osArch + "/jspawnhelper"); + String s = System.getProperty( + "jdk.lang.Process.launchMechanism", "posix_spawn"); + + try { + return LaunchMechanism.valueOf(s.toUpperCase()); + } catch (IllegalArgumentException e) { + throw new Error(s + " is not a supported " + + "process launch mechanism on this platform."); + } + } + }); + } + + /* this is for the reaping thread */ + private native int waitForProcessExit(int pid); + + /** + * Create a process. Depending on the mode flag, this is done by + * one of the following mechanisms. + * - fork(2) and exec(2) + * - clone(2) and exec(2) + * - vfork(2) and exec(2) + * + * @param fds an array of three file descriptors. + * Indexes 0, 1, and 2 correspond to standard input, + * standard output and standard error, respectively. On + * input, a value of -1 means to create a pipe to connect + * child and parent processes. On output, a value which + * is not -1 is the parent pipe fd corresponding to the + * pipe which has been created. An element of this array + * is -1 on input if and only if it is not -1 on + * output. + * @return the pid of the subprocess + */ + private native int forkAndExec(int mode, byte[] helperpath, + byte[] prog, + byte[] argBlock, int argc, + byte[] envBlock, int envc, + byte[] dir, + int[] fds, + boolean redirectErrorStream) + throws IOException; + + /** + * The thread factory used to create "process reaper" daemon threads. + */ + private static class ProcessReaperThreadFactory implements ThreadFactory { + private final static ThreadGroup group = getRootThreadGroup(); + + private static ThreadGroup getRootThreadGroup() { + return doPrivileged(new PrivilegedAction () { + public ThreadGroup run() { + ThreadGroup root = Thread.currentThread().getThreadGroup(); + while (root.getParent() != null) + root = root.getParent(); + return root; + }}); + } + + public Thread newThread(Runnable grimReaper) { + // Our thread stack requirement is quite modest. + Thread t = new Thread(group, grimReaper, "process reaper", 32768); + t.setDaemon(true); + // A small attempt (probably futile) to avoid priority inversion + t.setPriority(Thread.MAX_PRIORITY); + return t; + } + } + + /** + * The thread pool of "process reaper" daemon threads. + */ + private static final Executor processReaperExecutor = + doPrivileged(new PrivilegedAction() { + public Executor run() { + return Executors.newCachedThreadPool + (new ProcessReaperThreadFactory()); + }}); + + UNIXProcess(final byte[] prog, + final byte[] argBlock, final int argc, + final byte[] envBlock, final int envc, + final byte[] dir, + final int[] fds, + final boolean redirectErrorStream) + throws IOException { + + pid = forkAndExec(launchMechanism.value, + helperpath, + prog, + argBlock, argc, + envBlock, envc, + dir, + fds, + redirectErrorStream); + + try { + doPrivileged(new PrivilegedExceptionAction() { + public Void run() throws IOException { + initStreams(fds); + return null; + }}); + } catch (PrivilegedActionException ex) { + throw (IOException) ex.getException(); + } + } + + static FileDescriptor newFileDescriptor(int fd) { + FileDescriptor fileDescriptor = new FileDescriptor(); + fdAccess.set(fileDescriptor, fd); + return fileDescriptor; + } + + void initStreams(int[] fds) throws IOException { + stdin = (fds[0] == -1) ? + ProcessBuilder.NullOutputStream.INSTANCE : + new ProcessPipeOutputStream(fds[0]); + + stdout = (fds[1] == -1) ? + ProcessBuilder.NullInputStream.INSTANCE : + new ProcessPipeInputStream(fds[1]); + + stderr = (fds[2] == -1) ? + ProcessBuilder.NullInputStream.INSTANCE : + new ProcessPipeInputStream(fds[2]); + + processReaperExecutor.execute(new Runnable() { + public void run() { + int exitcode = waitForProcessExit(pid); + UNIXProcess.this.processExited(exitcode); + }}); + } + + void processExited(int exitcode) { + synchronized (this) { + this.exitcode = exitcode; + hasExited = true; + notifyAll(); + } + + if (stdout instanceof ProcessPipeInputStream) + ((ProcessPipeInputStream) stdout).processExited(); + + if (stderr instanceof ProcessPipeInputStream) + ((ProcessPipeInputStream) stderr).processExited(); + + if (stdin instanceof ProcessPipeOutputStream) + ((ProcessPipeOutputStream) stdin).processExited(); + } + + public OutputStream getOutputStream() { + return stdin; + } + + public InputStream getInputStream() { + return stdout; + } + + public InputStream getErrorStream() { + return stderr; + } + + public synchronized int waitFor() throws InterruptedException { + while (!hasExited) { + wait(); + } + return exitcode; + } + + @Override + public synchronized boolean waitFor(long timeout, TimeUnit unit) + throws InterruptedException + { + if (hasExited) return true; + if (timeout <= 0) return false; + + long timeoutAsNanos = unit.toNanos(timeout); + long startTime = System.nanoTime(); + long rem = timeoutAsNanos; + + while (!hasExited && (rem > 0)) { + wait(Math.max(TimeUnit.NANOSECONDS.toMillis(rem), 1)); + rem = timeoutAsNanos - (System.nanoTime() - startTime); + } + return hasExited; + } + + public synchronized int exitValue() { + if (!hasExited) { + throw new IllegalThreadStateException("process hasn't exited"); + } + return exitcode; + } + + private static native void destroyProcess(int pid, boolean force); + private void destroy(boolean force) { + // There is a risk that pid will be recycled, causing us to + // kill the wrong process! So we only terminate processes + // that appear to still be running. Even with this check, + // there is an unavoidable race condition here, but the window + // is very small, and OSes try hard to not recycle pids too + // soon, so this is quite safe. + synchronized (this) { + if (!hasExited) + destroyProcess(pid, force); + } + try { stdin.close(); } catch (IOException ignored) {} + try { stdout.close(); } catch (IOException ignored) {} + try { stderr.close(); } catch (IOException ignored) {} + } + + public void destroy() { + destroy(false); + } + + @Override + public Process destroyForcibly() { + destroy(true); + return this; + } + + @Override + public synchronized boolean isAlive() { + return !hasExited; + } + + private static native void init(); + + static { + init(); + } + + /** + * A buffered input stream for a subprocess pipe file descriptor + * that allows the underlying file descriptor to be reclaimed when + * the process exits, via the processExited hook. + * + * This is tricky because we do not want the user-level InputStream to be + * closed until the user invokes close(), and we need to continue to be + * able to read any buffered data lingering in the OS pipe buffer. + * + * On AIX this is especially tricky, because the 'close()' system call + * will block if another thread is at the same time blocked in a file + * operation (e.g. 'read()') on the same file descriptor. We therefore + * combine this 'ProcessPipeInputStream' with the DeferredCloseInputStream + * approach used on Solaris (see "UNIXProcess.java.solaris"). This means + * that every potentially blocking operation on the file descriptor + * increments a counter before it is executed and decrements it once it + * finishes. The 'close()' operation will only be executed if there are + * no pending operations. Otherwise it is deferred after the last pending + * operation has finished. + * + */ + static class ProcessPipeInputStream extends BufferedInputStream { + private final Object closeLock = new Object(); + private int useCount = 0; + private boolean closePending = false; + + ProcessPipeInputStream(int fd) { + super(new FileInputStream(newFileDescriptor(fd))); + } + + private InputStream drainInputStream(InputStream in) + throws IOException { + int n = 0; + int j; + byte[] a = null; + synchronized (closeLock) { + if (buf == null) // asynchronous close()? + return null; // discard + j = in.available(); + } + while (j > 0) { + a = (a == null) ? new byte[j] : Arrays.copyOf(a, n + j); + synchronized (closeLock) { + if (buf == null) // asynchronous close()? + return null; // discard + n += in.read(a, n, j); + j = in.available(); + } + } + return (a == null) ? + ProcessBuilder.NullInputStream.INSTANCE : + new ByteArrayInputStream(n == a.length ? a : Arrays.copyOf(a, n)); + } + + /** Called by the process reaper thread when the process exits. */ + synchronized void processExited() { + try { + InputStream in = this.in; + if (in != null) { + InputStream stragglers = drainInputStream(in); + in.close(); + this.in = stragglers; + } + } catch (IOException ignored) { } + } + + private void raise() { + synchronized (closeLock) { + useCount++; + } + } + + private void lower() throws IOException { + synchronized (closeLock) { + useCount--; + if (useCount == 0 && closePending) { + closePending = false; + super.close(); + } + } + } + + @Override + public int read() throws IOException { + raise(); + try { + return super.read(); + } finally { + lower(); + } + } + + @Override + public int read(byte[] b) throws IOException { + raise(); + try { + return super.read(b); + } finally { + lower(); + } + } + + @Override + public int read(byte[] b, int off, int len) throws IOException { + raise(); + try { + return super.read(b, off, len); + } finally { + lower(); + } + } + + @Override + public long skip(long n) throws IOException { + raise(); + try { + return super.skip(n); + } finally { + lower(); + } + } + + @Override + public int available() throws IOException { + raise(); + try { + return super.available(); + } finally { + lower(); + } + } + + @Override + public void close() throws IOException { + // BufferedInputStream#close() is not synchronized unlike most other methods. + // Synchronizing helps avoid racing with drainInputStream(). + synchronized (closeLock) { + if (useCount == 0) { + super.close(); + } + else { + closePending = true; + } + } + } + } + + /** + * A buffered output stream for a subprocess pipe file descriptor + * that allows the underlying file descriptor to be reclaimed when + * the process exits, via the processExited hook. + */ + static class ProcessPipeOutputStream extends BufferedOutputStream { + ProcessPipeOutputStream(int fd) { + super(new FileOutputStream(newFileDescriptor(fd))); + } + + /** Called by the process reaper thread when the process exits. */ + synchronized void processExited() { + OutputStream out = this.out; + if (out != null) { + try { + out.close(); + } catch (IOException ignored) { + // We know of no reason to get an IOException, but if + // we do, there's nothing else to do but carry on. + } + this.out = ProcessBuilder.NullOutputStream.INSTANCE; + } + } + } +} diff --git a/jdk/src/solaris/classes/sun/awt/UNIXToolkit.java b/jdk/src/solaris/classes/sun/awt/UNIXToolkit.java index 50a913c5438..2fad1b6b4a7 100644 --- a/jdk/src/solaris/classes/sun/awt/UNIXToolkit.java +++ b/jdk/src/solaris/classes/sun/awt/UNIXToolkit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -49,7 +49,7 @@ public abstract class UNIXToolkit extends SunToolkit private BufferedImage tmpImage = null; public static int getDatatransferTimeout() { - Integer dt = (Integer)AccessController.doPrivileged( + Integer dt = AccessController.doPrivileged( new GetIntegerAction("sun.awt.datatransfer.timeout")); if (dt == null || dt <= 0) { return DEFAULT_DATATRANSFER_TIMEOUT; diff --git a/jdk/src/solaris/classes/sun/awt/X11/InfoWindow.java b/jdk/src/solaris/classes/sun/awt/X11/InfoWindow.java index 20c6174c2ee..48a5b946c81 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/InfoWindow.java +++ b/jdk/src/solaris/classes/sun/awt/X11/InfoWindow.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -451,7 +451,7 @@ public abstract class InfoWindow extends Window { while (true) { Message msg = null; try { - msg = (Message)messageQueue.take(); + msg = messageQueue.take(); } catch (InterruptedException e) { return; } diff --git a/jdk/src/solaris/classes/sun/awt/X11/MotifDnDConstants.java b/jdk/src/solaris/classes/sun/awt/X11/MotifDnDConstants.java index f35ba1c7e43..26e2cdbbba3 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/MotifDnDConstants.java +++ b/jdk/src/solaris/classes/sun/awt/X11/MotifDnDConstants.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, 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 @@ -163,7 +163,7 @@ class MotifDnDConstants { XlibWrapper.XGrabServer(newDisplay); try { - XlibWrapper.XSetCloseDownMode(newDisplay, (int)XConstants.RetainPermanent); + XlibWrapper.XSetCloseDownMode(newDisplay, XConstants.RetainPermanent); XSetWindowAttributes xwa = new XSetWindowAttributes(); @@ -435,7 +435,7 @@ class MotifDnDConstants { if (formats.length > 0) { // Make a defensive copy. - formats = (long[])formats.clone(); + formats = formats.clone(); Arrays.sort(formats); } diff --git a/jdk/src/solaris/classes/sun/awt/X11/MotifDnDDragSourceProtocol.java b/jdk/src/solaris/classes/sun/awt/X11/MotifDnDDragSourceProtocol.java index 85cd5448fd5..35109ebac70 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/MotifDnDDragSourceProtocol.java +++ b/jdk/src/solaris/classes/sun/awt/X11/MotifDnDDragSourceProtocol.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2010, 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 @@ -201,7 +201,7 @@ class MotifDnDDragSourceProtocol extends XDragSourceProtocol * CARD32 heap_offset B32; * } xmDragReceiverInfoStruct; */ - if (status == (int)XConstants.Success && wpg.getData() != 0 && + if (status == XConstants.Success && wpg.getData() != 0 && wpg.getActualType() != 0 && wpg.getActualFormat() == 8 && wpg.getNumberOfItems() >= MotifDnDConstants.MOTIF_RECEIVER_INFO_SIZE) { diff --git a/jdk/src/solaris/classes/sun/awt/X11/MotifDnDDropTargetProtocol.java b/jdk/src/solaris/classes/sun/awt/X11/MotifDnDDropTargetProtocol.java index 652b9e9e3af..735bf144df2 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/MotifDnDDropTargetProtocol.java +++ b/jdk/src/solaris/classes/sun/awt/X11/MotifDnDDropTargetProtocol.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, 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 @@ -118,7 +118,7 @@ class MotifDnDDropTargetProtocol extends XDropTargetProtocol { * CARD32 heap_offset B32; * } xmDragReceiverInfoStruct; */ - if (status == (int)XConstants.Success && wpg.getData() != 0 && + if (status == XConstants.Success && wpg.getData() != 0 && wpg.getActualType() != 0 && wpg.getActualFormat() == 8 && wpg.getNumberOfItems() >= MotifDnDConstants.MOTIF_RECEIVER_INFO_SIZE) { @@ -220,7 +220,7 @@ class MotifDnDDropTargetProtocol extends XDropTargetProtocol { * CARD32 heap_offset B32; * } xmDragReceiverInfoStruct; */ - if (status == (int)XConstants.Success && wpg.getData() != 0 && + if (status == XConstants.Success && wpg.getData() != 0 && wpg.getActualType() != 0 && wpg.getActualFormat() == 8 && wpg.getNumberOfItems() >= MotifDnDConstants.MOTIF_RECEIVER_INFO_SIZE) { @@ -292,7 +292,7 @@ class MotifDnDDropTargetProtocol extends XDropTargetProtocol { * CARD32 heap_offset B32; * } xmDragReceiverInfoStruct; */ - if (status == (int)XConstants.Success && wpg.getData() != 0 && + if (status == XConstants.Success && wpg.getData() != 0 && wpg.getActualType() != 0 && wpg.getActualFormat() == 8 && wpg.getNumberOfItems() >= MotifDnDConstants.MOTIF_RECEIVER_INFO_SIZE) { @@ -327,7 +327,7 @@ class MotifDnDDropTargetProtocol extends XDropTargetProtocol { try { int status = wpg.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance()); - if (status == (int)XConstants.Success && wpg.getData() != 0 && + if (status == XConstants.Success && wpg.getData() != 0 && wpg.getActualType() != 0 && wpg.getActualFormat() == 8 && wpg.getNumberOfItems() >= MotifDnDConstants.MOTIF_RECEIVER_INFO_SIZE) { diff --git a/jdk/src/solaris/classes/sun/awt/X11/XAWTFormatter.java b/jdk/src/solaris/classes/sun/awt/X11/XAWTFormatter.java index 20117bc47ad..a2145dcc3c2 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XAWTFormatter.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XAWTFormatter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2004, 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 @@ -43,7 +43,7 @@ public class XAWTFormatter extends java.util.logging.Formatter { // Line separator string. This is the value of the line.separator // property at the moment that the SimpleFormatter was created. - private String lineSeparator = (String) java.security.AccessController.doPrivileged( + private String lineSeparator = java.security.AccessController.doPrivileged( new sun.security.action.GetPropertyAction("line.separator")); boolean displayFullRecord = false; diff --git a/jdk/src/solaris/classes/sun/awt/X11/XAtom.java b/jdk/src/solaris/classes/sun/awt/X11/XAtom.java index 56ebd11b5dd..2d37879e057 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XAtom.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XAtom.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2008, 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 @@ -681,7 +681,7 @@ public final class XAtom { return emptyList; } - int count = (int)getter.getNumberOfItems(); + int count = getter.getNumberOfItems(); if (count == 0) { return emptyList; } diff --git a/jdk/src/solaris/classes/sun/awt/X11/XBaseMenuWindow.java b/jdk/src/solaris/classes/sun/awt/X11/XBaseMenuWindow.java index 2ccfcd083a5..1d82f04a78c 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XBaseMenuWindow.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XBaseMenuWindow.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 @@ -292,7 +292,7 @@ abstract public class XBaseMenuWindow extends XWindow { */ XMenuItemPeer[] copyItems() { synchronized(getMenuTreeLock()) { - return (XMenuItemPeer[])items.toArray(new XMenuItemPeer[] {}); + return items.toArray(new XMenuItemPeer[] {}); } } diff --git a/jdk/src/solaris/classes/sun/awt/X11/XBaseWindow.java b/jdk/src/solaris/classes/sun/awt/X11/XBaseWindow.java index 28db82f8a99..1d8804ec9c6 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XBaseWindow.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XBaseWindow.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2010, 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 @@ -285,7 +285,7 @@ public class XBaseWindow { params.putIfNull(BOUNDS, new Rectangle(DEF_LOCATION, DEF_LOCATION, MIN_SIZE, MIN_SIZE)); params.putIfNull(DEPTH, Integer.valueOf((int)XConstants.CopyFromParent)); params.putIfNull(VISUAL, Long.valueOf(XConstants.CopyFromParent)); - params.putIfNull(VISUAL_CLASS, Integer.valueOf((int)XConstants.InputOnly)); + params.putIfNull(VISUAL_CLASS, Integer.valueOf(XConstants.InputOnly)); params.putIfNull(VALUE_MASK, Long.valueOf(XConstants.CWEventMask)); Rectangle bounds = (Rectangle)params.get(BOUNDS); bounds.width = Math.max(MIN_SIZE, bounds.width); @@ -544,7 +544,7 @@ public class XBaseWindow { } flags |= XUtilConstants.PWinGravity; hints.set_flags(flags); - hints.set_win_gravity((int)XConstants.NorthWestGravity); + hints.set_win_gravity(XConstants.NorthWestGravity); if (insLog.isLoggable(PlatformLogger.Level.FINER)) { insLog.finer("Setting hints, resulted flags " + XlibWrapper.hintsToString(flags) + ", values " + hints); diff --git a/jdk/src/solaris/classes/sun/awt/X11/XComponentPeer.java b/jdk/src/solaris/classes/sun/awt/X11/XComponentPeer.java index c3cb2649c17..6bdff13fdc9 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XComponentPeer.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XComponentPeer.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 @@ -184,7 +184,7 @@ public class XComponentPeer extends XWindow implements ComponentPeer, DropTarget XWindowPeer wpeer = (XWindowPeer)(container.getPeer()); if (wpeer != null) { return (wpeer.winAttr.visibilityState != - wpeer.winAttr.AWT_UNOBSCURED); + XWindowAttributesData.AWT_UNOBSCURED); } } return true; @@ -335,7 +335,7 @@ public class XComponentPeer extends XWindow implements ComponentPeer, DropTarget return rejectFocusRequestHelper("Waiting for asynchronous processing of the request"); } return XKeyboardFocusManagerPeer.deliverFocus(lightweightChild, - (Component)target, + target, temporary, focusedWindowChangeAllowed, time, cause); diff --git a/jdk/src/solaris/classes/sun/awt/X11/XContentWindow.java b/jdk/src/solaris/classes/sun/awt/X11/XContentWindow.java index fcdd6d09f6c..85e578b4052 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XContentWindow.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XContentWindow.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, 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 @@ -137,7 +137,7 @@ public final class XContentWindow extends XWindow { // NOTE: This method may be called by privileged threads. // DO NOT INVOKE CLIENT CODE ON THIS THREAD! public void handleResize(Rectangle bounds) { - AWTAccessor.getComponentAccessor().setSize((Component)target, bounds.width, bounds.height); + AWTAccessor.getComponentAccessor().setSize(target, bounds.width, bounds.height); postEvent(new ComponentEvent(target, ComponentEvent.COMPONENT_RESIZED)); } diff --git a/jdk/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java b/jdk/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java index fa5c884020a..f37cfbc22e9 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XDecoratedPeer.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 @@ -318,7 +318,7 @@ abstract class XDecoratedPeer extends XWindowPeer { insets_corrected = true; return; } - Component t = (Component)target; + Component t = target; if (getDecorations() == XWindowAttributesData.AWT_DECOR_NONE) { setReparented(true); insets_corrected = true; @@ -428,7 +428,7 @@ abstract class XDecoratedPeer extends XWindowPeer { public void handleMoved(WindowDimensions dims) { Point loc = dims.getLocation(); - AWTAccessor.getComponentAccessor().setLocation((Component)target, loc.x, loc.y); + AWTAccessor.getComponentAccessor().setLocation(target, loc.x, loc.y); postEvent(new ComponentEvent(target, ComponentEvent.COMPONENT_MOVED)); } @@ -536,8 +536,8 @@ abstract class XDecoratedPeer extends XWindowPeer { // its location changes. Point oldLocation = getLocation(); - Point newLocation = new Point(AWTAccessor.getComponentAccessor().getX((Component)target), - AWTAccessor.getComponentAccessor().getY((Component)target)); + Point newLocation = new Point(AWTAccessor.getComponentAccessor().getX(target), + AWTAccessor.getComponentAccessor().getY(target)); if (!newLocation.equals(oldLocation)) { handleMoved(newDimensions); @@ -738,7 +738,7 @@ abstract class XDecoratedPeer extends XWindowPeer { updateChildrenSizes(); // Bounds of the window - Rectangle targetBounds = AWTAccessor.getComponentAccessor().getBounds((Component)target); + Rectangle targetBounds = AWTAccessor.getComponentAccessor().getBounds(target); Point newLocation = getNewLocation(xe, currentInsets.left, currentInsets.top); @@ -1052,10 +1052,10 @@ abstract class XDecoratedPeer extends XWindowPeer { final void dumpTarget() { AWTAccessor.ComponentAccessor compAccessor = AWTAccessor.getComponentAccessor(); - int getWidth = compAccessor.getWidth((Component)target); - int getHeight = compAccessor.getHeight((Component)target); - int getTargetX = compAccessor.getX((Component)target); - int getTargetY = compAccessor.getY((Component)target); + int getWidth = compAccessor.getWidth(target); + int getHeight = compAccessor.getHeight(target); + int getTargetX = compAccessor.getX(target); + int getTargetY = compAccessor.getY(target); System.err.println(">>> Target: " + getTargetX + ", " + getTargetY + ", " + getWidth + ", " + getHeight); } diff --git a/jdk/src/solaris/classes/sun/awt/X11/XDialogPeer.java b/jdk/src/solaris/classes/sun/awt/X11/XDialogPeer.java index fc0a0b7d44f..c2e451785f7 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XDialogPeer.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XDialogPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2008, 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 @@ -47,9 +47,9 @@ class XDialogPeer extends XDecoratedPeer implements DialogPeer { undecorated = Boolean.valueOf(target.isUndecorated()); winAttr.nativeDecor = !target.isUndecorated(); if (winAttr.nativeDecor) { - winAttr.decorations = winAttr.AWT_DECOR_ALL; + winAttr.decorations = XWindowAttributesData.AWT_DECOR_ALL; } else { - winAttr.decorations = winAttr.AWT_DECOR_NONE; + winAttr.decorations = XWindowAttributesData.AWT_DECOR_NONE; } winAttr.functions = MWMConstants.MWM_FUNC_ALL; winAttr.isResizable = true; //target.isResizable(); diff --git a/jdk/src/solaris/classes/sun/awt/X11/XDnDDragSourceProtocol.java b/jdk/src/solaris/classes/sun/awt/X11/XDnDDragSourceProtocol.java index 8a22f65eba1..b1e6f2ad041 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XDnDDragSourceProtocol.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XDnDDragSourceProtocol.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, 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 @@ -283,7 +283,7 @@ class XDnDDragSourceProtocol extends XDragSourceProtocol { XClientMessageEvent msg = new XClientMessageEvent(); try { - msg.set_type((int)XConstants.ClientMessage); + msg.set_type(XConstants.ClientMessage); msg.set_window(getTargetWindow()); msg.set_format(32); msg.set_message_type(XDnDConstants.XA_XdndEnter.getAtom()); @@ -311,7 +311,7 @@ class XDnDDragSourceProtocol extends XDragSourceProtocol { XClientMessageEvent msg = new XClientMessageEvent(); try { - msg.set_type((int)XConstants.ClientMessage); + msg.set_type(XConstants.ClientMessage); msg.set_window(getTargetWindow()); msg.set_format(32); msg.set_message_type(XDnDConstants.XA_XdndPosition.getAtom()); @@ -335,7 +335,7 @@ class XDnDDragSourceProtocol extends XDragSourceProtocol { XClientMessageEvent msg = new XClientMessageEvent(); try { - msg.set_type((int)XConstants.ClientMessage); + msg.set_type(XConstants.ClientMessage); msg.set_window(getTargetWindow()); msg.set_format(32); msg.set_message_type(XDnDConstants.XA_XdndLeave.getAtom()); @@ -361,7 +361,7 @@ class XDnDDragSourceProtocol extends XDragSourceProtocol { XClientMessageEvent msg = new XClientMessageEvent(); try { - msg.set_type((int)XConstants.ClientMessage); + msg.set_type(XConstants.ClientMessage); msg.set_window(getTargetWindow()); msg.set_format(32); msg.set_message_type(XDnDConstants.XA_XdndDrop.getAtom()); diff --git a/jdk/src/solaris/classes/sun/awt/X11/XDnDDropTargetProtocol.java b/jdk/src/solaris/classes/sun/awt/X11/XDnDDropTargetProtocol.java index f0a6622c4bd..074f37dd753 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XDnDDropTargetProtocol.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XDnDDropTargetProtocol.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, 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 @@ -742,7 +742,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol { long data3, long data4) { XClientMessageEvent enter = new XClientMessageEvent(); try { - enter.set_type((int)XConstants.ClientMessage); + enter.set_type(XConstants.ClientMessage); enter.set_window(toplevel); enter.set_format(32); enter.set_message_type(XDnDConstants.XA_XdndEnter.getAtom()); @@ -768,7 +768,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol { long sourceWindow) { XClientMessageEvent leave = new XClientMessageEvent(); try { - leave.set_type((int)XConstants.ClientMessage); + leave.set_type(XConstants.ClientMessage); leave.set_window(toplevel); leave.set_format(32); leave.set_message_type(XDnDConstants.XA_XdndLeave.getAtom()); @@ -798,7 +798,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol { XClientMessageEvent msg = new XClientMessageEvent(); try { - msg.set_type((int)XConstants.ClientMessage); + msg.set_type(XConstants.ClientMessage); msg.set_window(xclient.get_data(0)); msg.set_format(32); msg.set_message_type(XDnDConstants.XA_XdndStatus.getAtom()); @@ -886,7 +886,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol { XClientMessageEvent msg = new XClientMessageEvent(); try { - msg.set_type((int)XConstants.ClientMessage); + msg.set_type(XConstants.ClientMessage); msg.set_window(xclient.get_data(0)); msg.set_format(32); msg.set_message_type(XDnDConstants.XA_XdndFinished.getAtom()); @@ -1005,6 +1005,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol { } } + @SuppressWarnings("static") private void notifyProtocolListener(XWindow xwindow, int x, int y, int dropAction, XClientMessageEvent xclient, @@ -1147,7 +1148,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol { event while it still can be referenced from other Java events. */ { XClientMessageEvent copy = new XClientMessageEvent(); - unsafe.copyMemory(xclient.pData, copy.pData, copy.getSize()); + unsafe.copyMemory(xclient.pData, copy.pData, XClientMessageEvent.getSize()); copy.set_data(0, xclient.get_window()); diff --git a/jdk/src/solaris/classes/sun/awt/X11/XDragSourceContextPeer.java b/jdk/src/solaris/classes/sun/awt/X11/XDragSourceContextPeer.java index e762ae0118e..f376b395823 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XDragSourceContextPeer.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XDragSourceContextPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2008, 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 @@ -538,7 +538,7 @@ public final class XDragSourceContextPeer return false; } - if (ev.get_type() != (int)XConstants.ClientMessage) { + if (ev.get_type() != XConstants.ClientMessage) { return false; } @@ -612,7 +612,7 @@ public final class XDragSourceContextPeer xkey.get_keycode(), 0); switch ((int)keysym) { case (int)XKeySymConstants.XK_Escape: { - if (ev.get_type() == (int)XConstants.KeyRelease) { + if (ev.get_type() == XConstants.KeyRelease) { cleanup(xkey.get_time()); } break; diff --git a/jdk/src/solaris/classes/sun/awt/X11/XDropTargetEventProcessor.java b/jdk/src/solaris/classes/sun/awt/X11/XDropTargetEventProcessor.java index 65d0b11c6c4..26a4941788d 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XDropTargetEventProcessor.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XDropTargetEventProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2008, 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 @@ -43,7 +43,7 @@ final class XDropTargetEventProcessor { private XDropTargetEventProcessor() {} private boolean doProcessEvent(XEvent ev) { - if (ev.get_type() == (int)XConstants.DestroyNotify && + if (ev.get_type() == XConstants.DestroyNotify && protocol != null && ev.get_xany().get_window() == protocol.getSourceWindow()) { protocol.cleanup(); @@ -51,7 +51,7 @@ final class XDropTargetEventProcessor { return false; } - if (ev.get_type() == (int)XConstants.PropertyNotify) { + if (ev.get_type() == XConstants.PropertyNotify) { XPropertyEvent xproperty = ev.get_xproperty(); if (xproperty.get_atom() == MotifDnDConstants.XA_MOTIF_DRAG_RECEIVER_INFO.getAtom()) { @@ -60,7 +60,7 @@ final class XDropTargetEventProcessor { } } - if (ev.get_type() != (int)XConstants.ClientMessage) { + if (ev.get_type() != XConstants.ClientMessage) { return false; } diff --git a/jdk/src/solaris/classes/sun/awt/X11/XDropTargetRegistry.java b/jdk/src/solaris/classes/sun/awt/X11/XDropTargetRegistry.java index e983eccc807..b8a8441379e 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XDropTargetRegistry.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XDropTargetRegistry.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, 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 @@ -328,8 +328,7 @@ final class XDropTargetRegistry { Long lToplevel = Long.valueOf(embedder); boolean isXEmbedServer = false; synchronized (this) { - EmbeddedDropSiteEntry entry = - (EmbeddedDropSiteEntry)embeddedDropSiteRegistry.get(lToplevel); + EmbeddedDropSiteEntry entry = embeddedDropSiteRegistry.get(lToplevel); if (entry == null) { return; } @@ -430,8 +429,7 @@ final class XDropTargetRegistry { Long lToplevel = Long.valueOf(toplevel); EmbeddedDropSiteEntry entry = null; synchronized (this) { - entry = - (EmbeddedDropSiteEntry)embeddedDropSiteRegistry.get(lToplevel); + entry = embeddedDropSiteRegistry.get(lToplevel); if (entry == null) { if (peer != null) { // Toplevel is an XEmbed server within this VM. @@ -495,8 +493,7 @@ final class XDropTargetRegistry { Long lToplevel = Long.valueOf(toplevel); EmbeddedDropSiteEntry entry = null; synchronized (this) { - entry = - (EmbeddedDropSiteEntry)embeddedDropSiteRegistry.get(lToplevel); + entry = embeddedDropSiteRegistry.get(lToplevel); if (entry == null) { return; } @@ -526,8 +523,7 @@ final class XDropTargetRegistry { */ public long getEmbeddedDropSite(long embedder, int x, int y) { Long lToplevel = Long.valueOf(embedder); - EmbeddedDropSiteEntry entry = - (EmbeddedDropSiteEntry)embeddedDropSiteRegistry.get(lToplevel); + EmbeddedDropSiteEntry entry = embeddedDropSiteRegistry.get(lToplevel); if (entry == null) { return 0; } diff --git a/jdk/src/solaris/classes/sun/awt/X11/XEmbedCanvasPeer.java b/jdk/src/solaris/classes/sun/awt/X11/XEmbedCanvasPeer.java index 167c3fe3209..cdce154834e 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XEmbedCanvasPeer.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XEmbedCanvasPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, 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 @@ -654,9 +654,9 @@ public class XEmbedCanvasPeer extends XCanvasPeer implements WindowFocusListener if (xembedLog.isLoggable(PlatformLogger.Level.FINER)) { xembedLog.finer("Client message to embedder: " + msg); } - if (msg.get_message_type() == xembed.XEmbed.getAtom()) { + if (msg.get_message_type() == XEmbedHelper.XEmbed.getAtom()) { if (xembedLog.isLoggable(PlatformLogger.Level.FINE)) { - xembedLog.fine(xembed.XEmbedMessageToString(msg)); + xembedLog.fine(XEmbedHelper.XEmbedMessageToString(msg)); } } if (isXEmbedActive()) { diff --git a/jdk/src/solaris/classes/sun/awt/X11/XEmbedHelper.java b/jdk/src/solaris/classes/sun/awt/X11/XEmbedHelper.java index 49c7a5dcf04..947a3cb543c 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XEmbedHelper.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XEmbedHelper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2008, 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 @@ -99,7 +99,7 @@ public class XEmbedHelper { } void sendMessage(long window, int message, long detail, long data1, long data2) { XClientMessageEvent msg = new XClientMessageEvent(); - msg.set_type((int)XConstants.ClientMessage); + msg.set_type(XConstants.ClientMessage); msg.set_window(window); msg.set_message_type(XEmbed.getAtom()); msg.set_format(32); diff --git a/jdk/src/solaris/classes/sun/awt/X11/XEmbedServerTester.java b/jdk/src/solaris/classes/sun/awt/X11/XEmbedServerTester.java index e21d1d255f4..9b37a429125 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XEmbedServerTester.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XEmbedServerTester.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2008, 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 @@ -647,7 +647,7 @@ public class XEmbedServerTester implements XEventDispatcher { public void dispatchEvent(XEvent ev) { if (ev.get_type() == ClientMessage) { XClientMessageEvent msg = ev.get_xclient(); - if (msg.get_message_type() == xembed.XEmbed.getAtom()) { + if (msg.get_message_type() == XEmbedHelper.XEmbed.getAtom()) { if (xembedLog.isLoggable(PlatformLogger.Level.FINE)) { xembedLog.fine("Embedded message: " + XEmbedHelper.msgidToString((int)msg.get_data(1))); } @@ -689,7 +689,7 @@ public class XEmbedServerTester implements XEventDispatcher { } } else { synchronized(EVENT_LOCK) { - int eventID = (int)ev.get_type() | SYSTEM_EVENT_MASK; + int eventID = ev.get_type() | SYSTEM_EVENT_MASK; events.add(eventID); if (xembedLog.isLoggable(PlatformLogger.Level.FINER)) { diff --git a/jdk/src/solaris/classes/sun/awt/X11/XFileDialogPeer.java b/jdk/src/solaris/classes/sun/awt/X11/XFileDialogPeer.java index b1c2b0ed845..5da53e88634 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XFileDialogPeer.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XFileDialogPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2010, 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 @@ -775,7 +775,7 @@ class XFileDialogPeer extends XDialogPeer implements FileDialogPeer, ActionListe // 03/02/2005 b5097243 Pressing 'ESC' on a file dlg does not dispose the dlg on Xtoolkit public void setVisible(boolean b){ if (fileDialog == null) { - init((FileDialog)target); + init(target); } if (savedDir != null || userDir != null) { diff --git a/jdk/src/solaris/classes/sun/awt/X11/XFramePeer.java b/jdk/src/solaris/classes/sun/awt/X11/XFramePeer.java index 050e0f20171..ac93ae6501e 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XFramePeer.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XFramePeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2010, 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 @@ -67,9 +67,9 @@ class XFramePeer extends XDecoratedPeer implements FramePeer { undecorated = Boolean.valueOf(target.isUndecorated()); winAttr.nativeDecor = !target.isUndecorated(); if (winAttr.nativeDecor) { - winAttr.decorations = winAttr.AWT_DECOR_ALL; + winAttr.decorations = XWindowAttributesData.AWT_DECOR_ALL; } else { - winAttr.decorations = winAttr.AWT_DECOR_NONE; + winAttr.decorations = XWindowAttributesData.AWT_DECOR_NONE; } winAttr.functions = MWMConstants.MWM_FUNC_ALL; winAttr.isResizable = true; // target.isResizable(); diff --git a/jdk/src/solaris/classes/sun/awt/X11/XGlobalCursorManager.java b/jdk/src/solaris/classes/sun/awt/X11/XGlobalCursorManager.java index c309d310e0a..bcef8c85315 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XGlobalCursorManager.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XGlobalCursorManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, 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 @@ -133,8 +133,8 @@ public final class XGlobalCursorManager extends GlobalCursorManager { XlibWrapper.larg6, XlibWrapper.larg7); - p.x = (int) XlibWrapper.unsafe.getInt(XlibWrapper.larg3); - p.y = (int) XlibWrapper.unsafe.getInt(XlibWrapper.larg4); + p.x = XlibWrapper.unsafe.getInt(XlibWrapper.larg3); + p.y = XlibWrapper.unsafe.getInt(XlibWrapper.larg4); } finally { XToolkit.awtUnlock(); } diff --git a/jdk/src/solaris/classes/sun/awt/X11/XIconWindow.java b/jdk/src/solaris/classes/sun/awt/X11/XIconWindow.java index 7c6684bfddc..07899ef8de4 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XIconWindow.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XIconWindow.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, 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 @@ -301,8 +301,8 @@ public class XIconWindow extends XBaseWindow { } long dst = XlibWrapper.XCreateImage(XToolkit.getDisplay(), visInfo.get_visual(), - (int)awtImage.get_Depth(), - (int)XConstants.ZPixmap, + awtImage.get_Depth(), + XConstants.ZPixmap, 0, bytes, iconWidth, @@ -483,7 +483,7 @@ public class XIconWindow extends XBaseWindow { params.add(BACKGROUND_PIXMAP, iconPixmap); params.add(COLORMAP, adata.get_awt_cmap()); params.add(DEPTH, awtImage.get_Depth()); - params.add(VISUAL_CLASS, (int)XConstants.InputOutput); + params.add(VISUAL_CLASS, XConstants.InputOutput); params.add(VISUAL, visInfo.get_visual()); params.add(VALUE_MASK, XConstants.CWBorderPixel | XConstants.CWColormap | XConstants.CWBackPixmap); params.add(PARENT_WINDOW, XlibWrapper.RootWindow(XToolkit.getDisplay(), visInfo.get_screen())); diff --git a/jdk/src/solaris/classes/sun/awt/X11/XInputMethod.java b/jdk/src/solaris/classes/sun/awt/X11/XInputMethod.java index 6392f2cbf8a..67e729b440c 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XInputMethod.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XInputMethod.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 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 @@ -138,7 +138,7 @@ public class XInputMethod extends X11InputMethod { } long getCurrentParentWindow() { - return (long)((XWindow)clientComponentWindow.getPeer()).getContentWindow(); + return ((XWindow)clientComponentWindow.getPeer()).getContentWindow(); } /* diff --git a/jdk/src/solaris/classes/sun/awt/X11/XMenuBarPeer.java b/jdk/src/solaris/classes/sun/awt/X11/XMenuBarPeer.java index 7cf0cd73123..c1b568bc0fb 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XMenuBarPeer.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XMenuBarPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2007, 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 @@ -525,7 +525,7 @@ public class XMenuBarPeer extends XBaseMenuWindow implements MenuBarPeer { if (isEventDisabled(xev)) { return; } - final Component currentSource = (Component)getEventSource(); + final Component currentSource = getEventSource(); //This is the only difference from XWindow.handleKeyPress //Ancestor's function can invoke handleF10KeyPress here handleKeyPress(xkey); diff --git a/jdk/src/solaris/classes/sun/awt/X11/XMenuWindow.java b/jdk/src/solaris/classes/sun/awt/X11/XMenuWindow.java index a524f0d6e38..9863c983873 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XMenuWindow.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XMenuWindow.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2006, 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 @@ -250,7 +250,7 @@ public class XMenuWindow extends XBaseMenuWindow { } //Item rectangles for (int i = 0; i < itemCnt; i++) { - XMenuItemPeer item = (XMenuItemPeer)itemVector[i]; + XMenuItemPeer item = itemVector[i]; XMenuItemPeer.TextMetrics metrics = itemMetrics[i]; Dimension dim = metrics.getTextDimension(); if (dim != null) { diff --git a/jdk/src/solaris/classes/sun/awt/X11/XNETProtocol.java b/jdk/src/solaris/classes/sun/awt/X11/XNETProtocol.java index dfd372edabf..722261113d1 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XNETProtocol.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XNETProtocol.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, 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 @@ -108,7 +108,7 @@ final class XNETProtocol extends XProtocol implements XStateProtocol, XLayerProt if (log.isLoggable(PlatformLogger.Level.FINE)) { log.fine("Requesting state on " + window + " for " + state); } - req.set_type((int)XConstants.ClientMessage); + req.set_type(XConstants.ClientMessage); req.set_window(window.getWindow()); req.set_message_type(XA_NET_WM_STATE.getAtom()); req.set_format(32); @@ -181,7 +181,7 @@ final class XNETProtocol extends XProtocol implements XStateProtocol, XLayerProt public void requestState(XWindow window, XAtom state, boolean isAdd) { XClientMessageEvent req = new XClientMessageEvent(); try { - req.set_type((int)XConstants.ClientMessage); + req.set_type(XConstants.ClientMessage); req.set_window(window.getWindow()); req.set_message_type(XA_NET_WM_STATE.getAtom()); req.set_format(32); diff --git a/jdk/src/solaris/classes/sun/awt/X11/XPopupMenuPeer.java b/jdk/src/solaris/classes/sun/awt/X11/XPopupMenuPeer.java index cbb71925b50..81c60dd55b2 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XPopupMenuPeer.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XPopupMenuPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2008, 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 @@ -349,7 +349,7 @@ public class XPopupMenuPeer extends XMenuWindow implements PopupMenuPeer { if (isEventDisabled(xev)) { return; } - final Component currentSource = (Component)getEventSource(); + final Component currentSource = getEventSource(); handleKeyPress(xkey); } diff --git a/jdk/src/solaris/classes/sun/awt/X11/XTextAreaPeer.java b/jdk/src/solaris/classes/sun/awt/X11/XTextAreaPeer.java index 7c7b2d1936a..f4bf1ec2062 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XTextAreaPeer.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XTextAreaPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, 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 @@ -342,7 +342,7 @@ final class XTextAreaPeer extends XComponentPeer implements TextAreaPeer { @Override void handleJavaInputMethodEvent(InputMethodEvent e) { if (jtext != null) - jtext.processInputMethodEventPublic((InputMethodEvent)e); + jtext.processInputMethodEventPublic(e); } /** diff --git a/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java b/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java index 1ae0a0967b6..7dcb6e19b7b 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java @@ -55,7 +55,6 @@ import sun.print.PrintJob2D; import sun.security.action.GetPropertyAction; import sun.security.action.GetBooleanAction; import sun.util.logging.PlatformLogger; -import sun.security.util.SecurityConstants; public final class XToolkit extends UNIXToolkit implements Runnable { private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.X11.XToolkit"); @@ -654,8 +653,8 @@ public final class XToolkit extends UNIXToolkit implements Runnable { XWindowAttributes pattr = new XWindowAttributes(); try { XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(), XToolkit.getDefaultRootWindow(), pattr.pData); - screenWidth = (int) pattr.get_width(); - screenHeight = (int) pattr.get_height(); + screenWidth = pattr.get_width(); + screenHeight = pattr.get_height(); } finally { pattr.dispose(); } @@ -1161,7 +1160,7 @@ public final class XToolkit extends UNIXToolkit implements Runnable { public Clipboard getSystemClipboard() { SecurityManager security = System.getSecurityManager(); if (security != null) { - security.checkPermission(SecurityConstants.AWT.ACCESS_CLIPBOARD_PERMISSION); + security.checkPermission(AWTPermissions.ACCESS_CLIPBOARD_PERMISSION); } synchronized (this) { if (clipboard == null) { @@ -1174,7 +1173,7 @@ public final class XToolkit extends UNIXToolkit implements Runnable { public Clipboard getSystemSelection() { SecurityManager security = System.getSecurityManager(); if (security != null) { - security.checkPermission(SecurityConstants.AWT.ACCESS_CLIPBOARD_PERMISSION); + security.checkPermission(AWTPermissions.ACCESS_CLIPBOARD_PERMISSION); } synchronized (this) { if (selection == null) { @@ -1546,7 +1545,7 @@ public final class XToolkit extends UNIXToolkit implements Runnable { */ if (desktopProperties.get(SunToolkit.DESKTOPFONTHINTS) == null) { if (XWM.isKDE2()) { - Object hint = fcManager.getFontConfigAAHint(); + Object hint = FontConfigManager.getFontConfigAAHint(); if (hint != null) { /* set the fontconfig/KDE property so that * getDesktopHints() below will see it @@ -2078,7 +2077,7 @@ public final class XToolkit extends UNIXToolkit implements Runnable { } private static void setBackingStoreType() { - String prop = (String)AccessController.doPrivileged( + String prop = AccessController.doPrivileged( new sun.security.action.GetPropertyAction("sun.awt.backingStore")); if (prop == null) { diff --git a/jdk/src/solaris/classes/sun/awt/X11/XWindow.java b/jdk/src/solaris/classes/sun/awt/X11/XWindow.java index 6aa9d514a7f..d59ac88d3a0 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XWindow.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XWindow.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2010, 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 @@ -200,7 +200,7 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer { getColorModel(); // fix 4948833: this call forces the color map to be initialized params.putIfNull(COLORMAP, gData.get_awt_cmap()); params.putIfNull(DEPTH, gData.get_awt_depth()); - params.putIfNull(VISUAL_CLASS, Integer.valueOf((int)XConstants.InputOutput)); + params.putIfNull(VISUAL_CLASS, Integer.valueOf(XConstants.InputOutput)); params.putIfNull(VISUAL, visInfo.get_visual()); params.putIfNull(VALUE_MASK, XConstants.CWBorderPixel | XConstants.CWEventMask | XConstants.CWColormap); Long parentWindow = (Long)params.get(PARENT_WINDOW); @@ -350,7 +350,7 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer { Graphics getGraphics(SurfaceData surfData, Color afore, Color aback, Font afont) { if (surfData == null) return null; - Component target = (Component) this.target; + Component target = this.target; /* Fix for bug 4746122. Color and Font shouldn't be null */ Color bgColor = aback; @@ -549,7 +549,7 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer { int w = xe.get_width(); int h = xe.get_height(); - Component target = (Component)getEventSource(); + Component target = getEventSource(); AWTAccessor.ComponentAccessor compAccessor = AWTAccessor.getComponentAccessor(); if (!compAccessor.getIgnoreRepaint(target) @@ -741,7 +741,7 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer { modifiers = getModifiers(xbe.get_state(),button,0, type, wheel_mouse); if (!wheel_mouse) { - MouseEvent me = new MouseEvent((Component)getEventSource(), + MouseEvent me = new MouseEvent(getEventSource(), type == XConstants.ButtonPress ? MouseEvent.MOUSE_PRESSED : MouseEvent.MOUSE_RELEASED, jWhen,modifiers, x, y, xbe.get_x_root(), @@ -753,7 +753,7 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer { if ((type == XConstants.ButtonRelease) && ((mouseButtonClickAllowed & XlibUtil.getButtonMask(lbutton)) != 0) ) // No up-button in the drag-state { - postEventToEventQueue(me = new MouseEvent((Component)getEventSource(), + postEventToEventQueue(me = new MouseEvent(getEventSource(), MouseEvent.MOUSE_CLICKED, jWhen, modifiers, @@ -767,7 +767,7 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer { } else { if (xev.get_type() == XConstants.ButtonPress) { - MouseWheelEvent mwe = new MouseWheelEvent((Component)getEventSource(),MouseEvent.MOUSE_WHEEL, jWhen, + MouseWheelEvent mwe = new MouseWheelEvent(getEventSource(),MouseEvent.MOUSE_WHEEL, jWhen, modifiers, x, y, xbe.get_x_root(), @@ -838,7 +838,7 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer { int modifiers = getModifiers(xme.get_state(), 0, 0); boolean popupTrigger = false; - Component source = (Component)getEventSource(); + Component source = getEventSource(); if (xme.get_window() != window) { Point localXY = toLocal(xme.get_x_root(), xme.get_y_root()); @@ -1112,7 +1112,7 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer { unicodeKey = keysymToUnicode( keysym[0], ev.get_state() ); if (keyEventLog.isLoggable(PlatformLogger.Level.FINE)) { keyEventLog.fine("--XWindow.java XIM did NOT process event, hex keysym:"+Long.toHexString(keysym[0])+"\n"+ - " unicode key:"+Integer.toHexString((int)unicodeKey)); + " unicode key:"+Integer.toHexString(unicodeKey)); } } }else { @@ -1122,7 +1122,7 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer { unicodeKey = keysymToUnicode( keysym[0], ev.get_state() ); if (keyEventLog.isLoggable(PlatformLogger.Level.FINE)) { keyEventLog.fine("--XWindow.java XIM is absent; hex keysym:"+Long.toHexString(keysym[0])+"\n"+ - " unicode key:"+Integer.toHexString((int)unicodeKey)); + " unicode key:"+Integer.toHexString(unicodeKey)); } } // Keysym should be converted to Unicode, if possible and necessary, @@ -1467,7 +1467,7 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer { long jWhen = XToolkit.nowMillisUTC_offset(when); int modifiers = getModifiers(state, 0, keyCode); - KeyEvent ke = new KeyEvent((Component)getEventSource(), id, jWhen, + KeyEvent ke = new KeyEvent(getEventSource(), id, jWhen, modifiers, keyCode, (char)keyChar, keyLocation); if (event != 0) { byte[] data = Native.toBytes(event, eventSize); diff --git a/jdk/src/solaris/classes/sun/awt/X11/XWindowPeer.java b/jdk/src/solaris/classes/sun/awt/X11/XWindowPeer.java index 8dcd15bc975..521bbc145b3 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XWindowPeer.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XWindowPeer.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 @@ -291,7 +291,7 @@ class XWindowPeer extends XPanelPeer implements WindowPeer, public void updateIconImages() { Window target = (Window)this.target; - java.util.List iconImages = ((Window)target).getIconImages(); + java.util.List iconImages = target.getIconImages(); XWindowPeer ownerPeer = getOwnerPeer(); winAttr.icons = new ArrayList(); if (iconImages.size() != 0) { @@ -463,8 +463,8 @@ class XWindowPeer extends XPanelPeer implements WindowPeer, public void updateMinimumSize() { //This function only saves minimumSize value in XWindowPeer //Setting WMSizeHints is implemented in XDecoratedPeer - targetMinimumSize = (((Component)target).isMinimumSizeSet()) ? - ((Component)target).getMinimumSize() : null; + targetMinimumSize = (target.isMinimumSizeSet()) ? + target.getMinimumSize() : null; } public Dimension getTargetMinimumSize() { @@ -719,10 +719,10 @@ class XWindowPeer extends XPanelPeer implements WindowPeer, Runnable dc = new Runnable() { public void run() { AWTAccessor.getComponentAccessor(). - setGraphicsConfiguration((Component)target, gc); + setGraphicsConfiguration(target, gc); } }; - SunToolkit.executeOnEventHandlerThread((Component)target, dc); + SunToolkit.executeOnEventHandlerThread(target, dc); } /** @@ -750,7 +750,7 @@ class XWindowPeer extends XPanelPeer implements WindowPeer, protected Point getNewLocation(XConfigureEvent xe, int leftInset, int topInset) { // Bounds of the window - Rectangle targetBounds = AWTAccessor.getComponentAccessor().getBounds((Component)target); + Rectangle targetBounds = AWTAccessor.getComponentAccessor().getBounds(target); int runningWM = XWM.getWMID(); Point newLocation = targetBounds.getLocation(); @@ -1108,7 +1108,7 @@ class XWindowPeer extends XPanelPeer implements WindowPeer, XUnmapEvent unmap = new XUnmapEvent(); unmap.set_window(window); unmap.set_event(XToolkit.getDefaultRootWindow()); - unmap.set_type((int)XConstants.UnmapNotify); + unmap.set_type(XConstants.UnmapNotify); unmap.set_from_configure(false); XlibWrapper.XSendEvent(XToolkit.getDisplay(), XToolkit.getDefaultRootWindow(), false, XConstants.SubstructureNotifyMask | XConstants.SubstructureRedirectMask, diff --git a/jdk/src/solaris/classes/sun/awt/X11FontManager.java b/jdk/src/solaris/classes/sun/awt/X11FontManager.java index 573d250acba..c9d2ebc9ba4 100644 --- a/jdk/src/solaris/classes/sun/awt/X11FontManager.java +++ b/jdk/src/solaris/classes/sun/awt/X11FontManager.java @@ -715,7 +715,7 @@ public class X11FontManager extends SunFontManager { if (FontUtilities.isLinux) { fontConfigDirs.add(jreLibDirName+File.separator+"oblique-fonts"); } - fontdirs = (String[])fontConfigDirs.toArray(new String[0]); + fontdirs = fontConfigDirs.toArray(new String[0]); } // Implements SunGraphicsEnvironment.createFontConfiguration. diff --git a/jdk/src/solaris/classes/sun/awt/X11GraphicsEnvironment.java b/jdk/src/solaris/classes/sun/awt/X11GraphicsEnvironment.java index 60846b69c18..547af9c3bed 100644 --- a/jdk/src/solaris/classes/sun/awt/X11GraphicsEnvironment.java +++ b/jdk/src/solaris/classes/sun/awt/X11GraphicsEnvironment.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, 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 @@ -232,7 +232,7 @@ public class X11GraphicsEnvironment return true; } - String isRemote = (String)java.security.AccessController.doPrivileged( + String isRemote = java.security.AccessController.doPrivileged( new sun.security.action.GetPropertyAction("sun.java2d.remote")); if (isRemote != null) { return isRemote.equals("false"); diff --git a/jdk/src/solaris/classes/sun/font/FcFontConfiguration.java b/jdk/src/solaris/classes/sun/font/FcFontConfiguration.java index e33e08a867b..23cf93624a6 100644 --- a/jdk/src/solaris/classes/sun/font/FcFontConfiguration.java +++ b/jdk/src/solaris/classes/sun/font/FcFontConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2012, 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 @@ -441,7 +441,7 @@ public class FcFontConfiguration extends FontConfiguration { try { fcVersion = Integer.parseInt(fcVersionStr); if (fcVersion != 0 && - fcVersion != fcm.getFontConfigVersion()) { + fcVersion != FontConfigManager.getFontConfigVersion()) { return; } } catch (Exception e) { diff --git a/jdk/src/solaris/classes/sun/font/NativeFont.java b/jdk/src/solaris/classes/sun/font/NativeFont.java index 9fa469fce3c..bc39f743a91 100644 --- a/jdk/src/solaris/classes/sun/font/NativeFont.java +++ b/jdk/src/solaris/classes/sun/font/NativeFont.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2006, 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 @@ -331,6 +331,7 @@ public class NativeFont extends PhysicalFont { * ie to request 12 pt Times New Roman italic font, use an XLFD like : * -monotype-times new roman-regular-i---*-120-72-72-p-*-iso8859-1 */ + @SuppressWarnings("cast") byte[] getPlatformNameBytes(int ptSize) { int[] hPos = new int[14]; int hyphenCnt = 1; diff --git a/jdk/src/solaris/classes/sun/font/X11TextRenderer.java b/jdk/src/solaris/classes/sun/font/X11TextRenderer.java index a408168a5cc..3afb0ccd5a4 100644 --- a/jdk/src/solaris/classes/sun/font/X11TextRenderer.java +++ b/jdk/src/solaris/classes/sun/font/X11TextRenderer.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 @@ -57,11 +57,11 @@ public class X11TextRenderer extends GlyphListPipe { super.drawGlyphVector(sg2d, g, x, y); return; case SunHints.INTVAL_TEXT_ANTIALIAS_ON: - sg2d.surfaceData.aaTextRenderer.drawGlyphVector(sg2d, g, x, y); + SurfaceData.aaTextRenderer.drawGlyphVector(sg2d, g, x, y); return; case SunHints.INTVAL_TEXT_ANTIALIAS_LCD_HRGB: case SunHints.INTVAL_TEXT_ANTIALIAS_LCD_VRGB: - sg2d.surfaceData.lcdTextRenderer.drawGlyphVector(sg2d, g, x, y); + SurfaceData.lcdTextRenderer.drawGlyphVector(sg2d, g, x, y); return; default: } diff --git a/jdk/src/solaris/classes/sun/font/XRGlyphCacheEntry.java b/jdk/src/solaris/classes/sun/font/XRGlyphCacheEntry.java index 18ece2b813b..b1dd7c150fc 100644 --- a/jdk/src/solaris/classes/sun/font/XRGlyphCacheEntry.java +++ b/jdk/src/solaris/classes/sun/font/XRGlyphCacheEntry.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 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 @@ -48,8 +48,8 @@ public class XRGlyphCacheEntry { this.glyphInfoPtr = glyphInfoPtr; /* TODO: Does it make sence to cache results? */ - xOff = (int) Math.round(getXAdvance()); - yOff = (int) Math.round(getYAdvance()); + xOff = Math.round(getXAdvance()); + yOff = Math.round(getYAdvance()); } public int getXOff() { diff --git a/jdk/src/solaris/classes/sun/java2d/x11/X11SurfaceData.java b/jdk/src/solaris/classes/sun/java2d/x11/X11SurfaceData.java index d9d883a0e52..af65891495f 100644 --- a/jdk/src/solaris/classes/sun/java2d/x11/X11SurfaceData.java +++ b/jdk/src/solaris/classes/sun/java2d/x11/X11SurfaceData.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 @@ -214,13 +214,13 @@ public abstract class X11SurfaceData extends XSurfaceData { if (!isX11SurfaceDataInitialized() && !GraphicsEnvironment.isHeadless()) { // If a screen magnifier is present, don't attempt to use DGA - String magPresent = (String) java.security.AccessController.doPrivileged + String magPresent = java.security.AccessController.doPrivileged (new sun.security.action.GetPropertyAction("javax.accessibility.screen_magnifier_present")); boolean tryDGA = magPresent == null || !"true".equals(magPresent); initIDs(XORComposite.class, tryDGA); - String xtextpipe = (String) java.security.AccessController.doPrivileged + String xtextpipe = java.security.AccessController.doPrivileged (new sun.security.action.GetPropertyAction("sun.java2d.xtextpipe")); if (xtextpipe == null || "true".startsWith(xtextpipe)) { if ("true".equals(xtextpipe)) { @@ -264,8 +264,7 @@ public abstract class X11SurfaceData extends XSurfaceData { if (GraphicsEnvironment.isHeadless()) { accelerationEnabled = Boolean.FALSE; } else { - String prop = - (String) java.security.AccessController.doPrivileged( + String prop = java.security.AccessController.doPrivileged( new sun.security.action.GetPropertyAction("sun.java2d.pmoffscreen")); if (prop != null) { // true iff prop==true, false otherwise diff --git a/jdk/src/solaris/classes/sun/java2d/xr/XRDrawLine.java b/jdk/src/solaris/classes/sun/java2d/xr/XRDrawLine.java index 66b595e9455..a3c46ae26da 100644 --- a/jdk/src/solaris/classes/sun/java2d/xr/XRDrawLine.java +++ b/jdk/src/solaris/classes/sun/java2d/xr/XRDrawLine.java @@ -1,7 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. - - + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -249,7 +247,7 @@ public class XRDrawLine { if (dx < 0) { xsteps = -xsteps; } - x1 = ucX1 + (int) xsteps; + x1 = ucX1 + xsteps; } else if ((outcode1 & (OUTCODE_LEFT | OUTCODE_RIGHT)) != 0) { if ((outcode1 & OUTCODE_LEFT) != 0) { x1 = cxmin; @@ -268,7 +266,7 @@ public class XRDrawLine { if (dy < 0) { ysteps = -ysteps; } - y1 = ucY1 + (int) ysteps; + y1 = ucY1 + ysteps; } outcode1 = outcode(x1, y1, cxmin, cymin, cxmax, cymax); } else { @@ -292,7 +290,7 @@ public class XRDrawLine { if (dx > 0) { xsteps = -xsteps; } - x2 = ucX2 + (int) xsteps; + x2 = ucX2 + xsteps; } else if ((outcode2 & (OUTCODE_LEFT | OUTCODE_RIGHT)) != 0) { if ((outcode2 & OUTCODE_LEFT) != 0) { x2 = cxmin; @@ -313,7 +311,7 @@ public class XRDrawLine { if (dy > 0) { ysteps = -ysteps; } - y2 = ucY2 + (int) ysteps; + y2 = ucY2 + ysteps; } outcode2 = outcode(x2, y2, cxmin, cymin, cxmax, cymax); } diff --git a/jdk/src/solaris/classes/sun/java2d/xr/XRPMBlitLoops.java b/jdk/src/solaris/classes/sun/java2d/xr/XRPMBlitLoops.java index 981629d1e06..58ebf7193b7 100644 --- a/jdk/src/solaris/classes/sun/java2d/xr/XRPMBlitLoops.java +++ b/jdk/src/solaris/classes/sun/java2d/xr/XRPMBlitLoops.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 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 @@ -178,6 +178,7 @@ class XRPMScaledBlit extends ScaledBlit { super(srcType, CompositeType.AnyAlpha, dstType); } + @SuppressWarnings("cast") public void Scale(SurfaceData src, SurfaceData dst, Composite comp, Region clip, int sx1, int sy1, int sx2, int sy2, double dx1, double dy1, double dx2, double dy2) { try { diff --git a/jdk/src/solaris/classes/sun/java2d/xr/XRPaints.java b/jdk/src/solaris/classes/sun/java2d/xr/XRPaints.java index 05136dabaf2..07cba15ec3f 100644 --- a/jdk/src/solaris/classes/sun/java2d/xr/XRPaints.java +++ b/jdk/src/solaris/classes/sun/java2d/xr/XRPaints.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 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 @@ -231,7 +231,7 @@ abstract class XRPaints { Rectangle2D anchor = paint.getAnchorRect(); XRSurfaceData dstData = (XRSurfaceData) sg2d.surfaceData; - XRSurfaceData srcData = (XRSurfaceData) getAccSrcSurface(dstData, bi); + XRSurfaceData srcData = getAccSrcSurface(dstData, bi); AffineTransform at = new AffineTransform(); at.translate(anchor.getX(), anchor.getY()); @@ -259,7 +259,7 @@ abstract class XRPaints { public int colorToIntArgbPixel(Color c) { int rgb = c.getRGB(); - int a = (int) Math.round(xrCompMan.getExtraAlpha() * (rgb >>> 24)); + int a = Math.round(xrCompMan.getExtraAlpha() * (rgb >>> 24)); return ((a << 24) | (rgb & 0x00FFFFFF)); } } diff --git a/jdk/src/solaris/classes/sun/management/OperatingSystemImpl.java b/jdk/src/solaris/classes/sun/management/OperatingSystemImpl.java index 666840f247d..5e2f8dca3b7 100644 --- a/jdk/src/solaris/classes/sun/management/OperatingSystemImpl.java +++ b/jdk/src/solaris/classes/sun/management/OperatingSystemImpl.java @@ -39,19 +39,61 @@ class OperatingSystemImpl extends BaseOperatingSystemImpl super(vm); } - public native long getCommittedVirtualMemorySize(); - public native long getTotalSwapSpaceSize(); - public native long getFreeSwapSpaceSize(); - public native long getProcessCpuTime(); - public native long getFreePhysicalMemorySize(); - public native long getTotalPhysicalMemorySize(); - public native long getOpenFileDescriptorCount(); - public native long getMaxFileDescriptorCount(); - public native double getSystemCpuLoad(); - public native double getProcessCpuLoad(); + public long getCommittedVirtualMemorySize() { + return getCommittedVirtualMemorySize0(); + } + + public long getTotalSwapSpaceSize() { + return getTotalSwapSpaceSize0(); + } + + public long getFreeSwapSpaceSize() { + return getFreeSwapSpaceSize0(); + } + + public long getProcessCpuTime() { + return getProcessCpuTime0(); + } + + public long getFreePhysicalMemorySize() { + return getFreePhysicalMemorySize0(); + } + + public long getTotalPhysicalMemorySize() { + return getTotalPhysicalMemorySize0(); + } + + public long getOpenFileDescriptorCount() { + return getOpenFileDescriptorCount0(); + } + + public long getMaxFileDescriptorCount() { + return getMaxFileDescriptorCount0(); + } + + public double getSystemCpuLoad() { + return getSystemCpuLoad0(); + } + + public double getProcessCpuLoad() { + return getProcessCpuLoad0(); + } + + /* native methods */ + private native long getCommittedVirtualMemorySize0(); + private native long getFreePhysicalMemorySize0(); + private native long getFreeSwapSpaceSize0(); + private native long getMaxFileDescriptorCount0(); + private native long getOpenFileDescriptorCount0(); + private native long getProcessCpuTime0(); + private native double getProcessCpuLoad0(); + private native double getSystemCpuLoad0(); + private native long getTotalPhysicalMemorySize0(); + private native long getTotalSwapSpaceSize0(); static { - initialize(); + initialize0(); } - private static native void initialize(); + + private static native void initialize0(); } diff --git a/jdk/src/solaris/classes/sun/net/PortConfig.java b/jdk/src/solaris/classes/sun/net/PortConfig.java new file mode 100644 index 00000000000..0f4ca744257 --- /dev/null +++ b/jdk/src/solaris/classes/sun/net/PortConfig.java @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package sun.net; + +import java.security.AccessController; + +/** + * Determines the ephemeral port range in use on this system. + * If this cannot be determined, then the default settings + * of the OS are returned. + */ + +public final class PortConfig { + + private static int defaultUpper, defaultLower; + private final static int upper, lower; + + private PortConfig() {} + + static { + AccessController.doPrivileged( + new java.security.PrivilegedAction() { + public Void run() { + System.loadLibrary("net"); + String os = System.getProperty("os.name"); + if (os.startsWith("Linux")) { + defaultLower = 32768; + defaultUpper = 61000; + } else if (os.startsWith("SunOS")) { + defaultLower = 32768; + defaultUpper = 65535; + } else if (os.contains("OS X")) { + defaultLower = 49152; + defaultUpper = 65535; + } else { + throw new InternalError( + "sun.net.PortConfig: unknown OS"); + } + return null; + } + }); + + int v = getLower0(); + if (v == -1) { + v = defaultLower; + } + lower = v; + + v = getUpper0(); + if (v == -1) { + v = defaultUpper; + } + upper = v; + } + + static native int getLower0(); + static native int getUpper0(); + + public static int getLower() { + return lower; + } + + public static int getUpper() { + return upper; + } +} diff --git a/jdk/src/solaris/classes/sun/nio/ch/DefaultAsynchronousChannelProvider.java b/jdk/src/solaris/classes/sun/nio/ch/DefaultAsynchronousChannelProvider.java index 667c51ab59f..7a0ce392299 100644 --- a/jdk/src/solaris/classes/sun/nio/ch/DefaultAsynchronousChannelProvider.java +++ b/jdk/src/solaris/classes/sun/nio/ch/DefaultAsynchronousChannelProvider.java @@ -68,6 +68,8 @@ public class DefaultAsynchronousChannelProvider { return createProvider("sun.nio.ch.LinuxAsynchronousChannelProvider"); if (osname.contains("OS X")) return createProvider("sun.nio.ch.BsdAsynchronousChannelProvider"); + if (osname.equals("AIX")) + return createProvider("sun.nio.ch.AixAsynchronousChannelProvider"); throw new InternalError("platform not recognized"); } } diff --git a/jdk/src/solaris/classes/sun/nio/ch/EPollPort.java b/jdk/src/solaris/classes/sun/nio/ch/EPollPort.java index 17cd171bc80..4238984c8d2 100644 --- a/jdk/src/solaris/classes/sun/nio/ch/EPollPort.java +++ b/jdk/src/solaris/classes/sun/nio/ch/EPollPort.java @@ -93,7 +93,7 @@ final class EPollPort try { socketpair(sv); // register one end with epoll - epollCtl(epfd, EPOLL_CTL_ADD, sv[0], POLLIN); + epollCtl(epfd, EPOLL_CTL_ADD, sv[0], Net.POLLIN); } catch (IOException x) { close0(epfd); throw x; diff --git a/jdk/src/solaris/classes/sun/nio/ch/KQueuePort.java b/jdk/src/solaris/classes/sun/nio/ch/KQueuePort.java index c323f076fb2..5a1066444eb 100644 --- a/jdk/src/solaris/classes/sun/nio/ch/KQueuePort.java +++ b/jdk/src/solaris/classes/sun/nio/ch/KQueuePort.java @@ -172,9 +172,9 @@ final class KQueuePort // TBD: Measure cost of EV_ONESHOT vs. EV_CLEAR, either will do here. int err = 0; int flags = (EV_ADD|EV_ONESHOT); - if ((events & Port.POLLIN) > 0) + if ((events & Net.POLLIN) > 0) err = keventRegister(kqfd, fd, EVFILT_READ, flags); - if (err == 0 && (events & Port.POLLOUT) > 0) + if (err == 0 && (events & Net.POLLOUT) > 0) err = keventRegister(kqfd, fd, EVFILT_WRITE, flags); if (err != 0) throw new InternalError("kevent failed: " + err); // should not happen @@ -227,9 +227,9 @@ final class KQueuePort int filter = getFilter(keventAddress); int events = 0; if (filter == EVFILT_READ) - events = Port.POLLIN; + events = Net.POLLIN; else if (filter == EVFILT_WRITE) - events = Port.POLLOUT; + events = Net.POLLOUT; Event ev = new Event(channel, events); diff --git a/jdk/src/solaris/classes/sun/nio/ch/PollArrayWrapper.java b/jdk/src/solaris/classes/sun/nio/ch/PollArrayWrapper.java index 3a57bfc4ba2..50fd67c5a83 100644 --- a/jdk/src/solaris/classes/sun/nio/ch/PollArrayWrapper.java +++ b/jdk/src/solaris/classes/sun/nio/ch/PollArrayWrapper.java @@ -43,8 +43,6 @@ import sun.misc.*; public class PollArrayWrapper extends AbstractPollArrayWrapper { - public static final short POLLCONN = POLLOUT; - // File descriptor to write for interrupt int interruptFD; @@ -58,7 +56,7 @@ public class PollArrayWrapper extends AbstractPollArrayWrapper { void initInterrupt(int fd0, int fd1) { interruptFD = fd1; putDescriptor(0, fd0); - putEventOps(0, POLLIN); + putEventOps(0, Net.POLLIN); putReventOps(0, 0); } diff --git a/jdk/src/solaris/classes/sun/nio/ch/Port.java b/jdk/src/solaris/classes/sun/nio/ch/Port.java index 94025089933..81e1ed87615 100644 --- a/jdk/src/solaris/classes/sun/nio/ch/Port.java +++ b/jdk/src/solaris/classes/sun/nio/ch/Port.java @@ -40,10 +40,6 @@ import java.util.concurrent.locks.ReentrantReadWriteLock; */ abstract class Port extends AsynchronousChannelGroupImpl { - static final short POLLIN = 0x0001; - static final short POLLOUT = 0x0004; - static final short POLLERR = 0x0008; - static final short POLLHUP = 0x0010; /** * Implemented by clients registered with this port. @@ -76,12 +72,22 @@ abstract class Port extends AsynchronousChannelGroupImpl { } } + /** + * Callback method for implementations that need special handling when fd is + * removed (currently only needed in the AIX-Port - see AixPollPort.java). + */ + protected void preUnregister(int fd) { + // Do nothing by default. + } + /** * Unregister channel identified by its file descriptor */ final void unregister(int fd) { boolean checkForShutdown = false; + preUnregister(fd); + fdToChannelLock.writeLock().lock(); try { fdToChannel.remove(Integer.valueOf(fd)); diff --git a/jdk/src/solaris/classes/sun/nio/ch/SinkChannelImpl.java b/jdk/src/solaris/classes/sun/nio/ch/SinkChannelImpl.java index a0645221ed0..bdc6c687070 100644 --- a/jdk/src/solaris/classes/sun/nio/ch/SinkChannelImpl.java +++ b/jdk/src/solaris/classes/sun/nio/ch/SinkChannelImpl.java @@ -118,17 +118,16 @@ class SinkChannelImpl int oldOps = sk.nioReadyOps(); int newOps = initialOps; - if ((ops & PollArrayWrapper.POLLNVAL) != 0) + if ((ops & Net.POLLNVAL) != 0) throw new Error("POLLNVAL detected"); - if ((ops & (PollArrayWrapper.POLLERR - | PollArrayWrapper.POLLHUP)) != 0) { + if ((ops & (Net.POLLERR | Net.POLLHUP)) != 0) { newOps = intOps; sk.nioReadyOps(newOps); return (newOps & ~oldOps) != 0; } - if (((ops & PollArrayWrapper.POLLOUT) != 0) && + if (((ops & Net.POLLOUT) != 0) && ((intOps & SelectionKey.OP_WRITE) != 0)) newOps |= SelectionKey.OP_WRITE; @@ -146,7 +145,7 @@ class SinkChannelImpl public void translateAndSetInterestOps(int ops, SelectionKeyImpl sk) { if (ops == SelectionKey.OP_WRITE) - ops = PollArrayWrapper.POLLOUT; + ops = Net.POLLOUT; sk.selector.putEventOps(sk, ops); } diff --git a/jdk/src/solaris/classes/sun/nio/ch/SourceChannelImpl.java b/jdk/src/solaris/classes/sun/nio/ch/SourceChannelImpl.java index d632b74259f..398b169cc84 100644 --- a/jdk/src/solaris/classes/sun/nio/ch/SourceChannelImpl.java +++ b/jdk/src/solaris/classes/sun/nio/ch/SourceChannelImpl.java @@ -118,17 +118,16 @@ class SourceChannelImpl int oldOps = sk.nioReadyOps(); int newOps = initialOps; - if ((ops & PollArrayWrapper.POLLNVAL) != 0) + if ((ops & Net.POLLNVAL) != 0) throw new Error("POLLNVAL detected"); - if ((ops & (PollArrayWrapper.POLLERR - | PollArrayWrapper.POLLHUP)) != 0) { + if ((ops & (Net.POLLERR | Net.POLLHUP)) != 0) { newOps = intOps; sk.nioReadyOps(newOps); return (newOps & ~oldOps) != 0; } - if (((ops & PollArrayWrapper.POLLIN) != 0) && + if (((ops & Net.POLLIN) != 0) && ((intOps & SelectionKey.OP_READ) != 0)) newOps |= SelectionKey.OP_READ; @@ -146,7 +145,7 @@ class SourceChannelImpl public void translateAndSetInterestOps(int ops, SelectionKeyImpl sk) { if (ops == SelectionKey.OP_READ) - ops = PollArrayWrapper.POLLIN; + ops = Net.POLLIN; sk.selector.putEventOps(sk, ops); } diff --git a/jdk/src/solaris/classes/sun/nio/ch/UnixAsynchronousServerSocketChannelImpl.java b/jdk/src/solaris/classes/sun/nio/ch/UnixAsynchronousServerSocketChannelImpl.java index 752b70ee4f0..294dc014236 100644 --- a/jdk/src/solaris/classes/sun/nio/ch/UnixAsynchronousServerSocketChannelImpl.java +++ b/jdk/src/solaris/classes/sun/nio/ch/UnixAsynchronousServerSocketChannelImpl.java @@ -148,7 +148,7 @@ class UnixAsynchronousServerSocketChannelImpl synchronized (updateLock) { acceptPending = true; } - port.startPoll(fdVal, Port.POLLIN); + port.startPoll(fdVal, Net.POLLIN); return; } @@ -299,7 +299,7 @@ class UnixAsynchronousServerSocketChannelImpl } // register for connections - port.startPoll(fdVal, Port.POLLIN); + port.startPoll(fdVal, Net.POLLIN); return result; } } catch (Throwable x) { diff --git a/jdk/src/solaris/classes/sun/nio/ch/UnixAsynchronousSocketChannelImpl.java b/jdk/src/solaris/classes/sun/nio/ch/UnixAsynchronousSocketChannelImpl.java index c718057f060..d7f11dc6ffd 100644 --- a/jdk/src/solaris/classes/sun/nio/ch/UnixAsynchronousSocketChannelImpl.java +++ b/jdk/src/solaris/classes/sun/nio/ch/UnixAsynchronousSocketChannelImpl.java @@ -142,9 +142,9 @@ class UnixAsynchronousSocketChannelImpl assert Thread.holdsLock(updateLock); int events = 0; if (readPending) - events |= Port.POLLIN; + events |= Net.POLLIN; if (connectPending || writePending) - events |= Port.POLLOUT; + events |= Net.POLLOUT; if (events != 0) port.startPoll(fdVal, events); } @@ -204,9 +204,9 @@ class UnixAsynchronousSocketChannelImpl */ @Override public void onEvent(int events, boolean mayInvokeDirect) { - boolean readable = (events & Port.POLLIN) > 0; - boolean writable = (events & Port.POLLOUT) > 0; - if ((events & (Port.POLLERR | Port.POLLHUP)) > 0) { + boolean readable = (events & Net.POLLIN) > 0; + boolean writable = (events & Net.POLLOUT) > 0; + if ((events & (Net.POLLERR | Net.POLLHUP)) > 0) { readable = true; writable = true; } diff --git a/jdk/src/solaris/classes/sun/nio/ch/sctp/SctpChannelImpl.java b/jdk/src/solaris/classes/sun/nio/ch/sctp/SctpChannelImpl.java index 73c96cfc22b..84a9944aa20 100644 --- a/jdk/src/solaris/classes/sun/nio/ch/sctp/SctpChannelImpl.java +++ b/jdk/src/solaris/classes/sun/nio/ch/sctp/SctpChannelImpl.java @@ -187,6 +187,10 @@ public class SctpChannelImpl extends SctpChannel SctpNet.throwAlreadyBoundException(); InetSocketAddress isa = (local == null) ? new InetSocketAddress(0) : Net.checkAddress(local); + SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + sm.checkListen(isa.getPort()); + } Net.bind(fd, isa.getAddress(), isa.getPort()); InetSocketAddress boundIsa = Net.localAddress(fd); port = boundIsa.getPort(); @@ -589,15 +593,14 @@ public class SctpChannelImpl extends SctpChannel int oldOps = sk.nioReadyOps(); int newOps = initialOps; - if ((ops & PollArrayWrapper.POLLNVAL) != 0) { + if ((ops & Net.POLLNVAL) != 0) { /* This should only happen if this channel is pre-closed while a * selection operation is in progress * ## Throw an error if this channel has not been pre-closed */ return false; } - if ((ops & (PollArrayWrapper.POLLERR - | PollArrayWrapper.POLLHUP)) != 0) { + if ((ops & (Net.POLLERR | Net.POLLHUP)) != 0) { newOps = intOps; sk.nioReadyOps(newOps); /* No need to poll again in checkConnect, @@ -606,19 +609,19 @@ public class SctpChannelImpl extends SctpChannel return (newOps & ~oldOps) != 0; } - if (((ops & PollArrayWrapper.POLLIN) != 0) && + if (((ops & Net.POLLIN) != 0) && ((intOps & SelectionKey.OP_READ) != 0) && isConnected()) newOps |= SelectionKey.OP_READ; - if (((ops & PollArrayWrapper.POLLCONN) != 0) && + if (((ops & Net.POLLCONN) != 0) && ((intOps & SelectionKey.OP_CONNECT) != 0) && ((state == ChannelState.UNCONNECTED) || (state == ChannelState.PENDING))) { newOps |= SelectionKey.OP_CONNECT; readyToConnect = true; } - if (((ops & PollArrayWrapper.POLLOUT) != 0) && + if (((ops & Net.POLLOUT) != 0) && ((intOps & SelectionKey.OP_WRITE) != 0) && isConnected()) newOps |= SelectionKey.OP_WRITE; @@ -642,11 +645,11 @@ public class SctpChannelImpl extends SctpChannel public void translateAndSetInterestOps(int ops, SelectionKeyImpl sk) { int newOps = 0; if ((ops & SelectionKey.OP_READ) != 0) - newOps |= PollArrayWrapper.POLLIN; + newOps |= Net.POLLIN; if ((ops & SelectionKey.OP_WRITE) != 0) - newOps |= PollArrayWrapper.POLLOUT; + newOps |= Net.POLLOUT; if ((ops & SelectionKey.OP_CONNECT) != 0) - newOps |= PollArrayWrapper.POLLCONN; + newOps |= Net.POLLCONN; sk.selector.putEventOps(sk, newOps); } diff --git a/jdk/src/solaris/classes/sun/nio/ch/sctp/SctpMultiChannelImpl.java b/jdk/src/solaris/classes/sun/nio/ch/sctp/SctpMultiChannelImpl.java index 424c1d1642d..0a00bd4162e 100644 --- a/jdk/src/solaris/classes/sun/nio/ch/sctp/SctpMultiChannelImpl.java +++ b/jdk/src/solaris/classes/sun/nio/ch/sctp/SctpMultiChannelImpl.java @@ -321,25 +321,24 @@ public class SctpMultiChannelImpl extends SctpMultiChannel int oldOps = sk.nioReadyOps(); int newOps = initialOps; - if ((ops & PollArrayWrapper.POLLNVAL) != 0) { + if ((ops & Net.POLLNVAL) != 0) { /* This should only happen if this channel is pre-closed while a * selection operation is in progress * ## Throw an error if this channel has not been pre-closed */ return false; } - if ((ops & (PollArrayWrapper.POLLERR - | PollArrayWrapper.POLLHUP)) != 0) { + if ((ops & (Net.POLLERR | Net.POLLHUP)) != 0) { newOps = intOps; sk.nioReadyOps(newOps); return (newOps & ~oldOps) != 0; } - if (((ops & PollArrayWrapper.POLLIN) != 0) && + if (((ops & Net.POLLIN) != 0) && ((intOps & SelectionKey.OP_READ) != 0)) newOps |= SelectionKey.OP_READ; - if (((ops & PollArrayWrapper.POLLOUT) != 0) && + if (((ops & Net.POLLOUT) != 0) && ((intOps & SelectionKey.OP_WRITE) != 0)) newOps |= SelectionKey.OP_WRITE; @@ -361,9 +360,9 @@ public class SctpMultiChannelImpl extends SctpMultiChannel public void translateAndSetInterestOps(int ops, SelectionKeyImpl sk) { int newOps = 0; if ((ops & SelectionKey.OP_READ) != 0) - newOps |= PollArrayWrapper.POLLIN; + newOps |= Net.POLLIN; if ((ops & SelectionKey.OP_WRITE) != 0) - newOps |= PollArrayWrapper.POLLOUT; + newOps |= Net.POLLOUT; sk.selector.putEventOps(sk, newOps); } diff --git a/jdk/src/solaris/classes/sun/nio/ch/sctp/SctpServerChannelImpl.java b/jdk/src/solaris/classes/sun/nio/ch/sctp/SctpServerChannelImpl.java index d22af25f1d1..c32fb9ebc0f 100644 --- a/jdk/src/solaris/classes/sun/nio/ch/sctp/SctpServerChannelImpl.java +++ b/jdk/src/solaris/classes/sun/nio/ch/sctp/SctpServerChannelImpl.java @@ -314,21 +314,20 @@ public class SctpServerChannelImpl extends SctpServerChannel int oldOps = sk.nioReadyOps(); int newOps = initialOps; - if ((ops & PollArrayWrapper.POLLNVAL) != 0) { + if ((ops & Net.POLLNVAL) != 0) { /* This should only happen if this channel is pre-closed while a * selection operation is in progress * ## Throw an error if this channel has not been pre-closed */ return false; } - if ((ops & (PollArrayWrapper.POLLERR - | PollArrayWrapper.POLLHUP)) != 0) { + if ((ops & (Net.POLLERR | Net.POLLHUP)) != 0) { newOps = intOps; sk.nioReadyOps(newOps); return (newOps & ~oldOps) != 0; } - if (((ops & PollArrayWrapper.POLLIN) != 0) && + if (((ops & Net.POLLIN) != 0) && ((intOps & SelectionKey.OP_ACCEPT) != 0)) newOps |= SelectionKey.OP_ACCEPT; @@ -352,7 +351,7 @@ public class SctpServerChannelImpl extends SctpServerChannel /* Translate ops */ if ((ops & SelectionKey.OP_ACCEPT) != 0) - newOps |= PollArrayWrapper.POLLIN; + newOps |= Net.POLLIN; /* Place ops into pollfd array */ sk.selector.putEventOps(sk, newOps); diff --git a/jdk/src/solaris/classes/sun/nio/fs/DefaultFileSystemProvider.java b/jdk/src/solaris/classes/sun/nio/fs/DefaultFileSystemProvider.java index d909916450e..595f3c6d187 100644 --- a/jdk/src/solaris/classes/sun/nio/fs/DefaultFileSystemProvider.java +++ b/jdk/src/solaris/classes/sun/nio/fs/DefaultFileSystemProvider.java @@ -63,6 +63,8 @@ public class DefaultFileSystemProvider { return createProvider("sun.nio.fs.LinuxFileSystemProvider"); if (osname.contains("OS X")) return createProvider("sun.nio.fs.MacOSXFileSystemProvider"); + if (osname.equals("AIX")) + return createProvider("sun.nio.fs.AixFileSystemProvider"); throw new AssertionError("Platform not recognized"); } } diff --git a/jdk/src/solaris/classes/sun/nio/fs/UnixFileSystemProvider.java b/jdk/src/solaris/classes/sun/nio/fs/UnixFileSystemProvider.java index bd8253e94e5..d14569e8808 100644 --- a/jdk/src/solaris/classes/sun/nio/fs/UnixFileSystemProvider.java +++ b/jdk/src/solaris/classes/sun/nio/fs/UnixFileSystemProvider.java @@ -375,11 +375,12 @@ public abstract class UnixFileSystemProvider UnixPath dir = UnixPath.toUnixPath(obj); dir.checkWrite(); - int mode = UnixFileModeAttribute - .toUnixMode(UnixFileModeAttribute.ALL_PERMISSIONS, attrs); + int mode = UnixFileModeAttribute.toUnixMode(UnixFileModeAttribute.ALL_PERMISSIONS, attrs); try { mkdir(dir, mode); } catch (UnixException x) { + if (x.errno() == EISDIR) + throw new FileAlreadyExistsException(dir.toString()); x.rethrowAsIOException(dir); } } diff --git a/jdk/src/solaris/classes/sun/print/AttributeClass.java b/jdk/src/solaris/classes/sun/print/AttributeClass.java index f9018dce19f..76a652b2a93 100644 --- a/jdk/src/solaris/classes/sun/print/AttributeClass.java +++ b/jdk/src/solaris/classes/sun/print/AttributeClass.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2008, 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 @@ -274,7 +274,7 @@ public class AttributeClass { } private int unsignedByteToInt(byte b) { - return (int) (b & 0xff); + return (b & 0xff); } private int convertToInt(byte[] buf) { diff --git a/jdk/src/solaris/classes/sun/print/CUPSPrinter.java b/jdk/src/solaris/classes/sun/print/CUPSPrinter.java index a4c1082e78c..ddfb6e1e742 100644 --- a/jdk/src/solaris/classes/sun/print/CUPSPrinter.java +++ b/jdk/src/solaris/classes/sun/print/CUPSPrinter.java @@ -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 @@ -298,7 +298,7 @@ public class CUPSPrinter { printerInfo[0] = UnixPrintServiceLookup. getDefaultPrinterNameSysV(); printerInfo[1] = null; - return (String[])printerInfo.clone(); + return printerInfo.clone(); } else { return null; } @@ -318,7 +318,7 @@ public class CUPSPrinter { } os.close(); urlConnection.disconnect(); - return (String [])printerInfo.clone(); + return printerInfo.clone(); } } os.close(); diff --git a/jdk/src/solaris/classes/sun/print/IPPPrintService.java b/jdk/src/solaris/classes/sun/print/IPPPrintService.java index f48dd5ba38e..689288126b9 100644 --- a/jdk/src/solaris/classes/sun/print/IPPPrintService.java +++ b/jdk/src/solaris/classes/sun/print/IPPPrintService.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2007, 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 @@ -74,8 +74,7 @@ public class IPPPrintService implements PrintService, SunPrinterJobService { private static final String FORCE_PIPE_PROP = "sun.print.ippdebug"; static { - String debugStr = - (String)java.security.AccessController.doPrivileged( + String debugStr = java.security.AccessController.doPrivileged( new sun.security.action.GetPropertyAction(FORCE_PIPE_PROP)); debugPrint = "true".equalsIgnoreCase(debugStr); @@ -424,7 +423,7 @@ public class IPPPrintService implements PrintService, SunPrinterJobService { } // use IPP to get all media, - Media[] allMedia = (Media[])getSupportedMedia(); + Media[] allMedia = getSupportedMedia(); ArrayList sizeList = new ArrayList(); ArrayList trayList = new ArrayList(); for (int i=0; i= 1 && !splitPart[0].trim().endsWith(":")) { + printers.add(posPrinters[i]); + } + } + + return (String[])printers.toArray(new String[printers.size()]); + } + + private PrinterIsAcceptingJobs getPrinterIsAcceptingJobsAIX() { + // On AIX there should not be a blank after '-a'. + String command = "/usr/bin/lpstat -a" + printer; + String results[]= UnixPrintServiceLookup.execCmd(command); + + // Remove headers and bogus entries added by remote printers. + results = filterPrinterNamesAIX(results); + + if (results != null && results.length > 0) { + for (int i = 0; i < results.length; i++) { + if (results[i].contains("READY") || + results[i].contains("RUNNING")) { + return PrinterIsAcceptingJobs.ACCEPTING_JOBS; + } + } + } + + return PrinterIsAcceptingJobs.NOT_ACCEPTING_JOBS; + + } + private PrinterIsAcceptingJobs getPrinterIsAcceptingJobs() { if (UnixPrintServiceLookup.isSysV()) { return getPrinterIsAcceptingJobsSysV(); } else if (UnixPrintServiceLookup.isBSD()) { return getPrinterIsAcceptingJobsBSD(); + } else if (UnixPrintServiceLookup.isAIX()) { + return getPrinterIsAcceptingJobsAIX(); } else { return PrinterIsAcceptingJobs.ACCEPTING_JOBS; } @@ -345,11 +393,32 @@ public class UnixPrintService implements PrintService, AttributeUpdater, return new QueuedJobCount(qlen); } + private QueuedJobCount getQueuedJobCountAIX() { + // On AIX there should not be a blank after '-a'. + String command = "/usr/bin/lpstat -a" + printer; + String results[]= UnixPrintServiceLookup.execCmd(command); + + // Remove headers and bogus entries added by remote printers. + results = filterPrinterNamesAIX(results); + + int qlen = 0; + if (results != null && results.length > 0){ + for (int i = 0; i < results.length; i++) { + if (results[i].contains("QUEUED")){ + qlen ++; + } + } + } + return new QueuedJobCount(qlen); + } + private QueuedJobCount getQueuedJobCount() { if (UnixPrintServiceLookup.isSysV()) { return getQueuedJobCountSysV(); } else if (UnixPrintServiceLookup.isBSD()) { return getQueuedJobCountBSD(); + } else if (UnixPrintServiceLookup.isAIX()) { + return getQueuedJobCountAIX(); } else { return new QueuedJobCount(0); } @@ -369,6 +438,13 @@ public class UnixPrintService implements PrintService, AttributeUpdater, return attrs; } + private PrintServiceAttributeSet getAIXServiceAttributes() { + PrintServiceAttributeSet attrs = new HashPrintServiceAttributeSet(); + attrs.add(getQueuedJobCountAIX()); + attrs.add(getPrinterIsAcceptingJobsAIX()); + return attrs; + } + private boolean isSupportedCopies(Copies copies) { int numCopies = copies.getValue(); return (numCopies > 0 && numCopies < MAXCOPIES); @@ -394,6 +470,8 @@ public class UnixPrintService implements PrintService, AttributeUpdater, private PrintServiceAttributeSet getDynamicAttributes() { if (UnixPrintServiceLookup.isSysV()) { return getSysVServiceAttributes(); + } else if (UnixPrintServiceLookup.isAIX()) { + return getAIXServiceAttributes(); } else { return getBSDServiceAttributes(); } diff --git a/jdk/src/solaris/classes/sun/print/UnixPrintServiceLookup.java b/jdk/src/solaris/classes/sun/print/UnixPrintServiceLookup.java index fb6950b7d0d..9a7be7f9971 100644 --- a/jdk/src/solaris/classes/sun/print/UnixPrintServiceLookup.java +++ b/jdk/src/solaris/classes/sun/print/UnixPrintServiceLookup.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, 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 @@ -78,6 +78,19 @@ public class UnixPrintServiceLookup extends PrintServiceLookup static String osname; + // List of commands used to deal with the printer queues on AIX + String[] lpNameComAix = { + "/usr/bin/lsallq", + "/usr/bin/lpstat -W -p|/usr/bin/expand|/usr/bin/cut -f1 -d' '", + "/usr/bin/lpstat -W -d|/usr/bin/expand|/usr/bin/cut -f1 -d' '", + "/usr/bin/lpstat -W -v" + }; + private static final int aix_lsallq = 0; + private static final int aix_lpstat_p = 1; + private static final int aix_lpstat_d = 2; + private static final int aix_lpstat_v = 3; + private static int aix_defaultPrinterEnumeration = aix_lsallq; + static { /* The system property "sun.java2d.print.polling" * can be used to force the printing code to poll or not poll @@ -114,6 +127,24 @@ public class UnixPrintServiceLookup extends PrintServiceLookup osname = java.security.AccessController.doPrivileged( new sun.security.action.GetPropertyAction("os.name")); + + /* The system property "sun.java2d.print.aix.lpstat" + * can be used to force the usage of 'lpstat -p' to enumerate all + * printer queues. By default we use 'lsallq', because 'lpstat -p' can + * take lots of time if thousands of printers are attached to a server. + */ + if (isAIX()) { + String aixPrinterEnumerator = java.security.AccessController.doPrivileged( + new sun.security.action.GetPropertyAction("sun.java2d.print.aix.lpstat")); + + if (aixPrinterEnumerator != null) { + if (aixPrinterEnumerator.equalsIgnoreCase("lpstat")) { + aix_defaultPrinterEnumeration = aix_lpstat_p; + } else if (aixPrinterEnumerator.equalsIgnoreCase("lsallq")) { + aix_defaultPrinterEnumeration = aix_lsallq; + } + } + } } static boolean isMac() { @@ -133,6 +164,10 @@ public class UnixPrintServiceLookup extends PrintServiceLookup osname.contains("OS X")); } + static boolean isAIX() { + return osname.equals("AIX"); + } + static final int UNINITIALIZED = -1; static final int BSD_LPD = 0; static final int BSD_LPD_NG = 1; @@ -200,7 +235,7 @@ public class UnixPrintServiceLookup extends PrintServiceLookup if (printServices == null) { return new PrintService[0]; } else { - return (PrintService[])printServices.clone(); + return printServices.clone(); } } @@ -213,13 +248,13 @@ public class UnixPrintServiceLookup extends PrintServiceLookup // information when queried using IPP. Workaround is to remove it. // Even CUPS ignores these entries as shown in lpstat or using // their web configuration. - PrinterURI uri = (PrinterURI)ps.getAttribute(PrinterURI.class); + PrinterURI uri = ps.getAttribute(PrinterURI.class); if (uri.getURI().getHost().equals("localhost")) { IPPPrintService.debug_println(debugPrefix+"duplicate PrintService, ignoring the new local printer: "+ps); return index; // Do not add this. } PrintService oldPS = (PrintService)(printerList.get(index)); - uri = (PrinterURI)oldPS.getAttribute(PrinterURI.class); + uri = oldPS.getAttribute(PrinterURI.class); if (uri.getURI().getHost().equals("localhost")) { IPPPrintService.debug_println(debugPrefix+"duplicate PrintService, removing existing local printer: "+oldPS); printerList.remove(oldPS); @@ -251,6 +286,8 @@ public class UnixPrintServiceLookup extends PrintServiceLookup } else { if (isMac() || isSysV()) { printers = getAllPrinterNamesSysV(); + } else if (isAIX()) { + printers = getAllPrinterNamesAIX(); } else { //BSD printers = getAllPrinterNamesBSD(); } @@ -410,8 +447,7 @@ public class UnixPrintServiceLookup extends PrintServiceLookup /* check if all printers are already available */ if (printServices != null) { for (PrintService printService : printServices) { - PrinterName printerName = - (PrinterName)printService.getAttribute(PrinterName.class); + PrinterName printerName = printService.getAttribute(PrinterName.class); if (printerName.getValue().equals(name)) { return printService; } @@ -435,6 +471,8 @@ public class UnixPrintServiceLookup extends PrintServiceLookup PrintService printer = null; if (isMac() || isSysV()) { printer = getNamedPrinterNameSysV(name); + } else if (isAIX()) { + printer = getNamedPrinterNameAIX(name); } else { printer = getNamedPrinterNameBSD(name); } @@ -464,8 +502,7 @@ public class UnixPrintServiceLookup extends PrintServiceLookup * initialised. */ - PrinterName defName = - (PrinterName)defService.getAttribute(PrinterName.class); + PrinterName defName = defService.getAttribute(PrinterName.class); if (defName != null && name.equals(defName)) { if (matchesAttributes(defService, serviceSet)) { @@ -600,6 +637,8 @@ public class UnixPrintServiceLookup extends PrintServiceLookup } else { if (isMac() || isSysV()) { defaultPrinter = getDefaultPrinterNameSysV(); + } else if (isAIX()) { + defaultPrinter = getDefaultPrinterNameAIX(); } else { defaultPrinter = getDefaultPrinterNameBSD(); } @@ -774,11 +813,49 @@ public class UnixPrintServiceLookup extends PrintServiceLookup return (String[])printerNames.toArray(new String[printerNames.size()]); } + private String getDefaultPrinterNameAIX() { + String[] names = execCmd(lpNameComAix[aix_lpstat_d]); + // Remove headers and bogus entries added by remote printers. + names = UnixPrintService.filterPrinterNamesAIX(names); + if (names == null || names.length != 1) { + // No default printer found + return null; + } else { + return names[0]; + } + } + + private PrintService getNamedPrinterNameAIX(String name) { + // On AIX there should be no blank after '-v'. + String[] result = execCmd(lpNameComAix[aix_lpstat_v] + name); + // Remove headers and bogus entries added by remote printers. + result = UnixPrintService.filterPrinterNamesAIX(result); + if (result == null || result.length != 1) { + return null; + } else { + return new UnixPrintService(name); + } + } + + private String[] getAllPrinterNamesAIX() { + // Determine all printers of the system. + String [] names = execCmd(lpNameComAix[aix_defaultPrinterEnumeration]); + + // Remove headers and bogus entries added by remote printers. + names = UnixPrintService.filterPrinterNamesAIX(names); + + ArrayList printerNames = new ArrayList(); + for ( int i=0; i < names.length; i++) { + printerNames.add(names[i]); + } + return printerNames.toArray(new String[printerNames.size()]); + } + static String[] execCmd(final String command) { ArrayList results = null; try { final String[] cmd = new String[3]; - if (isSysV()) { + if (isSysV() || isAIX()) { cmd[0] = "/usr/bin/sh"; cmd[1] = "-c"; cmd[2] = "env LC_ALL=C " + command; diff --git a/jdk/src/solaris/demo/jvmti/hprof/hprof_md.c b/jdk/src/solaris/demo/jvmti/hprof/hprof_md.c index 9cfcc592c3a..78a4f606735 100644 --- a/jdk/src/solaris/demo/jvmti/hprof/hprof_md.c +++ b/jdk/src/solaris/demo/jvmti/hprof/hprof_md.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -42,7 +42,7 @@ #include #include -#if !defined(LINUX) && !defined(_ALLBSD_SOURCE) +#if !defined(LINUX) && !defined(_ALLBSD_SOURCE) && !defined(AIX) #include #endif @@ -65,6 +65,10 @@ #include "jvm_md.h" #include "hprof.h" +#ifdef AIX +#include "porting_aix.h" /* For the 'dladdr' function. */ +#endif + int md_getpid(void) { @@ -86,7 +90,7 @@ md_sleep(unsigned seconds) void md_init(void) { -#if defined(LINUX) || defined(_ALLBSD_SOURCE) +#if defined(LINUX) || defined(_ALLBSD_SOURCE) || defined(AIX) /* No Hi-Res timer option? */ #else if ( gdata->micro_state_accounting ) { @@ -253,7 +257,7 @@ md_timeofday(void) jlong md_get_microsecs(void) { -#if defined(LINUX) || defined(_ALLBSD_SOURCE) +#if defined(LINUX) || defined(_ALLBSD_SOURCE) || defined(AIX) return (jlong)(md_timeofday() * (jlong)1000); /* Milli to micro */ #else return (jlong)(gethrtime()/(hrtime_t)1000); /* Nano seconds to micro seconds */ @@ -271,7 +275,7 @@ md_get_timemillis(void) jlong md_get_thread_cpu_timemillis(void) { -#if defined(LINUX) || defined(_ALLBSD_SOURCE) +#if defined(LINUX) || defined(_ALLBSD_SOURCE) || defined(AIX) return md_timeofday(); #else return (jlong)(gethrvtime()/1000); /* Nano seconds to milli seconds */ @@ -286,7 +290,7 @@ md_get_prelude_path(char *path, int path_len, char *filename) Dl_info dlinfo; libdir[0] = 0; -#if defined(LINUX) || defined(_ALLBSD_SOURCE) +#if defined(LINUX) || defined(_ALLBSD_SOURCE) || defined(AIX) addr = (void*)&Agent_OnLoad; #else /* Just using &Agent_OnLoad will get the first external symbol with @@ -457,3 +461,5 @@ md_find_library_entry(void *handle, const char *name) sym = dlsym(handle, name); return sym; } + + diff --git a/jdk/src/solaris/native/common/jdk_util_md.h b/jdk/src/solaris/native/common/jdk_util_md.h index d9fd2a2557f..c13bb7794e4 100644 --- a/jdk/src/solaris/native/common/jdk_util_md.h +++ b/jdk/src/solaris/native/common/jdk_util_md.h @@ -39,6 +39,10 @@ #include #define ISNANF(f) isnanf(f) #define ISNAND(d) isnan(d) +#elif defined(_AIX) +#include +#define ISNANF(f) _isnanf(f) +#define ISNAND(d) _isnan(d) #else #error "missing platform-specific definition here" #endif diff --git a/jdk/src/solaris/native/common/jni_util_md.c b/jdk/src/solaris/native/common/jni_util_md.c index e9e0f4e0f3f..42ab2de0037 100644 --- a/jdk/src/solaris/native/common/jni_util_md.c +++ b/jdk/src/solaris/native/common/jni_util_md.c @@ -23,6 +23,8 @@ * questions. */ +#include + #include "jni.h" #include "jni_util.h" #include "dlfcn.h" @@ -40,7 +42,11 @@ void* getProcessHandle() { if (procHandle != NULL) { return procHandle; } +#ifdef __APPLE__ + procHandle = (void*)dlopen(NULL, RTLD_FIRST); +#else procHandle = (void*)dlopen(NULL, RTLD_LAZY); +#endif return procHandle; } diff --git a/jdk/src/solaris/native/java/io/io_util_md.c b/jdk/src/solaris/native/java/io/io_util_md.c index e74bc127102..5899a410347 100644 --- a/jdk/src/solaris/native/java/io/io_util_md.c +++ b/jdk/src/solaris/native/java/io/io_util_md.c @@ -35,7 +35,7 @@ #include #endif -#if defined(__linux__) || defined(_ALLBSD_SOURCE) +#if defined(__linux__) || defined(_ALLBSD_SOURCE) || defined(_AIX) #include #endif diff --git a/jdk/src/solaris/native/java/lang/UNIXProcess_md.c b/jdk/src/solaris/native/java/lang/UNIXProcess_md.c index 177031e5c74..ec85b685dc6 100644 --- a/jdk/src/solaris/native/java/lang/UNIXProcess_md.c +++ b/jdk/src/solaris/native/java/lang/UNIXProcess_md.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 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 @@ -44,7 +44,7 @@ #include #include -#if defined(__solaris__) || defined(_ALLBSD_SOURCE) +#if defined(__solaris__) || defined(_ALLBSD_SOURCE) || defined(_AIX) #include #endif @@ -455,7 +455,7 @@ forkChild(ChildStuff *c) { return resultPid; } -#if defined(__solaris__) || defined(_ALLBSD_SOURCE) +#if defined(__solaris__) || defined(_ALLBSD_SOURCE) || defined(_AIX) static pid_t spawnChild(JNIEnv *env, jobject process, ChildStuff *c, const char *helperpath) { pid_t resultPid; @@ -551,7 +551,7 @@ startChild(JNIEnv *env, jobject process, ChildStuff *c, const char *helperpath) return vforkChild(c); case MODE_FORK: return forkChild(c); -#if defined(__solaris__) || defined(_ALLBSD_SOURCE) +#if defined(__solaris__) || defined(_ALLBSD_SOURCE) || defined(_AIX) case MODE_POSIX_SPAWN: return spawnChild(env, process, c, helperpath); #endif diff --git a/jdk/src/solaris/native/java/lang/childproc.c b/jdk/src/solaris/native/java/lang/childproc.c index 0cfcf6fe9a8..1d183cf1fb2 100644 --- a/jdk/src/solaris/native/java/lang/childproc.c +++ b/jdk/src/solaris/native/java/lang/childproc.c @@ -66,6 +66,9 @@ isAsciiDigit(char c) #define FD_DIR "/dev/fd" #define dirent64 dirent #define readdir64 readdir +#elif defined(_AIX) +/* AIX does not understand '/proc/self' - it requires the real process ID */ +#define FD_DIR aix_fd_dir #else #define FD_DIR "/proc/self/fd" #endif @@ -87,6 +90,12 @@ closeDescriptors(void) close(from_fd); /* for possible use by opendir() */ close(from_fd + 1); /* another one for good luck */ +#if defined(_AIX) + /* AIX does not understand '/proc/self' - it requires the real process ID */ + char aix_fd_dir[32]; /* the pid has at most 19 digits */ + snprintf(aix_fd_dir, 32, "/proc/%d/fd", getpid()); +#endif + if ((dp = opendir(FD_DIR)) == NULL) return 0; diff --git a/jdk/src/solaris/native/java/net/NetworkInterface.c b/jdk/src/solaris/native/java/net/NetworkInterface.c index b2ebd8e222b..16acf07a269 100644 --- a/jdk/src/solaris/native/java/net/NetworkInterface.c +++ b/jdk/src/solaris/native/java/net/NetworkInterface.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -52,6 +52,13 @@ #include #endif +#if defined(_AIX) +#include +#include +#include +#include +#endif + #ifdef __linux__ #define _PATH_PROCNET_IFINET6 "/proc/net/if_inet6" #endif @@ -1041,8 +1048,8 @@ static int openSocket(JNIEnv *env, int proto){ } -/** Linux **/ -#ifdef __linux__ +/** Linux, AIX **/ +#if defined(__linux__) || defined(_AIX) /* Open socket for further ioct calls, try v4 socket first and * if it falls return v6 socket */ @@ -1080,11 +1087,13 @@ static int openSocketWithFallback(JNIEnv *env, const char *ifname){ static netif *enumIPv4Interfaces(JNIEnv *env, int sock, netif *ifs) { struct ifconf ifc; struct ifreq *ifreqP; - char *buf; + char *buf = NULL; int numifs; unsigned i; + int siocgifconfRequest = SIOCGIFCONF; +#if defined(__linux__) /* need to do a dummy SIOCGIFCONF to determine the buffer size. * SIOCGIFCOUNT doesn't work */ @@ -1093,11 +1102,21 @@ static netif *enumIPv4Interfaces(JNIEnv *env, int sock, netif *ifs) { NET_ThrowByNameWithLastError(env , JNU_JAVANETPKG "SocketException", "ioctl SIOCGIFCONF failed"); return ifs; } +#elif defined(_AIX) + ifc.ifc_buf = NULL; + if (ioctl(sock, SIOCGSIZIFCONF, &(ifc.ifc_len)) < 0) { + NET_ThrowByNameWithLastError(env , JNU_JAVANETPKG "SocketException", "ioctl SIOCGSIZIFCONF failed"); + return ifs; + } +#endif /* __linux__ */ CHECKED_MALLOC3(buf,char *, ifc.ifc_len); ifc.ifc_buf = buf; - if (ioctl(sock, SIOCGIFCONF, (char *)&ifc) < 0) { +#if defined(_AIX) + siocgifconfRequest = CSIOCGIFCONF; +#endif + if (ioctl(sock, siocgifconfRequest, (char *)&ifc) < 0) { NET_ThrowByNameWithLastError(env , JNU_JAVANETPKG "SocketException", "ioctl SIOCGIFCONF failed"); (void) free(buf); return ifs; @@ -1108,6 +1127,9 @@ static netif *enumIPv4Interfaces(JNIEnv *env, int sock, netif *ifs) { */ ifreqP = ifc.ifc_req; for (i=0; iifr_addr.sa_family != AF_INET) continue; +#endif /* * Add to the list */ @@ -1135,7 +1157,7 @@ static netif *enumIPv4Interfaces(JNIEnv *env, int sock, netif *ifs) { * Enumerates and returns all IPv6 interfaces on Linux */ -#ifdef AF_INET6 +#if defined(AF_INET6) && defined(__linux__) static netif *enumIPv6Interfaces(JNIEnv *env, int sock, netif *ifs) { FILE *f; char addr6[40], devname[21]; @@ -1179,11 +1201,108 @@ static netif *enumIPv6Interfaces(JNIEnv *env, int sock, netif *ifs) { #endif +/* + * Enumerates and returns all IPv6 interfaces on AIX + */ + +#if defined(AF_INET6) && defined(_AIX) +static netif *enumIPv6Interfaces(JNIEnv *env, int sock, netif *ifs) { + struct ifconf ifc; + struct ifreq *ifreqP; + char *buf; + int numifs; + unsigned i; + unsigned bufsize; + char *cp, *cplimit; + + /* use SIOCGSIZIFCONF to get size for SIOCGIFCONF */ + + ifc.ifc_buf = NULL; + if (ioctl(sock, SIOCGSIZIFCONF, &(ifc.ifc_len)) < 0) { + NET_ThrowByNameWithLastError(env , JNU_JAVANETPKG "SocketException", + "ioctl SIOCGSIZIFCONF failed"); + return ifs; + } + bufsize = ifc.ifc_len; + + buf = (char *)malloc(bufsize); + if (!buf) { + JNU_ThrowOutOfMemoryError(env, "Network interface native buffer allocation failed"); + return ifs; + } + ifc.ifc_len = bufsize; + ifc.ifc_buf = buf; + if (ioctl(sock, SIOCGIFCONF, (char *)&ifc) < 0) { + NET_ThrowByNameWithLastError(env , JNU_JAVANETPKG "SocketException", + "ioctl CSIOCGIFCONF failed"); + free(buf); + return ifs; + } + + /* + * Iterate through each interface + */ + ifreqP = ifc.ifc_req; + cp = (char *)ifc.ifc_req; + cplimit = cp + ifc.ifc_len; + + for ( ; cp < cplimit; cp += (sizeof(ifreqP->ifr_name) + MAX((ifreqP->ifr_addr).sa_len, sizeof(ifreqP->ifr_addr)))) { + ifreqP = (struct ifreq *)cp; + struct ifreq if2; + + memset((char *)&if2, 0, sizeof(if2)); + strcpy(if2.ifr_name, ifreqP->ifr_name); + + /* + * Skip interface that aren't UP + */ + if (ioctl(sock, SIOCGIFFLAGS, (char *)&if2) >= 0) { + if (!(if2.ifr_flags & IFF_UP)) { + continue; + } + } + + if (ifreqP->ifr_addr.sa_family != AF_INET6) + continue; + + if (ioctl(sock, SIOCGIFSITE6, (char *)&if2) >= 0) { + struct sockaddr_in6 *s6= (struct sockaddr_in6 *)&(ifreqP->ifr_addr); + s6->sin6_scope_id = if2.ifr_site6; + } + + /* + * Add to the list + */ + ifs = addif(env, sock, ifreqP->ifr_name, ifs, + (struct sockaddr *)&(ifreqP->ifr_addr), + AF_INET6, 0); + + /* + * If an exception occurred then free the list + */ + if ((*env)->ExceptionOccurred(env)) { + free(buf); + freeif(ifs); + return NULL; + } + } + + /* + * Free socket and buffer + */ + free(buf); + return ifs; +} +#endif + + static int getIndex(int sock, const char *name){ /* * Try to get the interface index - * (Not supported on Solaris 2.6 or 7) */ +#if defined(_AIX) + return if_nametoindex(name); +#else struct ifreq if2; strcpy(if2.ifr_name, name); @@ -1192,6 +1311,7 @@ static int getIndex(int sock, const char *name){ } return if2.ifr_ifindex; +#endif } /** @@ -1258,6 +1378,46 @@ static short getSubnet(JNIEnv *env, int sock, const char *ifname) { * MAC address. Returns -1 if there is no hardware address on that interface. */ static int getMacAddress(JNIEnv *env, int sock, const char* ifname, const struct in_addr* addr, unsigned char *buf) { +#if defined (_AIX) + int size; + struct kinfo_ndd *nddp; + void *end; + + size = getkerninfo(KINFO_NDD, 0, 0, 0); + if (size == 0) { + return -1; + } + + if (size < 0) { + perror("getkerninfo 1"); + return -1; + } + + nddp = (struct kinfo_ndd *)malloc(size); + + if (!nddp) { + return -1; + } + + if (getkerninfo(KINFO_NDD, nddp, &size, 0) < 0) { + perror("getkerninfo 2"); + return -1; + } + + end = (void *)nddp + size; + while ((void *)nddp < end) { + if (!strcmp(nddp->ndd_alias, ifname) || + !strcmp(nddp->ndd_name, ifname)) { + bcopy(nddp->ndd_addr, buf, 6); + return 6; + } else { + nddp++; + } + } + + return -1; + +#elif defined(__linux__) static struct ifreq ifr; int i; @@ -1279,6 +1439,7 @@ static int getMacAddress(JNIEnv *env, int sock, const char* ifname, const struct } return -1; +#endif } static int getMTU(JNIEnv *env, int sock, const char *ifname) { diff --git a/jdk/src/solaris/native/java/net/PlainDatagramSocketImpl.c b/jdk/src/solaris/native/java/net/PlainDatagramSocketImpl.c index 09f8e5d0c61..53d8fae2751 100644 --- a/jdk/src/solaris/native/java/net/PlainDatagramSocketImpl.c +++ b/jdk/src/solaris/native/java/net/PlainDatagramSocketImpl.c @@ -1202,6 +1202,9 @@ static void setMulticastInterface(JNIEnv *env, jobject this, int fd, #ifdef __linux__ mcast_set_if_by_addr_v4(env, this, fd, value); if (ipv6_available()) { + if ((*env)->ExceptionCheck(env)){ + (*env)->ExceptionClear(env); + } mcast_set_if_by_addr_v6(env, this, fd, value); } #else /* __linux__ not defined */ @@ -1224,6 +1227,9 @@ static void setMulticastInterface(JNIEnv *env, jobject this, int fd, #ifdef __linux__ mcast_set_if_by_if_v4(env, this, fd, value); if (ipv6_available()) { + if ((*env)->ExceptionCheck(env)){ + (*env)->ExceptionClear(env); + } mcast_set_if_by_if_v6(env, this, fd, value); } #else /* __linux__ not defined */ @@ -1297,6 +1303,9 @@ static void setMulticastLoopbackMode(JNIEnv *env, jobject this, int fd, #ifdef __linux__ mcast_set_loop_v4(env, this, fd, value); if (ipv6_available()) { + if ((*env)->ExceptionCheck(env)){ + (*env)->ExceptionClear(env); + } mcast_set_loop_v6(env, this, fd, value); } #else /* __linux__ not defined */ diff --git a/jdk/src/solaris/native/java/net/PlainSocketImpl.c b/jdk/src/solaris/native/java/net/PlainSocketImpl.c index b6f78b9c158..a4958efc512 100644 --- a/jdk/src/solaris/native/java/net/PlainSocketImpl.c +++ b/jdk/src/solaris/native/java/net/PlainSocketImpl.c @@ -963,7 +963,7 @@ Java_java_net_PlainSocketImpl_socketSetOption(JNIEnv *env, jobject this, } if (NET_SetSockOpt(fd, level, optname, (const void *)&optval, optlen) < 0) { -#ifdef __solaris__ +#if defined(__solaris__) || defined(_AIX) if (errno == EINVAL) { // On Solaris setsockopt will set errno to EINVAL if the socket // is closed. The default error message is then confusing diff --git a/jdk/src/solaris/native/java/net/net_util_md.c b/jdk/src/solaris/native/java/net/net_util_md.c index d7ebbd5a7c9..209af3f04e3 100644 --- a/jdk/src/solaris/native/java/net/net_util_md.c +++ b/jdk/src/solaris/native/java/net/net_util_md.c @@ -138,8 +138,7 @@ static int useExclBind = 0; * of the parameter is assumed to be an 'int'. If the parameter * cannot be obtained return -1 */ -static int -getParam(char *driver, char *param) +int net_getParam(char *driver, char *param) { struct strioctl stri; char buf [64]; @@ -166,7 +165,7 @@ getParam(char *driver, char *param) /* * Iterative way to find the max value that SO_SNDBUF or SO_RCVBUF - * for Solaris versions that do not support the ioctl() in getParam(). + * for Solaris versions that do not support the ioctl() in net_getParam(). * Ugly, but only called once (for each sotype). * * As an optimization, we make a guess using the default values for Solaris @@ -738,14 +737,23 @@ static int getLocalScopeID (char *addr) { return 0; } -void initLocalAddrTable () { +void platformInit () { initLoopbackRoutes(); initLocalIfs(); } +#elif defined(_AIX) + +/* Initialize stubs for blocking I/O workarounds (see src/solaris/native/java/net/linux_close.c) */ +extern void aix_close_init(); + +void platformInit () { + aix_close_init(); +} + #else -void initLocalAddrTable () {} +void platformInit () {} #endif @@ -1272,6 +1280,7 @@ int NET_SetSockOpt(int fd, int level, int opt, const void *arg, int len) { + #ifndef IPTOS_TOS_MASK #define IPTOS_TOS_MASK 0x1e #endif @@ -1292,9 +1301,6 @@ NET_SetSockOpt(int fd, int level, int opt, const void *arg, #else static long maxsockbuf = -1; #endif - - int addopt; - struct linger *ling; #endif /* @@ -1359,7 +1365,7 @@ NET_SetSockOpt(int fd, int level, int opt, const void *arg, * If that fails, we use the search algorithm in findMaxBuf() */ if (!init_tcp_max_buf && sotype == SOCK_STREAM) { - tcp_max_buf = getParam("/dev/tcp", "tcp_max_buf"); + tcp_max_buf = net_getParam("/dev/tcp", "tcp_max_buf"); if (tcp_max_buf == -1) { tcp_max_buf = findMaxBuf(fd, opt, SOCK_STREAM); if (tcp_max_buf == -1) { @@ -1368,7 +1374,7 @@ NET_SetSockOpt(int fd, int level, int opt, const void *arg, } init_tcp_max_buf = 1; } else if (!init_udp_max_buf && sotype == SOCK_DGRAM) { - udp_max_buf = getParam("/dev/udp", "udp_max_buf"); + udp_max_buf = net_getParam("/dev/udp", "udp_max_buf"); if (udp_max_buf == -1) { udp_max_buf = findMaxBuf(fd, opt, SOCK_DGRAM); if (udp_max_buf == -1) { @@ -1387,6 +1393,29 @@ NET_SetSockOpt(int fd, int level, int opt, const void *arg, } #endif +#ifdef _AIX + if (level == SOL_SOCKET) { + if (opt == SO_SNDBUF || opt == SO_RCVBUF) { + /* + * Just try to set the requested size. If it fails we will leave the + * socket option as is. Setting the buffer size means only a hint in + * the jse2/java software layer, see javadoc. In the previous + * solution the buffer has always been truncated to a length of + * 0x100000 Byte, even if the technical limit has not been reached. + * This kind of absolute truncation was unexpected in the jck tests. + */ + int ret = setsockopt(fd, level, opt, arg, len); + if ((ret == 0) || (ret == -1 && errno == ENOBUFS)) { + // Accept failure because of insufficient buffer memory resources. + return 0; + } else { + // Deliver all other kinds of errors. + return ret; + } + } + } +#endif + /* * On Linux the receive buffer is used for both socket * structures and the the packet payload. The implication @@ -1443,10 +1472,12 @@ NET_SetSockOpt(int fd, int level, int opt, const void *arg, } } +#endif +#if defined(_ALLBSD_SOURCE) || defined(_AIX) /* * On Solaris, SO_REUSEADDR will allow multiple datagram - * sockets to bind to the same port. The network jck tests + * sockets to bind to the same port. The network jck tests check * for this "feature", so we need to emulate it by turning on * SO_REUSEPORT as well for that combination. */ @@ -1460,11 +1491,9 @@ NET_SetSockOpt(int fd, int level, int opt, const void *arg, } if (sotype == SOCK_DGRAM) { - addopt = SO_REUSEPORT; - setsockopt(fd, level, addopt, arg, len); + setsockopt(fd, level, SO_REUSEPORT, arg, len); } } - #endif return setsockopt(fd, level, opt, arg, len); @@ -1634,7 +1663,7 @@ NET_Wait(JNIEnv *env, jint fd, jint flags, jint timeout) if (timeout <= 0) { return read_rv > 0 ? 0 : -1; } - newTime = prevTime; + prevTime = newTime; if (read_rv > 0) { break; diff --git a/jdk/src/solaris/native/java/net/net_util_md.h b/jdk/src/solaris/native/java/net/net_util_md.h index 4470a49b1e2..c602753b950 100644 --- a/jdk/src/solaris/native/java/net/net_util_md.h +++ b/jdk/src/solaris/native/java/net/net_util_md.h @@ -37,7 +37,17 @@ #endif -#if defined(__linux__) || defined(MACOSX) +/* + AIX needs a workaround for I/O cancellation, see: + http://publib.boulder.ibm.com/infocenter/pseries/v5r3/index.jsp?topic=/com.ibm.aix.basetechref/doc/basetrf1/close.htm + ... + The close subroutine is blocked until all subroutines which use the file + descriptor return to usr space. For example, when a thread is calling close + and another thread is calling select with the same file descriptor, the + close subroutine does not return until the select call returns. + ... +*/ +#if defined(__linux__) || defined(MACOSX) || defined (_AIX) extern int NET_Timeout(int s, long timeout); extern int NET_Read(int s, void* buf, size_t len); extern int NET_RecvFrom(int s, void *buf, int len, unsigned int flags, @@ -81,6 +91,9 @@ extern int NET_Poll(struct pollfd *ufds, unsigned int nfds, int timeout); int getDefaultIPv6Interface(struct in6_addr *target_addr); #endif +#ifdef __solaris__ +extern int net_getParam(char *driver, char *param); +#endif /* needed from libsocket on Solaris 8 */ diff --git a/jdk/src/solaris/native/java/util/FileSystemPreferences.c b/jdk/src/solaris/native/java/util/FileSystemPreferences.c index eb0bf43fec5..757f64c34f0 100644 --- a/jdk/src/solaris/native/java/util/FileSystemPreferences.c +++ b/jdk/src/solaris/native/java/util/FileSystemPreferences.c @@ -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 @@ -38,12 +38,14 @@ JNIEXPORT jint JNICALL Java_java_util_prefs_FileSystemPreferences_chmod(JNIEnv *env, jclass thisclass, jstring java_fname, jint permission) { - const char *fname = JNU_GetStringPlatformChars(env, java_fname, JNI_FALSE); - int result; - result = chmod(fname, permission); - if (result != 0) - result = errno; - JNU_ReleaseStringPlatformChars(env, java_fname, fname); + const char *fname = JNU_GetStringPlatformChars(env, java_fname, NULL); + int result = -1; + if (fname) { + result = chmod(fname, permission); + if (result != 0) + result = errno; + JNU_ReleaseStringPlatformChars(env, java_fname, fname); + } return (jint) result; } @@ -61,13 +63,16 @@ typedef struct flock64 FLOCK; JNIEXPORT jintArray JNICALL Java_java_util_prefs_FileSystemPreferences_lockFile0(JNIEnv *env, jclass thisclass, jstring java_fname, jint permission, jboolean shared) { - const char *fname = JNU_GetStringPlatformChars(env, java_fname, JNI_FALSE); + const char *fname = JNU_GetStringPlatformChars(env, java_fname, NULL); int fd, rc; int result[2]; - jintArray javaResult; + jintArray javaResult = NULL; int old_umask; FLOCK fl; + if (!fname) + return javaResult; + fl.l_whence = SEEK_SET; fl.l_len = 0; fl.l_start = 0; @@ -104,7 +109,8 @@ Java_java_util_prefs_FileSystemPreferences_lockFile0(JNIEnv *env, } JNU_ReleaseStringPlatformChars(env, java_fname, fname); javaResult = (*env)->NewIntArray(env,2); - (*env)->SetIntArrayRegion(env, javaResult, 0, 2, result); + if (javaResult) + (*env)->SetIntArrayRegion(env, javaResult, 0, 2, result); return javaResult; } diff --git a/jdk/src/solaris/native/java/util/TimeZone_md.c b/jdk/src/solaris/native/java/util/TimeZone_md.c index ce2fa5aca8c..e1af8f92556 100644 --- a/jdk/src/solaris/native/java/util/TimeZone_md.c +++ b/jdk/src/solaris/native/java/util/TimeZone_md.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -123,7 +123,7 @@ findZoneinfoFile(char *buf, size_t size, const char *dir) return NULL; } -#if defined(__linux__) || defined(MACOSX) || (defined(__solaris__) \ +#if defined(_AIX) || defined(__linux__) || defined(MACOSX) || (defined(__solaris__) \ && (defined(_POSIX_PTHREAD_SEMANTICS) || defined(_LP64))) while (readdir_r(dirp, entry, &dp) == 0 && dp != NULL) { #else @@ -615,6 +615,14 @@ getSolarisDefaultZoneID() { #endif /*__solaris__*/ #endif /*__linux__*/ +#ifdef _AIX +static char * +getPlatformTimeZoneID() +{ + return NULL; +} +#endif + /* * findJavaTZ_md() maps platform time zone ID to Java time zone ID * using /lib/tzmappings. If the TZ value is not found, it @@ -635,7 +643,7 @@ findJavaTZ_md(const char *java_home_dir, const char *country) #if defined(__linux__) || defined(_ALLBSD_SOURCE) if (tz == NULL) { #else -#ifdef __solaris__ +#if defined (__solaris__) || defined(_AIX) if (tz == NULL || *tz == '\0') { #endif #endif diff --git a/jdk/src/solaris/native/sun/awt/awt_LoadLibrary.c b/jdk/src/solaris/native/sun/awt/awt_LoadLibrary.c index b6da1dc60c8..754600a591d 100644 --- a/jdk/src/solaris/native/sun/awt/awt_LoadLibrary.c +++ b/jdk/src/solaris/native/sun/awt/awt_LoadLibrary.c @@ -37,6 +37,10 @@ #include "awt_Plugin.h" +#ifdef AIX +#include "porting_aix.h" /* For the 'dladdr' function. */ +#endif + #ifdef DEBUG #define VERBOSE_AWT_DEBUG #endif diff --git a/jdk/src/solaris/native/sun/awt/fontpath.c b/jdk/src/solaris/native/sun/awt/fontpath.c index 12c8405beae..19e5d9bf8d8 100644 --- a/jdk/src/solaris/native/sun/awt/fontpath.c +++ b/jdk/src/solaris/native/sun/awt/fontpath.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -64,7 +64,7 @@ extern Display *awt_display; #define MAXFDIRS 512 /* Max number of directories that contain fonts */ -#if !defined(__linux__) +#if defined(__solaris__) /* * This can be set in the makefile to "/usr/X11" if so desired. */ @@ -114,7 +114,7 @@ static char *fullSolarisFontPath[] = { NULL, /* terminates the list */ }; -#else /* __linux */ +#elif defined( __linux__) /* All the known interesting locations we have discovered on * various flavors of Linux */ @@ -134,6 +134,12 @@ static char *fullLinuxFontPath[] = { "/usr/share/fonts/default/Type1", /* RH 9.0 */ NULL, /* terminates the list */ }; +#elif defined(_AIX) +static char *fullAixFontPath[] = { + "/usr/lpp/X11/lib/X11/fonts/Type1", /* from X11.fnt.iso_T1 */ + "/usr/lpp/X11/lib/X11/fonts/TrueType", /* from X11.fnt.ucs.ttf */ + NULL, /* terminates the list */ +}; #endif static char **getFontConfigLocations(); @@ -497,10 +503,11 @@ static char *getPlatformFontPathChars(JNIEnv *env, jboolean noType1) { #if defined(__linux__) knowndirs = fullLinuxFontPath; -#else /* IF SOLARIS */ +#elif defined(__solaris__) knowndirs = fullSolarisFontPath; +#elif defined(_AIX) + knowndirs = fullAixFontPath; #endif - /* REMIND: this code requires to be executed when the GraphicsEnvironment * is already initialised. That is always true, but if it were not so, * this code could throw an exception and the fontpath would fail to @@ -592,6 +599,25 @@ static void* openFontConfig() { } } #endif + +#if defined(_AIX) + /* On AIX, fontconfig is not a standard package supported by IBM. + * instead it has to be installed from the "AIX Toolbox for Linux Applications" + * site http://www-03.ibm.com/systems/power/software/aix/linux/toolbox/alpha.html + * and will be installed under /opt/freeware/lib/libfontconfig.a. + * Notice that the archive contains the real 32- and 64-bit shared libraries. + * We first try to load 'libfontconfig.so' from the default library path in the + * case the user has installed a private version of the library and if that + * doesn't succeed, we try the version from /opt/freeware/lib/libfontconfig.a + */ + libfontconfig = dlopen("libfontconfig.so", RTLD_LOCAL|RTLD_LAZY); + if (libfontconfig == NULL) { + libfontconfig = dlopen("/opt/freeware/lib/libfontconfig.a(libfontconfig.so.1)", RTLD_MEMBER|RTLD_LOCAL|RTLD_LAZY); + if (libfontconfig == NULL) { + return NULL; + } + } +#else /* 64 bit sparc should pick up the right version from the lib path. * New features may be added to libfontconfig, this is expected to * be compatible with old features, but we may need to start @@ -606,6 +632,7 @@ static void* openFontConfig() { return NULL; } } +#endif /* Version 1.0 of libfontconfig crashes if HOME isn't defined in * the environment. This should generally never happen, but we can't @@ -1203,7 +1230,7 @@ Java_sun_font_FontConfigManager_getFontConfig */ if (fontformat != NULL && (strcmp((char*)fontformat, "TrueType") != 0) -#ifdef __linux__ +#if defined(__linux__) || defined(_AIX) && (strcmp((char*)fontformat, "Type 1") != 0) #endif ) { diff --git a/jdk/src/solaris/native/sun/awt/splashscreen/splashscreen_sys.c b/jdk/src/solaris/native/sun/awt/splashscreen/splashscreen_sys.c index e43ebcaf236..930f7ebbeb9 100644 --- a/jdk/src/solaris/native/sun/awt/splashscreen/splashscreen_sys.c +++ b/jdk/src/solaris/native/sun/awt/splashscreen/splashscreen_sys.c @@ -577,8 +577,8 @@ SplashEventLoop(Splash * splash) { SplashUnlock(splash); rc = poll(pfd, 2, timeout); SplashLock(splash); - if (splash->isVisible>0 && SplashTime() >= splash->time + - splash->frames[splash->currentFrame].delay) { + if (splash->isVisible > 0 && splash->currentFrame >= 0 && + SplashTime() >= splash->time + splash->frames[splash->currentFrame].delay) { SplashNextFrame(splash); SplashUpdateShape(splash); SplashRedrawWindow(splash); diff --git a/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.c b/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.c index 79e3be488a6..fd48e42cf1e 100644 --- a/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.c +++ b/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.c @@ -56,8 +56,8 @@ typedef struct _X11RIPrivate { int x, y; } X11RIPrivate; -#define MAX(a,b) ((a) > (b) ? (a) : (b)) -#define MIN(a,b) ((a) < (b) ? (a) : (b)) +#define XSD_MAX(a,b) ((a) > (b) ? (a) : (b)) +#define XSD_MIN(a,b) ((a) < (b) ? (a) : (b)) static LockFunc X11SD_Lock; static GetRasInfoFunc X11SD_GetRasInfo; @@ -1090,10 +1090,10 @@ X11SD_ClipToRoot(SurfaceDataBounds *b, SurfaceDataBounds *bounds, x2 = x1 + DisplayWidth(awt_display, xsdo->configData->awt_visInfo.screen); y2 = y1 + DisplayHeight(awt_display, xsdo->configData->awt_visInfo.screen); - x1 = MAX(bounds->x1, x1); - y1 = MAX(bounds->y1, y1); - x2 = MIN(bounds->x2, x2); - y2 = MIN(bounds->y2, y2); + x1 = XSD_MAX(bounds->x1, x1); + y1 = XSD_MAX(bounds->y1, y1); + x2 = XSD_MIN(bounds->x2, x2); + y2 = XSD_MIN(bounds->y2, y2); if ((x1 >= x2) || (y1 >= y2)) { return FALSE; } diff --git a/jdk/src/solaris/native/sun/java2d/x11/XRBackendNative.c b/jdk/src/solaris/native/sun/java2d/x11/XRBackendNative.c index e2554b3209e..733606ec444 100644 --- a/jdk/src/solaris/native/sun/java2d/x11/XRBackendNative.c +++ b/jdk/src/solaris/native/sun/java2d/x11/XRBackendNative.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -72,8 +72,8 @@ typedef struct _XRadialGradient { #include -#ifdef __solaris__ -/* Solaris 10 will not have these symbols at runtime */ +#if defined(__solaris__) || defined(_AIX) +/* Solaris 10 and AIX will not have these symbols at runtime */ typedef Picture (*XRenderCreateLinearGradientFuncType) (Display *dpy, @@ -147,7 +147,7 @@ static jboolean IsXRenderAvailable(jboolean verbose, jboolean ignoreLinuxVersion return JNI_FALSE; } -#ifdef __solaris__ +#if defined(__solaris__) || defined(_AIX) xrenderlib = dlopen("libXrender.so",RTLD_GLOBAL|RTLD_LAZY); if (xrenderlib != NULL) { diff --git a/jdk/src/solaris/native/sun/management/LinuxOperatingSystem.c b/jdk/src/solaris/native/sun/management/LinuxOperatingSystem.c index c8bd739ebef..1d6c89ed754 100644 --- a/jdk/src/solaris/native/sun/management/LinuxOperatingSystem.c +++ b/jdk/src/solaris/native/sun/management/LinuxOperatingSystem.c @@ -310,7 +310,7 @@ double get_process_load() { } JNIEXPORT jdouble JNICALL -Java_sun_management_OperatingSystemImpl_getSystemCpuLoad +Java_sun_management_OperatingSystemImpl_getSystemCpuLoad0 (JNIEnv *env, jobject dummy) { if(perfInit() == 0) { @@ -321,7 +321,7 @@ Java_sun_management_OperatingSystemImpl_getSystemCpuLoad } JNIEXPORT jdouble JNICALL -Java_sun_management_OperatingSystemImpl_getProcessCpuLoad +Java_sun_management_OperatingSystemImpl_getProcessCpuLoad0 (JNIEnv *env, jobject dummy) { if(perfInit() == 0) { diff --git a/jdk/src/solaris/native/sun/management/MacosxOperatingSystem.c b/jdk/src/solaris/native/sun/management/MacosxOperatingSystem.c index 8fb39786fe1..24c8669ba47 100644 --- a/jdk/src/solaris/native/sun/management/MacosxOperatingSystem.c +++ b/jdk/src/solaris/native/sun/management/MacosxOperatingSystem.c @@ -31,7 +31,7 @@ JNIEXPORT jdouble JNICALL -Java_sun_management_OperatingSystemImpl_getSystemCpuLoad +Java_sun_management_OperatingSystemImpl_getSystemCpuLoad0 (JNIEnv *env, jobject dummy) { // This code is influenced by the darwin top source @@ -83,7 +83,7 @@ Java_sun_management_OperatingSystemImpl_getSystemCpuLoad JNIEXPORT jdouble JNICALL -Java_sun_management_OperatingSystemImpl_getProcessCpuLoad +Java_sun_management_OperatingSystemImpl_getProcessCpuLoad0 (JNIEnv *env, jobject dummy) { // This code is influenced by the darwin top source diff --git a/jdk/src/solaris/native/sun/management/OperatingSystemImpl.c b/jdk/src/solaris/native/sun/management/OperatingSystemImpl.c index f1322ebd90b..898a0f9e58a 100644 --- a/jdk/src/solaris/native/sun/management/OperatingSystemImpl.c +++ b/jdk/src/solaris/native/sun/management/OperatingSystemImpl.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -41,7 +41,7 @@ #include #include #endif -#else +#elif !defined(_AIX) #include #endif #include @@ -57,9 +57,13 @@ #include #include +#if defined(_AIX) +#include +#endif + static jlong page_size = 0; -#if defined(_ALLBSD_SOURCE) +#if defined(_ALLBSD_SOURCE) || defined(_AIX) #define MB (1024UL * 1024UL) #else @@ -175,14 +179,14 @@ static jlong get_total_or_available_swap_space_size(JNIEnv* env, jboolean availa } JNIEXPORT void JNICALL -Java_sun_management_OperatingSystemImpl_initialize +Java_sun_management_OperatingSystemImpl_initialize0 (JNIEnv *env, jclass cls) { page_size = sysconf(_SC_PAGESIZE); } JNIEXPORT jlong JNICALL -Java_sun_management_OperatingSystemImpl_getCommittedVirtualMemorySize +Java_sun_management_OperatingSystemImpl_getCommittedVirtualMemorySize0 (JNIEnv *env, jobject mbean) { #ifdef __solaris__ @@ -249,21 +253,21 @@ Java_sun_management_OperatingSystemImpl_getCommittedVirtualMemorySize } JNIEXPORT jlong JNICALL -Java_sun_management_OperatingSystemImpl_getTotalSwapSpaceSize +Java_sun_management_OperatingSystemImpl_getTotalSwapSpaceSize0 (JNIEnv *env, jobject mbean) { return get_total_or_available_swap_space_size(env, JNI_FALSE); } JNIEXPORT jlong JNICALL -Java_sun_management_OperatingSystemImpl_getFreeSwapSpaceSize +Java_sun_management_OperatingSystemImpl_getFreeSwapSpaceSize0 (JNIEnv *env, jobject mbean) { return get_total_or_available_swap_space_size(env, JNI_TRUE); } JNIEXPORT jlong JNICALL -Java_sun_management_OperatingSystemImpl_getProcessCpuTime +Java_sun_management_OperatingSystemImpl_getProcessCpuTime0 (JNIEnv *env, jobject mbean) { #ifdef __APPLE__ @@ -305,7 +309,7 @@ Java_sun_management_OperatingSystemImpl_getProcessCpuTime } JNIEXPORT jlong JNICALL -Java_sun_management_OperatingSystemImpl_getFreePhysicalMemorySize +Java_sun_management_OperatingSystemImpl_getFreePhysicalMemorySize0 (JNIEnv *env, jobject mbean) { #ifdef __APPLE__ @@ -326,6 +330,12 @@ Java_sun_management_OperatingSystemImpl_getFreePhysicalMemorySize */ // throw_internal_error(env, "unimplemented in FreeBSD") return (128 * MB); +#elif defined(_AIX) + perfstat_memory_total_t memory_info; + if (-1 != perfstat_memory_total(NULL, &memory_info, sizeof(perfstat_memory_total_t), 1)) { + return (jlong)(memory_info.real_free * 4L * 1024L); + } + return -1; #else // solaris / linux jlong num_avail_physical_pages = sysconf(_SC_AVPHYS_PAGES); return (num_avail_physical_pages * page_size); @@ -333,7 +343,7 @@ Java_sun_management_OperatingSystemImpl_getFreePhysicalMemorySize } JNIEXPORT jlong JNICALL -Java_sun_management_OperatingSystemImpl_getTotalPhysicalMemorySize +Java_sun_management_OperatingSystemImpl_getTotalPhysicalMemorySize0 (JNIEnv *env, jobject mbean) { #ifdef _ALLBSD_SOURCE @@ -349,6 +359,12 @@ Java_sun_management_OperatingSystemImpl_getTotalPhysicalMemorySize return -1; } return result; +#elif defined(_AIX) + perfstat_memory_total_t memory_info; + if (-1 != perfstat_memory_total(NULL, &memory_info, sizeof(perfstat_memory_total_t), 1)) { + return (jlong)(memory_info.real_total * 4L * 1024L); + } + return -1; #else // solaris / linux jlong num_physical_pages = sysconf(_SC_PHYS_PAGES); return (num_physical_pages * page_size); @@ -358,7 +374,7 @@ Java_sun_management_OperatingSystemImpl_getTotalPhysicalMemorySize JNIEXPORT jlong JNICALL -Java_sun_management_OperatingSystemImpl_getOpenFileDescriptorCount +Java_sun_management_OperatingSystemImpl_getOpenFileDescriptorCount0 (JNIEnv *env, jobject mbean) { #ifdef __APPLE__ @@ -417,7 +433,16 @@ Java_sun_management_OperatingSystemImpl_getOpenFileDescriptorCount struct dirent* dentp; jlong fds = 0; - dirp = opendir("/proc/self/fd"); +#if defined(_AIX) +/* AIX does not understand '/proc/self' - it requires the real process ID */ +#define FD_DIR aix_fd_dir + char aix_fd_dir[32]; /* the pid has at most 19 digits */ + snprintf(aix_fd_dir, 32, "/proc/%d/fd", getpid()); +#else +#define FD_DIR "/proc/self/fd" +#endif + + dirp = opendir(FD_DIR); if (dirp == NULL) { throw_internal_error(env, "Unable to open directory /proc/self/fd"); return -1; @@ -438,7 +463,7 @@ Java_sun_management_OperatingSystemImpl_getOpenFileDescriptorCount } JNIEXPORT jlong JNICALL -Java_sun_management_OperatingSystemImpl_getMaxFileDescriptorCount +Java_sun_management_OperatingSystemImpl_getMaxFileDescriptorCount0 (JNIEnv *env, jobject mbean) { struct rlimit rlp; diff --git a/jdk/src/solaris/native/sun/management/SolarisOperatingSystem.c b/jdk/src/solaris/native/sun/management/SolarisOperatingSystem.c index a8136f1ac63..f89da99aa39 100644 --- a/jdk/src/solaris/native/sun/management/SolarisOperatingSystem.c +++ b/jdk/src/solaris/native/sun/management/SolarisOperatingSystem.c @@ -226,14 +226,14 @@ double get_process_load(void) { } JNIEXPORT jdouble JNICALL -Java_sun_management_OperatingSystemImpl_getSystemCpuLoad +Java_sun_management_OperatingSystemImpl_getSystemCpuLoad0 (JNIEnv *env, jobject dummy) { return get_cpu_load(-1); } JNIEXPORT jdouble JNICALL -Java_sun_management_OperatingSystemImpl_getProcessCpuLoad +Java_sun_management_OperatingSystemImpl_getProcessCpuLoad0 (JNIEnv *env, jobject dummy) { return get_process_load(); diff --git a/jdk/src/solaris/native/sun/net/portconfig.c b/jdk/src/solaris/native/sun/net/portconfig.c new file mode 100644 index 00000000000..56730f0f40a --- /dev/null +++ b/jdk/src/solaris/native/sun/net/portconfig.c @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +#include +#include +#include +#include + +#if defined(_ALLBSD_SOURCE) +#include +#endif + +#include "jni.h" +#include "net_util.h" +#include "sun_net_PortConfig.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct portrange { + int lower; + int higher; +}; + +static int getPortRange(struct portrange *range) +{ +#ifdef __linux__ + { + FILE *f; + int ret; + + f = fopen("/proc/sys/net/ipv4/ip_local_port_range", "r"); + if (f != NULL) { + ret = fscanf(f, "%d %d", &range->lower, &range->higher); + fclose(f); + return ret == 2 ? 0 : -1; + } + return -1; + } + +#elif defined(__solaris__) + { + range->higher = net_getParam("/dev/tcp", "tcp_largest_anon_port"); + range->lower = net_getParam("/dev/tcp", "tcp_smallest_anon_port"); + return 0; + } +#elif defined(_ALLBSD_SOURCE) + { + int ret; + size_t size = sizeof(range->lower); + ret = sysctlbyname( + "net.inet.ip.portrange.first", &range->lower, &size, 0, 0 + ); + if (ret == -1) { + return -1; + } + size = sizeof(range->higher); + ret = sysctlbyname( + "net.inet.ip.portrange.last", &range->higher, &size, 0, 0 + ); + return ret; + } +#else + return -1; +#endif +} + +/* + * Class: sun_net_PortConfig + * Method: getLower0 + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_sun_net_PortConfig_getLower0 + (JNIEnv *env, jclass clazz) +{ + struct portrange range; + if (getPortRange(&range) < 0) { + return -1; + } + return range.lower; +} + +/* + * Class: sun_net_PortConfig + * Method: getUpper0 + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_sun_net_PortConfig_getUpper0 + (JNIEnv *env, jclass clazz) +{ + struct portrange range; + if (getPortRange(&range) < 0) { + return -1; + } + return range.higher; +} + +#ifdef __cplusplus +} +#endif diff --git a/jdk/src/solaris/native/sun/net/spi/DefaultProxySelector.c b/jdk/src/solaris/native/sun/net/spi/DefaultProxySelector.c index 76b2e2dae42..e2ecd979072 100644 --- a/jdk/src/solaris/native/sun/net/spi/DefaultProxySelector.c +++ b/jdk/src/solaris/native/sun/net/spi/DefaultProxySelector.c @@ -38,6 +38,10 @@ #include #endif +#ifndef CHECK_NULL_RETURN +#define CHECK_NULL_RETURN(x, y) if ((x) == NULL) return y; +#endif + /** * These functions are used by the sun.net.spi.DefaultProxySelector class * to access some platform specific settings. @@ -114,18 +118,36 @@ static jclass isaddr_class; static jclass ptype_class; static jmethodID isaddr_createUnresolvedID; static jmethodID proxy_ctrID; -static jfieldID pr_no_proxyID; static jfieldID ptype_httpID; static jfieldID ptype_socksID; static void* gconf_client = NULL; - static int use_gproxyResolver = 0; static int use_gconf = 0; -#define CHECK_NULL(X) { if ((X) == NULL) fprintf (stderr,"JNI errror at line %d\n", __LINE__); } +static jobject createProxy(JNIEnv *env, jfieldID ptype_ID, + const char* phost, unsigned short pport) +{ + jobject jProxy = NULL; + jobject type_proxy = NULL; + type_proxy = (*env)->GetStaticObjectField(env, ptype_class, ptype_ID); + if (type_proxy) { + jstring jhost = NULL; + jhost = (*env)->NewStringUTF(env, phost); + if (jhost) { + jobject isa = NULL; + isa = (*env)->CallStaticObjectMethod(env, isaddr_class, + isaddr_createUnresolvedID, jhost, pport); + if (isa) { + jProxy = (*env)->NewObject(env, proxy_class, proxy_ctrID, + type_proxy, isa); + } + } + } + return jProxy; +} static int initGConf() { /** @@ -182,9 +204,8 @@ static jobject getProxyByGConf(JNIEnv *env, const char* cproto, int pport = 0; int use_proxy = 0; int use_same_proxy = 0; - jobject isa = NULL; jobject proxy = NULL; - jobject type_proxy = NULL; + jfieldID ptype_ID = ptype_httpID; // We only check manual proxy configurations mode = (*my_get_string_func)(gconf_client, "/system/proxy/mode", NULL); @@ -199,8 +220,6 @@ static jobject getProxyByGConf(JNIEnv *env, const char* cproto, phost = (*my_get_string_func)(gconf_client, "/system/http_proxy/host", NULL); pport = (*my_get_int_func)(gconf_client, "/system/http_proxy/port", NULL); use_proxy = (phost != NULL && pport != 0); - if (use_proxy) - type_proxy = (*env)->GetStaticObjectField(env, ptype_class, ptype_httpID); } if (!use_proxy) { @@ -214,8 +233,6 @@ static jobject getProxyByGConf(JNIEnv *env, const char* cproto, phost = (*my_get_string_func)(gconf_client, "/system/http_proxy/host", NULL); pport = (*my_get_int_func)(gconf_client, "/system/http_proxy/port", NULL); use_proxy = (phost != NULL && pport != 0); - if (use_proxy) - type_proxy = (*env)->GetStaticObjectField(env, ptype_class, ptype_httpID); } /** @@ -228,8 +245,6 @@ static jobject getProxyByGConf(JNIEnv *env, const char* cproto, phost = (*my_get_string_func)(gconf_client, "/system/proxy/secure_host", NULL); pport = (*my_get_int_func)(gconf_client, "/system/proxy/secure_port", NULL); use_proxy = (phost != NULL && pport != 0); - if (use_proxy) - type_proxy = (*env)->GetStaticObjectField(env, ptype_class, ptype_httpID); } /** @@ -242,8 +257,6 @@ static jobject getProxyByGConf(JNIEnv *env, const char* cproto, phost = (*my_get_string_func)(gconf_client, "/system/proxy/ftp_host", NULL); pport = (*my_get_int_func)(gconf_client, "/system/proxy/ftp_port", NULL); use_proxy = (phost != NULL && pport != 0); - if (use_proxy) - type_proxy = (*env)->GetStaticObjectField(env, ptype_class, ptype_httpID); } /** @@ -256,8 +269,6 @@ static jobject getProxyByGConf(JNIEnv *env, const char* cproto, phost = (*my_get_string_func)(gconf_client, "/system/proxy/gopher_host", NULL); pport = (*my_get_int_func)(gconf_client, "/system/proxy/gopher_port", NULL); use_proxy = (phost != NULL && pport != 0); - if (use_proxy) - type_proxy = (*env)->GetStaticObjectField(env, ptype_class, ptype_httpID); } /** @@ -271,7 +282,7 @@ static jobject getProxyByGConf(JNIEnv *env, const char* cproto, pport = (*my_get_int_func)(gconf_client, "/system/proxy/socks_port", NULL); use_proxy = (phost != NULL && pport != 0); if (use_proxy) - type_proxy = (*env)->GetStaticObjectField(env, ptype_class, ptype_socksID); + ptype_ID = ptype_socksID; } } } @@ -302,12 +313,8 @@ static jobject getProxyByGConf(JNIEnv *env, const char* cproto, s = strtok_r(NULL, ", ", tmpbuf); } } - if (use_proxy) { - CHECK_NULL(type_proxy); - jhost = (*env)->NewStringUTF(env, phost); - isa = (*env)->CallStaticObjectMethod(env, isaddr_class, isaddr_createUnresolvedID, jhost, pport); - proxy = (*env)->NewObject(env, proxy_class, proxy_ctrID, type_proxy, isa); - } + if (use_proxy) + proxy = createProxy(env, ptype_ID, phost, pport); } return proxy; @@ -375,7 +382,7 @@ static jobject getProxyByGProxyResolver(JNIEnv *env, const char* cproto, size_t hostLen = 0; char* uri = NULL; - jobject objProxy = NULL; + jobject jProxy = NULL; resolver = (*g_proxy_resolver_get_default)(); if (resolver == NULL) { @@ -407,7 +414,7 @@ static jobject getProxyByGProxyResolver(JNIEnv *env, const char* cproto, if (proxies) { if (!error) { int i; - for(i = 0; proxies[i] && !objProxy; i++) { + for(i = 0; proxies[i] && !jProxy; i++) { if (strcmp(proxies[i], "direct://")) { GSocketConnectable* conn = (*g_network_address_parse_uri)(proxies[i], 0, @@ -418,25 +425,11 @@ static jobject getProxyByGProxyResolver(JNIEnv *env, const char* cproto, phost = (*g_network_address_get_hostname)(conn); pport = (*g_network_address_get_port)(conn); if (phost && pport > 0) { - jobject type_proxy = NULL; - jstring jhost = NULL; - jobject isa = NULL; jfieldID ptype_ID = ptype_httpID; - if (!strncmp(proxies[i], "socks", 5)) { + if (!strncmp(proxies[i], "socks", 5)) ptype_ID = ptype_socksID; - } - type_proxy = (*env)->GetStaticObjectField(env, - ptype_class, ptype_ID); - CHECK_NULL(type_proxy); - jhost = (*env)->NewStringUTF(env, phost); - CHECK_NULL(jhost); - isa = (*env)->CallStaticObjectMethod(env, - isaddr_class, isaddr_createUnresolvedID, - jhost, pport); - CHECK_NULL(isa); - objProxy = (*env)->NewObject(env, proxy_class, - proxy_ctrID, type_proxy, isa); + jProxy = createProxy(env, ptype_ID, phost, pport); } } } @@ -445,33 +438,45 @@ static jobject getProxyByGProxyResolver(JNIEnv *env, const char* cproto, (*g_strfreev)(proxies); } - return objProxy; + return jProxy; } -static void initJavaClass(JNIEnv *env) { - jclass cls = NULL; - CHECK_NULL(cls = (*env)->FindClass(env,"java/net/Proxy")); - proxy_class = (*env)->NewGlobalRef(env, cls); - CHECK_NULL(cls = (*env)->FindClass(env,"java/net/Proxy$Type")); - ptype_class = (*env)->NewGlobalRef(env, cls); - CHECK_NULL(cls = (*env)->FindClass(env, "java/net/InetSocketAddress")); - isaddr_class = (*env)->NewGlobalRef(env, cls); +static int initJavaClass(JNIEnv *env) { + jclass proxy_cls = NULL; + jclass ptype_cls = NULL; + jclass isaddr_cls = NULL; + + // Proxy initialization + proxy_cls = (*env)->FindClass(env,"java/net/Proxy"); + CHECK_NULL_RETURN(proxy_cls, 0); + proxy_class = (*env)->NewGlobalRef(env, proxy_cls); + CHECK_NULL_RETURN(proxy_class, 0); proxy_ctrID = (*env)->GetMethodID(env, proxy_class, "", "(Ljava/net/Proxy$Type;Ljava/net/SocketAddress;)V"); - CHECK_NULL(proxy_ctrID); - pr_no_proxyID = (*env)->GetStaticFieldID(env, proxy_class, "NO_PROXY", - "Ljava/net/Proxy;"); - CHECK_NULL(pr_no_proxyID); + CHECK_NULL_RETURN(proxy_ctrID, 0); + + // Proxy$Type initialization + ptype_cls = (*env)->FindClass(env,"java/net/Proxy$Type"); + CHECK_NULL_RETURN(ptype_cls, 0); + ptype_class = (*env)->NewGlobalRef(env, ptype_cls); + CHECK_NULL_RETURN(ptype_class, 0); ptype_httpID = (*env)->GetStaticFieldID(env, ptype_class, "HTTP", - "Ljava/net/Proxy$Type;"); - CHECK_NULL(ptype_httpID); + "Ljava/net/Proxy$Type;"); + CHECK_NULL_RETURN(ptype_httpID, 0); ptype_socksID = (*env)->GetStaticFieldID(env, ptype_class, "SOCKS", - "Ljava/net/Proxy$Type;"); - CHECK_NULL(ptype_socksID); + "Ljava/net/Proxy$Type;"); + CHECK_NULL_RETURN(ptype_socksID, 0); + + // InetSocketAddress initialization + isaddr_cls = (*env)->FindClass(env, "java/net/InetSocketAddress"); + CHECK_NULL_RETURN(isaddr_cls, 0); + isaddr_class = (*env)->NewGlobalRef(env, isaddr_cls); + CHECK_NULL_RETURN(isaddr_class, 0); isaddr_createUnresolvedID = (*env)->GetStaticMethodID(env, isaddr_class, "createUnresolved", "(Ljava/lang/String;I)Ljava/net/InetSocketAddress;"); - CHECK_NULL(isaddr_createUnresolvedID); + + return isaddr_createUnresolvedID != NULL ? 1 : 0; } @@ -487,10 +492,10 @@ Java_sun_net_spi_DefaultProxySelector_init(JNIEnv *env, jclass clazz) { use_gconf = initGConf(); if (use_gproxyResolver || use_gconf) { - initJavaClass(env); - return JNI_TRUE; - } else - return JNI_FALSE; + if (initJavaClass(env)) + return JNI_TRUE; + } + return JNI_FALSE; } /* @@ -528,11 +533,6 @@ Java_sun_net_spi_DefaultProxySelector_getSystemProxy(JNIEnv *env, if (isProtoCopy == JNI_TRUE) (*env)->ReleaseStringUTFChars(env, proto, cproto); } - - if (proxy == NULL) { - CHECK_NULL(proxy = (*env)->GetStaticObjectField(env, proxy_class, - pr_no_proxyID)); - } return proxy; } diff --git a/jdk/src/solaris/native/sun/nio/ch/DatagramChannelImpl.c b/jdk/src/solaris/native/sun/nio/ch/DatagramChannelImpl.c index cd2f4927bdb..816270c9b8e 100644 --- a/jdk/src/solaris/native/sun/nio/ch/DatagramChannelImpl.c +++ b/jdk/src/solaris/native/sun/nio/ch/DatagramChannelImpl.c @@ -81,7 +81,7 @@ Java_sun_nio_ch_DatagramChannelImpl_disconnect0(JNIEnv *env, jobject this, rv = connect(fd, 0, 0); #endif -#if defined(__linux__) || defined(_ALLBSD_SOURCE) +#if defined(__linux__) || defined(_ALLBSD_SOURCE) || defined(_AIX) { int len; SOCKADDR sa; @@ -114,6 +114,14 @@ Java_sun_nio_ch_DatagramChannelImpl_disconnect0(JNIEnv *env, jobject this, #if defined(_ALLBSD_SOURCE) if (rv < 0 && errno == EADDRNOTAVAIL) rv = errno = 0; +#endif +#if defined(_AIX) + /* See W. Richard Stevens, "UNIX Network Programming, Volume 1", p. 254: + * 'Setting the address family to AF_UNSPEC might return EAFNOSUPPORT + * but that is acceptable. + */ + if (rv < 0 && errno == EAFNOSUPPORT) + rv = errno = 0; #endif } #endif diff --git a/jdk/src/solaris/native/sun/nio/ch/FileDispatcherImpl.c b/jdk/src/solaris/native/sun/nio/ch/FileDispatcherImpl.c index 25beacc3d5d..c9d20112479 100644 --- a/jdk/src/solaris/native/sun/nio/ch/FileDispatcherImpl.c +++ b/jdk/src/solaris/native/sun/nio/ch/FileDispatcherImpl.c @@ -147,6 +147,19 @@ Java_sun_nio_ch_FileDispatcherImpl_force0(JNIEnv *env, jobject this, if (md == JNI_FALSE) { result = fdatasync(fd); } else { +#ifdef _AIX + /* On AIX, calling fsync on a file descriptor that is opened only for + * reading results in an error ("EBADF: The FileDescriptor parameter is + * not a valid file descriptor open for writing."). + * However, at this point it is not possibly anymore to read the + * 'writable' attribute of the corresponding file channel so we have to + * use 'fcntl'. + */ + int getfl = fcntl(fd, F_GETFL); + if (getfl >= 0 && (getfl & O_ACCMODE) == O_RDONLY) { + return 0; + } +#endif result = fsync(fd); } return handle(env, result, "Force failed"); diff --git a/jdk/src/solaris/native/sun/nio/ch/IOUtil.c b/jdk/src/solaris/native/sun/nio/ch/IOUtil.c index 58ef02014b5..7dbf010fcac 100644 --- a/jdk/src/solaris/native/sun/nio/ch/IOUtil.c +++ b/jdk/src/solaris/native/sun/nio/ch/IOUtil.c @@ -145,7 +145,6 @@ Java_sun_nio_ch_IOUtil_iovMax(JNIEnv *env, jclass this) return (jint)iov_max; } - /* Declared in nio_util.h for use elsewhere in NIO */ jint diff --git a/jdk/src/solaris/native/sun/nio/ch/NativeThread.c b/jdk/src/solaris/native/sun/nio/ch/NativeThread.c index 79a91a068ac..5e2a78b7af3 100644 --- a/jdk/src/solaris/native/sun/nio/ch/NativeThread.c +++ b/jdk/src/solaris/native/sun/nio/ch/NativeThread.c @@ -32,27 +32,32 @@ #include "sun_nio_ch_NativeThread.h" #include "nio_util.h" - #ifdef __linux__ -#include -#include - -/* Also defined in src/solaris/native/java/net/linux_close.c */ -#define INTERRUPT_SIGNAL (__SIGRTMAX - 2) + #include + #include + /* Also defined in net/linux_close.c */ + #define INTERRUPT_SIGNAL (__SIGRTMAX - 2) +#elif __solaris__ + #include + #include + #define INTERRUPT_SIGNAL (SIGRTMAX - 2) +#elif _ALLBSD_SOURCE + #include + #include + /* Also defined in net/bsd_close.c */ + #define INTERRUPT_SIGNAL SIGIO +#else + #error "missing platform-specific definition here" +#endif static void nullHandler(int sig) { } -#endif - - JNIEXPORT void JNICALL Java_sun_nio_ch_NativeThread_init(JNIEnv *env, jclass cl) { -#ifdef __linux__ - /* Install the null handler for INTERRUPT_SIGNAL. This might overwrite the * handler previously installed by java/net/linux_close.c, but that's okay * since neither handler actually does anything. We install our own @@ -67,25 +72,27 @@ Java_sun_nio_ch_NativeThread_init(JNIEnv *env, jclass cl) sigemptyset(&sa.sa_mask); if (sigaction(INTERRUPT_SIGNAL, &sa, &osa) < 0) JNU_ThrowIOExceptionWithLastError(env, "sigaction"); - -#endif } JNIEXPORT jlong JNICALL Java_sun_nio_ch_NativeThread_current(JNIEnv *env, jclass cl) { -#ifdef __linux__ - return (long)pthread_self(); +#ifdef __solaris__ + return (jlong)thr_self(); #else - return -1; + return (jlong)pthread_self(); #endif } JNIEXPORT void JNICALL Java_sun_nio_ch_NativeThread_signal(JNIEnv *env, jclass cl, jlong thread) { -#ifdef __linux__ - if (pthread_kill((pthread_t)thread, INTERRUPT_SIGNAL)) - JNU_ThrowIOExceptionWithLastError(env, "Thread signal failed"); + int ret; +#ifdef __solaris__ + ret = thr_kill((thread_t)thread, INTERRUPT_SIGNAL); +#else + ret = pthread_kill((pthread_t)thread, INTERRUPT_SIGNAL); #endif + if (ret != 0) + JNU_ThrowIOExceptionWithLastError(env, "Thread signal failed"); } diff --git a/jdk/src/solaris/native/sun/nio/ch/Net.c b/jdk/src/solaris/native/sun/nio/ch/Net.c index 679a9d8d0da..4bb21396036 100644 --- a/jdk/src/solaris/native/sun/nio/ch/Net.c +++ b/jdk/src/solaris/native/sun/nio/ch/Net.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -23,6 +23,7 @@ * questions. */ +#include #include #include #include @@ -40,6 +41,9 @@ #include "nio.h" #include "sun_nio_ch_PollArrayWrapper.h" +#ifdef _AIX +#include +#endif /** * IP_MULTICAST_ALL supported since 2.6.31 but may not be available at @@ -47,56 +51,35 @@ */ #ifdef __linux__ #ifndef IP_MULTICAST_ALL - #define IP_MULTICAST_ALL 49 + #define IP_MULTICAST_ALL 49 #endif #endif -#ifdef _ALLBSD_SOURCE - -#ifndef IP_BLOCK_SOURCE - -#define IP_ADD_SOURCE_MEMBERSHIP 70 /* join a source-specific group */ -#define IP_DROP_SOURCE_MEMBERSHIP 71 /* drop a single source */ -#define IP_BLOCK_SOURCE 72 /* block a source */ -#define IP_UNBLOCK_SOURCE 73 /* unblock a source */ - -#endif /* IP_BLOCK_SOURCE */ - -#ifndef MCAST_BLOCK_SOURCE - -#define MCAST_JOIN_SOURCE_GROUP 82 /* join a source-specific group */ -#define MCAST_LEAVE_SOURCE_GROUP 83 /* leave a single source */ -#define MCAST_BLOCK_SOURCE 84 /* block a source */ -#define MCAST_UNBLOCK_SOURCE 85 /* unblock a source */ - -#endif /* MCAST_BLOCK_SOURCE */ - -#ifndef IPV6_ADD_MEMBERSHIP - -#define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP -#define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP - -#endif /* IPV6_ADD_MEMBERSHIP */ - -struct my_ip_mreq_source { - struct in_addr imr_multiaddr; - struct in_addr imr_interface; - struct in_addr imr_sourceaddr; -}; - -struct my_group_source_req { - uint32_t gsr_interface; /* interface index */ - struct sockaddr_storage gsr_group; /* group address */ - struct sockaddr_storage gsr_source; /* source address */ -}; - -#else /* _ALLBSD_SOURCE */ - -#define my_ip_mreq_source ip_mreq_source -#define my_group_source_req group_source_req - +/** + * IPV6_ADD_MEMBERSHIP/IPV6_DROP_MEMBERSHIP may not be defined on OSX and AIX + */ +#if defined(__APPLE__) || defined(_AIX) + #ifndef IPV6_ADD_MEMBERSHIP + #define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP + #define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP + #endif #endif +#if defined(_AIX) + #ifndef IP_BLOCK_SOURCE + #define IP_BLOCK_SOURCE 58 /* Block data from a given source to a given group */ + #define IP_UNBLOCK_SOURCE 59 /* Unblock data from a given source to a given group */ + #define IP_ADD_SOURCE_MEMBERSHIP 60 /* Join a source-specific group */ + #define IP_DROP_SOURCE_MEMBERSHIP 61 /* Leave a source-specific group */ + #endif + + #ifndef MCAST_BLOCK_SOURCE + #define MCAST_BLOCK_SOURCE 64 + #define MCAST_UNBLOCK_SOURCE 65 + #define MCAST_JOIN_SOURCE_GROUP 66 + #define MCAST_LEAVE_SOURCE_GROUP 67 + #endif +#endif /* _AIX */ #define COPY_INET6_ADDRESS(env, source, target) \ (*env)->GetByteArrayRegion(env, source, 0, 16, target) @@ -107,7 +90,7 @@ struct my_group_source_req { */ #ifdef AF_INET6 static void initGroupSourceReq(JNIEnv* env, jbyteArray group, jint index, - jbyteArray source, struct my_group_source_req* req) + jbyteArray source, struct group_source_req* req) { struct sockaddr_in6* sin6; @@ -123,6 +106,36 @@ static void initGroupSourceReq(JNIEnv* env, jbyteArray group, jint index, } #endif +#ifdef _AIX + +/* + * Checks whether or not "socket extensions for multicast source filters" is supported. + * Returns JNI_TRUE if it is supported, JNI_FALSE otherwise + */ +static jboolean isSourceFilterSupported(){ + static jboolean alreadyChecked = JNI_FALSE; + static jboolean result = JNI_TRUE; + if (alreadyChecked != JNI_TRUE){ + struct utsname uts; + memset(&uts, 0, sizeof(uts)); + strcpy(uts.sysname, "?"); + const int utsRes = uname(&uts); + int major = -1; + int minor = -1; + major = atoi(uts.version); + minor = atoi(uts.release); + if (strcmp(uts.sysname, "AIX") == 0) { + if (major < 6 || (major == 6 && minor < 1)) {// unsupported on aix < 6.1 + result = JNI_FALSE; + } + } + alreadyChecked = JNI_TRUE; + } + return result; +} + +#endif /* _AIX */ + JNIEXPORT void JNICALL Java_sun_nio_ch_Net_initIDs(JNIEnv *env, jclass clazz) { @@ -143,7 +156,7 @@ Java_sun_nio_ch_Net_isExclusiveBindAvailable(JNIEnv *env, jclass clazz) { JNIEXPORT jboolean JNICALL Java_sun_nio_ch_Net_canIPv6SocketJoinIPv4Group0(JNIEnv* env, jclass cl) { -#ifdef MACOSX +#if defined(__APPLE__) || defined(_AIX) /* for now IPv6 sockets cannot join IPv4 multicast groups */ return JNI_FALSE; #else @@ -460,7 +473,7 @@ Java_sun_nio_ch_Net_joinOrDrop4(JNIEnv *env, jobject this, jboolean join, jobjec jint group, jint interf, jint source) { struct ip_mreq mreq; - struct my_ip_mreq_source mreq_source; + struct ip_mreq_source mreq_source; int opt, n, optlen; void* optval; @@ -471,22 +484,25 @@ Java_sun_nio_ch_Net_joinOrDrop4(JNIEnv *env, jobject this, jboolean join, jobjec optval = (void*)&mreq; optlen = sizeof(mreq); } else { -#ifdef MACOSX - /* no IPv4 include-mode filtering for now */ - return IOS_UNAVAILABLE; -#else + +#ifdef _AIX + /* check AIX for support of source filtering */ + if (isSourceFilterSupported() != JNI_TRUE){ + return IOS_UNAVAILABLE; + } +#endif + mreq_source.imr_multiaddr.s_addr = htonl(group); mreq_source.imr_sourceaddr.s_addr = htonl(source); mreq_source.imr_interface.s_addr = htonl(interf); opt = (join) ? IP_ADD_SOURCE_MEMBERSHIP : IP_DROP_SOURCE_MEMBERSHIP; optval = (void*)&mreq_source; optlen = sizeof(mreq_source); -#endif } n = setsockopt(fdval(env,fdo), IPPROTO_IP, opt, optval, optlen); if (n < 0) { - if (join && (errno == ENOPROTOOPT)) + if (join && (errno == ENOPROTOOPT || errno == EOPNOTSUPP)) return IOS_UNAVAILABLE; handleSocketError(env, errno); } @@ -497,14 +513,21 @@ JNIEXPORT jint JNICALL Java_sun_nio_ch_Net_blockOrUnblock4(JNIEnv *env, jobject this, jboolean block, jobject fdo, jint group, jint interf, jint source) { -#ifdef MACOSX +#ifdef __APPLE__ /* no IPv4 exclude-mode filtering for now */ return IOS_UNAVAILABLE; #else - struct my_ip_mreq_source mreq_source; + struct ip_mreq_source mreq_source; int n; int opt = (block) ? IP_BLOCK_SOURCE : IP_UNBLOCK_SOURCE; +#ifdef _AIX + /* check AIX for support of source filtering */ + if (isSourceFilterSupported() != JNI_TRUE){ + return IOS_UNAVAILABLE; + } +#endif + mreq_source.imr_multiaddr.s_addr = htonl(group); mreq_source.imr_sourceaddr.s_addr = htonl(source); mreq_source.imr_interface.s_addr = htonl(interf); @@ -512,7 +535,7 @@ Java_sun_nio_ch_Net_blockOrUnblock4(JNIEnv *env, jobject this, jboolean block, j n = setsockopt(fdval(env,fdo), IPPROTO_IP, opt, (void*)&mreq_source, sizeof(mreq_source)); if (n < 0) { - if (block && (errno == ENOPROTOOPT)) + if (block && (errno == ENOPROTOOPT || errno == EOPNOTSUPP)) return IOS_UNAVAILABLE; handleSocketError(env, errno); } @@ -526,7 +549,7 @@ Java_sun_nio_ch_Net_joinOrDrop6(JNIEnv *env, jobject this, jboolean join, jobjec { #ifdef AF_INET6 struct ipv6_mreq mreq6; - struct my_group_source_req req; + struct group_source_req req; int opt, n, optlen; void* optval; @@ -537,7 +560,7 @@ Java_sun_nio_ch_Net_joinOrDrop6(JNIEnv *env, jobject this, jboolean join, jobjec optval = (void*)&mreq6; optlen = sizeof(mreq6); } else { -#ifdef MACOSX +#ifdef __APPLE__ /* no IPv6 include-mode filtering for now */ return IOS_UNAVAILABLE; #else @@ -550,7 +573,7 @@ Java_sun_nio_ch_Net_joinOrDrop6(JNIEnv *env, jobject this, jboolean join, jobjec n = setsockopt(fdval(env,fdo), IPPROTO_IPV6, opt, optval, optlen); if (n < 0) { - if (join && (errno == ENOPROTOOPT)) + if (join && (errno == ENOPROTOOPT || errno == EOPNOTSUPP)) return IOS_UNAVAILABLE; handleSocketError(env, errno); } @@ -566,11 +589,11 @@ Java_sun_nio_ch_Net_blockOrUnblock6(JNIEnv *env, jobject this, jboolean block, j jbyteArray group, jint index, jbyteArray source) { #ifdef AF_INET6 - #ifdef MACOSX + #ifdef __APPLE__ /* no IPv6 exclude-mode filtering for now */ return IOS_UNAVAILABLE; #else - struct my_group_source_req req; + struct group_source_req req; int n; int opt = (block) ? MCAST_BLOCK_SOURCE : MCAST_UNBLOCK_SOURCE; @@ -579,7 +602,7 @@ Java_sun_nio_ch_Net_blockOrUnblock6(JNIEnv *env, jobject this, jboolean block, j n = setsockopt(fdval(env,fdo), IPPROTO_IPV6, opt, (void*)&req, sizeof(req)); if (n < 0) { - if (block && (errno == ENOPROTOOPT)) + if (block && (errno == ENOPROTOOPT || errno == EOPNOTSUPP)) return IOS_UNAVAILABLE; handleSocketError(env, errno); } @@ -679,6 +702,42 @@ Java_sun_nio_ch_Net_poll(JNIEnv* env, jclass this, jobject fdo, jint events, jlo } } +JNIEXPORT jshort JNICALL +Java_sun_nio_ch_Net_pollinValue(JNIEnv *env, jclass this) +{ + return (jshort)POLLIN; +} + +JNIEXPORT jshort JNICALL +Java_sun_nio_ch_Net_polloutValue(JNIEnv *env, jclass this) +{ + return (jshort)POLLOUT; +} + +JNIEXPORT jshort JNICALL +Java_sun_nio_ch_Net_pollerrValue(JNIEnv *env, jclass this) +{ + return (jshort)POLLERR; +} + +JNIEXPORT jshort JNICALL +Java_sun_nio_ch_Net_pollhupValue(JNIEnv *env, jclass this) +{ + return (jshort)POLLHUP; +} + +JNIEXPORT jshort JNICALL +Java_sun_nio_ch_Net_pollnvalValue(JNIEnv *env, jclass this) +{ + return (jshort)POLLNVAL; +} + +JNIEXPORT jshort JNICALL +Java_sun_nio_ch_Net_pollconnValue(JNIEnv *env, jclass this) +{ + return (jshort)POLLOUT; +} + /* Declared in nio_util.h */ diff --git a/jdk/src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c b/jdk/src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c index 8f408951e77..12f399d8512 100644 --- a/jdk/src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c +++ b/jdk/src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c @@ -42,7 +42,7 @@ #include #endif -#ifdef __linux__ +#if defined(__linux__) || defined(_AIX) #include #endif @@ -294,7 +294,13 @@ Java_sun_nio_fs_UnixNativeDispatcher_strerror(JNIEnv* env, jclass this, jint err jsize len; jbyteArray bytes; +#ifdef _AIX + /* strerror() is not thread-safe on AIX so we have to use strerror_r() */ + char buffer[256]; + msg = (strerror_r((int)error, buffer, 256) == 0) ? buffer : "Error while calling strerror_r"; +#else msg = strerror((int)error); +#endif len = strlen(msg); bytes = (*env)->NewByteArray(env, len); if (bytes != NULL) { @@ -674,6 +680,15 @@ Java_sun_nio_fs_UnixNativeDispatcher_readdir(JNIEnv* env, jclass this, jlong val /* EINTR not listed as a possible error */ /* TDB: reentrant version probably not required here */ res = readdir64_r(dirp, ptr, &result); + +#ifdef _AIX + /* On AIX, readdir_r() returns EBADF (i.e. '9') and sets 'result' to NULL for the */ + /* directory stream end. Otherwise, 'errno' will contain the error code. */ + if (res != 0) { + res = (result == NULL && res == EBADF) ? 0 : errno; + } +#endif + if (res != 0) { throwUnixException(env, res); return NULL; @@ -877,6 +892,18 @@ Java_sun_nio_fs_UnixNativeDispatcher_statvfs0(JNIEnv* env, jclass this, if (err == -1) { throwUnixException(env, errno); } else { +#ifdef _AIX + /* AIX returns ULONG_MAX in buf.f_blocks for the /proc file system. */ + /* This is too big for a Java signed long and fools various tests. */ + if (buf.f_blocks == ULONG_MAX) { + buf.f_blocks = 0; + } + /* The number of free or available blocks can never exceed the total number of blocks */ + if (buf.f_blocks == 0) { + buf.f_bfree = 0; + buf.f_bavail = 0; + } +#endif (*env)->SetLongField(env, attrs, attrs_f_frsize, long_to_jlong(buf.f_frsize)); (*env)->SetLongField(env, attrs, attrs_f_blocks, long_to_jlong(buf.f_blocks)); (*env)->SetLongField(env, attrs, attrs_f_bfree, long_to_jlong(buf.f_bfree)); diff --git a/jdk/src/solaris/native/sun/security/pkcs11/j2secmod_md.c b/jdk/src/solaris/native/sun/security/pkcs11/j2secmod_md.c index f509c42b559..8b3a62bfdc6 100644 --- a/jdk/src/solaris/native/sun/security/pkcs11/j2secmod_md.c +++ b/jdk/src/solaris/native/sun/security/pkcs11/j2secmod_md.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -50,7 +50,11 @@ JNIEXPORT jlong JNICALL Java_sun_security_pkcs11_Secmod_nssGetLibraryHandle { const char *libName = (*env)->GetStringUTFChars(env, jLibName, NULL); // look up existing handle only, do not load +#if defined(AIX) + void *hModule = dlopen(libName, RTLD_LAZY); +#else void *hModule = dlopen(libName, RTLD_NOLOAD); +#endif dprintf2("-handle for %s: %u\n", libName, hModule); (*env)->ReleaseStringUTFChars(env, jLibName, libName); return ptr_to_jlong(hModule); diff --git a/jdk/src/windows/bin/java_md.c b/jdk/src/windows/bin/java_md.c index 4078ecc754b..c6a525f101d 100644 --- a/jdk/src/windows/bin/java_md.c +++ b/jdk/src/windows/bin/java_md.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -179,7 +179,7 @@ CreateExecutionEnvironment(int *pargc, char ***pargv, int wanted = running; char** argv = *pargv; - for (i = 0; i < *pargc ; i++) { + for (i = 1; i < *pargc ; i++) { if (JLI_StrCmp(argv[i], "-J-d64") == 0 || JLI_StrCmp(argv[i], "-d64") == 0) { wanted = 64; continue; @@ -188,6 +188,11 @@ CreateExecutionEnvironment(int *pargc, char ***pargv, wanted = 32; continue; } + + if (IsJavaArgs() && argv[i][0] != '-') + continue; + if (argv[i][0] != '-') + break; } if (running != wanted) { JLI_ReportErrorMessage(JRE_ERROR2, wanted); @@ -1470,7 +1475,7 @@ CreateApplicationArgs(JNIEnv *env, char **strv, int argc) // expand the arguments that require expansion, the java method will strip // out the indicator character. - inArray = NewPlatformStringArray(env, nargv, argc); + NULL_CHECK0(inArray = NewPlatformStringArray(env, nargv, argc)); outArray = (*env)->CallStaticObjectMethod(env, cls, mid, inArray); for (i = 0; i < argc; i++) { JLI_MemFree(nargv[i]); diff --git a/jdk/src/windows/classes/sun/awt/Win32GraphicsDevice.java b/jdk/src/windows/classes/sun/awt/Win32GraphicsDevice.java index a38068514c6..d7cfc58e1e8 100644 --- a/jdk/src/windows/classes/sun/awt/Win32GraphicsDevice.java +++ b/jdk/src/windows/classes/sun/awt/Win32GraphicsDevice.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, 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,7 +88,7 @@ public class Win32GraphicsDevice extends GraphicsDevice implements // is run as an NT service. To prevent the loading of ddraw.dll // completely, sun.awt.nopixfmt should be set as well. Apps which use // OpenGL w/ Java probably don't want to set this. - String nopixfmt = (String)java.security.AccessController.doPrivileged( + String nopixfmt = java.security.AccessController.doPrivileged( new sun.security.action.GetPropertyAction("sun.awt.nopixfmt")); pfDisabled = (nopixfmt != null); initIDs(); diff --git a/jdk/src/windows/classes/sun/awt/windows/WPathGraphics.java b/jdk/src/windows/classes/sun/awt/windows/WPathGraphics.java index 282d84563e6..8e440646404 100644 --- a/jdk/src/windows/classes/sun/awt/windows/WPathGraphics.java +++ b/jdk/src/windows/classes/sun/awt/windows/WPathGraphics.java @@ -94,7 +94,7 @@ final class WPathGraphics extends PathGraphics { private static boolean preferGDITextLayout = false; static { String textLayoutStr = - (String)java.security.AccessController.doPrivileged( + java.security.AccessController.doPrivileged( new sun.security.action.GetPropertyAction( "sun.java2d.print.enableGDITextLayout")); diff --git a/jdk/src/windows/classes/sun/awt/windows/WToolkit.java b/jdk/src/windows/classes/sun/awt/windows/WToolkit.java index 5bc140ebccb..6086cd45eba 100644 --- a/jdk/src/windows/classes/sun/awt/windows/WToolkit.java +++ b/jdk/src/windows/classes/sun/awt/windows/WToolkit.java @@ -37,6 +37,7 @@ import java.beans.PropertyChangeListener; import java.security.AccessController; import java.security.PrivilegedAction; import sun.awt.AWTAutoShutdown; +import sun.awt.AWTPermissions; import sun.awt.LightweightFrame; import sun.awt.SunToolkit; import sun.awt.Win32GraphicsDevice; @@ -65,7 +66,6 @@ import sun.font.FontManagerFactory; import sun.font.SunFontManager; import sun.misc.PerformanceLogger; import sun.util.logging.PlatformLogger; -import sun.security.util.SecurityConstants; public final class WToolkit extends SunToolkit implements Runnable { @@ -735,7 +735,7 @@ public final class WToolkit extends SunToolkit implements Runnable { public Clipboard getSystemClipboard() { SecurityManager security = System.getSecurityManager(); if (security != null) { - security.checkPermission(SecurityConstants.AWT.ACCESS_CLIPBOARD_PERMISSION); + security.checkPermission(AWTPermissions.ACCESS_CLIPBOARD_PERMISSION); } synchronized (this) { if (clipboard == null) { diff --git a/jdk/src/windows/classes/sun/io/Win32ErrorMode.java b/jdk/src/windows/classes/sun/io/Win32ErrorMode.java index d11a63b1096..8ec417fd6e2 100644 --- a/jdk/src/windows/classes/sun/io/Win32ErrorMode.java +++ b/jdk/src/windows/classes/sun/io/Win32ErrorMode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 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 @@ -67,7 +67,7 @@ public class Win32ErrorMode { */ public static void initialize() { if (!sun.misc.VM.isBooted()) { - String s = (String) System.getProperty("sun.io.allowCriticalErrorMessageBox"); + String s = System.getProperty("sun.io.allowCriticalErrorMessageBox"); if (s == null || s.equals(Boolean.FALSE.toString())) { long mode = setErrorMode(0); mode |= SEM_FAILCRITICALERRORS; diff --git a/jdk/src/windows/classes/sun/java2d/d3d/D3DBufImgOps.java b/jdk/src/windows/classes/sun/java2d/d3d/D3DBufImgOps.java index c2dee96aaef..890bb87d66b 100644 --- a/jdk/src/windows/classes/sun/java2d/d3d/D3DBufImgOps.java +++ b/jdk/src/windows/classes/sun/java2d/d3d/D3DBufImgOps.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -78,12 +78,12 @@ class D3DBufImgOps extends BufferedBufImgOps { } SurfaceData srcData = - dstData.getSourceSurfaceData(img, sg.TRANSFORM_ISIDENT, + dstData.getSourceSurfaceData(img, SunGraphics2D.TRANSFORM_ISIDENT, CompositeType.SrcOver, null); if (!(srcData instanceof D3DSurfaceData)) { // REMIND: this hack tries to ensure that we have a cached texture srcData = - dstData.getSourceSurfaceData(img, sg.TRANSFORM_ISIDENT, + dstData.getSourceSurfaceData(img, SunGraphics2D.TRANSFORM_ISIDENT, CompositeType.SrcOver, null); if (!(srcData instanceof D3DSurfaceData)) { return false; diff --git a/jdk/src/windows/classes/sun/java2d/d3d/D3DDrawImage.java b/jdk/src/windows/classes/sun/java2d/d3d/D3DDrawImage.java index 8bfac53732b..f814dc2f613 100644 --- a/jdk/src/windows/classes/sun/java2d/d3d/D3DDrawImage.java +++ b/jdk/src/windows/classes/sun/java2d/d3d/D3DDrawImage.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -53,7 +53,7 @@ public class D3DDrawImage extends DrawImage { SurfaceData dstData = sg.surfaceData; SurfaceData srcData = dstData.getSourceSurfaceData(img, - sg.TRANSFORM_GENERIC, + SunGraphics2D.TRANSFORM_GENERIC, sg.imageComp, bgColor); diff --git a/jdk/src/windows/classes/sun/java2d/d3d/D3DGraphicsDevice.java b/jdk/src/windows/classes/sun/java2d/d3d/D3DGraphicsDevice.java index 2012b19e700..bf6134648c3 100644 --- a/jdk/src/windows/classes/sun/java2d/d3d/D3DGraphicsDevice.java +++ b/jdk/src/windows/classes/sun/java2d/d3d/D3DGraphicsDevice.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -235,10 +235,12 @@ public class D3DGraphicsDevice extends Win32GraphicsDevice { */ private static class D3DFSWindowAdapter extends WindowAdapter { @Override + @SuppressWarnings("static") public void windowDeactivated(WindowEvent e) { D3DRenderQueue.getInstance().restoreDevices(); } @Override + @SuppressWarnings("static") public void windowActivated(WindowEvent e) { D3DRenderQueue.getInstance().restoreDevices(); } diff --git a/jdk/src/windows/classes/sun/java2d/d3d/D3DPaints.java b/jdk/src/windows/classes/sun/java2d/d3d/D3DPaints.java index 53e59762c23..b328ce3a083 100644 --- a/jdk/src/windows/classes/sun/java2d/d3d/D3DPaints.java +++ b/jdk/src/windows/classes/sun/java2d/d3d/D3DPaints.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -132,14 +132,14 @@ abstract class D3DPaints { } SurfaceData srcData = - dstData.getSourceSurfaceData(bi, sg2d.TRANSFORM_ISIDENT, + dstData.getSourceSurfaceData(bi, SunGraphics2D.TRANSFORM_ISIDENT, CompositeType.SrcOver, null); if (!(srcData instanceof D3DSurfaceData)) { // REMIND: this is a hack that attempts to cache the system // memory image from the TexturePaint instance into a // D3D texture... srcData = - dstData.getSourceSurfaceData(bi, sg2d.TRANSFORM_ISIDENT, + dstData.getSourceSurfaceData(bi, SunGraphics2D.TRANSFORM_ISIDENT, CompositeType.SrcOver, null); if (!(srcData instanceof D3DSurfaceData)) { return false; diff --git a/jdk/src/windows/classes/sun/java2d/d3d/D3DSurfaceData.java b/jdk/src/windows/classes/sun/java2d/d3d/D3DSurfaceData.java index d37db9e925b..ffab9092a5a 100644 --- a/jdk/src/windows/classes/sun/java2d/d3d/D3DSurfaceData.java +++ b/jdk/src/windows/classes/sun/java2d/d3d/D3DSurfaceData.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -542,7 +542,7 @@ public class D3DSurfaceData extends SurfaceData implements AccelSurface { // REMIND: the D3D pipeline doesn't support XOR!, more // fixes will be needed below. For now we disable D3D rendering // for the surface which had any XOR rendering done to. - if (sg2d.compositeState >= sg2d.COMP_XOR) { + if (sg2d.compositeState >= SunGraphics2D.COMP_XOR) { super.validatePipe(sg2d); sg2d.imagepipe = d3dImagePipe; disableAccelerationForSurface(); @@ -557,18 +557,18 @@ public class D3DSurfaceData extends SurfaceData implements AccelSurface { // by the CompositeType.SrcNoEa (any color) test below.) if (/* CompositeType.SrcNoEa (any color) */ - (sg2d.compositeState <= sg2d.COMP_ISCOPY && - sg2d.paintState <= sg2d.PAINT_ALPHACOLOR) || + (sg2d.compositeState <= SunGraphics2D.COMP_ISCOPY && + sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR) || /* CompositeType.SrcOver (any color) */ - (sg2d.compositeState == sg2d.COMP_ALPHA && - sg2d.paintState <= sg2d.PAINT_ALPHACOLOR && + (sg2d.compositeState == SunGraphics2D.COMP_ALPHA && + sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR && (((AlphaComposite)sg2d.composite).getRule() == AlphaComposite.SRC_OVER)) || /* CompositeType.Xor (any color) */ - (sg2d.compositeState == sg2d.COMP_XOR && - sg2d.paintState <= sg2d.PAINT_ALPHACOLOR)) + (sg2d.compositeState == SunGraphics2D.COMP_XOR && + sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR)) { textpipe = d3dTextPipe; } else { @@ -583,12 +583,12 @@ public class D3DSurfaceData extends SurfaceData implements AccelSurface { D3DRenderer nonTxPipe = null; if (sg2d.antialiasHint != SunHints.INTVAL_ANTIALIAS_ON) { - if (sg2d.paintState <= sg2d.PAINT_ALPHACOLOR) { - if (sg2d.compositeState <= sg2d.COMP_XOR) { + if (sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR) { + if (sg2d.compositeState <= SunGraphics2D.COMP_XOR) { txPipe = d3dTxRenderPipe; nonTxPipe = d3dRenderPipe; } - } else if (sg2d.compositeState <= sg2d.COMP_ALPHA) { + } else if (sg2d.compositeState <= SunGraphics2D.COMP_ALPHA) { if (D3DPaints.isValid(sg2d)) { txPipe = d3dTxRenderPipe; nonTxPipe = d3dRenderPipe; @@ -596,7 +596,7 @@ public class D3DSurfaceData extends SurfaceData implements AccelSurface { // custom paints handled by super.validatePipe() below } } else { - if (sg2d.paintState <= sg2d.PAINT_ALPHACOLOR) { + if (sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR) { if (graphicsDevice.isCapPresent(CAPS_AA_SHADER) && (sg2d.imageComp == CompositeType.SrcOverNoEa || sg2d.imageComp == CompositeType.SrcOver)) @@ -613,7 +613,7 @@ public class D3DSurfaceData extends SurfaceData implements AccelSurface { sg2d.drawpipe = aaConverter; sg2d.fillpipe = aaConverter; sg2d.shapepipe = aaConverter; - } else if (sg2d.compositeState == sg2d.COMP_XOR) { + } else if (sg2d.compositeState == SunGraphics2D.COMP_XOR) { // install the solid pipes when AA and XOR are both enabled txPipe = d3dTxRenderPipe; nonTxPipe = d3dRenderPipe; @@ -623,10 +623,10 @@ public class D3DSurfaceData extends SurfaceData implements AccelSurface { } if (txPipe != null) { - if (sg2d.transformState >= sg2d.TRANSFORM_TRANSLATESCALE) { + if (sg2d.transformState >= SunGraphics2D.TRANSFORM_TRANSLATESCALE) { sg2d.drawpipe = txPipe; sg2d.fillpipe = txPipe; - } else if (sg2d.strokeState != sg2d.STROKE_THIN) { + } else if (sg2d.strokeState != SunGraphics2D.STROKE_THIN) { sg2d.drawpipe = txPipe; sg2d.fillpipe = nonTxPipe; } else { @@ -653,7 +653,7 @@ public class D3DSurfaceData extends SurfaceData implements AccelSurface { @Override protected MaskFill getMaskFill(SunGraphics2D sg2d) { - if (sg2d.paintState > sg2d.PAINT_ALPHACOLOR) { + if (sg2d.paintState > SunGraphics2D.PAINT_ALPHACOLOR) { /* * We can only accelerate non-Color MaskFill operations if * all of the following conditions hold true: @@ -678,8 +678,8 @@ public class D3DSurfaceData extends SurfaceData implements AccelSurface { public boolean copyArea(SunGraphics2D sg2d, int x, int y, int w, int h, int dx, int dy) { - if (sg2d.transformState < sg2d.TRANSFORM_TRANSLATESCALE && - sg2d.compositeState < sg2d.COMP_XOR) + if (sg2d.transformState < SunGraphics2D.TRANSFORM_TRANSLATESCALE && + sg2d.compositeState < SunGraphics2D.COMP_XOR) { x += sg2d.transX; y += sg2d.transY; @@ -738,7 +738,7 @@ public class D3DSurfaceData extends SurfaceData implements AccelSurface { D3DRenderQueue rq = D3DRenderQueue.getInstance(); // swapBuffers can be called from the toolkit thread by swing, we // should detect this and prevent the deadlocks - if (rq.isRenderQueueThread()) { + if (D3DRenderQueue.isRenderQueueThread()) { if (!rq.tryLock()) { // if we could not obtain the lock, repaint the area // that was supposed to be swapped, and no-op this swap diff --git a/jdk/src/windows/classes/sun/java2d/d3d/D3DSurfaceDataProxy.java b/jdk/src/windows/classes/sun/java2d/d3d/D3DSurfaceDataProxy.java index 46b1446c975..66e98882a19 100644 --- a/jdk/src/windows/classes/sun/java2d/d3d/D3DSurfaceDataProxy.java +++ b/jdk/src/windows/classes/sun/java2d/d3d/D3DSurfaceDataProxy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 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 @@ -72,7 +72,7 @@ public class D3DSurfaceDataProxy extends SurfaceDataProxy { try { cachedData = d3dgc.createManagedSurface(w, h, transparency); } catch (InvalidPipeException e) { - if (!d3dgc.getD3DDevice().isD3DAvailable()) { + if (!D3DGraphicsDevice.isD3DAvailable()) { invalidate(); flush(); return null; diff --git a/jdk/src/windows/classes/sun/java2d/windows/GDIRenderer.java b/jdk/src/windows/classes/sun/java2d/windows/GDIRenderer.java index bb3e2725700..5971c09cdd6 100644 --- a/jdk/src/windows/classes/sun/java2d/windows/GDIRenderer.java +++ b/jdk/src/windows/classes/sun/java2d/windows/GDIRenderer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2006, 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 @@ -264,7 +264,7 @@ public class GDIRenderer implements Path2D.Float p2df; int transX; int transY; - if (sg2d.transformState <= sg2d.TRANSFORM_INT_TRANSLATE) { + if (sg2d.transformState <= SunGraphics2D.TRANSFORM_INT_TRANSLATE) { if (s instanceof Path2D.Float) { p2df = (Path2D.Float)s; } else { @@ -308,9 +308,9 @@ public class GDIRenderer implements } public void draw(SunGraphics2D sg2d, Shape s) { - if (sg2d.strokeState == sg2d.STROKE_THIN) { + if (sg2d.strokeState == SunGraphics2D.STROKE_THIN) { doShape(sg2d, s, false); - } else if (sg2d.strokeState < sg2d.STROKE_CUSTOM) { + } else if (sg2d.strokeState < SunGraphics2D.STROKE_CUSTOM) { ShapeSpanIterator si = LoopPipe.getStrokeSpans(sg2d, s); try { doFillSpans(sg2d, si); diff --git a/jdk/src/windows/classes/sun/java2d/windows/GDIWindowSurfaceData.java b/jdk/src/windows/classes/sun/java2d/windows/GDIWindowSurfaceData.java index deaf9c60e0d..49d9261bbd3 100644 --- a/jdk/src/windows/classes/sun/java2d/windows/GDIWindowSurfaceData.java +++ b/jdk/src/windows/classes/sun/java2d/windows/GDIWindowSurfaceData.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2008, 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 @@ -153,11 +153,11 @@ public class GDIWindowSurfaceData extends SurfaceData { public void validatePipe(SunGraphics2D sg2d) { if (sg2d.antialiasHint != SunHints.INTVAL_ANTIALIAS_ON && - sg2d.paintState <= sg2d.PAINT_ALPHACOLOR && - (sg2d.compositeState <= sg2d.COMP_ISCOPY || - sg2d.compositeState == sg2d.COMP_XOR)) + sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR && + (sg2d.compositeState <= SunGraphics2D.COMP_ISCOPY || + sg2d.compositeState == SunGraphics2D.COMP_XOR)) { - if (sg2d.clipState == sg2d.CLIP_SHAPE) { + if (sg2d.clipState == SunGraphics2D.CLIP_SHAPE) { // Do this to init textpipe correctly; we will override the // other non-text pipes below // REMIND: we should clean this up eventually instead of @@ -194,10 +194,10 @@ public class GDIWindowSurfaceData extends SurfaceData { } } sg2d.imagepipe = imagepipe; - if (sg2d.transformState >= sg2d.TRANSFORM_TRANSLATESCALE) { + if (sg2d.transformState >= SunGraphics2D.TRANSFORM_TRANSLATESCALE) { sg2d.drawpipe = gdiTxPipe; sg2d.fillpipe = gdiTxPipe; - } else if (sg2d.strokeState != sg2d.STROKE_THIN){ + } else if (sg2d.strokeState != SunGraphics2D.STROKE_THIN){ sg2d.drawpipe = gdiTxPipe; sg2d.fillpipe = gdiPipe; } else { @@ -220,8 +220,8 @@ public class GDIWindowSurfaceData extends SurfaceData { } public RenderLoops getRenderLoops(SunGraphics2D sg2d) { - if (sg2d.paintState <= sg2d.PAINT_ALPHACOLOR && - sg2d.compositeState <= sg2d.COMP_ISCOPY) + if (sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR && + sg2d.compositeState <= SunGraphics2D.COMP_ISCOPY) { return solidloops; } @@ -295,8 +295,8 @@ public class GDIWindowSurfaceData extends SurfaceData { int x, int y, int w, int h, int dx, int dy) { CompositeType comptype = sg2d.imageComp; - if (sg2d.transformState < sg2d.TRANSFORM_TRANSLATESCALE && - sg2d.clipState != sg2d.CLIP_SHAPE && + if (sg2d.transformState < SunGraphics2D.TRANSFORM_TRANSLATESCALE && + sg2d.clipState != SunGraphics2D.CLIP_SHAPE && (CompositeType.SrcOverNoEa.equals(comptype) || CompositeType.SrcNoEa.equals(comptype))) { diff --git a/jdk/src/windows/classes/sun/management/OperatingSystemImpl.java b/jdk/src/windows/classes/sun/management/OperatingSystemImpl.java index ca766448177..f24ef7d9653 100644 --- a/jdk/src/windows/classes/sun/management/OperatingSystemImpl.java +++ b/jdk/src/windows/classes/sun/management/OperatingSystemImpl.java @@ -50,18 +50,48 @@ class OperatingSystemImpl extends BaseOperatingSystemImpl return getCommittedVirtualMemorySize0(); } } - private native long getCommittedVirtualMemorySize0(); - public native long getTotalSwapSpaceSize(); - public native long getFreeSwapSpaceSize(); - public native long getProcessCpuTime(); - public native long getFreePhysicalMemorySize(); - public native long getTotalPhysicalMemorySize(); - public native double getSystemCpuLoad(); - public native double getProcessCpuLoad(); + public long getTotalSwapSpaceSize() { + return getTotalSwapSpaceSize0(); + } + + public long getFreeSwapSpaceSize() { + return getFreeSwapSpaceSize0(); + } + + public long getProcessCpuTime() { + return getProcessCpuTime0(); + } + + public long getFreePhysicalMemorySize() { + return getFreePhysicalMemorySize0(); + } + + public long getTotalPhysicalMemorySize() { + return getTotalPhysicalMemorySize0(); + } + + public double getSystemCpuLoad() { + return getSystemCpuLoad0(); + } + + public double getProcessCpuLoad() { + return getProcessCpuLoad0(); + } + + /* native methods */ + private native long getCommittedVirtualMemorySize0(); + private native long getFreePhysicalMemorySize0(); + private native long getFreeSwapSpaceSize0(); + private native double getProcessCpuLoad0(); + private native long getProcessCpuTime0(); + private native double getSystemCpuLoad0(); + private native long getTotalPhysicalMemorySize0(); + private native long getTotalSwapSpaceSize0(); static { - initialize(); + initialize0(); } - private static native void initialize(); + + private static native void initialize0(); } diff --git a/jdk/src/windows/classes/sun/net/PortConfig.java b/jdk/src/windows/classes/sun/net/PortConfig.java new file mode 100644 index 00000000000..e2ba12fee85 --- /dev/null +++ b/jdk/src/windows/classes/sun/net/PortConfig.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package sun.net; + +import java.security.AccessController; + +/** + * Determines the ephemeral port range in use on this system. + * If this cannot be determined, then the default settings + * of the OS are returned. + */ + +public final class PortConfig { + + private static int defaultUpper, defaultLower; + private final static int upper, lower; + + static { + AccessController.doPrivileged( + new java.security.PrivilegedAction() { + public Void run() { + System.loadLibrary("net"); + return null; + } + }); + + int v = getLower0(); + if (v == -1) { + v = defaultLower; + } + lower = v; + + v = getUpper0(); + if (v == -1) { + v = defaultUpper; + } + upper = v; + } + + static native int getLower0(); + static native int getUpper0(); + + public static int getLower() { + return lower; + } + + public static int getUpper() { + return upper; + } +} diff --git a/jdk/src/windows/classes/sun/nio/ch/PollArrayWrapper.java b/jdk/src/windows/classes/sun/nio/ch/PollArrayWrapper.java index 89455769485..08591f82061 100644 --- a/jdk/src/windows/classes/sun/nio/ch/PollArrayWrapper.java +++ b/jdk/src/windows/classes/sun/nio/ch/PollArrayWrapper.java @@ -53,15 +53,6 @@ class PollArrayWrapper { static short SIZE_POLLFD = 8; // sizeof pollfd struct - // events masks - @Native static final short POLLIN = AbstractPollArrayWrapper.POLLIN; - @Native static final short POLLOUT = AbstractPollArrayWrapper.POLLOUT; - @Native static final short POLLERR = AbstractPollArrayWrapper.POLLERR; - @Native static final short POLLHUP = AbstractPollArrayWrapper.POLLHUP; - @Native static final short POLLNVAL = AbstractPollArrayWrapper.POLLNVAL; - @Native static final short POLLREMOVE = AbstractPollArrayWrapper.POLLREMOVE; - @Native static final short POLLCONN = 0x0002; - private int size; // Size of the pollArray PollArrayWrapper(int newSize) { @@ -119,6 +110,6 @@ class PollArrayWrapper { // Adds Windows wakeup socket at a given index. void addWakeupSocket(int fdVal, int index) { putDescriptor(index, fdVal); - putEventOps(index, POLLIN); + putEventOps(index, Net.POLLIN); } } diff --git a/jdk/src/windows/classes/sun/nio/ch/SinkChannelImpl.java b/jdk/src/windows/classes/sun/nio/ch/SinkChannelImpl.java index 1450928a816..57e88ac38cf 100644 --- a/jdk/src/windows/classes/sun/nio/ch/SinkChannelImpl.java +++ b/jdk/src/windows/classes/sun/nio/ch/SinkChannelImpl.java @@ -78,17 +78,16 @@ class SinkChannelImpl int oldOps = sk.nioReadyOps(); int newOps = initialOps; - if ((ops & PollArrayWrapper.POLLNVAL) != 0) + if ((ops & Net.POLLNVAL) != 0) throw new Error("POLLNVAL detected"); - if ((ops & (PollArrayWrapper.POLLERR - | PollArrayWrapper.POLLHUP)) != 0) { + if ((ops & (Net.POLLERR | Net.POLLHUP)) != 0) { newOps = intOps; sk.nioReadyOps(newOps); return (newOps & ~oldOps) != 0; } - if (((ops & PollArrayWrapper.POLLOUT) != 0) && + if (((ops & Net.POLLOUT) != 0) && ((intOps & SelectionKey.OP_WRITE) != 0)) newOps |= SelectionKey.OP_WRITE; @@ -106,7 +105,7 @@ class SinkChannelImpl public void translateAndSetInterestOps(int ops, SelectionKeyImpl sk) { if ((ops & SelectionKey.OP_WRITE) != 0) - ops = PollArrayWrapper.POLLOUT; + ops = Net.POLLOUT; sk.selector.putEventOps(sk, ops); } diff --git a/jdk/src/windows/classes/sun/nio/ch/SourceChannelImpl.java b/jdk/src/windows/classes/sun/nio/ch/SourceChannelImpl.java index da45df639af..2605d61b47c 100644 --- a/jdk/src/windows/classes/sun/nio/ch/SourceChannelImpl.java +++ b/jdk/src/windows/classes/sun/nio/ch/SourceChannelImpl.java @@ -77,17 +77,16 @@ class SourceChannelImpl int oldOps = sk.nioReadyOps(); int newOps = initialOps; - if ((ops & PollArrayWrapper.POLLNVAL) != 0) + if ((ops & Net.POLLNVAL) != 0) throw new Error("POLLNVAL detected"); - if ((ops & (PollArrayWrapper.POLLERR - | PollArrayWrapper.POLLHUP)) != 0) { + if ((ops & (Net.POLLERR | Net.POLLHUP)) != 0) { newOps = intOps; sk.nioReadyOps(newOps); return (newOps & ~oldOps) != 0; } - if (((ops & PollArrayWrapper.POLLIN) != 0) && + if (((ops & Net.POLLIN) != 0) && ((intOps & SelectionKey.OP_READ) != 0)) newOps |= SelectionKey.OP_READ; @@ -105,7 +104,7 @@ class SourceChannelImpl public void translateAndSetInterestOps(int ops, SelectionKeyImpl sk) { if ((ops & SelectionKey.OP_READ) != 0) - ops = PollArrayWrapper.POLLIN; + ops = Net.POLLIN; sk.selector.putEventOps(sk, ops); } diff --git a/jdk/src/windows/classes/sun/nio/ch/WindowsAsynchronousSocketChannelImpl.java b/jdk/src/windows/classes/sun/nio/ch/WindowsAsynchronousSocketChannelImpl.java index 124205a65f7..8e193a888b4 100644 --- a/jdk/src/windows/classes/sun/nio/ch/WindowsAsynchronousSocketChannelImpl.java +++ b/jdk/src/windows/classes/sun/nio/ch/WindowsAsynchronousSocketChannelImpl.java @@ -31,6 +31,9 @@ import java.nio.BufferOverflowException; import java.net.*; import java.util.concurrent.*; import java.io.IOException; +import java.security.AccessController; +import java.security.PrivilegedActionException; +import java.security.PrivilegedExceptionAction; import sun.misc.Unsafe; /** @@ -300,6 +303,19 @@ class WindowsAsynchronousSocketChannelImpl } } + private void doPrivilegedBind(final SocketAddress sa) throws IOException { + try { + AccessController.doPrivileged(new PrivilegedExceptionAction() { + public Void run() throws IOException { + bind(sa); + return null; + } + }); + } catch (PrivilegedActionException e) { + throw (IOException) e.getException(); + } + } + @Override Future implConnect(SocketAddress remote, A attachment, @@ -330,7 +346,12 @@ class WindowsAsynchronousSocketChannelImpl throw new ConnectionPendingException(); if (localAddress == null) { try { - bind(new InetSocketAddress(0)); + SocketAddress any = new InetSocketAddress(0); + if (sm == null) { + bind(any); + } else { + doPrivilegedBind(any); + } } catch (IOException x) { bindException = x; } diff --git a/jdk/src/windows/classes/sun/nio/ch/WindowsSelectorImpl.java b/jdk/src/windows/classes/sun/nio/ch/WindowsSelectorImpl.java index d84712ba97c..eec35ea9518 100644 --- a/jdk/src/windows/classes/sun/nio/ch/WindowsSelectorImpl.java +++ b/jdk/src/windows/classes/sun/nio/ch/WindowsSelectorImpl.java @@ -313,16 +313,16 @@ final class WindowsSelectorImpl extends SelectorImpl { private int processSelectedKeys(long updateCount) { int numKeysUpdated = 0; numKeysUpdated += processFDSet(updateCount, readFds, - PollArrayWrapper.POLLIN, + Net.POLLIN, false); numKeysUpdated += processFDSet(updateCount, writeFds, - PollArrayWrapper.POLLCONN | - PollArrayWrapper.POLLOUT, + Net.POLLCONN | + Net.POLLOUT, false); numKeysUpdated += processFDSet(updateCount, exceptFds, - PollArrayWrapper.POLLIN | - PollArrayWrapper.POLLCONN | - PollArrayWrapper.POLLOUT, + Net.POLLIN | + Net.POLLCONN | + Net.POLLOUT, true); return numKeysUpdated; } diff --git a/jdk/src/windows/classes/sun/nio/fs/WindowsFileSystemProvider.java b/jdk/src/windows/classes/sun/nio/fs/WindowsFileSystemProvider.java index 1f2f22e326d..2e6484b7ba7 100644 --- a/jdk/src/windows/classes/sun/nio/fs/WindowsFileSystemProvider.java +++ b/jdk/src/windows/classes/sun/nio/fs/WindowsFileSystemProvider.java @@ -493,6 +493,14 @@ public class WindowsFileSystemProvider try { CreateDirectory(dir.getPathForWin32Calls(), sd.address()); } catch (WindowsException x) { + // convert ERROR_ACCESS_DENIED to FileAlreadyExistsException if we can + // verify that the directory exists + if (x.lastError() == ERROR_ACCESS_DENIED) { + try { + if (WindowsFileAttributes.get(dir, false).isDirectory()) + throw new FileAlreadyExistsException(dir.toString()); + } catch (WindowsException ignore) { } + } x.rethrowAsIOException(dir); } finally { sd.release(); diff --git a/jdk/src/windows/classes/sun/print/Win32PrintJob.java b/jdk/src/windows/classes/sun/print/Win32PrintJob.java index 844f3ee4f22..570d23a91d2 100644 --- a/jdk/src/windows/classes/sun/print/Win32PrintJob.java +++ b/jdk/src/windows/classes/sun/print/Win32PrintJob.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 @@ -308,12 +308,10 @@ public class Win32PrintJob implements CancelablePrintJob { } } - PrinterState prnState = (PrinterState)service.getAttribute( - PrinterState.class); + PrinterState prnState = service.getAttribute(PrinterState.class); if (prnState == PrinterState.STOPPED) { PrinterStateReasons prnStateReasons = - (PrinterStateReasons)service.getAttribute( - PrinterStateReasons.class); + service.getAttribute(PrinterStateReasons.class); if ((prnStateReasons != null) && (prnStateReasons.containsKey(PrinterStateReason.SHUTDOWN))) { @@ -321,9 +319,8 @@ public class Win32PrintJob implements CancelablePrintJob { } } - if ((PrinterIsAcceptingJobs)(service.getAttribute( - PrinterIsAcceptingJobs.class)) == - PrinterIsAcceptingJobs.NOT_ACCEPTING_JOBS) { + if (service.getAttribute(PrinterIsAcceptingJobs.class) == + PrinterIsAcceptingJobs.NOT_ACCEPTING_JOBS) { throw new PrintException("Printer is not accepting job."); } diff --git a/jdk/src/windows/classes/sun/print/Win32PrintService.java b/jdk/src/windows/classes/sun/print/Win32PrintService.java index 73e89269285..1fc7fe46f54 100644 --- a/jdk/src/windows/classes/sun/print/Win32PrintService.java +++ b/jdk/src/windows/classes/sun/print/Win32PrintService.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 @@ -506,8 +506,7 @@ public class Win32PrintService implements PrintService, AttributeUpdater, } } else { // if getting MPA failed, we use MediaSize - MediaSize ms = - MediaSize.getMediaSizeForName((MediaSizeName)mediaName); + MediaSize ms = MediaSize.getMediaSizeForName(mediaName); if (ms != null) { try { diff --git a/jdk/src/windows/classes/sun/security/mscapi/SunMSCAPI.java b/jdk/src/windows/classes/sun/security/mscapi/SunMSCAPI.java index 7725b27d3c6..fb1ce9194a3 100644 --- a/jdk/src/windows/classes/sun/security/mscapi/SunMSCAPI.java +++ b/jdk/src/windows/classes/sun/security/mscapi/SunMSCAPI.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 @@ -56,7 +56,7 @@ public final class SunMSCAPI extends Provider { } public SunMSCAPI() { - super("SunMSCAPI", 1.8d, INFO); + super("SunMSCAPI", 1.9d, INFO); // if there is no security manager installed, put directly into // the provider. Otherwise, create a temporary map and use a diff --git a/jdk/src/windows/native/java/net/DualStackPlainDatagramSocketImpl.c b/jdk/src/windows/native/java/net/DualStackPlainDatagramSocketImpl.c index fa2c994bf05..d0f09d5e8b5 100644 --- a/jdk/src/windows/native/java/net/DualStackPlainDatagramSocketImpl.c +++ b/jdk/src/windows/native/java/net/DualStackPlainDatagramSocketImpl.c @@ -41,7 +41,7 @@ static jboolean purgeOutstandingICMP(JNIEnv *env, jint fd) char buf[1]; fd_set tbl; struct timeval t = { 0, 0 }; - struct sockaddr_in rmtaddr; + SOCKETADDRESS rmtaddr; int addrlen = sizeof(rmtaddr); /* diff --git a/jdk/src/windows/native/java/net/TwoStacksPlainDatagramSocketImpl.c b/jdk/src/windows/native/java/net/TwoStacksPlainDatagramSocketImpl.c index 77496d195cf..3f0a211fd01 100644 --- a/jdk/src/windows/native/java/net/TwoStacksPlainDatagramSocketImpl.c +++ b/jdk/src/windows/native/java/net/TwoStacksPlainDatagramSocketImpl.c @@ -332,7 +332,7 @@ static jboolean purgeOutstandingICMP(JNIEnv *env, jobject this, jint fd) char buf[1]; fd_set tbl; struct timeval t = { 0, 0 }; - struct sockaddr_in rmtaddr; + SOCKETADDRESS rmtaddr; int addrlen = sizeof(rmtaddr); /* diff --git a/jdk/src/windows/native/java/net/net_util_md.c b/jdk/src/windows/native/java/net/net_util_md.c index 6ddb2bcfd78..1cacb57386b 100644 --- a/jdk/src/windows/native/java/net/net_util_md.c +++ b/jdk/src/windows/native/java/net/net_util_md.c @@ -125,8 +125,8 @@ DllMain(HINSTANCE hinst, DWORD reason, LPVOID reserved) return TRUE; } -void initLocalAddrTable () {} -void parseExclusiveBindProperty (JNIEnv *env) {} +void platformInit() {} +void parseExclusiveBindProperty(JNIEnv *env) {} /* * Since winsock doesn't have the equivalent of strerror(errno) diff --git a/jdk/src/windows/native/sun/management/OperatingSystemImpl.c b/jdk/src/windows/native/sun/management/OperatingSystemImpl.c index c684e2bd81c..260f9f695b4 100644 --- a/jdk/src/windows/native/sun/management/OperatingSystemImpl.c +++ b/jdk/src/windows/native/sun/management/OperatingSystemImpl.c @@ -77,7 +77,7 @@ static HANDLE main_process; int perfiInit(void); JNIEXPORT void JNICALL -Java_sun_management_OperatingSystemImpl_initialize +Java_sun_management_OperatingSystemImpl_initialize0 (JNIEnv *env, jclass cls) { main_process = GetCurrentProcess(); @@ -97,7 +97,7 @@ Java_sun_management_OperatingSystemImpl_getCommittedVirtualMemorySize0 } JNIEXPORT jlong JNICALL -Java_sun_management_OperatingSystemImpl_getTotalSwapSpaceSize +Java_sun_management_OperatingSystemImpl_getTotalSwapSpaceSize0 (JNIEnv *env, jobject mbean) { MEMORYSTATUSEX ms; @@ -107,7 +107,7 @@ Java_sun_management_OperatingSystemImpl_getTotalSwapSpaceSize } JNIEXPORT jlong JNICALL -Java_sun_management_OperatingSystemImpl_getFreeSwapSpaceSize +Java_sun_management_OperatingSystemImpl_getFreeSwapSpaceSize0 (JNIEnv *env, jobject mbean) { MEMORYSTATUSEX ms; @@ -117,7 +117,7 @@ Java_sun_management_OperatingSystemImpl_getFreeSwapSpaceSize } JNIEXPORT jlong JNICALL -Java_sun_management_OperatingSystemImpl_getProcessCpuTime +Java_sun_management_OperatingSystemImpl_getProcessCpuTime0 (JNIEnv *env, jobject mbean) { @@ -136,7 +136,7 @@ Java_sun_management_OperatingSystemImpl_getProcessCpuTime } JNIEXPORT jlong JNICALL -Java_sun_management_OperatingSystemImpl_getFreePhysicalMemorySize +Java_sun_management_OperatingSystemImpl_getFreePhysicalMemorySize0 (JNIEnv *env, jobject mbean) { MEMORYSTATUSEX ms; @@ -146,7 +146,7 @@ Java_sun_management_OperatingSystemImpl_getFreePhysicalMemorySize } JNIEXPORT jlong JNICALL -Java_sun_management_OperatingSystemImpl_getTotalPhysicalMemorySize +Java_sun_management_OperatingSystemImpl_getTotalPhysicalMemorySize0 (JNIEnv *env, jobject mbean) { MEMORYSTATUSEX ms; @@ -927,14 +927,14 @@ perfInit(void) { } JNIEXPORT jdouble JNICALL -Java_sun_management_OperatingSystemImpl_getSystemCpuLoad +Java_sun_management_OperatingSystemImpl_getSystemCpuLoad0 (JNIEnv *env, jobject dummy) { return perfGetCPULoad(-1); } JNIEXPORT jdouble JNICALL -Java_sun_management_OperatingSystemImpl_getProcessCpuLoad +Java_sun_management_OperatingSystemImpl_getProcessCpuLoad0 (JNIEnv *env, jobject dummy) { return perfGetProcessLoad(); diff --git a/jdk/src/windows/native/sun/net/portconfig.c b/jdk/src/windows/native/sun/net/portconfig.c new file mode 100644 index 00000000000..f786ef7b511 --- /dev/null +++ b/jdk/src/windows/native/sun/net/portconfig.c @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +#include +#include "jni.h" +#include "net_util.h" +#include "sun_net_PortConfig.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct portrange { + int lower; + int higher; +}; + +static int getPortRange(struct portrange *range) +{ + OSVERSIONINFO ver; + ver.dwOSVersionInfoSize = sizeof(ver); + GetVersionEx(&ver); + + /* Check for major version 5 or less = Windows XP/2003 or older */ + if (ver.dwMajorVersion <= 5) { + LONG ret; + HKEY hKey; + range->lower = 1024; + range->higher = 4999; + + /* check registry to see if upper limit was raised */ + ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE, + "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters", + 0, KEY_READ, (PHKEY)&hKey + ); + if (ret == ERROR_SUCCESS) { + DWORD maxuserport; + ULONG ulType; + DWORD dwLen = sizeof(maxuserport); + ret = RegQueryValueEx(hKey, "MaxUserPort", NULL, &ulType, + (LPBYTE)&maxuserport, &dwLen); + RegCloseKey(hKey); + if (ret == ERROR_SUCCESS) { + range->higher = maxuserport; + } + } + } else { + /* There doesn't seem to be an API to access this. "MaxUserPort" + * is affected, but is not sufficient to determine. + * so we just use the defaults, which are less likely to change + */ + range->lower = 49152; + range->higher = 65535; + } + return 0; +} + +/* + * Class: sun_net_PortConfig + * Method: getLower0 + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_sun_net_PortConfig_getLower0 + (JNIEnv *env, jclass clazz) +{ + struct portrange range; + getPortRange(&range); + return range.lower; +} + +/* + * Class: sun_net_PortConfig + * Method: getUpper0 + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_sun_net_PortConfig_getUpper0 + (JNIEnv *env, jclass clazz) +{ + struct portrange range; + getPortRange(&range); + return range.higher; +} +#ifdef __cplusplus +} +#endif diff --git a/jdk/src/windows/native/sun/nio/ch/Net.c b/jdk/src/windows/native/sun/nio/ch/Net.c index 733405e6f80..acaa50d2b5e 100644 --- a/jdk/src/windows/native/sun/nio/ch/Net.c +++ b/jdk/src/windows/native/sun/nio/ch/Net.c @@ -554,11 +554,11 @@ Java_sun_nio_ch_Net_poll(JNIEnv* env, jclass this, jobject fdo, jint events, jlo FD_ZERO(&rd); FD_ZERO(&wr); FD_ZERO(&ex); - if (events & sun_nio_ch_PollArrayWrapper_POLLIN) { + if (events & POLLIN) { FD_SET(fd, &rd); } - if (events & sun_nio_ch_PollArrayWrapper_POLLOUT || - events & sun_nio_ch_PollArrayWrapper_POLLCONN) { + if (events & POLLOUT || + events & POLLCONN) { FD_SET(fd, &wr); } FD_SET(fd, &ex); @@ -572,14 +572,50 @@ Java_sun_nio_ch_Net_poll(JNIEnv* env, jclass this, jobject fdo, jint events, jlo } else if (rv >= 0) { rv = 0; if (FD_ISSET(fd, &rd)) { - rv |= sun_nio_ch_PollArrayWrapper_POLLIN; + rv |= POLLIN; } if (FD_ISSET(fd, &wr)) { - rv |= sun_nio_ch_PollArrayWrapper_POLLOUT; + rv |= POLLOUT; } if (FD_ISSET(fd, &ex)) { - rv |= sun_nio_ch_PollArrayWrapper_POLLERR; + rv |= POLLERR; } } return rv; } + +JNIEXPORT jshort JNICALL +Java_sun_nio_ch_Net_pollinValue(JNIEnv *env, jclass this) +{ + return (jshort)POLLIN; +} + +JNIEXPORT jshort JNICALL +Java_sun_nio_ch_Net_polloutValue(JNIEnv *env, jclass this) +{ + return (jshort)POLLOUT; +} + +JNIEXPORT jshort JNICALL +Java_sun_nio_ch_Net_pollerrValue(JNIEnv *env, jclass this) +{ + return (jshort)POLLERR; +} + +JNIEXPORT jshort JNICALL +Java_sun_nio_ch_Net_pollhupValue(JNIEnv *env, jclass this) +{ + return (jshort)POLLHUP; +} + +JNIEXPORT jshort JNICALL +Java_sun_nio_ch_Net_pollnvalValue(JNIEnv *env, jclass this) +{ + return (jshort)POLLNVAL; +} + +JNIEXPORT jshort JNICALL +Java_sun_nio_ch_Net_pollconnValue(JNIEnv *env, jclass this) +{ + return (jshort)POLLCONN; +} diff --git a/jdk/src/windows/native/sun/nio/ch/WindowsSelectorImpl.c b/jdk/src/windows/native/sun/nio/ch/WindowsSelectorImpl.c index aa10877c42b..7d5e1e77875 100644 --- a/jdk/src/windows/native/sun/nio/ch/WindowsSelectorImpl.c +++ b/jdk/src/windows/native/sun/nio/ch/WindowsSelectorImpl.c @@ -33,13 +33,15 @@ #define FD_SETSIZE 1024 #include +#include + #include "jvm.h" #include "jni.h" #include "jni_util.h" #include "sun_nio_ch_WindowsSelectorImpl.h" #include "sun_nio_ch_PollArrayWrapper.h" -#include "winsock2.h" +#include "nio_util.h" /* Needed for POLL* constants (includes "winsock2.h") */ typedef struct { jint fd; @@ -79,12 +81,11 @@ Java_sun_nio_ch_WindowsSelectorImpl_00024SubSelector_poll0(JNIEnv *env, jobject /* Set FD_SET structures required for select */ for (i = 0; i < numfds; i++) { - if (fds[i].events & sun_nio_ch_PollArrayWrapper_POLLIN) { + if (fds[i].events & POLLIN) { readfds.fd_array[read_count] = fds[i].fd; read_count++; } - if (fds[i].events & (sun_nio_ch_PollArrayWrapper_POLLOUT | - sun_nio_ch_PollArrayWrapper_POLLCONN)) + if (fds[i].events & (POLLOUT | POLLCONN)) { writefds.fd_array[write_count] = fds[i].fd; write_count++; @@ -110,12 +111,11 @@ Java_sun_nio_ch_WindowsSelectorImpl_00024SubSelector_poll0(JNIEnv *env, jobject /* prepare select structures for the i-th socket */ errreadfds.fd_count = 0; errwritefds.fd_count = 0; - if (fds[i].events & sun_nio_ch_PollArrayWrapper_POLLIN) { + if (fds[i].events & POLLIN) { errreadfds.fd_array[0] = fds[i].fd; errreadfds.fd_count = 1; } - if (fds[i].events & (sun_nio_ch_PollArrayWrapper_POLLOUT | - sun_nio_ch_PollArrayWrapper_POLLCONN)) + if (fds[i].events & (POLLOUT | POLLCONN)) { errwritefds.fd_array[0] = fds[i].fd; errwritefds.fd_count = 1; diff --git a/jdk/src/windows/native/sun/nio/ch/nio_util.h b/jdk/src/windows/native/sun/nio/ch/nio_util.h index cf2df5363b7..1d463241c25 100644 --- a/jdk/src/windows/native/sun/nio/ch/nio_util.h +++ b/jdk/src/windows/native/sun/nio/ch/nio_util.h @@ -23,6 +23,8 @@ * questions. */ +#include + #include "jni.h" /** @@ -55,3 +57,19 @@ struct iovec { }; #endif + +#ifndef POLLIN + /* WSAPoll()/WSAPOLLFD and the corresponding constants are only defined */ + /* in Windows Vista / Windows Server 2008 and later. If we are on an */ + /* older release we just use the Solaris constants as this was previously */ + /* done in PollArrayWrapper.java. */ + #define POLLIN 0x0001 + #define POLLOUT 0x0004 + #define POLLERR 0x0008 + #define POLLHUP 0x0010 + #define POLLNVAL 0x0020 + #define POLLCONN 0x0002 +#else + /* POLLCONN must not equal any of the other constants (see winsock2.h). */ + #define POLLCONN 0x2000 +#endif diff --git a/jdk/src/windows/native/sun/security/krb5/NativeCreds.c b/jdk/src/windows/native/sun/security/krb5/NativeCreds.c index b2537be03e8..9f0db518c82 100644 --- a/jdk/src/windows/native/sun/security/krb5/NativeCreds.c +++ b/jdk/src/windows/native/sun/security/krb5/NativeCreds.c @@ -388,7 +388,7 @@ JNIEXPORT jobject JNICALL Java_sun_security_krb5_Credentials_acquireDefaultNativ jobject ticketFlags, startTime, endTime, krbCreds = NULL; jobject authTime, renewTillTime, hostAddresses = NULL; KERB_EXTERNAL_TICKET *msticket; - int found_in_cache = 0; + int found = 0; FILETIME Now, EndTime, LocalEndTime; int i, netypes; @@ -476,7 +476,7 @@ JNIEXPORT jobject JNICALL Java_sun_security_krb5_Credentials_acquireDefaultNativ if (CompareFileTime(&Now, &LocalEndTime) < 0) { for (i=0; iSessionKey.KeyType) { - found_in_cache = 1; + found = 1; if (native_debug) { printf("LSA: Valid etype found: %d\n", etypes[i]); } @@ -486,7 +486,7 @@ JNIEXPORT jobject JNICALL Java_sun_security_krb5_Credentials_acquireDefaultNativ } } - if (!found_in_cache) { + if (!found) { if (native_debug) { printf("LSA: MS TGT in cache is invalid/not supported; request new ticket\n"); } @@ -529,6 +529,14 @@ JNIEXPORT jobject JNICALL Java_sun_security_krb5_Credentials_acquireDefaultNativ // got the native MS Kerberos TGT msticket = &(pTicketResponse->Ticket); + + if (msticket->SessionKey.KeyType != etypes[i]) { + if (native_debug) { + printf("LSA: Response etype is %d for %d. Retry.\n", msticket->SessionKey.KeyType, etypes[i]); + } + continue; + } + found = 1; break; } } @@ -583,6 +591,10 @@ JNIEXPORT jobject JNICALL Java_sun_security_krb5_Credentials_acquireDefaultNativ } KERB_CRYPTO_KEY, *PKERB_CRYPTO_KEY; */ + if (!found) { + break; + } + // Build a com.sun.security.krb5.Ticket ticket = BuildTicket(env, msticket->EncodedTicket, msticket->EncodedTicketSize); diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt index 7c83f52f75c..8126fbf8d3b 100644 --- a/jdk/test/ProblemList.txt +++ b/jdk/test/ProblemList.txt @@ -41,11 +41,11 @@ # # List items are testnames followed by labels, all MUST BE commented # as to why they are here and use a label: -# generic-all Problems on all platforms -# generic-ARCH Where ARCH is one of: sparc, sparcv9, x64, i586, etc. -# OSNAME-all Where OSNAME is one of: solaris, linux, windows, macosx -# OSNAME-ARCH Specific on to one OSNAME and ARCH, e.g. solaris-amd64 -# OSNAME-REV Specific on to one OSNAME and REV, e.g. solaris-5.8 +# generic-all Problems on all platforms +# generic-ARCH Where ARCH is one of: sparc, sparcv9, x64, i586, etc. +# OSNAME-all Where OSNAME is one of: solaris, linux, windows, macosx, aix +# OSNAME-ARCH Specific on to one OSNAME and ARCH, e.g. solaris-amd64 +# OSNAME-REV Specific on to one OSNAME and REV, e.g. solaris-5.8 # # More than one label is allowed but must be on the same line. # @@ -134,6 +134,11 @@ sun/management/jmxremote/bootstrap/RmiSslBootstrapTest.sh windows-all # jdk_jmx +# 8030957 +com/sun/management/OperatingSystemMXBean/GetProcessCpuLoad.java aix-all +com/sun/management/OperatingSystemMXBean/GetSystemCpuLoad.java aix-all +javax/management/MBeanServer/OldMBeanServerTest.java aix-all + ############################################################################ # jdk_math @@ -145,12 +150,6 @@ sun/management/jmxremote/bootstrap/RmiSslBootstrapTest.sh windows-all # 6988950 demo/jvmti/compiledMethodLoad/CompiledMethodLoadTest.java generic-all -# 7027502 -demo/jvmti/hprof/MonitorTest.java generic-all - -# 8027973 -javax/xml/jaxp/transform/jdk8004476/XSLTExFuncTest.java windows-all - ############################################################################ # jdk_net @@ -158,10 +157,6 @@ javax/xml/jaxp/transform/jdk8004476/XSLTExFuncTest.java windows-all # Filed 7052625 com/sun/net/httpserver/bugs/6725892/Test.java generic-all -# failing on vista 32/64 on nightly -# 7102702 -java/net/PortUnreachableException/OneExceptionOnly.java windows-all - # 7148829 sun/net/InetAddress/nameservice/simple/CacheTest.java generic-all sun/net/InetAddress/nameservice/simple/DefaultCaching.java generic-all @@ -183,11 +178,6 @@ java/net/DatagramSocket/SendDatagramToBadAddress.java macosx-all # 6963118 java/nio/channels/Selector/Wakeup.java windows-all -# 7133499, 7133497 -java/nio/channels/AsyncCloseAndInterrupt.java macosx-all -java/nio/channels/AsynchronousFileChannel/Lock.java macosx-all -java/nio/channels/FileChannel/Transfer.java macosx-all - # 7141822 java/nio/channels/DatagramChannel/ChangingAddress.java macosx-all @@ -263,9 +253,6 @@ sun/security/krb5/auto/BadKdc4.java solaris-sparcv9 # jdk_tools -# 7132203 -sun/jvmstat/monitor/MonitoredVm/CR6672135.java generic-all - # 8028474 sun/jvmstat/monitor/MonitoredVm/MonitorVmStartTerminate.sh generic-all @@ -280,17 +267,15 @@ tools/launcher/FXLauncherTest.java linux-all # jdk_jdi -# Filed 6952105 -com/sun/jdi/SuspendThreadTest.java generic-all - -# Filed 6653793 -com/sun/jdi/RedefineCrossEvent.java generic-all - ############################################################################ # jdk_util -# Filed 6772009 -java/util/concurrent/locks/ReentrantLock/CancelledLockLoops.java generic-all +############################################################################ + +# svc_tools + +# 8031482 +sun/tools/jcmd/TestJcmdSanity.java windows-all ############################################################################ diff --git a/jdk/test/TEST.groups b/jdk/test/TEST.groups index 77fae723f98..b624ca9b6eb 100644 --- a/jdk/test/TEST.groups +++ b/jdk/test/TEST.groups @@ -267,6 +267,24 @@ jdk_desktop = \ :jdk_sound \ :jdk_imageio +############################# +# +# Stable test groups +# + +jdk_stable = \ + :jdk_core \ + :jdk_svc \ + :jdk_beans \ + :jdk_imageio \ + :jdk_sound \ + :jdk_sctp \ + javax/accessibility \ + com/sun/java/swing \ + sun/pisces \ + com/sun/awt + + ############################################################################### # Profile-based Test Group Definitions # @@ -357,13 +375,10 @@ needs_jre = \ java/security/Security/ClassLoaderDeadlock/ClassLoaderDeadlock.sh \ java/security/Security/ClassLoaderDeadlock/Deadlock.sh \ java/util/jar/Manifest/CreateManifest.java \ - java/util/logging/Listeners.java \ - java/util/logging/ListenersWithSM.java \ java/util/logging/TestMainAppContext.java \ java/util/ResourceBundle/Control/Bug6530694.java \ java/text/Bidi/BidiConformance.java \ java/text/Bidi/BidiEmbeddingTest.java \ - java/text/Bidi/Bug6665028.java \ java/text/Bidi/Bug7042148.java \ java/text/Bidi/Bug7051769.java \ javax/crypto/Cipher/CipherStreamClose.java \ diff --git a/jdk/test/com/sun/corba/5036554/TestCorbaBug.sh b/jdk/test/com/sun/corba/5036554/TestCorbaBug.sh index 983608cb560..7e057e72c38 100644 --- a/jdk/test/com/sun/corba/5036554/TestCorbaBug.sh +++ b/jdk/test/com/sun/corba/5036554/TestCorbaBug.sh @@ -48,7 +48,7 @@ fi # set platform-dependent variables OS=`uname -s` case "$OS" in - SunOS | Linux | Darwin ) + SunOS | Linux | Darwin | AIX ) PS=":" FS="/" ;; diff --git a/jdk/test/com/sun/corba/cachedSocket/7056731.sh b/jdk/test/com/sun/corba/cachedSocket/7056731.sh index 5244b9a70a5..3b58ad6e632 100644 --- a/jdk/test/com/sun/corba/cachedSocket/7056731.sh +++ b/jdk/test/com/sun/corba/cachedSocket/7056731.sh @@ -31,7 +31,7 @@ OS=`uname -s` case "$OS" in - SunOS | Linux | Darwin ) + SunOS | Linux | Darwin | AIX ) PS=":" FS="/" ;; diff --git a/jdk/test/com/sun/java/swing/plaf/windows/8016551/bug8016551.java b/jdk/test/com/sun/java/swing/plaf/windows/8016551/bug8016551.java index e616daadde4..35e55f09174 100644 --- a/jdk/test/com/sun/java/swing/plaf/windows/8016551/bug8016551.java +++ b/jdk/test/com/sun/java/swing/plaf/windows/8016551/bug8016551.java @@ -25,7 +25,7 @@ * @bug 8016551 * @summary JMenuItem in WindowsLookAndFeel can't paint default icons * @author Leonid Romanov - * @run main bug8016551 + * @run main/othervm bug8016551 */ import javax.swing.*; diff --git a/jdk/test/com/sun/jdi/BadHandshakeTest.java b/jdk/test/com/sun/jdi/BadHandshakeTest.java index 8e35442ebb3..35afb33567a 100644 --- a/jdk/test/com/sun/jdi/BadHandshakeTest.java +++ b/jdk/test/com/sun/jdi/BadHandshakeTest.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 @@ -85,7 +85,7 @@ public class BadHandshakeTest { success.set(line.contains("Listening for transport dt_socket at address:")); return true; }, - 1500, + Integer.MAX_VALUE, TimeUnit.MILLISECONDS ); diff --git a/jdk/test/com/sun/jdi/ImmutableResourceTest.sh b/jdk/test/com/sun/jdi/ImmutableResourceTest.sh index fa312adad74..29c72ed6254 100644 --- a/jdk/test/com/sun/jdi/ImmutableResourceTest.sh +++ b/jdk/test/com/sun/jdi/ImmutableResourceTest.sh @@ -56,7 +56,7 @@ pass() OS=`uname -s` case "$OS" in - SunOS | Linux | Darwin ) + SunOS | Linux | Darwin | AIX ) PATHSEP=":" ;; diff --git a/jdk/test/com/sun/jdi/JITDebug.sh b/jdk/test/com/sun/jdi/JITDebug.sh index 0ec359799a6..c647e1153b5 100644 --- a/jdk/test/com/sun/jdi/JITDebug.sh +++ b/jdk/test/com/sun/jdi/JITDebug.sh @@ -63,7 +63,7 @@ pass() OS=`uname -s` export TRANSPORT_METHOD case "$OS" in - SunOS | Linux | Darwin ) + SunOS | Linux | Darwin | AIX ) PATHSEP=":" TRANSPORT_METHOD=dt_socket ;; diff --git a/jdk/test/com/sun/jdi/JdbExprTest.sh b/jdk/test/com/sun/jdi/JdbExprTest.sh new file mode 100644 index 00000000000..9645714dc08 --- /dev/null +++ b/jdk/test/com/sun/jdi/JdbExprTest.sh @@ -0,0 +1,158 @@ +#!/bin/sh + +# +# Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +# @test +# @bug 4660158 +# @author Staffan Larsen +# @run shell JdbExprTest.sh + +# These are variables that can be set to control execution + +#pkg=untitled7 +classname=JdbExprTest +compileOptions=-g +#java="java_g" +#set -x + +createJavaFile() +{ + cat < $classname.java.1 +import java.util.*; +import java.net.URLClassLoader; +import java.net.URL; + +class $classname { + + static long aLong; + static int anInt; + static boolean aBoolean; + + public static void bkpt() { + int i = 0; //@1 breakpoint + } + + public static void main(String[] args) { + bkpt(); + } +} +EOF +} + + +# drive jdb by sending cmds to it and examining its output +dojdbCmds() +{ + setBkpts @1 + runToBkpt @1 + + cmd print java.lang.Long.MAX_VALUE + jdbFailIfNotPresent " \= 9223372036854775807" 3 + + cmd print java.lang.Long.MIN_VALUE + jdbFailIfNotPresent " \= \-9223372036854775808" 3 + + cmd print 9223372036854775807L + jdbFailIfNotPresent "9223372036854775807L = 9223372036854775807" 3 + cmd print 9223372036854775807 + jdbFailIfNotPresent "9223372036854775807 = 9223372036854775807" 3 + + cmd print -9223372036854775807L + jdbFailIfNotPresent "\-9223372036854775807L = \-9223372036854775807" 3 + cmd print -9223372036854775807 + jdbFailIfNotPresent "\-9223372036854775807 = \-9223372036854775807" 3 + + cmd print -1 + jdbFailIfNotPresent "\-1 = \-1" 3 + cmd print 1L + jdbFailIfNotPresent "1L = 1" 3 + cmd print -1L + jdbFailIfNotPresent "\-1L = \-1" 3 + cmd print 0x1 + jdbFailIfNotPresent "0x1 = 1" 3 + + cmd set $classname.aLong = 9223372036854775807L + cmd print $classname.aLong + jdbFailIfNotPresent "$classname.aLong = 9223372036854775807" 3 + + cmd set $classname.anInt = java.lang.Integer.MAX_VALUE + 1 + cmd print $classname.anInt + jdbFailIfNotPresent "$classname.anInt = \-2147483648" 3 + + cmd set $classname.aLong = java.lang.Integer.MAX_VALUE + 1L + cmd print $classname.aLong + jdbFailIfNotPresent "$classname.aLong = 2147483648" 3 + + cmd set $classname.anInt = 0x80000000 + jdbFailIfNotPresent "InvalidTypeException: .* convert 2147483648 to int" 3 + cmd set $classname.anInt = 0x8000000000000000L + jdbFailIfNotPresent "java.lang.NumberFormatException: For input string: \"8000000000000000\"" 3 + + cmd set $classname.anInt = 0x7fffffff + jdbFailIfNotPresent "0x7fffffff = 2147483647" 3 + cmd set $classname.aLong = 0x7fffffffffffffff + jdbFailIfNotPresent "0x7fffffffffffffff = 9223372036854775807" 3 + + cmd print 3.1415 + jdbFailIfNotPresent "3.1415 = 3.1415" 3 + cmd print -3.1415 + jdbFailIfNotPresent "\-3.1415 = \-3.1415" 3 + cmd print 011 + jdbFailIfNotPresent "011 = 9" 3 + + cmd set $classname.aBoolean = false + jdbFailIfNotPresent "JdbExprTest.aBoolean = false = false" 3 + cmd print $classname.aBoolean + jdbFailIfNotPresent "JdbExprTest.aBoolean = false" 3 + cmd print !$classname.aBoolean + jdbFailIfNotPresent "JdbExprTest.aBoolean = true" 3 + + cmd print ~1 + jdbFailIfNotPresent "~1 = -2" 3 + + cmd quit +} + + +mysetup() +{ + if [ -z "$TESTSRC" ] ; then + TESTSRC=. + fi + + for ii in . $TESTSRC $TESTSRC/.. ; do + if [ -r "$ii/ShellScaffold.sh" ] ; then + . $ii/ShellScaffold.sh + break + fi + done +} + +# You could replace this next line with the contents +# of ShellScaffold.sh and this script will run just the same. +mysetup + +runit +jdbFailIfNotPresent "Breakpoint hit" +pass diff --git a/jdk/test/com/sun/jdi/JdbReadTwiceTest.sh b/jdk/test/com/sun/jdi/JdbReadTwiceTest.sh index 58be020422b..6f3cb193743 100644 --- a/jdk/test/com/sun/jdi/JdbReadTwiceTest.sh +++ b/jdk/test/com/sun/jdi/JdbReadTwiceTest.sh @@ -213,10 +213,17 @@ if [ ! -r c:/ ] ; then # If the file exists, we try to read it. The # read will fail. mkFiles $HOME/jdb.ini - chmod a-r $HOME/jdb.ini - doit - failIfNot 1 "open: $HOME/jdb.ini" - clean + id > $HOME/jdb.ini + chmod a-r $HOME/jdb.ini + if grep -q "uid=" $HOME/jdb.ini ; then + echo "Unable to make file unreadable, so test will fail. chmod: $HOME/jdb.ini" + if grep -q "uid=0" $HOME/jdb.ini ; then + echo "The test is running as root. Fix infrastructure!" + fi + fi + doit + failIfNot 1 "open: $HOME/jdb.ini" + clean fi diff --git a/jdk/test/com/sun/jdi/PrivateTransportTest.sh b/jdk/test/com/sun/jdi/PrivateTransportTest.sh index 32677db795b..ee8051f46ee 100644 --- a/jdk/test/com/sun/jdi/PrivateTransportTest.sh +++ b/jdk/test/com/sun/jdi/PrivateTransportTest.sh @@ -102,7 +102,7 @@ libdir=${TESTCLASSES} is_windows=false is_cygwin=false case `uname -s` in - SunOS|Linux) + SunOS|Linux|AIX) xx=`find ${jreloc}/lib -name libdt_socket.so` libloc=`dirname ${xx}` ;; @@ -161,13 +161,23 @@ elif [ -f ${libloc}/libdt_socket.so ] ; then echo cp ${libloc}/libdt_socket.so ${fullpath} cp ${libloc}/libdt_socket.so ${fullpath} # make sure we can find libraries in current directory - if [ "${LD_LIBRARY_PATH}" = "" ] ; then - LD_LIBRARY_PATH=${libdir} + if [ "$os" = "AIX" ] ; then + if [ "${LIBPATH}" = "" ] ; then + LIBPATH=${libdir} + else + LIBPATH=${LIBPATH}:${libdir} + fi + export LIBPATH + echo LIBPATH=${LIBPATH} else - LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${libdir} + if [ "${LD_LIBRARY_PATH}" = "" ] ; then + LD_LIBRARY_PATH=${libdir} + else + LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${libdir} + fi + export LD_LIBRARY_PATH + echo LD_LIBRARY_PATH=${LD_LIBRARY_PATH} fi - export LD_LIBRARY_PATH - echo LD_LIBRARY_PATH=${LD_LIBRARY_PATH} else echo "cannot find dt_socket in ${libloc} for ${private_transport}" fail "cannot find dt_socket in ${libloc} for ${private_transport}" diff --git a/jdk/test/com/sun/jdi/ProcessAttachTest.sh b/jdk/test/com/sun/jdi/ProcessAttachTest.sh index 10b5d503154..76a531bad38 100644 --- a/jdk/test/com/sun/jdi/ProcessAttachTest.sh +++ b/jdk/test/com/sun/jdi/ProcessAttachTest.sh @@ -87,7 +87,7 @@ startDebuggee() # "java" process. if [ "$OS" = "Windows" ]; then sleep 2 - pid=`ps -o pid,ppid,comm|grep ${startpid}|grep "java"|cut -c1-6` + pid=`ps -o pid,ppid,comm | awk '/${startpid}.+java/{ print $1 }'` fi echo "Waiting for Debuggee to initialize..." diff --git a/jdk/test/com/sun/jdi/ShellScaffold.sh b/jdk/test/com/sun/jdi/ShellScaffold.sh index 6ed55c1ae91..7bc063d44eb 100644 --- a/jdk/test/com/sun/jdi/ShellScaffold.sh +++ b/jdk/test/com/sun/jdi/ShellScaffold.sh @@ -199,6 +199,8 @@ findPid() if [ "$osname" = SunOS ] ; then # Solaris and OpenSolaris use pgrep and not ps in psCmd findPidCmd="$psCmd" + elif [ "$osname" = AIX ] ; then + findPidCmd="$psCmd" else # Never use plain 'ps', which requires a "controlling terminal" # and will fail with a "ps: no controlling terminal" error. @@ -293,7 +295,7 @@ EOF psCmd=ps jstack=jstack.exe ;; - SunOS | Linux | Darwin) + SunOS | Linux | Darwin | AIX) transport=dt_socket address= devnull=/dev/null diff --git a/jdk/test/com/sun/jdi/VisibleMethods.java b/jdk/test/com/sun/jdi/VisibleMethods.java new file mode 100644 index 00000000000..70f7f5abe40 --- /dev/null +++ b/jdk/test/com/sun/jdi/VisibleMethods.java @@ -0,0 +1,141 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @summary Test ReferenceType.visibleMethods + * @bug 8028430 + * + * @author Staffan Larsen + * + * @run build TestScaffold VMConnection TargetListener TargetAdapter + * @run compile -g VisibleMethods.java + * @run main VisibleMethods + */ +import com.sun.jdi.Method; +import com.sun.jdi.ReferenceType; +import com.sun.jdi.StackFrame; +import com.sun.jdi.StringReference; +import com.sun.jdi.ThreadReference; +import com.sun.jdi.event.BreakpointEvent; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +/********** target program **********/ + +interface Super { + public void m(Object o); // This method should not be visible in AC + public void m(String s); // This method should not be visible in AC +} + +interface One extends Super { + public void m(Object o); + public void m1(); // Either this method or Two.m1 should be visible in AC +} + +interface Two extends Super { + public void m(String s); + public void m1(); // Either this method or One.m1 should be visible in AC +} + +abstract class AC implements One, Two { +} + +class CC extends AC { + public void m(Object o) { + } + public void m(String s) { + } + public void m1() { + } + public static void main(String[] args) { + System.out.println("Goodbye from VisibleMethods!"); + } +} + +/********** test program **********/ + +public class VisibleMethods extends TestScaffold { + ReferenceType targetClass; + ThreadReference mainThread; + + VisibleMethods(String args[]) { + super(args); + } + + public static void main(String[] args) throws Exception { + new VisibleMethods(args).startTests(); + } + + /********** test core **********/ + + protected void runTests() + throws Exception + { + /* + * Run to String. + */ + startToMain("CC"); + + ReferenceType ac = findReferenceType("AC"); + List visible = ac.visibleMethods(). + stream(). + map(Method::toString). + collect(Collectors.toList()); + + System.out.println("visibleMethods(): " + visible); + + verifyContains(visible, 1, "Two.m(java.lang.String)"); + verifyContains(visible, 1, "One.m(java.lang.Object)"); + verifyContains(visible, 0, "Super.m(java.lang.Object)"); + verifyContains(visible, 0, "Super.m(java.lang.String)"); + verifyContains(visible, 1, "Two.m1()", "One.m1()"); + + /* + * resume the target listening for events + */ + listenUntilVMDisconnect(); + } + + private void verifyContains(List methods, int matches, + String... sigs) throws Exception { + if (countMatches(methods, sigs) != matches) { + throw new Exception("visibleMethods() should have contained " + + matches + " entry/entries from " + Arrays.toString(sigs)); + } + } + + private int countMatches(List list1, String[] list2) { + int count = 0; + for (String s1 : list1) { + for (String s2 : list2) { + if (s1.equals(s2)) { + count++; + } + } + } + return count; + } +} diff --git a/jdk/test/com/sun/jdi/connect/spi/JdiLoadedByCustomLoader.sh b/jdk/test/com/sun/jdi/connect/spi/JdiLoadedByCustomLoader.sh index 6222c80bd14..2b104822b17 100644 --- a/jdk/test/com/sun/jdi/connect/spi/JdiLoadedByCustomLoader.sh +++ b/jdk/test/com/sun/jdi/connect/spi/JdiLoadedByCustomLoader.sh @@ -45,7 +45,7 @@ fi OS=`uname -s` case "$OS" in - SunOS | Linux | Darwin ) + SunOS | Linux | Darwin | AIX ) PS=":" ;; Windows* | CYGWIN*) diff --git a/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java b/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java new file mode 100644 index 00000000000..8c28db26cf9 --- /dev/null +++ b/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8028994 + * @author Staffan Larsen + * @library /lib/testlibrary + * @run main CheckOrigin + */ + +import com.sun.management.HotSpotDiagnosticMXBean; +import com.sun.management.VMOption; +import com.sun.management.VMOption.Origin; +import com.sun.tools.attach.VirtualMachine; +import java.io.File; +import java.io.FileWriter; +import java.io.InputStream; +import java.io.PrintWriter; +import java.lang.management.ManagementFactory; +import java.util.Map; +import jdk.testlibrary.ProcessTools; +import sun.tools.attach.HotSpotVirtualMachine; + +public class CheckOrigin { + + private static HotSpotDiagnosticMXBean mbean; + + public static void main(String... args) throws Exception { + if (args.length == 0) { + // start a process that has options set in a number of different ways + + File flagsFile = File.createTempFile("CheckOriginFlags", null); + try (PrintWriter pw = + new PrintWriter(new FileWriter(flagsFile))) { + pw.println("+PrintSafepointStatistics"); + } + + ProcessBuilder pb = ProcessTools. + createJavaProcessBuilder( + "-XX:+PrintGCDetails", + "-XX:Flags=" + flagsFile.getAbsolutePath(), + "-cp", System.getProperty("test.class.path") + File.pathSeparator + getToolsJarPath(), + "CheckOrigin", + "-runtests"); + + Map env = pb.environment(); + env.put("_JAVA_OPTIONS", "-XX:+PrintOopAddress"); + + pb.redirectOutput(ProcessBuilder.Redirect.INHERIT); + pb.redirectError(ProcessBuilder.Redirect.INHERIT); + Process p = pb.start(); + int exit = p.waitFor(); + System.out.println("sub process exit == " + exit); + if (exit != 0) { + throw new Exception("Unexpected exit code from subprocess == " + exit); + } + } else { + mbean = + ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class); + + // set a few more options + mbean.setVMOption("HeapDumpOnOutOfMemoryError", "true"); + setOptionUsingAttach("HeapDumpPath", "/a/sample/path"); + + // check the origin field for all the options we set + checkOrigin("ManagementServer", Origin.DEFAULT); + checkOrigin("PrintGCDetails", Origin.VM_CREATION); + checkOrigin("PrintOopAddress", Origin.ENVIRON_VAR); + checkOrigin("PrintSafepointStatistics", Origin.CONFIG_FILE); + checkOrigin("HeapDumpOnOutOfMemoryError", Origin.MANAGEMENT); + checkOrigin("NewSize", Origin.ERGONOMIC); + checkOrigin("HeapDumpPath", Origin.ATTACH_ON_DEMAND); + } + } + + private static void checkOrigin(String option, Origin origin) throws Exception + { + Origin o = mbean.getVMOption(option).getOrigin(); + if (!o.equals(origin)) { + throw new Exception("Option '" + option + "' should have origin '" + origin + "' but had '" + o + "'"); + } + System.out.println("Option '" + option + "' verified origin = '" + origin + "'"); + } + + // use attach to set a manageable vm option + private static void setOptionUsingAttach(String option, String value) throws Exception { + HotSpotVirtualMachine vm = (HotSpotVirtualMachine) VirtualMachine.attach(ProcessTools.getProcessId()+""); + InputStream in = vm.setFlag(option, value); + System.out.println("Result from setting '" + option + "' to '" + value + "' using attach:"); + drain(vm, in); + System.out.println("-- end -- "); + } + + // Read the stream from the target VM until EOF, print to output, then detach + private static void drain(VirtualMachine vm, InputStream in) throws Exception { + byte b[] = new byte[256]; + int n; + do { + n = in.read(b); + if (n > 0) { + String s = new String(b, 0, n, "UTF-8"); + System.out.print(s); + } + } while (n > 0); + in.close(); + vm.detach(); + } + + private static String getToolsJarPath() { + return System.getProperty("java.home") + + "/../lib/tools.jar".replace("/", File.separator); + } +} diff --git a/jdk/test/com/sun/security/auth/callback/DialogCallbackHandler/Default.java b/jdk/test/com/sun/security/auth/callback/DialogCallbackHandler/Default.java deleted file mode 100644 index 89eed615d2a..00000000000 --- a/jdk/test/com/sun/security/auth/callback/DialogCallbackHandler/Default.java +++ /dev/null @@ -1,61 +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. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please 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 4470717 - * @summary fix default handling and other misc - * - * @ignore run these by hand - */ - -import com.sun.security.auth.callback.DialogCallbackHandler; -import javax.security.auth.callback.*; - -public class Default { - public static void main(String args[]) throws Exception { - DialogCallbackHandler h = new DialogCallbackHandler(); - TextOutputCallback toc = new TextOutputCallback - (TextOutputCallback.INFORMATION, - "hello"); - TextOutputCallback toc2 = new TextOutputCallback - (TextOutputCallback.INFORMATION, - "world"); - ConfirmationCallback cc = new ConfirmationCallback - ("Correct?", - ConfirmationCallback.INFORMATION, - ConfirmationCallback.YES_NO_OPTION, - ConfirmationCallback.NO); - - Callback[] callbacks = { toc, toc2, cc }; - h.handle(callbacks); - - if (cc.getSelectedIndex() == ConfirmationCallback.YES) { - System.out.println("yes"); - } else { - System.out.println("no"); - } - - System.exit(0); - } -} diff --git a/jdk/test/com/sun/security/sasl/digest/NoQuoteParams.java b/jdk/test/com/sun/security/sasl/digest/NoQuoteParams.java index f8e40204f24..11184674a9c 100644 --- a/jdk/test/com/sun/security/sasl/digest/NoQuoteParams.java +++ b/jdk/test/com/sun/security/sasl/digest/NoQuoteParams.java @@ -43,8 +43,6 @@ import javax.security.sasl.SaslClient; import javax.security.sasl.SaslException; import javax.security.sasl.SaslServer; import javax.security.auth.callback.CallbackHandler; -import com.sun.security.auth.callback.DialogCallbackHandler; -import com.sun.security.auth.callback.TextCallbackHandler; /* * According to RFC 2831, DIGEST-MD5 servers must generate challenge strings diff --git a/jdk/test/demo/jvmti/Context.java b/jdk/test/demo/jvmti/Context.java index 611d80588bb..2bb822ffbaa 100644 --- a/jdk/test/demo/jvmti/Context.java +++ b/jdk/test/demo/jvmti/Context.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -167,11 +167,16 @@ public final class Context extends Thread { turn.notifyAll(); } /* If we've had all our turns, break out of this loop */ - if ( thread_turns == turns_taken ) { + if (thread_turns == turns_taken) { + System.out.println("Loop end: thread got " + turns_taken + + " turns, expected " + thread_turns); break; } } - } catch (InterruptedException intEx) { /* skip */ } + } catch (InterruptedException intEx) { + System.out.println("Got an InterruptedException:" + intEx); + /* skip */ + } /* Make sure we got all our turns */ if ( thread_turns != turns_taken ) { diff --git a/jdk/test/demo/jvmti/hprof/StackMapTableTest.java b/jdk/test/demo/jvmti/hprof/StackMapTableTest.java index eb3fae1300b..758fdaec57e 100644 --- a/jdk/test/demo/jvmti/hprof/StackMapTableTest.java +++ b/jdk/test/demo/jvmti/hprof/StackMapTableTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2009, 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 @@ -27,7 +27,7 @@ * @summary Test jvmti hprof and java_crw_demo with StackMapTable attributes * * @compile ../DemoRun.java - * @compile -source 7 -g:lines HelloWorld.java + * @compile -g:lines HelloWorld.java * @build StackMapTableTest * @run main StackMapTableTest HelloWorld */ diff --git a/jdk/test/java/awt/Toolkit/AutoShutdown/ShowExitTest/ShowExitTest.sh b/jdk/test/java/awt/Toolkit/AutoShutdown/ShowExitTest/ShowExitTest.sh index 148041c2825..f772c25245f 100644 --- a/jdk/test/java/awt/Toolkit/AutoShutdown/ShowExitTest/ShowExitTest.sh +++ b/jdk/test/java/awt/Toolkit/AutoShutdown/ShowExitTest/ShowExitTest.sh @@ -102,6 +102,14 @@ case "$OS" in TMP=`cd "${SystemRoot}/Temp"; echo ${PWD}` ;; + AIX ) + VAR="A different value for AIX" + DEFAULT_JDK=/ + FILESEP="/" + PATHSEP=":" + TMP="/tmp" + ;; + # catch all other OSs * ) echo "Unrecognized system! $OS" diff --git a/jdk/test/java/awt/appletviewer/IOExceptionIfEncodedURLTest/IOExceptionIfEncodedURLTest.sh b/jdk/test/java/awt/appletviewer/IOExceptionIfEncodedURLTest/IOExceptionIfEncodedURLTest.sh index ccbea0c7ed0..d8880392570 100644 --- a/jdk/test/java/awt/appletviewer/IOExceptionIfEncodedURLTest/IOExceptionIfEncodedURLTest.sh +++ b/jdk/test/java/awt/appletviewer/IOExceptionIfEncodedURLTest/IOExceptionIfEncodedURLTest.sh @@ -135,6 +135,14 @@ case "$OS" in TMP=`cd "${SystemRoot}/Temp"; echo ${PWD}` ;; + AIX ) + VAR="A different value for AIX" + DEFAULT_JDK=/ + FILESEP="/" + PATHSEP=":" + TMP="/tmp" + ;; + # catch all other OSs * ) echo "Unrecognized system! $OS" diff --git a/jdk/test/java/io/Serializable/evolution/RenamePackage/run.sh b/jdk/test/java/io/Serializable/evolution/RenamePackage/run.sh index deda2826115..f37159d6899 100644 --- a/jdk/test/java/io/Serializable/evolution/RenamePackage/run.sh +++ b/jdk/test/java/io/Serializable/evolution/RenamePackage/run.sh @@ -45,7 +45,7 @@ OS=`uname -s` # Need to determine the classpath separator and filepath separator based on the # operating system. case "$OS" in -SunOS | Linux | Darwin ) +SunOS | Linux | Darwin | AIX ) PS=":" ;; Windows* | CYGWIN* ) PS=";" ;; diff --git a/jdk/test/java/io/Serializable/serialver/classpath/run.sh b/jdk/test/java/io/Serializable/serialver/classpath/run.sh index 8c6b9f3d0be..2aa1b0e92ea 100644 --- a/jdk/test/java/io/Serializable/serialver/classpath/run.sh +++ b/jdk/test/java/io/Serializable/serialver/classpath/run.sh @@ -47,7 +47,7 @@ fi # set platform-dependent variables OS=`uname -s` case "$OS" in - SunOS | Linux | Darwin ) + SunOS | Linux | Darwin | AIX ) PS=":" ;; Windows* | CYGWIN* ) PS=";" ;; diff --git a/jdk/test/java/io/Serializable/serialver/nested/run.sh b/jdk/test/java/io/Serializable/serialver/nested/run.sh index 765d2d41c41..578e74afc51 100644 --- a/jdk/test/java/io/Serializable/serialver/nested/run.sh +++ b/jdk/test/java/io/Serializable/serialver/nested/run.sh @@ -47,7 +47,7 @@ fi # set platform-dependent variables OS=`uname -s` case "$OS" in - SunOS | Linux | Darwin ) + SunOS | Linux | Darwin | AIX ) PS=":" ;; Windows* | CYGWIN* ) PS=";" ;; diff --git a/jdk/test/java/lang/ClassLoader/deadlock/TestCrossDelegate.sh b/jdk/test/java/lang/ClassLoader/deadlock/TestCrossDelegate.sh index 24b129aecbc..c86a4c00f73 100644 --- a/jdk/test/java/lang/ClassLoader/deadlock/TestCrossDelegate.sh +++ b/jdk/test/java/lang/ClassLoader/deadlock/TestCrossDelegate.sh @@ -58,6 +58,9 @@ case "$OS" in Darwin ) FS="/" ;; + AIX ) + FS="/" + ;; Windows*) FS="\\" ;; diff --git a/jdk/test/java/lang/ClassLoader/deadlock/TestOneWayDelegate.sh b/jdk/test/java/lang/ClassLoader/deadlock/TestOneWayDelegate.sh index 6d5aabb0728..49abefef8b4 100644 --- a/jdk/test/java/lang/ClassLoader/deadlock/TestOneWayDelegate.sh +++ b/jdk/test/java/lang/ClassLoader/deadlock/TestOneWayDelegate.sh @@ -63,6 +63,9 @@ case "$OS" in Darwin ) FS="/" ;; + AIX ) + FS="/" + ;; Windows* | CYGWIN* ) FS="\\" ;; diff --git a/jdk/test/tools/pack200/Reflect.java b/jdk/test/java/lang/ClassLoader/getResource/GetResource.java similarity index 58% rename from jdk/test/tools/pack200/Reflect.java rename to jdk/test/java/lang/ClassLoader/getResource/GetResource.java index 27287abab6d..1eb62d0bf24 100644 --- a/jdk/test/tools/pack200/Reflect.java +++ b/jdk/test/java/lang/ClassLoader/getResource/GetResource.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 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 @@ -21,27 +21,22 @@ * questions. */ -/* @test - * @summary Invoke getDeclaredMethods on Packer and Unpacker to ensure - * that all types referenced in the method signatures is present. - */ +import java.net.URL; -import java.util.jar.Pack200; -import java.util.jar.Pack200.Packer; -import java.util.jar.Pack200.Unpacker; -import java.lang.reflect.Method; +public class GetResource { + private static final String RESOURCE_NAME = "test.properties"; + public static void main(String[] args) { + String expect = args[0] + "/" + RESOURCE_NAME; + URL url = GetResource.class.getResource(RESOURCE_NAME); + System.out.println("getResource found: " + url); + if (!url.toString().endsWith(expect)) { + throw new RuntimeException(url + " != expected resource " + expect); + } -public class Reflect { - static void printMethods(Class c) { - System.out.println(c); - for (Method m: c.getDeclaredMethods()) { - System.out.println(" " + m); + url = ClassLoader.getSystemResource(RESOURCE_NAME); + System.out.println("getSystemResource found: " + url); + if (!url.toString().endsWith(expect)) { + throw new RuntimeException(url + " != expected resource " + expect); } } - public static void main(String[] args) { - printMethods(Pack200.Packer.class); - printMethods(Pack200.Unpacker.class); - printMethods(Pack200.newPacker().getClass()); - printMethods(Pack200.newUnpacker().getClass()); - } } diff --git a/jdk/test/java/lang/ClassLoader/getResource/GetResource.sh b/jdk/test/java/lang/ClassLoader/getResource/GetResource.sh new file mode 100644 index 00000000000..2f178cd20b8 --- /dev/null +++ b/jdk/test/java/lang/ClassLoader/getResource/GetResource.sh @@ -0,0 +1,124 @@ +# +# 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 6760902 +# @summary Empty path on bootclasspath is not default to current working +# directory for both class lookup and resource lookup whereas +# empty path on classpath is default to current working directory. +# +# @run shell GetResource.sh + +if [ "${TESTSRC}" = "" ] ; then + TESTSRC=`pwd` +fi +if [ "${TESTCLASSES}" = "" ] ; then + TESTCLASSES=`pwd` +fi + +if [ "${TESTJAVA}" = "" ] ; then + echo "TESTJAVA not set. Test cannot execute." + echo "FAILED!!!" + exit 1 +fi + +if [ "${COMPILEJAVA}" = "" ] ; then + COMPILEJAVA="${TESTJAVA}" +fi + +# set platform-specific variables +OS=`uname -s` +case "$OS" in + Windows*) + PS=";" + ;; + CYGWIN* ) + PS=";" + TESTCLASSES=`/usr/bin/cygpath -a -s -m ${TESTCLASSES}` + ;; + * ) + PS=":" + ;; +esac + +echo TESTSRC=${TESTSRC} +echo TESTCLASSES=${TESTCLASSES} +echo TESTJAVA=${TESTJAVA} +echo "" + +${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} \ + -d ${TESTCLASSES} \ + ${TESTSRC}/GetResource.java || exit 10 + +setup() { + dest=${TESTCLASSES}/$1 + rm -rf $dest + mkdir $dest + cp ${TESTSRC}/test.properties $dest + cp ${TESTCLASSES}/GetResource.class $dest +} + + +count=0 +runTest() { + expected=$1; + vmoption=$2; shift; shift + count=`expr $count+1` + echo "Test $count : $vmoption $@" + ${TESTJAVA}/bin/java ${TESTVMOPTS} "$vmoption" $@ \ + GetResource $expected || exit $count +} + +# run test +setup "a" +setup "b" + +cd ${TESTCLASSES} +DIR=`pwd` + +# Expected -Xbootclasspath +# Location or -classpath +runTest "a" "-Xbootclasspath/p:a" +runTest "a" "-Xbootclasspath/p:a${PS}b" +runTest "b" "-Xbootclasspath/p:b" +runTest "b" "-Xbootclasspath/p:b${PS}a" +runTest "a" -cp a +runTest "a" -cp "a${PS}b" +runTest "b" -cp b +runTest "b" -cp "b${PS}a" + +cd ${DIR}/a + +runTest "a" "-Xbootclasspath/p:." +runTest "b" "-Xbootclasspath/p:../b" + +# no -classpath +runTest "a" -cp "${PS}" +runTest "b" -cp "../b" + +# Test empty path in bootclasspath not default to current working directory +runTest "b" "-Xbootclasspath/p:${PS}../b" + +# Test empty path in classpath default to current working directory +runTest "a" -cp "${PS}../b" + diff --git a/jdk/test/java/lang/ClassLoader/getResource/test.properties b/jdk/test/java/lang/ClassLoader/getResource/test.properties new file mode 100644 index 00000000000..64ec12be2bd --- /dev/null +++ b/jdk/test/java/lang/ClassLoader/getResource/test.properties @@ -0,0 +1 @@ +# empty resource diff --git a/jdk/test/java/lang/Long/Unsigned.java b/jdk/test/java/lang/Long/Unsigned.java index 2ccbc8d509a..3686457ffe6 100644 --- a/jdk/test/java/lang/Long/Unsigned.java +++ b/jdk/test/java/lang/Long/Unsigned.java @@ -23,7 +23,7 @@ /* * @test - * @bug 4504839 4215269 6322074 + * @bug 4504839 4215269 6322074 8030814 * @summary Basic tests for unsigned operations * @author Joseph D. Darcy */ @@ -310,6 +310,55 @@ public class Unsigned { } } + // test case known at one time to fail + errors += testUnsignedOverflow("1234567890abcdef1", 16, true); + + // largest value with guard = 91 = 13*7; radix = 13 + errors += testUnsignedOverflow("196a78a44c3bba320c", 13, false); + + // smallest value with guard = 92 = 23*2*2; radix = 23 + errors += testUnsignedOverflow("137060c6g1c1dg0", 23, false); + + // guard in [92,98]: no overflow + + // one less than smallest guard value to overflow: guard = 99 = 11*3*3, radix = 33 + errors += testUnsignedOverflow("b1w8p7j5q9r6f", 33, false); + + // smallest guard value to overflow: guard = 99 = 11*3*3, radix = 33 + errors += testUnsignedOverflow("b1w8p7j5q9r6g", 33, true); + + // test overflow of overflow + BigInteger maxUnsignedLong = + BigInteger.ONE.shiftLeft(64).subtract(BigInteger.ONE); + for (int radix = Character.MIN_RADIX; radix <= Character.MAX_RADIX; radix++) { + BigInteger quotient = maxUnsignedLong.divide(BigInteger.valueOf(radix)); + for (int addend = 2; addend <= radix; addend++) { + BigInteger b = quotient.multiply(BigInteger.valueOf(radix + addend)); + errors += testUnsignedOverflow(b.toString(radix), radix, b.compareTo(maxUnsignedLong) > 0); + } + } + + return errors; + } + + // test for missing or unexpected unsigned overflow exception + private static int testUnsignedOverflow(String s, int radix, boolean exception) { + int errors = 0; + long result; + try { + result = Long.parseUnsignedLong(s, radix); + if (exception) { + System.err.printf("Unexpected result %d for Long.parseUnsignedLong(%s,%d)\n", + result, s, radix); + errors++; + } + } catch (NumberFormatException nfe) { + if (!exception) { + System.err.printf("Unexpected exception %s for Long.parseUnsignedLong(%s,%d)\n", + nfe.toString(), s, radix); + errors++; + } + } return errors; } diff --git a/jdk/test/java/lang/ProcessBuilder/Basic.java b/jdk/test/java/lang/ProcessBuilder/Basic.java index ff4c3744321..ce0bad7772f 100644 --- a/jdk/test/java/lang/ProcessBuilder/Basic.java +++ b/jdk/test/java/lang/ProcessBuilder/Basic.java @@ -38,6 +38,9 @@ import static java.lang.ProcessBuilder.Redirect.*; import java.io.*; import java.lang.reflect.Field; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; import java.util.*; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; @@ -58,6 +61,18 @@ public class Basic { /* used for Mac OS X only */ static final String cfUserTextEncoding = System.getenv("__CF_USER_TEXT_ENCODING"); + /* used for AIX only */ + static final String libpath = System.getenv("LIBPATH"); + + /** + * Returns the number of milliseconds since time given by + * startNanoTime, which must have been previously returned from a + * call to {@link System.nanoTime()}. + */ + private static long millisElapsedSince(long startNanoTime) { + return TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startNanoTime); + } + private static String commandOutput(Reader r) throws Throwable { StringBuilder sb = new StringBuilder(); int c; @@ -75,7 +90,11 @@ public class Basic { String output = commandOutput(r); equal(p.waitFor(), 0); equal(p.exitValue(), 0); - return output; + // The debug/fastdebug versions of the VM may write some warnings to stdout + // (i.e. "Warning: Cannot open log file: hotspot.log" if the VM is started + // in a directory without write permissions). These warnings will confuse tests + // which match the entire output of the child process so better filter them out. + return output.replaceAll("Warning:.*\\n", ""); } private static String commandOutput(ProcessBuilder pb) { @@ -515,18 +534,9 @@ public class Basic { } } - private static void copy(String src, String dst) { - system("/bin/cp", "-fp", src, dst); - } - - private static void system(String... command) { - try { - ProcessBuilder pb = new ProcessBuilder(command); - ProcessResults r = run(pb.start()); - equal(r.exitValue(), 0); - equal(r.out(), ""); - equal(r.err(), ""); - } catch (Throwable t) { unexpected(t); } + private static void copy(String src, String dst) throws IOException { + Files.copy(Paths.get(src), Paths.get(dst), + StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.COPY_ATTRIBUTES); } private static String javaChildOutput(ProcessBuilder pb, String...args) { @@ -585,6 +595,12 @@ public class Basic { System.getProperty("os.name").startsWith("Windows"); } + static class AIX { + public static boolean is() { return is; } + private static final boolean is = + System.getProperty("os.name").equals("AIX"); + } + static class Unix { public static boolean is() { return is; } private static final boolean is = @@ -638,7 +654,7 @@ public class Basic { private static boolean isEnglish(String envvar) { String val = getenv(envvar); - return (val == null) || val.matches("en.*"); + return (val == null) || val.matches("en.*") || val.matches("C"); } /** Returns true if we can expect English OS error strings */ @@ -713,6 +729,14 @@ public class Basic { return cleanedVars.replace(javaMainClassStr,""); } + /* Only used for AIX -- + * AIX adds the variable AIXTHREAD_GUARDPAGES=0 to the environment. + * Remove it from the list of env variables + */ + private static String removeAixExpectedVars(String vars) { + return vars.replace("AIXTHREAD_GUARDPAGES=0,",""); + } + private static String sortByLinesWindowsly(String text) { String[] lines = text.split("\n"); Arrays.sort(lines, new WindowsComparator()); @@ -1161,13 +1185,20 @@ public class Basic { ProcessBuilder pb = new ProcessBuilder(); pb.environment().clear(); String expected = Windows.is() ? "SystemRoot="+systemRoot+",": ""; + expected = AIX.is() ? "LIBPATH="+libpath+",": expected; if (Windows.is()) { pb.environment().put("SystemRoot", systemRoot); } + if (AIX.is()) { + pb.environment().put("LIBPATH", libpath); + } String result = getenvInChild(pb); if (MacOSX.is()) { result = removeMacExpectedVars(result); } + if (AIX.is()) { + result = removeAixExpectedVars(result); + } equal(result, expected); } catch (Throwable t) { unexpected(t); } @@ -1682,10 +1713,14 @@ public class Basic { } Process p = Runtime.getRuntime().exec(cmdp, envp); String expected = Windows.is() ? "=C:=\\,=ExitValue=3,SystemRoot="+systemRoot+"," : "=C:=\\,"; + expected = AIX.is() ? expected + "LIBPATH="+libpath+",": expected; String commandOutput = commandOutput(p); if (MacOSX.is()) { commandOutput = removeMacExpectedVars(commandOutput); } + if (AIX.is()) { + commandOutput = removeAixExpectedVars(commandOutput); + } equal(commandOutput, expected); if (Windows.is()) { ProcessBuilder pb = new ProcessBuilder(childArgs); @@ -1737,9 +1772,14 @@ public class Basic { if (MacOSX.is()) { commandOutput = removeMacExpectedVars(commandOutput); } + if (AIX.is()) { + commandOutput = removeAixExpectedVars(commandOutput); + } check(commandOutput.equals(Windows.is() ? "LC_ALL=C,SystemRoot="+systemRoot+"," - : "LC_ALL=C,"), + : AIX.is() + ? "LC_ALL=C,LIBPATH="+libpath+"," + : "LC_ALL=C,"), "Incorrect handling of envstrings containing NULs"); } catch (Throwable t) { unexpected(t); } @@ -2016,8 +2056,13 @@ public class Basic { if (Unix.is() && new File("/bin/bash").exists() && new File("/bin/sleep").exists()) { - final String[] cmd = { "/bin/bash", "-c", "(/bin/sleep 6666)" }; - final String[] cmdkill = { "/bin/bash", "-c", "(/usr/bin/pkill -f \"sleep 6666\")" }; + // Notice that we only destroy the process created by us (i.e. + // our child) but not our grandchild (i.e. '/bin/sleep'). So + // pay attention that the grandchild doesn't run too long to + // avoid polluting the process space with useless processes. + // Running the grandchild for 60s should be more than enough. + final String[] cmd = { "/bin/bash", "-c", "(/bin/sleep 60)" }; + final String[] cmdkill = { "/bin/bash", "-c", "(/usr/bin/pkill -f \"sleep 60\")" }; final ProcessBuilder pb = new ProcessBuilder(cmd); final Process p = pb.start(); final InputStream stdout = p.getInputStream(); @@ -2039,13 +2084,27 @@ public class Basic { reader.start(); Thread.sleep(100); p.destroy(); - // Subprocess is now dead, but file descriptors remain open. check(p.waitFor() != 0); check(p.exitValue() != 0); + // Subprocess is now dead, but file descriptors remain open. + // Make sure the test will fail if we don't manage to close + // the open streams within 30 seconds. Notice that this time + // must be shorter than the sleep time of the grandchild. + Timer t = new Timer("test/java/lang/ProcessBuilder/Basic.java process reaper", true); + t.schedule(new TimerTask() { + public void run() { + fail("Subprocesses which create subprocesses of " + + "their own caused the parent to hang while " + + "waiting for file descriptors to be closed."); + System.exit(-1); + } + }, 30000); stdout.close(); stderr.close(); stdin.close(); new ProcessBuilder(cmdkill).start(); + // All streams successfully closed so we can cancel the timer. + t.cancel(); //---------------------------------------------------------- // There remain unsolved issues with asynchronous close. // Here's a highly non-portable experiment to demonstrate: @@ -2191,8 +2250,9 @@ public class Basic { } long end = System.nanoTime(); // give waitFor(timeout) a wide berth (100ms) - if ((end - start) > 100000000) - fail("Test failed: waitFor took too long"); + // Old AIX machines my need a little longer. + if ((end - start) > 100000000L * (AIX.is() ? 4 : 1)) + fail("Test failed: waitFor took too long (" + (end - start) + "ns)"); p.destroy(); p.waitFor(); @@ -2219,7 +2279,7 @@ public class Basic { long end = System.nanoTime(); if ((end - start) < 500000000) - fail("Test failed: waitFor didn't take long enough"); + fail("Test failed: waitFor didn't take long enough (" + (end - start) + "ns)"); p.destroy(); @@ -2227,45 +2287,71 @@ public class Basic { p.waitFor(1000, TimeUnit.MILLISECONDS); end = System.nanoTime(); if ((end - start) > 900000000) - fail("Test failed: waitFor took too long on a dead process."); + fail("Test failed: waitFor took too long on a dead process. (" + (end - start) + "ns)"); } catch (Throwable t) { unexpected(t); } //---------------------------------------------------------------- // Check that Process.waitFor(timeout, TimeUnit.MILLISECONDS) - // interrupt works as expected. + // interrupt works as expected, if interrupted while waiting. //---------------------------------------------------------------- try { List childArgs = new ArrayList(javaChildArgs); childArgs.add("sleep"); final Process p = new ProcessBuilder(childArgs).start(); final long start = System.nanoTime(); - final CountDownLatch ready = new CountDownLatch(1); - final CountDownLatch done = new CountDownLatch(1); + final CountDownLatch aboutToWaitFor = new CountDownLatch(1); final Thread thread = new Thread() { public void run() { try { - final boolean result; - try { - ready.countDown(); - result = p.waitFor(30000, TimeUnit.MILLISECONDS); - } catch (InterruptedException e) { - return; - } + aboutToWaitFor.countDown(); + boolean result = p.waitFor(30L * 1000L, TimeUnit.MILLISECONDS); fail("waitFor() wasn't interrupted, its return value was: " + result); - } catch (Throwable t) { - unexpected(t); - } finally { - done.countDown(); - } + } catch (InterruptedException success) { + } catch (Throwable t) { unexpected(t); } } }; thread.start(); - ready.await(); + aboutToWaitFor.await(); Thread.sleep(1000); thread.interrupt(); - done.await(); + thread.join(10L * 1000L); + check(millisElapsedSince(start) < 10L * 1000L); + check(!thread.isAlive()); + p.destroy(); + } catch (Throwable t) { unexpected(t); } + + //---------------------------------------------------------------- + // Check that Process.waitFor(timeout, TimeUnit.MILLISECONDS) + // interrupt works as expected, if interrupted before waiting. + //---------------------------------------------------------------- + try { + List childArgs = new ArrayList(javaChildArgs); + childArgs.add("sleep"); + final Process p = new ProcessBuilder(childArgs).start(); + final long start = System.nanoTime(); + final CountDownLatch threadStarted = new CountDownLatch(1); + + final Thread thread = new Thread() { + public void run() { + try { + threadStarted.countDown(); + do { Thread.yield(); } + while (!Thread.currentThread().isInterrupted()); + boolean result = p.waitFor(30L * 1000L, TimeUnit.MILLISECONDS); + fail("waitFor() wasn't interrupted, its return value was: " + result); + } catch (InterruptedException success) { + } catch (Throwable t) { unexpected(t); } + } + }; + + thread.start(); + threadStarted.await(); + thread.interrupt(); + thread.join(10L * 1000L); + check(millisElapsedSince(start) < 10L * 1000L); + check(!thread.isAlive()); p.destroy(); } catch (Throwable t) { unexpected(t); } @@ -2441,7 +2527,7 @@ public class Basic { static void check(boolean cond, String m) {if (cond) pass(); else fail(m);} static void equal(Object x, Object y) { if (x == null ? y == null : x.equals(y)) pass(); - else fail(x + " not equal to " + y);} + else fail(">'" + x + "'<" + " not equal to " + "'" + y + "'");} public static void main(String[] args) throws Throwable { try {realMain(args);} catch (Throwable t) {unexpected(t);} diff --git a/jdk/test/java/lang/ProcessBuilder/DestroyTest.java b/jdk/test/java/lang/ProcessBuilder/DestroyTest.java index ebf00e32b79..401bd146c28 100644 --- a/jdk/test/java/lang/ProcessBuilder/DestroyTest.java +++ b/jdk/test/java/lang/ProcessBuilder/DestroyTest.java @@ -154,6 +154,9 @@ public class DestroyTest { } else if (osName.equals("SunOS")) { return new UnixTest( File.createTempFile("ProcessTrap-", ".sh",null)); + } else if (osName.equals("AIX")) { + return new UnixTest( + File.createTempFile("ProcessTrap-", ".sh",null)); } return null; } diff --git a/jdk/test/java/lang/SecurityManager/CheckPackageAccess.java b/jdk/test/java/lang/SecurityManager/CheckPackageAccess.java index ac206c6c705..a8e75896a6f 100644 --- a/jdk/test/java/lang/SecurityManager/CheckPackageAccess.java +++ b/jdk/test/java/lang/SecurityManager/CheckPackageAccess.java @@ -23,7 +23,7 @@ /* * @test - * @bug 6741606 7146431 8000450 8019830 + * @bug 6741606 7146431 8000450 8019830 8022945 * @summary Make sure all restricted packages listed in the package.access * property in the java.security file are blocked * @run main/othervm CheckPackageAccess @@ -56,6 +56,7 @@ public class CheckPackageAccess { "com.sun.istack.internal.", "com.sun.jmx.", "com.sun.media.sound.", + "com.sun.naming.internal.", "com.sun.proxy.", "com.sun.corba.se.", "com.sun.org.apache.bcel.internal.", diff --git a/jdk/test/java/lang/SecurityManager/NoAWT.java b/jdk/test/java/lang/SecurityManager/NoAWT.java index d55e05c1027..83a6fb6105c 100644 --- a/jdk/test/java/lang/SecurityManager/NoAWT.java +++ b/jdk/test/java/lang/SecurityManager/NoAWT.java @@ -22,9 +22,9 @@ */ /* @test - * @bug 8004502 8008793 - * @summary Sanity check that SecurityManager methods that check AWTPermission - * behave as expected when AWT is not present + * @bug 8004502 8008793 8029886 + * @summary Sanity check that SecurityManager methods that used to check + * AWTPermission now check for AllPermission */ import java.security.AllPermission; @@ -33,9 +33,9 @@ import java.security.Permission; public class NoAWT { static class MySecurityManager extends SecurityManager { - Class expectedClass; + final Class expectedClass; - void setExpectedPermissionClass(Class c) { + MySecurityManager(Class c) { expectedClass = c; } @@ -48,17 +48,7 @@ public class NoAWT { } public static void main(String[] args) { - Class awtPermissionClass = null; - try { - awtPermissionClass = Class.forName("java.awt.AWTPermission"); - } catch (ClassNotFoundException ignore) { } - - MySecurityManager sm = new MySecurityManager(); - if (awtPermissionClass != null) { - sm.setExpectedPermissionClass(awtPermissionClass); - } else { - sm.setExpectedPermissionClass(AllPermission.class); - } + MySecurityManager sm = new MySecurityManager(AllPermission.class); try { sm.checkAwtEventQueueAccess(); diff --git a/jdk/test/java/lang/StringCoding/CheckEncodings.sh b/jdk/test/java/lang/StringCoding/CheckEncodings.sh index edc5f9a4e49..2936d9cae65 100644 --- a/jdk/test/java/lang/StringCoding/CheckEncodings.sh +++ b/jdk/test/java/lang/StringCoding/CheckEncodings.sh @@ -30,7 +30,7 @@ # set platform-dependent variables OS=`uname -s` case "$OS" in - SunOS | Linux | Darwin) ;; + SunOS | Linux | Darwin | AIX ) ;; Windows* | CYGWIN* ) echo "Passed"; exit 0 ;; * ) echo "Unrecognized system!" ; exit 1 ;; diff --git a/jdk/test/java/lang/System/SetPropertiesNull.java b/jdk/test/java/lang/System/SetPropertiesNull.java new file mode 100644 index 00000000000..11e854d81d8 --- /dev/null +++ b/jdk/test/java/lang/System/SetPropertiesNull.java @@ -0,0 +1,44 @@ +/* + * 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. + */ + +/* + * This class tests to see if the system property java.version is properly + * reinitialized after setting System.setProperties(null). + * + * @test + * @bug 8030781 + * @summary Test for System.setProperties(null). + */ + +public class SetPropertiesNull { + + public static void main(String args[]) { + final String version = System.getProperty("java.version"); + System.setProperties(null); + final String newVersion = System.getProperty("java.version"); + if (!version.equals(newVersion)) { + throw new RuntimeException("java.version differs: '" + version + "' '" + + newVersion + "'"); + } + } +} diff --git a/jdk/test/java/lang/annotation/loaderLeak/LoaderLeak.sh b/jdk/test/java/lang/annotation/loaderLeak/LoaderLeak.sh index e62a63cd8a5..915aa9558ff 100644 --- a/jdk/test/java/lang/annotation/loaderLeak/LoaderLeak.sh +++ b/jdk/test/java/lang/annotation/loaderLeak/LoaderLeak.sh @@ -48,7 +48,7 @@ echo "CLASSPATH=${CLASSPATH}" # set platform-dependent variables OS=`uname -s` case "$OS" in - SunOS | Linux | Darwin) + SunOS | Linux | Darwin | AIX ) NULL=/dev/null PS=":" FS="/" diff --git a/jdk/test/tools/pack200/NoBeans.java b/jdk/test/java/lang/instrument/DaemonThread/DummyAgent.java similarity index 51% rename from jdk/test/tools/pack200/NoBeans.java rename to jdk/test/java/lang/instrument/DaemonThread/DummyAgent.java index c900940e274..64b4d59cf18 100644 --- a/jdk/test/tools/pack200/NoBeans.java +++ b/jdk/test/java/lang/instrument/DaemonThread/DummyAgent.java @@ -1,5 +1,6 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright 2014 Goldman Sachs. + * 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 @@ -21,29 +22,25 @@ * questions. */ -/* @test - * @bug 8004931 - * @compile NoBeans.java - * @summary A compile-only test to ensure that implementations of Packer - * and Unpacker can be compiled without implementating the - * addPropertyChangeListener and removePropertyChangeListener methods. - */ +import java.lang.instrument.ClassFileTransformer; +import java.lang.instrument.IllegalClassFormatException; +import java.lang.instrument.Instrumentation; +import java.security.ProtectionDomain; -import java.io.*; -import java.util.*; -import java.util.jar.*; +public class DummyAgent implements ClassFileTransformer { + @Override + public byte[] transform(ClassLoader loader, String className, + Class classBeingRedefined, ProtectionDomain protectionDomain, + byte[] classfileBuffer) throws IllegalClassFormatException { -public class NoBeans { - - static class MyPacker implements Pack200.Packer { - public SortedMap properties() { return null; } - public void pack(JarFile in, OutputStream out) { } - public void pack(JarInputStream in, OutputStream out) { } + /* The Daemon Thread bug is timing dependent and you want the transform method + * to return ASAP - so just return the buffer will be fine + */ + return classfileBuffer; } - static class MyUnpacker implements Pack200.Unpacker { - public SortedMap properties() { return null; } - public void unpack(InputStream in, JarOutputStream out) { } - public void unpack(File in, JarOutputStream out) { } + public static void premain(String agentArgs, Instrumentation inst) { + inst.addTransformer(new DummyAgent(), false); } + } diff --git a/langtools/test/tools/javac/Source5.java b/jdk/test/java/lang/instrument/DaemonThread/DummyClass.java similarity index 71% rename from langtools/test/tools/javac/Source5.java rename to jdk/test/java/lang/instrument/DaemonThread/DummyClass.java index 0b35c4cb651..18d671afc09 100644 --- a/langtools/test/tools/javac/Source5.java +++ b/jdk/test/java/lang/instrument/DaemonThread/DummyClass.java @@ -1,5 +1,6 @@ /* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright 2014 Goldman Sachs. + * 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 @@ -21,19 +22,6 @@ * questions. */ -/* - * @test - * @bug 5044157 - * @summary please accept -source 5 and -target 5 - * @author Peter von der Ahé - * - * @compile -source 5 -target 5 -encoding iso-8859-1 Source5.java - * @run main Source5 - */ - -public enum Source5 { - JDK5; - public static void main(String[] args) { - System.out.println("Hello, world!"); - } +/* Just a dummy class for loading */ +public class DummyClass { } diff --git a/jdk/test/java/lang/instrument/DaemonThread/TestDaemonThread.java b/jdk/test/java/lang/instrument/DaemonThread/TestDaemonThread.java new file mode 100644 index 00000000000..20c9077d02f --- /dev/null +++ b/jdk/test/java/lang/instrument/DaemonThread/TestDaemonThread.java @@ -0,0 +1,72 @@ +/* + * Copyright 2014 Goldman Sachs. + * 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 7142035 + * @summary Assert in java.lang.instrument agents during shutdown when classloading occurs after shutdown + * @library /lib/testlibrary + * + * @build DummyAgent DummyClass TestDaemonThreadLauncher TestDaemonThread + * @run shell ../MakeJAR3.sh DummyAgent + * @run main TestDaemonThreadLauncher /timeout=240 + * + */ +import java.io.File; +import java.net.URL; +import java.net.URLClassLoader; + +public class TestDaemonThread implements Runnable{ + File classpath; + + public TestDaemonThread(File classpath) { + this.classpath = classpath; + } + + @Override + public void run() { + + + try { + URL u = this.getClass().getClassLoader().getResource("DummyClass.class"); + String path = u.getPath(); + String parent = u.getPath().substring(0, path.lastIndexOf('/')+1); + URL parentURL = new URL(u, parent); + System.out.println(parentURL); + /* Load lots of class by creating multiple classloaders */ + for(;;) { + ClassLoader cl = new URLClassLoader(new URL[] {parentURL}, null); + cl.loadClass("DummyClass"); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + public static void main(String[] args) throws Exception { + Thread t = new Thread(new TestDaemonThread(new File(args[0]))); + /* The important part of the bug is that a Daemon thread can continue to load classes after shutdown */ + t.setDaemon(true); + t.start(); + Thread.sleep(200); + } +} diff --git a/jdk/test/java/lang/instrument/DaemonThread/TestDaemonThreadLauncher.java b/jdk/test/java/lang/instrument/DaemonThread/TestDaemonThreadLauncher.java new file mode 100644 index 00000000000..9660bbfa9dc --- /dev/null +++ b/jdk/test/java/lang/instrument/DaemonThread/TestDaemonThreadLauncher.java @@ -0,0 +1,44 @@ +/* + * Copyright 2014 Goldman Sachs. + * 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 jdk.testlibrary.JDKToolLauncher; +import jdk.testlibrary.OutputAnalyzer; +import jdk.testlibrary.ProcessTools; + +import java.io.IOException; +import java.nio.file.Path; + +public class TestDaemonThreadLauncher { + + private static ProcessBuilder processBuilder = new ProcessBuilder(); + + public static void main(String args[]) throws Exception { + for(int i=0; i<50; i++) { + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-javaagent:DummyAgent.jar", "TestDaemonThread", "."); + OutputAnalyzer analyzer = new OutputAnalyzer(pb.start()); + analyzer.shouldNotContain("ASSERTION FAILED"); + } + } +} diff --git a/jdk/test/java/lang/instrument/appendToClassLoaderSearch/CommonSetup.sh b/jdk/test/java/lang/instrument/appendToClassLoaderSearch/CommonSetup.sh index 3455959c3aa..c47f59de834 100644 --- a/jdk/test/java/lang/instrument/appendToClassLoaderSearch/CommonSetup.sh +++ b/jdk/test/java/lang/instrument/appendToClassLoaderSearch/CommonSetup.sh @@ -47,6 +47,10 @@ case "$OS" in PS=":" FS="/" ;; + AIX ) + PS=":" + FS="/" + ;; Windows*) PS=";" OS="Windows" diff --git a/jdk/test/java/lang/invoke/ObjectMethodInInterfaceTest.java b/jdk/test/java/lang/invoke/ObjectMethodInInterfaceTest.java new file mode 100644 index 00000000000..2ba7116200a --- /dev/null +++ b/jdk/test/java/lang/invoke/ObjectMethodInInterfaceTest.java @@ -0,0 +1,46 @@ +/* + * 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 8031502 + * @summary JSR292: IncompatibleClassChangeError in LambdaForm for CharSequence.toString() method handle type converter + * @compile ObjectMethodInInterfaceTest.java + * @run main/othervm -Djava.lang.invoke.MethodHandle.COMPILE_THRESHOLD=0 test.java.lang.invoke.ObjectMethodInInterfaceTest + */ +package test.java.lang.invoke; + +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodType; + +public class ObjectMethodInInterfaceTest { + public static void main(String[] args) throws Throwable { + MethodHandle mh = MethodHandles.lookup().findVirtual(CharSequence.class, "toString", MethodType.methodType(String.class)); + MethodType mt = MethodType.methodType(Object.class, CharSequence.class); + mh = mh.asType(mt); + + Object res = mh.invokeExact((CharSequence)"123"); + + System.out.println("TEST PASSED"); + } +} diff --git a/jdk/test/java/lang/invoke/lambda/T8032697.java b/jdk/test/java/lang/invoke/lambda/T8032697.java new file mode 100644 index 00000000000..be422a94b33 --- /dev/null +++ b/jdk/test/java/lang/invoke/lambda/T8032697.java @@ -0,0 +1,69 @@ +/* + * 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 8032697 + * @summary Issues with Lambda + */ + +import java.lang.invoke.LambdaMetafactory; +import java.lang.invoke.LambdaConversionException; +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodType; + +import T8032697_anotherpkg.T8032697_A; + +public class T8032697 extends T8032697_A { + + interface I { + int m(); + } + + interface IA { + int m(T8032697_A x); + } + + static MethodHandles.Lookup l; + static MethodHandle h; + private static MethodType mt(Class k) { return MethodType.methodType(k); } + private static MethodType mt(Class k, Class k2) { return MethodType.methodType(k, k2); } + private static boolean mf(MethodType mti, MethodType mtf) { + try { + LambdaMetafactory.metafactory(l, "m", mti,mtf,h,mtf); + } catch(LambdaConversionException e) { + return true; + } + return false; + } + + public static void main(String[] args) throws Throwable { + l = MethodHandles.lookup(); + h = l.findVirtual(T8032697_A.class, "f", mt(int.class)); + if (mf(mt(I.class, T8032697.class), mt(int.class))) throw new AssertionError("Error: Should work"); + if (mf(mt(IA.class), mt(int.class, T8032697.class))) throw new AssertionError("Error: Should work"); + if (!mf(mt(I.class, T8032697_A.class), mt(int.class))) throw new AssertionError("Error: Should fail"); + if (!mf(mt(IA.class), mt(int.class, T8032697_A.class))) throw new AssertionError("Error: Should fail"); + } +} diff --git a/langtools/test/tools/doclint/tidy/AAA.java b/jdk/test/java/lang/invoke/lambda/T8032697_anotherpkg/T8032697_A.java similarity index 74% rename from langtools/test/tools/doclint/tidy/AAA.java rename to jdk/test/java/lang/invoke/lambda/T8032697_anotherpkg/T8032697_A.java index 3880733edc9..d611e3fef6f 100644 --- a/langtools/test/tools/doclint/tidy/AAA.java +++ b/jdk/test/java/lang/invoke/lambda/T8032697_anotherpkg/T8032697_A.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 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 @@ -21,15 +21,8 @@ * questions. */ -/** - * @test - * @bug 8006728 - * @summary temporarily workaround jtreg problems for doclint tests in othervm - */ +package T8032697_anotherpkg; -// dummy test/class to be compiled before other tests in this directory -// see JDK-8006730 -public class AAA { - public static void main(String... args) { } +public class T8032697_A { + protected final int f() { return 2; } } - diff --git a/jdk/test/java/lang/invoke/lambda/T8032704.java b/jdk/test/java/lang/invoke/lambda/T8032704.java new file mode 100644 index 00000000000..9dfe3a0f108 --- /dev/null +++ b/jdk/test/java/lang/invoke/lambda/T8032704.java @@ -0,0 +1,62 @@ +/* + * 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 8032704 + * @summary Issues with lib perm in Lambda + */ + +import java.io.Closeable; +import java.lang.invoke.LambdaMetafactory; +import java.lang.invoke.LambdaConversionException; +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodType; + +public class T8032704 { + + public static void here() {} + static MethodHandle h; + private static MethodType mt(Class k) { return MethodType.methodType(k); } + private static boolean mf(MethodHandles.Lookup l) { + try { + LambdaMetafactory.metafactory(l, "close", + mt(Closeable.class),mt(void.class),h,mt(void.class)); + } catch(LambdaConversionException e) { + return true; + } + return false; + } + + public static void main(String[] args) throws Throwable { + MethodHandles.Lookup ll = MethodHandles.lookup(); + h = ll.findStatic(T8032704.class, "here", mt(void.class)); + if (mf(ll)) throw new AssertionError("Error: Should work"); + if (!mf(MethodHandles.publicLookup())) throw new AssertionError("Error: Should fail - public"); + if (!mf(ll.in(T8032704other.class))) throw new AssertionError("Error: Should fail - other"); + if (!mf(ll.in(Thread.class))) throw new AssertionError("Error: Should fail - Thread"); + } +} + +class T8032704other {} diff --git a/jdk/test/java/lang/invoke/lambda/T8032711.java b/jdk/test/java/lang/invoke/lambda/T8032711.java new file mode 100644 index 00000000000..b01009f8336 --- /dev/null +++ b/jdk/test/java/lang/invoke/lambda/T8032711.java @@ -0,0 +1,62 @@ +/* + * 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 8032711 + * @summary Issue with Lambda in handling + */ + +import java.lang.invoke.LambdaMetafactory; +import java.lang.invoke.LambdaConversionException; +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodType; + +public class T8032711 { + + interface I { + void m(); + } + + static void here() {} + static MethodHandles.Lookup l; + static MethodHandle h; + private static MethodType mt(Class k) { return MethodType.methodType(k); } + private static boolean mf(Class k) { + try { + LambdaMetafactory.metafactory(l, "m", + mt(I.class),mt(k),h,mt(void.class)); + } catch(LambdaConversionException e) { + return true; + } + return false; + } + + public static void main(String[] args) throws Throwable { + l = MethodHandles.lookup(); + h = l.findStatic(T8032711.class, "here", mt(void.class)); + if (mf(void.class)) throw new AssertionError("Error: Should work"); + if (!mf(String.class)) throw new AssertionError("Error: Should fail"); + } +} diff --git a/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest.java b/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest.java index e83eb067790..fedb3aa655d 100644 --- a/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest.java +++ b/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest.java @@ -32,17 +32,21 @@ * * @build LowMemoryTest MemoryUtil * @run main/othervm/timeout=600 LowMemoryTest + * @run main/othervm/timeout=600 -XX:+UseConcMarkSweepGC LowMemoryTest + * @run main/othervm/timeout=600 -XX:+UseParallelGC LowMemoryTest + * @run main/othervm/timeout=600 -XX:+UseSerialGC LowMemoryTest */ import java.lang.management.*; import java.util.*; +import java.util.concurrent.Phaser; import javax.management.*; import javax.management.openmbean.CompositeData; public class LowMemoryTest { - private static MemoryMXBean mm = ManagementFactory.getMemoryMXBean(); - private static List pools = ManagementFactory.getMemoryPoolMXBeans(); - private static List managers = ManagementFactory.getMemoryManagerMXBeans(); + private static final MemoryMXBean mm = ManagementFactory.getMemoryMXBean(); + private static final List pools = ManagementFactory.getMemoryPoolMXBeans(); + private static final Phaser phaser = new Phaser(2); private static MemoryPoolMXBean mpool = null; private static boolean trace = false; private static boolean testFailed = false; @@ -50,8 +54,9 @@ public class LowMemoryTest { private static final int NUM_CHUNKS = 2; private static long chunkSize; - private static boolean listenerInvoked = false; + private static volatile boolean listenerInvoked = false; static class SensorListener implements NotificationListener { + @Override public void handleNotification(Notification notif, Object handback) { String type = notif.getType(); if (type.equals(MemoryNotificationInfo.MEMORY_THRESHOLD_EXCEEDED) || @@ -69,8 +74,9 @@ public class LowMemoryTest { static class TestListener implements NotificationListener { private int triggers = 0; - private long[] count = new long[NUM_TRIGGERS * 2]; - private long[] usedMemory = new long[NUM_TRIGGERS * 2]; + private final long[] count = new long[NUM_TRIGGERS * 2]; + private final long[] usedMemory = new long[NUM_TRIGGERS * 2]; + @Override public void handleNotification(Notification notif, Object handback) { MemoryNotificationInfo minfo = MemoryNotificationInfo. from((CompositeData) notif.getUserData()); @@ -148,15 +154,20 @@ public class LowMemoryTest { newThreshold); } + allocator.start(); + // Force Allocator start first + phaser.arriveAndAwaitAdvance(); sweeper.start(); + try { allocator.join(); + // Wait until AllocatorThread's done + phaser.arriveAndAwaitAdvance(); sweeper.join(); } catch (InterruptedException e) { - e.printStackTrace(); - System.out.println("Unexpected exception."); + System.out.println("Unexpected exception:" + e); testFailed = true; } @@ -173,45 +184,17 @@ public class LowMemoryTest { try { Thread.sleep(ms); } catch (InterruptedException e) { - e.printStackTrace(); - System.out.println("Unexpected exception."); + System.out.println("Unexpected exception:" + e); testFailed = true; } } - private static Object go = new Object(); - private static boolean waiting = false; // No thread is waiting. - - // Synchronizes two thread. If no thread is waiting then wait - // for notification from a different thread and if it is - // is waiting then send notification. - // In this test case this method is used to synchronize sweeper - // thread and alocater thread to reach a particular point. - private static void wait_or_notify() { - synchronized (go) { - if (waiting == false) { - waiting = true; - System.out.println(" Waiting "); - try { - go.wait(); - } catch (InterruptedException e) { - e.printStackTrace(); - testFailed = true; - } - waiting = false; - } else { - System.out.println(" Notify "); - go.notify(); - } - } - } - - private static List objectPool = new ArrayList(); + private static final List objectPool = new ArrayList<>(); static class AllocatorThread extends Thread { public void doTask() { int iterations = 0; int numElements = (int) (chunkSize / 4); // minimal object size - while (!listenerInvoked) { + while (!listenerInvoked || mpool.getUsage().getUsed() < mpool.getUsageThreshold()) { iterations++; if (trace) { System.out.println(" Iteration " + iterations + @@ -234,23 +217,25 @@ public class LowMemoryTest { goSleep(100); } } + @Override public void run() { for (int i = 1; i <= NUM_TRIGGERS; i++) { - System.out.println("AllocatorThread is doing task " + i); + // Sync with SweeperThread's second phase. + phaser.arriveAndAwaitAdvance(); + System.out.println("AllocatorThread is doing task " + i + + " phase " + phaser.getPhase()); doTask(); - synchronized (sweep) { - sweep.notify(); + // Sync with SweeperThread's first phase. + phaser.arriveAndAwaitAdvance(); + System.out.println("AllocatorThread done task " + i + + " phase " + phaser.getPhase()); + if (testFailed) { + return; } - // System.out.print(" Allocater Thread "); - // If sweeper thread is waiting then send notify - // else wait for notification from sweeper thread. - wait_or_notify(); - if (testFailed) return; } } } - private static Object sweep = new Object(); static class SweeperThread extends Thread { private void doTask() { for (; mpool.getUsage().getUsed() >= @@ -261,28 +246,21 @@ public class LowMemoryTest { goSleep(100); } } + @Override public void run() { for (int i = 1; i <= NUM_TRIGGERS; i++) { - synchronized (sweep) { - while (!listenerInvoked) { - try { - sweep.wait(); - } catch (InterruptedException e) { - e.printStackTrace(); - System.out.println("Unexpected exception."); - testFailed = true; - } - } - } - System.out.println("SweepThread is doing task " + i); + // Sync with AllocatorThread's first phase. + phaser.arriveAndAwaitAdvance(); + System.out.println("SweepThread is doing task " + i + + " phase " + phaser.getPhase()); doTask(); listenerInvoked = false; - // System.out.print(" Sweeper Thread "); - // If Allocater thread is waiting wait send notify - // else wait for notfication from allocater thread. - wait_or_notify(); + // Sync with AllocatorThread's second phase. + phaser.arriveAndAwaitAdvance(); + System.out.println("SweepThread done task " + i + + " phase " + phaser.getPhase()); if (testFailed) return; } } diff --git a/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTestConcMarkSweepGC.sh b/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTestConcMarkSweepGC.sh deleted file mode 100644 index 159804ddf6b..00000000000 --- a/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTestConcMarkSweepGC.sh +++ /dev/null @@ -1,52 +0,0 @@ -# -# Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute 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 4530538 -# @summary Test LowMemoryTest with concurrent mark sweep GC -# @author Mandy Chung -# -# @run build LowMemoryTest -# @run shell/timeout=600 LowMemoryTestConcMarkSweepGC.sh -# - -#Set appropriate jdk - -if [ ! -z "${TESTJAVA}" ] ; then - jdk="$TESTJAVA" -else - echo "--Error: TESTJAVA must be defined as the pathname of a jdk to test." - exit 1 -fi - -runOne() -{ - echo "runOne $@" - $TESTJAVA/bin/java ${TESTVMOPTS} -classpath $TESTCLASSES $@ || exit 2 -} - -# Test LowMemoryTest with concurrent collector -runOne -XX:+UseConcMarkSweepGC LowMemoryTest - -exit 0 diff --git a/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTestParallelGC.sh b/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTestParallelGC.sh deleted file mode 100644 index 985a2e2e4f4..00000000000 --- a/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTestParallelGC.sh +++ /dev/null @@ -1,52 +0,0 @@ -# -# Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute 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 4530538 -# @summary Test LowMemoryTest with parallel GC -# @author Mandy Chung -# -# @run build LowMemoryTest -# @run shell/timeout=600 LowMemoryTestParallelGC.sh -# - -#Set appropriate jdk - -if [ ! -z "${TESTJAVA}" ] ; then - jdk="$TESTJAVA" -else - echo "--Error: TESTJAVA must be defined as the pathname of a jdk to test." - exit 1 -fi - -runOne() -{ - echo "runOne $@" - $TESTJAVA/bin/java ${TESTVMOPTS} -classpath $TESTCLASSES $@ || exit 2 -} - -# Test LowMemoryTest with parallel scavenger collector -runOne -XX:+UseParallelGC LowMemoryTest - -exit 0 diff --git a/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTestSerialGC.sh b/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTestSerialGC.sh deleted file mode 100644 index 282901958d4..00000000000 --- a/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTestSerialGC.sh +++ /dev/null @@ -1,52 +0,0 @@ -# -# Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute 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 4530538 -# @summary Test LowMemoryTest with Serial GC -# @author Mandy Chung -# -# @run build LowMemoryTest -# @run shell/timeout=600 LowMemoryTestSerialGC.sh -# - -#Set appropriate jdk - -if [ ! -z "${TESTJAVA}" ] ; then - jdk="$TESTJAVA" -else - echo "--Error: TESTJAVA must be defined as the pathname of a jdk to test." - exit 1 -fi - -runOne() -{ - echo "runOne $@" - $TESTJAVA/bin/java ${TESTVMOPTS} -classpath $TESTCLASSES $@ || exit 2 -} - -# Test LowMemoryTest with serial collector -runOne -XX:+UseSerialGC LowMemoryTest - -exit 0 diff --git a/jdk/test/java/lang/management/MemoryMXBean/MemoryManagement.java b/jdk/test/java/lang/management/MemoryMXBean/MemoryManagement.java index d9c8d472456..4077d2a08ef 100644 --- a/jdk/test/java/lang/management/MemoryMXBean/MemoryManagement.java +++ b/jdk/test/java/lang/management/MemoryMXBean/MemoryManagement.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2010, 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 @@ -23,9 +23,9 @@ /* * @test - * @bug 4530538 + * @bug 4530538 6980984 * @summary Basic unit test of memory management testing: - * 1) setUsatgeThreshold() and getUsageThreshold() + * 1) setUsageThreshold() and getUsageThreshold() * 2) test low memory detection on the old generation. * * @author Mandy Chung @@ -40,16 +40,18 @@ import javax.management.*; import javax.management.openmbean.CompositeData; public class MemoryManagement { - private static MemoryMXBean mm = ManagementFactory.getMemoryMXBean(); - private static List pools = ManagementFactory.getMemoryPoolMXBeans(); - private static List managers = ManagementFactory.getMemoryManagerMXBeans(); - private static MemoryPoolMXBean mpool = null; - private static boolean trace = false; - private static boolean testFailed = false; + private static final MemoryMXBean mm = ManagementFactory.getMemoryMXBean(); + private static final List pools = + Collections.synchronizedList(ManagementFactory.getMemoryPoolMXBeans()); + private static final List managers = + Collections.synchronizedList(ManagementFactory.getMemoryManagerMXBeans()); + private static volatile MemoryPoolMXBean mpool = null; + private static volatile boolean trace = false; + private static volatile boolean testFailed = false; private static final int NUM_CHUNKS = 2; - private static long chunkSize; + private static volatile long chunkSize; + private static volatile int listenerInvoked = 0; - private static int listenerInvoked = 0; static class SensorListener implements NotificationListener { public void handleNotification(Notification notif, Object handback) { String type = notif.getType(); @@ -101,7 +103,13 @@ public class MemoryManagement { // Now set threshold MemoryUsage mu = mpool.getUsage(); - chunkSize = (mu.getMax() - mu.getUsed()) / 20; + long max = mu.getMax(); + if (max != -1) { + chunkSize = (max - mu.getUsed()) / 20; + } else { // 6980984 + System.gc(); + chunkSize = Runtime.getRuntime().freeMemory()/20; + } newThreshold = mu.getUsed() + (chunkSize * NUM_CHUNKS); System.out.println("Setting threshold for " + mpool.getName() + diff --git a/jdk/test/java/lang/management/OperatingSystemMXBean/TestSystemLoadAvg.sh b/jdk/test/java/lang/management/OperatingSystemMXBean/TestSystemLoadAvg.sh index 571a3d931a3..1ef2f35c8e9 100644 --- a/jdk/test/java/lang/management/OperatingSystemMXBean/TestSystemLoadAvg.sh +++ b/jdk/test/java/lang/management/OperatingSystemMXBean/TestSystemLoadAvg.sh @@ -61,7 +61,7 @@ i=1 while true; do echo "Run $i: TestSystemLoadAvg" case `uname -s` in - SunOS | Linux | Darwin ) + SunOS | Linux | Darwin | AIX ) runOne GetSystemLoadAverage ;; * ) diff --git a/jdk/test/java/lang/management/ThreadMXBean/Locks.java b/jdk/test/java/lang/management/ThreadMXBean/Locks.java index c078dccd62d..e65d3637f67 100644 --- a/jdk/test/java/lang/management/ThreadMXBean/Locks.java +++ b/jdk/test/java/lang/management/ThreadMXBean/Locks.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2010, 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 @@ -27,18 +27,19 @@ * @summary Basic unit test of ThreadInfo.getLockName() * and ThreadInfo.getLockOwnerName() * @author Mandy Chung + * @author Jaroslav Bachorik * - * @build ThreadExecutionSynchronizer * @run main/othervm Locks */ import java.lang.management.*; +import java.util.concurrent.Phaser; public class Locks { - private static Object objA = new Object(); - private static Object objB = new Object(); - private static Object objC = new Object(); - private static ThreadMXBean tm = ManagementFactory.getThreadMXBean(); + private static final Object objA = new Object(); + private static final Object objB = new Object(); + private static final Object objC = new Object(); + private static final ThreadMXBean tm = ManagementFactory.getThreadMXBean(); private static boolean testFailed = false; @@ -46,48 +47,62 @@ public class Locks { if (lock == null) return null; return lock.getClass().getName() + '@' + - Integer.toHexString(System.identityHashCode(lock)); + Integer.toHexString(System.identityHashCode(lock)); + } + + private static void assertNoLock(Thread t) { + long tid = t.getId(); + ThreadInfo info = tm.getThreadInfo(tid); + String result = info.getLockName(); + + if (result != null) { + throw new RuntimeException("Thread " + t.getName() + " is not supposed to hold any lock. " + + "Currently owning lock: " + result); + } } private static void checkBlockedObject(Thread t, Object lock, Thread owner, Thread.State expectedState) { - ThreadInfo info = tm.getThreadInfo(t.getId()); + long tid = t.getId(); + ThreadInfo info = tm.getThreadInfo(tid); String result = info.getLockName(); String expectedLock = (lock != null ? getLockName(lock) : null); String expectedOwner = (owner != null ? owner.getName() : null); if (lock != null) { - if (expectedState ==Thread.State.BLOCKED) { + if (expectedState == Thread.State.BLOCKED) { int retryCount=0; while(info.getThreadState() != Thread.State.BLOCKED) { if (retryCount++ > 500) { throw new RuntimeException("Thread " + t.getName() + - " is expected to block on " + expectedLock + - " but got " + result + - " Thread.State = " + info.getThreadState()); + " is expected to block on " + expectedLock + + " but got " + result + + " Thread.State = " + info.getThreadState()); } goSleep(100); + info = tm.getThreadInfo(tid); + result = info.getLockName(); } } if (expectedState == Thread.State.WAITING && - info.getThreadState() != Thread.State.WAITING) { + info.getThreadState() != Thread.State.WAITING) { throw new RuntimeException("Thread " + t.getName() + - " is expected to wait on " + expectedLock + - " but got " + result + - " Thread.State = " + info.getThreadState()); + " is expected to wait on " + expectedLock + + " but got " + result + + " Thread.State = " + info.getThreadState()); } } if ((result != null && !result.equals(expectedLock)) || - (result == null && expectedLock != null)) { + (result == null && expectedLock != null)) { throw new RuntimeException("Thread " + t.getName() + " is blocked on " + - expectedLock + " but got " + result); + expectedLock + " but got " + result); } result = info.getLockOwnerName(); if ((result != null && !result.equals(expectedOwner)) || - (result == null && expectedOwner != null)) { + (result == null && expectedOwner != null)) { throw new RuntimeException("Owner of " + lock + " should be " + - expectedOwner + " but got " + result); + expectedOwner + " but got " + result); } } @@ -100,53 +115,49 @@ public class Locks { } } - static ThreadExecutionSynchronizer thrsync = new ThreadExecutionSynchronizer(); - static ThreadExecutionSynchronizer thrsync1 = new ThreadExecutionSynchronizer(); + private static volatile int dummyCounter = 0; static class LockAThread extends Thread { - public LockAThread() { + private final Phaser p; + public LockAThread(Phaser p) { super("LockAThread"); + this.p = p; } public void run() { synchronized(objA) { - // stop here for LockBThread to hold objB - thrsync.waitForSignal(); - - System.out.println("LockAThread about to block on objB"); - synchronized(objB) {}; + // stop here for LockBThread to hold objB + System.out.println("LockAThread about to block on objB"); + p.arriveAndAwaitAdvance(); // Phase 1 (blocking) + synchronized(objB) { + dummyCounter++; + }; } + p.arriveAndAwaitAdvance(); // Phase 2 (blocking) System.out.println("LockAThread about to exit"); - // The state could be anything. The expected state value - // passed with this method is not verified. - checkBlockedObject(this, null, null, Thread.State.TERMINATED); + // Make sure the current thread is not holding any lock + assertNoLock(this); } } static class LockBThread extends Thread { - public LockBThread() { + private final Phaser p; + public LockBThread(Phaser p) { super("LockBThread"); + this.p = p; } public void run() { synchronized(objB) { - // signal waiting LockAThread. - thrsync.signal(); - - System.out.println("LockBThread about to block on objC"); - // Signal main thread about to block on objC - thrsync1.signal(); - synchronized(objC) {}; + System.out.println("LockBThread about to block on objC"); + p.arriveAndAwaitAdvance(); // Phase 1 (blocking) + // Signal main thread about to block on objC + synchronized(objC) { + dummyCounter++; + }; } + p.arriveAndAwaitAdvance(); // Phase 2 (blocking) System.out.println("LockBThread about to exit"); - // The state could be anything. The expected state value - // passed with this method is not verified. - checkBlockedObject(this, null, null, Thread.State.TERMINATED); - } - - public void aboutToLockC() { - // Stop here till LockBThread about to blocked - // for lock objC. - thrsync1.waitForSignal(); - goSleep(500); + // Make sure the current thread is not holding any lock + assertNoLock(this); } } @@ -154,32 +165,36 @@ public class Locks { private static Object ready = new Object(); private static CheckerThread checker; static class WaitingThread extends Thread { - public WaitingThread() { + private final Phaser p; + public WaitingThread(Phaser p) { super("WaitingThread"); + this.p = p; } public void run() { synchronized(objC) { - System.out.println("WaitingThread about to wait on objC"); - try { - // Signal checker thread, about to wait on objC. - thrsync.signal(); - objC.wait(); - } catch (InterruptedException e) { - e.printStackTrace(); - testFailed = true; - } + System.out.println("WaitingThread about to wait on objC"); + try { + // Signal checker thread, about to wait on objC. + p.arriveAndAwaitAdvance(); // Phase 1 (waiting) + objC.wait(); + } catch (InterruptedException e) { + e.printStackTrace(); + testFailed = true; + } - // block until CheckerThread finishes checking - System.out.println("WaitingThread about to block on ready"); - // signal checker thread that it is about acquire - // object ready. - thrsync.signal(); - synchronized(ready) {}; + // block until CheckerThread finishes checking + System.out.println("WaitingThread about to block on ready"); + // signal checker thread that it is about acquire + // object ready. + p.arriveAndAwaitAdvance(); // Phase 2 (waiting) + synchronized(ready) { + dummyCounter++; + }; } synchronized(objC) { try { // signal checker thread, about to wait on objC - thrsync.signal(); + p.arriveAndAwaitAdvance(); // Phase 3 (waiting) objC.wait(); } catch (InterruptedException e) { e.printStackTrace(); @@ -190,21 +205,23 @@ public class Locks { } } static class CheckerThread extends Thread { - public CheckerThread() { + private final Phaser p; + public CheckerThread(Phaser p) { super("CheckerThread"); + this.p = p; } private void waitForState(Thread.State state) { - thrsync.waitForSignal(); - while (waiter.getState() != state) { - goSleep(10); + p.arriveAndAwaitAdvance(); + while (!waiter.isInterrupted() && waiter.getState() != state) { + goSleep(10); } } public void run() { synchronized (ready) { // wait until WaitingThread about to wait for objC - waitForState(Thread.State.WAITING); + waitForState(Thread.State.WAITING); // Phase 1 (waiting) checkBlockedObject(waiter, objC, null, Thread.State.WAITING); synchronized (objC) { @@ -213,13 +230,13 @@ public class Locks { // wait for waiter thread to about to enter // synchronized object ready. - waitForState(Thread.State.BLOCKED); + waitForState(Thread.State.BLOCKED); // Phase 2 (waiting) checkBlockedObject(waiter, ready, this, Thread.State.BLOCKED); } // wait for signal from waiting thread that it is about // wait for objC. - waitForState(Thread.State.WAITING); + waitForState(Thread.State.WAITING); // Phase 3 (waiting) synchronized(objC) { checkBlockedObject(waiter, objC, Thread.currentThread(), Thread.State.WAITING); objC.notify(); @@ -235,24 +252,24 @@ public class Locks { LockAThread t1; LockBThread t2; + Phaser p = new Phaser(3); synchronized(objC) { - // The state could be anything. The expected state value - // passed with this method is not verified. - checkBlockedObject(mainThread, null, null, Thread.State.RUNNABLE); + // Make sure the main thread is not holding any lock + assertNoLock(mainThread); // Test deadlock case // t1 holds lockA and attempts to lock B // t2 holds lockB and attempts to lock C - t1 = new LockAThread(); + + t1 = new LockAThread(p); t1.start(); - t2 = new LockBThread(); + t2 = new LockBThread(p); t2.start(); - t2.aboutToLockC(); - - checkBlockedObject(t1, objB, t2, Thread.State.BLOCKED); + p.arriveAndAwaitAdvance(); // Phase 1 (blocking) checkBlockedObject(t2, objC, mainThread, Thread.State.BLOCKED); + checkBlockedObject(t1, objB, t2, Thread.State.BLOCKED); long[] expectedThreads = new long[3]; expectedThreads[0] = t1.getId(); // blocked on lockB @@ -260,13 +277,14 @@ public class Locks { expectedThreads[2] = mainThread.getId(); // owner of lockC findThreadsBlockedOn(objB, expectedThreads); } - goSleep(100); + p.arriveAndAwaitAdvance(); // Phase 2 (blocking) + p = new Phaser(2); // Test Object.wait() case - waiter = new WaitingThread(); + waiter = new WaitingThread(p); waiter.start(); - checker = new CheckerThread(); + checker = new CheckerThread(p); checker.start(); try { @@ -284,7 +302,7 @@ public class Locks { } private static ThreadInfo findOwnerInfo(ThreadInfo[] infos, String lock) - throws Exception { + throws Exception { ThreadInfo ownerInfo = null; for (int i = 0; i < infos.length; i++) { String blockedLock = infos[i].getLockName(); @@ -292,7 +310,7 @@ public class Locks { long threadId = infos[i].getLockOwnerId(); if (threadId == -1) { throw new RuntimeException("TEST FAILED: " + - lock + " expected to have owner"); + lock + " expected to have owner"); } for (int j = 0; j < infos.length; j++) { if (infos[j].getThreadId() == threadId) { @@ -305,7 +323,7 @@ public class Locks { return ownerInfo; } private static void findThreadsBlockedOn(Object o, long[] expectedThreads) - throws Exception { + throws Exception { String lock = getLockName(o); // Check with ThreadInfo with no stack trace (i.e. no safepoint) ThreadInfo[] infos = tm.getThreadInfo(tm.getAllThreadIds()); @@ -317,14 +335,14 @@ public class Locks { } private static void doCheck(ThreadInfo[] infos, String lock, long[] expectedThreads) - throws Exception { + throws Exception { ThreadInfo ownerInfo = null; // Find the thread who is blocking on lock for (int i = 0; i < infos.length; i++) { String blockedLock = infos[i].getLockName(); if (lock.equals(blockedLock)) { System.out.print(infos[i].getThreadName() + - " blocked on " + blockedLock); + " blocked on " + blockedLock); ownerInfo = infos[i]; } } @@ -336,7 +354,7 @@ public class Locks { ownerInfo = findOwnerInfo(infos, lock); threads[count++] = ownerInfo.getThreadId(); System.out.println(" Owner = " + ownerInfo.getThreadName() + - " id = " + ownerInfo.getThreadId()); + " id = " + ownerInfo.getThreadId()); lock = ownerInfo.getLockName(); System.out.print(ownerInfo.getThreadName() + " Id = " + ownerInfo.getThreadId() + @@ -346,13 +364,13 @@ public class Locks { if (count != expectedThreads.length) { throw new RuntimeException("TEST FAILED: " + - "Expected chain of threads not matched; current count =" + count); + "Expected chain of threads not matched; current count =" + count); } for (int i = 0; i < count; i++) { if (threads[i] != expectedThreads[i]) { System.out.println("TEST FAILED: " + - "Unexpected thread in the chain " + threads[i] + - " expected to be " + expectedThreads[i]); + "Unexpected thread in the chain " + threads[i] + + " expected to be " + expectedThreads[i]); } } } diff --git a/jdk/test/java/lang/management/ThreadMXBean/SynchronizationStatistics.java b/jdk/test/java/lang/management/ThreadMXBean/SynchronizationStatistics.java index e03042864c9..6986adc6893 100644 --- a/jdk/test/java/lang/management/ThreadMXBean/SynchronizationStatistics.java +++ b/jdk/test/java/lang/management/ThreadMXBean/SynchronizationStatistics.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,45 +27,28 @@ * @summary Basic unit test of the synchronization statistics support: * * @author Mandy Chung + * @author Jaroslav Bachorik * - * @ignore 6309226 - * @build Semaphore * @run main/othervm SynchronizationStatistics */ import java.lang.management.*; +import java.util.concurrent.Phaser; public class SynchronizationStatistics { - private static ThreadMXBean mbean = ManagementFactory.getThreadMXBean(); - - private static boolean blockedTimeCheck = - mbean.isThreadContentionMonitoringSupported(); - private static boolean trace = false; - - private static Object lockA = new Object(); - private static Object lockB = new Object(); - private static Object lockC = new Object(); - private static Object lockD = new Object(); - private static Object waiter = new Object(); - private static volatile boolean testFailed = false; - - private static Object go = new Object(); - - private static void goSleep(long ms) { - try { - Thread.sleep(ms); - } catch (InterruptedException e) { - e.printStackTrace(); - System.out.println("Unexpected exception."); - testFailed = true; + private static class LockerThread extends Thread { + public LockerThread(Runnable r) { + super(r, "LockerThread"); } } - public static void main(String args[]) throws Exception { - if (args.length > 0 && args[0].equals("trace")) { - trace = true; - } + private static final ThreadMXBean mbean = ManagementFactory.getThreadMXBean(); + private static final boolean blockedTimeCheck = + mbean.isThreadContentionMonitoringSupported(); + + + public static void main(String args[]) throws Exception { if (blockedTimeCheck) { mbean.setThreadContentionMonitoringEnabled(true); } @@ -75,457 +58,317 @@ public class SynchronizationStatistics { "Thread Contention Monitoring is not enabled"); } - Examiner examiner = new Examiner("Examiner"); - BlockedThread blocked = new BlockedThread("BlockedThread"); - examiner.setThread(blocked); - - // Start the threads and check them in Blocked and Waiting states - examiner.start(); - - // wait until the examiner acquires all the locks and waiting - // for the BlockedThread to start - examiner.waitUntilWaiting(); - - System.out.println("Checking the thread state for the examiner thread " + - "is waiting to begin."); - - // The Examiner should be waiting to be notified by the BlockedThread - checkThreadState(examiner, Thread.State.WAITING); - - System.out.println("Now starting the blocked thread"); - blocked.start(); - - try { - examiner.join(); - blocked.join(); - } catch (InterruptedException e) { - e.printStackTrace(); - System.out.println("Unexpected exception."); - testFailed = true; - } - - if (testFailed) - throw new RuntimeException("TEST FAILED."); + testBlockingOnSimpleMonitor(); + testBlockingOnNestedMonitor(); + testWaitingOnSimpleMonitor(); + testMultiWaitingOnSimpleMonitor(); + testWaitingOnNestedMonitor(); System.out.println("Test passed."); } - private static String INDENT = " "; - private static void printStack(Thread t, StackTraceElement[] stack) { - System.out.println(INDENT + t + - " stack: (length = " + stack.length + ")"); - if (t != null) { - for (int j = 0; j < stack.length; j++) { - System.out.println(INDENT + stack[j]); + private static LockerThread newLockerThread(Runnable r) { + LockerThread t = new LockerThread(r); + t.setDaemon(true); + return t; + } + + private static void waitForThreadState(Thread t, Thread.State state) throws InterruptedException { + while (!t.isInterrupted() && t.getState() != state) { + Thread.sleep(3); + } + } + + /** + * Tests that blocking on a single monitor properly increases the + * blocked count at least by 1. Also asserts that the correct lock name is provided. + */ + private static void testBlockingOnSimpleMonitor() throws Exception { + System.out.println("testBlockingOnSimpleMonitor"); + final Object lock1 = new Object(); + final Phaser p = new Phaser(2); + LockerThread lt = newLockerThread(new Runnable() { + @Override + public void run() { + p.arriveAndAwaitAdvance(); // phase[1] + synchronized(lock1) { + System.out.println("[LockerThread obtained Lock1]"); + p.arriveAndAwaitAdvance(); // phase[2] + } + p.arriveAndAwaitAdvance(); // phase[3] } - System.out.println(); + }); + + lt.start(); + long tid = lt.getId(); + ThreadInfo ti = mbean.getThreadInfo(tid); + String lockName = null; + synchronized(lock1) { + p.arriveAndAwaitAdvance(); // phase[1] + waitForThreadState(lt, Thread.State.BLOCKED); + lockName = mbean.getThreadInfo(tid).getLockName(); } + + p.arriveAndAwaitAdvance(); // phase[2] + testBlocked(ti, mbean.getThreadInfo(tid), lockName, lock1); + p.arriveAndDeregister(); // phase[3] + + lt.join(); + + System.out.println("OK"); } - private static void checkThreadState(Thread thread, Thread.State s) - throws Exception { + /** + * Tests that blocking on a nested monitor properly increases the + * blocked count at least by 1 - it is not affected by the nesting depth. + * Also asserts that the correct lock name is provided. + */ + private static void testBlockingOnNestedMonitor() throws Exception { + System.out.println("testBlockingOnNestedMonitor"); + final Object lock1 = new Object(); + final Object lock2 = new Object(); - ThreadInfo ti = mbean.getThreadInfo(thread.getId()); - if (ti.getThreadState() != s) { - ThreadInfo info = mbean.getThreadInfo(thread.getId(), - Integer.MAX_VALUE); - System.out.println(INDENT + "TEST FAILED:"); - printStack(thread, info.getStackTrace()); - System.out.println(INDENT + "Thread state: " + info.getThreadState()); - - throw new RuntimeException("TEST FAILED: " + - "Thread state for " + thread + " returns " + ti.getThreadState() + - ". Expected to be " + s); - } - } - - private static void checkThreadState(Thread thread, - Thread.State s1, Thread.State s2) - throws Exception { - - ThreadInfo ti = mbean.getThreadInfo(thread.getId()); - if (ti.getThreadState() != s1 && ti.getThreadState() != s2) { - throw new RuntimeException("TEST FAILED: " + - "Thread state for " + thread + " returns " + ti.getThreadState() + - ". Expected to be " + s1 + " or " + s2); - } - } - - static class StatThread extends Thread { - private long blockingBaseTime = 0; - private long totalWaitTime = 0; - private long totalBlockedEnterTime = 0; - - StatThread(String name) { - super(name); - } - - void addWaitTime(long ns) { - totalWaitTime = totalWaitTime + ns; - } - void addBlockedEnterTime(long ns) { - totalBlockedEnterTime = totalBlockedEnterTime + ns; - } - void setBlockingBaseTime(long time) { - blockingBaseTime = time; - } - - long totalBlockedTimeMs() { - return totalBlockedEnterTime / 1000000; - } - - long totalBlockedTimeMs(long now) { - long t = totalBlockedEnterTime + (now - blockingBaseTime); - return t / 1000000; - } - - long totalWaitTimeMs() { - return totalWaitTime / 1000000; - } - - long totalWaitTimeMs(long now) { - long t = totalWaitTime + (now - blockingBaseTime); - return t / 1000000; - } - } - - static class BlockedThread extends StatThread { - private Semaphore handshake = new Semaphore(); - BlockedThread(String name) { - super(name); - } - void waitUntilBlocked() { - handshake.semaP(); - - // give a chance for the examiner thread to really wait - goSleep(20); - } - - void waitUntilWaiting() { - waitUntilBlocked(); - } - - boolean hasWaitersForBlocked() { - return (handshake.getWaiterCount() > 0); - } - - private void notifyWaiter() { - // wait until the examiner waits on the semaphore - while (handshake.getWaiterCount() == 0) { - goSleep(20); - } - handshake.semaV(); - } - - private void waitObj(long ms) { - synchronized (waiter) { - try { - // notify examinerabout to wait on a monitor - notifyWaiter(); - - long base = System.nanoTime(); - setBlockingBaseTime(base); - waiter.wait(ms); - long now = System.nanoTime(); - addWaitTime(now - base); - } catch (Exception e) { - e.printStackTrace(); - System.out.println("Unexpected exception."); - testFailed = true; + final Phaser p = new Phaser(2); + LockerThread lt = newLockerThread(new Runnable() { + @Override + public void run() { + p.arriveAndAwaitAdvance(); // phase[1] + synchronized(lock1) { + System.out.println("[LockerThread obtained Lock1]"); + p.arriveAndAwaitAdvance(); // phase[2] + p.arriveAndAwaitAdvance(); // phase[3] + synchronized(lock2) { + System.out.println("[LockerThread obtained Lock2]"); + p.arriveAndAwaitAdvance(); // phase[4] + } + p.arriveAndAwaitAdvance(); // phase[5] } } + }); + + lt.start(); + long tid = lt.getId(); + ThreadInfo ti = mbean.getThreadInfo(tid); + ThreadInfo ti1 = null; + String lockName = null; + synchronized(lock1) { + p.arriveAndAwaitAdvance(); // phase[1] + waitForThreadState(lt, Thread.State.BLOCKED); + lockName = mbean.getThreadInfo(tid).getLockName(); } + p.arriveAndAwaitAdvance(); // phase[2] - private void test() { - // notify examiner about to block on lockA - notifyWaiter(); + ti1 = mbean.getThreadInfo(tid); + testBlocked(ti, ti1, lockName, lock1); + ti = ti1; - long base = System.nanoTime(); - setBlockingBaseTime(base); - synchronized (lockA) { - long now = System.nanoTime(); - addBlockedEnterTime(now - base); - - A(); // Expected blocked count = 1 - } - E(); + synchronized(lock2) { + p.arriveAndAwaitAdvance(); // phase [3] + waitForThreadState(lt, Thread.State.BLOCKED); + lockName = mbean.getThreadInfo(tid).getLockName(); } - private void A() { - // notify examiner about to block on lockB - notifyWaiter(); + p.arriveAndAwaitAdvance(); // phase [4] + testBlocked(ti, mbean.getThreadInfo(tid), lockName, lock2); + p.arriveAndDeregister(); - long base = System.nanoTime(); - setBlockingBaseTime(base); - synchronized (lockB) { - long now = System.nanoTime(); - addBlockedEnterTime(now - base); + lt.join(); - B(); // Expected blocked count = 2 + System.out.println("OK"); + } + + /** + * Tests that waiting on a single monitor properly increases the waited + * count by 1 and the waited time by a positive number. + */ + private static void testWaitingOnSimpleMonitor() throws Exception { + System.out.println("testWaitingOnSimpleMonitor"); + final Object lock1 = new Object(); + final Phaser p = new Phaser(2); + LockerThread lt = newLockerThread(new Runnable() { + @Override + public void run() { + p.arriveAndAwaitAdvance(); // phase[1] + synchronized(lock1) { + System.out.println("[LockerThread obtained Lock1]"); + try { + lock1.wait(300); + } catch (InterruptedException ex) { + // ignore + } + p.arriveAndAwaitAdvance(); // phase[2] + } + p.arriveAndAwaitAdvance(); // phase[3] } + }); + + lt.start(); + ThreadInfo ti1 = mbean.getThreadInfo(lt.getId()); + synchronized(lock1) { + p.arriveAndAwaitAdvance(); // phase[1] + waitForThreadState(lt, Thread.State.BLOCKED); } - private void B() { - // notify examiner about to block on lockC - notifyWaiter(); + p.arriveAndAwaitAdvance(); // phase[2] - long base = System.nanoTime(); - setBlockingBaseTime(base); - synchronized (lockC) { - long now = System.nanoTime(); - addBlockedEnterTime(now - base); + ThreadInfo ti2 = mbean.getThreadInfo(lt.getId()); + p.arriveAndDeregister(); // phase[3] - C(); // Expected blocked count = 3 + lt.join(); + + testWaited(ti1, ti2, 1); + System.out.println("OK"); + } + + /** + * Tests that waiting multiple times on the same monitor subsequently + * increases the waited count by the number of subsequent calls and the + * waited time by a positive number. + */ + private static void testMultiWaitingOnSimpleMonitor() throws Exception { + System.out.println("testWaitingOnMultipleMonitors"); + final Object lock1 = new Object(); + + final Phaser p = new Phaser(2); + LockerThread lt = newLockerThread(new Runnable() { + @Override + public void run() { + p.arriveAndAwaitAdvance(); // phase[1] + synchronized(lock1) { + System.out.println("[LockerThread obtained Lock1]"); + for (int i = 0; i < 3; i++) { + try { + lock1.wait(300); + } catch (InterruptedException ex) { + // ignore + } + p.arriveAndAwaitAdvance(); // phase[2-4] + } + } + p.arriveAndAwaitAdvance(); // phase[5] } + }); + + lt.start(); + ThreadInfo ti1 = mbean.getThreadInfo(lt.getId()); + synchronized(lock1) { + p.arriveAndAwaitAdvance(); //phase[1] + waitForThreadState(lt, Thread.State.BLOCKED); } - private void C() { - // notify examiner about to block on lockD - notifyWaiter(); + int phase = p.getPhase(); + while ((p.arriveAndAwaitAdvance() - phase) < 3); // phase[2-4] - long base = System.nanoTime(); - setBlockingBaseTime(base); - synchronized (lockD) { - long now = System.nanoTime(); - addBlockedEnterTime(now - base); + ThreadInfo ti2 = mbean.getThreadInfo(lt.getId()); + p.arriveAndDeregister(); // phase[5] - D(); // Expected blocked count = 4 - } - } - private void D() { - goSleep(50); - } - private void E() { - final int WAIT = 1000; - waitObj(WAIT); - waitObj(WAIT); - waitObj(WAIT); - } + lt.join(); + testWaited(ti1, ti2, 3); + System.out.println("OK"); + } - public void run() { - test(); - } // run() - } // BlockedThread + /** + * Tests that waiting on monitors places in nested synchronized blocks + * properly increases the waited count by the number of times the "lock.wait()" + * was invoked and the waited time by a positive number. + */ + private static void testWaitingOnNestedMonitor() throws Exception { + System.out.println("testWaitingOnNestedMonitor"); + final Object lock1 = new Object(); + final Object lock2 = new Object(); + final Object lock3 = new Object(); - static int blockedCount = 0; - static int waitedCount = 0; - static class Examiner extends StatThread { - private BlockedThread blockedThread; - private Semaphore semaphore = new Semaphore(); + final Phaser p = new Phaser(2); + LockerThread lt = newLockerThread(new Runnable() { + @Override + public void run() { + p.arriveAndAwaitAdvance(); // phase[1] + synchronized(lock1) { + System.out.println("[LockerThread obtained Lock1]"); + try { + lock1.wait(300); + } catch (InterruptedException ex) { + // ignore + } - Examiner(String name) { - super(name); - } - - public void setThread(BlockedThread thread) { - blockedThread = thread; - } - - private void blockedTimeRangeCheck(StatThread t, - long blockedTime, - long nowNano) - throws Exception { - long expected = t.totalBlockedTimeMs(nowNano); - - // accept 5% range - timeRangeCheck(blockedTime, expected, 5); - } - private void waitedTimeRangeCheck(StatThread t, - long waitedTime, - long nowNano) - throws Exception { - long expected = t.totalWaitTimeMs(nowNano); - - // accept 5% range - timeRangeCheck(waitedTime, expected, 5); - } - - private void timeRangeCheck(long time, long expected, int percent) - throws Exception { - - double diff = expected - time; - - if (trace) { - System.out.println(" Time = " + time + - " expected = " + expected + - ". Diff = " + diff); - - } - // throw an exception if blockedTime and expectedTime - // differs > percent% - if (diff < 0) { - diff = diff * -1; - } - - long range = (expected * percent) / 100; - // minimum range = 2 ms - if (range < 2) { - range = 2; - } - if (diff > range) { - throw new RuntimeException("TEST FAILED: " + - "Time returned = " + time + - " expected = " + expected + ". Diff = " + diff); - } - } - private void checkInfo(StatThread t, Thread.State s, Object lock, - String lockName, int bcount, int wcount) - throws Exception { - - String action = "ERROR"; - if (s == Thread.State.WAITING || s == Thread.State.TIMED_WAITING) { - action = "wait on "; - } else if (s == Thread.State.BLOCKED) { - action = "block on "; - } - System.out.println(t + " expected to " + action + lockName + - " with blocked count = " + bcount + - " and waited count = " + wcount); - - long now = System.nanoTime(); - ThreadInfo info = mbean.getThreadInfo(t.getId()); - if (info.getThreadState() != s) { - printStack(t, info.getStackTrace()); - throw new RuntimeException("TEST FAILED: " + - "Thread state returned is " + info.getThreadState() + - ". Expected to be " + s); - } - - if (info.getLockName() == null || - !info.getLockName().equals(lock.toString())) { - throw new RuntimeException("TEST FAILED: " + - "getLockName() returned " + info.getLockName() + - ". Expected to be " + lockName + " - " + lock.toString()); - } - - if (info.getBlockedCount() != bcount) { - throw new RuntimeException("TEST FAILED: " + - "Blocked Count returned is " + info.getBlockedCount() + - ". Expected to be " + bcount); - } - if (info.getWaitedCount() != wcount) { - throw new RuntimeException("TEST FAILED: " + - "Waited Count returned is " + info.getWaitedCount() + - ". Expected to be " + wcount); - } - - String lockObj = info.getLockName(); - if (lockObj == null || !lockObj.equals(lock.toString())) { - throw new RuntimeException("TEST FAILED: " + - "Object blocked on is " + lockObj + - ". Expected to be " + lock.toString()); - } - - if (!blockedTimeCheck) { - return; - } - long blockedTime = info.getBlockedTime(); - if (blockedTime < 0) { - throw new RuntimeException("TEST FAILED: " + - "Blocked time returned is negative = " + blockedTime); - } - - if (s == Thread.State.BLOCKED) { - blockedTimeRangeCheck(t, blockedTime, now); - } else { - timeRangeCheck(blockedTime, t.totalBlockedTimeMs(), 5); - } - - long waitedTime = info.getWaitedTime(); - if (waitedTime < 0) { - throw new RuntimeException("TEST FAILED: " + - "Waited time returned is negative = " + waitedTime); - } - if (s == Thread.State.WAITING || s == Thread.State.TIMED_WAITING) { - waitedTimeRangeCheck(t, waitedTime, now); - } else { - timeRangeCheck(waitedTime, t.totalWaitTimeMs(), 5); - } - - } - - private void examine() { - try { - synchronized (lockD) { - synchronized (lockC) { - synchronized (lockB) { - synchronized (lockA) { - // notify main thread to continue - semaphore.semaV(); - - // wait until BlockedThread has started - blockedThread.waitUntilBlocked(); - - blockedCount++; - checkInfo(blockedThread, Thread.State.BLOCKED, - lockA, "lockA", - blockedCount, waitedCount); - } - - // wait until BlockedThread to block on lockB - blockedThread.waitUntilBlocked(); - - blockedCount++; - checkInfo(blockedThread, Thread.State.BLOCKED, - lockB, "lockB", - blockedCount, waitedCount); + p.arriveAndAwaitAdvance(); // phase[2] + synchronized(lock2) { + System.out.println("[LockerThread obtained Lock2]"); + try { + lock2.wait(300); + } catch (InterruptedException ex) { + // ignore } - // wait until BlockedThread to block on lockC - blockedThread.waitUntilBlocked(); - - blockedCount++; - checkInfo(blockedThread, Thread.State.BLOCKED, - lockC, "lockC", - blockedCount, waitedCount); + p.arriveAndAwaitAdvance(); // phase[3] + synchronized(lock3) { + System.out.println("[LockerThread obtained Lock3]"); + try { + lock3.wait(300); + } catch (InterruptedException ex) { + // ignore + } + p.arriveAndAwaitAdvance(); // phase[4] + } } - // wait until BlockedThread to block on lockD - blockedThread.waitUntilBlocked(); - blockedCount++; - - checkInfo(blockedThread, Thread.State.BLOCKED, - lockD, "lockD", - blockedCount, waitedCount); } - - // wait until BlockedThread about to call E() - // BlockedThread will wait on waiter for 3 times - blockedThread.waitUntilWaiting(); - - waitedCount++; - checkInfo(blockedThread, Thread.State.TIMED_WAITING, - waiter, "waiter", blockedCount, waitedCount); - - blockedThread.waitUntilWaiting(); - - waitedCount++; - checkInfo(blockedThread, Thread.State.TIMED_WAITING, - waiter, "waiter", blockedCount, waitedCount); - - blockedThread.waitUntilWaiting(); - - waitedCount++; - checkInfo(blockedThread, Thread.State.TIMED_WAITING, - waiter, "waiter", blockedCount, waitedCount); - - } catch (Exception e) { - e.printStackTrace(); - System.out.println("Unexpected exception."); - testFailed = true; + p.arriveAndAwaitAdvance(); // phase[5] } + }); + + lt.start(); + ThreadInfo ti1 = mbean.getThreadInfo(lt.getId()); + synchronized(lock1) { + p.arriveAndAwaitAdvance(); // phase[1] + waitForThreadState(lt, Thread.State.BLOCKED); } - public void run() { - examine(); - } // run() - - public void waitUntilWaiting() { - semaphore.semaP(); - - // wait until the examiner is waiting for - while (!blockedThread.hasWaitersForBlocked()) { - goSleep(50); - } - // give a chance for the examiner thread to really wait - goSleep(20); - + synchronized(lock2) { + p.arriveAndAwaitAdvance(); // phase[2] + waitForThreadState(lt, Thread.State.BLOCKED); } - } // Examiner + + synchronized(lock3) { + p.arriveAndAwaitAdvance(); // phase[3] + waitForThreadState(lt, Thread.State.BLOCKED); + } + + p.arriveAndAwaitAdvance(); // phase[4] + ThreadInfo ti2 = mbean.getThreadInfo(lt.getId()); + p.arriveAndDeregister(); // phase[5] + + lt.join(); + testWaited(ti1, ti2, 3); + System.out.println("OK"); + } + + private static void testWaited(ThreadInfo ti1, ThreadInfo ti2, int waited) throws Error { + long waitCntDiff = ti2.getWaitedCount() - ti1.getWaitedCount(); + long waitTimeDiff = ti2.getWaitedTime() - ti1.getWaitedTime(); + if (waitCntDiff < waited) { + throw new Error("Unexpected diff in waited count. Expecting at least " + + waited + " , got " + waitCntDiff); + } + if (waitTimeDiff <= 0) { + throw new Error("Unexpected diff in waited time. Expecting increasing " + + "value, got " + waitTimeDiff + "ms"); + } + } + + private static void testBlocked(ThreadInfo ti1, ThreadInfo ti2, + String lockName, final Object lock) + throws Error { + long blkCntDiff = ti2.getBlockedCount() - ti1.getBlockedCount(); + long blkTimeDiff = ti2.getBlockedTime() - ti1.getBlockedTime(); + if (blkCntDiff < 1) { + throw new Error("Unexpected diff in blocked count. Expecting at least 1, " + + "got " + blkCntDiff); + } + if (blkTimeDiff < 0) { + throw new Error("Unexpected diff in blocked time. Expecting a positive " + + "number, got " + blkTimeDiff); + } + if (!lockName.equals(lock.toString())) { + throw new Error("Unexpected blocked monitor name. Expecting " + + lock.toString() + ", got " + + lockName); + } + } } diff --git a/jdk/test/java/lang/management/ThreadMXBean/ThreadBlockedCount.java b/jdk/test/java/lang/management/ThreadMXBean/ThreadBlockedCount.java index 1cd9032e1ee..7fed519de59 100644 --- a/jdk/test/java/lang/management/ThreadMXBean/ThreadBlockedCount.java +++ b/jdk/test/java/lang/management/ThreadMXBean/ThreadBlockedCount.java @@ -26,177 +26,127 @@ * @bug 4530538 * @summary Basic unit test of ThreadInfo.getBlockedCount() * @author Alexei Guibadoulline and Mandy Chung - * - * @build ThreadExecutionSynchronizer + * @author Jaroslav Bachorik * @run main ThreadBlockedCount */ import java.lang.management.*; +import java.util.concurrent.Phaser; public class ThreadBlockedCount { - final static long EXPECTED_BLOCKED_COUNT = 3; + final static long EXPECTED_BLOCKED_COUNT = 3; final static int DEPTH = 10; - private static ThreadMXBean mbean + private static final ThreadMXBean mbean = ManagementFactory.getThreadMXBean(); - private static Object a = new Object(); - private static Object b = new Object(); - private static Object c = new Object(); - private static boolean aNotified = false; - private static boolean bNotified = false; - private static boolean cNotified = false; - private static Object blockedObj1 = new Object(); - private static Object blockedObj2 = new Object(); - private static Object blockedObj3 = new Object(); - private static volatile boolean testFailed = false; + private static final Object a = new Object(); + private static final Object b = new Object(); + private static final Object c = new Object(); + + private static final Object blockedObj1 = new Object(); + private static final Object blockedObj2 = new Object(); + private static final Object blockedObj3 = new Object(); + private static volatile boolean testOk = true; private static BlockingThread blocking; private static BlockedThread blocked; - private static ThreadExecutionSynchronizer thrsync; - - public static void main(String args[]) throws Exception { - // Create the BlockingThread before BlockedThread - // to make sure BlockingThread enter the lock before BlockedThread - thrsync = new ThreadExecutionSynchronizer(); - - blocking = new BlockingThread(); - blocking.start(); - - blocked = new BlockedThread(); - blocked.start(); - - try { - blocking.join(); - blocked.join(); - } catch (InterruptedException e) { - System.err.println("Unexpected exception."); - e.printStackTrace(System.err); - throw e; - } - - if (testFailed) { + // real run + runTest(); + if (!testOk) { throw new RuntimeException("TEST FAILED."); } System.out.println("Test passed."); } + private static void runTest() throws Exception { + final Phaser p = new Phaser(2); + + blocking = new BlockingThread(p); + blocking.start(); + + blocked = new BlockedThread(p); + blocked.start(); + + try { + blocking.join(); + + testOk = checkBlocked(); + p.arriveAndAwaitAdvance(); // #5 + + } catch (InterruptedException e) { + System.err.println("Unexpected exception."); + e.printStackTrace(System.err); + throw e; + } + } + static class BlockedThread extends Thread { - // NOTE: We can't use a.wait() here because wait() call is counted - // as blockedCount. Instead, we use a boolean flag and sleep. - // + private final Phaser p; + + BlockedThread(Phaser p) { + super("BlockedThread"); + this.p = p; + } + public void run() { - // wait Blocking thread - thrsync.signal(); + int accumulator = 0; + p.arriveAndAwaitAdvance(); // #1 // Enter lock a without blocking synchronized (a) { - // wait until BlockingThread holds blockedObj1 - while (!aNotified) { - try { - Thread.sleep(50); - } catch (InterruptedException e) { - System.err.println("Unexpected exception."); - e.printStackTrace(System.err); - testFailed = true; - break; - } - } - - // signal BlockingThread. - thrsync.signal(); + p.arriveAndAwaitAdvance(); // #2 // Block to enter blockedObj1 // blockedObj1 should be owned by BlockingThread synchronized (blockedObj1) { - System.out.println("BlockedThread entered lock blockedObj1."); + accumulator++; // filler } } - // signal BlockingThread. - thrsync.signal(); - // Enter lock a without blocking synchronized (b) { // wait until BlockingThread holds blockedObj2 - while (!bNotified) { - try { - Thread.sleep(50); - } catch (InterruptedException e) { - System.err.println("Unexpected exception."); - e.printStackTrace(System.err); - testFailed = true; - break; - } - } - - // signal BlockingThread. - thrsync.signal(); + p.arriveAndAwaitAdvance(); // #3 // Block to enter blockedObj2 // blockedObj2 should be owned by BlockingThread synchronized (blockedObj2) { - System.out.println("BlockedThread entered lock blockedObj2."); + accumulator++; // filler } } - // signal BlockingThread. - thrsync.signal(); - // Enter lock a without blocking synchronized (c) { // wait until BlockingThread holds blockedObj3 - while (!cNotified) { - try { - Thread.sleep(50); - } catch (InterruptedException e) { - System.err.println("Unexpected exception."); - e.printStackTrace(System.err); - testFailed = true; - break; - } - } - - // signal BlockingThread. - thrsync.signal(); + p.arriveAndAwaitAdvance(); // #4 // Block to enter blockedObj3 // blockedObj3 should be owned by BlockingThread synchronized (blockedObj3) { - System.out.println("BlockedThread entered lock blockedObj3."); + accumulator++; // filler } } - // wait for the thread stats to be updated for 10 seconds - for (int i = 0; i < 100; i++) { - if (getBlockedCount() == EXPECTED_BLOCKED_COUNT) { - return; - } - try { - Thread.sleep(100); - } catch (InterruptedException e) { - System.err.println("Unexpected exception."); - e.printStackTrace(System.err); - testFailed = true; - return; - } - } - long count = getBlockedCount(); - if (count != EXPECTED_BLOCKED_COUNT) { - System.err.println("TEST FAILED: Blocked thread has " + count + - " blocked counts. Expected " + - EXPECTED_BLOCKED_COUNT); - testFailed = true; - } + // wait for the main thread to check the blocked count + System.out.println("Acquired " + accumulator + " monitors"); + p.arriveAndAwaitAdvance(); // #5 + // ... and we can leave now } // run() - } // BlockingThread + } // BlockedThread static class BlockingThread extends Thread { - private void waitForSignalToRelease() { + private final Phaser p; + BlockingThread(Phaser p) { + super("BlockingThread"); + this.p = p; + } + + private void waitForBlocked() { // wait for BlockedThread. - thrsync.waitForSignal(); + p.arriveAndAwaitAdvance(); boolean threadBlocked = false; while (!threadBlocked) { @@ -206,7 +156,7 @@ public class ThreadBlockedCount { } catch (InterruptedException e) { System.err.println("Unexpected exception."); e.printStackTrace(System.err); - testFailed = true; + testOk = false; break; } ThreadInfo info = mbean.getThreadInfo(blocked.getId()); @@ -215,44 +165,55 @@ public class ThreadBlockedCount { } public void run() { - // wait for BlockedThread. - thrsync.waitForSignal(); + p.arriveAndAwaitAdvance(); // #1 synchronized (blockedObj1) { System.out.println("BlockingThread attempts to notify a"); - aNotified = true; - waitForSignalToRelease(); + waitForBlocked(); // #2 } - // wait for BlockedThread. - thrsync.waitForSignal(); - // block until BlockedThread is ready synchronized (blockedObj2) { System.out.println("BlockingThread attempts to notify b"); - bNotified = true; - waitForSignalToRelease(); + waitForBlocked(); // #3 } - // wait for BlockedThread. - thrsync.waitForSignal(); - // block until BlockedThread is ready synchronized (blockedObj3) { System.out.println("BlockingThread attempts to notify c"); - cNotified = true; - waitForSignalToRelease(); + waitForBlocked(); // #4 } } // run() - } // BlockedThread + } // BlockingThread private static long getBlockedCount() { long count; // Check the mbean now - ThreadInfo ti = mbean.getThreadInfo(Thread.currentThread(). - getId()); + ThreadInfo ti = mbean.getThreadInfo(blocked.getId()); count = ti.getBlockedCount(); return count; } + + private static boolean checkBlocked() { + // wait for the thread stats to be updated for 10 seconds + long count = -1; + for (int i = 0; i < 100; i++) { + count = getBlockedCount(); + if (count >= EXPECTED_BLOCKED_COUNT) { + return true; + } + try { + Thread.sleep(100); + } catch (InterruptedException e) { + System.err.println("Unexpected exception."); + e.printStackTrace(System.err); + return false; + } + } + System.err.println("TEST FAILED: Blocked thread has " + count + + " blocked counts. Expected at least " + + EXPECTED_BLOCKED_COUNT); + return false; + } } diff --git a/jdk/test/java/lang/management/ThreadMXBean/ThreadExecutionSynchronizer.java b/jdk/test/java/lang/management/ThreadMXBean/ThreadExecutionSynchronizer.java deleted file mode 100644 index 6cba7e73521..00000000000 --- a/jdk/test/java/lang/management/ThreadMXBean/ThreadExecutionSynchronizer.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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. - */ - -/* - * - * @summary This class is used to synchronize execution of two threads. - * @author Swamy Venkataramanappa - */ - -import java.util.concurrent.Semaphore; - -public class ThreadExecutionSynchronizer { - - private volatile boolean waiting; - private final Semaphore semaphore; - - public ThreadExecutionSynchronizer() { - semaphore = new Semaphore(1); - waiting = false; - } - - // Synchronizes two threads execution points. - // Basically any thread could get scheduled to run and - // it is not possible to know which thread reaches expected - // execution point. So whichever thread reaches a execution - // point first wait for the second thread. When the second thread - // reaches the expected execution point will wake up - // the thread which is waiting here. - void stopOrGo() { - semaphore.acquireUninterruptibly(); // Thread can get blocked. - if (!waiting) { - waiting = true; - // Wait for second thread to enter this method. - while(!semaphore.hasQueuedThreads()) { - try { - Thread.sleep(20); - } catch (InterruptedException xx) {} - } - semaphore.release(); - } else { - waiting = false; - semaphore.release(); - } - } - - // Wrapper function just for code readability. - void waitForSignal() { - stopOrGo(); - goSleep(50); - } - - void signal() { - stopOrGo(); - goSleep(50); - } - - private static void goSleep(long ms) { - try { - Thread.sleep(ms); - } catch (InterruptedException e) { - e.printStackTrace(); - System.out.println("Unexpected exception."); - } - } -} diff --git a/jdk/test/java/lang/reflect/OldenCompilingWithDefaults.java b/jdk/test/java/lang/reflect/OldenCompilingWithDefaults.java index c8609b35f9d..0d82520b517 100644 --- a/jdk/test/java/lang/reflect/OldenCompilingWithDefaults.java +++ b/jdk/test/java/lang/reflect/OldenCompilingWithDefaults.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,6 @@ * @test * @bug 8009267 * @summary Verify uses of isAnnotationPresent compile under older source versions - * @compile -source 1.5 -target 1.5 OldenCompilingWithDefaults.java * @compile -source 1.6 -target 1.6 OldenCompilingWithDefaults.java * @compile -source 1.7 -target 1.7 OldenCompilingWithDefaults.java * @compile OldenCompilingWithDefaults.java diff --git a/jdk/test/java/net/Authenticator/B4933582.sh b/jdk/test/java/net/Authenticator/B4933582.sh index fa1768398ae..1e1268e3f8a 100644 --- a/jdk/test/java/net/Authenticator/B4933582.sh +++ b/jdk/test/java/net/Authenticator/B4933582.sh @@ -26,7 +26,7 @@ OS=`uname -s` case "$OS" in - SunOS | Linux | Darwin ) + SunOS | Linux | Darwin | AIX ) PS=":" FS="/" ;; diff --git a/jdk/test/java/net/DatagramSocket/Send12k.java b/jdk/test/java/net/DatagramSocket/Send12k.java index 6446330d35e..f6375c1f0b7 100644 --- a/jdk/test/java/net/DatagramSocket/Send12k.java +++ b/jdk/test/java/net/DatagramSocket/Send12k.java @@ -53,7 +53,7 @@ public class Send12k { boolean sendOkay = true; try { s1.send(p1); - } catch (SocketException e) { + } catch (IOException e) { /* * Prior to merlin a send of > 12k to loopback address * would fail silently. diff --git a/jdk/test/java/net/DatagramSocket/SetDatagramSocketImplFactory/ADatagramSocket.sh b/jdk/test/java/net/DatagramSocket/SetDatagramSocketImplFactory/ADatagramSocket.sh index 271b21d26f3..eac0315e7e3 100644 --- a/jdk/test/java/net/DatagramSocket/SetDatagramSocketImplFactory/ADatagramSocket.sh +++ b/jdk/test/java/net/DatagramSocket/SetDatagramSocketImplFactory/ADatagramSocket.sh @@ -27,7 +27,7 @@ # set platform-dependent variables OS=`uname -s` case "$OS" in - SunOS | Darwin ) + SunOS | Darwin | AIX ) PATHSEP=":" FILESEP="/" ;; diff --git a/jdk/test/java/net/Socket/OldSocketImpl.sh b/jdk/test/java/net/Socket/OldSocketImpl.sh index bbe055fa2ea..70b92afc7b6 100644 --- a/jdk/test/java/net/Socket/OldSocketImpl.sh +++ b/jdk/test/java/net/Socket/OldSocketImpl.sh @@ -28,7 +28,7 @@ OS=`uname -s` case "$OS" in - SunOS | Linux | Darwin ) + SunOS | Linux | Darwin | AIX ) PS=":" FS="/" ;; diff --git a/jdk/test/java/net/Socks/SocksIPv6Test.java b/jdk/test/java/net/Socks/SocksIPv6Test.java new file mode 100644 index 00000000000..1b4dc82ff58 --- /dev/null +++ b/jdk/test/java/net/Socks/SocksIPv6Test.java @@ -0,0 +1,178 @@ +/* + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 7100957 + * @summary Java doesn't correctly handle the SOCKS protocol when used over IPv6. + * @run testng SocksIPv6Test + */ + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.net.Authenticator; +import java.net.InetSocketAddress; +import java.net.URL; +import java.net.Proxy; +import java.lang.Override; +import java.net.InetAddress; +import java.net.Inet6Address; +import java.net.ServerSocket; +import java.net.SocketException; +import java.net.NetworkInterface; +import java.net.UnknownHostException; +import java.util.Collections; +import java.util.List; +import com.sun.net.httpserver.*; +import java.io.BufferedWriter; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import static org.testng.Assert.*; + +public class SocksIPv6Test { + + private HttpServer server; + private SocksServer socks; + private String response = "Hello."; + private static boolean shouldRun = false; + + @BeforeClass + public void setUp() throws Exception { + shouldRun = ensureInet6AddressFamily() && ensureIPv6OnLoopback(); + + server = HttpServer.create(new InetSocketAddress(0), 0); + server.createContext("/", ex -> { + ex.sendResponseHeaders(200, response.length()); + try (BufferedWriter writer = new BufferedWriter( + new OutputStreamWriter(ex.getResponseBody(), "UTF-8"))) { + writer.write(response); + } + ex.close(); + }); + server.start(); + + socks = new SocksServer(0, false); + socks.addUser("user", "pass"); + socks.start(); + + Authenticator.setDefault(new Authenticator() { + @Override + protected java.net.PasswordAuthentication getPasswordAuthentication() { + return new java.net.PasswordAuthentication( + "user", "pass".toCharArray()); + } + }); + } + + private boolean ensureIPv6OnLoopback() throws Exception { + boolean ipv6 = false; + + List nics = Collections.list(NetworkInterface.getNetworkInterfaces()); + for (NetworkInterface nic : nics) { + if (!nic.isLoopback()) { + continue; + } + List addrs = Collections.list(nic.getInetAddresses()); + for (InetAddress addr : addrs) { + if (addr instanceof Inet6Address) { + ipv6 = true; + break; + } + } + } + if (!ipv6) + System.out.println("IPv6 is not enabled on loopback. Skipping test suite."); + return ipv6; + } + + private boolean ensureInet6AddressFamily() throws IOException { + try (ServerSocket s = new ServerSocket()) { + s.bind(new InetSocketAddress("::1", 0)); + return true; + } catch (SocketException e) { + System.out.println("Inet 6 address family is not available. Skipping test suite."); + } + return false; + } + + @Test(groups = "unit") + public void testSocksOverIPv6() throws Exception { + if (!shouldRun) return; + + Proxy proxy = new Proxy(Proxy.Type.SOCKS, new InetSocketAddress("::1", + socks.getPort())); + URL url = new URL("http://[::1]:" + server.getAddress().getPort()); + java.net.URLConnection conn = url.openConnection(proxy); + String actual = ""; + try (BufferedReader reader = new BufferedReader( + new InputStreamReader(conn.getInputStream()))) { + actual = reader.readLine(); + } + assertEquals(actual, response); + } + + @Test(groups = "unit") + public void testSocksOverIPv6Hostname() throws Exception { + if (!shouldRun) return; + + String ipv6Hostname = InetAddress.getByName("::1").getHostName(); + String ipv4Hostname = InetAddress.getByName("127.0.0.1").getHostName(); + + if (ipv6Hostname.equals(InetAddress.getByName("::1").getHostAddress())) { + System.out.println("Unable to get the hostname of the IPv6 loopback " + + "address. Skipping test case."); + return; + } + + if (ipv6Hostname.equals(ipv4Hostname)) { + System.out.println("IPv6 and IPv4 loopback addresses map to the" + + " same hostname. Skipping test case."); + return; + } + + Proxy proxy = new Proxy(Proxy.Type.SOCKS, new InetSocketAddress(ipv6Hostname, + socks.getPort())); + URL url = new URL("http://" + ipv6Hostname + ":" + server.getAddress().getPort()); + java.net.URLConnection conn = url.openConnection(proxy); + String actual = ""; + try (BufferedReader reader = new BufferedReader( + new InputStreamReader(conn.getInputStream()))) { + actual = reader.readLine(); + } + assertEquals(actual, response); + } + + @AfterClass + public void tearDown() { + if (server != null) { + server.stop(1); + } + if (socks != null) { + socks.terminate(); + } + } +} diff --git a/jdk/test/java/net/Socks/SocksServer.java b/jdk/test/java/net/Socks/SocksServer.java index 6e27e342e94..f2d6ef82bfe 100644 --- a/jdk/test/java/net/Socks/SocksServer.java +++ b/jdk/test/java/net/Socks/SocksServer.java @@ -89,6 +89,7 @@ public class SocksServer extends Thread { return; } tout.write(b); + tout.flush(); } catch (IOException e) { // actually exit from the thread return; @@ -99,8 +100,8 @@ public class SocksServer extends Thread { ClientHandler(Socket s) throws IOException { client = s; - in = client.getInputStream(); - out = client.getOutputStream(); + in = new BufferedInputStream(client.getInputStream()); + out = new BufferedOutputStream(client.getOutputStream()); } private void readBuf(InputStream is, byte[] buf) throws IOException { @@ -230,8 +231,8 @@ public class SocksServer extends Thread { out.write(port & 0xff); out.write(buf); out.flush(); - InputStream in2 = dest.getInputStream(); - OutputStream out2 = dest.getOutputStream(); + InputStream in2 = new BufferedInputStream(dest.getInputStream()); + OutputStream out2 = new BufferedOutputStream(dest.getOutputStream()); Tunnel tunnel = new Tunnel(in2, out); tunnel.start(); @@ -246,6 +247,7 @@ public class SocksServer extends Thread { return; } out2.write(b); + out2.flush(); } catch (IOException ex) { } } while (!client.isClosed()); @@ -323,8 +325,8 @@ public class SocksServer extends Thread { out.write((addr.getPort() >> 0) & 0xff); out.flush(); - InputStream in2 = dest.getInputStream(); - OutputStream out2 = dest.getOutputStream(); + InputStream in2 = new BufferedInputStream(dest.getInputStream()); + OutputStream out2 = new BufferedOutputStream(dest.getOutputStream()); Tunnel tunnel = new Tunnel(in2, out); tunnel.start(); @@ -340,6 +342,7 @@ public class SocksServer extends Thread { return; } out2.write(b); + out2.flush(); } catch(IOException ioe) { } } while (!client.isClosed()); @@ -384,6 +387,7 @@ public class SocksServer extends Thread { return; } out2.write(b); + out2.flush(); } catch(IOException ioe) { } } while (!client.isClosed()); @@ -410,14 +414,7 @@ public class SocksServer extends Thread { { byte[] buf = new byte[4]; readBuf(in, buf); - int i = 0; - StringBuffer sb = new StringBuffer(); - for (i = 0; i < 4; i++) { - sb.append(buf[i]&0xff); - if (i < 3) - sb.append('.'); - } - addr = sb.toString(); + addr = InetAddress.getByAddress(buf).getHostAddress(); } break; case DOMAIN_NAME: @@ -432,14 +429,7 @@ public class SocksServer extends Thread { { byte[] buf = new byte[16]; readBuf(in, buf); - int i = 0; - StringBuffer sb = new StringBuffer(); - for (i = 0; i<16; i++) { - sb.append(Integer.toHexString(buf[i]&0xff)); - if (i < 15) - sb.append(':'); - } - addr = sb.toString(); + addr = InetAddress.getByAddress(buf).getHostAddress(); } break; } diff --git a/jdk/test/java/net/URL/B5086147.sh b/jdk/test/java/net/URL/B5086147.sh index a669e1347ee..772d7a32cd1 100644 --- a/jdk/test/java/net/URL/B5086147.sh +++ b/jdk/test/java/net/URL/B5086147.sh @@ -26,7 +26,7 @@ OS=`uname -s` case "$OS" in - SunOS | Linux | Darwin ) + SunOS | Linux | Darwin | AIX ) exit 0 ;; CYGWIN* ) diff --git a/jdk/test/java/net/URLClassLoader/B5077773.sh b/jdk/test/java/net/URLClassLoader/B5077773.sh index 9bd9a1e6f34..3b52698840a 100644 --- a/jdk/test/java/net/URLClassLoader/B5077773.sh +++ b/jdk/test/java/net/URLClassLoader/B5077773.sh @@ -34,7 +34,7 @@ OS=`uname -s` case "$OS" in - SunOS | Darwin ) + SunOS | Darwin | AIX ) PS=":" FS="/" ;; diff --git a/jdk/test/java/net/URLClassLoader/sealing/checksealed.sh b/jdk/test/java/net/URLClassLoader/sealing/checksealed.sh index 0d212c62aae..339525a1042 100644 --- a/jdk/test/java/net/URLClassLoader/sealing/checksealed.sh +++ b/jdk/test/java/net/URLClassLoader/sealing/checksealed.sh @@ -27,7 +27,7 @@ OS=`uname -s` case "$OS" in - SunOS | Darwin ) + SunOS | Darwin | AIX ) PS=":" FS="/" ;; diff --git a/jdk/test/java/net/URLConnection/6212146/test.sh b/jdk/test/java/net/URLConnection/6212146/test.sh index 45f5310005e..9a0615cadf3 100644 --- a/jdk/test/java/net/URLConnection/6212146/test.sh +++ b/jdk/test/java/net/URLConnection/6212146/test.sh @@ -33,7 +33,7 @@ OS=`uname -s` case "$OS" in - SunOS | Darwin ) + SunOS | Darwin | AIX ) PS=":" FS="/" ;; diff --git a/jdk/test/java/net/URLPermission/OpenURL.java b/jdk/test/java/net/URLPermission/OpenURL.java new file mode 100644 index 00000000000..b0f7b6bfb01 --- /dev/null +++ b/jdk/test/java/net/URLPermission/OpenURL.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8029354 + * @run main/othervm OpenURL + */ + +import java.net.*; +import java.io.*; + +public class OpenURL { + + public static void main (String[] args) throws Exception { + + System.setSecurityManager(new SecurityManager()); + + try { + URL url = new URL ("http://joe@127.0.0.1/a/b"); + HttpURLConnection urlc = (HttpURLConnection)url.openConnection(); + InputStream is = urlc.getInputStream(); + // error will throw exception other than SecurityException + } catch (SecurityException e) { + System.out.println("OK"); + } + } +} diff --git a/jdk/test/java/net/URLPermission/URLPermissionTest.java b/jdk/test/java/net/URLPermission/URLPermissionTest.java index 7e55a63bc3c..2ffcf735f5b 100644 --- a/jdk/test/java/net/URLPermission/URLPermissionTest.java +++ b/jdk/test/java/net/URLPermission/URLPermissionTest.java @@ -26,7 +26,7 @@ import java.io.*; /** * @test - * @bug 8010464 8027570 8027687 + * @bug 8010464 8027570 8027687 8029354 */ public class URLPermissionTest { @@ -37,7 +37,30 @@ public class URLPermissionTest { abstract boolean execute(); }; + // Instantiation: should succeed + static class CreateTest extends Test { + String arg; + CreateTest(String arg) { + this.arg = arg; + } + + @Override + boolean execute() { + try { + URLPermission p = new URLPermission(arg); + return true; + } catch (Exception e) { + return false; + } + } + }; + + static CreateTest createtest(String arg) { + return new CreateTest(arg); + } + // Should throw an IAE on construction + static class ExTest extends Test { String arg; ExTest(String arg) { @@ -262,6 +285,7 @@ public class URLPermissionTest { imtest("https://www.foo.com/a/b", "https://www.foo.com:443/a/b", true), imtest("https://www.foo.com:200-500/a/b", "https://www.foo.com/a/b", true), imtest("http://www.foo.com:*/a/b", "http://www.foo.com:1-12345/a/b", true), + imtest("http://host/a/b", "http://HOST/a/b", true), // misc imtest("https:*", "http://www.foo.com", false), @@ -297,6 +321,16 @@ public class URLPermissionTest { eqtest("http://www.foo.com/a/b", "http://www.foo.com:82/a/b", false), eqtest("https://www.foo.com/a/b", "https://www.foo.com:443/a/b", true), eqtest("https://www.foo.com/a/b", "https://www.foo.com:444/a/b", false), + eqtest("http://michael@foo.com/bar","http://michael@foo.com/bar", true), + eqtest("http://Michael@foo.com/bar","http://michael@goo.com/bar",false), + eqtest("http://michael@foo.com/bar","http://george@foo.com/bar", true), + eqtest("http://@foo.com/bar","http://foo.com/bar", true) + }; + + static Test[] createTests = { + createtest("http://user@foo.com/a/b/c"), + createtest("http://user:pass@foo.com/a/b/c"), + createtest("http://user:@foo.com/a/b/c") }; static boolean failed = false; @@ -386,6 +420,17 @@ public class URLPermissionTest { } } + for (int i=0; i>> 1; - int start = RAND.nextInt(mid); - int end = mid + RAND.nextInt(mid); + int start = RAND.nextInt(mid + 1); // from 0 to mid + int end = mid + RAND.nextInt(cb.capacity() - mid + 1); // from mid to capacity cb.position(start); cb.limit(end); return cb; diff --git a/jdk/test/java/nio/channels/AsynchronousChannelGroup/Basic.java b/jdk/test/java/nio/channels/AsynchronousChannelGroup/Basic.java index 8c6b5cb7020..1c5da1309b3 100644 --- a/jdk/test/java/nio/channels/AsynchronousChannelGroup/Basic.java +++ b/jdk/test/java/nio/channels/AsynchronousChannelGroup/Basic.java @@ -24,8 +24,6 @@ /* @test * @bug 4607272 * @summary Unit test for AsynchronousChannelGroup - * @build Basic - * @run main/othervm -XX:-UseVMInterruptibleIO Basic */ import java.nio.ByteBuffer; @@ -37,12 +35,9 @@ import java.io.IOException; public class Basic { static final Random rand = new Random(); - static final ThreadFactory threadFactory = new ThreadFactory() { - @Override - public Thread newThread(final Runnable r) { - return new Thread(r); - }}; - + static final ThreadFactory threadFactory = (Runnable r) -> { + return new Thread(r); + }; public static void main(String[] args) throws Exception { shutdownTests(); @@ -51,6 +46,12 @@ public class Basic { miscTests(); } + static void awaitTermination(AsynchronousChannelGroup group) throws InterruptedException { + boolean terminated = group.awaitTermination(20, TimeUnit.SECONDS); + if (!terminated) + throw new RuntimeException("Group should have terminated"); + } + static void testShutdownWithNoChannels(ExecutorService pool, AsynchronousChannelGroup group) throws Exception @@ -59,9 +60,7 @@ public class Basic { if (!group.isShutdown()) throw new RuntimeException("Group should be shutdown"); // group should terminate quickly - boolean terminated = group.awaitTermination(3, TimeUnit.SECONDS); - if (!terminated) - throw new RuntimeException("Group should have terminated"); + awaitTermination(group); if (pool != null && !pool.isTerminated()) throw new RuntimeException("Executor should have terminated"); } @@ -86,9 +85,7 @@ public class Basic { ch.close(); // group should terminate quickly - boolean terminated = group.awaitTermination(3, TimeUnit.SECONDS); - if (!terminated) - throw new RuntimeException("Group should have terminated"); + awaitTermination(group); if (pool != null && !pool.isTerminated()) throw new RuntimeException("Executor should have terminated"); } @@ -153,9 +150,8 @@ public class Basic { if (ch.isOpen()) throw new RuntimeException("Channel should be closed"); - boolean terminated = group.awaitTermination(3, TimeUnit.SECONDS); - if (!terminated) - throw new RuntimeException("Group should have terminated"); + awaitTermination(group); + if (pool != null && !pool.isTerminated()) throw new RuntimeException("Executor should have terminated"); } @@ -260,9 +256,7 @@ public class Basic { // close channel; group should terminate quickly ch.close(); listener.close(); - terminated = group.awaitTermination(3, TimeUnit.SECONDS); - if (!terminated) - throw new RuntimeException("Group should have terminated"); + awaitTermination(group); } static void miscTests() throws Exception { diff --git a/jdk/test/java/nio/channels/AsynchronousChannelGroup/GroupOfOne.java b/jdk/test/java/nio/channels/AsynchronousChannelGroup/GroupOfOne.java index 2945343bfe0..ce7d3f63552 100644 --- a/jdk/test/java/nio/channels/AsynchronousChannelGroup/GroupOfOne.java +++ b/jdk/test/java/nio/channels/AsynchronousChannelGroup/GroupOfOne.java @@ -136,7 +136,7 @@ public class GroupOfOne { // clean-up group.shutdown(); - boolean terminated = group.awaitTermination(5, TimeUnit.SECONDS); + boolean terminated = group.awaitTermination(20, TimeUnit.SECONDS); if (!terminated) throw new RuntimeException("Group did not terminate"); diff --git a/jdk/test/java/nio/channels/AsynchronousChannelGroup/Restart.java b/jdk/test/java/nio/channels/AsynchronousChannelGroup/Restart.java index 5fb2f123b02..456f66a2eee 100644 --- a/jdk/test/java/nio/channels/AsynchronousChannelGroup/Restart.java +++ b/jdk/test/java/nio/channels/AsynchronousChannelGroup/Restart.java @@ -24,8 +24,6 @@ /* @test * @bug 4607272 6842687 * @summary Unit test for AsynchronousChannelGroup - * @build Restart - * @run main/othervm -XX:-UseVMInterruptibleIO Restart */ import java.nio.channels.*; diff --git a/jdk/test/java/nio/channels/Selector/ByteServer.java b/jdk/test/java/nio/channels/Selector/ByteServer.java index eefd1fb17a5..40d8adfb82c 100644 --- a/jdk/test/java/nio/channels/Selector/ByteServer.java +++ b/jdk/test/java/nio/channels/Selector/ByteServer.java @@ -22,52 +22,54 @@ */ /** - * - * Utility class for tests. A simple server, which waits for a connection, - * writes out n bytes and waits. + * Utility class for tests. A simple "in-thread" server to accept connections + * and write bytes. * @author kladko */ import java.net.Socket; import java.net.ServerSocket; +import java.net.SocketAddress; +import java.net.InetSocketAddress; +import java.io.IOException; +import java.io.Closeable; -public class ByteServer { +public class ByteServer implements Closeable { - public static final String LOCALHOST = "localhost"; - private int bytecount; - private Socket socket; - private ServerSocket serversocket; - private Thread serverthread; - volatile Exception savedException; + private final ServerSocket ss; + private Socket s; - public ByteServer(int bytecount) throws Exception{ - this.bytecount = bytecount; - serversocket = new ServerSocket(0); + ByteServer() throws IOException { + this.ss = new ServerSocket(0); } - public int port() { - return serversocket.getLocalPort(); + SocketAddress address() { + return new InetSocketAddress(ss.getInetAddress(), ss.getLocalPort()); } - public void start() { - serverthread = new Thread() { - public void run() { - try { - socket = serversocket.accept(); - socket.getOutputStream().write(new byte[bytecount]); - socket.getOutputStream().flush(); - } catch (Exception e) { - System.err.println("Exception in ByteServer: " + e); - System.exit(1); - } - } - }; - serverthread.start(); + void acceptConnection() throws IOException { + if (s != null) + throw new IllegalStateException("already connected"); + this.s = ss.accept(); } - public void exit() throws Exception { - serverthread.join(); - socket.close(); - serversocket.close(); + void closeConnection() throws IOException { + Socket s = this.s; + if (s != null) { + this.s = null; + s.close(); + } + } + + void write(int count) throws IOException { + if (s == null) + throw new IllegalStateException("no connection"); + s.getOutputStream().write(new byte[count]); + } + + public void close() throws IOException { + if (s != null) + s.close(); + ss.close(); } } diff --git a/jdk/test/java/nio/channels/Selector/ReadAfterConnect.java b/jdk/test/java/nio/channels/Selector/ReadAfterConnect.java index e5d0b091b82..93318fb6436 100644 --- a/jdk/test/java/nio/channels/Selector/ReadAfterConnect.java +++ b/jdk/test/java/nio/channels/Selector/ReadAfterConnect.java @@ -27,27 +27,25 @@ * @author kladko */ -import java.net.*; -import java.nio.*; -import java.nio.channels.*; +import java.nio.channels.Selector; +import java.nio.channels.SelectionKey; +import java.nio.channels.SocketChannel; public class ReadAfterConnect { - public static void main(String[] argv) throws Exception { - ByteServer server = new ByteServer(0); // server: accept connection and do nothing - server.start(); - InetSocketAddress isa = new InetSocketAddress( - InetAddress.getByName(ByteServer.LOCALHOST), server.port()); - Selector sel = Selector.open(); - SocketChannel sc = SocketChannel.open(); - sc.connect(isa); - sc.configureBlocking(false); - sc.register(sel, SelectionKey.OP_READ); - // Previously channel would get selected here, although there is nothing to read - if (sel.selectNow() != 0) - throw new Exception("Select returned nonzero value"); - sc.close(); - server.exit(); + try (ByteServer server = new ByteServer(); + SocketChannel sc = SocketChannel.open(server.address())) { + + server.acceptConnection(); + + try (Selector sel = Selector.open()) { + sc.configureBlocking(false); + sc.register(sel, SelectionKey.OP_READ); + // Previously channel would get selected here, although there is nothing to read + if (sel.selectNow() != 0) + throw new Exception("Select returned nonzero value"); + } + } } } diff --git a/jdk/test/java/nio/channels/Selector/SelectAfterRead.java b/jdk/test/java/nio/channels/Selector/SelectAfterRead.java index fccd9ddb56e..35631465217 100644 --- a/jdk/test/java/nio/channels/Selector/SelectAfterRead.java +++ b/jdk/test/java/nio/channels/Selector/SelectAfterRead.java @@ -28,60 +28,62 @@ * @author kladko */ -import java.net.*; -import java.nio.*; -import java.nio.channels.*; +import java.nio.ByteBuffer; +import java.nio.channels.Selector; +import java.nio.channels.SelectionKey; +import java.nio.channels.SocketChannel; public class SelectAfterRead { - final static int TIMEOUT = 1000; + private static final int TIMEOUT = 1000; public static void main(String[] argv) throws Exception { - InetAddress lh = InetAddress.getByName(ByteServer.LOCALHOST); // server: accept connection and write one byte - ByteServer server = new ByteServer(1); - server.start(); - Selector sel = Selector.open(); - SocketChannel sc = SocketChannel.open(); - sc.connect(new InetSocketAddress(lh, server.port())); - sc.read(ByteBuffer.allocate(1)); - sc.configureBlocking(false); - sc.register(sel, SelectionKey.OP_READ); - // previously on Windows select would select channel here, although there was - // nothing to read - if (sel.selectNow() != 0) - throw new Exception("Select returned nonzero value"); - sc.close(); - sel.close(); - server.exit(); + try (ByteServer server = new ByteServer(); + SocketChannel sc = SocketChannel.open(server.address())) { + + server.acceptConnection(); + server.write(1); + + try (Selector sel = Selector.open()) { + sc.read(ByteBuffer.allocate(1)); + sc.configureBlocking(false); + sc.register(sel, SelectionKey.OP_READ); + // previously on Windows select would select channel here, although there was + // nothing to read + if (sel.selectNow() != 0) + throw new Exception("Select returned nonzero value"); + } + } // Now we will test a two reads combination // server: accept connection and write two bytes - server = new ByteServer(2); - server.start(); - sc = SocketChannel.open(); - sc.connect(new InetSocketAddress(lh, server.port())); - sc.configureBlocking(false); - sel = Selector.open(); - sc.register(sel, SelectionKey.OP_READ); - if (sel.select(TIMEOUT) != 1) - throw new Exception("One selected key expected"); - sel.selectedKeys().clear(); - // previously on Windows a channel would get selected only once - if (sel.selectNow() != 1) - throw new Exception("One selected key expected"); - // Previously on Windows two consequent reads would cause select() - // to select a channel, although there was nothing remaining to - // read in the channel - if (sc.read(ByteBuffer.allocate(1)) != 1) - throw new Exception("One byte expected"); - if (sc.read(ByteBuffer.allocate(1)) != 1) - throw new Exception("One byte expected"); - if (sel.selectNow() != 0) - throw new Exception("Select returned nonzero value"); - sc.close(); - sel.close(); - server.exit(); + try (ByteServer server = new ByteServer(); + SocketChannel sc = SocketChannel.open(server.address())) { + + server.acceptConnection(); + server.write(2); + + try (Selector sel = Selector.open()) { + sc.configureBlocking(false); + sc.register(sel, SelectionKey.OP_READ); + if (sel.select(TIMEOUT) != 1) + throw new Exception("One selected key expected"); + sel.selectedKeys().clear(); + // previously on Windows a channel would get selected only once + if (sel.selectNow() != 1) + throw new Exception("One selected key expected"); + // Previously on Windows two consequent reads would cause select() + // to select a channel, although there was nothing remaining to + // read in the channel + if (sc.read(ByteBuffer.allocate(1)) != 1) + throw new Exception("One byte expected"); + if (sc.read(ByteBuffer.allocate(1)) != 1) + throw new Exception("One byte expected"); + if (sel.selectNow() != 0) + throw new Exception("Select returned nonzero value"); + } + } } } diff --git a/jdk/test/java/nio/channels/Selector/SelectWrite.java b/jdk/test/java/nio/channels/Selector/SelectWrite.java index 3c2d3d8870e..ab305edd174 100644 --- a/jdk/test/java/nio/channels/Selector/SelectWrite.java +++ b/jdk/test/java/nio/channels/Selector/SelectWrite.java @@ -22,36 +22,33 @@ */ /* @test - @bug 4645302 - @summary Socket with OP_WRITE would get selected only once - @author kladko + * @bug 4645302 + * @summary Socket with OP_WRITE would get selected only once + * @author kladko */ -import java.net.*; -import java.nio.*; -import java.nio.channels.*; - +import java.nio.channels.Selector; +import java.nio.channels.SelectionKey; +import java.nio.channels.SocketChannel; public class SelectWrite { public static void main(String[] argv) throws Exception { - ByteServer server = new ByteServer(0); - // server: accept connection and do nothing - server.start(); - InetSocketAddress isa = new InetSocketAddress( - InetAddress.getByName(ByteServer.LOCALHOST), server.port()); - Selector sel = Selector.open(); - SocketChannel sc = SocketChannel.open(); - sc.connect(isa); - sc.configureBlocking(false); - sc.register(sel, SelectionKey.OP_WRITE); - sel.select(); - sel.selectedKeys().clear(); - if (sel.select() == 0) { - throw new Exception("Select returned zero"); + try (ByteServer server = new ByteServer(); + SocketChannel sc = SocketChannel.open(server.address())) { + + server.acceptConnection(); + + try (Selector sel = Selector.open()) { + sc.configureBlocking(false); + sc.register(sel, SelectionKey.OP_WRITE); + sel.select(); + sel.selectedKeys().clear(); + if (sel.select() == 0) { + throw new Exception("Select returned zero"); + } + } } - sc.close(); - sel.close(); } } diff --git a/jdk/test/java/nio/charset/coders/CheckSJISMappingProp.sh b/jdk/test/java/nio/charset/coders/CheckSJISMappingProp.sh index fd76d5a5031..5c14e7392ec 100644 --- a/jdk/test/java/nio/charset/coders/CheckSJISMappingProp.sh +++ b/jdk/test/java/nio/charset/coders/CheckSJISMappingProp.sh @@ -34,7 +34,7 @@ OS=`uname -s` case "$OS" in - SunOS | Linux | Darwin ) ;; + SunOS | Linux | Darwin | AIX ) ;; # Skip locale test for Windows Windows* | CYGWIN* ) echo "Passed"; exit 0 ;; diff --git a/jdk/test/java/nio/charset/spi/basic.sh b/jdk/test/java/nio/charset/spi/basic.sh index 6b5ad3108ac..6bc60d140e7 100644 --- a/jdk/test/java/nio/charset/spi/basic.sh +++ b/jdk/test/java/nio/charset/spi/basic.sh @@ -48,7 +48,7 @@ JAR=$COMPILEJAVA/bin/jar DIR=`pwd` case `uname` in - SunOS | Linux | Darwin ) CPS=':' ;; + SunOS | Linux | Darwin | AIX ) CPS=':' ;; Windows* ) CPS=';' ;; CYGWIN* ) DIR=`/usr/bin/cygpath -a -s -m $DIR` @@ -81,7 +81,7 @@ if [ $# -gt 0 ]; then L="$1" shift s=`uname -s` - if [ $s != Linux -a $s != SunOS -a $s != Darwin ]; then + if [ $s != Linux -a $s != SunOS -a $s != Darwin -a $s != AIX ]; then echo "$L: Locales not supported on this system, skipping..." exit 0 fi diff --git a/jdk/test/java/nio/file/Files/Misc.java b/jdk/test/java/nio/file/Files/Misc.java index 191a4fa2807..5826d551d0b 100644 --- a/jdk/test/java/nio/file/Files/Misc.java +++ b/jdk/test/java/nio/file/Files/Misc.java @@ -22,7 +22,7 @@ */ /* @test - * @bug 4313887 6838333 8005566 + * @bug 4313887 6838333 8005566 8032220 * @summary Unit test for miscellenous methods in java.nio.file.Files * @library .. */ @@ -76,6 +76,11 @@ public class Misc { createDirectories(file.resolve("y")); throw new RuntimeException("failure expected"); } catch (IOException x) { } + + // the root directory always exists + Path root = Paths.get("/"); + Files.createDirectories(root); + Files.createDirectories(root.toAbsolutePath()); } /** diff --git a/jdk/test/java/nio/file/Files/SBC.java b/jdk/test/java/nio/file/Files/SBC.java index ab467266edf..d26428d5f60 100644 --- a/jdk/test/java/nio/file/Files/SBC.java +++ b/jdk/test/java/nio/file/Files/SBC.java @@ -235,7 +235,7 @@ public class SBC { try { Files.newByteChannel(link, READ, LinkOption.NOFOLLOW_LINKS); throw new RuntimeException(); - } catch (IOException x) { + } catch (IOException | UnsupportedOperationException x) { } finally { TestUtil.deleteUnchecked(link); } diff --git a/jdk/test/java/nio/file/Files/walkFileTree/find.sh b/jdk/test/java/nio/file/Files/walkFileTree/find.sh index 9a99147fda0..2549ad3cbbb 100644 --- a/jdk/test/java/nio/file/Files/walkFileTree/find.sh +++ b/jdk/test/java/nio/file/Files/walkFileTree/find.sh @@ -43,7 +43,14 @@ case "$OS" in echo "This test does not run on Windows" exit 0 ;; + AIX ) + CLASSPATH=${TESTCLASSES}:${TESTSRC} + # On AIX "find -follow" may core dump on recursive links without '-L' + # see: http://www-01.ibm.com/support/docview.wss?uid=isg1IV28143 + FIND_FOLLOW_OPT="-L" + ;; * ) + FIND_FOLLOW_OPT= CLASSPATH=${TESTCLASSES}:${TESTSRC} ;; esac @@ -65,7 +72,7 @@ if [ $? != 0 ]; then failures=`expr $failures + 1`; fi # cycles (sym links to ancestor directories), other versions do # not. For that reason we run PrintFileTree with the -printCycles # option when the output without this option differs to find(1). -find "$ROOT" -follow > out1 +find $FIND_FOLLOW_OPT "$ROOT" -follow > out1 $JAVA ${TESTVMOPTS} PrintFileTree -follow "$ROOT" > out2 diff out1 out2 if [ $? != 0 ]; diff --git a/jdk/test/java/rmi/RMISecurityManager/checkPackageAccess/CheckPackageAccess.java b/jdk/test/java/rmi/RMISecurityManager/checkPackageAccess/CheckPackageAccess.java index 32cbe5ff481..93d1ce8427d 100644 --- a/jdk/test/java/rmi/RMISecurityManager/checkPackageAccess/CheckPackageAccess.java +++ b/jdk/test/java/rmi/RMISecurityManager/checkPackageAccess/CheckPackageAccess.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 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 @@ -43,7 +43,7 @@ public class CheckPackageAccess { * access to classes in the sun.* hierarchy, which is what is specified * in the JDK's default java.security file. */ - private final static String restrictedClassName = "sun.misc.Ref"; + private final static String restrictedClassName = "sun.misc.Cache"; public static void main(String[] args) { diff --git a/jdk/test/java/rmi/activation/Activatable/extLoadedImpl/ext.sh b/jdk/test/java/rmi/activation/Activatable/extLoadedImpl/ext.sh index 9c7a2eac4ec..86dfff43f5b 100644 --- a/jdk/test/java/rmi/activation/Activatable/extLoadedImpl/ext.sh +++ b/jdk/test/java/rmi/activation/Activatable/extLoadedImpl/ext.sh @@ -33,7 +33,7 @@ OS=`uname -s` case "$OS" in - SunOS | Linux | Darwin ) + SunOS | Linux | Darwin | AIX ) PS=":" ;; Windows* | CYGWIN* ) diff --git a/jdk/test/java/rmi/activation/Activatable/inactiveGroup/InactiveGroup.java b/jdk/test/java/rmi/activation/Activatable/inactiveGroup/InactiveGroup.java index 238d3473a9e..4861e28a1eb 100644 --- a/jdk/test/java/rmi/activation/Activatable/inactiveGroup/InactiveGroup.java +++ b/jdk/test/java/rmi/activation/Activatable/inactiveGroup/InactiveGroup.java @@ -145,7 +145,9 @@ public class InactiveGroup * activation group's process hasn't gone away. */ System.err.println("Ping unicast object for existence"); - for (int i = 0; i < 10; i++) { + // set timeout 5 seconds + final long stopTime = System.currentTimeMillis() + 5000; + while (System.currentTimeMillis() < stopTime) { unicastObj.ping(); Thread.sleep(500); } diff --git a/jdk/test/java/rmi/activation/rmidViaInheritedChannel/RmidViaInheritedChannel.java b/jdk/test/java/rmi/activation/rmidViaInheritedChannel/RmidViaInheritedChannel.java index be9234d2fb9..6d81b0f1248 100644 --- a/jdk/test/java/rmi/activation/rmidViaInheritedChannel/RmidViaInheritedChannel.java +++ b/jdk/test/java/rmi/activation/rmidViaInheritedChannel/RmidViaInheritedChannel.java @@ -88,6 +88,17 @@ public class RmidViaInheritedChannel implements Callback { TestLibrary.RMIDVIAINHERITEDCHANNEL_ACTIVATION_PORT); rmid.addOptions(new String[]{ "-Djava.nio.channels.spi.SelectorProvider=RmidViaInheritedChannel$RmidSelectorProvider"}); + if (System.getProperty("os.name").startsWith("Windows") && + System.getProperty("os.version").startsWith("5.")) + { + /* Windows XP/2003 or older + * Need to expand ephemeral range to include RMI test ports + */ + rmid.addOptions(new String[]{ + "-Djdk.net.ephemeralPortRange.low=1024", + "-Djdk.net.ephemeralPortRange.high=64000" + }); + } rmid.start(); /* diff --git a/jdk/test/java/rmi/registry/readTest/readTest.sh b/jdk/test/java/rmi/registry/readTest/readTest.sh index bb37f65b4cc..812d0a42b54 100644 --- a/jdk/test/java/rmi/registry/readTest/readTest.sh +++ b/jdk/test/java/rmi/registry/readTest/readTest.sh @@ -29,8 +29,12 @@ # @run shell readTest.sh OS=`uname -s` +VER=`uname -r` +ARGS="" +REGARGS="" + case "$OS" in - SunOS | Linux | Darwin ) + SunOS | Linux | Darwin | AIX ) PS=":" FS="/" FILEURL="file:" @@ -39,11 +43,19 @@ case "$OS" in PS=";" FS="\\" FILEURL="file:/" + if [ "$VER" -eq "5" ]; then + ARGS="-Djdk.net.ephemeralPortRange.low=1024 -Djdk.net.ephemeralPortRange.high=65000" + REGARGS="-J-Djdk.net.ephemeralPortRange.low=1024 -J-Djdk.net.ephemeralPortRange.high=65000" + fi ;; CYGWIN* ) PS=";" FS="/" FILEURL="file:/" + if [ "$VER" -eq "5" ]; then + ARGS="-Djdk.net.ephemeralPortRange.low=1024 -Djdk.net.ephemeralPortRange.high=65000" + REGARGS="-J-Djdk.net.ephemeralPortRange.low=1024 -J-Djdk.net.ephemeralPortRange.high=65000" + fi ;; * ) echo "Unrecognized system!" @@ -61,8 +73,8 @@ RMIREG_OUT=rmi.out #start rmiregistry without any local classes on classpath cd rmi_tmp # NOTE: This RMI Registry port must match TestLibrary.READTEST_REGISTRY_PORT -${TESTJAVA}${FS}bin${FS}rmiregistry -J-Djava.rmi.server.useCodebaseOnly=false \ - ${TESTTOOLVMOPTS} 64005 > ..${FS}${RMIREG_OUT} 2>&1 & +${TESTJAVA}${FS}bin${FS}rmiregistry ${REGARGS} -J-Djava.rmi.server.useCodebaseOnly=false \ + ${TESTTOOLVMOPTS} 60005 > ..${FS}${RMIREG_OUT} 2>&1 & RMIREG_PID=$! # allow some time to start sleep 3 @@ -74,10 +86,10 @@ case "$OS" in ;; * ) CODEBASE=`pwd` - ;; + ;; esac # trailing / after code base is important for rmi codebase property. -${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -cp $TEST_CLASSPATH -Djava.rmi.server.codebase=${FILEURL}$CODEBASE/ readTest > OUT.TXT 2>&1 & +${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -cp $TEST_CLASSPATH ${ARGS} -Djava.rmi.server.codebase=${FILEURL}$CODEBASE/ readTest > OUT.TXT 2>&1 & TEST_PID=$! #bulk of testcase - let it run for a while sleep 5 @@ -100,7 +112,7 @@ grep "Test passed" OUT.TXT result2=$? if [ $result1 -eq 0 -a $result2 -eq 0 ] -then +then echo "Passed" exitCode=0; else @@ -108,6 +120,6 @@ else exitCode=1 fi rm -rf OUT.TXT ${RMIREG_OUT} rmi_tmp -exit ${exitCode} +exit ${exitCode} diff --git a/jdk/test/java/rmi/reliability/benchmark/bench/serial/Main.java b/jdk/test/java/rmi/reliability/benchmark/bench/serial/Main.java index 3e83a5babd8..8f9b715867f 100644 --- a/jdk/test/java/rmi/reliability/benchmark/bench/serial/Main.java +++ b/jdk/test/java/rmi/reliability/benchmark/bench/serial/Main.java @@ -43,10 +43,13 @@ * @build bench.serial.ReplaceTrees bench.serial.ShortArrays * @build bench.serial.Shorts bench.serial.SmallObjTrees * @build bench.serial.StreamBuffer bench.serial.Strings - * @run main/othervm/timeout=1800 bench.serial.Main -c jtreg-config + * @run main/othervm/timeout=1800 -Xss2m bench.serial.Main -c jtreg-config * @author Mike Warres, Nigel Daley */ +// The -Xss2m supplies additional stack space, as bench.serial.ClassDesc +// consumes a considerable amount of stack. + package bench.serial; import bench.ConfigFormatException; diff --git a/jdk/test/java/rmi/reliability/juicer/ApplicationServer.java b/jdk/test/java/rmi/reliability/juicer/ApplicationServer.java index 9e4b404dd35..e35c1608cd2 100644 --- a/jdk/test/java/rmi/reliability/juicer/ApplicationServer.java +++ b/jdk/test/java/rmi/reliability/juicer/ApplicationServer.java @@ -21,6 +21,7 @@ * questions. */ +import java.rmi.NotBoundException; import java.rmi.RemoteException; import java.rmi.registry.Registry; import java.rmi.registry.LocateRegistry; @@ -60,27 +61,29 @@ public class ApplicationServer implements Runnable { * On initialization, export remote objects and register * them with server. */ + @Override public void run() { try { int i = 0; /* - * Locate apple user object in registry. The lookup will - * occur until it is successful or fails LOOKUP_ATTEMPTS times. + * Locate apple user object in registry. The lookup will occur + * every 5 seconds until it is successful or timeout 50 seconds. * These repeated attempts allow the ApplicationServer * to be started before the AppleUserImpl. */ Exception exc = null; - for (i = 0; i < LOOKUP_ATTEMPTS; i++) { + long stopTime = System.currentTimeMillis() + LOOKUP_ATTEMPTS * 10000; + while (System.currentTimeMillis() < stopTime) { try { Registry registry = LocateRegistry.getRegistry( - registryHost, registryPort); + registryHost, registryPort); user = (AppleUser) registry.lookup("AppleUser"); user.startTest(); break; //successfully obtained AppleUser - } catch (Exception e) { + } catch (RemoteException | NotBoundException e) { exc = e; - Thread.sleep(10000); //sleep 10 seconds and try again + Thread.sleep(5000); //sleep 5 seconds and try again } } if (user == null) { @@ -113,9 +116,8 @@ public class ApplicationServer implements Runnable { logger.log(Level.SEVERE, "Failed to register callbacks for " + apples[i] + ":", e); user.reportException(e); - return; } - } catch (Exception e) { + } catch (InterruptedException | RemoteException e) { logger.log(Level.SEVERE, "Unexpected exception:", e); } } @@ -143,17 +145,22 @@ public class ApplicationServer implements Runnable { try { for (int i = 0; i < args.length ; i++ ) { String arg = args[i]; - if (arg.equals("-numApples")) { - i++; - num = Integer.parseInt(args[i]); - } else if (arg.equals("-registryHost")) { - i++; - host = args[i]; - } else if (arg.equals("-registryPort")) { - i++; - port = Integer.parseInt(args[i]); - } else { - usage(); + switch (arg) { + case "-numApples": + i++; + num = Integer.parseInt(args[i]); + break; + case "-registryHost": + i++; + host = args[i]; + break; + case "-registryPort": + i++; + port = Integer.parseInt(args[i]); + break; + default: + usage(); + break; } } diff --git a/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/UseCustomSocketFactory.java b/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/UseCustomSocketFactory.java index 5f032ec58cf..b300e1083bb 100644 --- a/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/UseCustomSocketFactory.java +++ b/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/UseCustomSocketFactory.java @@ -33,9 +33,8 @@ */ import java.io.*; +import java.net.MalformedURLException; import java.rmi.*; -import java.rmi.activation.*; -import java.rmi.server.*; import java.rmi.registry.*; public class UseCustomSocketFactory { @@ -51,7 +50,7 @@ public class UseCustomSocketFactory { try { LocateRegistry.createRegistry(REGISTRY_PORT); - } catch (Exception e) { + } catch (RemoteException e) { TestLibrary.bomb("creating registry", e); } @@ -92,15 +91,16 @@ public class UseCustomSocketFactory { protocol[i]); System.err.println("\nusing protocol: " + - (protocol[i] == "" ? "none" : protocol[i])); + ("".equals(protocol[i]) ? "none" : protocol[i])); try { /* spawn VM for EchoServer */ serverVM.start(); /* lookup server */ - int tries = 12; // need enough tries for slow machine. echo[i] = null; + // 24 seconds timeout + long stopTime = System.currentTimeMillis() + 24000; do { try { echo[i] = (Echo) Naming.lookup("//:" + REGISTRY_PORT + @@ -108,15 +108,14 @@ public class UseCustomSocketFactory { break; } catch (NotBoundException e) { try { - Thread.sleep(2000); - } catch (Exception ignore) { + Thread.sleep(200); + } catch (InterruptedException ignore) { } - continue; } - } while (--tries > 0); + } while (System.currentTimeMillis() < stopTime); if (echo[i] == null) - TestLibrary.bomb("server not bound in 12 tries", null); + TestLibrary.bomb("server not bound in 120 tries", null); /* invoke remote method and print result*/ System.err.println("Bound to " + echo[i]); @@ -135,9 +134,8 @@ public class UseCustomSocketFactory { serverVM.destroy(); try { Naming.unbind("//:" + REGISTRY_PORT + "/EchoServer"); - } catch (Exception e) { + } catch (RemoteException | NotBoundException | MalformedURLException e) { TestLibrary.bomb("unbinding EchoServer", e); - } } } @@ -152,7 +150,7 @@ public class UseCustomSocketFactory { for (int i = 0; i < echo.length; i++) { try { System.err.println("\nusing protocol: " + - (protocol[i] == "" ? "none" : protocol[i])); + ("".equals(protocol[i]) ? "none" : protocol[i])); byte[] data = ("Greetings, citizen " + System.getProperty("user.name") + "!").getBytes(); byte[] result = echo[i].echoNot(data); diff --git a/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/UseCustomSocketFactory.java b/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/UseCustomSocketFactory.java index 06571df79c1..8995aa3f213 100644 --- a/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/UseCustomSocketFactory.java +++ b/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/UseCustomSocketFactory.java @@ -33,9 +33,9 @@ * @run main/othervm/policy=security.policy/timeout=120 UseCustomSocketFactory */ -import java.io.*; +import java.io.IOException; +import java.net.MalformedURLException; import java.rmi.*; -import java.rmi.server.*; import java.rmi.registry.*; public class UseCustomSocketFactory { @@ -44,7 +44,7 @@ public class UseCustomSocketFactory { int registryPort = -1; - String[] protocol = new String[] { "", "compress", "xor" }; + String[] protocols = new String[] { "", "compress", "xor" }; System.out.println("\nRegression test for bug 4127826\n"); @@ -53,31 +53,26 @@ public class UseCustomSocketFactory { try { Registry registry = TestLibrary.createRegistryOnUnusedPort(); registryPort = TestLibrary.getRegistryPort(registry); - } catch (Exception e) { + } catch (RemoteException e) { TestLibrary.bomb("creating registry", e); } - - for (int i = 0; i < protocol.length; i++) { - + for (String protocol : protocols) { System.err.println("test policy: " + - TestParams.defaultPolicy); - - JavaVM serverVM = new JavaVM("EchoImpl", - "-Djava.security.policy=" + - TestParams.defaultPolicy + - " -Drmi.registry.port=" + - registryPort, - protocol[i]); + TestParams.defaultPolicy); + JavaVM serverVM = new JavaVM("EchoImpl", "-Djava.security.policy=" + + TestParams.defaultPolicy + + " -Drmi.registry.port=" + + registryPort, protocol); System.err.println("\nusing protocol: " + - (protocol[i] == "" ? "none" : protocol[i])); - + ("".equals(protocol) ? "none" : protocol)); try { /* spawn VM for EchoServer */ serverVM.start(); /* lookup server */ - int tries = 8; Echo obj = null; + // 16 seconds timeout + long stopTime = System.currentTimeMillis() + 16000; do { try { obj = (Echo) Naming.lookup("//:" + registryPort + @@ -85,12 +80,11 @@ public class UseCustomSocketFactory { break; } catch (NotBoundException e) { try { - Thread.sleep(2000); - } catch (Exception ignore) { + Thread.sleep(200); + } catch (InterruptedException ignore) { } - continue; } - } while (--tries > 0); + } while (System.currentTimeMillis() < stopTime); if (obj == null) TestLibrary.bomb("server not bound in 8 tries", null); @@ -98,21 +92,21 @@ public class UseCustomSocketFactory { /* invoke remote method and print result*/ System.err.println("Bound to " + obj); byte[] data = ("Greetings, citizen " + - System.getProperty("user.name") + "!"). getBytes(); + System.getProperty("user.name") + "!"). getBytes(); byte[] result = obj.echoNot(data); for (int j = 0; j < result.length; j++) result[j] = (byte) ~result[j]; System.err.println("Result: " + new String(result)); - } catch (Exception e) { + } catch (IOException e) { TestLibrary.bomb("test failed", e); } finally { serverVM.destroy(); try { Naming.unbind("//:" + registryPort + - "/EchoServer"); - } catch (Exception e) { + "/EchoServer"); + } catch (RemoteException | NotBoundException | MalformedURLException e) { TestLibrary.bomb("unbinding EchoServer", e); } diff --git a/jdk/test/java/rmi/server/RemoteObject/notExtending/NotExtending.java b/jdk/test/java/rmi/server/RemoteObject/notExtending/NotExtending.java index ef524a4dd8a..fd5ef1eacce 100644 --- a/jdk/test/java/rmi/server/RemoteObject/notExtending/NotExtending.java +++ b/jdk/test/java/rmi/server/RemoteObject/notExtending/NotExtending.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 @@ -123,7 +123,7 @@ public class NotExtending implements Remote { } /** - * Force desparate garbage collection so that all sun.misc.Ref instances + * Force desperate garbage collection so that soft references * will be cleared. * * This method is required with the JDK 1.1.x RMI runtime so that the diff --git a/jdk/test/java/rmi/testlibrary/ActivationLibrary.java b/jdk/test/java/rmi/testlibrary/ActivationLibrary.java index 5d21a4a32d4..fa6af600a35 100644 --- a/jdk/test/java/rmi/testlibrary/ActivationLibrary.java +++ b/jdk/test/java/rmi/testlibrary/ActivationLibrary.java @@ -66,7 +66,8 @@ public class ActivationLibrary { // We do as much as 50 deactivation trials, each separated by // at least 100 milliseconds sleep time (max sleep time of 5 secs). final long deactivateSleepTime = 100; - for (int i = 0; i < 50; i ++) { + long stopTime = System.currentTimeMillis() + deactivateSleepTime * 50; + while (System.currentTimeMillis() < stopTime) { try { if (Activatable.inactive(id) == true) { mesg("inactive successful"); diff --git a/jdk/test/java/rmi/testlibrary/JavaVM.java b/jdk/test/java/rmi/testlibrary/JavaVM.java index a1b169823cd..34680569fbd 100644 --- a/jdk/test/java/rmi/testlibrary/JavaVM.java +++ b/jdk/test/java/rmi/testlibrary/JavaVM.java @@ -59,9 +59,6 @@ public class JavaVM { } } - public JavaVM(String classname) { - this.classname = classname; - } public JavaVM(String classname, String options, String args) { this.classname = classname; @@ -110,15 +107,6 @@ public class JavaVM { return TestLibrary.getExtraProperty("jcov.options",""); } - public void start(Runnable runnable) throws IOException { - if (runnable == null) { - throw new NullPointerException("Runnable cannot be null."); - } - - start(); - new JavaVMCallbackHandler(runnable).start(); - } - /** * Exec the VM as specified in this object's constructor. */ @@ -176,7 +164,7 @@ public class JavaVM { */ public int waitFor() throws InterruptedException { if (vm == null) - throw new IllegalStateException("can't wait for JavaVM that hasn't started"); + throw new IllegalStateException("can't wait for JavaVM that isn't running"); int status = vm.waitFor(); outPipe.join(); @@ -191,35 +179,4 @@ public class JavaVM { start(); return waitFor(); } - - /** - * Handles calling the callback. - */ - private class JavaVMCallbackHandler extends Thread { - Runnable runnable; - - JavaVMCallbackHandler(Runnable runnable) { - this.runnable = runnable; - } - - - /** - * Wait for the Process to terminate and notify the callback. - */ - @Override - public void run() { - if (vm != null) { - try { - vm.waitFor(); - } catch(InterruptedException ie) { - // Restore the interrupted status - Thread.currentThread().interrupt(); - } - } - - if (runnable != null) { - runnable.run(); - } - } - } } diff --git a/jdk/test/java/rmi/testlibrary/TestLibrary.java b/jdk/test/java/rmi/testlibrary/TestLibrary.java index 87733be8e8f..8c28b8994ab 100644 --- a/jdk/test/java/rmi/testlibrary/TestLibrary.java +++ b/jdk/test/java/rmi/testlibrary/TestLibrary.java @@ -86,13 +86,13 @@ public class TestLibrary { * FIXED_PORT_MIN or above FIXED_PORT_MAX, then adjust * FIXED_PORT_MIN/MAX appropriately. */ - public final static int FIXED_PORT_MIN = 64001; - public final static int FIXED_PORT_MAX = 64010; - public final static int RMIDVIAINHERITEDCHANNEL_ACTIVATION_PORT = 64001; - public final static int RMIDVIAINHERITEDCHANNEL_REGISTRY_PORT = 64002; - public final static int INHERITEDCHANNELNOTSERVERSOCKET_ACTIVATION_PORT = 64003; - public final static int INHERITEDCHANNELNOTSERVERSOCKET_REGISTRY_PORT = 64004; - public final static int READTEST_REGISTRY_PORT = 64005; + public final static int FIXED_PORT_MIN = 60001; + public final static int FIXED_PORT_MAX = 60010; + public final static int RMIDVIAINHERITEDCHANNEL_ACTIVATION_PORT = 60001; + public final static int RMIDVIAINHERITEDCHANNEL_REGISTRY_PORT = 60002; + public final static int INHERITEDCHANNELNOTSERVERSOCKET_ACTIVATION_PORT = 60003; + public final static int INHERITEDCHANNELNOTSERVERSOCKET_REGISTRY_PORT = 60004; + public final static int READTEST_REGISTRY_PORT = 60005; private final static int MAX_SERVER_SOCKET_TRIES = 2*(FIXED_PORT_MAX-FIXED_PORT_MIN+1); static void mesg(Object mesg) { diff --git a/jdk/test/java/rmi/transport/readTimeout/ReadTimeoutTest.java b/jdk/test/java/rmi/transport/readTimeout/ReadTimeoutTest.java index 3a0bfa1cafa..8363a96609d 100644 --- a/jdk/test/java/rmi/transport/readTimeout/ReadTimeoutTest.java +++ b/jdk/test/java/rmi/transport/readTimeout/ReadTimeoutTest.java @@ -44,6 +44,8 @@ import java.rmi.*; import java.rmi.server.RMISocketFactory; import java.io.*; import java.net.*; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; public class ReadTimeoutTest { @@ -86,23 +88,18 @@ public class ReadTimeoutTest InputStream stream = DoS.getInputStream(); // Read on the socket in the background - boolean[] successful = new boolean[] { false }; - (new SomeReader(stream, successful)).start(); + CountDownLatch done = new CountDownLatch(1); + (new SomeReader(stream, done)).start(); // Wait for completion - int nretries = 4; - while (nretries-- > 0) { - if (successful[0]) - break; - Thread.sleep(DELAY); - } - - if (successful[0]) { + if (done.await(DELAY * 4, TimeUnit.SECONDS)) { System.err.println("TEST PASSED."); } else { throw new Error("TEST FAILED."); } + } catch (InterruptedException ie) { + throw new Error("Unexpected interrupt", ie); } finally { try { if (DoS != null) @@ -120,6 +117,7 @@ public class ReadTimeoutTest { private int servport = 0; + @Override public Socket createSocket(String h, int p) throws IOException { @@ -130,6 +128,7 @@ public class ReadTimeoutTest * Aborts if createServerSocket(0) is called twice, because then * it doesn't know whether to remember the first or second port. */ + @Override public ServerSocket createServerSocket(int p) throws IOException { @@ -155,22 +154,23 @@ public class ReadTimeoutTest } // end class SomeFactory protected static class SomeReader extends Thread { - private InputStream readon; - private boolean[] vec; + private final InputStream readon; + private final CountDownLatch done; - public SomeReader(InputStream s, boolean[] successvec) { + public SomeReader(InputStream s, CountDownLatch done) { super(); this.setDaemon(true); this.readon = s; - this.vec = successvec; + this.done = done; } + @Override public void run() { try { int c = this.readon.read(); if (c != -1) throw new Error ("Server returned " + c); - this.vec[0] = true; + done.countDown(); } catch (IOException e) { e.printStackTrace(); diff --git a/jdk/test/java/security/Provider/ProviderVersionCheck.java b/jdk/test/java/security/Provider/ProviderVersionCheck.java index 555d1df9428..83a2f855e46 100644 --- a/jdk/test/java/security/Provider/ProviderVersionCheck.java +++ b/jdk/test/java/security/Provider/ProviderVersionCheck.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,7 +27,7 @@ import java.lang.Exception; /* * @test - * @bug 7122707 + * @bug 8030823 * @run main/othervm ProviderVersionCheck * @summary Verify all providers in the default Providers list have the proper * version for the release @@ -42,7 +42,7 @@ public class ProviderVersionCheck { for (Provider p: Security.getProviders()) { System.out.print(p.getName() + " "); - if (p.getVersion() != 1.8d) { + if (p.getVersion() != 1.9d) { System.out.println("failed. " + "Version received was " + p.getVersion()); failure = true; diff --git a/jdk/test/java/security/Security/ClassLoaderDeadlock/ClassLoaderDeadlock.sh b/jdk/test/java/security/Security/ClassLoaderDeadlock/ClassLoaderDeadlock.sh index 7f5dc78c23a..3794cd41bbb 100644 --- a/jdk/test/java/security/Security/ClassLoaderDeadlock/ClassLoaderDeadlock.sh +++ b/jdk/test/java/security/Security/ClassLoaderDeadlock/ClassLoaderDeadlock.sh @@ -62,6 +62,10 @@ case "$OS" in PATHSEP=":" FILESEP="/" ;; + AIX ) + PATHSEP=":" + FILESEP="/" + ;; CYGWIN* ) PATHSEP=";" FILESEP="/" diff --git a/jdk/test/java/security/Security/ClassLoaderDeadlock/Deadlock.sh b/jdk/test/java/security/Security/ClassLoaderDeadlock/Deadlock.sh index e1ed14425fa..f2002448566 100644 --- a/jdk/test/java/security/Security/ClassLoaderDeadlock/Deadlock.sh +++ b/jdk/test/java/security/Security/ClassLoaderDeadlock/Deadlock.sh @@ -46,6 +46,10 @@ case "$OS" in PATHSEP=":" FILESEP="/" ;; + AIX ) + PATHSEP=":" + FILESEP="/" + ;; CYGWIN* ) PATHSEP=";" FILESEP="/" diff --git a/jdk/test/java/security/Security/ClassLoaderDeadlock/Deadlock2.sh b/jdk/test/java/security/Security/ClassLoaderDeadlock/Deadlock2.sh index e817db37898..2951a28e549 100644 --- a/jdk/test/java/security/Security/ClassLoaderDeadlock/Deadlock2.sh +++ b/jdk/test/java/security/Security/ClassLoaderDeadlock/Deadlock2.sh @@ -70,6 +70,10 @@ case "$OS" in PATHSEP=":" FILESEP="/" ;; + AIX ) + PATHSEP=":" + FILESEP="/" + ;; Windows* ) PATHSEP=";" FILESEP="\\" diff --git a/jdk/test/java/security/Security/signedfirst/Dyn.sh b/jdk/test/java/security/Security/signedfirst/Dyn.sh index 73cff3e80da..019a2f46c60 100644 --- a/jdk/test/java/security/Security/signedfirst/Dyn.sh +++ b/jdk/test/java/security/Security/signedfirst/Dyn.sh @@ -62,6 +62,10 @@ case "$OS" in PATHSEP=":" FILESEP="/" ;; + AIX ) + PATHSEP=":" + FILESEP="/" + ;; CYGWIN* ) PATHSEP=";" FILESEP="/" diff --git a/jdk/test/java/security/Security/signedfirst/Static.sh b/jdk/test/java/security/Security/signedfirst/Static.sh index 46765e4a92b..b22ca05e184 100644 --- a/jdk/test/java/security/Security/signedfirst/Static.sh +++ b/jdk/test/java/security/Security/signedfirst/Static.sh @@ -62,6 +62,10 @@ case "$OS" in PATHSEP=":" FILESEP="/" ;; + AIX ) + PATHSEP=":" + FILESEP="/" + ;; CYGWIN* ) PATHSEP=";" FILESEP="/" diff --git a/jdk/test/java/security/cert/CertPathBuilder/selfIssued/DisableRevocation.java b/jdk/test/java/security/cert/CertPathBuilder/selfIssued/DisableRevocation.java index 8dbe8acc33e..9ce3ef46ac1 100644 --- a/jdk/test/java/security/cert/CertPathBuilder/selfIssued/DisableRevocation.java +++ b/jdk/test/java/security/cert/CertPathBuilder/selfIssued/DisableRevocation.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,6 +21,12 @@ * questions. */ +// +// Security properties, once set, cannot revert to unset. To avoid +// conflicts with tests running in the same VM isolate this test by +// running it in otherVM mode. +// + /** * @test * @bug 6852744 @@ -234,6 +240,10 @@ public final class DisableRevocation { public static void main(String[] args) throws Exception { + // MD5 is used in this test case, don't disable MD5 algorithm. + Security.setProperty( + "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + CertPathBuilder builder = CertPathBuilder.getInstance("PKIX"); X509CertSelector selector = generateSelector(args[0]); diff --git a/jdk/test/java/security/cert/CertPathBuilder/selfIssued/KeyUsageMatters.java b/jdk/test/java/security/cert/CertPathBuilder/selfIssued/KeyUsageMatters.java index 53b3aceda52..75bf2ec5a02 100644 --- a/jdk/test/java/security/cert/CertPathBuilder/selfIssued/KeyUsageMatters.java +++ b/jdk/test/java/security/cert/CertPathBuilder/selfIssued/KeyUsageMatters.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,6 +21,12 @@ * questions. */ +// +// Security properties, once set, cannot revert to unset. To avoid +// conflicts with tests running in the same VM isolate this test by +// running it in otherVM mode. +// + /** * @test * @bug 6852744 @@ -277,6 +283,10 @@ public final class KeyUsageMatters { public static void main(String[] args) throws Exception { + // MD5 is used in this test case, don't disable MD5 algorithm. + Security.setProperty( + "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + CertPathBuilder builder = CertPathBuilder.getInstance("PKIX"); X509CertSelector selector = generateSelector(args[0]); diff --git a/jdk/test/java/security/cert/CertPathBuilder/selfIssued/StatusLoopDependency.java b/jdk/test/java/security/cert/CertPathBuilder/selfIssued/StatusLoopDependency.java index 873237cf3b8..6d0b24bef32 100644 --- a/jdk/test/java/security/cert/CertPathBuilder/selfIssued/StatusLoopDependency.java +++ b/jdk/test/java/security/cert/CertPathBuilder/selfIssued/StatusLoopDependency.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,6 +21,12 @@ * questions. */ +// +// Security properties, once set, cannot revert to unset. To avoid +// conflicts with tests running in the same VM isolate this test by +// running it in otherVM mode. +// + /** * @test * @bug 6852744 @@ -283,6 +289,10 @@ public final class StatusLoopDependency { public static void main(String[] args) throws Exception { + // MD5 is used in this test case, don't disable MD5 algorithm. + Security.setProperty( + "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + CertPathBuilder builder = CertPathBuilder.getInstance("PKIX"); X509CertSelector selector = generateSelector(args[0]); diff --git a/jdk/test/java/security/cert/CertPathValidator/OCSP/AIACheck.java b/jdk/test/java/security/cert/CertPathValidator/OCSP/AIACheck.java index 9f8d697740a..8c6e0458b33 100644 --- a/jdk/test/java/security/cert/CertPathValidator/OCSP/AIACheck.java +++ b/jdk/test/java/security/cert/CertPathValidator/OCSP/AIACheck.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -21,12 +21,19 @@ * questions. */ +// +// Security properties, once set, cannot revert to unset. To avoid +// conflicts with tests running in the same VM isolate this test by +// running it in otherVM mode. +// + /** * @test * @bug 5072953 * @summary Verify that the URL for an OCSP responder can be extracted from a * certificate's AuthorityInfoAccess extension when OCSP certifiate * validation has been enabled. + * @run main/othervm AIACheck */ import java.io.*; @@ -51,6 +58,10 @@ public class AIACheck { } public static void main(String args[]) throws Exception { + // MD5 is used in this test case, don't disable MD5 algorithm. + Security.setProperty( + "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + X509Certificate aiaCert = loadCertificate("AIACert.pem"); X509Certificate rootCert = loadCertificate("RootCert.pem"); diff --git a/jdk/test/java/security/cert/CertPathValidator/OCSP/FailoverToCRL.java b/jdk/test/java/security/cert/CertPathValidator/OCSP/FailoverToCRL.java index 29abf024e9f..d1e4e8c6a29 100644 --- a/jdk/test/java/security/cert/CertPathValidator/OCSP/FailoverToCRL.java +++ b/jdk/test/java/security/cert/CertPathValidator/OCSP/FailoverToCRL.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,16 +21,24 @@ * questions. */ +// +// Security properties, once set, cannot revert to unset. To avoid +// conflicts with tests running in the same VM isolate this test by +// running it in otherVM mode. +// + /** * @test * @bug 6383095 * @summary CRL revoked certificate failures masked by OCSP failures - * + * @run main/othervm FailoverToCRL + * @author Xuelei Fan + */ + +/* * Note that the certificate validity is from Mar 16 14:55:35 2009 GMT to * Dec 1 14:55:35 2028 GMT, please update it with newer certificate if * expires. - * - * @author Xuelei Fan */ /* @@ -229,6 +237,10 @@ public class FailoverToCRL { } public static void main(String args[]) throws Exception { + // MD5 is used in this test case, don't disable MD5 algorithm. + Security.setProperty( + "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + CertPath path = generateCertificatePath(); Set anchors = generateTrustAnchors(); CertStore crls = generateCertificateStore(); diff --git a/jdk/test/java/security/cert/CertPathValidator/indirectCRL/CircularCRLOneLevel.java b/jdk/test/java/security/cert/CertPathValidator/indirectCRL/CircularCRLOneLevel.java index c850b82ed63..9a21ae2de0d 100644 --- a/jdk/test/java/security/cert/CertPathValidator/indirectCRL/CircularCRLOneLevel.java +++ b/jdk/test/java/security/cert/CertPathValidator/indirectCRL/CircularCRLOneLevel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,11 +21,18 @@ * questions. */ +// +// Security properties, once set, cannot revert to unset. To avoid +// conflicts with tests running in the same VM isolate this test by +// running it in otherVM mode. +// + /** * @test * * @bug 6720721 * @summary CRL check with circular depency support needed + * @run main/othervm CircularCRLOneLevel * @author Xuelei Fan */ @@ -158,6 +165,10 @@ public class CircularCRLOneLevel { } public static void main(String args[]) throws Exception { + // MD5 is used in this test case, don't disable MD5 algorithm. + Security.setProperty( + "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + CertPath path = generateCertificatePath(); Set anchors = generateTrustAnchors(); CertStore crls = generateCertificateStore(); diff --git a/jdk/test/java/security/cert/CertPathValidator/indirectCRL/CircularCRLOneLevelRevoked.java b/jdk/test/java/security/cert/CertPathValidator/indirectCRL/CircularCRLOneLevelRevoked.java index ebbb3b09e4d..944483683ba 100644 --- a/jdk/test/java/security/cert/CertPathValidator/indirectCRL/CircularCRLOneLevelRevoked.java +++ b/jdk/test/java/security/cert/CertPathValidator/indirectCRL/CircularCRLOneLevelRevoked.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,11 +21,18 @@ * questions. */ +// +// Security properties, once set, cannot revert to unset. To avoid +// conflicts with tests running in the same VM isolate this test by +// running it in otherVM mode. +// + /** * @test * * @bug 6720721 * @summary CRL check with circular depency support needed + * @run main/othervm CircularCRLOneLevelRevoked * @author Xuelei Fan */ @@ -159,6 +166,10 @@ public class CircularCRLOneLevelRevoked { } public static void main(String args[]) throws Exception { + // MD5 is used in this test case, don't disable MD5 algorithm. + Security.setProperty( + "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + CertPath path = generateCertificatePath(); Set anchors = generateTrustAnchors(); CertStore crls = generateCertificateStore(); diff --git a/jdk/test/java/security/cert/CertPathValidator/indirectCRL/CircularCRLTwoLevel.java b/jdk/test/java/security/cert/CertPathValidator/indirectCRL/CircularCRLTwoLevel.java index d8ca3356ab6..d67db44e396 100644 --- a/jdk/test/java/security/cert/CertPathValidator/indirectCRL/CircularCRLTwoLevel.java +++ b/jdk/test/java/security/cert/CertPathValidator/indirectCRL/CircularCRLTwoLevel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,11 +21,18 @@ * questions. */ +// +// Security properties, once set, cannot revert to unset. To avoid +// conflicts with tests running in the same VM isolate this test by +// running it in otherVM mode. +// + /** * @test * * @bug 6720721 * @summary CRL check with circular depency support needed + * @run main/othervm CircularCRLTwoLevel * @author Xuelei Fan */ @@ -210,6 +217,10 @@ public class CircularCRLTwoLevel { } public static void main(String args[]) throws Exception { + // MD5 is used in this test case, don't disable MD5 algorithm. + Security.setProperty( + "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + CertPath path = generateCertificatePath(); Set anchors = generateTrustAnchors(); CertStore crls = generateCertificateStore(); diff --git a/jdk/test/java/security/cert/CertPathValidator/indirectCRL/CircularCRLTwoLevelRevoked.java b/jdk/test/java/security/cert/CertPathValidator/indirectCRL/CircularCRLTwoLevelRevoked.java index 4405ded75ea..e67934b8a19 100644 --- a/jdk/test/java/security/cert/CertPathValidator/indirectCRL/CircularCRLTwoLevelRevoked.java +++ b/jdk/test/java/security/cert/CertPathValidator/indirectCRL/CircularCRLTwoLevelRevoked.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,11 +21,18 @@ * questions. */ +// +// Security properties, once set, cannot revert to unset. To avoid +// conflicts with tests running in the same VM isolate this test by +// running it in otherVM mode. +// + /** * @test * * @bug 6720721 * @summary CRL check with circular depency support needed + * @run main/othervm CircularCRLTwoLevelRevoked * @author Xuelei Fan */ @@ -211,6 +218,10 @@ public class CircularCRLTwoLevelRevoked { } public static void main(String args[]) throws Exception { + // MD5 is used in this test case, don't disable MD5 algorithm. + Security.setProperty( + "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + CertPath path = generateCertificatePath(); Set anchors = generateTrustAnchors(); CertStore crls = generateCertificateStore(); diff --git a/jdk/test/java/security/cert/PKIXBuilderParameters/InvalidParameters.java b/jdk/test/java/security/cert/PKIXBuilderParameters/InvalidParameters.java index d9ef366c481..e1c64a5e045 100644 --- a/jdk/test/java/security/cert/PKIXBuilderParameters/InvalidParameters.java +++ b/jdk/test/java/security/cert/PKIXBuilderParameters/InvalidParameters.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2004, 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 @@ -21,16 +21,17 @@ * questions. */ -/** +/* * @test * @test 4422738 - * @compile -source 1.4 InvalidParameters.java + * @compile InvalidParameters.java * @run main InvalidParameters * @summary Make sure PKIXBuilderParameters(Set) detects invalid * parameters and throws correct exceptions */ import java.security.InvalidAlgorithmParameterException; import java.security.cert.PKIXBuilderParameters; +import java.security.cert.TrustAnchor; import java.util.Collections; import java.util.Set; @@ -53,8 +54,10 @@ public class InvalidParameters { // make sure Set of invalid objects throws ClassCastException try { + @SuppressWarnings("unchecked") // Knowingly do something bad + Set badSet = (Set) (Set) Collections.singleton(new String()); PKIXBuilderParameters p = - new PKIXBuilderParameters(Collections.singleton(new String()), null); + new PKIXBuilderParameters(badSet, null); throw new Exception("should have thrown ClassCastException"); } catch (ClassCastException cce) { } } diff --git a/jdk/test/java/security/cert/PKIXParameters/InvalidParameters.java b/jdk/test/java/security/cert/PKIXParameters/InvalidParameters.java index 3e16fa64d1d..ebce8a18347 100644 --- a/jdk/test/java/security/cert/PKIXParameters/InvalidParameters.java +++ b/jdk/test/java/security/cert/PKIXParameters/InvalidParameters.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2004, 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 @@ -24,7 +24,7 @@ /** * @test * @test 4422738 - * @compile -source 1.4 InvalidParameters.java + * @compile InvalidParameters.java * @run main InvalidParameters * @summary Make sure PKIXParameters(Set) and setTrustAnchors() detects invalid * parameters and throws correct exceptions @@ -64,12 +64,14 @@ public class InvalidParameters { } catch (NullPointerException npe) { } // make sure Set of invalid objects throws ClassCastException + @SuppressWarnings("unchecked") // Knowingly do something bad + Set badSet = (Set) (Set) Collections.singleton(new String()); try { - PKIXParameters p = new PKIXParameters(Collections.singleton(new String())); + PKIXParameters p = new PKIXParameters(badSet); throw new Exception("should have thrown ClassCastException"); } catch (ClassCastException cce) { } try { - params.setTrustAnchors(Collections.singleton(new String())); + params.setTrustAnchors(badSet); throw new Exception("should have thrown ClassCastException"); } catch (ClassCastException cce) { } } diff --git a/jdk/test/java/security/cert/X509Certificate/X509BadCertificate.java b/jdk/test/java/security/cert/X509Certificate/X509BadCertificate.java new file mode 100644 index 00000000000..b2a6c6923fa --- /dev/null +++ b/jdk/test/java/security/cert/X509Certificate/X509BadCertificate.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8028431 + * @summary Make sure that proper CertificateException is thrown + * when loading bad x509 certificate + * @author Artem Smotrakov + */ + +import java.io.File; +import java.io.FileInputStream; +import java.security.cert.CertificateFactory; +import java.security.cert.X509Certificate; +import java.security.cert.CertificateException; + +public class X509BadCertificate { + + public static void main(String[] args) throws Exception { + test("bad-cert-1.pem"); + } + + /** + * Parse X509 certificates. + */ + static void test(String filename) throws Exception { + try { + System.out.println("Parse file " + filename); + File f = new File(System.getProperty("test.src", "."), filename); + try (FileInputStream fis = new FileInputStream(f)) { + CertificateFactory cf = CertificateFactory.getInstance("X509"); + X509Certificate cert = (X509Certificate) + cf.generateCertificate(fis); + } + throw new Exception("Test failed: " + + "expected CertificateParsingException was not thrown"); + } catch (CertificateException e) { + System.out.println("Test passed: expected exception was thrown: " + + e.toString()); + } + } +} diff --git a/jdk/test/java/security/cert/X509Certificate/bad-cert-1.pem b/jdk/test/java/security/cert/X509Certificate/bad-cert-1.pem new file mode 100644 index 00000000000..0e6c355d0fd --- /dev/null +++ b/jdk/test/java/security/cert/X509Certificate/bad-cert-1.pem @@ -0,0 +1,21 @@ +-----BEGIN CERTIFICATE----- +MIIDZzCCAk+gAwIBAgIJAJYB3qu9C2kiMA0GCSqGSIb3DQEBBQUAMEoxDTALBgNV +BAMMBFRlc3QxDTALBgNVBAsMBEphdmExDzANBgNVBAoMBk9yYWNsZTEMMAoGA1UE +BwwDU1BCMQswCQYDVQQGEwJSVTAeFw0xMzEyMjMwNzA4MDhaFw0yMzEyMjEwNzA4 +MDhaMEoxDTALBgNVBAMMBFRlc3QxDTALBgNVBAsMBEphdmExDzANBgNVBAoMBk9y +YWNsZTEMMAoGA1UMBwwDU1BCMQswCQYDVQQGEwJSVTCCASIwDQYJKoZIhvcNAQEB +BQADggEPADCCAQoCggEBAOqiCN4gFxehl547Q7/VNGbGApr+wszLdanHPucAH6Wf +LtcRhKNUSqtBAQxEpFrTpMNEqm2GElAjiPa6m48qIjLVSvOb/9w3G/yXB8zyZbIm +/Nfp2sT4OEaa1JSEZSpolhS4FfqYzjGQp5cn4Xn4zKjDgiceHgfLls5x2dRydQZO +Yf91qSIioZxVHUtlo8yztkieiSaqPWt3nJ4PIwhFbsu1HVmWaYZD+nBYCKgVHqrS +cueO98Ca4Doz73O27X1dVbQBdLS0JI7qVAG8LD388iPL8qbsOkgWPzmEQ+kLRKO4 +g7RpuwlXuwaMSh95NWaxlu4Ob6GRJQmpconYoe13+7ECAwEAAaNQME4wHQYDVR0O +BBYEFIG8TPobXcbNbDi+zKudd9whpxoNMB8GA1UdIwQYMBaAFIG8TPobXcbNbDi+ +zKudd9whpxoNMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFRQADggEBAAynN+e7 +h+ufT5SBKN/gBuJAnF1mKIPESiipuv5KoYUGZOY8ShgYLcwY+qnbuHYFUlvq6Zns +K4/e+x/16h32vD7dEPkNvukbvER4YJQQiN6osDfXpTPzixYftWdmtX0u8xQfwb/g +R8DS7bazz99jVXk+jTK4yWBY+gMwEat+LyNQ5cyq8Qhi1oBKUbGRbiOts19B97fn +Rv8TsyXN3INLGYhdVxZoD7E5tyG1ydSFmOMadulAC2epBXDHOXZnz2UWauJc0XW5 +1L/YQVri47VkdHS3tisBzELEJdLmdMDb+5tAU+lItXmTXe2/PB53WIvsEIb4t+eQ +wY0hCj9lVJlajTQ= +-----END CERTIFICATE----- diff --git a/jdk/test/java/time/tck/java/time/AbstractTCKTest.java b/jdk/test/java/time/tck/java/time/AbstractTCKTest.java index 29c2aa9fe1a..d96011469a5 100644 --- a/jdk/test/java/time/tck/java/time/AbstractTCKTest.java +++ b/jdk/test/java/time/tck/java/time/AbstractTCKTest.java @@ -58,17 +58,18 @@ package tck.java.time; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertSame; +import static org.testng.Assert.fail; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.DataInputStream; +import java.io.DataOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.ObjectStreamConstants; import java.io.Serializable; import java.lang.reflect.Field; -import java.util.Arrays; import java.util.Formatter; /** @@ -164,6 +165,42 @@ public abstract class AbstractTCKTest { } } + /** + * Verify the class cannot be deserialized from a handcoded stream. + * Fail if the deserialization does not throw an Exception. + * @param serClass the class to embed in the handcoded stream + * @throws Exception if an unexpected condition occurs + */ + protected static void assertNotSerializable(Class serClass) throws Exception { + Field field = serClass.getDeclaredField("serialVersionUID"); + field.setAccessible(true); + long serVer = (Long) field.get(null); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + try (DataOutputStream out = new DataOutputStream(baos)) { + out.writeShort(ObjectStreamConstants.STREAM_MAGIC); + out.writeShort(ObjectStreamConstants.STREAM_VERSION); + out.writeByte(ObjectStreamConstants.TC_OBJECT); + out.writeByte(ObjectStreamConstants.TC_CLASSDESC); + out.writeUTF(serClass.getName()); + out.writeLong(serVer); + out.writeByte(ObjectStreamConstants.SC_SERIALIZABLE); // Flags ObjectStreamConstants + out.writeShort(0); // number of fields + out.writeByte(ObjectStreamConstants.TC_ENDBLOCKDATA); + out.writeByte(ObjectStreamConstants.TC_NULL); // no superclasses + } + + byte[] bytes = baos.toByteArray(); + + try (ByteArrayInputStream bis = new ByteArrayInputStream(bytes); + ObjectInputStream in = new ObjectInputStream(bis)) { + Object o = in.readObject(); + } catch (Exception ioe) { + // Expected exception + return; + } + fail("Class should not be deserializable " + serClass.getName()); + } + /** * Utility method to dump a byte array in a java syntax. diff --git a/jdk/test/java/time/tck/java/time/TCKLocalDateTime.java b/jdk/test/java/time/tck/java/time/TCKLocalDateTime.java index 6303f5acdc0..40ed5347589 100644 --- a/jdk/test/java/time/tck/java/time/TCKLocalDateTime.java +++ b/jdk/test/java/time/tck/java/time/TCKLocalDateTime.java @@ -1847,7 +1847,7 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { LocalDateTime dt = base.plusMinutes(i); t = t.plusMinutes(1); - if (t == LocalTime.MIDNIGHT) { + if (t.equals(LocalTime.MIDNIGHT)) { d = d.plusDays(1); } @@ -2539,7 +2539,7 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { LocalDateTime dt = base.minusMinutes(i); t = t.plusMinutes(1); - if (t == LocalTime.MIDNIGHT) { + if (t.equals(LocalTime.MIDNIGHT)) { d = d.plusDays(1); } diff --git a/jdk/test/java/time/tck/java/time/chrono/serial/TCKChronoLocalDateSerialization.java b/jdk/test/java/time/tck/java/time/chrono/serial/TCKChronoLocalDateSerialization.java index af6e9fb2e02..8116457b96a 100644 --- a/jdk/test/java/time/tck/java/time/chrono/serial/TCKChronoLocalDateSerialization.java +++ b/jdk/test/java/time/tck/java/time/chrono/serial/TCKChronoLocalDateSerialization.java @@ -161,4 +161,25 @@ public class TCKChronoLocalDateSerialization extends AbstractTCKTest { assertSerializedBySer(date, hijrahDateBytes, hijrahChronoBytes, dateBytes); } + + + //----------------------------------------------------------------------- + // Regular data factory for names and descriptions of available calendars + //----------------------------------------------------------------------- + @DataProvider(name = "invalidSerialformClasses") + Object[][] invalid_serial_classes() { + return new Object[][]{ + {JapaneseEra.class}, + {JapaneseDate.class}, + {MinguoDate.class}, + {ThaiBuddhistDate.class}, + {HijrahDate.class}, + }; + } + + @Test(dataProvider="invalidSerialformClasses") + public void test_invalid_serialform(Class clazz) throws Exception { + assertNotSerializable(clazz); + } + } diff --git a/jdk/test/java/time/tck/java/time/chrono/serial/TCKChronologySerialization.java b/jdk/test/java/time/tck/java/time/chrono/serial/TCKChronologySerialization.java index 7f9e30d35c5..c3222e281e6 100644 --- a/jdk/test/java/time/tck/java/time/chrono/serial/TCKChronologySerialization.java +++ b/jdk/test/java/time/tck/java/time/chrono/serial/TCKChronologySerialization.java @@ -111,4 +111,24 @@ public class TCKChronologySerialization extends AbstractTCKTest { assertSerializedBySer(chrono, bytes); } + + //----------------------------------------------------------------------- + // Regular data factory for names and descriptions of available calendars + //----------------------------------------------------------------------- + @DataProvider(name = "invalidSerialformClasses") + Object[][] invalid_serial_classes() { + return new Object[][]{ + {IsoChronology.class}, + {JapaneseChronology.class}, + {MinguoChronology.class}, + {ThaiBuddhistChronology.class}, + {HijrahChronology.class}, + }; + } + + @Test(dataProvider="invalidSerialformClasses") + public void test_invalid_serialform(Class clazz) throws Exception { + assertNotSerializable(clazz); + } + } diff --git a/jdk/test/java/time/tck/java/time/serial/TCKDurationSerialization.java b/jdk/test/java/time/tck/java/time/serial/TCKDurationSerialization.java index 15d079b9b41..b2251181572 100644 --- a/jdk/test/java/time/tck/java/time/serial/TCKDurationSerialization.java +++ b/jdk/test/java/time/tck/java/time/serial/TCKDurationSerialization.java @@ -110,4 +110,9 @@ public class TCKDurationSerialization extends AbstractTCKTest { assertSerializableSame(Duration.ZERO); } + @Test + public void test_invalid_serialform() throws Exception { + assertNotSerializable(Duration.class); + } + } diff --git a/jdk/test/java/time/tck/java/time/serial/TCKInstantSerialization.java b/jdk/test/java/time/tck/java/time/serial/TCKInstantSerialization.java index 34a7a513797..bb4eb47c8dd 100644 --- a/jdk/test/java/time/tck/java/time/serial/TCKInstantSerialization.java +++ b/jdk/test/java/time/tck/java/time/serial/TCKInstantSerialization.java @@ -91,5 +91,10 @@ public class TCKInstantSerialization extends AbstractTCKTest { assertSerializedBySer(Instant.ofEpochSecond(654321, 123456789), bytes); } + @Test + public void test_invalid_serialform() throws Exception { + assertNotSerializable(Instant.class); + } + } diff --git a/jdk/test/java/time/tck/java/time/serial/TCKLocalDateSerialization.java b/jdk/test/java/time/tck/java/time/serial/TCKLocalDateSerialization.java index c42fa5ece91..7a82822944b 100644 --- a/jdk/test/java/time/tck/java/time/serial/TCKLocalDateSerialization.java +++ b/jdk/test/java/time/tck/java/time/serial/TCKLocalDateSerialization.java @@ -102,4 +102,9 @@ public class TCKLocalDateSerialization extends AbstractTCKTest { assertSerializedBySer(LocalDate.of(2012, 9, 16), bytes); } + @Test + public void test_invalid_serialform() throws Exception { + assertNotSerializable(LocalDate.class); + } + } diff --git a/jdk/test/java/time/tck/java/time/serial/TCKLocalDateTimeSerialization.java b/jdk/test/java/time/tck/java/time/serial/TCKLocalDateTimeSerialization.java index aa739768808..c2078913808 100644 --- a/jdk/test/java/time/tck/java/time/serial/TCKLocalDateTimeSerialization.java +++ b/jdk/test/java/time/tck/java/time/serial/TCKLocalDateTimeSerialization.java @@ -99,4 +99,9 @@ public class TCKLocalDateTimeSerialization extends AbstractTCKTest { assertSerializedBySer(LocalDateTime.of(2012, 9, 16, 22, 17, 59, 459_000_000), bytes); } + @Test + public void test_invalid_serialform() throws Exception { + assertNotSerializable(LocalDateTime.class); + } + } diff --git a/jdk/test/java/time/tck/java/time/serial/TCKLocalTimeSerialization.java b/jdk/test/java/time/tck/java/time/serial/TCKLocalTimeSerialization.java index d78de651877..f03eb070233 100644 --- a/jdk/test/java/time/tck/java/time/serial/TCKLocalTimeSerialization.java +++ b/jdk/test/java/time/tck/java/time/serial/TCKLocalTimeSerialization.java @@ -141,5 +141,9 @@ public class TCKLocalTimeSerialization extends AbstractTCKTest { assertSerializedBySer(LocalTime.of(22, 17, 59, 459_000_000), bytes); } + @Test + public void test_invalid_serialform() throws Exception { + assertNotSerializable(LocalTime.class); + } } diff --git a/jdk/test/java/time/tck/java/time/serial/TCKMonthDaySerialization.java b/jdk/test/java/time/tck/java/time/serial/TCKMonthDaySerialization.java index 8650e7e641e..fff7ff5afa3 100644 --- a/jdk/test/java/time/tck/java/time/serial/TCKMonthDaySerialization.java +++ b/jdk/test/java/time/tck/java/time/serial/TCKMonthDaySerialization.java @@ -99,4 +99,9 @@ public class TCKMonthDaySerialization extends AbstractTCKTest { assertSerializedBySer(MonthDay.of(9, 16), bytes); } + @Test + public void test_invalid_serialform() throws Exception { + assertNotSerializable(MonthDay.class); + } + } diff --git a/jdk/test/java/time/tck/java/time/serial/TCKOffsetDateTimeSerialization.java b/jdk/test/java/time/tck/java/time/serial/TCKOffsetDateTimeSerialization.java index f2ff1afbb8a..1f08bd08fc0 100644 --- a/jdk/test/java/time/tck/java/time/serial/TCKOffsetDateTimeSerialization.java +++ b/jdk/test/java/time/tck/java/time/serial/TCKOffsetDateTimeSerialization.java @@ -111,4 +111,9 @@ public class TCKOffsetDateTimeSerialization extends AbstractTCKTest { assertSerializedBySer(OffsetDateTime.of(ldt, ZoneOffset.ofHours(1)), bytes); } + @Test + public void test_invalid_serialform() throws Exception { + assertNotSerializable(OffsetDateTime.class); + } + } diff --git a/jdk/test/java/time/tck/java/time/serial/TCKOffsetTimeSerialization.java b/jdk/test/java/time/tck/java/time/serial/TCKOffsetTimeSerialization.java index 292ef82d142..2052da6ac2e 100644 --- a/jdk/test/java/time/tck/java/time/serial/TCKOffsetTimeSerialization.java +++ b/jdk/test/java/time/tck/java/time/serial/TCKOffsetTimeSerialization.java @@ -107,5 +107,9 @@ public class TCKOffsetTimeSerialization extends AbstractTCKTest { assertSerializedBySer(OffsetTime.of(22, 17, 59, 464_000_000, ZoneOffset.ofHours(1)), bytes); } + @Test + public void test_invalid_serialform() throws Exception { + assertNotSerializable(OffsetTime.class); + } } diff --git a/jdk/test/java/time/tck/java/time/serial/TCKPeriodSerialization.java b/jdk/test/java/time/tck/java/time/serial/TCKPeriodSerialization.java index 57bb92f7dce..df1c6785567 100644 --- a/jdk/test/java/time/tck/java/time/serial/TCKPeriodSerialization.java +++ b/jdk/test/java/time/tck/java/time/serial/TCKPeriodSerialization.java @@ -78,4 +78,9 @@ public class TCKPeriodSerialization extends AbstractTCKTest { assertSerializable(Period.of(1, 2, 3)); } + @Test + public void test_invalid_serialform() throws Exception { + assertNotSerializable(Period.class); + } + } diff --git a/jdk/test/java/time/tck/java/time/serial/TCKYearMonthSerialization.java b/jdk/test/java/time/tck/java/time/serial/TCKYearMonthSerialization.java index 878b1639725..677aee4655f 100644 --- a/jdk/test/java/time/tck/java/time/serial/TCKYearMonthSerialization.java +++ b/jdk/test/java/time/tck/java/time/serial/TCKYearMonthSerialization.java @@ -100,4 +100,9 @@ public class TCKYearMonthSerialization extends AbstractTCKTest { assertSerializedBySer(YearMonth.of(2012, 9), bytes); } + @Test + public void test_invalid_serialform() throws Exception { + assertNotSerializable(YearMonth.class); + } + } diff --git a/jdk/test/java/time/tck/java/time/serial/TCKYearSerialization.java b/jdk/test/java/time/tck/java/time/serial/TCKYearSerialization.java index 12f3955dcc4..4167e35eb18 100644 --- a/jdk/test/java/time/tck/java/time/serial/TCKYearSerialization.java +++ b/jdk/test/java/time/tck/java/time/serial/TCKYearSerialization.java @@ -91,4 +91,9 @@ public class TCKYearSerialization extends AbstractTCKTest { assertSerializedBySer(Year.of(2012), bytes); } + @Test + public void test_invalid_serialform() throws Exception { + assertNotSerializable(Year.class); + } + } diff --git a/jdk/test/java/time/tck/java/time/serial/TCKZoneOffsetSerialization.java b/jdk/test/java/time/tck/java/time/serial/TCKZoneOffsetSerialization.java index 223d466fcb3..c2795c6b00b 100644 --- a/jdk/test/java/time/tck/java/time/serial/TCKZoneOffsetSerialization.java +++ b/jdk/test/java/time/tck/java/time/serial/TCKZoneOffsetSerialization.java @@ -114,5 +114,9 @@ public class TCKZoneOffsetSerialization extends AbstractTCKTest { assertSerializedBySer(ZoneOffset.ofTotalSeconds(53265), bytes); } + @Test + public void test_invalid_serialform() throws Exception { + assertNotSerializable(ZoneOffset.class); + } } diff --git a/jdk/test/java/time/tck/java/time/serial/TCKZonedDateTimeSerialization.java b/jdk/test/java/time/tck/java/time/serial/TCKZonedDateTimeSerialization.java index bde33acc04b..8200103cd62 100644 --- a/jdk/test/java/time/tck/java/time/serial/TCKZonedDateTimeSerialization.java +++ b/jdk/test/java/time/tck/java/time/serial/TCKZonedDateTimeSerialization.java @@ -139,4 +139,9 @@ public class TCKZonedDateTimeSerialization extends AbstractTCKTest { assertSerializedBySer(zdt, bytes); } + @Test + public void test_invalid_serialform() throws Exception { + assertNotSerializable(ZonedDateTime.class); + } + } diff --git a/jdk/test/java/time/tck/java/time/temporal/serial/TCKValueRangeSerialization.java b/jdk/test/java/time/tck/java/time/temporal/serial/TCKValueRangeSerialization.java index 9114bec6ca0..d99efd03535 100644 --- a/jdk/test/java/time/tck/java/time/temporal/serial/TCKValueRangeSerialization.java +++ b/jdk/test/java/time/tck/java/time/temporal/serial/TCKValueRangeSerialization.java @@ -60,11 +60,16 @@ package tck.java.time.temporal.serial; import static org.testng.Assert.assertEquals; +import static org.testng.Assert.fail; +import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.time.temporal.ValueRange; +import java.util.Arrays; import org.testng.annotations.Test; @@ -117,4 +122,57 @@ public class TCKValueRangeSerialization extends AbstractTCKTest { } } + @Test + public void test_invalid_serialform() throws Exception { + byte[] template = { + (byte)172, (byte)237, 0, 5, 115, 114, 0, 29, 106, 97, /* \u00ac \u00ed \u0000 \u0005 s r \u0000 \u001d j a */ + 118, 97, 46, 116, 105, 109, 101, 46, 116, 101, /* v a . t i m e . t e */ + 109, 112, 111, 114, 97, 108, 46, 86, 97, 108, /* m p o r a l . V a l */ + 117, 101, 82, 97, 110, 103, 101, (byte)154, 113, (byte)169, /* u e R a n g e \u009a q \u00a9 */ + 86, (byte)242, (byte)205, 90, (byte)184, 2, 0, 4, 74, 0, /* V \u00f2 \u00cd Z \u00b8 \u0002 \u0000 \u0004 J \u0000 */ + 10, 109, 97, 120, 76, 97, 114, 103, 101, 115, /* m a x L a r g e s */ + 116, 74, 0, 11, 109, 97, 120, 83, 109, 97, /* t J \u0000 \u000b m a x S m a */ + 108, 108, 101, 115, 116, 74, 0, 10, 109, 105,/* l l e s t J \u0000 m i */ + 110, 76, 97, 114, 103, 101, 115, 116, 74, 0, /* n L a r g e s t J \u0000 */ + 11, 109, 105, 110, 83, 109, 97, 108, 108, 101, /* \u000b m i n S m a l l e */ + 115, 116, 120, 112, 0, 0, 0, 0, 0, 0, /* s t x p \u0000 \u0000 \u0000 \u0000 \u0000 \u0000 */ + 0, 40, 0, 0, 0, 0, 0, 0, 0, 30, /* \u0000 ( \u0000 \u0000 \u0000 \u0000 \u0000 \u0000 \u0000 \u001e */ + 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, /* \u0000 \u0000 \u0000 \u0000 \u0000 \u0000 \u0000 \u0014 \u0000 \u0000 */ + 0, 0, 0, 0, 0, 10, /* \u0000 \u0000 \u0000 \u0000 \u0000 */ + }; + + // minSmallest > minLargest, insert invalid values and deserialize + byte[] bad1 = {0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 4}; + byte[] val = Arrays.copyOf(template, template.length); + System.arraycopy(bad1, 0, val, 114, bad1.length); + try (ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(val))) { + in.readObject(); + fail("Invalid minSmallest > minLargest " + ValueRange.class.getName()); + } catch (InvalidObjectException ioe) { + // Expected exception + } + + // maxSmallest > maxLargest, insert invalid values and deserialize + byte[] bad2 = {0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 4, 0, 0, 0, 3}; + val = Arrays.copyOf(template, template.length); + System.arraycopy(bad1, 0, val, 114, bad2.length); + try (ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(val))) { + in.readObject(); + fail("Invalid maxSmallest > maxLargest " + ValueRange.class.getName()); + } catch (InvalidObjectException ioe) { + // Expected exception + } + + // minLagest > maxLargest, insert invalid values and deserialize + byte[] bad3 = {0, 0, 0, 1, 0, 0, 0, 5, 0, 0, 0, 3, 0, 0, 0, 4}; + val = Arrays.copyOf(template, template.length); + System.arraycopy(bad1, 0, val, 114, bad3.length); + try (ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(val))) { + in.readObject(); + fail("Invalid minLagest > maxLargest " + ValueRange.class.getName()); + } catch (InvalidObjectException ioe) { + // Expected exception + } + } + } diff --git a/jdk/test/java/time/tck/java/time/temporal/serial/TCKWeekFieldsSerialization.java b/jdk/test/java/time/tck/java/time/temporal/serial/TCKWeekFieldsSerialization.java index 43f45a84f22..00186046c89 100644 --- a/jdk/test/java/time/tck/java/time/temporal/serial/TCKWeekFieldsSerialization.java +++ b/jdk/test/java/time/tck/java/time/temporal/serial/TCKWeekFieldsSerialization.java @@ -56,13 +56,21 @@ */ package tck.java.time.temporal.serial; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.fail; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; import tck.java.time.AbstractTCKTest; import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; import java.time.DayOfWeek; import java.time.temporal.WeekFields; +import java.util.Arrays; /** * Test serialization of WeekFields. @@ -90,5 +98,58 @@ public class TCKWeekFieldsSerialization extends AbstractTCKTest { return objects; } + @Test + public void test_invalid_serialform() throws Exception { + WeekFields wf = WeekFields.of(DayOfWeek.MONDAY, 7); + ByteArrayOutputStream baos = new ByteArrayOutputStream(64); + ObjectOutputStream out = new ObjectOutputStream(baos); + out.writeObject(wf); + byte[] template = baos.toByteArray(); + + // (minimalDays = 5) { + byte[] good1 = {0, 0, 0, 5}; + byte[] val = Arrays.copyOf(template, template.length); + System.arraycopy(good1, 0, val, 105, good1.length); + try (ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(val))) { + Object o = in.readObject(); + assertEquals(o, WeekFields.of(DayOfWeek.MONDAY, 5), "Should be MONDAY, min = 5"); + } catch (Exception ioe) { + fail("Unexpected exception " + ioe); + } + + // (minimalDays < 1) { + byte[] bad1 = {0, 0, 0, 0}; + val = Arrays.copyOf(template, template.length); + System.arraycopy(bad1, 0, val, 105, bad1.length); + try (ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(val))) { + in.readObject(); + fail("Invalid minimalDays < 1 " + WeekFields.class.getName()); + } catch (Exception ioe) { + // Expected exception + } + + // (minimalDays > 7) { + byte[] bad2 = {0, 0, 0, 8}; + val = Arrays.copyOf(template, template.length); + System.arraycopy(bad2, 0, val, 105, bad2.length); + try (ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(val))) { + in.readObject(); + fail("Invalid minimalDays > 7 " + WeekFields.class.getName()); + } catch (Exception ioe) { + // Expected exception + } + + // (StartDay = null) { + byte[] bad3 = {0x70}; + val = Arrays.copyOf(template, 110); + System.arraycopy(bad3, 0, val, 105 + 4, bad3.length); + try (ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(val))) { + in.readObject(); + fail("Invalid startDay == null " + WeekFields.class.getName()); + } catch (Exception ioe) { + // Expected exception + } + + } } diff --git a/jdk/test/java/time/tck/java/time/zone/serial/TCKZoneOffsetTransitionRuleSerialization.java b/jdk/test/java/time/tck/java/time/zone/serial/TCKZoneOffsetTransitionRuleSerialization.java index 9e4bf9b455e..42796f66f8f 100644 --- a/jdk/test/java/time/tck/java/time/zone/serial/TCKZoneOffsetTransitionRuleSerialization.java +++ b/jdk/test/java/time/tck/java/time/zone/serial/TCKZoneOffsetTransitionRuleSerialization.java @@ -133,4 +133,9 @@ public class TCKZoneOffsetTransitionRuleSerialization extends AbstractTCKTest { assertSerializable(test); } + @Test + public void test_invalid_serialform() throws Exception { + assertNotSerializable(ZoneOffsetTransitionRule.class); + } + } diff --git a/jdk/test/java/time/tck/java/time/zone/serial/TCKZoneOffsetTransitionSerialization.java b/jdk/test/java/time/tck/java/time/zone/serial/TCKZoneOffsetTransitionSerialization.java index e70fc747d88..01ffefe09df 100644 --- a/jdk/test/java/time/tck/java/time/zone/serial/TCKZoneOffsetTransitionSerialization.java +++ b/jdk/test/java/time/tck/java/time/zone/serial/TCKZoneOffsetTransitionSerialization.java @@ -110,4 +110,9 @@ public class TCKZoneOffsetTransitionSerialization extends AbstractTCKTest { assertSerializable(test); } + @Test + public void test_invalid_serialform() throws Exception { + assertNotSerializable(ZoneOffsetTransition.class); + } + } diff --git a/jdk/test/java/time/tck/java/time/zone/serial/TCKZoneRulesSerialization.java b/jdk/test/java/time/tck/java/time/zone/serial/TCKZoneRulesSerialization.java index 80237967990..5262d68eea0 100644 --- a/jdk/test/java/time/tck/java/time/zone/serial/TCKZoneRulesSerialization.java +++ b/jdk/test/java/time/tck/java/time/zone/serial/TCKZoneRulesSerialization.java @@ -70,11 +70,13 @@ import java.time.zone.ZoneRules; import static org.testng.Assert.assertEquals; +import tck.java.time.AbstractTCKTest; + /** * Test serialization of ZoneRules. */ @Test -public class TCKZoneRulesSerialization { +public class TCKZoneRulesSerialization extends AbstractTCKTest{ public void test_serialization_loaded() throws Exception { assertSerialization(europeLondon()); @@ -118,5 +120,9 @@ public class TCKZoneRulesSerialization { return ZoneId.of("America/New_York").getRules(); } + @Test + public void test_invalid_serialform() throws Exception { + assertNotSerializable(ZoneRules.class); + } } diff --git a/jdk/test/java/util/Calendar/GenericTimeZoneNamesTest.sh b/jdk/test/java/util/Calendar/GenericTimeZoneNamesTest.sh index ab3f4981c91..30d409cf6a4 100644 --- a/jdk/test/java/util/Calendar/GenericTimeZoneNamesTest.sh +++ b/jdk/test/java/util/Calendar/GenericTimeZoneNamesTest.sh @@ -32,10 +32,7 @@ STATUS=0 echo "Locale providers: default" -# TODO: The purpose of ja-JP is to make sure the fallback for generic -# names works. Remove ja-JP when adding generic names to localized -# resources. -if ! ${TESTJAVA}/bin/java -esa ${TESTVMOPTS} -cp "${TESTCLASSES}" GenericTimeZoneNamesTest en-US ja-JP; then +if ! ${TESTJAVA}/bin/java -esa ${TESTVMOPTS} -cp "${TESTCLASSES}" GenericTimeZoneNamesTest en-US; then STATUS=1 fi diff --git a/jdk/test/java/util/Currency/PropertiesTest.sh b/jdk/test/java/util/Currency/PropertiesTest.sh index 65ab89da2e0..01f1326cd2d 100644 --- a/jdk/test/java/util/Currency/PropertiesTest.sh +++ b/jdk/test/java/util/Currency/PropertiesTest.sh @@ -52,7 +52,7 @@ echo "CLASSPATH=${CLASSPATH}" # set platform-dependent variables OS=`uname -s` case "$OS" in - SunOS | Linux | Darwin ) + SunOS | Linux | Darwin | AIX ) PS=":" FS="/" ;; diff --git a/jdk/test/java/util/LinkedHashMap/Basic.java b/jdk/test/java/util/LinkedHashMap/Basic.java index 7048a02ba6e..83ca4347951 100644 --- a/jdk/test/java/util/LinkedHashMap/Basic.java +++ b/jdk/test/java/util/LinkedHashMap/Basic.java @@ -23,28 +23,29 @@ /** * @test - * @bug 4245809 + * @bug 4245809 8029795 * @summary Basic test for LinkedHashMap. (Based on MapBash) */ import java.util.*; +import java.util.function.*; import java.io.*; public class Basic { - static Random rnd = new Random(666); - static Object nil = new Integer(0); + final static Random rnd = new Random(666); + final static Integer nil = new Integer(0); public static void main(String[] args) throws Exception { int numItr = 500; int mapSize = 500; - // Linked List test + // Linked List testk for (int i=0; i m = new LinkedHashMap(); + Integer head = nil; for (int j=0; j m2 = new LinkedHashMap(); m2.putAll(m); m2.values().removeAll(m.keySet()); if (m2.size()!= 1 || !m2.containsValue(nil)) throw new Exception("Collection views test failed."); @@ -66,7 +67,7 @@ public class Basic { while (head != nil) { if (!m.containsKey(head)) throw new Exception("Linked list doesn't contain a link."); - Object newHead = m.get(head); + Integer newHead = m.get(head); if (newHead == null) throw new Exception("Could not retrieve a link."); m.remove(head); @@ -79,7 +80,7 @@ public class Basic { throw new Exception("Linked list size not as expected."); } - Map m = new LinkedHashMap(); + Map m = new LinkedHashMap(); for (int i=0; i m2 = new LinkedHashMap(); m2.putAll(m); if (!m.equals(m2)) throw new Exception("Clone not equal to original. (1)"); if (!m2.equals(m)) throw new Exception("Clone not equal to original. (2)"); - Set s = m.entrySet(), s2 = m2.entrySet(); + Set> s = m.entrySet(), s2 = m2.entrySet(); if (!s.equals(s2)) throw new Exception("Clone not equal to original. (3)"); if (!s2.equals(s)) @@ -137,7 +138,7 @@ public class Basic { // Test ordering properties with insert order m = new LinkedHashMap(); - List l = new ArrayList(mapSize); + List l = new ArrayList(mapSize); for (int i=0; i l2 = new ArrayList(l); Collections.shuffle(l2); for (int i=0; i f = (Integer y, Integer z) -> { + if (!Objects.equals(y,z)) + throw new RuntimeException("unequal " + y + "," + z); + return new Integer(z); + }; + + for (int i=0; i map = new LinkedHashMap<>(2, 0.75f, true); + map.put("first", null); + map.put("second", null); + + map.computeIfAbsent("first", l -> null); // should do nothing + + String key = map.keySet().stream() + .findFirst() + .orElseThrow(() -> new RuntimeException("no value")); + if(!"first".equals(key)) { + throw new RuntimeException("not expected value " + "first" + "!=" + key); + } + } +} diff --git a/jdk/test/java/util/Locale/Bug4175998Test.java b/jdk/test/java/util/Locale/Bug4175998Test.java index 55d92a6ce0d..e890ae9e667 100644 --- a/jdk/test/java/util/Locale/Bug4175998Test.java +++ b/jdk/test/java/util/Locale/Bug4175998Test.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -20,13 +20,15 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + /* - @test - @summary test ISO639-2 language codes - @compile -encoding ascii -source 5 Bug4175998Test.java - @run main Bug4175998Test - @bug 4175998 -*/ + * @test + * @summary test ISO639-2 language codes + * @compile -encoding ascii Bug4175998Test.java + * @run main Bug4175998Test + * @bug 4175998 + */ + /* * * @@ -731,7 +733,7 @@ pol pol Polish pon pon Pohnpeian por por Portuguese pra pra Prakrit languages -pro pro Provençal, Old (to 1500) +pro pro Proven\u00E7al, Old (to 1500) pus pus Pushto qaa-qtz qaa-qtz Reserved for local use que que Quechua diff --git a/jdk/test/java/util/Locale/LocaleCategory.sh b/jdk/test/java/util/Locale/LocaleCategory.sh index 7715d354225..989556a2477 100644 --- a/jdk/test/java/util/Locale/LocaleCategory.sh +++ b/jdk/test/java/util/Locale/LocaleCategory.sh @@ -52,7 +52,7 @@ echo "CLASSPATH=${CLASSPATH}" # set platform-dependent variables OS=`uname -s` case "$OS" in - SunOS | Linux | *BSD | Darwin ) + SunOS | Linux | *BSD | Darwin | AIX ) PS=":" FS="/" ;; diff --git a/jdk/test/java/util/Locale/LocaleProviders.sh b/jdk/test/java/util/Locale/LocaleProviders.sh index db6e4a92d62..58cd9c82060 100644 --- a/jdk/test/java/util/Locale/LocaleProviders.sh +++ b/jdk/test/java/util/Locale/LocaleProviders.sh @@ -56,7 +56,7 @@ echo "CLASSPATH=${CLASSPATH}" # set platform-dependent variables OS=`uname -s` case "$OS" in - SunOS | Linux | *BSD | Darwin ) + SunOS | Linux | *BSD | Darwin | AIX ) PS=":" FS="/" ;; diff --git a/jdk/test/java/util/Map/Defaults.java b/jdk/test/java/util/Map/Defaults.java index 46a49a63a51..9211ad6d06e 100644 --- a/jdk/test/java/util/Map/Defaults.java +++ b/jdk/test/java/util/Map/Defaults.java @@ -80,18 +80,22 @@ public class Defaults { @Test(dataProvider = "Map rw=true keys=withNull values=withNull") public void testPutIfAbsentNulls(String description, Map map) { + // null -> null assertTrue(map.containsKey(null), "null key absent"); assertNull(map.get(null), "value not null"); assertNull(map.putIfAbsent(null, EXTRA_VALUE), "previous not null"); + // null -> EXTRA_VALUE assertTrue(map.containsKey(null), "null key absent"); assertSame(map.get(null), EXTRA_VALUE, "unexpected value"); assertSame(map.putIfAbsent(null, null), EXTRA_VALUE, "previous not expected value"); assertTrue(map.containsKey(null), "null key absent"); assertSame(map.get(null), EXTRA_VALUE, "unexpected value"); assertSame(map.remove(null), EXTRA_VALUE, "removed unexpected value"); + // null -> assertFalse(map.containsKey(null), description + ": key present after remove"); assertNull(map.putIfAbsent(null, null), "previous not null"); + // null -> null assertTrue(map.containsKey(null), "null key absent"); assertNull(map.get(null), "value not null"); assertNull(map.putIfAbsent(null, EXTRA_VALUE), "previous not null"); @@ -100,15 +104,19 @@ public class Defaults { @Test(dataProvider = "Map rw=true keys=all values=all") public void testPutIfAbsent(String description, Map map) { + // 1 -> 1 assertTrue(map.containsKey(KEYS[1])); Object expected = map.get(KEYS[1]); assertTrue(null == expected || expected == VALUES[1]); assertSame(map.putIfAbsent(KEYS[1], EXTRA_VALUE), expected); assertSame(map.get(KEYS[1]), expected); + // EXTRA_KEY -> assertFalse(map.containsKey(EXTRA_KEY)); assertSame(map.putIfAbsent(EXTRA_KEY, EXTRA_VALUE), null); assertSame(map.get(EXTRA_KEY), EXTRA_VALUE); + assertSame(map.putIfAbsent(EXTRA_KEY, VALUES[2]), EXTRA_VALUE); + assertSame(map.get(EXTRA_KEY), EXTRA_VALUE); } @Test(dataProvider = "Map rw=all keys=all values=all") @@ -268,14 +276,28 @@ public class Defaults { @Test(dataProvider = "Map rw=true keys=withNull values=withNull") public void testComputeIfAbsentNulls(String description, Map map) { + // null -> null assertTrue(map.containsKey(null), "null key absent"); assertNull(map.get(null), "value not null"); - assertSame(map.computeIfAbsent(null, (k) -> EXTRA_VALUE), EXTRA_VALUE, description); - assertSame(map.get(null), EXTRA_VALUE, description); + assertSame(map.computeIfAbsent(null, (k) -> null), null, "not expected result"); + assertTrue(map.containsKey(null), "null key absent"); + assertNull(map.get(null), "value not null"); + assertSame(map.computeIfAbsent(null, (k) -> EXTRA_VALUE), EXTRA_VALUE, "not mapped to result"); + // null -> EXTRA_VALUE + assertTrue(map.containsKey(null), "null key absent"); + assertSame(map.get(null), EXTRA_VALUE, "not expected value"); + assertSame(map.remove(null), EXTRA_VALUE, "removed unexpected value"); + // null -> + assertFalse(map.containsKey(null), "null key present"); + assertSame(map.computeIfAbsent(null, (k) -> EXTRA_VALUE), EXTRA_VALUE, "not mapped to result"); + // null -> EXTRA_VALUE + assertTrue(map.containsKey(null), "null key absent"); + assertSame(map.get(null), EXTRA_VALUE, "not expected value"); } @Test(dataProvider = "Map rw=true keys=all values=all") public void testComputeIfAbsent(String description, Map map) { + // 1 -> 1 assertTrue(map.containsKey(KEYS[1])); Object expected = map.get(KEYS[1]); assertTrue(null == expected || expected == VALUES[1], description + String.valueOf(expected)); @@ -283,8 +305,12 @@ public class Defaults { assertSame(map.computeIfAbsent(KEYS[1], (k) -> EXTRA_VALUE), expected, description); assertSame(map.get(KEYS[1]), expected, description); + // EXTRA_KEY -> + assertFalse(map.containsKey(EXTRA_KEY)); + assertNull(map.computeIfAbsent(EXTRA_KEY, (k) -> null)); assertFalse(map.containsKey(EXTRA_KEY)); assertSame(map.computeIfAbsent(EXTRA_KEY, (k) -> EXTRA_VALUE), EXTRA_VALUE); + // EXTRA_KEY -> EXTRA_VALUE assertSame(map.get(EXTRA_KEY), EXTRA_VALUE); } @@ -741,7 +767,6 @@ public class Defaults { Collection cases = new ArrayList<>(); cases.addAll(makeMergeTestCases()); - cases.addAll(makeMergeNullValueTestCases()); return cases.iterator(); } @@ -764,32 +789,6 @@ public class Defaults { return cases; } - static Collection makeMergeNullValueTestCases() { - Collection cases = new ArrayList<>(); - - for( Object[] mapParams : makeAllRWMapsWithNulls() ) { - cases.add(new Object[] { mapParams[0], mapParams[1], Merging.Value.OLDVALUE, Merging.Value.NULL, Merging.Merger.NULL, Merging.Value.ABSENT, Merging.Value.NULL }); - } - - for( Object[] mapParams : makeAllRWMapsWithNulls() ) { - cases.add(new Object[] { mapParams[0], mapParams[1], Merging.Value.OLDVALUE, Merging.Value.NULL, Merging.Merger.RESULT, Merging.Value.RESULT, Merging.Value.RESULT }); - } - - for( Object[] mapParams : makeAllRWMapsWithNulls() ) { - cases.add(new Object[] { mapParams[0], mapParams[1], Merging.Value.ABSENT, Merging.Value.NULL, Merging.Merger.UNUSED, Merging.Value.ABSENT, Merging.Value.NULL }); - } - - for( Object[] mapParams : makeAllRWMapsWithNulls() ) { - cases.add(new Object[] { mapParams[0], mapParams[1], Merging.Value.NULL, Merging.Value.NULL, Merging.Merger.UNUSED, Merging.Value.ABSENT, Merging.Value.NULL }); - } - - for( Object[] mapParams : makeAllRWMapsWithNulls() ) { - cases.add(new Object[] { mapParams[0], mapParams[1], Merging.Value.NULL, Merging.Value.NEWVALUE, Merging.Merger.UNUSED, Merging.Value.NEWVALUE, Merging.Value.NEWVALUE }); - } - - return cases; - } - public interface Thrower { public void run() throws T; diff --git a/jdk/test/java/util/PluggableLocale/ExecTest.sh b/jdk/test/java/util/PluggableLocale/ExecTest.sh index 3aa001c86ca..a30d70312d2 100644 --- a/jdk/test/java/util/PluggableLocale/ExecTest.sh +++ b/jdk/test/java/util/PluggableLocale/ExecTest.sh @@ -62,7 +62,7 @@ echo "CLASSPATH=${CLASSPATH}" # set platform-dependent variables OS=`uname -s` case "$OS" in - SunOS | Linux | Darwin ) + SunOS | Linux | Darwin | AIX ) PS=":" FS="/" ;; diff --git a/jdk/test/java/util/ResourceBundle/Bug6299235Test.sh b/jdk/test/java/util/ResourceBundle/Bug6299235Test.sh index d348d495d50..d0eb2a2f609 100644 --- a/jdk/test/java/util/ResourceBundle/Bug6299235Test.sh +++ b/jdk/test/java/util/ResourceBundle/Bug6299235Test.sh @@ -31,7 +31,7 @@ # set platform-dependent variables OS=`uname -s` case "$OS" in - SunOS | Linux | Darwin ) + SunOS | Linux | Darwin | AIX ) PATHSEP=":" FILESEP="/" ;; diff --git a/jdk/test/java/util/ServiceLoader/basic.sh b/jdk/test/java/util/ServiceLoader/basic.sh index 5d8846a02d8..2c1cd6f6418 100644 --- a/jdk/test/java/util/ServiceLoader/basic.sh +++ b/jdk/test/java/util/ServiceLoader/basic.sh @@ -43,7 +43,7 @@ JAR="$COMPILEJAVA/bin/jar" OS=`uname -s` case "$OS" in - SunOS | Darwin ) + SunOS | Darwin | AIX ) SEP=':' ;; Linux ) SEP=':' ;; diff --git a/jdk/test/java/util/concurrent/BlockingQueue/CancelledProducerConsumerLoops.java b/jdk/test/java/util/concurrent/BlockingQueue/CancelledProducerConsumerLoops.java index acee6e676be..74a902ae754 100644 --- a/jdk/test/java/util/concurrent/BlockingQueue/CancelledProducerConsumerLoops.java +++ b/jdk/test/java/util/concurrent/BlockingQueue/CancelledProducerConsumerLoops.java @@ -34,7 +34,6 @@ /* * @test * @bug 4486658 - * @compile -source 1.5 CancelledProducerConsumerLoops.java * @run main/timeout=7000 CancelledProducerConsumerLoops * @summary Checks for responsiveness of blocking queues to cancellation. * Runs under the assumption that ITERS computations require more than diff --git a/jdk/test/java/util/concurrent/BlockingQueue/MultipleProducersSingleConsumerLoops.java b/jdk/test/java/util/concurrent/BlockingQueue/MultipleProducersSingleConsumerLoops.java index 58983059bfe..47b7347174d 100644 --- a/jdk/test/java/util/concurrent/BlockingQueue/MultipleProducersSingleConsumerLoops.java +++ b/jdk/test/java/util/concurrent/BlockingQueue/MultipleProducersSingleConsumerLoops.java @@ -34,7 +34,6 @@ /* * @test * @bug 4486658 - * @compile -source 1.5 MultipleProducersSingleConsumerLoops.java * @run main/timeout=3600 MultipleProducersSingleConsumerLoops * @summary multiple producers and single consumer using blocking queues */ diff --git a/jdk/test/java/util/concurrent/BlockingQueue/ProducerConsumerLoops.java b/jdk/test/java/util/concurrent/BlockingQueue/ProducerConsumerLoops.java index 7755126674c..e8770cd0d39 100644 --- a/jdk/test/java/util/concurrent/BlockingQueue/ProducerConsumerLoops.java +++ b/jdk/test/java/util/concurrent/BlockingQueue/ProducerConsumerLoops.java @@ -34,7 +34,6 @@ /* * @test * @bug 4486658 - * @compile -source 1.5 ProducerConsumerLoops.java * @run main/timeout=3600 ProducerConsumerLoops * @summary multiple producers and consumers using blocking queues */ diff --git a/jdk/test/java/util/concurrent/BlockingQueue/SingleProducerMultipleConsumerLoops.java b/jdk/test/java/util/concurrent/BlockingQueue/SingleProducerMultipleConsumerLoops.java index a697d312df5..51efc7ac7f3 100644 --- a/jdk/test/java/util/concurrent/BlockingQueue/SingleProducerMultipleConsumerLoops.java +++ b/jdk/test/java/util/concurrent/BlockingQueue/SingleProducerMultipleConsumerLoops.java @@ -34,7 +34,6 @@ /* * @test * @bug 4486658 - * @compile -source 1.5 SingleProducerMultipleConsumerLoops.java * @run main/timeout=600 SingleProducerMultipleConsumerLoops * @summary check ordering for blocking queues with 1 producer and multiple consumers */ diff --git a/jdk/test/java/util/concurrent/ConcurrentHashMap/MapCheck.java b/jdk/test/java/util/concurrent/ConcurrentHashMap/MapCheck.java index 723ef64dc89..4246e6147cb 100644 --- a/jdk/test/java/util/concurrent/ConcurrentHashMap/MapCheck.java +++ b/jdk/test/java/util/concurrent/ConcurrentHashMap/MapCheck.java @@ -34,7 +34,6 @@ /* * @test * @bug 4486658 - * @compile -source 1.5 MapCheck.java * @run main/timeout=240 MapCheck * @summary Times and checks basic map operations */ diff --git a/jdk/test/java/util/concurrent/ConcurrentHashMap/MapLoops.java b/jdk/test/java/util/concurrent/ConcurrentHashMap/MapLoops.java index 49f615a3401..4a4ce22239d 100644 --- a/jdk/test/java/util/concurrent/ConcurrentHashMap/MapLoops.java +++ b/jdk/test/java/util/concurrent/ConcurrentHashMap/MapLoops.java @@ -34,7 +34,6 @@ /* * @test * @bug 4486658 - * @compile -source 1.5 MapLoops.java * @run main/timeout=1600 MapLoops * @summary Exercise multithreaded maps, by default ConcurrentHashMap. * Multithreaded hash table test. Each thread does a random walk diff --git a/jdk/test/java/util/concurrent/Exchanger/ExchangeLoops.java b/jdk/test/java/util/concurrent/Exchanger/ExchangeLoops.java index 7527e4fe4c2..6dd04134edb 100644 --- a/jdk/test/java/util/concurrent/Exchanger/ExchangeLoops.java +++ b/jdk/test/java/util/concurrent/Exchanger/ExchangeLoops.java @@ -34,7 +34,6 @@ /* * @test * @bug 4486658 - * @compile -source 1.5 ExchangeLoops.java * @run main/timeout=720 ExchangeLoops * @summary checks to make sure a pipeline of exchangers passes data. */ diff --git a/jdk/test/java/util/concurrent/ExecutorCompletionService/ExecutorCompletionServiceLoops.java b/jdk/test/java/util/concurrent/ExecutorCompletionService/ExecutorCompletionServiceLoops.java index 79b2c5634e9..91c6cf412eb 100644 --- a/jdk/test/java/util/concurrent/ExecutorCompletionService/ExecutorCompletionServiceLoops.java +++ b/jdk/test/java/util/concurrent/ExecutorCompletionService/ExecutorCompletionServiceLoops.java @@ -34,7 +34,6 @@ /* * @test * @bug 4965960 - * @compile -source 1.5 ExecutorCompletionServiceLoops.java * @run main/timeout=3600 ExecutorCompletionServiceLoops * @summary Exercise ExecutorCompletionServiceLoops */ diff --git a/jdk/test/java/util/concurrent/FutureTask/CancelledFutureLoops.java b/jdk/test/java/util/concurrent/FutureTask/CancelledFutureLoops.java index 25cec33881d..5575bb4505a 100644 --- a/jdk/test/java/util/concurrent/FutureTask/CancelledFutureLoops.java +++ b/jdk/test/java/util/concurrent/FutureTask/CancelledFutureLoops.java @@ -34,7 +34,6 @@ /* * @test * @bug 4486658 - * @compile -source 1.5 CancelledFutureLoops.java * @run main/timeout=2000 CancelledFutureLoops * @summary Checks for responsiveness of futures to cancellation. * Runs under the assumption that ITERS computations require more than diff --git a/jdk/test/java/util/concurrent/atomic/AtomicUpdaters.java b/jdk/test/java/util/concurrent/atomic/AtomicUpdaters.java index 62d066914d2..8728224ce8e 100644 --- a/jdk/test/java/util/concurrent/atomic/AtomicUpdaters.java +++ b/jdk/test/java/util/concurrent/atomic/AtomicUpdaters.java @@ -33,7 +33,7 @@ */ import java.util.concurrent.atomic.*; import java.lang.reflect.*; -import java.security.AccessControlException; +import java.security.*; public class AtomicUpdaters { enum TYPE { INT, LONG, REF } @@ -102,6 +102,8 @@ public class AtomicUpdaters { verbose = true; } else if ("UseSM".equals(arg)) { + // Ensure that the test is not influenced by the default users policy. + Policy.setPolicy(new NoPermissionsPolicy()); SecurityManager m = System.getSecurityManager(); if (m != null) throw new RuntimeException("No security manager should initially be installed"); @@ -186,4 +188,24 @@ public class AtomicUpdaters { throw new Error("Some tests failed - see previous stacktraces"); } } + + /** + * Policy with no permissions. + */ + private static class NoPermissionsPolicy extends Policy { + @Override + public PermissionCollection getPermissions(CodeSource cs) { + return Policy.UNSUPPORTED_EMPTY_COLLECTION; + } + + @Override + public PermissionCollection getPermissions(ProtectionDomain pd) { + return Policy.UNSUPPORTED_EMPTY_COLLECTION; + } + + @Override + public boolean implies(ProtectionDomain pd, Permission p) { + return Policy.UNSUPPORTED_EMPTY_COLLECTION.implies(p); + } + } } diff --git a/jdk/test/java/util/concurrent/atomic/VMSupportsCS8.java b/jdk/test/java/util/concurrent/atomic/VMSupportsCS8.java index 9bbce5d72eb..144e6d8d41f 100644 --- a/jdk/test/java/util/concurrent/atomic/VMSupportsCS8.java +++ b/jdk/test/java/util/concurrent/atomic/VMSupportsCS8.java @@ -24,7 +24,6 @@ /* * @test * @bug 4992443 4994819 - * @compile -source 1.5 VMSupportsCS8.java * @run main VMSupportsCS8 * @summary Checks that the value of VMSupportsCS8 matches system properties. */ diff --git a/jdk/test/java/util/concurrent/locks/ReentrantLock/CancelledLockLoops.java b/jdk/test/java/util/concurrent/locks/ReentrantLock/CancelledLockLoops.java index e942e1811bd..f9b3cc907bc 100644 --- a/jdk/test/java/util/concurrent/locks/ReentrantLock/CancelledLockLoops.java +++ b/jdk/test/java/util/concurrent/locks/ReentrantLock/CancelledLockLoops.java @@ -34,7 +34,6 @@ /* * @test * @bug 4486658 - * @compile -source 1.5 CancelledLockLoops.java * @run main/timeout=2800 CancelledLockLoops * @summary tests lockInterruptibly. * Checks for responsiveness of locks to interrupts. Runs under that @@ -49,14 +48,11 @@ import java.util.*; public final class CancelledLockLoops { static final Random rng = new Random(); static boolean print = false; - static final int ITERS = 1000000; + static final int ITERS = 5000000; static final long TIMEOUT = 100; public static void main(String[] args) throws Exception { - int maxThreads = 5; - if (args.length > 0) - maxThreads = Integer.parseInt(args[0]); - + int maxThreads = (args.length > 0) ? Integer.parseInt(args[0]) : 5; print = true; for (int i = 2; i <= maxThreads; i += (i+1) >>> 1) { @@ -90,7 +86,7 @@ public final class CancelledLockLoops { threads[i] = new Thread(this); for (int i = 0; i < threads.length; ++i) threads[i].start(); - Thread[] cancels = (Thread[]) (threads.clone()); + Thread[] cancels = threads.clone(); Collections.shuffle(Arrays.asList(cancels), rng); barrier.await(); Thread.sleep(TIMEOUT); diff --git a/jdk/test/java/util/concurrent/locks/ReentrantLock/LockOncePerThreadLoops.java b/jdk/test/java/util/concurrent/locks/ReentrantLock/LockOncePerThreadLoops.java index c3cedf4ab1e..c0a62906d7b 100644 --- a/jdk/test/java/util/concurrent/locks/ReentrantLock/LockOncePerThreadLoops.java +++ b/jdk/test/java/util/concurrent/locks/ReentrantLock/LockOncePerThreadLoops.java @@ -34,7 +34,6 @@ /* * @test * @bug 4486658 - * @compile -source 1.5 LockOncePerThreadLoops.java * @run main/timeout=15000 LockOncePerThreadLoops * @summary Checks for missed signals by locking and unlocking each of an array of locks once per thread */ diff --git a/jdk/test/java/util/concurrent/locks/ReentrantLock/SimpleReentrantLockLoops.java b/jdk/test/java/util/concurrent/locks/ReentrantLock/SimpleReentrantLockLoops.java index f3e77053027..bd650022cd9 100644 --- a/jdk/test/java/util/concurrent/locks/ReentrantLock/SimpleReentrantLockLoops.java +++ b/jdk/test/java/util/concurrent/locks/ReentrantLock/SimpleReentrantLockLoops.java @@ -34,7 +34,6 @@ /* * @test * @bug 4486658 - * @compile -source 1.5 SimpleReentrantLockLoops.java * @run main/timeout=4500 SimpleReentrantLockLoops * @summary multiple threads using a single lock */ diff --git a/jdk/test/java/util/concurrent/locks/ReentrantLock/TimeoutLockLoops.java b/jdk/test/java/util/concurrent/locks/ReentrantLock/TimeoutLockLoops.java index 303e11038a8..575a7bf47f3 100644 --- a/jdk/test/java/util/concurrent/locks/ReentrantLock/TimeoutLockLoops.java +++ b/jdk/test/java/util/concurrent/locks/ReentrantLock/TimeoutLockLoops.java @@ -34,7 +34,6 @@ /* * @test * @bug 4486658 5031862 - * @compile -source 1.5 TimeoutLockLoops.java * @run main TimeoutLockLoops * @summary Checks for responsiveness of locks to timeouts. * Runs under the assumption that ITERS computations require more than diff --git a/jdk/test/java/util/concurrent/locks/ReentrantReadWriteLock/MapLoops.java b/jdk/test/java/util/concurrent/locks/ReentrantReadWriteLock/MapLoops.java index 36116703814..c9846df1486 100644 --- a/jdk/test/java/util/concurrent/locks/ReentrantReadWriteLock/MapLoops.java +++ b/jdk/test/java/util/concurrent/locks/ReentrantReadWriteLock/MapLoops.java @@ -34,7 +34,6 @@ /* * @test * @bug 4486658 - * @compile -source 1.5 MapLoops.java * @run main/timeout=4700 MapLoops * @summary Exercise multithreaded maps, by default ConcurrentHashMap. * Multithreaded hash table test. Each thread does a random walk diff --git a/jdk/test/java/util/logging/AnonLoggerWeakRefLeak.sh b/jdk/test/java/util/logging/AnonLoggerWeakRefLeak.sh index eef8641c7b6..fc1aece9ebd 100644 --- a/jdk/test/java/util/logging/AnonLoggerWeakRefLeak.sh +++ b/jdk/test/java/util/logging/AnonLoggerWeakRefLeak.sh @@ -83,9 +83,9 @@ if [ "$status" != 0 ]; then fi if [ "$status" != 0 ]; then - echo "ERROR: 'jmap $jmap_option' is not supported so this test" - echo "ERROR: cannot work reliably. Aborting!" - exit 2 + echo "WARNING: 'jmap $jmap_option' is not supported on this platform" + echo "WARNING: so this test cannot work reliably. Aborting!" + exit 0 fi fi diff --git a/jdk/test/java/util/logging/HandlersConfigTest$Configured.props b/jdk/test/java/util/logging/HandlersConfigTest$Configured.props new file mode 100644 index 00000000000..af6e7f5cfe6 --- /dev/null +++ b/jdk/test/java/util/logging/HandlersConfigTest$Configured.props @@ -0,0 +1,29 @@ +# mandatory Default properties... + +.level= INFO +handlers=HandlersConfigTest$ConfiguredHandler + +java.util.logging.MemoryHandler.target=HandlersConfigTest$ConfiguredHandler + +# in addition to Default, Configured adds the following... + +java.util.logging.MemoryHandler.level=FINE +java.util.logging.MemoryHandler.filter=HandlersConfigTest$ConfiguredFilter +java.util.logging.MemoryHandler.formatter=HandlersConfigTest$ConfiguredFormatter +java.util.logging.MemoryHandler.size=123 +java.util.logging.MemoryHandler.push=FINE + +java.util.logging.ConsoleHandler.level=FINE +java.util.logging.ConsoleHandler.encoding=ASCII +java.util.logging.ConsoleHandler.filter=HandlersConfigTest$ConfiguredFilter +java.util.logging.ConsoleHandler.formatter=HandlersConfigTest$ConfiguredFormatter + +java.util.logging.StreamHandler.level=FINE +java.util.logging.StreamHandler.encoding=ASCII +java.util.logging.StreamHandler.filter=HandlersConfigTest$ConfiguredFilter +java.util.logging.StreamHandler.formatter=HandlersConfigTest$ConfiguredFormatter + +java.util.logging.SocketHandler.level=FINE +java.util.logging.SocketHandler.encoding=ASCII +java.util.logging.SocketHandler.filter=HandlersConfigTest$ConfiguredFilter +java.util.logging.SocketHandler.formatter=HandlersConfigTest$ConfiguredFormatter diff --git a/jdk/test/java/util/logging/HandlersConfigTest$Default.props b/jdk/test/java/util/logging/HandlersConfigTest$Default.props new file mode 100644 index 00000000000..fc216319b7d --- /dev/null +++ b/jdk/test/java/util/logging/HandlersConfigTest$Default.props @@ -0,0 +1,6 @@ +# mandatory Default properties... + +.level= INFO +handlers=HandlersConfigTest$ConfiguredHandler + +java.util.logging.MemoryHandler.target=HandlersConfigTest$ConfiguredHandler diff --git a/jdk/test/java/util/logging/HandlersConfigTest.java b/jdk/test/java/util/logging/HandlersConfigTest.java new file mode 100644 index 00000000000..7d122cd9f86 --- /dev/null +++ b/jdk/test/java/util/logging/HandlersConfigTest.java @@ -0,0 +1,330 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8029781 8030801 + * @summary Test which verifies that various JDK logging Handlers are + * configured correctly from defaults and/or LogManager properties + * as specified in javadoc and that no special + * logging permission is required for instantiating them. + * @run main/othervm HandlersConfigTest default + * @run main/othervm HandlersConfigTest configured + */ + +import java.io.IOException; +import java.io.OutputStream; +import java.lang.reflect.Field; +import java.net.ServerSocket; +import java.net.URL; +import java.util.Objects; +import java.util.logging.ConsoleHandler; +import java.util.logging.Filter; +import java.util.logging.Formatter; +import java.util.logging.Handler; +import java.util.logging.Level; +import java.util.logging.LogManager; +import java.util.logging.LogRecord; +import java.util.logging.MemoryHandler; +import java.util.logging.SimpleFormatter; +import java.util.logging.SocketHandler; +import java.util.logging.StreamHandler; +import java.util.logging.XMLFormatter; + +public abstract class HandlersConfigTest implements Runnable { + + public static void main(String[] args) { + switch (args.length == 1 ? args[0] : "usage") { + case "default": + new Default().run(); + break; + case "configured": + new Configured().run(); + break; + default: + System.err.println("Usage: HandlersConfigTest [default|configured]"); + break; + } + } + + static final String CONFIG_FILE_PROPERTY = "java.util.logging.config.file"; + final Field memoryHandlerTarget, memoryHandlerSize, streamHandlerOutput; + final ServerSocket serverSocket; + + HandlersConfigTest() { + // establish access to private fields + try { + memoryHandlerTarget = MemoryHandler.class.getDeclaredField("target"); + memoryHandlerTarget.setAccessible(true); + memoryHandlerSize = MemoryHandler.class.getDeclaredField("size"); + memoryHandlerSize.setAccessible(true); + streamHandlerOutput = StreamHandler.class.getDeclaredField("output"); + streamHandlerOutput.setAccessible(true); + } catch (NoSuchFieldException e) { + throw new AssertionError(e); + } + + // load logging.propertes for the test + String rname = getClass().getName().replace('.', '/') + ".props"; + URL url = getClass().getClassLoader().getResource(rname); + if (url == null || !"file".equals(url.getProtocol())) { + throw new IllegalStateException("Resource: " + rname + " not found or not on file: " + url); + } + System.setProperty(CONFIG_FILE_PROPERTY, url.getFile()); + + // create ServerSocket as a target for SocketHandler + try { + serverSocket = new ServerSocket(0); // auto allocated port + } catch (IOException e) { + throw new AssertionError(e); + } + + // activate security + System.setSecurityManager(new SecurityManager() { + @Override + public void checkConnect(String host, int port) { + // allow socket connections + } + }); + + // initialize logging system + LogManager.getLogManager(); + } + + // check that defaults are used as specified by javadoc + + public static class Default extends HandlersConfigTest { + public static void main(String[] args) { + new Default().run(); + } + + @Override + public void run() { + // MemoryHandler + + check(new MemoryHandler(), + Level.ALL, null, null, SimpleFormatter.class, + ConfiguredHandler.class, 1000, Level.SEVERE); + + check(new MemoryHandler(new SpecifiedHandler(), 100, Level.WARNING), + Level.ALL, null, null, SimpleFormatter.class, + SpecifiedHandler.class, 100, Level.WARNING); + + // StreamHandler + + check(new StreamHandler(), + Level.INFO, null, null, SimpleFormatter.class, + null); + + check(new StreamHandler(System.out, new SpecifiedFormatter()), + Level.INFO, null, null, SpecifiedFormatter.class, + System.out); + + // ConsoleHandler + + check(new ConsoleHandler(), + Level.INFO, null, null, SimpleFormatter.class, + System.err); + + // SocketHandler (use the ServerSocket's port) + + try { + check(new SocketHandler("localhost", serverSocket.getLocalPort()), + Level.ALL, null, null, XMLFormatter.class); + } catch (IOException e) { + throw new RuntimeException("Can't connect to localhost:" + serverSocket.getLocalPort(), e); + } + } + } + + // check that LogManager properties configuration is respected + + public static class Configured extends HandlersConfigTest { + public static void main(String[] args) { + new Configured().run(); + } + + @Override + public void run() { + // MemoryHandler + + check(new MemoryHandler(), + Level.FINE, null, ConfiguredFilter.class, ConfiguredFormatter.class, + ConfiguredHandler.class, 123, Level.FINE); + + check(new MemoryHandler(new SpecifiedHandler(), 100, Level.WARNING), + Level.FINE, null, ConfiguredFilter.class, ConfiguredFormatter.class, + SpecifiedHandler.class, 100, Level.WARNING); + + // StreamHandler + + check(new StreamHandler(), + Level.FINE, "ASCII", ConfiguredFilter.class, ConfiguredFormatter.class, + null); + + check(new StreamHandler(System.out, new SpecifiedFormatter()), + Level.FINE, "ASCII", ConfiguredFilter.class, SpecifiedFormatter.class, + System.out); + + // ConsoleHandler + + check(new ConsoleHandler(), + Level.FINE, "ASCII", ConfiguredFilter.class, ConfiguredFormatter.class, + System.err); + + // SocketHandler (use the ServerSocket's port) + + try { + check(new SocketHandler("localhost", serverSocket.getLocalPort()), + Level.FINE, "ASCII", ConfiguredFilter.class, ConfiguredFormatter.class); + } catch (Exception e) { + throw new RuntimeException("Can't connect to localhost:" + serverSocket.getLocalPort(), e); + } + } + } + + // test infrastructure + + void check(Handler handler, + Level expectedLevel, + String expectedEncoding, + Class expectedFilterType, + Class expectedFormatterType) { + checkEquals(handler, "level", handler.getLevel(), expectedLevel); + checkEquals(handler, "encoding", handler.getEncoding(), expectedEncoding); + checkType(handler, "filter", handler.getFilter(), expectedFilterType); + checkType(handler, "formatter", handler.getFormatter(), expectedFormatterType); + } + + void check(MemoryHandler handler, + Level expectedLevel, + String expectedEncoding, + Class expectedFilterType, + Class expectedFormatterType, + Class expextedTargetType, + int expextedSize, + Level expectedPushLevel) { + checkType(handler, "target", getTarget(handler), expextedTargetType); + checkEquals(handler, "size", getSize(handler), expextedSize); + checkEquals(handler, "pushLevel", handler.getPushLevel(), expectedPushLevel); + check(handler, expectedLevel, expectedEncoding, expectedFilterType, expectedFormatterType); + } + + void check(StreamHandler handler, + Level expectedLevel, + String expectedEncoding, + Class expectedFilterType, + Class expectedFormatterType, + OutputStream expectedOutputStream) { + checkEquals(handler, "outputStream", getOutput(handler), expectedOutputStream); + check(handler, expectedLevel, expectedEncoding, expectedFilterType, expectedFormatterType); + } + + void checkEquals(Handler handler, String property, T value, T expectedValue) { + if (!Objects.equals(value, expectedValue)) { + fail(handler, property + ": " + value + ", expected " + property + ": " + expectedValue); + } + } + + void checkType(Handler handler, String property, T value, Class expectedType) { + if (!(expectedType == null && value == null || expectedType != null && expectedType.isInstance(value))) { + Class type = value == null ? null : value.getClass(); + fail(handler, property + " type: " + type + ", expected " + property + " type: " + expectedType); + } + } + + void fail(Handler handler, String message) { + throw new AssertionError("Handler: " + handler.getClass().getName() + + ", configured with: " + getClass().getName() + + ", " + message); + } + + Handler getTarget(MemoryHandler memoryHandler) { + try { + return (Handler) memoryHandlerTarget.get(memoryHandler); + } catch (IllegalAccessException e) { + throw new IllegalAccessError(e.getMessage()); + } + } + + int getSize(MemoryHandler memoryHandler) { + try { + return (int) memoryHandlerSize.get(memoryHandler); + } catch (IllegalAccessException e) { + throw new IllegalAccessError(e.getMessage()); + } + } + + OutputStream getOutput(StreamHandler streamHandler) { + try { + return (OutputStream) streamHandlerOutput.get(streamHandler); + } catch (IllegalAccessException e) { + throw new IllegalAccessError(e.getMessage()); + } + } + + // various independent types of Formatters, Filters, Handlers... + + public static class SpecifiedFormatter extends Formatter { + @Override + public String format(LogRecord record) { + return String.valueOf(record); + } + } + + public static class SpecifiedHandler extends Handler { + @Override + public void publish(LogRecord record) { } + + @Override + public void flush() { } + + @Override + public void close() throws SecurityException { } + } + + public static class ConfiguredFormatter extends Formatter { + @Override + public String format(LogRecord record) { + return String.valueOf(record); + } + } + + public static class ConfiguredFilter implements Filter { + @Override + public boolean isLoggable(LogRecord record) { + return true; + } + } + + public static class ConfiguredHandler extends Handler { + @Override + public void publish(LogRecord record) { } + + @Override + public void flush() { } + + @Override + public void close() throws SecurityException { } + } +} diff --git a/jdk/test/java/util/logging/Listeners.java b/jdk/test/java/util/logging/Listeners.java deleted file mode 100644 index 86383ef065b..00000000000 --- a/jdk/test/java/util/logging/Listeners.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 7192275 - * @summary Basic test of addPropertyListener/removePropertyListener methods - * @run main/othervm Listeners - */ - -import java.util.logging.LogManager; -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeEvent; - -public class Listeners { - - static void assertTrue(boolean result, String msg) { - if (!result) - throw new RuntimeException(msg); - } - - /** - * A {@code PropertyChangeListener} that counts the number of times that - * the {@code propertyChange} method is fired, and also checks that the - * event source is the expected (fixed) object. - */ - static class Listener implements PropertyChangeListener { - private final Object expectedSource; - private int fireCount; - - Listener(Object expectedSource) { - this.expectedSource = expectedSource; - } - - int fireCount() { - return fireCount; - } - - Listener reset() { - fireCount = 0; - return this; - } - - @Override - public void propertyChange(PropertyChangeEvent evt) { - assertTrue(evt.getSource() == expectedSource, "Unexpected source"); - fireCount++; - } - } - - /** - * Tests that the given listeners are invoked the expected number of - * times. - */ - static void test(Listener[] listeners, int... expected) throws Exception { - // reset counts - for (Listener listener : listeners) { - listener.reset(); - } - - // re-reading configuration causes events to be fired - LogManager.getLogManager().readConfiguration(); - - // check event listeners invoked as expected - for (int i = 0; i < expected.length; i++) { - assertTrue(listeners[i].fireCount() == expected[i], - "Unexpected event count"); - } - } - - @SuppressWarnings("deprecation") - public static void main(String[] args) throws Exception { - LogManager logman = LogManager.getLogManager(); - - Listener[] listeners = new Listener[2]; - Listener listener1 = listeners[0] = new Listener(LogManager.class); - Listener listener2 = listeners[1] = new Listener(LogManager.class); - - // add listeners - logman.addPropertyChangeListener(listener1); - test(listeners, 1, 0); - - logman.addPropertyChangeListener(listener1); - test(listeners, 2, 0); - - logman.addPropertyChangeListener(listener2); - test(listeners, 2, 1); - - // null handling to check for impact on the existing registrations - try { - logman.addPropertyChangeListener(null); - assertTrue(false, "NullPointerException expected"); - } catch (NullPointerException expected) { } - test(listeners, 2, 1); - - logman.removePropertyChangeListener(null); // no-op - test(listeners, 2, 1); - - // remove listeners - logman.removePropertyChangeListener(listener1); - test(listeners, 1, 1); - - logman.removePropertyChangeListener(listener1); - test(listeners, 0, 1); - - logman.removePropertyChangeListener(listener1); // no-op - test(listeners, 0, 1); - - logman.removePropertyChangeListener(listener2); - test(listeners, 0, 0); - - logman.removePropertyChangeListener(listener2); // no-op - test(listeners, 0, 0); - } -} diff --git a/jdk/test/java/util/logging/ListenersWithSM.java b/jdk/test/java/util/logging/ListenersWithSM.java deleted file mode 100644 index 49eba235dc6..00000000000 --- a/jdk/test/java/util/logging/ListenersWithSM.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* @test - * @bug 7192275 - * @summary Basic test of addPropertyListener/removePropertyListener methods - * @run main/othervm ListenersWithSM grant - * @run main/othervm ListenersWithSM deny - */ - -import java.nio.file.Paths; -import java.util.logging.LogManager; -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeEvent; - -public class ListenersWithSM { - - @SuppressWarnings("deprecation") - public static void main(String[] args) throws Exception { - boolean granted = args[0].equals("grant"); - - // need to get reference to LogManager before setting SecurityManager - LogManager logman = LogManager.getLogManager(); - - // set policy and enable security manager - if (granted) { - String testSrc = System.getProperty("test.src"); - if (testSrc == null) - testSrc = "."; - System.setProperty("java.security.policy", - Paths.get(testSrc).resolve("java.policy").toString()); - } - System.setSecurityManager(new SecurityManager()); - - PropertyChangeListener listener = new PropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent evt) { - } - }; - - if (granted) { - // permission granted, no security exception expected - logman.addPropertyChangeListener(listener); - logman.removePropertyChangeListener(listener); - } else { - // denied - try { - logman.addPropertyChangeListener(listener); - throw new RuntimeException("SecurityException expected"); - } catch (SecurityException expected) { } - try { - logman.removePropertyChangeListener(listener); - throw new RuntimeException("SecurityException expected"); - } catch (SecurityException expected) { } - } - } -} diff --git a/jdk/test/java/util/logging/Logger/setResourceBundle/TestSetResourceBundle.java b/jdk/test/java/util/logging/Logger/setResourceBundle/TestSetResourceBundle.java index 3ba69e7af49..fbdb6116190 100644 --- a/jdk/test/java/util/logging/Logger/setResourceBundle/TestSetResourceBundle.java +++ b/jdk/test/java/util/logging/Logger/setResourceBundle/TestSetResourceBundle.java @@ -57,8 +57,8 @@ public class TestSetResourceBundle { * that was present in the last LogRecord instance published. */ static final class TestHandler extends Handler { - ResourceBundle lastBundle = null; - String lastBundleName = null; + volatile ResourceBundle lastBundle = null; + volatile String lastBundleName = null; @Override public void publish(LogRecord record) { lastBundle = record.getResourceBundle(); @@ -186,6 +186,8 @@ public class TestSetResourceBundle { public static void test(String loggerName) throws Exception { + System.out.println("Starting test for " + loggerName); + final ResourceBundle bundle = ResourceBundle.getBundle(LIST_BUNDLE_NAME); Logger foobar = Logger.getLogger(loggerName); @@ -235,16 +237,21 @@ public class TestSetResourceBundle { } // Create a child logger - Logger foobaz = Logger.getLogger(loggerName + ".baz"); + final Logger foobaz = Logger.getLogger(loggerName + ".baz"); + + if (foobar != foobaz.getParent()) { + throw new RuntimeException("Unexpected parent: " + + foobaz.getParent() + " != " + foobar); + } // Check that the child logger does not have a bundle set locally if (foobaz.getResourceBundle() != null) { throw new RuntimeException("Unexpected bundle: " - + foobar.getResourceBundle()); + + foobaz.getResourceBundle()); } if (foobaz.getResourceBundleName() != null) { throw new RuntimeException("Unexpected bundle: " - + foobar.getResourceBundleName()); + + foobaz.getResourceBundleName()); } @@ -258,39 +265,65 @@ public class TestSetResourceBundle { // checks that the message has been logged with the bundle // inherited from the parent logger if (!LIST_BUNDLE_NAME.equals(handler.lastBundleName)) { + debugLogger(foobaz, foobar, handler); throw new RuntimeException("Unexpected bundle name: " + handler.lastBundleName); } if (!bundle_fr.equals(handler.lastBundle)) { + debugLogger(foobaz, foobar, handler); throw new RuntimeException("Unexpected bundle: " + handler.lastBundle); } // Check that we can get set a bundle on the child logger // using Logger.getLogger. - foobaz = Logger.getLogger(loggerName + ".baz", PROPERTY_BUNDLE_NAME); + final Logger foobaz2 = Logger.getLogger(loggerName + ".baz", PROPERTY_BUNDLE_NAME); + if (foobaz2 != foobaz) { + throw new RuntimeException("Unexpected logger: " + foobaz2 + " != " + foobaz); + } + if (foobar != foobaz.getParent()) { + throw new RuntimeException("Unexpected parent: " + + foobaz.getParent() + " != " + foobar); + } // check that the child logger has the correct bundle. // it should no longer inherit it from its parent. - if (!PROPERTY_BUNDLE_NAME.equals(foobaz.getResourceBundleName())) { + if (!PROPERTY_BUNDLE_NAME.equals(foobaz2.getResourceBundleName())) { throw new RuntimeException("Unexpected bundle name: " - + foobaz.getResourceBundleName()); + + foobaz2.getResourceBundleName()); } - if (!PROPERTY_BUNDLE_NAME.equals(foobaz.getResourceBundle().getBaseBundleName())) { + + if (!PROPERTY_BUNDLE_NAME.equals(foobaz2.getResourceBundle().getBaseBundleName())) { throw new RuntimeException("Unexpected bundle name: " - + foobaz.getResourceBundle().getBaseBundleName()); + + foobaz2.getResourceBundle().getBaseBundleName()); + } + + boolean found = false; + for (Handler h : foobaz2.getHandlers()) { + if (h == handler) { + found = true; + break; + } + } + + if (!found) { + throw new RuntimeException("Expected handler not found in: " + + foobaz2.getName() + "(" + foobaz2.getClass().getName()+")" ); } // log a message on the child logger - foobaz.severe("dummy"); + foobaz2.severe("dummy"); + // check that the last published log record has the appropriate // bundle. if (!PROPERTY_BUNDLE_NAME.equals(handler.lastBundleName)) { + debugLogger(foobaz2, foobar, handler); throw new RuntimeException("Unexpected bundle name: " + handler.lastBundleName); } - if (foobaz.getResourceBundle() != handler.lastBundle) { + if (foobaz2.getResourceBundle() != handler.lastBundle) { + debugLogger(foobaz2, foobar, handler); throw new RuntimeException("Unexpected bundle: " + handler.lastBundle); } @@ -298,7 +331,7 @@ public class TestSetResourceBundle { // try to set a bundle that has a different name, and checks that // it fails in IAE. try { - foobaz.setResourceBundle(bundle_fr); + foobaz2.setResourceBundle(bundle_fr); throw new RuntimeException("Expected exception not raised!"); } catch (IllegalArgumentException x) { System.out.println("Got expected exception: " + x); @@ -333,10 +366,12 @@ public class TestSetResourceBundle { // check that the log record had the correct bundle. if (! PROPERTY_BUNDLE_NAME.equals(handler2.lastBundleName)) { + debugLogger(customLogger, foobar, handler2); throw new RuntimeException("Unexpected bundle name: " + handler2.lastBundleName); } if (! PROPERTY_BUNDLE_NAME.equals(customLogger.getResourceBundleName())) { + debugLogger(customLogger, foobar, handler2); throw new RuntimeException("Unexpected bundle name: " + customLogger.getResourceBundleName()); } @@ -356,6 +391,7 @@ public class TestSetResourceBundle { // because getResourceBundleName() is called on parent logger // we will have handler2.lastBundleName = PROPERTY_BUNDLE_NAME if (!PROPERTY_BUNDLE_NAME.equals(handler2.lastBundleName)) { + debugLogger(biebar, customLogger, handler2); throw new RuntimeException("Unexpected bundle name: " + handler2.lastBundleName); } @@ -363,13 +399,70 @@ public class TestSetResourceBundle { // we will have getBaseName(handler2.lastBundle) = PROPERTY_BUNDLE_NAME // and not handler2.lastBundle = bundle_fr if (handler2.lastBundle == null) { + debugLogger(biebar, customLogger, handler2); throw new RuntimeException("Unexpected bundle: " + handler2.lastBundle); } if (!PROPERTY_BUNDLE_NAME.equals(getBaseName(handler2.lastBundle))) { + debugLogger(biebar, customLogger, handler2); throw new RuntimeException("Unexpected bundle name: " + getBaseName(handler2.lastBundle)); } + + // Just make sure that these loggers won't be eagerly GCed... + if (foobar == null || !loggerName.equals(foobar.getName())) { + throw new RuntimeException("foobar is null " + + "- or doesn't have the expected name: " + foobar); + } + if (foobaz == null || !foobaz.getName().startsWith(loggerName)) { + throw new RuntimeException("foobaz is null " + + "- or doesn't have the expected name: " + foobaz); + } + if (foobaz2 == null || !foobaz2.getName().startsWith(loggerName)) { + throw new RuntimeException("foobaz2 is null " + + "- or doesn't have the expected name: " + foobaz2); + } + if (!customLogger.getName().startsWith(loggerName)) { + throw new RuntimeException("customLogger " + + "doesn't have the expected name: " + customLogger); + } + if (!biebar.getName().startsWith(loggerName)) { + throw new RuntimeException("biebar " + + "doesn't have the expected name: " + biebar.getName()); + } + System.out.println("Test passed for " + loggerName); + } + + static void debugLogger(Logger logger, Logger expectedParent, TestHandler handler) { + final String logName = logger.getName(); + final String prefix = " " + logName; + System.err.println("Logger " + logName + + " logged with bundle name " + handler.lastBundleName + + " (" + handler.lastBundle + ")"); + System.err.println(prefix + ".getResourceBundleName() is " + + logger.getResourceBundleName()); + System.err.println(prefix + ".getResourceBundle() is " + + logger.getResourceBundle()); + final Logger parent = logger.getParent(); + final String pname = parent == null ? null : parent.getName(); + final String pclass = parent == null ? "" + : ("(" + parent.getClass().getName() + ")"); + final String presn = parent == null ? null + : parent.getResourceBundleName(); + final ResourceBundle pres = parent == null ? null + : parent.getResourceBundle(); + System.err.println(prefix + ".getParent() is " + + pname + (pname == null ? "" + : (" " + pclass + ": " + parent))); + System.err.println(" expected parent is :" + expectedParent); + System.err.println(prefix + ".parent.getResourceBundleName() is " + + presn); + System.err.println(prefix + ".parent.getResourceBundle() is " + + pres); + System.err.println(" expected parent getResourceBundleName() is " + + expectedParent.getResourceBundleName()); + System.err.println(" expected parent.getResourceBundle() is " + + expectedParent.getResourceBundle()); } public static class SimplePolicy extends Policy { diff --git a/jdk/test/java/util/logging/LoggerWeakRefLeak.sh b/jdk/test/java/util/logging/LoggerWeakRefLeak.sh index ea3dc1f8f1d..25cc4aabc74 100644 --- a/jdk/test/java/util/logging/LoggerWeakRefLeak.sh +++ b/jdk/test/java/util/logging/LoggerWeakRefLeak.sh @@ -83,9 +83,9 @@ if [ "$status" != 0 ]; then fi if [ "$status" != 0 ]; then - echo "ERROR: 'jmap $jmap_option' is not supported so this test" - echo "ERROR: cannot work reliably. Aborting!" - exit 2 + echo "WARNING: 'jmap $jmap_option' is not supported on this platform" + echo "WARNING: so this test cannot work reliably. Aborting!" + exit 0 fi fi diff --git a/jdk/test/java/util/logging/ParentLoggersTest.java b/jdk/test/java/util/logging/ParentLoggersTest.java index a5070a375e3..eba26947e0b 100644 --- a/jdk/test/java/util/logging/ParentLoggersTest.java +++ b/jdk/test/java/util/logging/ParentLoggersTest.java @@ -63,7 +63,9 @@ public class ParentLoggersTest { static final String LOGGER_NAME_1 = PARENT_NAME_1 + ".myLogger"; static final String LOGGER_NAME_2 = PARENT_NAME_2 + ".myBar.myLogger"; - static final List initialLoggerNames = new ArrayList(); + static final List initialLoggerNames = new ArrayList<>(); + static final List createdLoggers = new ArrayList<>(); + public static void main(String args[]) throws Exception { // cache the initial set of loggers before this test begins // to add any loggers @@ -74,7 +76,7 @@ public class ParentLoggersTest { if (!defaultLoggers.contains(logger)) { initialLoggerNames.add(logger); } - }; + } String tstSrc = System.getProperty(TST_SRC_PROP); File fname = new File(tstSrc, LM_PROP_FNAME); @@ -92,7 +94,7 @@ public class ParentLoggersTest { } public static List getDefaultLoggerNames() { - List expectedLoggerNames = new ArrayList(); + List expectedLoggerNames = new ArrayList<>(); // LogManager always creates two loggers: expectedLoggerNames.add(""); // root logger: "" @@ -106,56 +108,43 @@ public class ParentLoggersTest { */ public static boolean checkLoggers() { String failMsg = "# checkLoggers: getLoggerNames() returned unexpected loggers"; - Vector expectedLoggerNames = new Vector(getDefaultLoggerNames()); + List expectedLoggerNames = new ArrayList<>(getDefaultLoggerNames()); // Create the logger LOGGER_NAME_1 - Logger.getLogger(LOGGER_NAME_1); - expectedLoggerNames.addElement(PARENT_NAME_1); - expectedLoggerNames.addElement(LOGGER_NAME_1); + createdLoggers.add(Logger.getLogger(LOGGER_NAME_1)); + expectedLoggerNames.add(PARENT_NAME_1); + expectedLoggerNames.add(LOGGER_NAME_1); // Create the logger LOGGER_NAME_2 - Logger.getLogger(LOGGER_NAME_2); - expectedLoggerNames.addElement(PARENT_NAME_2); - expectedLoggerNames.addElement(LOGGER_NAME_2); + createdLoggers.add(Logger.getLogger(LOGGER_NAME_2)); + expectedLoggerNames.add(PARENT_NAME_2); + expectedLoggerNames.add(LOGGER_NAME_2); + Enumeration returnedLoggersEnum = logMgr.getLoggerNames(); - Vector returnedLoggerNames = new Vector(0); + List returnedLoggerNames = new ArrayList<>(0); while (returnedLoggersEnum.hasMoreElements()) { String logger = returnedLoggersEnum.nextElement(); if (!initialLoggerNames.contains(logger)) { // filter out the loggers that have been added before this test runs - returnedLoggerNames.addElement(logger); + returnedLoggerNames.add(logger); } - }; - + } + System.out.println(returnedLoggerNames); return checkNames(expectedLoggerNames, returnedLoggerNames, failMsg); } // Returns boolean values: PASSED or FAILED - private static boolean checkNames(Vector expNames, - Vector retNames, + private static boolean checkNames(List expNames, + List retNames, String failMsg) { boolean status = PASSED; if (expNames.size() != retNames.size()) { status = FAILED; - } else { - boolean checked[] = new boolean[retNames.size()]; - for (int i = 0; i < expNames.size(); i++) { - int j = 0; - for (; j < retNames.size(); j++) { - if (!checked[j] && - expNames.elementAt(i).equals(retNames.elementAt(j))) { - checked[j] = true; - break; - } - } - if (j >= retNames.size()) { - status = FAILED; - break; - } - } + } else if (!new HashSet<>(expNames).equals(new HashSet<>(retNames))) { + status = FAILED; } if (!status) { printFailMsg(expNames, retNames, failMsg); @@ -163,25 +152,25 @@ public class ParentLoggersTest { return status; } - private static void printFailMsg(Vector expNames, - Vector retNames, + private static void printFailMsg(List expNames, + List retNames, String failMsg) { out.println(); out.println(failMsg); - if (expNames.size() == 0) { + if (expNames.isEmpty()) { out.println("# there are NO expected logger names"); } else { out.println("# expected logger names (" + expNames.size() + "):"); for (int i = 0; i < expNames.size(); i++) { - out.println(" expNames[" + i + "] = " + expNames.elementAt(i)); + out.println(" expNames[" + i + "] = " + expNames.get(i)); } } - if (retNames.size() == 0) { + if (retNames.isEmpty()) { out.println("# there are NO returned logger names"); } else { out.println("# returned logger names (" + retNames.size() + "):"); for (int i = 0; i < retNames.size(); i++) { - out.println(" retNames[" + i + "] = " + retNames.elementAt(i)); + out.println(" retNames[" + i + "] = " + retNames.get(i)); } } } diff --git a/jdk/test/java/util/logging/RootLogger/RootLevelInConfigFile.java b/jdk/test/java/util/logging/RootLogger/RootLevelInConfigFile.java new file mode 100644 index 00000000000..f7ca5ce6d55 --- /dev/null +++ b/jdk/test/java/util/logging/RootLogger/RootLevelInConfigFile.java @@ -0,0 +1,207 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.io.File; +import java.io.FilePermission; +import java.io.IOException; +import java.security.Permission; +import java.security.PermissionCollection; +import java.security.Permissions; +import java.security.Policy; +import java.security.ProtectionDomain; +import java.util.PropertyPermission; +import java.util.logging.Level; +import java.util.logging.LogManager; +import java.util.logging.Logger; +import java.util.logging.LoggingPermission; +import sun.misc.JavaAWTAccess; +import sun.misc.SharedSecrets; + +/** + * @test + * @bug 8030850 + * @summary Tests that setting .level=FINEST for the root logger in logging + * configuration file does work. + * @run main/othervm RootLevelInConfigFile + * + * @author danielfuchs + */ +public class RootLevelInConfigFile { + + public final static String CONFIG_FILE_KEY = "java.util.logging.config.file"; + + public static void main(String[] args) throws IOException { + System.setProperty(CONFIG_FILE_KEY, + new File(System.getProperty("test.src", "."), + "rootlogger.properties").getAbsolutePath()); + System.out.println(CONFIG_FILE_KEY + "=" + + System.getProperty(CONFIG_FILE_KEY)); + if (! new File(System.getProperty(CONFIG_FILE_KEY)).canRead()) { + throw new RuntimeException("can't read config file: " + + System.getProperty(CONFIG_FILE_KEY)); + } + + final String configFile = System.getProperty(CONFIG_FILE_KEY); + + test("no security"); + + LogManager.getLogManager().readConfiguration(); + + Policy.setPolicy(new SimplePolicy(configFile)); + System.setSecurityManager(new SecurityManager()); + + test("security"); + + LogManager.getLogManager().readConfiguration(); + + final JavaAWTAccessStub access = new JavaAWTAccessStub(); + SharedSecrets.setJavaAWTAccess(access); + + test("security and no context"); + + for (Context ctx : Context.values()) { + + LogManager.getLogManager().readConfiguration(); + + access.setContext(ctx); + + test("security and context " + ctx); + } + } + + public static void test(String conf) throws IOException { + + System.out.println("Testing with " + conf); + + testLoggableLevels(); + + LogManager.getLogManager().readConfiguration(); + + testLoggableLevels(); + + } + + private static void testLoggableLevels() { + + Logger foobar = Logger.getLogger("foo.bar"); + if (!foobar.isLoggable(Level.FINEST)) { + throw new RuntimeException("Expected FINEST to be loggable in " + + foobar.getName()); + } + if (!foobar.getParent().isLoggable(Level.FINEST)) { + throw new RuntimeException("Expected FINEST to be loggable in " + + foobar.getName()); + } + + Logger global = Logger.getGlobal(); + if (!global.isLoggable(Level.FINEST)) { + throw new RuntimeException("Expected FINEST to be loggable in " + + global.getName()); + } + if (!global.getParent().isLoggable(Level.FINEST)) { + throw new RuntimeException("Expected FINEST to be loggable in " + + global.getName()); + } + + Logger root = Logger.getLogger(""); + if (!global.isLoggable(Level.FINEST)) { + throw new RuntimeException("Expected FINEST to be loggable in " + + root.getName()); + } + if (!global.getParent().isLoggable(Level.FINEST)) { + throw new RuntimeException("Expected FINEST to be loggable in " + + root.getName()); + } + + root.setLevel(Level.FINER); + + if (foobar.isLoggable(Level.FINEST)) { + throw new RuntimeException("Didn't expect FINEST to be loggable in " + + foobar.getName()); + } + if (foobar.getParent().isLoggable(Level.FINEST)) { + throw new RuntimeException("Didn't expect FINEST to be loggable in " + + foobar.getName()); + } + if (global.isLoggable(Level.FINEST)) { + throw new RuntimeException("Didn't expect FINEST to be loggable in " + + global.getName()); + } + if (global.getParent().isLoggable(Level.FINEST)) { + throw new RuntimeException("Didn't expect FINEST to be loggable in " + + global.getName()); + } + + if (!foobar.isLoggable(Level.FINER)) { + throw new RuntimeException("Expected FINER to be loggable in " + + foobar.getName()); + } + if (!foobar.getParent().isLoggable(Level.FINER)) { + throw new RuntimeException("Expected FINER to be loggable in " + + foobar.getName()); + } + + if (!global.isLoggable(Level.FINER)) { + throw new RuntimeException("Expected FINER to be loggable in " + + global.getName()); + } + if (!global.getParent().isLoggable(Level.FINER)) { + throw new RuntimeException("Expected FINER to be loggable in " + + global.getName()); + } + + } + + static final class SimplePolicy extends Policy { + + final PermissionCollection perms = new Permissions(); + public SimplePolicy(String configFile) { + perms.add(new LoggingPermission("control", null)); + perms.add(new PropertyPermission("java.util.logging.config.class","read")); + perms.add(new PropertyPermission("java.util.logging.config.file","read")); + perms.add(new FilePermission(configFile, "read")); + perms.add(new RuntimePermission("accessClassInPackage.sun.misc")); + } + + @Override + public boolean implies(ProtectionDomain domain, Permission permission) { + return perms.implies(permission); + } + } + + static enum Context { ONE, TWO }; + + static final class JavaAWTAccessStub implements JavaAWTAccess { + private Context context; + + public void setContext(Context context) { + this.context = context; + } + + @Override + public Object getAppletContext() { + return context; + } + } + +} diff --git a/jdk/test/java/util/logging/RootLogger/rootlogger.properties b/jdk/test/java/util/logging/RootLogger/rootlogger.properties new file mode 100644 index 00000000000..966abb1beb4 --- /dev/null +++ b/jdk/test/java/util/logging/RootLogger/rootlogger.properties @@ -0,0 +1 @@ +.level=FINEST diff --git a/jdk/test/java/util/logging/TestLogConfigurationDeadLock.java b/jdk/test/java/util/logging/TestLogConfigurationDeadLock.java index 3d1e3d2da52..70badde17f5 100644 --- a/jdk/test/java/util/logging/TestLogConfigurationDeadLock.java +++ b/jdk/test/java/util/logging/TestLogConfigurationDeadLock.java @@ -196,7 +196,8 @@ public class TestLogConfigurationDeadLock { if (ids.length == 1) { throw new RuntimeException("Found 1 deadlocked thread: "+ids[0]); } else if (ids.length > 0) { - ThreadInfo[] infos = ManagementFactory.getThreadMXBean().getThreadInfo(ids); + ThreadInfo[] infos = ManagementFactory.getThreadMXBean() + .getThreadInfo(ids, Integer.MAX_VALUE); System.err.println("Found "+ids.length+" deadlocked threads: "); for (ThreadInfo inf : infos) { System.err.println(inf.toString()); diff --git a/jdk/test/java/util/logging/TestLogConfigurationDeadLockWithConf.java b/jdk/test/java/util/logging/TestLogConfigurationDeadLockWithConf.java new file mode 100644 index 00000000000..9bde8d516fc --- /dev/null +++ b/jdk/test/java/util/logging/TestLogConfigurationDeadLockWithConf.java @@ -0,0 +1,340 @@ +/* + * 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.PrintStream; +import java.lang.management.ManagementFactory; +import java.lang.management.ThreadInfo; +import java.security.Permission; +import java.security.Policy; +import java.security.ProtectionDomain; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Random; +import java.util.Set; +import java.util.concurrent.atomic.AtomicLong; +import java.util.logging.Level; +import java.util.logging.LogManager; +import java.util.logging.Logger; + + +/** + * @test + * @bug 8027670 8029281 + * @summary Deadlock in drainLoggerRefQueueBounded / readConfiguration + * caused by synchronization issues in Logger and LogManager. + * @run main/othervm TestLogConfigurationDeadLockWithConf + * @author danielfuchs + */ +// This test is a best effort to try & detect issues. The test itself will run +// for 8secs. This is usually sufficient to detect issues. +// However to get a greater confidence it is recommended to run this test in a loop: +// e.g. use something like: +// $ while jtreg -jdk:$JDK -verbose:all \ +// test/java/util/logging/TestLogConfigurationDeadLockWithConf.java ; \ +// do echo Running test again ; done +// and let it run for a few hours... +// +public class TestLogConfigurationDeadLockWithConf { + + static volatile Exception thrown = null; + static volatile boolean goOn = true; + + static final int READERS = 2; + static final int LOGGERS = 2; + static final long TIME = 4 * 1000; // 4 sec. + static final long STEP = 1 * 1000; // message every 1 sec. + static final int LCOUNT = 50; // 50 loggers created in a row... + static final AtomicLong nextLogger = new AtomicLong(0); + static final AtomicLong readCount = new AtomicLong(0); + static final AtomicLong checkCount = new AtomicLong(0); + + /** + * This test will run both with and without a security manager. + * + * The test starts a number of threads that will call + * LogManager.readConfiguration() concurrently (ReadConf), then starts + * a number of threads that will create new loggers concurrently + * (AddLogger), and then two additional threads: one (Stopper) that + * will stop the test after 4secs (TIME ms), and one DeadlockDetector + * that will attempt to detect deadlocks. + * If after 4secs no deadlock was detected and no exception was thrown + * then the test is considered a success and passes. + * + * This procedure is done twice: once without a security manager and once + * again with a security manager - which means the test takes ~8secs to + * run. + * + * Note that 8sec may not be enough to detect issues if there are some. + * This is a best effort test. + * + * @param args the command line arguments + * @throws java.lang.Exception if the test fails. + */ + public static void main(String[] args) throws Exception { + File config = new File(System.getProperty("test.src", "."), + "deadlockconf.properties"); + if (!config.canRead()) { + System.err.println("Can't read config file: test cannot execute."); + System.err.println("Please check your test environment: "); + System.err.println("\t -Dtest.src=" + System.getProperty("test.src", ".")); + System.err.println("\t config file is: " + config.getAbsolutePath()); + throw new RuntimeException("Can't read config file: " + + config.getAbsolutePath()); + } + + System.setProperty("java.util.logging.config.file", + config.getAbsolutePath()); + + // test without security + System.out.println("No security"); + test(); + + // test with security + System.out.println("\nWith security"); + Policy.setPolicy(new Policy() { + @Override + public boolean implies(ProtectionDomain domain, Permission permission) { + if (super.implies(domain, permission)) return true; + // System.out.println("Granting " + permission); + return true; // all permissions + } + }); + System.setSecurityManager(new SecurityManager()); + test(); + } + + static Random rand = new Random(System.currentTimeMillis()); + private static int getBarCount() { + return rand.nextInt(10); + } + + /** + * Starts all threads, wait 4secs, then stops all threads. + * @throws Exception if a deadlock was detected or an error occurred. + */ + public static void test() throws Exception { + goOn = true; + thrown = null; + long sNextLogger = nextLogger.get(); + long sReadCount = readCount.get(); + long sCheckCount = checkCount.get(); + List threads = new ArrayList<>(); + for (int i = 0; i deadlocked = Collections.synchronizedSet(new HashSet()); + + static List asList(long... ids) { + final List list = new ArrayList<>(ids.length); + for (long id : ids) { + list.add(id); + } + return list; + } + + @Override + public void run() { + while(goOn) { + try { + long[] ids = ManagementFactory.getThreadMXBean().findDeadlockedThreads(); + checkCount.incrementAndGet(); + ids = ids == null ? new long[0] : ids; + if (ids.length > 0) { + deadlocked.addAll(asList(ids)); + } + if (ids.length == 1) { + throw new RuntimeException("Found 1 deadlocked thread: "+ids[0]); + } else if (ids.length > 0) { + ThreadInfo[] infos = ManagementFactory.getThreadMXBean().getThreadInfo(ids, Integer.MAX_VALUE); + System.err.println("Found "+ids.length+" deadlocked threads: "); + for (ThreadInfo inf : infos) { + System.err.println(inf.toString()); + } + throw new RuntimeException("Found "+ids.length+" deadlocked threads"); + } + Thread.sleep(100); + } catch(InterruptedException | RuntimeException x) { + fail(x); + } + } + } + + } + + static final class Stopper extends Thread { + long start; + long time; + + static final Logger logger = Logger.getLogger("remaining"); + + Stopper(long time) { + start = System.currentTimeMillis(); + this.time = time; + } + + @Override + public void run() { + try { + long rest, previous; + previous = time; + while (goOn && (rest = start - System.currentTimeMillis() + time) > 0) { + if (previous == time || previous - rest >= STEP) { + logger.log(Level.INFO, + "{0}ms remaining...", String.valueOf(rest)); + previous = rest == time ? rest -1 : rest; + System.gc(); + } + if (goOn == false) break; + Thread.sleep(Math.min(rest, 100)); + } + System.out.println(System.currentTimeMillis() - start + + " ms elapsed ("+time+ " requested)"); + goOn = false; + } catch(InterruptedException | RuntimeException x) { + fail(x); + } + } + + } + + static void fail(Exception x) { + x.printStackTrace(); + if (thrown == null) { + thrown = x; + } + goOn = false; + } +} diff --git a/jdk/test/java/util/logging/TestLoggerBundleSync.java b/jdk/test/java/util/logging/TestLoggerBundleSync.java index bbac23c665f..48933c9adca 100644 --- a/jdk/test/java/util/logging/TestLoggerBundleSync.java +++ b/jdk/test/java/util/logging/TestLoggerBundleSync.java @@ -190,8 +190,10 @@ public class TestLoggerBundleSync { final static class MyHandler extends Handler { volatile ResourceBundle rb; volatile String rbName; + volatile int count = 0; @Override public synchronized void publish(LogRecord record) { + count++; rb = record.getResourceBundle(); rbName = record.getResourceBundleName(); } @@ -227,23 +229,51 @@ public class TestLoggerBundleSync { Logger ll = Logger.getLogger(l.getName()+".bie.bye"); ResourceBundle hrb; String hrbName; + if (handler.getLevel() != Level.FINEST) { + throw new RuntimeException("Handler level is not finest: " + + handler.getLevel()); + } + final int countBefore = handler.count; ll.setLevel(Level.FINEST); ll.addHandler(handler); ll.fine("dummy"); ll.removeHandler(handler); + final int countAfter = handler.count; + if (countBefore == countAfter) { + throw new RuntimeException("Handler not called for " + + ll.getName() + "("+ countAfter +")"); + } hrb = handler.rb; hrbName = handler.rbName; if (name != null) { + // if name is not null, then it implies that it + // won't change, since setResourceBundle() cannot + // replace a non null name. + // Since we never set the resource bundle on 'll', + // then ll must inherit its resource bundle [name] + // from l - and therefor we should find it in + // handler.rb/handler.rbName if (!name.equals(hrbName)) { throw new RuntimeException("Unexpected bundle name: " - +hrb.getBaseBundleName()); + +hrbName); } + // here we know that hrbName is not null so hrb + // should not be null either. if (!name.equals(hrb.getBaseBundleName())) { throw new RuntimeException("Unexpected bundle name: " +hrb.getBaseBundleName()); } } + // Make sure to refer to 'l' explicitly in order to + // prevent eager garbage collecting before the end of + // the test (JDK-8030192) + if (!ll.getName().startsWith(l.getName())) { + throw new RuntimeException("Logger " + ll.getName() + + "does not start with expected prefix " + + l.getName()); + } + getRBcount.incrementAndGet(); if (!goOn) break; Thread.sleep(1); diff --git a/jdk/test/java/util/logging/deadlockconf.properties b/jdk/test/java/util/logging/deadlockconf.properties new file mode 100644 index 00000000000..e81742fa158 --- /dev/null +++ b/jdk/test/java/util/logging/deadlockconf.properties @@ -0,0 +1,22 @@ +# This file is used by TestLogConfigurationDeadLockWithConf +handlers= java.util.logging.ConsoleHandler +.level= INFO +java.util.logging.ConsoleHandler.level = INFO +java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter + + +foo.bar0.level = INFO +foo.bar1.level = INFO +foo.bar2.level = INFO +foo.bar3.level = INFO +foo.bar4.level = INFO + +# We leave foo.bar5 out so that we have at least +# one logger whose parent won't be in the configuration +# file +#foo.bar5.level = INFO + +foo.bar6.level = INFO +foo.bar7.level = INFO +foo.bar8.level = INFO +foo.bar9.level = INFO diff --git a/jdk/test/java/util/logging/java.policy b/jdk/test/java/util/logging/java.policy deleted file mode 100644 index e41f260730e..00000000000 --- a/jdk/test/java/util/logging/java.policy +++ /dev/null @@ -1,3 +0,0 @@ -grant { - permission java.util.logging.LoggingPermission "control"; -}; diff --git a/jdk/test/java/util/prefs/CheckUserPrefsStorage.sh b/jdk/test/java/util/prefs/CheckUserPrefsStorage.sh index 28210696b39..bfb4a2a54c7 100644 --- a/jdk/test/java/util/prefs/CheckUserPrefsStorage.sh +++ b/jdk/test/java/util/prefs/CheckUserPrefsStorage.sh @@ -31,7 +31,7 @@ OS=`uname -s` case "$OS" in - SunOS | Linux | Darwin ) + SunOS | Linux | Darwin | AIX ) PS=":" FS="/" ;; diff --git a/jdk/test/java/util/stream/TestDoubleSumAverage.java b/jdk/test/java/util/stream/TestDoubleSumAverage.java index 01453bd06d4..e8df2e995c6 100644 --- a/jdk/test/java/util/stream/TestDoubleSumAverage.java +++ b/jdk/test/java/util/stream/TestDoubleSumAverage.java @@ -25,23 +25,35 @@ import java.util.*; import java.util.function.*; import java.util.stream.*; +import static java.lang.Double.*; + /* * @test - * @bug 8006572 + * @bug 8006572 8030212 * @summary Test for use of non-naive summation in stream-related sum and average operations. */ public class TestDoubleSumAverage { public static void main(String... args) { int failures = 0; - failures += testForCompenstation(); failures += testZeroAverageOfNonEmptyStream(); + failures += testForCompenstation(); + failures += testNonfiniteSum(); if (failures > 0) { throw new RuntimeException("Found " + failures + " numerical failure(s)."); } } + /** + * Test to verify that a non-empty stream with a zero average is non-empty. + */ + private static int testZeroAverageOfNonEmptyStream() { + Supplier ds = () -> DoubleStream.iterate(0.0, e -> 0.0).limit(10); + + return compareUlpDifference(0.0, ds.get().average().getAsDouble(), 0); + } + /** * Compute the sum and average of a sequence of double values in * various ways and report an error if naive summation is used. @@ -83,19 +95,68 @@ public class TestDoubleSumAverage { return failures; } - /** - * Test to verify that a non-empty stream with a zero average is non-empty. - */ - private static int testZeroAverageOfNonEmptyStream() { - Supplier ds = () -> DoubleStream.iterate(0.0, e -> 0.0).limit(10); + private static int testNonfiniteSum() { + int failures = 0; - return compareUlpDifference(0.0, ds.get().average().getAsDouble(), 0); + Map, Double> testCases = new LinkedHashMap<>(); + testCases.put(() -> DoubleStream.of(MAX_VALUE, MAX_VALUE), POSITIVE_INFINITY); + testCases.put(() -> DoubleStream.of(-MAX_VALUE, -MAX_VALUE), NEGATIVE_INFINITY); + + testCases.put(() -> DoubleStream.of(1.0d, POSITIVE_INFINITY, 1.0d), POSITIVE_INFINITY); + testCases.put(() -> DoubleStream.of(POSITIVE_INFINITY), POSITIVE_INFINITY); + testCases.put(() -> DoubleStream.of(POSITIVE_INFINITY, POSITIVE_INFINITY), POSITIVE_INFINITY); + testCases.put(() -> DoubleStream.of(POSITIVE_INFINITY, POSITIVE_INFINITY, 0.0), POSITIVE_INFINITY); + + testCases.put(() -> DoubleStream.of(1.0d, NEGATIVE_INFINITY, 1.0d), NEGATIVE_INFINITY); + testCases.put(() -> DoubleStream.of(NEGATIVE_INFINITY), NEGATIVE_INFINITY); + testCases.put(() -> DoubleStream.of(NEGATIVE_INFINITY, NEGATIVE_INFINITY), NEGATIVE_INFINITY); + testCases.put(() -> DoubleStream.of(NEGATIVE_INFINITY, NEGATIVE_INFINITY, 0.0), NEGATIVE_INFINITY); + + testCases.put(() -> DoubleStream.of(1.0d, NaN, 1.0d), NaN); + testCases.put(() -> DoubleStream.of(NaN), NaN); + testCases.put(() -> DoubleStream.of(1.0d, NEGATIVE_INFINITY, POSITIVE_INFINITY, 1.0d), NaN); + testCases.put(() -> DoubleStream.of(1.0d, POSITIVE_INFINITY, NEGATIVE_INFINITY, 1.0d), NaN); + testCases.put(() -> DoubleStream.of(POSITIVE_INFINITY, NaN), NaN); + testCases.put(() -> DoubleStream.of(NEGATIVE_INFINITY, NaN), NaN); + testCases.put(() -> DoubleStream.of(NaN, POSITIVE_INFINITY), NaN); + testCases.put(() -> DoubleStream.of(NaN, NEGATIVE_INFINITY), NaN); + + for(Map.Entry, Double> testCase : testCases.entrySet()) { + Supplier ds = testCase.getKey(); + double expected = testCase.getValue(); + + DoubleSummaryStatistics stats = ds.get().collect(DoubleSummaryStatistics::new, + DoubleSummaryStatistics::accept, + DoubleSummaryStatistics::combine); + + failures += compareUlpDifference(expected, stats.getSum(), 0); + failures += compareUlpDifference(expected, stats.getAverage(), 0); + + failures += compareUlpDifference(expected, ds.get().sum(), 0); + failures += compareUlpDifference(expected, ds.get().average().getAsDouble(), 0); + + failures += compareUlpDifference(expected, ds.get().boxed().collect(Collectors.summingDouble(d -> d)), 0); + failures += compareUlpDifference(expected, ds.get().boxed().collect(Collectors.averagingDouble(d -> d)), 0); + } + + return failures; } /** * Compute the ulp difference of two double values and compare against an error threshold. */ private static int compareUlpDifference(double expected, double computed, double threshold) { + if (!Double.isFinite(expected)) { + // Handle NaN and infinity cases + if (Double.compare(expected, computed) == 0) + return 0; + else { + System.err.printf("Unexpected sum, %g rather than %g.%n", + computed, expected); + return 1; + } + } + double ulpDifference = Math.abs(expected - computed) / Math.ulp(expected); if (ulpDifference > threshold) { diff --git a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/CountLargeTest.java b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/CountLargeTest.java new file mode 100644 index 00000000000..9b87a09f344 --- /dev/null +++ b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/CountLargeTest.java @@ -0,0 +1,70 @@ +/* + * 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 + * @summary Tests counting of streams containing Integer.MAX_VALUE + 1 elements + * @bug 8031187 + */ + +package org.openjdk.tests.java.util.stream; + +import java.util.stream.LongStream; + +import org.testng.annotations.Test; + +import static org.testng.Assert.*; + +@Test +public class CountLargeTest { + + static final long EXPECTED_LARGE_COUNT = 1L + Integer.MAX_VALUE; + + public void testRefLarge() { + long count = LongStream.range(0, EXPECTED_LARGE_COUNT) + .mapToObj(e -> null).count(); + + assertEquals(count, EXPECTED_LARGE_COUNT); + } + + public void testIntLarge() { + long count = LongStream.range(0, EXPECTED_LARGE_COUNT) + .mapToInt(e -> 0).count(); + + assertEquals(count, EXPECTED_LARGE_COUNT); + } + + public void testLongLarge() { + long count = LongStream.range(0, EXPECTED_LARGE_COUNT) + .count(); + + assertEquals(count, EXPECTED_LARGE_COUNT); + } + + public void testDoubleLarge() { + long count = LongStream.range(0, EXPECTED_LARGE_COUNT) + .mapToDouble(e -> 0.0).count(); + + assertEquals(count, EXPECTED_LARGE_COUNT); + } +} diff --git a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/CountTest.java b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/CountTest.java new file mode 100644 index 00000000000..c5d337e8539 --- /dev/null +++ b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/CountTest.java @@ -0,0 +1,86 @@ +/* + * 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 + * @summary Tests counting of streams + * @bug 8031187 + */ + +package org.openjdk.tests.java.util.stream; + +import java.util.stream.DoubleStream; +import java.util.stream.DoubleStreamTestDataProvider; +import java.util.stream.IntStream; +import java.util.stream.IntStreamTestDataProvider; +import java.util.stream.LongStream; +import java.util.stream.LongStreamTestDataProvider; +import java.util.stream.OpTestCase; +import java.util.stream.Stream; +import java.util.stream.StreamTestDataProvider; +import java.util.stream.TestData; + +import org.testng.annotations.Test; + +public class CountTest extends OpTestCase { + + @Test(dataProvider = "StreamTestData", dataProviderClass = StreamTestDataProvider.class) + public void testOps(String name, TestData.OfRef data) { + long expectedCount = data.size(); + + withData(data). + terminal(Stream::count). + expectedResult(expectedCount). + exercise(); + } + + @Test(dataProvider = "IntStreamTestData", dataProviderClass = IntStreamTestDataProvider.class) + public void testOps(String name, TestData.OfInt data) { + long expectedCount = data.size(); + + withData(data). + terminal(IntStream::count). + expectedResult(expectedCount). + exercise(); + } + + @Test(dataProvider = "LongStreamTestData", dataProviderClass = LongStreamTestDataProvider.class) + public void testOps(String name, TestData.OfLong data) { + long expectedCount = data.size(); + + withData(data). + terminal(LongStream::count). + expectedResult(expectedCount). + exercise(); + } + + @Test(dataProvider = "DoubleStreamTestData", dataProviderClass = DoubleStreamTestDataProvider.class) + public void testOps(String name, TestData.OfDouble data) { + long expectedCount = data.size(); + + withData(data). + terminal(DoubleStream::count). + expectedResult(expectedCount). + exercise(); + } +} diff --git a/jdk/test/java/util/zip/ZipFile/FinalizeZipFile.java b/jdk/test/java/util/zip/ZipFile/FinalizeZipFile.java index 1c27e848280..055c05aa72d 100644 --- a/jdk/test/java/util/zip/ZipFile/FinalizeZipFile.java +++ b/jdk/test/java/util/zip/ZipFile/FinalizeZipFile.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,11 +27,9 @@ */ import java.io.*; -import java.nio.*; import java.util.Random; import java.util.zip.*; import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; public class FinalizeZipFile { @@ -43,6 +41,7 @@ public class FinalizeZipFile { super(f); System.out.printf("Using %s%n", f.getPath()); } + @Override protected void finalize() throws IOException { System.out.printf("Killing %s%n", getName()); super.finalize(); @@ -81,7 +80,7 @@ public class FinalizeZipFile { makeGarbage(); System.gc(); - finalizersDone.await(5, TimeUnit.SECONDS); + finalizersDone.await(); // Not all ZipFiles were collected? equal(finalizersDone.getCount(), 0L); diff --git a/jdk/test/java/util/zip/ZipFile/ReadLongZipFileName.java b/jdk/test/java/util/zip/ZipFile/ReadLongZipFileName.java index 7b6aa64801a..217ce52dcd3 100644 --- a/jdk/test/java/util/zip/ZipFile/ReadLongZipFileName.java +++ b/jdk/test/java/util/zip/ZipFile/ReadLongZipFileName.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 @@ -24,6 +24,7 @@ /** * @test * @bug 6374379 + * @library ../../../../lib/testlibrary * @summary Verify that we can read zip file names > 255 chars long */ @@ -31,6 +32,7 @@ import java.io.*; import java.util.jar.*; import java.util.zip.*; import java.util.Stack; +import jdk.testlibrary.FileUtils; public class ReadLongZipFileName { private static String entryName = "testFile.txt";; @@ -101,7 +103,12 @@ public class ReadLongZipFileName { while (! directories.empty()) { File f = directories.pop(); - check(f.delete()); + try { + FileUtils.deleteFileWithRetry(f.toPath()); + } catch (IOException e) { + unexpected(e, "Fail to clean up directory, " + f); + break; + } } } diff --git a/jdk/test/javax/crypto/SecretKeyFactory/FailOverTest.sh b/jdk/test/javax/crypto/SecretKeyFactory/FailOverTest.sh index c16b60ff877..51eaa6eda0c 100644 --- a/jdk/test/javax/crypto/SecretKeyFactory/FailOverTest.sh +++ b/jdk/test/javax/crypto/SecretKeyFactory/FailOverTest.sh @@ -56,7 +56,7 @@ echo "TESTCLASSES=${TESTCLASSES}" # set platform-dependent variables OS=`uname -s` case "$OS" in - SunOS | Linux | Darwin ) + SunOS | Linux | Darwin | AIX ) NULL=/dev/null PS=":" FS="/" diff --git a/jdk/test/javax/imageio/metadata/GetObjectMinValue.java b/jdk/test/javax/imageio/metadata/GetObjectMinValue.java index b5d3f6fdfef..04094e3e041 100644 --- a/jdk/test/javax/imageio/metadata/GetObjectMinValue.java +++ b/jdk/test/javax/imageio/metadata/GetObjectMinValue.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 @@ -24,14 +24,12 @@ /* * @test * @bug 4429875 7186799 - * @compile -source 1.4 GetObjectMinValue.java + * @compile GetObjectMinValue.java * @run main GetObjectMinValue * @summary Tests the getObject{Min,Max}Value method of * IIOMetadataFormatImpl for an inclusive range */ -// Compiled with -source 1.4 to work around javac bug 5041233 - import javax.imageio.metadata.IIOMetadataFormatImpl; import javax.imageio.ImageTypeSpecifier; @@ -79,13 +77,13 @@ public class GetObjectMinValue { } public void addObjectValue(String elementName, - Class classType, Object defaultValue, + Class classType, Integer defaultValue, Comparable minValue, Comparable maxValue, boolean minInclusive, boolean maxInclusive) { - super.addObjectValue(elementName, - classType, defaultValue, - minValue, maxValue, - minInclusive, maxInclusive); + super.addObjectValue(elementName, + (Class)classType, defaultValue, + (Comparable) minValue, (Comparable) maxValue, + minInclusive, maxInclusive); } public boolean canNodeAppear(String elementName, diff --git a/jdk/test/javax/imageio/metadata/IIOMetadataFormat/runMetadataFormatTest.sh b/jdk/test/javax/imageio/metadata/IIOMetadataFormat/runMetadataFormatTest.sh index 84a58535cf1..800a898eb1a 100644 --- a/jdk/test/javax/imageio/metadata/IIOMetadataFormat/runMetadataFormatTest.sh +++ b/jdk/test/javax/imageio/metadata/IIOMetadataFormat/runMetadataFormatTest.sh @@ -89,7 +89,7 @@ case "$OS" in FILESEP="/" ;; - Linux | Darwin ) + Linux | Darwin | AIX ) VAR="A different value for Linux" DEFAULT_JDK=/none #DEFAULT_JDK=/usr/local/java/jdk1.4/linux-i386 diff --git a/jdk/test/javax/imageio/metadata/IIOMetadataFormat/runMetadataFormatThreadTest.sh b/jdk/test/javax/imageio/metadata/IIOMetadataFormat/runMetadataFormatThreadTest.sh index ed36fef3f17..eb60ba99282 100644 --- a/jdk/test/javax/imageio/metadata/IIOMetadataFormat/runMetadataFormatThreadTest.sh +++ b/jdk/test/javax/imageio/metadata/IIOMetadataFormat/runMetadataFormatThreadTest.sh @@ -90,7 +90,7 @@ case "$OS" in FILESEP="/" ;; - Linux | Darwin ) + Linux | Darwin | AIX ) VAR="A different value for Linux" DEFAULT_JDK=/none #DEFAULT_JDK=/usr/local/java/jdk1.4/linux-i386 diff --git a/jdk/test/javax/imageio/stream/StreamCloserLeak/run_test.sh b/jdk/test/javax/imageio/stream/StreamCloserLeak/run_test.sh index 18ffc1c8d40..1977ca80275 100644 --- a/jdk/test/javax/imageio/stream/StreamCloserLeak/run_test.sh +++ b/jdk/test/javax/imageio/stream/StreamCloserLeak/run_test.sh @@ -92,6 +92,14 @@ case "$OS" in TMP="/tmp" ;; + AIX ) + VAR="A different value for AIX" + DEFAULT_JDK=/ + FILESEP="/" + PATHSEP=":" + TMP="/tmp" + ;; + Darwin ) VAR="A different value for MacOSX" DEFAULT_JDK=/usr diff --git a/jdk/test/javax/management/monitor/StartStopTest.java b/jdk/test/javax/management/monitor/StartStopTest.java index 98eca2976ba..80694c63e05 100644 --- a/jdk/test/javax/management/monitor/StartStopTest.java +++ b/jdk/test/javax/management/monitor/StartStopTest.java @@ -27,6 +27,8 @@ * @summary Test that tasks are cancelled properly when * monitors are started and stopped in a loop. * @author Luis-Miguel Alventosa + * @library /lib/testlibrary + * @run build jdk.testlibrary.Utils * @run clean StartStopTest * @run build StartStopTest * @run main/othervm/timeout=300 StartStopTest 1 @@ -52,14 +54,15 @@ import javax.management.monitor.Monitor; import javax.management.monitor.MonitorNotification; import javax.management.monitor.StringMonitor; -public class StartStopTest { +import jdk.testlibrary.Utils; +public class StartStopTest { static int maxPoolSize; static final AtomicInteger counter = new AtomicInteger(); // MBean class public class ObservedObject implements ObservedObjectMBean { - public boolean called = false; + volatile public boolean called = false; public Integer getInteger() { task("Integer"); return 0; @@ -142,7 +145,7 @@ public class StartStopTest { for (int i = 0; i < nTasks; i++) monitor[i].start(); echo(">>> MONITORS started"); - Thread.sleep(500); + doSleep(500); echo(">>> Check FLAGS true"); for (int i = 0; i < nTasks; i++) if (!monitored[i].called) { @@ -154,7 +157,7 @@ public class StartStopTest { for (int i = 0; i < nTasks; i++) monitor[i].stop(); echo(">>> MONITORS stopped"); - Thread.sleep(500); + doSleep(500); echo(">>> Set FLAGS to false"); for (int i = 0; i < nTasks; i++) monitored[i].called = false; @@ -208,4 +211,8 @@ public class StartStopTest { echo(">>> Happy Bye, Bye!"); } } + + private static void doSleep(long ms) throws Exception { + Thread.sleep(Math.round(ms * Utils.TIMEOUT_FACTOR)); + } } diff --git a/jdk/test/javax/script/CommonSetup.sh b/jdk/test/javax/script/CommonSetup.sh index 69ed2379eda..7a64bd8c661 100644 --- a/jdk/test/javax/script/CommonSetup.sh +++ b/jdk/test/javax/script/CommonSetup.sh @@ -36,7 +36,7 @@ OS=`uname -s` case "$OS" in - SunOS | Linux | Darwin ) + SunOS | Linux | Darwin | AIX ) PS=":" FS="/" ;; diff --git a/jdk/test/javax/security/auth/Subject/doAs/Test.sh b/jdk/test/javax/security/auth/Subject/doAs/Test.sh index 73565211859..fac17d138c5 100644 --- a/jdk/test/javax/security/auth/Subject/doAs/Test.sh +++ b/jdk/test/javax/security/auth/Subject/doAs/Test.sh @@ -48,6 +48,11 @@ case "$OS" in FS="/" RM="/bin/rm -f" ;; + AIX ) + PS=":" + FS="/" + RM="/bin/rm -f" + ;; CYGWIN* ) PS=";" FS="/" diff --git a/jdk/test/javax/sound/midi/MidiDeviceConnectors/TestAllDevices.java b/jdk/test/javax/sound/midi/MidiDeviceConnectors/TestAllDevices.java index 9155dbb6b32..27290738a0c 100644 --- a/jdk/test/javax/sound/midi/MidiDeviceConnectors/TestAllDevices.java +++ b/jdk/test/javax/sound/midi/MidiDeviceConnectors/TestAllDevices.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 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,7 +25,7 @@ * @test * @bug 4933700 * @summary Tests that default devices return MidiDeviceTransmitter/Receiver and returned objects return correct MidiDevice - * @compile -source 1.7 TestAllDevices.java + * @compile TestAllDevices.java * @run main TestAllDevices * @author Alex Menkov */ diff --git a/jdk/test/javax/sound/sampled/AudioFormat/PCM_FLOAT_support.java b/jdk/test/javax/sound/sampled/AudioFormat/PCM_FLOAT_support.java index 43d39fb8ead..7b4f0b1b8e7 100644 --- a/jdk/test/javax/sound/sampled/AudioFormat/PCM_FLOAT_support.java +++ b/jdk/test/javax/sound/sampled/AudioFormat/PCM_FLOAT_support.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 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,7 +25,7 @@ * @test * @bug 6944033 * @summary Tests that PCM_FLOAT encoding is supported - * @compile -source 1.7 PCM_FLOAT_support.java + * @compile PCM_FLOAT_support.java * @run main PCM_FLOAT_support * @author Alex Menkov * diff --git a/jdk/test/javax/xml/jaxp/parsers/8027359/XML11EntityScannerTest.java b/jdk/test/javax/xml/jaxp/parsers/8027359/XML11EntityScannerTest.java new file mode 100644 index 00000000000..a430b5f51a9 --- /dev/null +++ b/jdk/test/javax/xml/jaxp/parsers/8027359/XML11EntityScannerTest.java @@ -0,0 +1,184 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8027359 + * @summary test that the XML11EntityScanner refreshes cache when it loads new data + * @run main XML11EntityScannerTest + */ + +import java.io.*; +import java.util.regex.Pattern; +import javax.xml.parsers.DocumentBuilderFactory; +import org.w3c.dom.*; + + +/** + * XML11EntityScanner functions similarly as XMLEntityScanner in handling data + * cache + */ +public class XML11EntityScannerTest { + static final String rawXML = + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + ""; + + /** + * main method. + * + * @param args Standard args. + */ + public static void main(String[] args) { + try { + final Document xmlDoc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream(rawXML.getBytes("UTF-8"))); + final Element identityElement = (Element) xmlDoc.getElementsByTagName("Identity").item(0); + final Element trustListElement = (Element) identityElement.getElementsByTagName("TrustList").item(0); + final NodeList trustList = trustListElement.getElementsByTagName("Trust"); + final Pattern keyPattern = Pattern.compile("USK@[%,~" + "*-_./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz" + "]+"); + for (int i = 0; i < trustList.getLength(); ++i) { + Element trustElement = (Element) trustList.item(i); + final String identity = trustElement.getAttribute("Identity"); + if (!keyPattern.matcher(identity).matches()) { + throw new RuntimeException("Parsing failure: Instead of USK URI I got: " + identity); + } + } + } catch (Exception ex) { + throw new RuntimeException(ex.getMessage()); + } + } + +} diff --git a/jdk/test/javax/xml/jaxp/parsers/8029955/EntityScannerTest.java b/jdk/test/javax/xml/jaxp/parsers/8029955/EntityScannerTest.java new file mode 100644 index 00000000000..7a1ae6cc6e4 --- /dev/null +++ b/jdk/test/javax/xml/jaxp/parsers/8029955/EntityScannerTest.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8029955 + * @summary test that the size of whitespace lookup buffer is adjusted as needed + * @run main EntityScannerTest + */ + +import java.io.*; +import org.xml.sax.InputSource; +import org.xml.sax.XMLReader; +import org.xml.sax.helpers.XMLReaderFactory; + + +/** + * + * @author Joe Wang huizhe.wang@oracle.com + */ +public class EntityScannerTest { + + /** + * main method. + * + * @param args Standard args. + */ + public static void main(String[] args) { + try { + StringBuilder builder = new StringBuilder(); + builder.append(""); + final XMLReader reader = XMLReaderFactory.createXMLReader(); + System.out.println(reader.getClass().getName()); + reader.parse(new InputSource(new StringReader(builder.toString()))); + } catch (ArrayIndexOutOfBoundsException e) { + throw new RuntimeException("Test failed: ArrayIndexOutOfBoundsException " + e.getMessage()); + } catch (Exception e) { + throw new RuntimeException(e.getMessage()); + } + } + +} diff --git a/jdk/test/jdk/lambda/MethodReferenceTestCallerSensitive.java b/jdk/test/jdk/lambda/MethodReferenceTestCallerSensitive.java index 805a6a203cb..86c22a10627 100644 --- a/jdk/test/jdk/lambda/MethodReferenceTestCallerSensitive.java +++ b/jdk/test/jdk/lambda/MethodReferenceTestCallerSensitive.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,6 +28,8 @@ import java.util.function.Function; /** + * @test + * @bug 8020816 * @author Robert Field */ diff --git a/jdk/test/lib/security/java.policy/Ext_AllPolicy.sh b/jdk/test/lib/security/java.policy/Ext_AllPolicy.sh index b562afa4323..fff2a3436fc 100644 --- a/jdk/test/lib/security/java.policy/Ext_AllPolicy.sh +++ b/jdk/test/lib/security/java.policy/Ext_AllPolicy.sh @@ -53,7 +53,7 @@ fi # set platform-dependent variables OS=`uname -s` case "$OS" in - SunOS | Linux | Darwin ) + SunOS | Linux | Darwin | AIX ) NULL=/dev/null PS=":" FS="/" diff --git a/jdk/test/lib/testlibrary/jdk/testlibrary/JcmdBase.java b/jdk/test/lib/testlibrary/jdk/testlibrary/JcmdBase.java index 14599c998bd..f8a212e2bdb 100644 --- a/jdk/test/lib/testlibrary/jdk/testlibrary/JcmdBase.java +++ b/jdk/test/lib/testlibrary/jdk/testlibrary/JcmdBase.java @@ -26,34 +26,91 @@ package jdk.testlibrary; import java.util.Arrays; /** - * Super class for tests which need to attach jcmd to the current process. + * Helper class for starting jcmd process. + *
+ * - jcmd will send diagnostic requests to the current java process:
+ *      jcmd pid_to_current_process PerfCounter.print
+ * - jcmd will be run without sending request to any JVM
+ *      jcmd -h
+ * 
*/ -public class JcmdBase { +public final class JcmdBase { private static ProcessBuilder processBuilder = new ProcessBuilder(); + private JcmdBase() { + // Private constructor to prevent class instantiation + } + /** - * Attach jcmd to the current process + * Sends the diagnostic command request to the current process * - * @param toolArgs - * jcmd command line parameters, e.g. VM.flags - * @return jcmd output + * @see #jcmd(boolean, String[], String[]) + */ + public final static OutputAnalyzer jcmd(String... jcmdArgs) + throws Exception { + return jcmd(true, null, jcmdArgs); + } + + /** + * Sends the diagnostic command request to the current process. + * jcmd will be run with specified {@code vmArgs}. + * + * @see #jcmd(boolean, String[], String[]) + */ + public final static OutputAnalyzer jcmd(String[] vmArgs, + String[] jcmdArgs) throws Exception { + return jcmd(true, vmArgs, jcmdArgs); + } + + /** + * Runs jcmd without sending request to any JVM + * + * @see #jcmd(boolean, String[], String[]) + */ + public final static OutputAnalyzer jcmdNoPid(String[] vmArgs, + String[] jcmdArgs) throws Exception { + return jcmd(false, vmArgs, jcmdArgs); + } + + /** + * If {@code requestToCurrentProcess} is {@code true} + * sends a diagnostic command request to the current process. + * If {@code requestToCurrentProcess} is {@code false} + * runs jcmd without sending request to any JVM. + * + * @param requestToCurrentProcess + * Defines if jcmd will send request to the current process + * @param vmArgs + * jcmd will be run with VM arguments specified, + * e.g. -XX:+UsePerfData + * @param jcmdArgs + * jcmd will be run with option or command and its arguments + * specified, e.g. VM.flags + * @return The output from {@link OutputAnalyzer} object * @throws Exception */ - public final static OutputAnalyzer jcmd(String... toolArgs) - throws Exception { + private static final OutputAnalyzer jcmd(boolean requestToCurrentProcess, + String[] vmArgs, String[] jcmdArgs) throws Exception { JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jcmd"); - launcher.addToolArg(Integer.toString(ProcessTools.getProcessId())); - for (String toolArg : toolArgs) { - launcher.addToolArg(toolArg); + if (vmArgs != null) { + for (String vmArg : vmArgs) { + launcher.addVMArg(vmArg); + } + } + if (requestToCurrentProcess) { + launcher.addToolArg(Integer.toString(ProcessTools.getProcessId())); + } + if (jcmdArgs != null) { + for (String toolArg : jcmdArgs) { + launcher.addToolArg(toolArg); + } } processBuilder.command(launcher.getCommand()); System.out.println(Arrays.toString(processBuilder.command().toArray()).replace(",", "")); OutputAnalyzer output = new OutputAnalyzer(processBuilder.start()); System.out.println(output.getOutput()); - output.shouldHaveExitValue(0); - return output; } diff --git a/jdk/test/lib/testlibrary/jdk/testlibrary/OutputAnalyzer.java b/jdk/test/lib/testlibrary/jdk/testlibrary/OutputAnalyzer.java index d4cbd27fa9b..602df9f0143 100644 --- a/jdk/test/lib/testlibrary/jdk/testlibrary/OutputAnalyzer.java +++ b/jdk/test/lib/testlibrary/jdk/testlibrary/OutputAnalyzer.java @@ -23,7 +23,11 @@ package jdk.testlibrary; +import static jdk.testlibrary.Asserts.*; + import java.io.IOException; +import java.util.ArrayList; +import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -394,4 +398,99 @@ public final class OutputAnalyzer { public int getExitValue() { return exitValue; } + + /** + * Get the contents of the output buffer (stdout and stderr) as list of strings. + * Output will be split by system property 'line.separator'. + * + * @return Contents of the output buffer as list of strings + */ + public List asLines() { + List l = new ArrayList<>(); + String[] a = getOutput().split(Utils.NEW_LINE); + for (String string : a) { + l.add(string); + } + return l; + } + + /** + * Check if there is a line matching {@code pattern} and return its index + * + * @param pattern Matching pattern + * @return Index of first matching line + */ + private int indexOf(List lines, String pattern) { + for (int i = 0; i < lines.size(); i++) { + if (lines.get(i).matches(pattern)) { + return i; + } + } + return -1; + } + + /** + * @see #shouldMatchByLine(String, String, String) + */ + public int shouldMatchByLine(String pattern) { + return shouldMatchByLine(null, null, pattern); + } + + /** + * @see #shouldMatchByLine(String, String, String) + */ + public int shouldMatchByLineFrom(String from, String pattern) { + return shouldMatchByLine(from, null, pattern); + } + + /** + * @see #shouldMatchByLine(String, String, String) + */ + public int shouldMatchByLineTo(String to, String pattern) { + return shouldMatchByLine(null, to, pattern); + } + + /** + * Verify that the stdout and stderr contents of output buffer match the + * {@code pattern} line by line. The whole output could be matched or + * just a subset of it. + * + * @param from + * The line from where output will be matched. + * Set {@code from} to null for matching from the first line. + * @param to + * The line until where output will be matched. + * Set {@code to} to null for matching until the last line. + * @param pattern + * Matching pattern + * @return Count of lines which match the {@code pattern} + */ + public int shouldMatchByLine(String from, String to, String pattern) { + List lines = asLines(); + + int fromIndex = 0; + if (from != null) { + fromIndex = indexOf(lines, from); + assertGreaterThan(fromIndex, -1, + "The line/pattern '" + from + "' from where the output should match can not be found"); + } + + int toIndex = lines.size(); + if (to != null) { + toIndex = indexOf(lines, to); + assertGreaterThan(toIndex, -1, + "The line/pattern '" + to + "' until where the output should match can not be found"); + } + + List subList = lines.subList(fromIndex, toIndex); + int matchedCount = 0; + for (String line : subList) { + assertTrue(line.matches(pattern), + "The line '" + line + "' does not match pattern '" + pattern + "'"); + matchedCount++; + } + + return matchedCount; + } + } diff --git a/jdk/test/lib/testlibrary/jdk/testlibrary/ProcessTools.java b/jdk/test/lib/testlibrary/jdk/testlibrary/ProcessTools.java index a454ce5c9b7..c949e0f6c11 100644 --- a/jdk/test/lib/testlibrary/jdk/testlibrary/ProcessTools.java +++ b/jdk/test/lib/testlibrary/jdk/testlibrary/ProcessTools.java @@ -32,6 +32,7 @@ import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collections; +import java.util.concurrent.CountDownLatch; import java.util.Map; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; @@ -39,6 +40,7 @@ import java.util.concurrent.Phaser; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.function.Predicate; +import java.util.function.Consumer; import sun.management.VMManagement; @@ -69,10 +71,38 @@ public final class ProcessTools { */ public static Process startProcess(String name, ProcessBuilder processBuilder) + throws IOException { + return startProcess(name, processBuilder, null); + } + + /** + *

Starts a process from its builder.

+ * The default redirects of STDOUT and STDERR are started + *

It is possible to monitor the in-streams via the provided {@code consumer} + * @param name The process name + * @param consumer {@linkplain Consumer} instance to process the in-streams + * @param processBuilder The process builder + * @return Returns the initialized process + * @throws IOException + */ + public static Process startProcess(String name, + ProcessBuilder processBuilder, + Consumer consumer) throws IOException { Process p = null; try { - p = startProcess(name, processBuilder, null, -1, TimeUnit.NANOSECONDS); + p = startProcess( + name, + processBuilder, + line -> { + if (consumer != null) { + consumer.accept(line); + } + return false; + }, + -1, + TimeUnit.NANOSECONDS + ); } catch (InterruptedException | TimeoutException e) { // can't ever happen } @@ -111,25 +141,28 @@ public final class ProcessTools { stdout.addPump(new LineForwarder(name, System.out)); stderr.addPump(new LineForwarder(name, System.err)); - final Phaser phs = new Phaser(1); + CountDownLatch latch = new CountDownLatch(1); if (linePredicate != null) { - stdout.addPump(new StreamPumper.LinePump() { + StreamPumper.LinePump pump = new StreamPumper.LinePump() { @Override protected void processLine(String line) { - if (linePredicate.test(line)) { - if (phs.getRegisteredParties() > 0) { - phs.arriveAndDeregister(); - } + if (latch.getCount() > 0 && linePredicate.test(line)) { + latch.countDown(); } } - }); + }; + stdout.addPump(pump); + stderr.addPump(pump); } Future stdoutTask = stdout.process(); Future stderrTask = stderr.process(); try { if (timeout > -1) { - phs.awaitAdvanceInterruptibly(0, timeout, unit); + long realTimeout = Math.round(timeout * Utils.TIMEOUT_FACTOR); + if (!latch.await(realTimeout, unit)) { + throw new TimeoutException(); + } } } catch (TimeoutException | InterruptedException e) { System.err.println("Failed to start a process (thread dump follows)"); diff --git a/jdk/test/lib/testlibrary/jdk/testlibrary/Utils.java b/jdk/test/lib/testlibrary/jdk/testlibrary/Utils.java index d557a7ef439..7d4687ee88f 100644 --- a/jdk/test/lib/testlibrary/jdk/testlibrary/Utils.java +++ b/jdk/test/lib/testlibrary/jdk/testlibrary/Utils.java @@ -25,6 +25,9 @@ package jdk.testlibrary; import static jdk.testlibrary.Asserts.assertTrue; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; import java.io.IOException; import java.net.InetAddress; import java.net.ServerSocket; @@ -56,6 +59,15 @@ public final class Utils { */ public static final String JAVA_OPTIONS = System.getProperty("test.java.opts", "").trim(); + /** + * Returns the value of 'test.timeout.factor' system property + * converted to {@code double}. + */ + public static final double TIMEOUT_FACTOR; + static { + String toFactor = System.getProperty("test.timeout.factor", "1.0"); + TIMEOUT_FACTOR = Double.parseDouble(toFactor); + } private Utils() { // Private constructor to prevent class instantiation @@ -203,7 +215,6 @@ public final class Utils { * @throws Exception If multiple matching jvms are found. */ public static int tryFindJvmPid(String key) throws Throwable { - ProcessBuilder pb = null; OutputAnalyzer output = null; try { JDKToolLauncher jcmdLauncher = JDKToolLauncher.create("jcmd"); @@ -229,4 +240,24 @@ public final class Utils { throw t; } } + + /** + * Returns file content as a list of strings + * + * @param file File to operate on + * @return List of strings + * @throws IOException + */ + public static List fileAsList(File file) throws IOException { + assertTrue(file.exists() && file.isFile(), + file.getAbsolutePath() + " does not exist or not a file"); + List output = new ArrayList<>(); + try (BufferedReader reader = new BufferedReader(new FileReader(file.getAbsolutePath()))) { + while (reader.ready()) { + output.add(reader.readLine().replace(NEW_LINE, "")); + } + } + return output; + } + } diff --git a/jdk/test/sun/management/jmxremote/LocalRMIServerSocketFactoryTest.java b/jdk/test/sun/management/jmxremote/LocalRMIServerSocketFactoryTest.java index 620b828caba..83e63f8565a 100644 --- a/jdk/test/sun/management/jmxremote/LocalRMIServerSocketFactoryTest.java +++ b/jdk/test/sun/management/jmxremote/LocalRMIServerSocketFactoryTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,7 +28,7 @@ * * @author Daniel Fuchs * - * @run compile -XDignore.symbol.file=true -source 1.6 -g LocalRMIServerSocketFactoryTest.java + * @run compile -XDignore.symbol.file=true -g LocalRMIServerSocketFactoryTest.java * @run main LocalRMIServerSocketFactoryTest */ @@ -44,6 +44,7 @@ public class LocalRMIServerSocketFactoryTest { private static final SynchronousQueue queue = new SynchronousQueue(); + private static volatile boolean isRunning = true; static final class Result extends Exception { @@ -91,19 +92,23 @@ public class LocalRMIServerSocketFactoryTest { Thread t = new Thread() { public void run() { - while (true) { + while (isRunning) { Exception error = Result.SUCCESS; try { System.err.println("Accepting: "); final Socket ss = s.accept(); System.err.println(ss.getInetAddress() + " accepted"); } catch (Exception x) { - x.printStackTrace(); + if (isRunning) { + x.printStackTrace(); + } error = x; } finally { try { - // wait for the client to get the exception. - queue.put(error); + if (isRunning) { + // wait for the client to get the exception. + queue.put(error); + } } catch (Exception x) { // too bad! System.err.println("Could't send result to client!"); @@ -114,32 +119,38 @@ public class LocalRMIServerSocketFactoryTest { } } }; - t.setDaemon(true); - t.start(); - System.err.println("new Socket((String)null, port)"); - final Socket s1 = new Socket((String) null, port); - checkError("new Socket((String)null, port)"); - s1.close(); - System.err.println("new Socket((String)null, port): PASSED"); + try { + t.start(); - System.err.println("new Socket(InetAddress.getByName(null), port)"); - final Socket s2 = new Socket(InetAddress.getByName(null), port); - checkError("new Socket(InetAddress.getByName(null), port)"); - s2.close(); - System.err.println("new Socket(InetAddress.getByName(null), port): PASSED"); + System.err.println("new Socket((String)null, port)"); + final Socket s1 = new Socket((String) null, port); + checkError("new Socket((String)null, port)"); + s1.close(); + System.err.println("new Socket((String)null, port): PASSED"); - System.err.println("new Socket(localhost, port)"); - final Socket s3 = new Socket("localhost", port); - checkError("new Socket(localhost, port)"); - s3.close(); - System.err.println("new Socket(localhost, port): PASSED"); + System.err.println("new Socket(InetAddress.getByName(null), port)"); + final Socket s2 = new Socket(InetAddress.getByName(null), port); + checkError("new Socket(InetAddress.getByName(null), port)"); + s2.close(); + System.err.println("new Socket(InetAddress.getByName(null), port): PASSED"); - System.err.println("new Socket(127.0.0.1, port)"); - final Socket s4 = new Socket("127.0.0.1", port); - checkError("new Socket(127.0.0.1, port)"); - s4.close(); - System.err.println("new Socket(127.0.0.1, port): PASSED"); + System.err.println("new Socket(localhost, port)"); + final Socket s3 = new Socket("localhost", port); + checkError("new Socket(localhost, port)"); + s3.close(); + System.err.println("new Socket(localhost, port): PASSED"); + System.err.println("new Socket(127.0.0.1, port)"); + final Socket s4 = new Socket("127.0.0.1", port); + checkError("new Socket(127.0.0.1, port)"); + s4.close(); + System.err.println("new Socket(127.0.0.1, port): PASSED"); + } + finally { + isRunning = false; + s.close(); + t.join(); + } } } diff --git a/jdk/test/sun/management/jmxremote/bootstrap/CustomLauncherTest.java b/jdk/test/sun/management/jmxremote/bootstrap/CustomLauncherTest.java index d1f9633ebe6..ca448159cd1 100644 --- a/jdk/test/sun/management/jmxremote/bootstrap/CustomLauncherTest.java +++ b/jdk/test/sun/management/jmxremote/bootstrap/CustomLauncherTest.java @@ -22,11 +22,13 @@ */ import java.io.File; +import java.io.IOException; import java.nio.file.FileSystem; import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.LinkOption; import java.nio.file.Path; +import java.nio.file.StandardCopyOption; import java.nio.file.attribute.PosixFilePermission; import java.util.HashSet; import java.util.Set; @@ -47,6 +49,7 @@ import jdk.testlibrary.ProcessTools; public class CustomLauncherTest { private static final String TEST_CLASSPATH = System.getProperty("test.class.path"); private static final String TEST_JDK = System.getProperty("test.jdk"); + private static final String WORK_DIR = System.getProperty("user.dir"); private static final String TEST_SRC = System.getProperty("test.src"); private static final String OSNAME = System.getProperty("os.name"); @@ -88,36 +91,14 @@ public class CustomLauncherTest { return; } - String PLATFORM = ""; - switch (OSNAME.toLowerCase()) { - case "linux": { - PLATFORM = "linux"; - break; - } - case "sunos": { - PLATFORM = "solaris"; - break; - } - default: { - System.out.println("Test not designed to run on this operating " + - "system (" + OSNAME + "), skipping..."); - return; - } - } - - String LAUNCHER = TEST_SRC + File.separator + PLATFORM + "-" + ARCH + - File.separator + "launcher"; - - final FileSystem FS = FileSystems.getDefault(); - Path launcherPath = FS.getPath(LAUNCHER); - - final boolean hasLauncher = Files.isRegularFile(launcherPath, LinkOption.NOFOLLOW_LINKS)&& - Files.isReadable(launcherPath); - if (!hasLauncher) { - System.out.println("Launcher [" + LAUNCHER + "] does not exist. Skipping the test."); + if (getPlatform() == null) { + System.out.println("Test not designed to run on this operating " + + "system (" + OSNAME + "), skipping..."); return; } + final FileSystem FS = FileSystems.getDefault(); + Path libjvmPath = findLibjvm(FS); if (libjvmPath == null) { throw new Error("Unable to locate 'libjvm.so' in " + TEST_JDK); @@ -125,23 +106,20 @@ public class CustomLauncherTest { Process serverPrc = null, clientPrc = null; - final Set launcherOrigPerms = - Files.getPosixFilePermissions(launcherPath, LinkOption.NOFOLLOW_LINKS); try { - // It is impossible to store an executable file in the source control - // We need to set the executable flag here - if (!Files.isExecutable(launcherPath)) { - Set perms = new HashSet<>(launcherOrigPerms); - perms.add(PosixFilePermission.OWNER_EXECUTE); - Files.setPosixFilePermissions(launcherPath, perms); - } + String[] launcher = getLauncher(); System.out.println("Starting custom launcher:"); System.out.println("========================="); - System.out.println(" launcher : " + LAUNCHER); + System.out.println(" launcher : " + launcher[0]); System.out.println(" libjvm : " + libjvmPath.toString()); System.out.println(" classpath : " + TEST_CLASSPATH); - ProcessBuilder server = new ProcessBuilder(LAUNCHER, libjvmPath.toString(), TEST_CLASSPATH, "TestApplication"); + ProcessBuilder server = new ProcessBuilder( + launcher[1], + libjvmPath.toString(), + TEST_CLASSPATH, + "TestApplication" + ); final AtomicReference port = new AtomicReference<>(); final AtomicReference pid = new AtomicReference<>(); @@ -198,8 +176,6 @@ public class CustomLauncherTest { throw new Error("Test failed"); } } finally { - // Let's restore the original launcher permissions - Files.setPosixFilePermissions(launcherPath, launcherOrigPerms); if (clientPrc != null) { clientPrc.destroy(); clientPrc.waitFor(); @@ -240,4 +216,62 @@ public class CustomLauncherTest { private static boolean isFileOk(Path path) { return Files.isRegularFile(path) && Files.isReadable(path); } + + private static String getPlatform() { + String platform = null; + switch (OSNAME.toLowerCase()) { + case "linux": { + platform = "linux"; + break; + } + case "sunos": { + platform = "solaris"; + break; + } + default: { + platform = null; + } + } + + return platform; + } + + private static String[] getLauncher() throws IOException { + String platform = getPlatform(); + if (platform == null) { + return null; + } + + String launcher = TEST_SRC + File.separator + platform + "-" + ARCH + + File.separator + "launcher"; + + final FileSystem FS = FileSystems.getDefault(); + Path launcherPath = FS.getPath(launcher); + + final boolean hasLauncher = Files.isRegularFile(launcherPath, LinkOption.NOFOLLOW_LINKS)&& + Files.isReadable(launcherPath); + if (!hasLauncher) { + System.out.println("Launcher [" + launcher + "] does not exist. Skipping the test."); + return null; + } + + // It is impossible to store an executable file in the source control + // We need to copy the launcher to the working directory + // and set the executable flag + Path localLauncherPath = FS.getPath(WORK_DIR, "launcher"); + Files.copy(launcherPath, localLauncherPath, + StandardCopyOption.REPLACE_EXISTING, + StandardCopyOption.COPY_ATTRIBUTES); + if (!Files.isExecutable(localLauncherPath)) { + Set perms = new HashSet<>( + Files.getPosixFilePermissions( + localLauncherPath, + LinkOption.NOFOLLOW_LINKS + ) + ); + perms.add(PosixFilePermission.OWNER_EXECUTE); + Files.setPosixFilePermissions(localLauncherPath, perms); + } + return new String[] {launcher, localLauncherPath.toAbsolutePath().toString()}; + } } diff --git a/jdk/test/sun/management/jmxremote/bootstrap/GeneratePropertyPassword.sh b/jdk/test/sun/management/jmxremote/bootstrap/GeneratePropertyPassword.sh index 570631dc11e..55d7e7635f4 100644 --- a/jdk/test/sun/management/jmxremote/bootstrap/GeneratePropertyPassword.sh +++ b/jdk/test/sun/management/jmxremote/bootstrap/GeneratePropertyPassword.sh @@ -34,15 +34,16 @@ OS=`uname -s` UMASK=`umask` -if [[ $OS == CYGWIN_NT* ]] ; then +case $OS in +CYGWIN_NT*) OS="Windows_NT" if [ -z "$SystemRoot" ] ; then - SystemRoot=$SYSTEMROOT + SystemRoot=$SYSTEMROOT fi -fi +esac case $OS in -SunOS | Linux | Darwin) +SunOS | Linux | Darwin | AIX ) PATHSEP=":" FILESEP="/" DFILESEP=$FILESEP diff --git a/jdk/test/sun/management/jmxremote/startstop/JMXStartStopDoSomething.java b/jdk/test/sun/management/jmxremote/startstop/JMXStartStopDoSomething.java index 98b759ea79a..e6b1f43a752 100644 --- a/jdk/test/sun/management/jmxremote/startstop/JMXStartStopDoSomething.java +++ b/jdk/test/sun/management/jmxremote/startstop/JMXStartStopDoSomething.java @@ -21,37 +21,20 @@ * questions. */ -import java.io.File; +import java.io.IOException; +import jdk.testlibrary.ProcessTools; public class JMXStartStopDoSomething { - - private static final String lockFileName = "JMXStartStop.lck"; - - public static void doSomething() { - try { - File lockFile = new File(lockFileName); - lockFile.createNewFile(); - - while(lockFile.exists()) { - long datetime = lockFile.lastModified(); - long epoch = System.currentTimeMillis()/1000; - - // Don't allow test app to run more than an hour - if (epoch - datetime > 3600) { - System.err.println("Lock is too old. Aborting"); - return; - } - Thread.sleep(500); - } - - } catch (Throwable e) { - System.err.println("Something bad happens:" +e); - } + public static void doSomething() throws IOException{ + int r = System.in.read(); + System.out.println("read: " + r); } public static void main(String args[]) throws Exception { - System.err.println("main enter"); + System.out.println("pid:" + ProcessTools.getProcessId()); + System.out.println("main enter"); + System.out.flush(); doSomething(); - System.err.println("main exit"); + System.out.println("main exit"); } } diff --git a/jdk/test/sun/management/jmxremote/startstop/JMXStartStopTest.java b/jdk/test/sun/management/jmxremote/startstop/JMXStartStopTest.java index 4f97477b02b..65f4a3a33aa 100644 --- a/jdk/test/sun/management/jmxremote/startstop/JMXStartStopTest.java +++ b/jdk/test/sun/management/jmxremote/startstop/JMXStartStopTest.java @@ -22,45 +22,60 @@ */ import java.io.File; -import java.io.FileInputStream; -import java.io.FilenameFilter; import java.io.IOException; -import java.io.InputStream; +import java.lang.reflect.Method; +import java.net.ConnectException; +import java.rmi.NoSuchObjectException; import java.rmi.registry.LocateRegistry; import java.rmi.registry.Registry; import java.util.ArrayList; import java.util.Arrays; -import java.util.Enumeration; import java.util.HashMap; import java.util.Iterator; +import java.util.List; import java.util.Map; -import java.util.Properties; +import java.util.Objects; import java.util.Set; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Consumer; import javax.management.*; import javax.management.remote.*; +import javax.net.ssl.SSLHandshakeException; -import sun.management.AgentConfigurationError; -import sun.management.jmxremote.ConnectorBootstrap; +import jdk.testlibrary.ProcessTools; +import jdk.testlibrary.JDKToolLauncher; +/** + * @test + * @bug 7110104 + * @library /lib/testlibrary + * @build jdk.testlibrary.ProcessTools + * @build jdk.testlibrary.JDKToolLauncher + * @build jdk.testlibrary.Utils + * @build JMXStartStopTest JMXStartStopDoSomething + * @run main/othervm JMXStartStopTest + * @summary Makes sure that enabling/disabling the management agent through + * JCMD achieves the desired results + */ public class JMXStartStopTest { + private static final String TEST_JDK = System.getProperty("test.jdk"); + private static final String TEST_SRC = System.getProperty("test.src"); - static boolean verbose = false; + private static final boolean verbose = false; - static void dbg_print(String msg){ + private static void dbg_print(String msg){ if (verbose) { - System.err.println("DBG: " +msg); + System.out.println("DBG: " +msg); } } - static void dbg_print(String msg, Throwable ex){ - if (verbose) { - System.err.println("DBG: " + msg + " " + ex.getMessage() ); - ex.printStackTrace(System.err); - } - } - - public static int listMBeans(MBeanServerConnection server, ObjectName pattern, QueryExp query) + private static int listMBeans(MBeanServerConnection server, + ObjectName pattern, + QueryExp query) throws Exception { Set names = server.queryNames(pattern,query); @@ -72,10 +87,9 @@ public class JMXStartStopTest { MBeanAttributeInfo[] attrs = info.getAttributes(); if (attrs == null) continue; - - for (int j=0; j 0) { - port = Integer.parseInt(args[0]); - } dbg_print("Using port: " + port); - int rmiPort = 0; - if (args != null && args.length > 1) { - rmiPort = Integer.parseInt(args[1]); - } dbg_print("Using rmi port: " + rmiPort); Registry registry = LocateRegistry.getRegistry(port); @@ -140,8 +173,13 @@ public class JMXStartStopTest { } String jmxUrlStr = (rmiPort != 0) ? - String.format("service:jmx:rmi://localhost:%d/jndi/rmi://localhost:%d/jmxrmi", rmiPort, port) : - String.format("service:jmx:rmi:///jndi/rmi://localhost:%d/jmxrmi",port); + String.format( + "service:jmx:rmi://localhost:%d/jndi/rmi://localhost:%d/jmxrmi", + rmiPort, + port) : + String.format( + "service:jmx:rmi:///jndi/rmi://localhost:%d/jmxrmi", + port); JMXServiceURL url = new JMXServiceURL(jmxUrlStr); Map m = new HashMap(); @@ -153,29 +191,632 @@ public class JMXStartStopTest { int count = listMBeans(conn,pattern,null); if (count == 0) - throw new Exception("Expected at least one matching "+ "MBean for "+pattern); + throw new Exception("Expected at least one matching " + + "MBean for " + pattern); } + private static class Failure { + private final Throwable cause; + private final String msg; - public static void main(String args[]) { - JMXStartStopTest manager = new JMXStartStopTest(); - try { - if (args!=null && args[0].equals("local")) { - manager.run_local(args[1]); - } else { - manager.run(args); - } - } catch (RuntimeException r) { - dbg_print("No connection: ", r); - System.out.print("NO_CONN"); - System.exit(1); - } catch (Throwable t) { - dbg_print("No connection: ", t); - System.out.print("NO_CONN"); - System.exit(2); + public Failure(Throwable cause, String msg) { + this.cause = cause; + this.msg = msg; + } + + public Failure(String msg) { + this(null, msg); + } + + public Throwable getCause() { + return cause; + } + + public String getMsg() { + return msg; + } + + @Override + public int hashCode() { + int hash = 7; + hash = 97 * hash + Objects.hashCode(this.cause); + hash = 97 * hash + Objects.hashCode(this.msg); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final Failure other = (Failure) obj; + if (!Objects.equals(this.cause, other.cause)) { + return false; + } + if (!Objects.equals(this.msg, other.msg)) { + return false; + } + return true; + } + + @Override + public String toString() { + if (cause != null) { + return msg + "\n" + cause; + } else { + return msg; + } } - System.out.print("OK_CONN"); - System.exit(0); } + private static List failures = new ArrayList<>(); + + public static void main(String args[]) throws Exception { + for (int i=0;i<3;i++) { + System.out.println("=== PASS " + i + " ==="); + for (Method m : JMXStartStopTest.class.getDeclaredMethods()) { + if (m.getName().startsWith("test_")) { + try { + m.invoke(null); + System.out.println("=== PASSED\n"); + } catch (Throwable e) { + failures.add(new Failure(e, m.getName() + " failed")); + } + } + } + + if (!failures.isEmpty()) { + for(Failure f : failures) { + System.err.println(f.getMsg()); + f.getCause().printStackTrace(System.err); + } + throw new Error(); + } + } + } + + /** + * Retrieves the PID of the test application using JCMD + * @return The PID of the test application + * @throws InterruptedException + * @throws IOException + */ + private static String getPID() throws InterruptedException, IOException { + final AtomicReference pid = new AtomicReference<>(); + jcmd( + null, + line -> { + if (line.endsWith("JMXStartStopDoSomething")) { + pid.set(line.split(" ")[0]); + } + } + ); + return pid.get(); + } + + private static class Something { + private Process p; + private final ProcessBuilder pb; + private final String name; + private final AtomicBoolean started = new AtomicBoolean(false); + private volatile int pid = -1; + + public Something(ProcessBuilder pb, String name) { + this.pb = pb; + this.name = name; + } + + public synchronized void start() throws InterruptedException, IOException, TimeoutException { + if (started.compareAndSet(false, true)) { + try { + p = ProcessTools.startProcess( + "JMXStartStopDoSomething", + pb, + (line) -> { + if (line.toLowerCase().startsWith("pid:")) { + pid = Integer.parseInt(line.split("\\:")[1]); + } + return line.equals("main enter"); + }, + 5, + TimeUnit.SECONDS + ); + } catch (TimeoutException e) { + p.destroy(); + p.waitFor(); + throw e; + } + } + } + + public int getPid() { + return pid; + } + + public synchronized void stop() + throws IOException, InterruptedException { + if (started.compareAndSet(true, false)) { + p.getOutputStream().write(0); + p.getOutputStream().flush(); + int ec = p.waitFor(); + if (ec != 0) { + StringBuilder msg = new StringBuilder(); + msg.append("Test application '").append(name); + msg.append("' failed with exit code: "); + msg.append(ec); + + failures.add(new Failure(msg.toString())); + } + } + } + } + + /** + * Runs the test application "JMXStartStopDoSomething" + * @param name Test run name + * @param args Additional arguments + * @return Returns a {@linkplain Something} instance representing the run + * @throws IOException + * @throws InterruptedException + * @throws TimeoutException + */ + private static Something doSomething(String name, String ... args) + throws Exception { + List pbArgs = new ArrayList<>(Arrays.asList( + "-cp", + System.getProperty("test.class.path") + )); + pbArgs.addAll(Arrays.asList(args)); + pbArgs.add("JMXStartStopDoSomething"); + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + pbArgs.toArray(new String[pbArgs.size()]) + ); + Something s = new Something(pb, name); + s.start(); + return s; + } + + /** + * Run the "jcmd" command + * + * @param command Command with parameters; space separated string + * @throws IOException + * @throws InterruptedException + */ + private static void jcmd(String ... command) throws IOException, InterruptedException { + if (command.length == 0) { + jcmd(null, (Consumer)null); + } else { + jcmd(null, command); + } + } + + /** + * Run the "jcmd" command + * + * @param c {@linkplain Consumer} instance; may be null + * @param command Command with parameters; space separated string + * @throws IOException + * @throws InterruptedException + */ + private static void jcmd(Consumer c, String ... command) throws IOException, InterruptedException { + jcmd("JMXStartStopDoSomething", c, command); + } + + /** + * Run the "jcmd" command + * @param target The target application name (or PID) + * @param c {@linkplain Consumer} instance; may be null + * @param command Command with parameters; space separated string + * @throws IOException + * @throws InterruptedException + */ + private static void jcmd(String target, final Consumer c, String ... command) throws IOException, InterruptedException { + dbg_print("[jcmd] " + (command.length > 0 ? command[0] : "list")); + + JDKToolLauncher l = JDKToolLauncher.createUsingTestJDK("jcmd"); + l.addToolArg(target); + for(String cmd : command) { + l.addToolArg(cmd); + } + Process p = ProcessTools.startProcess( + "jcmd", + new ProcessBuilder(l.getCommand()), + c + ); + + p.waitFor(); + dbg_print("[jcmd] --------"); + } + + private static final String CMD_STOP = "ManagementAgent.stop"; + private static final String CMD_START= "ManagementAgent.start"; + private static final String CMD_START_LOCAL = "ManagementAgent.start_local"; + private static final int port1 = 50234; + private static final int port2 = 50235; + + private static void test_01() throws Exception { + // Run an app with JMX enabled stop it and + // restart on other port + + System.out.println("**** Test one ****"); + + Something s = doSomething( + "test_01", + "-Dcom.sun.management.jmxremote.port=" + port1, + "-Dcom.sun.management.jmxremote.authenticate=false", + "-Dcom.sun.management.jmxremote.ssl=false"); + + try { + testConnect(port1); + + jcmd(CMD_STOP); + testNoConnect(port1); + + jcmd(CMD_START, "jmxremote.port=" + port2); + testConnect(port2); + } finally { + s.stop(); + } + } + + private static void test_02() throws Exception { + // Run an app without JMX enabled + // start JMX by jcmd + + System.out.println("**** Test two ****"); + + Something s = doSomething("test_02"); + try { + jcmd(CMD_START, + "jmxremote.port=" + port1, + "jmxremote.authenticate=false", + "jmxremote.ssl=false"); + + testConnect(port1); + } finally { + s.stop(); + } + } + + private static void test_03() throws Exception { + // Run an app without JMX enabled + // start JMX by jcmd on one port than on other one + + System.out.println("**** Test three ****"); + + Something s = doSomething("test_03"); + try { + jcmd(CMD_START, + "jmxremote.port=" + port1, + "jmxremote.authenticate=false", + "jmxremote.ssl=false"); + + // Second agent shouldn't start + jcmd(CMD_START, + "jmxremote.port=" + port2, + "jmxremote.authenticate=false", + "jmxremote.ssl=false"); + + // First agent should connect + testConnect(port1); + + // Second agent should not connect + testNoConnect(port2); + } finally { + s.stop(); + } + } + + private static void test_04() throws Exception { + // Run an app without JMX enabled + // start JMX by jcmd on one port, specify rmi port explicitly + + System.out.println("**** Test four ****"); + + Something s = doSomething("test_04"); + + try { + jcmd(CMD_START, + "jmxremote.port=" + port1, + "jmxremote.rmi.port=" + port2, + "jmxremote.authenticate=false", + "jmxremote.ssl=false"); + + testConnect(port1, port2); + } finally { + s.stop(); + } + } + + private static void test_05() throws Exception { + // Run an app without JMX enabled, it will enable local server + // but should leave remote server disabled + + System.out.println("**** Test five ****"); + + Something s = doSomething("test_05"); + try { + jcmd(CMD_START_LOCAL); + + testNoConnect(port1); + testConnectLocal(s.getPid()); + } finally { + s.stop(); + } + } + + private static void test_06() throws Exception { + // Run an app without JMX enabled + // start JMX by jcmd on one port, specify rmi port explicitly + // attempt to start it again + // 1) with the same port + // 2) with other port + // 3) attempt to stop it twice + // Check for valid messages in the output + + System.out.println("**** Test six ****"); + + Something s = doSomething("test_06"); + + try { + jcmd(CMD_START, + "jmxremote.port=" + port1, + "jmxremote.authenticate=false", + "jmxremote.ssl=false"); + + testConnect(port1, port2); + + final boolean[] checks = new boolean[3]; + jcmd( + line -> { + if (line.equals("java.lang.RuntimeException: Invalid agent state")) { + checks[0] = true; + } + }, + CMD_START, + "jmxremote.port=" + port1, + "jmxremote.authenticate=false", + "jmxremote.ssl=false"); + + jcmd( + line -> { + if (line.equals("java.lang.RuntimeException: Invalid agent state")) { + checks[1] = true; + } + }, + CMD_START, + "jmxremote.port=" + port2, + "jmxremote.authenticate=false", + "jmxremote.ssl=false"); + + jcmd(CMD_STOP); + jcmd(CMD_STOP); + + jcmd( + line -> { + if (line.contains("Port already in use: 22")) { + checks[2] = true; + } + }, + CMD_START, + "jmxremote.port=22", + "jmxremote.rmi.port=" + port2, + "jmxremote.authenticate=false", + "jmxremote.ssl=false"); + if (!checks[0]) { + throw new Exception("Starting agent on port " + port1 + " should " + + "report an invalid agent state"); + } + if (!checks[1]) { + throw new Exception("Starting agent on poprt " + port2 + " should " + + "report an invalid agent state"); + } + if (!checks[2]) { + throw new Exception("Starting agent on port 22 should " + + "report port in use"); + } + } finally { + s.stop(); + } + } + + private static void test_07() throws Exception { + // Run an app without JMX enabled, but with some properties set + // in command line. + // make sure these properties overriden corectly + + System.out.println("**** Test seven ****"); + + Something s = doSomething( + "test_07", + "-Dcom.sun.management.jmxremote.authenticate=false", + "-Dcom.sun.management.jmxremote.ssl=true"); + + try { + testNoConnect(port1); + jcmd( + CMD_START, + "jmxremote.port=" + port2, + "jmxremote.authenticate=false", + "jmxremote.ssl=false" + ); + testConnect(port2); + } finally { + s.stop(); + } + } + + private static void test_08() throws Exception { + // Run an app with JMX enabled and with some properties set + // in command line. + // stop JMX agent and then start it again with different property values + // make sure these properties overriden corectly + + System.out.println("**** Test eight ****"); + + Something s = doSomething( + "test_08", + "-Dcom.sun.management.jmxremote.port=" + port1, + "-Dcom.sun.management.jmxremote.authenticate=false", + "-Dcom.sun.management.jmxremote.ssl=true"); + + try { + testNoConnect(port1); + + jcmd(CMD_STOP); + + testNoConnect(port1); + + jcmd( + CMD_START, + "jmxremote.port=" + port2, + "jmxremote.authenticate=false", + "jmxremote.ssl=false" + ); + + testConnect(port2); + } finally { + s.stop(); + } + } + + private static void test_09() throws Exception { + // Run an app with JMX enabled and with some properties set + // in command line. + // stop JMX agent and then start it again with different property values + // specifing some property in management config file and some of them + // in command line + // make sure these properties overriden corectly + + System.out.println("**** Test nine ****"); + + Something s = doSomething("test_09", + "-Dcom.sun.management.config.file=" + + TEST_SRC + File.separator + "management_cl.properties", + "-Dcom.sun.management.jmxremote.authenticate=false" + ); + + try { + testNoConnect(port1); + + jcmd(CMD_STOP); + + testNoConnect(port1); + + jcmd(CMD_START, + "config.file=" + TEST_SRC + File.separator + + "management_jcmd.properties", + "jmxremote.authenticate=false", + "jmxremote.port=" + port2 + ); + + testConnect(port2); + } finally { + s.stop(); + } + } + + private static void test_10() throws Exception { + // Run an app with JMX enabled and with some properties set + // in command line. + // stop JMX agent and then start it again with different property values + // stop JMX agent again and then start it without property value + // make sure these properties overriden corectly + + System.out.println("**** Test ten ****"); + + Something s = doSomething( + "test_10", + "-Dcom.sun.management.jmxremote.port=" + port1, + "-Dcom.sun.management.jmxremote.authenticate=false", + "-Dcom.sun.management.jmxremote.ssl=true"); + + try { + testNoConnect(port1); + + jcmd(CMD_STOP); + jcmd(CMD_START, + "jmxremote.ssl=false", + "jmxremote.port=" + port1 + ); + testConnect(port1); + + jcmd(CMD_STOP); + jcmd(CMD_START, + "jmxremote.port=" + port1 + ); + + testNoConnect(port1); + } finally { + s.stop(); + } + } + + private static void test_11() throws Exception { + // Run an app with JMX enabled + // stop remote agent + // make sure local agent is not affected + + System.out.println("**** Test eleven ****"); + + Something s = doSomething( + "test_11", + "-Dcom.sun.management.jmxremote.port=" + port1, + "-Dcom.sun.management.jmxremote.authenticate=false", + "-Dcom.sun.management.jmxremote.ssl=false"); + try { + testConnect(port1); + jcmd(CMD_STOP); + testConnectLocal(s.getPid()); + } finally { + s.stop(); + } + } + + private static void test_12() throws Exception { + // Run an app with JMX disabled + // start local agent only + + System.out.println("**** Test twelve ****"); + + Something s = doSomething("test_12"); + + try { + testNoConnect(port1); + jcmd(CMD_START + "_local"); + + testConnectLocal(s.getPid()); + + } finally { + s.stop(); + } + } + + private static void test_13() throws Exception { + // Run an app with -javaagent make sure it works as expected - + // system properties are ignored + + System.out.println("**** Test fourteen ****"); + + String agent = TEST_JDK + "/jre/lib/management-agent.jar"; + if (!new File(agent).exists()) { + agent = TEST_JDK + "/lib/management-agent.jar"; + } + + Something s = doSomething("test_14", + "-javaagent:" + agent + "=com.sun.management.jmxremote.port=" + + port1 + ",com.sun.management.jmxremote.authenticate=false", + "-Dcom.sun.management.jmxremote.ssl=false" + ); + + try { + testNoConnect(port1); + } finally { + s.stop(); + } + } } diff --git a/jdk/test/sun/management/jmxremote/startstop/JMXStartStopTest.sh b/jdk/test/sun/management/jmxremote/startstop/JMXStartStopTest.sh deleted file mode 100644 index 4d672166211..00000000000 --- a/jdk/test/sun/management/jmxremote/startstop/JMXStartStopTest.sh +++ /dev/null @@ -1,579 +0,0 @@ -#!/bin/sh - -# 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. - -# @test -# @bug 7110104 -# @build JMXStartStopTest JMXStartStopDoSomething -# @run shell JMXStartStopTest.sh --jtreg --no-compile -# @summary No word Failed expected in the test output - -_server=no -_jtreg=no -_compile=yes -_testsuite="01,02,03,04,05,06,07,08,09,10,11,12,13" -_port_one=50234 -_port_two=50235 - - -_testclasses=".classes" -_testsrc=`pwd` - -_logname=".classes/output.txt" -_lockFileName="JMXStartStop.lck" - -_compile(){ - - if [ ! -d ${_testclasses} ] - then - mkdir -p ${_testclasses} - fi - - rm -f ${_testclasses}/JMXStartStopTest.class - - # Compile testcase - ${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d ${_testclasses} \ - JMXStartStopDoSomething.java JMXStartStopTest.java - - if [ ! -f ${_testclasses}/JMXStartStopTest.class ] - then - echo "ERROR: Can't compile" - exit -1 - fi -} - -_app_start(){ - ${TESTJAVA}/bin/java ${TESTVMOPTS} $* -cp ${_testclasses} JMXStartStopDoSomething >> ${_logname} 2>&1 & - - x=0 - while [ ! -f ${_lockFileName} ] - do - if [ $x -gt 20 ] - then - echo "ERROR: Test app not started" - if [ "${_jtreg}" = "yes" ] - then - exit -1 - fi - fi - - echo "Waiting JMXStartStopDoSomething to start: $x" - x=`expr $x + 1` - sleep 1 - done -} - -_get_pid(){ - ${COMPILEJAVA}/bin/jps ${TESTTOOLVMOPTS} | sed -n "/JMXStartStopDoSomething/s/ .*//p" -} - -_app_stop(){ - rm ${_lockFileName} - - # wait until VM is actually shuts down - while true - do - npid=`_get_pid` - if [ "${npid}" = "" ] - then - break - fi - sleep 1 - done -} - -_exit_on_jtreg(){ - # Stop on first failed test under jtreg - if [ "${_jtreg}" = "yes" ] - then - _app_stop - exit -1 - fi -} - -_testme(){ - ${TESTJAVA}/bin/java ${TESTVMOPTS} -cp ${_testclasses} JMXStartStopTest $* -} - - -_jcmd(){ - ${TESTJAVA}/bin/jcmd ${TESTTOOLVMOPTS} JMXStartStopDoSomething $* > /dev/null 2>/dev/null -} - -_echo(){ - echo "$*" - echo "$*" >> ${_logname} -} - -# ============= TESTS ====================================== - -test_01(){ -# Run an app with JMX enabled stop it and -# restart on other port - - _echo "**** Test one ****" - - _app_start -Dcom.sun.management.jmxremote.port=$1 \ - -Dcom.sun.management.jmxremote.authenticate=false \ - -Dcom.sun.management.jmxremote.ssl=false - - res1=`_testme $1` - - _jcmd ManagementAgent.stop - - res2=`_testme $1` - - _jcmd ManagementAgent.start jmxremote.port=$2 - - res3=`_testme $2` - - if [ "${res1}" = "OK_CONN" -a "${res2}" = "NO_CONN" -a "${res3}" = "OK_CONN" ] - then - _echo "Passed" - else - _echo "Failed r1(OK):${res1} r2(NO):${res2} r3(OK):${res3}" - _exit_on_jtreg - fi - - _app_stop -} - -test_02(){ -# Run an app without JMX enabled -# start JMX by jcmd - - _echo "**** Test two ****" - _app_start - - _jcmd ManagementAgent.start jmxremote.port=$1 jmxremote.authenticate=false jmxremote.ssl=false - - res1=`_testme $1` - - if [ "${res1}" = "OK_CONN" ] - then - _echo "Passed" - else - _echo "Failed r1(OK):${res1}" - _exit_on_jtreg - fi - _app_stop -} - -test_03(){ -# Run an app without JMX enabled -# start JMX by jcmd on one port than on other one - - _echo "**** Test three ****" - _app_start - - _jcmd ManagementAgent.start jmxremote.port=$1 jmxremote.authenticate=false jmxremote.ssl=false - -# Second agent shouldn't start - _jcmd ManagementAgent.start jmxremote.port=$2 jmxremote.authenticate=false jmxremote.ssl=false - -# First agent should connect - res1=`_testme $1` - - if [ "${res1}" = "OK_CONN" ] - then - _echo "Passed $1" - else - _echo "Failed r1(NO):${res1}" - _exit_on_jtreg - fi - -#Second agent shouldn't connect - res1=`_testme $2` - - if [ "${res1}" = "NO_CONN" ] - then - _echo "Passed $2" - else - _echo "Failed r1(OK):${res1}" - _exit_on_jtreg - fi - - _app_stop -} - -test_04(){ -# Run an app without JMX enabled -# start JMX by jcmd on one port, specify rmi port explicitly - - _echo "**** Test four ****" - _app_start - - _jcmd ManagementAgent.start jmxremote.port=$1 jmxremote.rmi.port=$2 jmxremote.authenticate=false jmxremote.ssl=false - -# First agent should connect - res1=`_testme $1 $2` - - if [ "${res1}" = "OK_CONN" ] - then - _echo "Passed $1 $2" - else - _echo "Failed r1(NO):${res1}" - _exit_on_jtreg - fi - - _app_stop -} - -test_05(){ -# Run an app without JMX enabled, it will enable local server -# but should leave remote server disabled - - _echo "**** Test five ****" - _app_start - - _jcmd ManagementAgent.start jmxremote=1 - - # First agent should connect - res1=`_testme $1` - - if [ "${res1}" = "NO_CONN" ] - then - _echo "Passed $1 $2" - else - _echo "Failed r1(OK):${res1}" - _exit_on_jtreg - fi - - _app_stop -} - -test_06(){ -# Run an app without JMX enabled -# start JMX by jcmd on one port, specify rmi port explicitly -# attempt to start it again -# 1) with the same port -# 2) with other port -# 3) attempt to stop it twice -# Check for valid messages in the output - - _echo "**** Test six ****" - _app_start - - _jcmd ManagementAgent.start jmxremote.port=$1 jmxremote.authenticate=false jmxremote.ssl=false - - # First agent should connect - res1=`_testme $1 $2` - - if [ "${res1}" = "OK_CONN" ] - then - _echo "Passed $1 $2" - else - _echo "Failed r1(NO):${res1}" - _exit_on_jtreg - fi - - _jcmd ManagementAgent.start jmxremote.port=$1 jmxremote.authenticate=false jmxremote.ssl=false - - _jcmd ManagementAgent.start jmxremote.port=$2 jmxremote.authenticate=false jmxremote.ssl=false - - _jcmd ManagementAgent.stop - - _jcmd ManagementAgent.stop - - _jcmd ManagementAgent.start jmxremote.port=22 jmxremote.rmi.port=$2 jmxremote.authenticate=false jmxremote.ssl=false - - _app_stop -} - -test_07(){ -# Run an app without JMX enabled, but with some properties set -# in command line. -# make sure these properties overriden corectly - - _echo "**** Test seven ****" - - _app_start -Dcom.sun.management.jmxremote.authenticate=false \ - -Dcom.sun.management.jmxremote.ssl=true - - res1=`_testme $1` - - _jcmd ManagementAgent.start jmxremote.port=$2 jmxremote.authenticate=false jmxremote.ssl=false - - res2=`_testme $2` - - if [ "${res1}" = "NO_CONN" -a "${res2}" = "OK_CONN" ] - then - echo "Passed" - else - _echo "Failed r1(NO):${res1} r2(OK):${res2}" - _exit_on_jtreg - fi - - _app_stop -} - -test_08(){ -# Run an app with JMX enabled and with some properties set -# in command line. -# stop JMX agent and then start it again with different property values -# make sure these properties overriden corectly - - _echo "**** Test eight ****" - - _app_start -Dcom.sun.management.jmxremote.port=$1 \ - -Dcom.sun.management.jmxremote.authenticate=false \ - -Dcom.sun.management.jmxremote.ssl=true - - res1=`_testme $1` - - _jcmd ManagementAgent.stop - - res2=`_testme $1` - - _jcmd ManagementAgent.start jmxremote.port=$2 jmxremote.authenticate=false jmxremote.ssl=false - - res3=`_testme $2` - - if [ "${res1}" = "NO_CONN" -a "${res2}" = "NO_CONN" -a "${res3}" = "OK_CONN" ] - then - _echo "Passed" - else - _echo "Failed r1(NO):${res1} r2(NO):${res2} r3(OK):${res3}" - _exit_on_jtreg - fi - - _app_stop -} - -test_09(){ -# Run an app with JMX enabled and with some properties set -# in command line. -# stop JMX agent and then start it again with different property values -# specifing some property in management config file and some of them -# in command line -# make sure these properties overriden corectly - - _echo "**** Test nine ****" - - _app_start -Dcom.sun.management.config.file=${_testsrc}/management_cl.properties \ - -Dcom.sun.management.jmxremote.authenticate=false - - res1=`_testme $1` - - _jcmd ManagementAgent.stop - - res2=`_testme $1` - - _jcmd ManagementAgent.start config.file=${_testsrc}/management_jcmd.properties \ - jmxremote.authenticate=false jmxremote.port=$2 - - res3=`_testme $2` - - if [ "${res1}" = "NO_CONN" -a "${res2}" = "NO_CONN" -a "${res3}" = "OK_CONN" ] - then - _echo "Passed" - else - _echo "Failed r1(NO):${res1} r2(NO):${res2} r3(OK):${res3}" - _exit_on_jtreg - fi - - _app_stop -} - -test_10(){ -# Run an app with JMX enabled and with some properties set -# in command line. -# stop JMX agent and then start it again with different property values -# stop JMX agent again and then start it without property value -# make sure these properties overriden corectly - - _echo "**** Test ten ****" - - _app_start -Dcom.sun.management.jmxremote.port=$1 \ - -Dcom.sun.management.jmxremote.authenticate=false \ - -Dcom.sun.management.jmxremote.ssl=true - - res1=`_testme $1` - - _jcmd ManagementAgent.stop - _jcmd ManagementAgent.start jmxremote.ssl=false jmxremote.port=$1 - - - res2=`_testme $1` - - _jcmd ManagementAgent.stop - _jcmd ManagementAgent.start jmxremote.port=$1 - - res3=`_testme $1` - - if [ "${res1}" = "NO_CONN" -a "${res2}" = "OK_CONN" -a "${res3}" = "NO_CONN" ] - then - _echo "Passed" - else - _echo "Failed r1(NO):${res1} r2(OK):${res2} r3(NO):${res3}" - _exit_on_jtreg - fi - - _app_stop -} - -test_11(){ -# Run an app with JMX enabled -# stop remote agent -# make sure local agent is not affected - - _echo "**** Test eleven ****" - - _app_start -Dcom.sun.management.jmxremote.port=$2 \ - -Dcom.sun.management.jmxremote.authenticate=false \ - -Dcom.sun.management.jmxremote.ssl=false - - res1=`_testme $2` - - _jcmd ManagementAgent.stop - - pid=`${COMPILEJAVA}/bin/jps ${TESTTOOLVMOPTS} | sed -n "/JMXStartStopDoSomething/s/ .*//p"` - res2=`_testme local ${pid}` - - if [ "${res1}" = "OK_CONN" -a "${res2}" = "OK_CONN" ] - then - _echo "Passed" - else - _echo "Failed r1(OK):${res1} r2(OK):${res2}" - _exit_on_jtreg - fi - - _app_stop -} - -test_12(){ -# Run an app with JMX disabled -# start local agent only - - _echo "**** Test twelve ****" - - _app_start - - res1=`_testme $1` - - _jcmd ManagementAgent.start_local - - pid=`_get_pid` - if [ "x${pid}" = "x" ] - then - res2="NO_CONN" - else - res2=`_testme local ${pid}` - fi - - if [ "${res1}" = "NO_CONN" -a "${res2}" = "OK_CONN" ] - then - _echo "Passed" - else - _echo "Failed r1(NO):${res1} r2(OK):${res2}" - _exit_on_jtreg - fi - - _app_stop -} - -test_13(){ -# Run an app with -javaagent make sure it works as expected - system properties are ignored - - _echo "**** Test thirteen ****" - - AGENT="${TESTJAVA}/jre/lib/management-agent.jar" - if [ ! -f ${AGENT} ] - then - AGENT="${TESTJAVA}/lib/management-agent.jar" - fi - - _app_start -javaagent:${AGENT}=com.sun.management.jmxremote.port=$1,com.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false - - res1=`_testme $1` - - if [ "${res1}" = "NO_CONN" ] - then - _echo "Passed" - else - _echo "Failed r1(NO):${res1}" - _exit_on_jtreg - fi - - _app_stop -} - -# ============= MAIN ======================================= - -if [ "x${TESTJAVA}" = "x" ] -then - echo "TESTJAVA env have to be set" - exit -fi - -if [ ! -x "${TESTJAVA}/bin/jcmd" ] -then - echo "${TESTJAVA}/bin/jcmd" - echo "Doesn't exist or not an executable" - exit -fi - - -#------------------------------------------------------------------------------ -# reading parameters - -for parm in "$@" -do - case $parm in - --jtreg) _jtreg=yes ;; - --no-compile) _compile=no ;; - --testsuite=*) _testsuite=`_echo $parm | sed "s,^--.*=\(.*\),\1,"` ;; - --port-one=*) _port_one=`_echo $parm | sed "s,^--.*=\(.*\),\1,"` ;; - --port-two=*) _port_two=`_echo $parm | sed "s,^--.*=\(.*\),\1,"` ;; - *) - echo "Undefined parameter $parm. Try --help for help" - exit - ;; - esac -done - -if [ "${COMPILEJAVA}" = "" ] -then - COMPILEJAVA=${TESTJAVA} -fi - -if [ ${_compile} = "yes" ] -then - _compile -fi - -if [ ${_jtreg} = "yes" ] -then - _testclasses=${TESTCLASSES} - _testsrc=${TESTSRC} - _logname="JMXStartStopTest_output.txt" -fi - -rm -f ${_logname} - -# Local mode tests -for i in `echo ${_testsuite} | sed -e "s/,/ /g"` -do - test_${i} ${_port_one} ${_port_two} -done - - diff --git a/jdk/test/sun/misc/Version/Version.java b/jdk/test/sun/misc/Version/Version.java index 13e507540c1..85c8ce2a071 100644 --- a/jdk/test/sun/misc/Version/Version.java +++ b/jdk/test/sun/misc/Version/Version.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -116,10 +116,16 @@ public class Version { } else if (Character.isDigit(cs.charAt(0)) && Character.isDigit(cs.charAt(1)) && cs.charAt(2) == '.' && Character.isDigit(cs.charAt(3))) { - // HSX has nn.n (major.minor) version + // HSX has nn.n[n] (major.minor) version major = Integer.valueOf(version.substring(0, 2)).intValue(); - minor = Character.digit(cs.charAt(3), 10); - cs = cs.subSequence(4, cs.length()); + if (Character.isDigit(cs.charAt(4))) { + minor = Integer.valueOf(version.substring(3, 5)).intValue(); + cs = cs.subSequence(5, cs.length()); + } + else { + minor = Character.digit(cs.charAt(3), 10); + cs = cs.subSequence(4, cs.length()); + } } if (cs.charAt(0) == '_' && cs.length() >= 3 && Character.isDigit(cs.charAt(1)) && diff --git a/jdk/test/sun/net/ftp/MarkResetTest.sh b/jdk/test/sun/net/ftp/MarkResetTest.sh index c998bcffef2..3878b505d90 100644 --- a/jdk/test/sun/net/ftp/MarkResetTest.sh +++ b/jdk/test/sun/net/ftp/MarkResetTest.sh @@ -28,7 +28,7 @@ OS=`uname -s` case "$OS" in - SunOS | Linux | Darwin ) + SunOS | Linux | Darwin | AIX ) PS=":" FS="/" ;; diff --git a/jdk/test/sun/net/www/http/HttpClient/RetryPost.sh b/jdk/test/sun/net/www/http/HttpClient/RetryPost.sh index 17d08cd30b0..c500171220c 100644 --- a/jdk/test/sun/net/www/http/HttpClient/RetryPost.sh +++ b/jdk/test/sun/net/www/http/HttpClient/RetryPost.sh @@ -28,7 +28,7 @@ OS=`uname -s` case "$OS" in - SunOS | Linux | Darwin ) + SunOS | Linux | Darwin | AIX ) PS=":" FS="/" ;; diff --git a/jdk/test/sun/net/www/protocol/jar/B5105410.sh b/jdk/test/sun/net/www/protocol/jar/B5105410.sh index f47ca5ed99d..aa31a53ebc2 100644 --- a/jdk/test/sun/net/www/protocol/jar/B5105410.sh +++ b/jdk/test/sun/net/www/protocol/jar/B5105410.sh @@ -31,7 +31,7 @@ OS=`uname -s` case "$OS" in - SunOS | Linux | Darwin ) + SunOS | Linux | Darwin | AIX ) PS=":" FS="/" ;; diff --git a/jdk/test/sun/net/www/protocol/jar/jarbug/run.sh b/jdk/test/sun/net/www/protocol/jar/jarbug/run.sh index 5f039b97c93..69632014bac 100644 --- a/jdk/test/sun/net/www/protocol/jar/jarbug/run.sh +++ b/jdk/test/sun/net/www/protocol/jar/jarbug/run.sh @@ -31,7 +31,7 @@ DEST=`pwd` OS=`uname -s` case "$OS" in - SunOS | Linux | Darwin ) + SunOS | Linux | Darwin | AIX ) PS=":" FS="/" ;; diff --git a/jdk/test/sun/nio/cs/MalformedSurrogates.java b/jdk/test/sun/nio/cs/MalformedSurrogates.java index 36481dafbf7..462e1651d09 100644 --- a/jdk/test/sun/nio/cs/MalformedSurrogates.java +++ b/jdk/test/sun/nio/cs/MalformedSurrogates.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 @@ -22,64 +22,132 @@ */ /* @test - @bug 4153987 - @summary Malformed surrogates should be handled by the converter in - substitution mode. + * @bug 4153987 + * @summary Malformed surrogates should be handled by the converter in + * substitution mode. */ - import java.io.*; +import java.nio.charset.Charset; +import java.nio.charset.CharsetDecoder; +import java.nio.charset.CharsetEncoder; +import java.nio.CharBuffer; +import java.nio.ByteBuffer; +import java.nio.charset.CodingErrorAction; +import java.nio.charset.MalformedInputException; +import java.nio.charset.UnmappableCharacterException; +import java.util.SortedMap; public class MalformedSurrogates { - public static void main(String[] args) throws Exception { + private static final String PREFIX = "abc"; + private static final String SUFFIX = "efgh"; + private static final String MALFORMED_SURROGATE = PREFIX + "\uD800\uDB00" + SUFFIX; + private static final String NORMAL_SURROGATE = PREFIX + "\uD800\uDC00" + SUFFIX; + private static final String REVERSED_SURROGATE = PREFIX + "\uDC00\uD800" + SUFFIX; + private static final String SOLITARY_HIGH_SURROGATE = PREFIX + "\uD800" + SUFFIX; + private static final String SOLITARY_LOW_SURROGATE = PREFIX + "\uDC00" + SUFFIX; - String fe = System.getProperty("file.encoding"); - if ( fe.equalsIgnoreCase("UTF8") - || fe.equalsIgnoreCase("UTF-8") - || fe.equalsIgnoreCase("UTF_8")) - // This test is meaningless if the default charset - // does handle surrogates + public static void main(String[] args) throws IOException { + SortedMap map = Charset.availableCharsets(); + for (String name : map.keySet()) { + Charset charset = map.get(name); + if (charset.canEncode() && !charset.name().equals("x-COMPOUND_TEXT")) { + testNormalSurrogate(charset, NORMAL_SURROGATE); + testMalformedSurrogate(charset, MALFORMED_SURROGATE); + testMalformedSurrogate(charset, REVERSED_SURROGATE); + testMalformedSurrogate(charset, SOLITARY_HIGH_SURROGATE); + testMalformedSurrogate(charset, SOLITARY_LOW_SURROGATE); + testSurrogateWithReplacement(charset, NORMAL_SURROGATE); + testSurrogateWithReplacement(charset, MALFORMED_SURROGATE); + testSurrogateWithReplacement(charset, REVERSED_SURROGATE); + testSurrogateWithReplacement(charset, SOLITARY_HIGH_SURROGATE); + testSurrogateWithReplacement(charset, SOLITARY_LOW_SURROGATE); + } + } + } + + public static void testMalformedSurrogate(Charset cs, String surrogate) throws IOException { + CharsetEncoder en = cs.newEncoder(); + if (en.canEncode(surrogate)) { + throw new RuntimeException("testMalformedSurrogate failed with charset " + cs.name()); + } + + try { + en.encode(CharBuffer.wrap(surrogate)); + throw new RuntimeException("Should throw MalformedInputException or UnmappableCharacterException"); + } catch (MalformedInputException | UnmappableCharacterException ex) { + } finally { + en.reset(); + } + + try (OutputStreamWriter osw = new OutputStreamWriter(new ByteArrayOutputStream(), en)) { + osw.write(surrogate); + throw new RuntimeException("Should throw MalformedInputException or UnmappableCharacterException"); + } catch (MalformedInputException | UnmappableCharacterException ex) { + } + } + + public static void testNormalSurrogate(Charset cs, String surrogate) throws IOException { + CharsetEncoder en = cs.newEncoder(); + try { + en.encode(CharBuffer.wrap(surrogate)); + } catch (UnmappableCharacterException ex) { + } finally { + en.reset(); + } + + try (OutputStreamWriter osw = new OutputStreamWriter(new ByteArrayOutputStream(), en)) { + osw.write(surrogate); + } catch (UnmappableCharacterException ex) { + } + } + + public static void testSurrogateWithReplacement(Charset cs, String surrogate) throws IOException { + CharsetEncoder en = cs.newEncoder(); + CharsetDecoder de = cs.newDecoder(); + if (!en.canEncode(NORMAL_SURROGATE)) { return; - - System.out.println("Testing string conversion..."); - /* Example with malformed surrogate, and an offset */ - String t = "abc\uD800\uDB00efgh"; - String t2 = t.substring(2); - byte[] b = t2.getBytes(); - System.err.println(b.length); - for (int i = 0; i < b.length; i++) - System.err.println("[" + i + "]" + "=" + (char) b[i] - + "=" + (int) b[i]); - if (b.length != 7) { - throw new Exception("Bad string conversion for bad surrogate"); + } + String expected = null; + String replace = new String(en.replacement(), cs); + switch (surrogate) { + case MALFORMED_SURROGATE: + case REVERSED_SURROGATE: + expected = PREFIX + replace + replace + SUFFIX; + break; + case SOLITARY_HIGH_SURROGATE: + case SOLITARY_LOW_SURROGATE: + expected = PREFIX + replace + SUFFIX; + break; + default: + expected = NORMAL_SURROGATE; } - /* Example with a proper surrogate, no offset. Always worked */ - String t3 = "abc\uD800\uDC00efgh"; - byte[] b2 = t3.getBytes(); - System.out.println(b2.length); - for(int i = 0; i < b2.length; i++) - System.err.println("[" + i + "]" + "=" + (char) b2[i]); - if (b2.length != 8) { - throw new Exception("Bad string conversion for good surrogate"); + try { + en.onMalformedInput(CodingErrorAction.REPLACE); + en.onUnmappableCharacter(CodingErrorAction.REPLACE); + ByteBuffer bbuf = en.encode(CharBuffer.wrap(surrogate)); + CharBuffer cbuf = de.decode(bbuf); + if (!cbuf.toString().equals(expected)) { + throw new RuntimeException("charset " + cs.name() + " (en)decoded the surrogate " + surrogate + " to " + cbuf.toString() + " which is not same as the expected " + expected); + } + } finally { + en.reset(); + de.reset(); } - OutputStream os = new ByteArrayOutputStream(); - OutputStreamWriter osw = new OutputStreamWriter(os); - System.out.println("Testing flush...."); - /* Check for the case where the converter has a left over - high surrogate when flush is called on the converter */ - osw.flush(); - String s = "abc\uD800"; // High surrogate - char[] c = s.toCharArray(); - osw.write(s, 0, 4); - osw.flush(); - - System.out.println("Testing convert..."); - /* Verify that all other characters go through */ - for (int k = 1; k < 65535 ; k++) { - osw.write("Char[" + k + "]=\"" + ((char) k) + "\""); + try (ByteArrayOutputStream bos = new ByteArrayOutputStream(); + OutputStreamWriter osw = new OutputStreamWriter(bos, en);) { + osw.write(surrogate); + osw.flush(); + try (InputStreamReader isr = new InputStreamReader(new ByteArrayInputStream(bos.toByteArray()), de)) { + CharBuffer cbuf = CharBuffer.allocate(expected.length()); + isr.read(cbuf); + cbuf.rewind(); + if (!cbuf.toString().equals(expected)) { + throw new RuntimeException("charset " + cs.name() + " (en)decoded the surrogate " + surrogate + " to " + cbuf.toString() + " which is not same as the expected " + expected); + } + } } - } } diff --git a/jdk/test/sun/rmi/rmic/newrmic/equivalence/batch.sh b/jdk/test/sun/rmi/rmic/newrmic/equivalence/batch.sh index 020202a1818..25913c63ea0 100644 --- a/jdk/test/sun/rmi/rmic/newrmic/equivalence/batch.sh +++ b/jdk/test/sun/rmi/rmic/newrmic/equivalence/batch.sh @@ -61,13 +61,13 @@ mkdir $newv11dir $newvcompatdir $newv12dir set -ex -${TESTJAVA}/bin/rmic -keep -nowrite -v1.1 -d $refv11dir -classpath "$@" -${TESTJAVA}/bin/rmic -keep -nowrite -vcompat -d $refvcompatdir -classpath "$@" -${TESTJAVA}/bin/rmic -keep -v1.2 -d $refv12dir -classpath "$@" +${TESTJAVA}/bin/rmic -keep -nowrite -v1.1 -d $refv11dir -classpath "$@" +${TESTJAVA}/bin/rmic -keep -nowrite -vcompat -d $refvcompatdir -classpath "$@" +${TESTJAVA}/bin/rmic -keep -nowrite -v1.2 -d $refv12dir -classpath "$@" -${TESTJAVA}/bin/rmic -Xnew -nowrite -keep -v1.1 -d $newv11dir -classpath "$@" -${TESTJAVA}/bin/rmic -Xnew -nowrite -keep -vcompat -d $newvcompatdir -classpath "$@" -${TESTJAVA}/bin/rmic -Xnew -keep -v1.2 -d $newv12dir -classpath "$@" +${TESTJAVA}/bin/rmic -Xnew -keep -nowrite -v1.1 -d $newv11dir -classpath "$@" +${TESTJAVA}/bin/rmic -Xnew -keep -nowrite -vcompat -d $newvcompatdir -classpath "$@" +${TESTJAVA}/bin/rmic -Xnew -keep -nowrite -v1.2 -d $newv12dir -classpath "$@" set +ex diff --git a/jdk/test/sun/security/ec/TestEC.java b/jdk/test/sun/security/ec/TestEC.java index 155e06ab027..c524b943365 100644 --- a/jdk/test/sun/security/ec/TestEC.java +++ b/jdk/test/sun/security/ec/TestEC.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -59,6 +59,10 @@ import java.security.Security; public class TestEC { public static void main(String[] args) throws Exception { + // MD5 is used in this test case, don't disable MD5 algorithm. + Security.setProperty( + "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + ProvidersSnapshot snapshot = ProvidersSnapshot.create(); try { main0(args); diff --git a/jdk/test/sun/security/jgss/GssMemoryIssues.java b/jdk/test/sun/security/jgss/GssMemoryIssues.java new file mode 100644 index 00000000000..91f9a45054a --- /dev/null +++ b/jdk/test/sun/security/jgss/GssMemoryIssues.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8028780 + * @summary JDK KRB5 module throws OutOfMemoryError when CCache is corrupt + * @run main/othervm -Xmx8m GssMemoryIssues + */ + +import org.ietf.jgss.GSSException; +import org.ietf.jgss.GSSManager; +import org.ietf.jgss.GSSName; + +public class GssMemoryIssues { + + public static void main(String[] argv) throws Exception { + GSSManager man = GSSManager.getInstance(); + String s = "me@REALM"; + GSSName name = man.createName(s, GSSName.NT_USER_NAME); + byte[] exported = name.export(); + // Offset of the length of the mech name. Length in big endian + int lenOffset = exported.length - s.length() - 4; + // Make it huge + exported[lenOffset] = 0x7f; + try { + man.createName(exported, GSSName.NT_EXPORT_NAME); + } catch (GSSException gsse) { + System.out.println(gsse); + } + } +} diff --git a/jdk/test/sun/security/krb5/ccache/CorruptedCC.java b/jdk/test/sun/security/krb5/ccache/CorruptedCC.java new file mode 100644 index 00000000000..355e2ff6c0e --- /dev/null +++ b/jdk/test/sun/security/krb5/ccache/CorruptedCC.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8028780 + * @summary JDK KRB5 module throws OutOfMemoryError when CCache is corrupt + * @run main/othervm -Xmx8m CorruptedCC + */ +import java.nio.file.Files; +import java.nio.file.Paths; +import sun.security.krb5.internal.ccache.CredentialsCache; + +public class CorruptedCC { + public static void main(String[] args) throws Exception { + for (int i=0; i certmap = new HashMap(); + static { + certmap.put("trustAnchor_SHA1withRSA_1024", + trustAnchor_SHA1withRSA_1024); + certmap.put("trustAnchor_SHA1withRSA_512", + trustAnchor_SHA1withRSA_512); + certmap.put("intermediate_SHA1withRSA_1024_1024", + intermediate_SHA1withRSA_1024_1024); + certmap.put("intermediate_SHA1withRSA_1024_512", + intermediate_SHA1withRSA_1024_512); + certmap.put("intermediate_SHA1withRSA_512_1024", + intermediate_SHA1withRSA_512_1024); + certmap.put("intermediate_SHA1withRSA_512_512", + intermediate_SHA1withRSA_512_512); + certmap.put("intermediate_MD5withRSA_1024_1024", + intermediate_MD5withRSA_1024_1024); + certmap.put("intermediate_MD5withRSA_1024_512", + intermediate_MD5withRSA_1024_512); + certmap.put("endentiry_SHA1withRSA_1024_1024", + endentiry_SHA1withRSA_1024_1024); + certmap.put("endentiry_SHA1withRSA_1024_512", + endentiry_SHA1withRSA_1024_512); + certmap.put("endentiry_SHA1withRSA_512_1024", + endentiry_SHA1withRSA_512_1024); + certmap.put("endentiry_SHA1withRSA_512_512", + endentiry_SHA1withRSA_512_512); + certmap.put("endentiry_MD5withRSA_1024_1024", + endentiry_MD5withRSA_1024_1024); + certmap.put("endentiry_MD5withRSA_1024_512", + endentiry_MD5withRSA_1024_512); + } + + private static Set generateTrustAnchors() + throws CertificateException { + // generate certificate from cert string + CertificateFactory cf = CertificateFactory.getInstance("X.509"); + HashSet anchors = new HashSet(); + + ByteArrayInputStream is = + new ByteArrayInputStream(trustAnchor_SHA1withRSA_1024.getBytes()); + Certificate cert = cf.generateCertificate(is); + TrustAnchor anchor = new TrustAnchor((X509Certificate)cert, null); + anchors.add(anchor); + + is = new ByteArrayInputStream(trustAnchor_SHA1withRSA_512.getBytes()); + cert = cf.generateCertificate(is); + anchor = new TrustAnchor((X509Certificate)cert, null); + anchors.add(anchor); + + return anchors; + } + + private static CertStore generateCertificateStore() throws Exception { + Collection entries = new HashSet(); + + // generate certificate from certificate string + CertificateFactory cf = CertificateFactory.getInstance("X.509"); + + for (String key : certmap.keySet()) { + String certStr = certmap.get(key); + ByteArrayInputStream is = + new ByteArrayInputStream(certStr.getBytes());; + Certificate cert = cf.generateCertificate(is); + entries.add(cert); + } + + return CertStore.getInstance("Collection", + new CollectionCertStoreParameters(entries)); + } + + private static X509CertSelector generateSelector(String name) + throws Exception { + X509CertSelector selector = new X509CertSelector(); + + String certStr = certmap.get(name); + if (certStr == null) { + return null; + } + + // generate certificate from certificate string + CertificateFactory cf = CertificateFactory.getInstance("X.509"); + ByteArrayInputStream is = new ByteArrayInputStream(certStr.getBytes()); + X509Certificate target = (X509Certificate)cf.generateCertificate(is); + + selector.setCertificate(target); + + return selector; + } + + private static boolean match(String name, Certificate cert) + throws Exception { + X509CertSelector selector = new X509CertSelector(); + + String certStr = certmap.get(name); + if (certStr == null) { + return false; + } + + // generate certificate from certificate string + CertificateFactory cf = CertificateFactory.getInstance("X.509"); + ByteArrayInputStream is = new ByteArrayInputStream(certStr.getBytes()); + X509Certificate target = (X509Certificate)cf.generateCertificate(is); + + return target.equals(cert); + } + + public static void main(String args[]) throws Exception { + CertPathBuilder builder = CertPathBuilder.getInstance("PKIX"); + + X509CertSelector selector = generateSelector(args[0]); + if (selector == null) { + // no target certificate, ignore it + return; + } + + Set anchors = generateTrustAnchors(); + CertStore certs = generateCertificateStore(); + + PKIXBuilderParameters params = + new PKIXBuilderParameters(anchors, selector); + params.addCertStore(certs); + params.setRevocationEnabled(false); + params.setDate(new Date(114, 9, 1)); // 2014-09-01 + + boolean success = Boolean.valueOf(args[2]); + try { + PKIXCertPathBuilderResult result = + (PKIXCertPathBuilderResult)builder.build(params); + if (!success) { + throw new Exception("expected algorithm disabled exception"); + } + + int length = Integer.parseInt(args[1]); + List path = + result.getCertPath().getCertificates(); + if (length != path.size()) { + throw new Exception("unexpected certification path length"); + } + + if (!path.isEmpty()) { // the target is not a trust anchor + if (!match(args[0], path.get(0))) { + throw new Exception("unexpected certificate"); + } + } + } catch (CertPathBuilderException cpbe) { + if (success) { + throw new Exception("unexpected exception", cpbe); + } else { + System.out.println("Get the expected exception " + cpbe); + } + } + } + +} diff --git a/jdk/test/sun/security/provider/certpath/ReverseBuilder/ReverseBuild.java b/jdk/test/sun/security/provider/certpath/ReverseBuilder/ReverseBuild.java index 21736eac623..abb18ebd439 100644 --- a/jdk/test/sun/security/provider/certpath/ReverseBuilder/ReverseBuild.java +++ b/jdk/test/sun/security/provider/certpath/ReverseBuilder/ReverseBuild.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 @@ -21,15 +21,23 @@ * questions. */ +// +// Security properties, once set, cannot revert to unset. To avoid +// conflicts with tests running in the same VM isolate this test by +// running it in otherVM mode. +// + /* * @test * @bug 7167988 * @summary PKIX CertPathBuilder in reverse mode doesn't work if more than * one trust anchor is specified + * @run main/othervm ReverseBuild */ import java.io.*; import java.util.*; import java.security.cert.*; +import java.security.Security; import sun.security.provider.certpath.SunCertPathBuilderParameters; @@ -279,6 +287,9 @@ public class ReverseBuild { public static void main(String args[]) throws Exception { + // MD5 is used in this test case, don't disable MD5 algorithm. + Security.setProperty( + "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); // generate certificate from cert string CertificateFactory cf = CertificateFactory.getInstance("X.509"); diff --git a/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/DHKeyExchange/DHEKeySizing.java b/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/DHKeyExchange/DHEKeySizing.java index ec61b303bc8..5c784b4e9ec 100644 --- a/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/DHKeyExchange/DHEKeySizing.java +++ b/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/DHKeyExchange/DHEKeySizing.java @@ -443,7 +443,7 @@ public class DHEKeySizing { TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509"); tmf.init(ts); - SSLContext sslCtx = SSLContext.getInstance("TLS"); + SSLContext sslCtx = SSLContext.getInstance("TLSv1"); sslCtx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null); return sslCtx; diff --git a/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/EngineArgs/DebugReportsOneExtraByte.java b/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/EngineArgs/DebugReportsOneExtraByte.java index 0f69a0590d9..fc6eafa259a 100644 --- a/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/EngineArgs/DebugReportsOneExtraByte.java +++ b/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/EngineArgs/DebugReportsOneExtraByte.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -159,7 +159,7 @@ public class DebugReportsOneExtraByte { TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509"); tmf.init(ts); - SSLContext sslCtx = SSLContext.getInstance("TLS"); + SSLContext sslCtx = SSLContext.getInstance("TLSv1"); sslCtx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null); diff --git a/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/EngineArgs/DebugReportsOneExtraByte.sh b/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/EngineArgs/DebugReportsOneExtraByte.sh index 9b48bee7f3b..b0a824fc45e 100644 --- a/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/EngineArgs/DebugReportsOneExtraByte.sh +++ b/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/EngineArgs/DebugReportsOneExtraByte.sh @@ -33,7 +33,7 @@ OS=`uname -s` case "$OS" in - SunOS | Linux | Darwin ) + SunOS | Linux | Darwin | AIX ) PS=":" FS="/" ;; diff --git a/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/InputRecord/SSLSocketTimeoutNulls.java b/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/InputRecord/SSLSocketTimeoutNulls.java index 70344cde866..4a72a1ecf1e 100644 --- a/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/InputRecord/SSLSocketTimeoutNulls.java +++ b/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/InputRecord/SSLSocketTimeoutNulls.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -21,6 +21,11 @@ * questions. */ +// +// SunJSSE does not support dynamic system properties, no way to re-use +// system properties in samevm/agentvm mode. +// + /* * @test * @bug 4456039 @@ -28,9 +33,6 @@ * after timeout occurs. This bug was fixed as part of 4393337, * but this is another bug we want to check regressions against. * @run main/othervm/timeout=140 SSLSocketTimeoutNulls - * - * SunJSSE does not support dynamic system properties, no way to re-use - * system properties in samevm/agentvm mode. * @author Brad Wetmore */ @@ -152,7 +154,7 @@ public class SSLSocketTimeoutNulls { caught = true; // Try to read it again after it should be available. - Thread.sleep(5000); + Thread.sleep(6500); if (sslIS.read() == 85) System.out.println("Read the right value"); else diff --git a/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLContextImpl/CustomizedDefaultProtocols.java b/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLContextImpl/CustomizedDefaultProtocols.java new file mode 100644 index 00000000000..3045064d0ad --- /dev/null +++ b/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLContextImpl/CustomizedDefaultProtocols.java @@ -0,0 +1,239 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// SunJSSE does not support dynamic system properties, no way to re-use +// system properties in samevm/agentvm mode. + +/* + * @test + * @bug 7093640 + * @summary Enable TLS 1.1 and TLS 1.2 by default in client side of SunJSSE + * @run main/othervm -Djdk.tls.client.protocols="SSLv3,TLSv1,TLSv1.1" + * CustomizedDefaultProtocols + */ + +import javax.net.*; +import javax.net.ssl.*; +import java.util.Arrays; + +public class CustomizedDefaultProtocols { + static enum ContextVersion { + TLS_CV_01("SSL", + new String[] {"SSLv3", "TLSv1", "TLSv1.1"}), + TLS_CV_02("TLS", + new String[] {"SSLv3", "TLSv1", "TLSv1.1"}), + TLS_CV_03("SSLv3", + new String[] {"SSLv3", "TLSv1"}), + TLS_CV_04("TLSv1", + new String[] {"SSLv3", "TLSv1"}), + TLS_CV_05("TLSv1.1", + new String[] {"SSLv3", "TLSv1", "TLSv1.1"}), + TLS_CV_06("TLSv1.2", + new String[] {"SSLv3", "TLSv1", "TLSv1.1", "TLSv1.2"}), + TLS_CV_07("Default", + new String[] {"SSLv3", "TLSv1", "TLSv1.1"}); + + final String contextVersion; + final String[] enabledProtocols; + final static String[] supportedProtocols = new String[] { + "SSLv2Hello", "SSLv3", "TLSv1", "TLSv1.1", "TLSv1.2"}; + + ContextVersion(String contextVersion, String[] enabledProtocols) { + this.contextVersion = contextVersion; + this.enabledProtocols = enabledProtocols; + } + } + + private static boolean checkProtocols(String[] target, String[] expected) { + boolean success = true; + if (target.length == 0) { + System.out.println("\tError: No protocols"); + success = false; + } + + if (!Arrays.equals(target, expected)) { + System.out.println("\tError: Expected to get protocols " + + Arrays.toString(expected)); + System.out.println("\tError: The actual protocols " + + Arrays.toString(target)); + success = false; + } + + return success; + } + + private static boolean checkCipherSuites(String[] target) { + boolean success = true; + if (target.length == 0) { + System.out.println("\tError: No cipher suites"); + success = false; + } + + return success; + } + + public static void main(String[] args) throws Exception { + boolean failed = false; + for (ContextVersion cv : ContextVersion.values()) { + System.out.println("Checking SSLContext of " + cv.contextVersion); + SSLContext context = SSLContext.getInstance(cv.contextVersion); + + // Default SSLContext is initialized automatically. + if (!cv.contextVersion.equals("Default")) { + // Use default TK, KM and random. + context.init((KeyManager[])null, (TrustManager[])null, null); + } + + // + // Check SSLContext + // + // Check default SSLParameters of SSLContext + System.out.println("\tChecking default SSLParameters"); + SSLParameters parameters = context.getDefaultSSLParameters(); + + String[] protocols = parameters.getProtocols(); + failed |= !checkProtocols(protocols, cv.enabledProtocols); + + String[] ciphers = parameters.getCipherSuites(); + failed |= !checkCipherSuites(ciphers); + + // Check supported SSLParameters of SSLContext + System.out.println("\tChecking supported SSLParameters"); + parameters = context.getSupportedSSLParameters(); + + protocols = parameters.getProtocols(); + failed |= !checkProtocols(protocols, cv.supportedProtocols); + + ciphers = parameters.getCipherSuites(); + failed |= !checkCipherSuites(ciphers); + + // + // Check SSLEngine + // + // Check SSLParameters of SSLEngine + System.out.println(); + System.out.println("\tChecking SSLEngine of this SSLContext"); + System.out.println("\tChecking SSLEngine.getSSLParameters()"); + SSLEngine engine = context.createSSLEngine(); + engine.setUseClientMode(true); + parameters = engine.getSSLParameters(); + + protocols = parameters.getProtocols(); + failed |= !checkProtocols(protocols, cv.enabledProtocols); + + ciphers = parameters.getCipherSuites(); + failed |= !checkCipherSuites(ciphers); + + System.out.println("\tChecking SSLEngine.getEnabledProtocols()"); + protocols = engine.getEnabledProtocols(); + failed |= !checkProtocols(protocols, cv.enabledProtocols); + + System.out.println("\tChecking SSLEngine.getEnabledCipherSuites()"); + ciphers = engine.getEnabledCipherSuites(); + failed |= !checkCipherSuites(ciphers); + + System.out.println("\tChecking SSLEngine.getSupportedProtocols()"); + protocols = engine.getSupportedProtocols(); + failed |= !checkProtocols(protocols, cv.supportedProtocols); + + System.out.println( + "\tChecking SSLEngine.getSupportedCipherSuites()"); + ciphers = engine.getSupportedCipherSuites(); + failed |= !checkCipherSuites(ciphers); + + // + // Check SSLSocket + // + // Check SSLParameters of SSLSocket + System.out.println(); + System.out.println("\tChecking SSLSocket of this SSLContext"); + System.out.println("\tChecking SSLSocket.getSSLParameters()"); + SocketFactory fac = context.getSocketFactory(); + SSLSocket socket = (SSLSocket)fac.createSocket(); + parameters = socket.getSSLParameters(); + + protocols = parameters.getProtocols(); + failed |= !checkProtocols(protocols, cv.enabledProtocols); + + ciphers = parameters.getCipherSuites(); + failed |= !checkCipherSuites(ciphers); + + System.out.println("\tChecking SSLEngine.getEnabledProtocols()"); + protocols = socket.getEnabledProtocols(); + failed |= !checkProtocols(protocols, cv.enabledProtocols); + + System.out.println("\tChecking SSLEngine.getEnabledCipherSuites()"); + ciphers = socket.getEnabledCipherSuites(); + failed |= !checkCipherSuites(ciphers); + + System.out.println("\tChecking SSLEngine.getSupportedProtocols()"); + protocols = socket.getSupportedProtocols(); + failed |= !checkProtocols(protocols, cv.supportedProtocols); + + System.out.println( + "\tChecking SSLEngine.getSupportedCipherSuites()"); + ciphers = socket.getSupportedCipherSuites(); + failed |= !checkCipherSuites(ciphers); + + // + // Check SSLServerSocket + // + // Check SSLParameters of SSLServerSocket + System.out.println(); + System.out.println("\tChecking SSLServerSocket of this SSLContext"); + System.out.println("\tChecking SSLServerSocket.getSSLParameters()"); + SSLServerSocketFactory sf = context.getServerSocketFactory(); + SSLServerSocket ssocket = (SSLServerSocket)sf.createServerSocket(); + parameters = ssocket.getSSLParameters(); + + protocols = parameters.getProtocols(); + failed |= !checkProtocols(protocols, cv.supportedProtocols); + + ciphers = parameters.getCipherSuites(); + failed |= !checkCipherSuites(ciphers); + + System.out.println("\tChecking SSLEngine.getEnabledProtocols()"); + protocols = ssocket.getEnabledProtocols(); + failed |= !checkProtocols(protocols, cv.supportedProtocols); + + System.out.println("\tChecking SSLEngine.getEnabledCipherSuites()"); + ciphers = ssocket.getEnabledCipherSuites(); + failed |= !checkCipherSuites(ciphers); + + System.out.println("\tChecking SSLEngine.getSupportedProtocols()"); + protocols = ssocket.getSupportedProtocols(); + failed |= !checkProtocols(protocols, cv.supportedProtocols); + + System.out.println( + "\tChecking SSLEngine.getSupportedCipherSuites()"); + ciphers = ssocket.getSupportedCipherSuites(); + failed |= !checkCipherSuites(ciphers); + } + + if (failed) { + throw new Exception("Run into problems, see log for more details"); + } else { + System.out.println("\t... Success"); + } + } +} diff --git a/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLContextImpl/DefaultEnabledProtocols.java b/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLContextImpl/DefaultEnabledProtocols.java new file mode 100644 index 00000000000..20381c6b577 --- /dev/null +++ b/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLContextImpl/DefaultEnabledProtocols.java @@ -0,0 +1,238 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// SunJSSE does not support dynamic system properties, no way to re-use +// system properties in samevm/agentvm mode. + +/* + * @test + * @bug 7093640 + * @summary Enable TLS 1.1 and TLS 1.2 by default in client side of SunJSSE + * @run main/othervm DefaultEnabledProtocols + */ + +import javax.net.*; +import javax.net.ssl.*; +import java.util.Arrays; + +public class DefaultEnabledProtocols { + static enum ContextVersion { + TLS_CV_01("SSL", + new String[] {"SSLv3", "TLSv1", "TLSv1.1", "TLSv1.2"}), + TLS_CV_02("TLS", + new String[] {"SSLv3", "TLSv1", "TLSv1.1", "TLSv1.2"}), + TLS_CV_03("SSLv3", + new String[] {"SSLv3", "TLSv1"}), + TLS_CV_04("TLSv1", + new String[] {"SSLv3", "TLSv1"}), + TLS_CV_05("TLSv1.1", + new String[] {"SSLv3", "TLSv1", "TLSv1.1"}), + TLS_CV_06("TLSv1.2", + new String[] {"SSLv3", "TLSv1", "TLSv1.1", "TLSv1.2"}), + TLS_CV_07("Default", + new String[] {"SSLv3", "TLSv1", "TLSv1.1", "TLSv1.2"}); + + final String contextVersion; + final String[] enabledProtocols; + final static String[] supportedProtocols = new String[] { + "SSLv2Hello", "SSLv3", "TLSv1", "TLSv1.1", "TLSv1.2"}; + + ContextVersion(String contextVersion, String[] enabledProtocols) { + this.contextVersion = contextVersion; + this.enabledProtocols = enabledProtocols; + } + } + + private static boolean checkProtocols(String[] target, String[] expected) { + boolean success = true; + if (target.length == 0) { + System.out.println("\tError: No protocols"); + success = false; + } + + if (!Arrays.equals(target, expected)) { + System.out.println("\tError: Expected to get protocols " + + Arrays.toString(expected)); + System.out.println("\tError: The actual protocols " + + Arrays.toString(target)); + success = false; + } + + return success; + } + + private static boolean checkCipherSuites(String[] target) { + boolean success = true; + if (target.length == 0) { + System.out.println("\tError: No cipher suites"); + success = false; + } + + return success; + } + + public static void main(String[] args) throws Exception { + boolean failed = false; + for (ContextVersion cv : ContextVersion.values()) { + System.out.println("Checking SSLContext of " + cv.contextVersion); + SSLContext context = SSLContext.getInstance(cv.contextVersion); + + // Default SSLContext is initialized automatically. + if (!cv.contextVersion.equals("Default")) { + // Use default TK, KM and random. + context.init((KeyManager[])null, (TrustManager[])null, null); + } + + // + // Check SSLContext + // + // Check default SSLParameters of SSLContext + System.out.println("\tChecking default SSLParameters"); + SSLParameters parameters = context.getDefaultSSLParameters(); + + String[] protocols = parameters.getProtocols(); + failed |= !checkProtocols(protocols, cv.enabledProtocols); + + String[] ciphers = parameters.getCipherSuites(); + failed |= !checkCipherSuites(ciphers); + + // Check supported SSLParameters of SSLContext + System.out.println("\tChecking supported SSLParameters"); + parameters = context.getSupportedSSLParameters(); + + protocols = parameters.getProtocols(); + failed |= !checkProtocols(protocols, cv.supportedProtocols); + + ciphers = parameters.getCipherSuites(); + failed |= !checkCipherSuites(ciphers); + + // + // Check SSLEngine + // + // Check SSLParameters of SSLEngine + System.out.println(); + System.out.println("\tChecking SSLEngine of this SSLContext"); + System.out.println("\tChecking SSLEngine.getSSLParameters()"); + SSLEngine engine = context.createSSLEngine(); + engine.setUseClientMode(true); + parameters = engine.getSSLParameters(); + + protocols = parameters.getProtocols(); + failed |= !checkProtocols(protocols, cv.enabledProtocols); + + ciphers = parameters.getCipherSuites(); + failed |= !checkCipherSuites(ciphers); + + System.out.println("\tChecking SSLEngine.getEnabledProtocols()"); + protocols = engine.getEnabledProtocols(); + failed |= !checkProtocols(protocols, cv.enabledProtocols); + + System.out.println("\tChecking SSLEngine.getEnabledCipherSuites()"); + ciphers = engine.getEnabledCipherSuites(); + failed |= !checkCipherSuites(ciphers); + + System.out.println("\tChecking SSLEngine.getSupportedProtocols()"); + protocols = engine.getSupportedProtocols(); + failed |= !checkProtocols(protocols, cv.supportedProtocols); + + System.out.println( + "\tChecking SSLEngine.getSupportedCipherSuites()"); + ciphers = engine.getSupportedCipherSuites(); + failed |= !checkCipherSuites(ciphers); + + // + // Check SSLSocket + // + // Check SSLParameters of SSLSocket + System.out.println(); + System.out.println("\tChecking SSLSocket of this SSLContext"); + System.out.println("\tChecking SSLSocket.getSSLParameters()"); + SocketFactory fac = context.getSocketFactory(); + SSLSocket socket = (SSLSocket)fac.createSocket(); + parameters = socket.getSSLParameters(); + + protocols = parameters.getProtocols(); + failed |= !checkProtocols(protocols, cv.enabledProtocols); + + ciphers = parameters.getCipherSuites(); + failed |= !checkCipherSuites(ciphers); + + System.out.println("\tChecking SSLEngine.getEnabledProtocols()"); + protocols = socket.getEnabledProtocols(); + failed |= !checkProtocols(protocols, cv.enabledProtocols); + + System.out.println("\tChecking SSLEngine.getEnabledCipherSuites()"); + ciphers = socket.getEnabledCipherSuites(); + failed |= !checkCipherSuites(ciphers); + + System.out.println("\tChecking SSLEngine.getSupportedProtocols()"); + protocols = socket.getSupportedProtocols(); + failed |= !checkProtocols(protocols, cv.supportedProtocols); + + System.out.println( + "\tChecking SSLEngine.getSupportedCipherSuites()"); + ciphers = socket.getSupportedCipherSuites(); + failed |= !checkCipherSuites(ciphers); + + // + // Check SSLServerSocket + // + // Check SSLParameters of SSLServerSocket + System.out.println(); + System.out.println("\tChecking SSLServerSocket of this SSLContext"); + System.out.println("\tChecking SSLServerSocket.getSSLParameters()"); + SSLServerSocketFactory sf = context.getServerSocketFactory(); + SSLServerSocket ssocket = (SSLServerSocket)sf.createServerSocket(); + parameters = ssocket.getSSLParameters(); + + protocols = parameters.getProtocols(); + failed |= !checkProtocols(protocols, cv.supportedProtocols); + + ciphers = parameters.getCipherSuites(); + failed |= !checkCipherSuites(ciphers); + + System.out.println("\tChecking SSLEngine.getEnabledProtocols()"); + protocols = ssocket.getEnabledProtocols(); + failed |= !checkProtocols(protocols, cv.supportedProtocols); + + System.out.println("\tChecking SSLEngine.getEnabledCipherSuites()"); + ciphers = ssocket.getEnabledCipherSuites(); + failed |= !checkCipherSuites(ciphers); + + System.out.println("\tChecking SSLEngine.getSupportedProtocols()"); + protocols = ssocket.getSupportedProtocols(); + failed |= !checkProtocols(protocols, cv.supportedProtocols); + + System.out.println( + "\tChecking SSLEngine.getSupportedCipherSuites()"); + ciphers = ssocket.getSupportedCipherSuites(); + failed |= !checkCipherSuites(ciphers); + } + + if (failed) { + throw new Exception("Run into problems, see log for more details"); + } else { + System.out.println("\t... Success"); + } + } +} diff --git a/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLContextImpl/IllegalProtocolProperty.java b/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLContextImpl/IllegalProtocolProperty.java new file mode 100644 index 00000000000..f85d166178b --- /dev/null +++ b/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLContextImpl/IllegalProtocolProperty.java @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// SunJSSE does not support dynamic system properties, no way to re-use +// system properties in samevm/agentvm mode. + +/* + * @test + * @bug 7093640 + * @summary Enable TLS 1.1 and TLS 1.2 by default in client side of SunJSSE + * @run main/othervm -Djdk.tls.client.protocols="XSLv3,TLSv1" + * IllegalProtocolProperty + */ + +import javax.net.ssl.*; +import java.security.NoSuchAlgorithmException; + +public class IllegalProtocolProperty { + static enum ContextVersion { + TLS_CV_01("SSL", "TLSv1", "TLSv1.2", true), + TLS_CV_02("TLS", "TLSv1", "TLSv1.2", true), + TLS_CV_03("SSLv3", "TLSv1", "TLSv1.2", false), + TLS_CV_04("TLSv1", "TLSv1", "TLSv1.2", false), + TLS_CV_05("TLSv1.1", "TLSv1.1", "TLSv1.2", false), + TLS_CV_06("TLSv1.2", "TLSv1.2", "TLSv1.2", false), + TLS_CV_07("Default", "TLSv1", "TLSv1.2", true); + + final String contextVersion; + final String defaultProtocolVersion; + final String supportedProtocolVersion; + final boolean impacted; + + ContextVersion(String contextVersion, String defaultProtocolVersion, + String supportedProtocolVersion, boolean impacted) { + this.contextVersion = contextVersion; + this.defaultProtocolVersion = defaultProtocolVersion; + this.supportedProtocolVersion = supportedProtocolVersion; + this.impacted = impacted; + } + } + + public static void main(String[] args) throws Exception { + for (ContextVersion cv : ContextVersion.values()) { + System.out.println("Checking SSLContext of " + cv.contextVersion); + + SSLContext context; + try { + context = SSLContext.getInstance(cv.contextVersion); + if (cv.impacted) { + throw new Exception( + "illegal system property jdk.tls.client.protocols: " + + System.getProperty("jdk.tls.client.protocols")); + } + } catch (NoSuchAlgorithmException nsae) { + if (cv.impacted) { + System.out.println( + "\tIgnore: illegal system property " + + "jdk.tls.client.protocols=" + + System.getProperty("jdk.tls.client.protocols")); + continue; + } else { + throw nsae; + } + } + + // Default SSLContext is initialized automatically. + if (!cv.contextVersion.equals("Default")) { + // Use default TK, KM and random. + context.init((KeyManager[])null, (TrustManager[])null, null); + } + + SSLParameters parameters = context.getDefaultSSLParameters(); + + String[] protocols = parameters.getProtocols(); + String[] ciphers = parameters.getCipherSuites(); + + if (protocols.length == 0 || ciphers.length == 0) { + throw new Exception("No default protocols or cipher suites"); + } + + boolean isMatch = false; + for (String protocol : protocols) { + System.out.println("\tdefault protocol version " + protocol); + if (protocol.equals(cv.defaultProtocolVersion)) { + isMatch = true; + break; + } + } + + if (!isMatch) { + throw new Exception("No matched default protocol"); + } + + parameters = context.getSupportedSSLParameters(); + + protocols = parameters.getProtocols(); + ciphers = parameters.getCipherSuites(); + + if (protocols.length == 0 || ciphers.length == 0) { + throw new Exception("No supported protocols or cipher suites"); + } + + isMatch = false; + for (String protocol : protocols) { + System.out.println("\tsupported protocol version " + protocol); + if (protocol.equals(cv.supportedProtocolVersion)) { + isMatch = true; + break; + } + } + + if (!isMatch) { + throw new Exception("No matched supported protocol"); + } + System.out.println("\t... Success"); + } + } +} diff --git a/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLContextImpl/MD2InTrustAnchor.java b/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLContextImpl/MD2InTrustAnchor.java index 9cf0fbb7185..9b695a2fc7b 100644 --- a/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLContextImpl/MD2InTrustAnchor.java +++ b/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLContextImpl/MD2InTrustAnchor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 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 @@ -23,13 +23,15 @@ * questions. */ +// +// SunJSSE does not support dynamic system properties, no way to re-use +// system properties in samevm/agentvm mode. +// + /* * @test * @bug 7113275 * @summary compatibility issue with MD2 trust anchor and old X509TrustManager - * - * SunJSSE does not support dynamic system properties, no way to re-use - * system properties in samevm/agentvm mode. * @run main/othervm MD2InTrustAnchor PKIX TLSv1.1 * @run main/othervm MD2InTrustAnchor SunX509 TLSv1.1 * @run main/othervm MD2InTrustAnchor PKIX TLSv1.2 @@ -40,6 +42,7 @@ import java.net.*; import java.util.*; import java.io.*; import javax.net.ssl.*; +import java.security.Security; import java.security.KeyStore; import java.security.KeyFactory; import java.security.cert.Certificate; @@ -283,6 +286,10 @@ public class MD2InTrustAnchor { volatile Exception clientException = null; public static void main(String[] args) throws Exception { + // MD5 is used in this test case, don't disable MD5 algorithm. + Security.setProperty( + "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + if (debug) System.setProperty("javax.net.debug", "all"); diff --git a/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLContextImpl/NoOldVersionContext.java b/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLContextImpl/NoOldVersionContext.java new file mode 100644 index 00000000000..d7b1abdeffc --- /dev/null +++ b/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLContextImpl/NoOldVersionContext.java @@ -0,0 +1,239 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// SunJSSE does not support dynamic system properties, no way to re-use +// system properties in samevm/agentvm mode. + +/* + * @test + * @bug 7093640 + * @summary Enable TLS 1.1 and TLS 1.2 by default in client side of SunJSSE + * @run main/othervm -Djdk.tls.client.protocols="TLSv1,TLSv1.1,TLSv1.2" + * NoOldVersionContext + */ + +import javax.net.*; +import javax.net.ssl.*; +import java.util.Arrays; + +public class NoOldVersionContext { + static enum ContextVersion { + TLS_CV_01("SSL", + new String[] {"TLSv1", "TLSv1.1", "TLSv1.2"}), + TLS_CV_02("TLS", + new String[] {"TLSv1", "TLSv1.1", "TLSv1.2"}), + TLS_CV_03("SSLv3", + new String[] {"SSLv3", "TLSv1"}), + TLS_CV_04("TLSv1", + new String[] {"SSLv3", "TLSv1"}), + TLS_CV_05("TLSv1.1", + new String[] {"SSLv3", "TLSv1", "TLSv1.1"}), + TLS_CV_06("TLSv1.2", + new String[] {"SSLv3", "TLSv1", "TLSv1.1", "TLSv1.2"}), + TLS_CV_07("Default", + new String[] {"TLSv1", "TLSv1.1", "TLSv1.2"}); + + final String contextVersion; + final String[] enabledProtocols; + final static String[] supportedProtocols = new String[] { + "SSLv2Hello", "SSLv3", "TLSv1", "TLSv1.1", "TLSv1.2"}; + + ContextVersion(String contextVersion, String[] enabledProtocols) { + this.contextVersion = contextVersion; + this.enabledProtocols = enabledProtocols; + } + } + + private static boolean checkProtocols(String[] target, String[] expected) { + boolean success = true; + if (target.length == 0) { + System.out.println("\tError: No protocols"); + success = false; + } + + if (!Arrays.equals(target, expected)) { + System.out.println("\tError: Expected to get protocols " + + Arrays.toString(expected)); + System.out.println("\tError: The actual protocols " + + Arrays.toString(target)); + success = false; + } + + return success; + } + + private static boolean checkCipherSuites(String[] target) { + boolean success = true; + if (target.length == 0) { + System.out.println("\tError: No cipher suites"); + success = false; + } + + return success; + } + + public static void main(String[] args) throws Exception { + boolean failed = false; + for (ContextVersion cv : ContextVersion.values()) { + System.out.println("Checking SSLContext of " + cv.contextVersion); + SSLContext context = SSLContext.getInstance(cv.contextVersion); + + // Default SSLContext is initialized automatically. + if (!cv.contextVersion.equals("Default")) { + // Use default TK, KM and random. + context.init((KeyManager[])null, (TrustManager[])null, null); + } + + // + // Check SSLContext + // + // Check default SSLParameters of SSLContext + System.out.println("\tChecking default SSLParameters"); + SSLParameters parameters = context.getDefaultSSLParameters(); + + String[] protocols = parameters.getProtocols(); + failed |= !checkProtocols(protocols, cv.enabledProtocols); + + String[] ciphers = parameters.getCipherSuites(); + failed |= !checkCipherSuites(ciphers); + + // Check supported SSLParameters of SSLContext + System.out.println("\tChecking supported SSLParameters"); + parameters = context.getSupportedSSLParameters(); + + protocols = parameters.getProtocols(); + failed |= !checkProtocols(protocols, cv.supportedProtocols); + + ciphers = parameters.getCipherSuites(); + failed |= !checkCipherSuites(ciphers); + + // + // Check SSLEngine + // + // Check SSLParameters of SSLEngine + System.out.println(); + System.out.println("\tChecking SSLEngine of this SSLContext"); + System.out.println("\tChecking SSLEngine.getSSLParameters()"); + SSLEngine engine = context.createSSLEngine(); + engine.setUseClientMode(true); + parameters = engine.getSSLParameters(); + + protocols = parameters.getProtocols(); + failed |= !checkProtocols(protocols, cv.enabledProtocols); + + ciphers = parameters.getCipherSuites(); + failed |= !checkCipherSuites(ciphers); + + System.out.println("\tChecking SSLEngine.getEnabledProtocols()"); + protocols = engine.getEnabledProtocols(); + failed |= !checkProtocols(protocols, cv.enabledProtocols); + + System.out.println("\tChecking SSLEngine.getEnabledCipherSuites()"); + ciphers = engine.getEnabledCipherSuites(); + failed |= !checkCipherSuites(ciphers); + + System.out.println("\tChecking SSLEngine.getSupportedProtocols()"); + protocols = engine.getSupportedProtocols(); + failed |= !checkProtocols(protocols, cv.supportedProtocols); + + System.out.println( + "\tChecking SSLEngine.getSupportedCipherSuites()"); + ciphers = engine.getSupportedCipherSuites(); + failed |= !checkCipherSuites(ciphers); + + // + // Check SSLSocket + // + // Check SSLParameters of SSLSocket + System.out.println(); + System.out.println("\tChecking SSLSocket of this SSLContext"); + System.out.println("\tChecking SSLSocket.getSSLParameters()"); + SocketFactory fac = context.getSocketFactory(); + SSLSocket socket = (SSLSocket)fac.createSocket(); + parameters = socket.getSSLParameters(); + + protocols = parameters.getProtocols(); + failed |= !checkProtocols(protocols, cv.enabledProtocols); + + ciphers = parameters.getCipherSuites(); + failed |= !checkCipherSuites(ciphers); + + System.out.println("\tChecking SSLEngine.getEnabledProtocols()"); + protocols = socket.getEnabledProtocols(); + failed |= !checkProtocols(protocols, cv.enabledProtocols); + + System.out.println("\tChecking SSLEngine.getEnabledCipherSuites()"); + ciphers = socket.getEnabledCipherSuites(); + failed |= !checkCipherSuites(ciphers); + + System.out.println("\tChecking SSLEngine.getSupportedProtocols()"); + protocols = socket.getSupportedProtocols(); + failed |= !checkProtocols(protocols, cv.supportedProtocols); + + System.out.println( + "\tChecking SSLEngine.getSupportedCipherSuites()"); + ciphers = socket.getSupportedCipherSuites(); + failed |= !checkCipherSuites(ciphers); + + // + // Check SSLServerSocket + // + // Check SSLParameters of SSLServerSocket + System.out.println(); + System.out.println("\tChecking SSLServerSocket of this SSLContext"); + System.out.println("\tChecking SSLServerSocket.getSSLParameters()"); + SSLServerSocketFactory sf = context.getServerSocketFactory(); + SSLServerSocket ssocket = (SSLServerSocket)sf.createServerSocket(); + parameters = ssocket.getSSLParameters(); + + protocols = parameters.getProtocols(); + failed |= !checkProtocols(protocols, cv.supportedProtocols); + + ciphers = parameters.getCipherSuites(); + failed |= !checkCipherSuites(ciphers); + + System.out.println("\tChecking SSLEngine.getEnabledProtocols()"); + protocols = ssocket.getEnabledProtocols(); + failed |= !checkProtocols(protocols, cv.supportedProtocols); + + System.out.println("\tChecking SSLEngine.getEnabledCipherSuites()"); + ciphers = ssocket.getEnabledCipherSuites(); + failed |= !checkCipherSuites(ciphers); + + System.out.println("\tChecking SSLEngine.getSupportedProtocols()"); + protocols = ssocket.getSupportedProtocols(); + failed |= !checkProtocols(protocols, cv.supportedProtocols); + + System.out.println( + "\tChecking SSLEngine.getSupportedCipherSuites()"); + ciphers = ssocket.getSupportedCipherSuites(); + failed |= !checkCipherSuites(ciphers); + } + + if (failed) { + throw new Exception("Run into problems, see log for more details"); + } else { + System.out.println("\t... Success"); + } + } +} diff --git a/jdk/test/sun/security/ssl/javax/net/ssl/SSLContextVersion.java b/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLContextImpl/SSLContextVersion.java similarity index 91% rename from jdk/test/sun/security/ssl/javax/net/ssl/SSLContextVersion.java rename to jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLContextImpl/SSLContextVersion.java index 003c3ab17da..3a9ba719b94 100644 --- a/jdk/test/sun/security/ssl/javax/net/ssl/SSLContextVersion.java +++ b/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLContextImpl/SSLContextVersion.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -21,24 +21,28 @@ * questions. */ +// SunJSSE does not support dynamic system properties, no way to re-use +// system properties in samevm/agentvm mode. + /* * @test * @bug 6976117 * @summary SSLContext.getInstance("TLSv1.1") returns SSLEngines/SSLSockets * without TLSv1.1 enabled + * @run main/othervm SSLContextVersion */ import javax.net.ssl.*; public class SSLContextVersion { static enum ContextVersion { - TLS_CV_01("SSL", "TLSv1", "TLSv1.2"), - TLS_CV_02("TLS", "TLSv1", "TLSv1.2"), + TLS_CV_01("SSL", "TLSv1.2", "TLSv1.2"), + TLS_CV_02("TLS", "TLSv1.2", "TLSv1.2"), TLS_CV_03("SSLv3", "TLSv1", "TLSv1.2"), TLS_CV_04("TLSv1", "TLSv1", "TLSv1.2"), TLS_CV_05("TLSv1.1", "TLSv1.1", "TLSv1.2"), TLS_CV_06("TLSv1.2", "TLSv1.2", "TLSv1.2"), - TLS_CV_07("Default", "TLSv1", "TLSv1.2"); + TLS_CV_07("Default", "TLSv1.2", "TLSv1.2"); final String contextVersion; final String defaultProtocolVersion; diff --git a/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLContextImpl/TrustTrustedCert.java b/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLContextImpl/TrustTrustedCert.java index ff8887c212a..01fc5dc5d86 100644 --- a/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLContextImpl/TrustTrustedCert.java +++ b/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLContextImpl/TrustTrustedCert.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 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 @@ -23,13 +23,15 @@ * questions. */ +// +// SunJSSE does not support dynamic system properties, no way to re-use +// system properties in samevm/agentvm mode. +// + /* * @test * @bug 7113275 * @summary compatibility issue with MD2 trust anchor and old X509TrustManager - * - * SunJSSE does not support dynamic system properties, no way to re-use - * system properties in samevm/agentvm mode. * @run main/othervm TrustTrustedCert PKIX TLSv1.1 * @run main/othervm TrustTrustedCert SunX509 TLSv1.1 * @run main/othervm TrustTrustedCert PKIX TLSv1.2 @@ -336,6 +338,10 @@ public class TrustTrustedCert { volatile Exception clientException = null; public static void main(String[] args) throws Exception { + // MD5 is used in this test case, don't disable MD5 algorithm. + Security.setProperty( + "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + if (debug) System.setProperty("javax.net.debug", "all"); diff --git a/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLEngineImpl/SSLEngineBadBufferArrayAccess.java b/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLEngineImpl/SSLEngineBadBufferArrayAccess.java index ee5efb9ddbe..45a6df001e8 100644 --- a/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLEngineImpl/SSLEngineBadBufferArrayAccess.java +++ b/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLEngineImpl/SSLEngineBadBufferArrayAccess.java @@ -148,14 +148,14 @@ public class SSLEngineBadBufferArrayAccess { "SSLv3", "TLSv1", "TLSv1.1", "TLSv1.2" }; for (String protocol : protocols) { - log("Testing " + protocol); /* * Run the tests with direct and indirect buffers. */ - SSLEngineBadBufferArrayAccess test = - new SSLEngineBadBufferArrayAccess(protocol); - test.runTest(true); - test.runTest(false); + log("Testing " + protocol + ":true"); + new SSLEngineBadBufferArrayAccess(protocol).runTest(true); + + log("Testing " + protocol + ":false"); + new SSLEngineBadBufferArrayAccess(protocol).runTest(false); } System.out.println("Test Passed."); diff --git a/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/NotifyHandshakeTest.sh b/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/NotifyHandshakeTest.sh index eff4930de4a..ee2381612d0 100644 --- a/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/NotifyHandshakeTest.sh +++ b/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/NotifyHandshakeTest.sh @@ -46,7 +46,7 @@ fi OS=`uname -s` case "$OS" in - SunOS | Linux | Darwin ) + SunOS | Linux | Darwin | AIX ) FILESEP="/" PATHSEP=":" ;; diff --git a/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/SSLSocketImplThrowsWrongExceptions.java b/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/SSLSocketImplThrowsWrongExceptions.java index 4c8ad80cbf7..1333561f7e6 100644 --- a/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/SSLSocketImplThrowsWrongExceptions.java +++ b/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/SSLSocketImplThrowsWrongExceptions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -21,15 +21,17 @@ * questions. */ +// +// SunJSSE does not support dynamic system properties, no way to re-use +// system properties in samevm/agentvm mode. +// + /* * @test * @bug 4361124 4325806 * @summary SSLServerSocket isn't throwing exceptions when negotiations are * failing & java.net.SocketException: occures in Auth and clientmode * @run main/othervm SSLSocketImplThrowsWrongExceptions - * - * SunJSSE does not support dynamic system properties, no way to re-use - * system properties in samevm/agentvm mode. * @author Brad Wetmore */ @@ -184,34 +186,76 @@ public class SSLSocketImplThrowsWrongExceptions { * Fork off the other side, then do your work. */ SSLSocketImplThrowsWrongExceptions () throws Exception { - if (separateServerThread) { - startServer(true); - startClient(false); - } else { - startClient(true); - startServer(false); + Exception startException = null; + try { + if (separateServerThread) { + startServer(true); + startClient(false); + } else { + startClient(true); + startServer(false); + } + } catch (Exception e) { + startException = e; } /* * Wait for other side to close down. */ if (separateServerThread) { - serverThread.join(); + if (serverThread != null) { + serverThread.join(); + } } else { - clientThread.join(); + if (clientThread != null) { + clientThread.join(); + } } /* * When we get here, the test is pretty much over. - * - * If the main thread excepted, that propagates back - * immediately. If the other thread threw an exception, we - * should report back. + * Which side threw the error? */ - if (serverException != null) - throw serverException; - if (clientException != null) - throw clientException; + Exception local; + Exception remote; + + if (separateServerThread) { + remote = serverException; + local = clientException; + } else { + remote = clientException; + local = serverException; + } + + Exception exception = null; + + /* + * Check various exception conditions. + */ + if ((local != null) && (remote != null)) { + // If both failed, return the curthread's exception. + local.initCause(remote); + exception = local; + } else if (local != null) { + exception = local; + } else if (remote != null) { + exception = remote; + } else if (startException != null) { + exception = startException; + } + + /* + * If there was an exception *AND* a startException, + * output it. + */ + if (exception != null) { + if (exception != startException && startException != null) { + exception.addSuppressed(startException); + } + throw exception; + } + + // Fall-through: no exception to throw! } void startServer(boolean newThread) throws Exception { @@ -226,7 +270,7 @@ public class SSLSocketImplThrowsWrongExceptions { * * Release the client, if not active already... */ - System.out.println("Server died..."); + System.err.println("Server died..."); serverReady = true; serverException = e; } @@ -234,7 +278,13 @@ public class SSLSocketImplThrowsWrongExceptions { }; serverThread.start(); } else { - doServerSide(); + try { + doServerSide(); + } catch (Exception e) { + serverException = e; + } finally { + serverReady = true; + } } } @@ -248,14 +298,18 @@ public class SSLSocketImplThrowsWrongExceptions { /* * Our client thread just died. */ - System.out.println("Client died..."); + System.err.println("Client died..."); clientException = e; } } }; clientThread.start(); } else { - doClientSide(); + try { + doClientSide(); + } catch (Exception e) { + clientException = e; + } } } } diff --git a/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/X509KeyManager/PreferredKey.java b/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/X509KeyManager/PreferredKey.java index 4ac150b4208..47e1e775856 100644 --- a/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/X509KeyManager/PreferredKey.java +++ b/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/X509KeyManager/PreferredKey.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 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 @@ -21,11 +21,18 @@ * questions. */ +// +// Security properties, once set, cannot revert to unset. To avoid +// conflicts with tests running in the same VM isolate this test by +// running it in otherVM mode. +// + /* * @test * @bug 6302644 * @summary X509KeyManager implementation for NewSunX509 doesn't return most * preferable key + * @run main/othervm PreferredKey */ import java.io.*; import java.net.*; @@ -49,6 +56,10 @@ public class PreferredKey { public static void main(String[] args) throws Exception { + // MD5 is used in this test case, don't disable MD5 algorithm. + Security.setProperty( + "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + KeyStore ks; KeyManagerFactory kmf; X509KeyManager km; diff --git a/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/X509TrustManagerImpl/BasicConstraints.java b/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/X509TrustManagerImpl/BasicConstraints.java index 8f1e71622c4..4f64cd1b758 100644 --- a/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/X509TrustManagerImpl/BasicConstraints.java +++ b/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/X509TrustManagerImpl/BasicConstraints.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 @@ -21,14 +21,16 @@ * questions. */ +// +// SunJSSE does not support dynamic system properties, no way to re-use +// system properties in samevm/agentvm mode. +// + /* * @test * @bug 7166570 * @summary JSSE certificate validation has started to fail for * certificate chains - * - * SunJSSE does not support dynamic system properties, no way to re-use - * system properties in samevm/agentvm mode. * @run main/othervm BasicConstraints PKIX * @run main/othervm BasicConstraints SunX509 */ @@ -37,6 +39,7 @@ import java.net.*; import java.util.*; import java.io.*; import javax.net.ssl.*; +import java.security.Security; import java.security.KeyStore; import java.security.KeyFactory; import java.security.cert.*; @@ -454,6 +457,10 @@ public class BasicConstraints { volatile Exception clientException = null; public static void main(String args[]) throws Exception { + // MD5 is used in this test case, don't disable MD5 algorithm. + Security.setProperty( + "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + if (debug) System.setProperty("javax.net.debug", "all"); diff --git a/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/X509TrustManagerImpl/PKIXExtendedTM.java b/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/X509TrustManagerImpl/PKIXExtendedTM.java index aaf5fb2447d..3b2587f6913 100644 --- a/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/X509TrustManagerImpl/PKIXExtendedTM.java +++ b/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/X509TrustManagerImpl/PKIXExtendedTM.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,21 +21,23 @@ * questions. */ +// +// SunJSSE does not support dynamic system properties, no way to re-use +// system properties in samevm/agentvm mode. +// /* * @test * @bug 6916074 * @summary Add support for TLS 1.2 * @run main/othervm PKIXExtendedTM - * - * SunJSSE does not support dynamic system properties, no way to re-use - * system properties in samevm/agentvm mode. */ import java.net.*; import java.util.*; import java.io.*; import javax.net.ssl.*; +import java.security.Security; import java.security.KeyStore; import java.security.KeyFactory; import java.security.cert.Certificate; @@ -791,6 +793,10 @@ public class PKIXExtendedTM { volatile Exception clientException = null; public static void main(String args[]) throws Exception { + // MD5 is used in this test case, don't disable MD5 algorithm. + Security.setProperty( + "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + if (debug) System.setProperty("javax.net.debug", "all"); diff --git a/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/X509TrustManagerImpl/SelfIssuedCert.java b/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/X509TrustManagerImpl/SelfIssuedCert.java index 1f8f7298383..a17541212b6 100644 --- a/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/X509TrustManagerImpl/SelfIssuedCert.java +++ b/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/X509TrustManagerImpl/SelfIssuedCert.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,15 +21,17 @@ * questions. */ +// +// SunJSSE does not support dynamic system properties, no way to re-use +// system properties in samevm/agentvm mode. +// + /* * @test * @bug 6822460 * @summary support self-issued certificate * @run main/othervm SelfIssuedCert PKIX * @run main/othervm SelfIssuedCert SunX509 - * - * SunJSSE does not support dynamic system properties, no way to re-use - * system properties in samevm/agentvm mode. * @author Xuelei Fan */ @@ -37,6 +39,7 @@ import java.net.*; import java.util.*; import java.io.*; import javax.net.ssl.*; +import java.security.Security; import java.security.KeyStore; import java.security.KeyFactory; import java.security.cert.Certificate; @@ -302,6 +305,10 @@ public class SelfIssuedCert { volatile Exception clientException = null; public static void main(String args[]) throws Exception { + // MD5 is used in this test case, don't disable MD5 algorithm. + Security.setProperty( + "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + if (debug) System.setProperty("javax.net.debug", "all"); diff --git a/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/X509TrustManagerImpl/SunX509ExtendedTM.java b/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/X509TrustManagerImpl/SunX509ExtendedTM.java index 561718fe59e..54b2de89219 100644 --- a/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/X509TrustManagerImpl/SunX509ExtendedTM.java +++ b/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/X509TrustManagerImpl/SunX509ExtendedTM.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,20 +21,23 @@ * questions. */ +// +// SunJSSE does not support dynamic system properties, no way to re-use +// system properties in samevm/agentvm mode. +// + /* * @test * @bug 6916074 * @summary Add support for TLS 1.2 * @run main/othervm SunX509ExtendedTM - * - * SunJSSE does not support dynamic system properties, no way to re-use - * system properties in samevm/agentvm mode. */ import java.net.*; import java.util.*; import java.io.*; import javax.net.ssl.*; +import java.security.Security; import java.security.KeyStore; import java.security.KeyFactory; import java.security.cert.Certificate; @@ -792,6 +795,10 @@ public class SunX509ExtendedTM { volatile Exception clientException = null; public static void main(String args[]) throws Exception { + // MD5 is used in this test case, don't disable MD5 algorithm. + Security.setProperty( + "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + if (debug) System.setProperty("javax.net.debug", "all"); diff --git a/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/www/protocol/https/HttpsURLConnection/CriticalSubjectAltName.java b/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/www/protocol/https/HttpsURLConnection/CriticalSubjectAltName.java index e01115224c5..f9abcd670b2 100644 --- a/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/www/protocol/https/HttpsURLConnection/CriticalSubjectAltName.java +++ b/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/www/protocol/https/HttpsURLConnection/CriticalSubjectAltName.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2011, 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 @@ -21,18 +21,21 @@ * questions. */ +// +// SunJSSE does not support dynamic system properties, no way to re-use +// system properties in samevm/agentvm mode. +// + /* * @test * @bug 6668231 * @summary Presence of a critical subjectAltName causes JSSE's SunX509 to * fail trusted checks * @run main/othervm CriticalSubjectAltName - * - * SunJSSE does not support dynamic system properties, no way to re-use - * system properties in samevm/agentvm mode. - * * @author Xuelei Fan - * + */ + +/* * This test depends on binary keystore, crisubn.jks and trusted.jks. Because * JAVA keytool cannot generate X509 certificate with SubjectAltName extension, * the certificates are generated with openssl toolkits and then imported into @@ -47,6 +50,7 @@ import java.io.*; import java.net.*; import javax.net.ssl.*; +import java.security.Security; import java.security.cert.Certificate; public class CriticalSubjectAltName implements HostnameVerifier { @@ -154,6 +158,10 @@ public class CriticalSubjectAltName implements HostnameVerifier { volatile Exception clientException = null; public static void main(String[] args) throws Exception { + // MD5 is used in this test case, don't disable MD5 algorithm. + Security.setProperty( + "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + String keyFilename = System.getProperty("test.src", "./") + "/" + pathToStores + "/" + keyStoreFile; diff --git a/jdk/test/sun/security/ssl/javax/net/ssl/ServerName/SSLSocketSNISensitive.java b/jdk/test/sun/security/ssl/javax/net/ssl/ServerName/SSLSocketSNISensitive.java index 1b93237a544..ac4f8a11ab1 100644 --- a/jdk/test/sun/security/ssl/javax/net/ssl/ServerName/SSLSocketSNISensitive.java +++ b/jdk/test/sun/security/ssl/javax/net/ssl/ServerName/SSLSocketSNISensitive.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 @@ -44,6 +44,7 @@ import java.net.*; import java.util.*; import java.io.*; import javax.net.ssl.*; +import java.security.Security; import java.security.KeyStore; import java.security.KeyFactory; import java.security.cert.Certificate; @@ -431,6 +432,10 @@ public class SSLSocketSNISensitive { volatile Exception clientException = null; public static void main(String[] args) throws Exception { + // MD5 is used in this test case, don't disable MD5 algorithm. + Security.setProperty( + "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + if (debug) System.setProperty("javax.net.debug", "all"); diff --git a/jdk/test/sun/security/ssl/javax/net/ssl/TLSv11/EmptyCertificateAuthorities.java b/jdk/test/sun/security/ssl/javax/net/ssl/TLSv11/EmptyCertificateAuthorities.java index 07503cb7c03..3b11d2a59a7 100644 --- a/jdk/test/sun/security/ssl/javax/net/ssl/TLSv11/EmptyCertificateAuthorities.java +++ b/jdk/test/sun/security/ssl/javax/net/ssl/TLSv11/EmptyCertificateAuthorities.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,15 +23,16 @@ * questions. */ +// +// SunJSSE does not support dynamic system properties, no way to re-use +// system properties in samevm/agentvm mode. +// + /* * @test * @bug 4873188 * @summary Support TLS 1.1 * @run main/othervm EmptyCertificateAuthorities - * - * SunJSSE does not support dynamic system properties, no way to re-use - * system properties in samevm/agentvm mode. - * * @author Xuelei Fan */ @@ -228,6 +229,10 @@ public class EmptyCertificateAuthorities { volatile Exception clientException = null; public static void main(String[] args) throws Exception { + // MD5 is used in this test case, don't disable MD5 algorithm. + Security.setProperty( + "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + String keyFilename = System.getProperty("test.src", ".") + "/" + pathToStores + "/" + keyStoreFile; diff --git a/jdk/test/sun/security/ssl/sanity/ciphersuites/CipherSuitesInOrder.java b/jdk/test/sun/security/ssl/sanity/ciphersuites/CipherSuitesInOrder.java index 361ac866803..012fe96720e 100644 --- a/jdk/test/sun/security/ssl/sanity/ciphersuites/CipherSuitesInOrder.java +++ b/jdk/test/sun/security/ssl/sanity/ciphersuites/CipherSuitesInOrder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,12 +35,28 @@ import java.util.*; import javax.net.ssl.*; +import java.security.Security; public class CipherSuitesInOrder { // supported ciphersuites private final static List supportedCipherSuites = Arrays.asList( + "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", + "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", + "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", + "TLS_RSA_WITH_AES_256_GCM_SHA384", + "TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384", + "TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384", + "TLS_DHE_RSA_WITH_AES_256_GCM_SHA384", + "TLS_DHE_DSS_WITH_AES_256_GCM_SHA384", + "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", + "TLS_RSA_WITH_AES_128_GCM_SHA256", + "TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256", + "TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256", + "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256", + "TLS_DHE_DSS_WITH_AES_128_GCM_SHA256", + "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384", "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384", "TLS_RSA_WITH_AES_256_CBC_SHA256", @@ -75,21 +91,6 @@ public class CipherSuitesInOrder { "TLS_ECDH_ECDSA_WITH_RC4_128_SHA", "TLS_ECDH_RSA_WITH_RC4_128_SHA", - "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", - "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", - "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", - "TLS_RSA_WITH_AES_256_GCM_SHA384", - "TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384", - "TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384", - "TLS_DHE_RSA_WITH_AES_256_GCM_SHA384", - "TLS_DHE_DSS_WITH_AES_256_GCM_SHA384", - "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", - "TLS_RSA_WITH_AES_128_GCM_SHA256", - "TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256", - "TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256", - "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256", - "TLS_DHE_DSS_WITH_AES_128_GCM_SHA256", - "TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA", "TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA", "SSL_RSA_WITH_3DES_EDE_CBC_SHA", diff --git a/jdk/test/sun/security/ssl/sanity/interop/ClientJSSEServerJSSE.java b/jdk/test/sun/security/ssl/sanity/interop/ClientJSSEServerJSSE.java index 953d2ea8e5f..ca2f1885fdd 100644 --- a/jdk/test/sun/security/ssl/sanity/interop/ClientJSSEServerJSSE.java +++ b/jdk/test/sun/security/ssl/sanity/interop/ClientJSSEServerJSSE.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 @@ -28,10 +28,15 @@ * @author Andreas Sterbenz * @run main/othervm/timeout=300 ClientJSSEServerJSSE */ +import java.security.Security; public class ClientJSSEServerJSSE { public static void main(String[] args) throws Exception { + // MD5 is used in this test case, don't disable MD5 algorithm. + Security.setProperty( + "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + CipherTest.main(new JSSEFactory(), args); } diff --git a/jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/DNSIdentities.java b/jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/DNSIdentities.java index 4e740fa4d84..b5295f31cf5 100644 --- a/jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/DNSIdentities.java +++ b/jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/DNSIdentities.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,13 +21,15 @@ * questions. */ +// +// SunJSSE does not support dynamic system properties, no way to re-use +// system properties in samevm/agentvm mode. +// + /* @test * @bug 6766775 * @summary X509 certificate hostname checking is broken in JDK1.6.0_10 * @run main/othervm DNSIdentities - * - * SunJSSE does not support dynamic system properties, no way to re-use - * system properties in samevm/agentvm mode. * @author Xuelei Fan */ @@ -35,6 +37,7 @@ import java.net.*; import java.util.*; import java.io.*; import javax.net.ssl.*; +import java.security.Security; import java.security.KeyStore; import java.security.KeyFactory; import java.security.cert.Certificate; @@ -743,6 +746,10 @@ public class DNSIdentities { volatile Exception clientException = null; public static void main(String args[]) throws Exception { + // MD5 is used in this test case, don't disable MD5 algorithm. + Security.setProperty( + "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + if (debug) System.setProperty("javax.net.debug", "all"); diff --git a/jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/IPAddressIPIdentities.java b/jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/IPAddressIPIdentities.java index 2fc92a254c9..bbf6892c43b 100644 --- a/jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/IPAddressIPIdentities.java +++ b/jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/IPAddressIPIdentities.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,13 +21,15 @@ * questions. */ +// +// SunJSSE does not support dynamic system properties, no way to re-use +// system properties in samevm/agentvm mode. +// + /* @test * @summary X509 certificate hostname checking is broken in JDK1.6.0_10 * @bug 6766775 * @run main/othervm IPAddressIPIdentities - * - * SunJSSE does not support dynamic system properties, no way to re-use - * system properties in samevm/agentvm mode. * @author Xuelei Fan */ @@ -35,6 +37,7 @@ import java.net.*; import java.util.*; import java.io.*; import javax.net.ssl.*; +import java.security.Security; import java.security.KeyStore; import java.security.KeyFactory; import java.security.cert.Certificate; @@ -744,6 +747,10 @@ public class IPAddressIPIdentities { volatile Exception clientException = null; public static void main(String args[]) throws Exception { + // MD5 is used in this test case, don't disable MD5 algorithm. + Security.setProperty( + "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + if (debug) System.setProperty("javax.net.debug", "all"); diff --git a/jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/IPIdentities.java b/jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/IPIdentities.java index 1d93e9c6ed6..c0d897b5fac 100644 --- a/jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/IPIdentities.java +++ b/jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/IPIdentities.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,13 +21,15 @@ * questions. */ +// +// SunJSSE does not support dynamic system properties, no way to re-use +// system properties in samevm/agentvm mode. +// + /* @test * @summary X509 certificate hostname checking is broken in JDK1.6.0_10 * @bug 6766775 * @run main/othervm IPIdentities - * - * SunJSSE does not support dynamic system properties, no way to re-use - * system properties in samevm/agentvm mode. * @author Xuelei Fan */ @@ -35,6 +37,7 @@ import java.net.*; import java.util.*; import java.io.*; import javax.net.ssl.*; +import java.security.Security; import java.security.KeyStore; import java.security.KeyFactory; import java.security.cert.Certificate; @@ -743,6 +746,10 @@ public class IPIdentities { volatile Exception clientException = null; public static void main(String args[]) throws Exception { + // MD5 is used in this test case, don't disable MD5 algorithm. + Security.setProperty( + "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + if (debug) System.setProperty("javax.net.debug", "all"); diff --git a/jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/Identities.java b/jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/Identities.java index e7396d5f339..55dfb1c04dc 100644 --- a/jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/Identities.java +++ b/jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/Identities.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,13 +21,15 @@ * questions. */ +// +// SunJSSE does not support dynamic system properties, no way to re-use +// system properties in samevm/agentvm mode. +// + /* @test * @bug 6766775 * @summary X509 certificate hostname checking is broken in JDK1.6.0_10 * @run main/othervm Identities - * - * SunJSSE does not support dynamic system properties, no way to re-use - * system properties in samevm/agentvm mode. * @author Xuelei Fan */ @@ -35,6 +37,7 @@ import java.net.*; import java.util.*; import java.io.*; import javax.net.ssl.*; +import java.security.Security; import java.security.KeyStore; import java.security.KeyFactory; import java.security.cert.Certificate; @@ -743,6 +746,10 @@ public class Identities { volatile Exception clientException = null; public static void main(String args[]) throws Exception { + // MD5 is used in this test case, don't disable MD5 algorithm. + Security.setProperty( + "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + if (debug) System.setProperty("javax.net.debug", "all"); diff --git a/jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/PostThruProxy.sh b/jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/PostThruProxy.sh index 4cdc5d4d1b7..1b7cf984e8b 100644 --- a/jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/PostThruProxy.sh +++ b/jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/PostThruProxy.sh @@ -32,7 +32,7 @@ HOSTNAME=`uname -n` OS=`uname -s` case "$OS" in - SunOS | Linux | Darwin ) + SunOS | Linux | Darwin | AIX ) PS=":" FS="/" ;; diff --git a/jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/PostThruProxyWithAuth.sh b/jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/PostThruProxyWithAuth.sh index de7b039488c..fd24c76a475 100644 --- a/jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/PostThruProxyWithAuth.sh +++ b/jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/PostThruProxyWithAuth.sh @@ -32,7 +32,7 @@ HOSTNAME=`uname -n` OS=`uname -s` case "$OS" in - SunOS | Linux | Darwin ) + SunOS | Linux | Darwin | AIX ) PS=":" FS="/" ;; diff --git a/jdk/test/sun/security/ssl/templates/SSLSocketSSLEngineTemplate.java b/jdk/test/sun/security/ssl/templates/SSLSocketSSLEngineTemplate.java index 16696dbe414..d61a1e5345e 100644 --- a/jdk/test/sun/security/ssl/templates/SSLSocketSSLEngineTemplate.java +++ b/jdk/test/sun/security/ssl/templates/SSLSocketSSLEngineTemplate.java @@ -221,6 +221,9 @@ public class SSLSocketSSLEngineTemplate { try { boolean closed = false; + // will try to read one more time in case client message + // is fragmented to multiple pieces + boolean retry = true; InputStream is = socket.getInputStream(); OutputStream os = socket.getOutputStream(); @@ -295,8 +298,14 @@ public class SSLSocketSSLEngineTemplate { /* * A sanity check to ensure we got what was sent. */ - if (serverIn.remaining() != clientMsg.length) { - throw new Exception("Client: Data length error"); + if (serverIn.remaining() != clientMsg.length) { + if (retry && serverIn.remaining() < clientMsg.length) { + log("Need to read more from client"); + retry = false; + continue; + } else { + throw new Exception("Client: Data length error"); + } } for (int i = 0; i < clientMsg.length; i++) { diff --git a/jdk/test/sun/security/tools/jarsigner/AlgOptions.sh b/jdk/test/sun/security/tools/jarsigner/AlgOptions.sh index b6f8c8b3ff2..9b16831d799 100644 --- a/jdk/test/sun/security/tools/jarsigner/AlgOptions.sh +++ b/jdk/test/sun/security/tools/jarsigner/AlgOptions.sh @@ -46,7 +46,7 @@ fi # set platform-dependent variables OS=`uname -s` case "$OS" in - SunOS | Linux | Darwin ) + SunOS | Linux | Darwin | AIX ) NULL=/dev/null PS=":" FS="/" diff --git a/jdk/test/sun/security/tools/jarsigner/EntriesOrder.java b/jdk/test/sun/security/tools/jarsigner/EntriesOrder.java new file mode 100644 index 00000000000..96c90e98e12 --- /dev/null +++ b/jdk/test/sun/security/tools/jarsigner/EntriesOrder.java @@ -0,0 +1,199 @@ +/* + * 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 8031572 + * @summary jarsigner -verify exits with 0 when a jar file is not properly signed + */ + +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.security.cert.Certificate; +import java.util.*; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; +import java.util.jar.JarInputStream; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; + +public class EntriesOrder { + + public static void main(String[] args) throws Exception { + + String[] entries = { + "META-INF/", + "META-INF/MANIFEST.MF", + "META-INF/A.RSA", + "META-INF/A.SF", + "META-INF/inf", + "a"}; + + Map content = new HashMap<>(); + + // We will create a jar containing entries above. Try all permutations + // and confirm 1) When opened as a JarFile, we can always get 3 signed + // ones (MANIFEST, inf, a), and 2) When opened as a JarInputStream, + // when the order is correct (MANIFEST at beginning, followed by RSA/SF, + // directory ignored), we can get 2 signed ones (inf, a). + + // Prepares raw files + Files.write(Paths.get("a"), "a".getBytes()); + Files.createDirectory(Paths.get("META-INF/")); + Files.write(Paths.get("META-INF/inf"), "inf".getBytes()); + + // Pack, sign, and extract to get all files + sun.tools.jar.Main m = + new sun.tools.jar.Main(System.out, System.err, "jar"); + if (!m.run("cvf a.jar a META-INF/inf".split(" "))) { + throw new Exception("jar creation failed"); + } + sun.security.tools.keytool.Main.main( + ("-keystore jks -storepass changeit -keypass changeit -dname" + + " CN=A -alias a -genkeypair -keyalg rsa").split(" ")); + sun.security.tools.jarsigner.Main.main( + "-keystore jks -storepass changeit a.jar a".split(" ")); + m = new sun.tools.jar.Main(System.out, System.err, "jar"); + if (!m.run("xvf a.jar".split(" "))) { + throw new Exception("jar extraction failed"); + } + + // Data + for (String s: entries) { + if (!s.endsWith("/")) { + content.put(s, Files.readAllBytes(Paths.get(s))); + } + } + + // Test + for (List perm: Permute(entries)) { + + // Recreate a jar + try (ZipOutputStream zos + = new ZipOutputStream(new FileOutputStream("x.jar"))) { + for (String e: perm) { + zos.putNextEntry(new ZipEntry(e)); + if (Paths.get(e).toFile().isDirectory()) continue; + zos.write(content.get(e)); + } + } + + // Open with JarFile, number of signed entries should be 3. + int cc = 0; + try (JarFile jf = new JarFile("x.jar")) { + Enumeration jes = jf.entries(); + while (jes.hasMoreElements()) { + JarEntry je = jes.nextElement(); + sun.misc.IOUtils.readFully(jf.getInputStream(je), -1, true); + Certificate[] certs = je.getCertificates(); + if (certs != null && certs.length > 0) { + cc++; + } + } + } + + if (cc != 3) { + System.out.println(perm + " - jf - " + cc); + throw new Exception(); + } + + // Open with JarInputStream + int signed; + + perm.remove("META-INF/"); + if (perm.get(0).equals("META-INF/MANIFEST.MF") && + perm.get(1).contains("/A.") && + perm.get(2).contains("/A.")) { + signed = 2; // Good order + } else { + signed = 0; // Bad order. In this case, the number of signed + // entries is not documented. Just test impl. + } + + cc = 0; + try (JarInputStream jis + = new JarInputStream(new FileInputStream("x.jar"))) { + while (true) { + JarEntry je = jis.getNextJarEntry(); + if (je == null) break; + sun.misc.IOUtils.readFully(jis, -1, true); + Certificate[] certs = je.getCertificates(); + if (certs != null && certs.length > 0) { + cc++; + } + } + } + + if (cc != signed) { + System.out.println(perm + " - jis - " + cc + " " + signed); + throw new Exception(); + } + } + } + + // Helper method to return all permutations of an array. Each output can + // be altered without damaging the iteration process. + static Iterable> Permute(String[] entries) { + return new Iterable>() { + + int s = entries.length; + long c = factorial(s) - 1; // number of permutations + + private long factorial(int n) { + return (n == 1) ? 1: (n * factorial(n-1)); + } + + @Override + public Iterator> iterator() { + return new Iterator>() { + @Override + public boolean hasNext() { + return c >= 0; + } + + @Override + public List next() { + if (c < 0) return null; + List result = new ArrayList<>(s); + LinkedList source = new LinkedList<>( + Arrays.asList(entries)); + // Treat c as a integer with different radixes at + // different digits, i.e. at digit 0, radix is s; + // at digit 1, radix is s-1. Thus a s-digit number + // is able to represent s! different values. + long n = c; + for (int i=s; i>=1; i--) { + int x = (int)(n % i); + result.add(source.remove(x)); + n = n / i; + } + c--; + return result; + } + }; + } + }; + } +} diff --git a/jdk/test/sun/security/tools/jarsigner/PercentSign.sh b/jdk/test/sun/security/tools/jarsigner/PercentSign.sh index 559c0533e73..38d9ece9bbc 100644 --- a/jdk/test/sun/security/tools/jarsigner/PercentSign.sh +++ b/jdk/test/sun/security/tools/jarsigner/PercentSign.sh @@ -46,7 +46,7 @@ fi # set platform-dependent variables OS=`uname -s` case "$OS" in - SunOS | Linux | Darwin ) + SunOS | Linux | Darwin | AIX ) NULL=/dev/null PS=":" FS="/" diff --git a/jdk/test/sun/security/tools/jarsigner/TimestampCheck.java b/jdk/test/sun/security/tools/jarsigner/TimestampCheck.java index 2b04e918819..309252e2523 100644 --- a/jdk/test/sun/security/tools/jarsigner/TimestampCheck.java +++ b/jdk/test/sun/security/tools/jarsigner/TimestampCheck.java @@ -239,13 +239,13 @@ public class TimestampCheck { " -J-Djava.security.egd=file:/dev/./urandom" + " -debug -keystore " + TSKS + " -storepass changeit" + " -tsa http://localhost:" + port + "/%d" + - " -signedjar new.jar " + JAR + " old"; + " -signedjar new_%d.jar " + JAR + " old"; } else { cmd = System.getProperty("java.home") + "/bin/jarsigner" + " -J-Djava.security.egd=file:/dev/./urandom" + " -debug -keystore " + TSKS + " -storepass changeit" + " -tsa http://localhost:" + port + "/%d" + - " -signedjar new.jar " + JAR + " old"; + " -signedjar new_%d.jar " + JAR + " old"; } try { @@ -280,7 +280,7 @@ public class TimestampCheck { static void jarsigner(String cmd, int path, boolean expected) throws Exception { System.err.println("Test " + path); - Process p = Runtime.getRuntime().exec(String.format(cmd, path)); + Process p = Runtime.getRuntime().exec(String.format(cmd, path, path)); BufferedReader reader = new BufferedReader( new InputStreamReader(p.getErrorStream())); while (true) { @@ -288,9 +288,25 @@ public class TimestampCheck { if (s == null) break; System.err.println(s); } + + // Will not see noTimestamp warning + boolean seeWarning = false; + reader = new BufferedReader( + new InputStreamReader(p.getInputStream())); + while (true) { + String s = reader.readLine(); + if (s == null) break; + System.err.println(s); + if (s.indexOf("Warning:") >= 0) { + seeWarning = true; + } + } int result = p.waitFor(); if (expected && result != 0 || !expected && result == 0) { throw new Exception("Failed"); } + if (seeWarning) { + throw new Exception("See warning"); + } } } diff --git a/jdk/test/sun/security/tools/jarsigner/concise_jarsigner.sh b/jdk/test/sun/security/tools/jarsigner/concise_jarsigner.sh index 5fbb7d0b9c4..df6a5739030 100644 --- a/jdk/test/sun/security/tools/jarsigner/concise_jarsigner.sh +++ b/jdk/test/sun/security/tools/jarsigner/concise_jarsigner.sh @@ -139,7 +139,6 @@ LINES=`$JARSIGNER -verify a.jar -verbose:summary -certs | grep "more)" | wc -l` # 16 and 32 already covered in the first part # ========================================================== -$KT -genkeypair -alias expiring -dname CN=expiring -startdate -1m $KT -genkeypair -alias expired -dname CN=expired -startdate -10m $KT -genkeypair -alias notyetvalid -dname CN=notyetvalid -startdate +1m $KT -genkeypair -alias badku -dname CN=badku -ext KU=cRLSign -validity 365 @@ -154,9 +153,6 @@ $KT -certreq -alias badchain | $KT -gencert -alias ca -validity 365 | \ $KT -importcert -alias badchain $KT -delete -alias ca -$JARSIGNER -strict -keystore js.jks -storepass changeit a.jar expiring -[ $? = 2 ] || exit $LINENO - $JARSIGNER -strict -keystore js.jks -storepass changeit a.jar expired [ $? = 4 ] || exit $LINENO diff --git a/jdk/test/sun/security/tools/jarsigner/diffend.sh b/jdk/test/sun/security/tools/jarsigner/diffend.sh index 0f943796af4..787b58680f3 100644 --- a/jdk/test/sun/security/tools/jarsigner/diffend.sh +++ b/jdk/test/sun/security/tools/jarsigner/diffend.sh @@ -41,7 +41,7 @@ fi # set platform-dependent variables OS=`uname -s` case "$OS" in - SunOS | Linux | Darwin ) + SunOS | Linux | Darwin | AIX ) NULL=/dev/null PS=":" FS="/" diff --git a/jdk/test/sun/security/tools/jarsigner/oldsig.sh b/jdk/test/sun/security/tools/jarsigner/oldsig.sh index aae758cb937..062c2aa21d9 100644 --- a/jdk/test/sun/security/tools/jarsigner/oldsig.sh +++ b/jdk/test/sun/security/tools/jarsigner/oldsig.sh @@ -42,7 +42,7 @@ fi # set platform-dependent variables OS=`uname -s` case "$OS" in - SunOS | Linux | Darwin ) + SunOS | Linux | Darwin | AIX ) NULL=/dev/null PS=":" FS="/" diff --git a/jdk/test/sun/security/tools/jarsigner/ts.sh b/jdk/test/sun/security/tools/jarsigner/ts.sh index b38922692ec..0b89f3dd631 100644 --- a/jdk/test/sun/security/tools/jarsigner/ts.sh +++ b/jdk/test/sun/security/tools/jarsigner/ts.sh @@ -22,7 +22,7 @@ # # @test -# @bug 6543842 6543440 6939248 8009636 +# @bug 6543842 6543440 6939248 8009636 8024302 # @summary checking response of timestamp # # @run shell/timeout=600 ts.sh @@ -53,7 +53,7 @@ fi JAR="${TESTJAVA}${FS}bin${FS}jar" JAVA="${TESTJAVA}${FS}bin${FS}java" JAVAC="${TESTJAVA}${FS}bin${FS}javac" -KT="${TESTJAVA}${FS}bin${FS}keytool -keystore tsks -storepass changeit -keypass changeit -keyalg rsa" +KT="${TESTJAVA}${FS}bin${FS}keytool -keystore tsks -storepass changeit -keypass changeit -keyalg rsa -validity 200" rm tsks echo Nothing > A diff --git a/jdk/test/sun/security/tools/jarsigner/warnings.sh b/jdk/test/sun/security/tools/jarsigner/warnings.sh new file mode 100644 index 00000000000..fbe745585ae --- /dev/null +++ b/jdk/test/sun/security/tools/jarsigner/warnings.sh @@ -0,0 +1,119 @@ +# +# Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +# @test +# @bug 8024302 +# @bug 8026037 +# @summary Clarify jar verifications +# + +if [ "${TESTJAVA}" = "" ] ; then + JAVAC_CMD=`which javac` + TESTJAVA=`dirname $JAVAC_CMD`/.. +fi + +# set platform-dependent variables +OS=`uname -s` +case "$OS" in + Windows_* ) + FS="\\" + ;; + * ) + FS="/" + ;; +esac + +KS=warnings.jks +JFILE=warnings.jar + +KT="$TESTJAVA${FS}bin${FS}keytool -storepass changeit -keypass changeit \ + -keystore $KS" +JAR=$TESTJAVA${FS}bin${FS}jar +JARSIGNER="$TESTJAVA${FS}bin${FS}jarsigner -keystore $KS -storepass changeit" + +rm $KS 2> /dev/null + +LANG=C +export LANG + +echo 12345 > file + +ERR="" + +# Normal signer expiring on 2100-01-01 +$KT -alias s1 -dname CN=s1 -genkey -startdate 2000/01/01 -validity 36525 || ERR="$ERR keytool s1," +# Cert expiring soon, informational warning +$KT -alias s2 -dname CN=s2 -genkey -validity 100 || ERR="$ERR keytool s2," +# Cert expired, severe warning +$KT -alias s3 -dname CN=s3 -genkey -startdate -200d -validity 100 || ERR="$ERR keytool s3," + +# noTimestamp is informatiional warning and includes a date +$JAR cvf $JFILE file +$JARSIGNER $JFILE s1 > output1 || ERR="$ERR jarsigner s1," +$JARSIGNER -strict $JFILE s1 >> output1 || ERR="$ERR jarsigner s1 strict," +$JARSIGNER -verify $JFILE s1 >> output1 || ERR="$ERR jarsigner s1," +$JARSIGNER -verify -strict $JFILE s1 >> output1 || ERR="$ERR jarsigner s1 strict," + +cat output1 | grep Warning || ERR="$ERR s1 warning," +cat output1 | grep Error && ERR="$ERR s1 error," +cat output1 | grep timestamp | grep 2100-01-01 || ERR="$ERR s1 timestamp," +cat output1 | grep "with signer errors" && ERR="$ERR s1 err," + +# hasExpiringCert is informatiional warning +$JAR cvf $JFILE file +$JARSIGNER $JFILE s2 > output2 || ERR="$ERR jarsigner s2," +$JARSIGNER -strict $JFILE s2 >> output2 || ERR="$ERR jarsigner s2 strict," +$JARSIGNER -verify $JFILE s2 >> output2 || ERR="$ERR jarsigner s2," +$JARSIGNER -verify -strict $JFILE s2 >> output2 || ERR="$ERR jarsigner s2 strict," + +cat output2 | grep Warning || ERR="$ERR s2 warning," +cat output2 | grep Error && ERR="$ERR s2 error," +cat output2 | grep timestamp || ERR="$ERR s2 timestamp," +cat output2 | grep "will expire" || ERR="$ERR s2 expiring," +cat output2 | grep "with signer errors" && ERR="$ERR s2 err," + +# hasExpiredCert is severe warning +$JAR cvf $JFILE file +$JARSIGNER $JFILE s3 > output3 || ERR="$ERR jarsigner s3," +$JARSIGNER -strict $JFILE s3 > output3s && ERR="$ERR jarsigner s3 strict," +$JARSIGNER -verify $JFILE s3 >> output3 || ERR="$ERR jarsigner s3," +$JARSIGNER -verify -strict $JFILE s3 >> output3s && ERR="$ERR jarsigner s3 strict," + +# warning without -strict +cat output3 | grep Warning || ERR="$ERR s3 warning," +cat output3 | grep Error && ERR="$ERR s3 error," +cat output3 | grep "with signer errors" && ERR="$ERR s3 err," + +# error with -strict +cat output3s | grep Warning || ERR="$ERR s3s warning," +cat output3s | grep Error || ERR="$ERR s3s error," +cat output3s | grep "with signer errors" || ERR="$ERR s3 err," + +if [ "$ERR" = "" ]; then + exit 0 +else + echo "ERR is $ERR" + exit 1 +fi + + diff --git a/jdk/test/sun/security/tools/keytool/AltProviderPath.sh b/jdk/test/sun/security/tools/keytool/AltProviderPath.sh index 82bc65787ab..8fd67ef0e0a 100644 --- a/jdk/test/sun/security/tools/keytool/AltProviderPath.sh +++ b/jdk/test/sun/security/tools/keytool/AltProviderPath.sh @@ -46,7 +46,7 @@ fi # set platform-dependent variables OS=`uname -s` case "$OS" in - SunOS | Linux | Darwin ) + SunOS | Linux | Darwin | AIX ) NULL=/dev/null PS=":" FS="/" diff --git a/jdk/test/sun/security/tools/keytool/CloneKeyAskPassword.sh b/jdk/test/sun/security/tools/keytool/CloneKeyAskPassword.sh index 0f9b82c84b8..62d1195a1ca 100644 --- a/jdk/test/sun/security/tools/keytool/CloneKeyAskPassword.sh +++ b/jdk/test/sun/security/tools/keytool/CloneKeyAskPassword.sh @@ -59,6 +59,10 @@ case "$OS" in PATHSEP=":" FILESEP="/" ;; + AIX ) + PATHSEP=":" + FILESEP="/" + ;; CYGWIN* ) PATHSEP=";" FILESEP="/" diff --git a/jdk/test/sun/security/tools/keytool/NoExtNPE.sh b/jdk/test/sun/security/tools/keytool/NoExtNPE.sh index da63ed8ce3a..99b6ae51f36 100644 --- a/jdk/test/sun/security/tools/keytool/NoExtNPE.sh +++ b/jdk/test/sun/security/tools/keytool/NoExtNPE.sh @@ -51,6 +51,10 @@ case "$OS" in Darwin ) FILESEP="/" ;; + AIX ) + PATHSEP=":" + FILESEP="/" + ;; CYGWIN* ) FILESEP="/" ;; diff --git a/jdk/test/sun/security/tools/keytool/SecretKeyKS.sh b/jdk/test/sun/security/tools/keytool/SecretKeyKS.sh index 6246d2bdbb1..3323179daff 100644 --- a/jdk/test/sun/security/tools/keytool/SecretKeyKS.sh +++ b/jdk/test/sun/security/tools/keytool/SecretKeyKS.sh @@ -45,7 +45,7 @@ fi # set platform-dependent variables OS=`uname -s` case "$OS" in - SunOS | Linux | Darwin ) + SunOS | Linux | Darwin | AIX ) NULL=/dev/null PS=":" FS="/" diff --git a/jdk/test/sun/security/tools/keytool/StandardAlgName.sh b/jdk/test/sun/security/tools/keytool/StandardAlgName.sh index 8ac1324bc11..c12348537e1 100644 --- a/jdk/test/sun/security/tools/keytool/StandardAlgName.sh +++ b/jdk/test/sun/security/tools/keytool/StandardAlgName.sh @@ -46,7 +46,7 @@ fi # set platform-dependent variables OS=`uname -s` case "$OS" in - SunOS | Linux | Darwin ) + SunOS | Linux | Darwin | AIX ) NULL=/dev/null PS=":" FS="/" diff --git a/jdk/test/sun/security/tools/keytool/StorePasswordsByShell.sh b/jdk/test/sun/security/tools/keytool/StorePasswordsByShell.sh index 7347f345878..d3cd2ff92cb 100644 --- a/jdk/test/sun/security/tools/keytool/StorePasswordsByShell.sh +++ b/jdk/test/sun/security/tools/keytool/StorePasswordsByShell.sh @@ -46,15 +46,7 @@ fi # set platform-dependent variables OS=`uname -s` case "$OS" in - SunOS ) - PATHSEP=":" - FILESEP="/" - ;; - Linux ) - PATHSEP=":" - FILESEP="/" - ;; - Darwin ) + SunOS | Linux | Darwin | AIX) PATHSEP=":" FILESEP="/" ;; diff --git a/jdk/test/sun/security/tools/keytool/printssl.sh b/jdk/test/sun/security/tools/keytool/printssl.sh index 36ba9d09437..6ebdd3dad22 100644 --- a/jdk/test/sun/security/tools/keytool/printssl.sh +++ b/jdk/test/sun/security/tools/keytool/printssl.sh @@ -40,7 +40,7 @@ fi # set platform-dependent variables OS=`uname -s` case "$OS" in - SunOS | Linux | Darwin ) + SunOS | Linux | Darwin | AIX ) FS="/" ;; CYGWIN* ) diff --git a/jdk/test/sun/security/tools/keytool/resource.sh b/jdk/test/sun/security/tools/keytool/resource.sh index 1256422144e..1e31ff2d241 100644 --- a/jdk/test/sun/security/tools/keytool/resource.sh +++ b/jdk/test/sun/security/tools/keytool/resource.sh @@ -43,7 +43,7 @@ fi # set platform-dependent variables OS=`uname -s` case "$OS" in - SunOS | Linux | Darwin ) + SunOS | Linux | Darwin | AIX ) NULL=/dev/null FS="/" ;; diff --git a/jdk/test/sun/security/tools/keytool/standard.sh b/jdk/test/sun/security/tools/keytool/standard.sh index 630aa41c46f..a42fbfda3cc 100644 --- a/jdk/test/sun/security/tools/keytool/standard.sh +++ b/jdk/test/sun/security/tools/keytool/standard.sh @@ -45,7 +45,7 @@ fi # set platform-dependent variables OS=`uname -s` case "$OS" in - SunOS | Linux | Darwin | CYGWIN* ) + SunOS | Linux | Darwin | AIX | CYGWIN* ) FS="/" ;; Windows_* ) diff --git a/jdk/test/sun/security/tools/policytool/Alias.sh b/jdk/test/sun/security/tools/policytool/Alias.sh index ae1e4082004..c7c25899ce3 100644 --- a/jdk/test/sun/security/tools/policytool/Alias.sh +++ b/jdk/test/sun/security/tools/policytool/Alias.sh @@ -47,7 +47,7 @@ fi # set platform-dependent variables OS=`uname -s` case "$OS" in - SunOS | Linux | Darwin ) + SunOS | Linux | Darwin | AIX ) NULL=/dev/null PS=":" FS="/" diff --git a/jdk/test/sun/security/tools/policytool/ChangeUI.sh b/jdk/test/sun/security/tools/policytool/ChangeUI.sh index 1b6a7984087..96077fa6beb 100644 --- a/jdk/test/sun/security/tools/policytool/ChangeUI.sh +++ b/jdk/test/sun/security/tools/policytool/ChangeUI.sh @@ -46,7 +46,7 @@ fi # set platform-dependent variables OS=`uname -s` case "$OS" in - SunOS | Linux | Darwin ) + SunOS | Linux | Darwin | AIX ) NULL=/dev/null PS=":" FS="/" diff --git a/jdk/test/sun/security/tools/policytool/OpenPolicy.sh b/jdk/test/sun/security/tools/policytool/OpenPolicy.sh index 325b817c3d2..ada838ebda9 100644 --- a/jdk/test/sun/security/tools/policytool/OpenPolicy.sh +++ b/jdk/test/sun/security/tools/policytool/OpenPolicy.sh @@ -46,7 +46,7 @@ fi # set platform-dependent variables OS=`uname -s` case "$OS" in - SunOS | Linux | Darwin ) + SunOS | Linux | Darwin | AIX ) NULL=/dev/null PS=":" FS="/" diff --git a/jdk/test/sun/security/tools/policytool/SaveAs.sh b/jdk/test/sun/security/tools/policytool/SaveAs.sh index af18ad96c21..1c16ecb426c 100644 --- a/jdk/test/sun/security/tools/policytool/SaveAs.sh +++ b/jdk/test/sun/security/tools/policytool/SaveAs.sh @@ -47,7 +47,7 @@ fi # set platform-dependent variables OS=`uname -s` case "$OS" in - SunOS | Linux | Darwin ) + SunOS | Linux | Darwin | AIX ) NULL=/dev/null PS=":" FS="/" diff --git a/jdk/test/sun/security/tools/policytool/UpdatePermissions.sh b/jdk/test/sun/security/tools/policytool/UpdatePermissions.sh index 05978a38b57..70992074e2b 100644 --- a/jdk/test/sun/security/tools/policytool/UpdatePermissions.sh +++ b/jdk/test/sun/security/tools/policytool/UpdatePermissions.sh @@ -47,7 +47,7 @@ fi # set platform-dependent variables OS=`uname -s` case "$OS" in - SunOS | Linux | Darwin ) + SunOS | Linux | Darwin | AIX ) NULL=/dev/null PS=":" FS="/" diff --git a/jdk/test/sun/security/tools/policytool/UsePolicy.sh b/jdk/test/sun/security/tools/policytool/UsePolicy.sh index c8412389a3b..a1e3d34c6c4 100644 --- a/jdk/test/sun/security/tools/policytool/UsePolicy.sh +++ b/jdk/test/sun/security/tools/policytool/UsePolicy.sh @@ -46,7 +46,7 @@ fi # set platform-dependent variables OS=`uname -s` case "$OS" in - SunOS | Linux | Darwin ) + SunOS | Linux | Darwin | AIX ) NULL=/dev/null PS=":" FS="/" diff --git a/jdk/test/sun/security/tools/policytool/i18n.sh b/jdk/test/sun/security/tools/policytool/i18n.sh index 58b59e060b2..18ce68dda28 100644 --- a/jdk/test/sun/security/tools/policytool/i18n.sh +++ b/jdk/test/sun/security/tools/policytool/i18n.sh @@ -49,7 +49,7 @@ fi # set platform-dependent variables OS=`uname -s` case "$OS" in - SunOS | Linux | Darwin ) + SunOS | Linux | Darwin | AIX ) NULL=/dev/null PS=":" FS="/" diff --git a/jdk/test/sun/tools/common/CommonSetup.sh b/jdk/test/sun/tools/common/CommonSetup.sh index db58377a668..f4401a7f6f2 100644 --- a/jdk/test/sun/tools/common/CommonSetup.sh +++ b/jdk/test/sun/tools/common/CommonSetup.sh @@ -48,6 +48,7 @@ # isSolaris - true if OS is Solaris # isWindows - true if OS is Windows # isMacos - true if OS is Macos X +# isAIX - true if OS is AIX if [ -z "${TESTJAVA}" ]; then @@ -83,6 +84,7 @@ isSolaris=false isUnknownOS=false isWindows=false isMacos=false +isAIX=false OS=`uname -s` @@ -113,6 +115,10 @@ case "$OS" in OS="Solaris" isSolaris=true ;; + AIX ) + OS="AIX" + isAIX=true + ;; Windows* ) OS="Windows" PATTERN_EOL='[ ]*$' diff --git a/jdk/test/sun/tools/jcmd/TestJcmdDefaults.java b/jdk/test/sun/tools/jcmd/TestJcmdDefaults.java new file mode 100644 index 00000000000..a5310862859 --- /dev/null +++ b/jdk/test/sun/tools/jcmd/TestJcmdDefaults.java @@ -0,0 +1,104 @@ +/* + * 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import static jdk.testlibrary.Asserts.*; + +import java.io.File; +import java.io.IOException; +import java.util.List; + +import jdk.testlibrary.JcmdBase; +import jdk.testlibrary.OutputAnalyzer; +import jdk.testlibrary.Utils; + +/** + * Unit test for jcmd utility. Tests jcmd options which do not send + * requests to a specific JVM process. + */ +/* + * @test + * @bug 7104647 + * @library /lib/testlibrary + * @run main TestJcmdDefaults + */ +public class TestJcmdDefaults { + + private static final String TEST_SRC = System.getProperty("test.src").trim(); + private static final String[] VM_ARGS = new String[] { "-XX:+UsePerfData" }; + private static final String JCMD_LIST_REGEX = "^\\d+\\s*.*"; + + public static void main(String[] args) throws Exception { + testJcmdUsage("-h"); + testJcmdUsage("-help"); + testJcmdDefaults(); + testJcmdDefaults("-l"); + } + + /** + * jcmd -J-XX:+UsePerfData -h + * jcmd -J-XX:+UsePerfData -help + */ + private static void testJcmdUsage(String... jcmdArgs) throws Exception { + OutputAnalyzer output = JcmdBase.jcmdNoPid(VM_ARGS, jcmdArgs); + + assertNotEquals(output.getExitValue(), 0); + verifyOutputAgainstFile(output); + } + + /** + * jcmd -J-XX:+UsePerfData + * jcmd -J-XX:+UsePerfData -l + */ + private static void testJcmdDefaults(String... jcmdArgs) throws Exception { + OutputAnalyzer output = JcmdBase.jcmdNoPid(VM_ARGS, jcmdArgs); + + output.shouldHaveExitValue(0); + output.shouldContain("sun.tools.jcmd.JCmd"); + matchListedProcesses(output); + } + + /** + * Verifies the listed processes match a certain pattern. + * + * The output should look like: + * 12246 sun.tools.jcmd.JCmd + * 24428 com.sun.javatest.regtest.MainWrapper /tmp/jtreg/jtreg-workdir/classes/sun/tools/jcmd/TestJcmdDefaults.jta + * + * @param output The generated output from the jcmd. + * @throws Exception + */ + private static void matchListedProcesses(OutputAnalyzer output) throws Exception { + int matchedCount = output.shouldMatchByLine(JCMD_LIST_REGEX); + assertGreaterThan(matchedCount , 0, + "Found no lines matching pattern: " + JCMD_LIST_REGEX); + } + + private static void verifyOutputAgainstFile(OutputAnalyzer output) throws IOException { + File file = new File(TEST_SRC, "usage.out"); + List fileOutput = Utils.fileAsList(file); + List outputAsLines = output.asLines(); + assertTrue(outputAsLines.containsAll(fileOutput), + "The ouput should contain all content of " + file.getAbsolutePath()); + } + +} diff --git a/jdk/test/sun/tools/jcmd/TestJcmdSanity.java b/jdk/test/sun/tools/jcmd/TestJcmdSanity.java new file mode 100644 index 00000000000..52fa840fe43 --- /dev/null +++ b/jdk/test/sun/tools/jcmd/TestJcmdSanity.java @@ -0,0 +1,169 @@ +/* + * 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import static jdk.testlibrary.Asserts.*; + +import java.io.File; +import java.io.IOException; +import java.util.List; + +import jdk.testlibrary.JcmdBase; +import jdk.testlibrary.OutputAnalyzer; +import jdk.testlibrary.ProcessTools; +import jdk.testlibrary.Utils; + +/** + * Unit test for jcmd utility. The test will send different diagnostic command + * requests to the current java process. + */ +/* + * @test + * @bug 7104647 7154822 + * @library /lib/testlibrary + * @run main TestJcmdSanity + */ +public class TestJcmdSanity { + + private static final String TEST_SRC = System.getProperty("test.src").trim(); + private static final String[] VM_ARGS = new String[] { "-XX:+UsePerfData" }; + private static final String JCMD_COMMAND_REGEX = "(\\w|\\.)*"; + private static final String PERF_COUNTER_REGEX = "(\\w|\\.)*\\=.*"; + + public static void main(String[] args) throws Exception { + testJcmdPidHelp(); + testJcmdPidHelpHelp(); + testJcmdPid_f(); + testJcmdPidPerfCounterPrint(); + testJcmdPidBigScript(); + } + + /** + * jcmd -J-XX:+UsePerfData pid help + */ + private static void testJcmdPidHelp() throws Exception { + OutputAnalyzer output = JcmdBase.jcmd(VM_ARGS, + new String[] {"help"}); + + output.shouldHaveExitValue(0); + output.shouldNotContain("Exception"); + output.shouldContain(Integer.toString(ProcessTools.getProcessId()) + ":"); + matchJcmdCommands(output); + output.shouldContain("For more information about a specific command use 'help '."); + } + + /** + * jcmd -J-XX:+UsePerfData pid help help + */ + private static void testJcmdPidHelpHelp() throws Exception { + OutputAnalyzer output = JcmdBase.jcmd(VM_ARGS, + new String[] {"help", "help"}); + + output.shouldHaveExitValue(0); + verifyOutputAgainstFile(output); + } + + /** + * jcmd -J-XX:+UsePerfData pid PerfCounter.print + */ + private static void testJcmdPidPerfCounterPrint() throws Exception { + OutputAnalyzer output = JcmdBase.jcmd(VM_ARGS, + new String[] {"PerfCounter.print"}); + + output.shouldHaveExitValue(0); + matchPerfCounters(output); + } + + /** + * jcmd -J-XX:+UsePerfData pid -f dcmd-script.txt + */ + private static void testJcmdPid_f() throws Exception { + File scrpitFile = new File(TEST_SRC, "dcmd-script.txt"); + OutputAnalyzer output = JcmdBase.jcmd(VM_ARGS, + new String[] {"-f", scrpitFile.getAbsolutePath()}); + + output.shouldHaveExitValue(0); + verifyOutputAgainstFile(output); + } + + /** + * Tests that it possible send a file over 1024 bytes large via jcmd -f. + * + * jcmd -J-XX:+UsePerfData pid -f dcmd-big-script.txt + */ + private static void testJcmdPidBigScript() throws Exception { + File scrpitFile = new File(TEST_SRC, "dcmd-big-script.txt"); + OutputAnalyzer output = JcmdBase.jcmd(VM_ARGS, + new String[] {"-f", scrpitFile.getAbsolutePath()}); + + output.shouldHaveExitValue(0); + output.shouldNotContain("Exception"); + output.shouldContain(System.getProperty("java.vm.name").trim()); + } + + /** + * Verifies the listed jcmd commands match a certain pattern. + * + * The output of the jcmd commands should look like: + * VM.uptime + * VM.flags + * VM.system_properties + * + * @param output The generated output from the jcmd. + * @throws Exception + */ + private static void matchJcmdCommands(OutputAnalyzer output) throws Exception { + int matchedCount = output.shouldMatchByLine(JCMD_COMMAND_REGEX, + "help", + JCMD_COMMAND_REGEX); + assertGreaterThan(matchedCount , 0, + "Found no lines matching pattern: " + JCMD_COMMAND_REGEX); + } + + /** + * Verifies the generated output from the PerfCounter.print command + * matches a certain pattern. + * + * The output of perf counters should look like: + * java.property.java.vm.name="Java HotSpot(TM) 64-Bit Server VM" + * java.threads.daemon=7 + * sun.rt.javaCommand="com.sun.javatest.regtest.MainWrapper /tmp/jtreg/jtreg-workdir/classes/sun/tools/jcmd/TestJcmdSanity.jta" + * + * @param output The generated output from the PerfCounter.print command. + * @throws Exception + */ + private static void matchPerfCounters(OutputAnalyzer output) throws Exception { + int matchedCount = output.shouldMatchByLineFrom(PERF_COUNTER_REGEX, + PERF_COUNTER_REGEX); + assertGreaterThan(matchedCount , 0, + "Found no lines matching pattern: " + PERF_COUNTER_REGEX); + } + + private static void verifyOutputAgainstFile(OutputAnalyzer output) throws IOException { + File file = new File(TEST_SRC, "help_help.out"); + List fileOutput = Utils.fileAsList(file); + List outputAsLines = output.asLines(); + assertTrue(outputAsLines.containsAll(fileOutput), + "The ouput should contain all content of " + file.getAbsolutePath()); + } + +} diff --git a/jdk/test/sun/tools/jcmd/help_help.out b/jdk/test/sun/tools/jcmd/help_help.out index beaf0f35b94..3f151b92acd 100644 --- a/jdk/test/sun/tools/jcmd/help_help.out +++ b/jdk/test/sun/tools/jcmd/help_help.out @@ -1,7 +1,7 @@ help For more information about a specific command use 'help '. With no argument this will show a list of available commands. 'help all' will show help for all commands. -Impact: Low +Impact: Low Syntax : help [options] [] diff --git a/jdk/test/sun/tools/jcmd/jcmd-Defaults.sh b/jdk/test/sun/tools/jcmd/jcmd-Defaults.sh deleted file mode 100644 index 2d6aa2ebe89..00000000000 --- a/jdk/test/sun/tools/jcmd/jcmd-Defaults.sh +++ /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. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please 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 7104647 -# @run shell jcmd-Defaults.sh -# @summary Test that output of 'jcmd' and 'jcmd -l' match a specific pattern - -JCMD="${TESTJAVA}/bin/jcmd" - -${JCMD} -J-XX:+UsePerfData 2>&1 | awk -f ${TESTSRC}/jcmd_Output1.awk - -${JCMD} -J-XX:+UsePerfData -l 2>&1 | awk -f ${TESTSRC}/jcmd_Output1.awk diff --git a/jdk/test/sun/tools/jcmd/jcmd-big-script.sh b/jdk/test/sun/tools/jcmd/jcmd-big-script.sh deleted file mode 100644 index a101c8cf2a8..00000000000 --- a/jdk/test/sun/tools/jcmd/jcmd-big-script.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/sh - -# -# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - - -# @test -# @bug 7154822 -# @summary test if we can send a file over 1024 bytes large via jcmd -f -# @author David Buck -# -# @library ../common -# @build SimpleApplication ShutdownSimpleApplication -# @run shell jcmd-big-script.sh - -. ${TESTSRC}/../common/CommonSetup.sh -. ${TESTSRC}/../common/ApplicationSetup.sh - -# Start application and use PORTFILE for coordination -PORTFILE="${TESTCLASSES}"/shutdown.port -startApplication SimpleApplication "${PORTFILE}" - -failed=0; - -# -f - - - -

$comments

- EOF - - cp $WDIR/$DIR/$TNAME.lhs.html $WDIR/$DIR/$TNAME.rhs.html - - insert_anchors $lhsfile >> $WDIR/$DIR/$TNAME.lhs.html - insert_anchors $rhsfile >> $WDIR/$DIR/$TNAME.rhs.html - - close='' - - print $close >> $WDIR/$DIR/$TNAME.lhs.html - print $close >> $WDIR/$DIR/$TNAME.rhs.html - - print "$FRAMEHTML$STDHEAD" > $WDIR/$DIR/$TNAME.frames.html - print "$WNAME Framed-Sdiff " \ - "$TPATH/$TNAME " >> $WDIR/$DIR/$TNAME.frames.html - cat >> $WDIR/$DIR/$TNAME.frames.html <<-EOF - - - - - - - - <body id="SUNWwebrev"> - Alas 'frames' webrev requires that your browser supports frames - and has the feature enabled. - </body> - - - - EOF -} - - -# -# fix_postscript -# -# Merge codereview output files to a single conforming postscript file, by: -# - removing all extraneous headers/trailers -# - making the page numbers right -# - removing pages devoid of contents which confuse some -# postscript readers. -# -# From Casper. -# -function fix_postscript -{ - infile=$1 - - cat > /tmp/$$.crmerge.pl << \EOF - - print scalar(<>); # %!PS-Adobe--- - print "%%Orientation: Landscape\n"; - - $pno = 0; - $doprint = 1; - - $page = ""; - - while (<>) { - next if (/^%%Pages:\s*\d+/); - - if (/^%%Page:/) { - if ($pno == 0 || $page =~ /\)S/) { - # Header or single page containing text - print "%%Page: ? $pno\n" if ($pno > 0); - print $page; - $pno++; - } else { - # Empty page, skip it. - } - $page = ""; - $doprint = 1; - next; - } - - # Skip from %%Trailer of one document to Endprolog - # %%Page of the next - $doprint = 0 if (/^%%Trailer/); - $page .= $_ if ($doprint); - } - - if ($page =~ /\)S/) { - print "%%Page: ? $pno\n"; - print $page; - } else { - $pno--; - } - print "%%Trailer\n%%Pages: $pno\n"; -EOF - - $PERL /tmp/$$.crmerge.pl < $infile -} - - -# -# input_cmd | insert_anchors | output_cmd -# -# Flag blocks of difference with sequentially numbered invisible -# anchors. These are used to drive the frames version of the -# sdiffs output. -# -# NOTE: Anchor zero flags the top of the file irrespective of changes, -# an additional anchor is also appended to flag the bottom. -# -# The script detects changed lines as any line that has a "", anc, anc++; - } - - BEGIN { - anc=1; - inblock=1; - printf "
\n";
-	}
-	NF == 0 || /^";
-		printf "--- EOF ---"
-        	for(i=0;i<8;i++) printf "\n\n\n\n\n\n\n\n\n\n";
-		printf "
" - printf "
"; - printf "", - anc - 1; - printf "
"; - } - ' $1 -} - - -# -# relative_dir -# -# Print a relative return path from $1 to $2. For example if -# $1=/tmp/myreview/raw_files/usr/src/tools/scripts and $2=/tmp/myreview, -# this function would print "../../../../". -# -# In the event that $1 is not in $2 a warning is printed to stderr, -# and $2 is returned-- the result of this is that the resulting webrev -# is not relocatable. -# -function relative_dir -{ - d1=$1 - d2=$2 - if [[ "$d1" == "." ]]; then - print "." - else - typeset cur="${d1##$d2?(/)}" - typeset ret="" - if [[ $d2 == $cur ]]; then # Should never happen. - # Should never happen. - print -u2 "\nWARNING: relative_dir: \"$1\" not relative " - print -u2 "to \"$2\". Check input paths. Framed webrev " - print -u2 "will not be relocatable!" - print $2 - return - fi - - while [[ -n ${cur} ]]; - do - cur=${cur%%*(/)*([!/])} - if [[ -z $ret ]]; then - ret=".." - else - ret="../$ret" - fi - done - print $ret - fi -} - - -# -# frame_nav_js -# -# Emit javascript for frame navigation -# -function frame_nav_js -{ -cat << \EOF -var myInt; -var scrolling=0; -var sfactor = 3; -var scount=10; - -function scrollByPix() { - if (scount<=0) { - sfactor*=1.2; - scount=10; - } - parent.lhs.scrollBy(0,sfactor); - parent.rhs.scrollBy(0,sfactor); - scount--; -} - -function scrollToAnc(num) { - - // Update the value of the anchor in the form which we use as - // storage for this value. setAncValue() will take care of - // correcting for overflow and underflow of the value and return - // us the new value. - num = setAncValue(num); - - // Set location and scroll back a little to expose previous - // lines. - // - // Note that this could be improved: it is possible although - // complex to compute the x and y position of an anchor, and to - // scroll to that location directly. - // - parent.lhs.location.replace(parent.lhs.location.pathname + "#" + num); - parent.rhs.location.replace(parent.rhs.location.pathname + "#" + num); - - parent.lhs.scrollBy(0,-30); - parent.rhs.scrollBy(0,-30); -} - -function getAncValue() -{ - return (parseInt(parent.nav.document.diff.real.value)); -} - -function setAncValue(val) -{ - if (val <= 0) { - val = 0; - parent.nav.document.diff.real.value = val; - parent.nav.document.diff.display.value = "BOF"; - return (val); - } - - // - // The way we compute the max anchor value is to stash it - // inline in the left and right hand side pages-- it's the same - // on each side, so we pluck from the left. - // - maxval = parent.lhs.document.eof.value.value; - if (val < maxval) { - parent.nav.document.diff.real.value = val; - parent.nav.document.diff.display.value = val.toString(); - return (val); - } - - // this must be: val >= maxval - val = maxval; - parent.nav.document.diff.real.value = val; - parent.nav.document.diff.display.value = "EOF"; - return (val); -} - -function stopScroll() { - if (scrolling==1) { - clearInterval(myInt); - scrolling=0; - } -} - -function startScroll() { - stopScroll(); - scrolling=1; - myInt=setInterval("scrollByPix()",10); -} - -function handlePress(b) { - - switch (b) { - case 1 : - scrollToAnc(-1); - break; - case 2 : - scrollToAnc(getAncValue() - 1); - break; - case 3 : - sfactor=-3; - startScroll(); - break; - case 4 : - sfactor=3; - startScroll(); - break; - case 5 : - scrollToAnc(getAncValue() + 1); - break; - case 6 : - scrollToAnc(999999); - break; - } -} - -function handleRelease(b) { - stopScroll(); -} - -function keypress(ev) { - var keynum; - var keychar; - - if (window.event) { // IE - keynum = ev.keyCode; - } else if (ev.which) { // non-IE - keynum = ev.which; - } - - keychar = String.fromCharCode(keynum); - - if (keychar == "k") { - handlePress(2); - return (0); - } else if (keychar == "j" || keychar == " ") { - handlePress(5); - return (0); - } - return (1); -} - -function ValidateDiffNum(){ - val = parent.nav.document.diff.display.value; - if (val == "EOF") { - scrollToAnc(999999); - return; - } - - if (val == "BOF") { - scrollToAnc(0); - return; - } - - i=parseInt(val); - if (isNaN(i)) { - parent.nav.document.diff.display.value = getAncValue(); - } else { - scrollToAnc(i); - } - return false; -} - -EOF -} - -# -# frame_navigation -# -# Output anchor navigation file for framed sdiffs. -# -function frame_navigation -{ - print "$HTML$STDHEAD" - - cat << \EOF -Anchor Navigation - - - - -EOF - - print "" - - cat << \EOF - - - - - - - - - -
Diff navigation: - Use 'j' and 'k' for next and previous diffs; or use buttons - at right -
- - - - - - - - - - - -
- BOF - Scroll Up - Prev Diff -
- EOF - Scroll Down - Next Diff
-
-
-
- - -
-
- - -EOF -} - - - -# -# diff_to_html { U | C } -# -# Processes the output of diff to produce an HTML file representing either -# context or unified diffs. -# -diff_to_html() -{ - TNAME=$1 - TPATH=$2 - DIFFTYPE=$3 - COMMENT=$4 - - print "$HTML$STDHEAD" - print "$WNAME ${DIFFTYPE}diff $TPATH" - - if [[ $DIFFTYPE == "U" ]]; then - print "$UDIFFCSS" - fi - - cat <<-EOF - - -

$TPATH

- Print this page -
$COMMENT
-
-EOF
-
-	html_quote | $AWK '
-	/^--- new/	{ next }
-	/^\+\+\+ new/	{ next }
-	/^--- old/	{ next }
-	/^\*\*\* old/	{ next }
-	/^\*\*\*\*/	{ next }
-	/^-------/	{ printf "

%s

\n", $0; next } - /^\@\@.*\@\@$/ { printf "

\n";
-			  printf "%s\n", $0;
-			  next}
-
-	/^\*\*\*/	{ printf "
%s\n", $0; - next} - /^---/ { printf "%s\n", $0; - next} - /^\+/ {printf "%s\n", $0; next} - /^!/ {printf "%s\n", $0; next} - /^-/ {printf "%s\n", $0; next} - {printf "%s\n", $0; next} - ' - - print "
\n" -} - - -# -# source_to_html { new | old } -# -# Process a plain vanilla source file to transform it into an HTML file. -# -source_to_html() -{ - WHICH=$1 - TNAME=$2 - - print "$HTML$STDHEAD" - print "$WHICH $TNAME" - print "" - print "
"
-	html_quote | $AWK '{line += 1 ; printf "%4d %s\n", line, $0 }'
-	print "
" -} - -comments_from_mercurial() -{ - fmt=$1 - pfile=$PWS/$2 - cfile=$CWS/$3 - - logdir=`dirname $cfile` - logf=`basename $cfile` - if [ -d $logdir ]; then - ( cd $logdir; - active=`hg status $logf 2>/dev/null` - # If the output from 'hg status' is not empty, it means the file - # hasn't been committed, so don't fetch comments. - if [[ -z $active ]] ; then - if [[ -n $ALL_CREV ]]; then - rev_opt= - for rev in $ALL_CREV; do - rev_opt="$rev_opt --rev $rev" - done - comm=`hg log $rev_opt --follow --template 'rev {rev} : {desc}\n' $logf` - elif [[ -n $FIRST_CREV ]]; then - comm=`hg log --rev $FIRST_CREV:tip --follow --template 'rev {rev} : {desc}\n' $logf` - else - comm=`hg log -l1 --follow --template 'rev {rev} : {desc}\n' $logf` - fi - else - comm="" - fi - if [[ $fmt == "text" ]]; then - print "$comm" - return - fi - - print "$comm" | html_quote | bug2url - ) - fi -} - - -# -# getcomments {text|html} filepath parentpath -# -# Fetch the comments depending on what SCM mode we're in. -# -getcomments() -{ - typeset fmt=$1 - typeset p=$2 - typeset pp=$3 - - comments_from_mercurial $fmt $pp $p -} - -# -# printCI -# -# Print out Code Inspection figures similar to sccs-prt(1) format. -# -function printCI -{ - integer tot=$1 ins=$2 del=$3 mod=$4 unc=$5 - typeset str - if (( tot == 1 )); then - str="line" - else - str="lines" - fi - printf '%d %s changed: %d ins; %d del; %d mod; %d unchg' \ - $tot $str $ins $del $mod $unc -} - - -# -# difflines -# -# Calculate and emit number of added, removed, modified and unchanged lines, -# and total lines changed, the sum of added + removed + modified. -# -function difflines -{ - integer tot mod del ins unc err - typeset filename - - eval $( diff -e $1 $2 | $AWK ' - # Change range of lines: N,Nc - /^[0-9]*,[0-9]*c$/ { - n=split(substr($1,1,length($1)-1), counts, ","); - if (n != 2) { - error=2 - exit; - } - # - # 3,5c means lines 3 , 4 and 5 are changed, a total of 3 lines. - # following would be 5 - 3 = 2! Hence +1 for correction. - # - r=(counts[2]-counts[1])+1; - - # - # Now count replacement lines: each represents a change instead - # of a delete, so increment c and decrement r. - # - while (getline != /^\.$/) { - c++; - r--; - } - # - # If there were more replacement lines than original lines, - # then r will be negative; in this case there are no deletions, - # but there are r changes that should be counted as adds, and - # since r is negative, subtract it from a and add it to c. - # - if (r < 0) { - a-=r; - c+=r; - } - - # - # If there were more original lines than replacement lines, then - # r will be positive; in this case, increment d by that much. - # - if (r > 0) { - d+=r; - } - next; - } - - # Change lines: Nc - /^[0-9].*c$/ { - # The first line is a replacement; any more are additions. - if (getline != /^\.$/) { - c++; - while (getline != /^\.$/) a++; - } - next; - } - - # Add lines: both Na and N,Na - /^[0-9].*a$/ { - while (getline != /^\.$/) a++; - next; - } - - # Delete range of lines: N,Nd - /^[0-9]*,[0-9]*d$/ { - n=split(substr($1,1,length($1)-1), counts, ","); - if (n != 2) { - error=2 - exit; - } - # - # 3,5d means lines 3 , 4 and 5 are deleted, a total of 3 lines. - # following would be 5 - 3 = 2! Hence +1 for correction. - # - r=(counts[2]-counts[1])+1; - d+=r; - next; - } - - # Delete line: Nd. For example 10d says line 10 is deleted. - /^[0-9]*d$/ {d++; next} - - # Should not get here! - { - error=1; - exit; - } - - # Finish off - print results - END { - printf("tot=%d;mod=%d;del=%d;ins=%d;err=%d\n", - (c+d+a), c, d, a, error); - }' ) - - # End of $AWK, Check to see if any trouble occurred. - if (( $? > 0 || err > 0 )); then - print "Unexpected Error occurred reading" \ - "\`diff -e $1 $2\`: \$?=$?, err=" $err - return - fi - - # Accumulate totals - (( TOTL += tot )) - (( TMOD += mod )) - (( TDEL += del )) - (( TINS += ins )) - # Calculate unchanged lines - unc=`wc -l < $1` - if (( unc > 0 )); then - (( unc -= del + mod )) - (( TUNC += unc )) - fi - # print summary - print "\c" - printCI $tot $ins $del $mod $unc - print "" -} - -function outgoing_from_mercurial_forest -{ - hg foutgoing --template 'rev: {rev}\n' $OUTPWS | $FILTER | $AWK ' - BEGIN {ntree=0} - /^comparing/ {next} - /^no changes/ {next} - /^searching/ {next} - /^\[.*\]$/ {tree=substr($1,2,length($1)-2); - trees[ntree++] = tree; - revs[tree]=-1; - next} - /^rev:/ {rev=$2+0; - if (revs[tree] == -1 || rev < revs[tree]) - { revs[tree] = rev; }; - next;} - END {for (tree in trees) - { rev=revs[trees[tree]]; - if (rev > 0) - {printf("%s %d\n",trees[tree],rev-1)} - }}' | while read LINE - do - set - $LINE - TREE=$1 - REV=$2 - A=`hg -R $CWS/$TREE log --rev $REV --template '{node}'` - FSTAT_OPT="--rev $A" - print "Revision: $A $REV" >> $FLIST - treestatus $TREE - done -} - -function flist_from_mercurial_forest -{ - rm -f $FLIST - if [ -z "$Nflag" ]; then - print " File list from hg foutgoing $PWS ..." - outgoing_from_mercurial_forest - HG_LIST_FROM_COMMIT=1 - fi - if [ ! -f $FLIST ]; then - # hg commit hasn't been run see what is lying around - print "\n No outgoing, perhaps you haven't commited." - print " File list from hg fstatus -mard ...\c" - FSTAT_OPT= - fstatus - HG_LIST_FROM_COMMIT= - fi - print " Done." -} - -# -# Used when dealing with the result of 'hg foutgoing' -# When now go down the tree and generate the change list -# -function treestatus -{ - TREE=$1 - HGCMD="hg -R $CWS/$TREE status $FSTAT_OPT" - - $HGCMD -mdn 2>/dev/null | $FILTER | while read F - do - echo $TREE/$F - done >> $FLIST - - # Then all the added files - # But some of these could have been "moved" or renamed ones or copied ones - # so let's make sure we get the proper info - # hg status -aC will produce something like: - # A subdir/File3 - # A subdir/File4 - # File4 - # A subdir/File5 - # The first and last are simple addition while the middle one - # is a move/rename or a copy. We can't distinguish from a rename vs a copy - # without also getting the status of removed files. The middle case above - # is a rename if File4 is also shown a being removed. If File4 is not a - # removed file, then the middle case is a copy from File4 to subdir/File4 - # FIXME - we're not distinguishing copy from rename - $HGCMD -aC | $FILTER | while read LINE; do - ldone="" - while [ -z "$ldone" ]; do - ldone="1" - set - $LINE - if [ $# -eq 2 -a "$1" == "A" ]; then - AFILE=$2 - if read LINE2; then - set - $LINE2 - if [ $# -eq 1 ]; then - echo $TREE/$AFILE $TREE/$1 >>$FLIST - elif [ $# -eq 2 ]; then - echo $TREE/$AFILE >>$FLIST - LINE=$LINE2 - ldone="" - fi - else - echo $TREE/$AFILE >>$FLIST - fi - fi - done - done - $HGCMD -rn | $FILTER | while read RFILE; do - grep "$TREE/$RFILE" $FLIST >/dev/null - if [ $? -eq 1 ]; then - echo $TREE/$RFILE >>$FLIST - fi - done -} - -function fstatus -{ - # - # forest extension is still being changed. For instance the output - # of fstatus used to no prepend the tree path to filenames, but - # this has changed recently. AWK code below does try to handle both - # cases - # - hg fstatus -mdn $FSTAT_OPT 2>/dev/null | $FILTER | $AWK ' - /^\[.*\]$/ {tree=substr($1,2,length($1)-2); next} - $1 != "" {n=index($1,tree); - if (n == 0) - { printf("%s/%s\n",tree,$1)} - else - { printf("%s\n",$1)}}' >> $FLIST - - # - # There is a bug in the output of fstatus -aC on recent versions: it - # inserts a space between the name of the tree and the filename of the - # old file. e.g.: - # - # $ hg fstatus -aC - # [.] - # - # [MyWS] - # A MyWS/subdir/File2 - # MyWS/ File2 - # - # [MyWS2] - # - - hg fstatus -aC $FSTAT_OPT 2>/dev/null | $FILTER | $AWK ' - /^\[.*\]$/ {tree=substr($1,2,length($1)-2); next} - /^A .*/ {n=index($2,tree); - if (n == 0) - { printf("A %s/%s\n",tree,$2)} - else - { printf("A %s\n",$2)}; - next} - /^ / {n=index($1,tree); - if (n == 0) - { printf("%s/%s\n",tree,$1)} - else - { if (NF == 2) - printf("%s/%s\n",tree,$2) - else - printf("%s\n",$1) - }; - next} - ' | while read LINE; do - ldone="" - while [ -z "$ldone" ]; do - ldone="1" - set - $LINE - if [ $# -eq 2 -a "$1" == "A" ]; then - AFILE=$2 - if read LINE2; then - set - $LINE2 - if [ $# -eq 1 ]; then - echo $AFILE $1 >>$FLIST - elif [ $# -eq 2 ]; then - echo $AFILE >>$FLIST - LINE=$LINE2 - ldone="" - fi - else - echo $AFILE >>$FLIST - fi - fi - done - done - hg fstatus -rn $FSTAT_OPT 2>/dev/null | $FILTER | $AWK ' - /^\[.*\]$/ {tree=substr($1,2,length($1)-2); next} - $1 != "" {n=index($1,tree); - if (n == 0) - { printf("%s/%s\n",tree,$1)} - else - { printf("%s\n",$1)}}' | while read RFILE; do - grep "$RFILE" $FLIST >/dev/null - if [ $? -eq 1 ]; then - echo $RFILE >>$FLIST - fi - done -} - -# -# flist_from_mercurial $PWS -# -# Only local file based repositories are supported at present -# since even though we can determine the list from the parent finding -# the changes is harder. -# -# We first look for any outgoing files, this is for when the user has -# run hg commit. If we don't find any then we look with hg status. -# -# We need at least one of default-push or default paths set in .hg/hgrc -# If neither are set we don't know who to compare with. - -function flist_from_mercurial -{ -# if [ "${PWS##ssh://}" != "$PWS" -o \ -# "${PWS##http://}" != "$PWS" -o \ -# "${PWS##https://}" != "$PWS" ]; then -# print "Remote Mercurial repositories not currently supported." -# print "Set default and/or default-push to a local repository" -# exit -# fi - if [[ -n $forestflag ]]; then - HG_LIST_FROM_COMMIT= - flist_from_mercurial_forest - else - STATUS_REV= - if [[ -n $rflag ]]; then - STATUS_REV="--rev $PARENT_REV" - elif [[ -n $OUTREV ]]; then - STATUS_REV="--rev $OUTREV" - else - # hg commit hasn't been run see what is lying around - print "\n No outgoing, perhaps you haven't commited." - fi - # First let's list all the modified or deleted files - - hg status $STATUS_REV -mdn | $FILTER > $FLIST - - # Then all the added files - # But some of these could have been "moved" or renamed ones - # so let's make sure we get the proper info - # hg status -aC will produce something like: - # A subdir/File3 - # A subdir/File4 - # File4 - # A subdir/File5 - # The first and last are simple addition while the middle one - # is a move/rename or a copy. We can't distinguish from a rename vs a copy - # without also getting the status of removed files. The middle case above - # is a rename if File4 is also shown a being removed. If File4 is not a - # removed file, then the middle case is a copy from File4 to subdir/File4 - # FIXME - we're not distinguishing copy from rename - - hg status $STATUS_REV -aC | $FILTER >$FLIST.temp - while read LINE; do - ldone="" - while [ -z "$ldone" ]; do - ldone="1" - set - $LINE - if [ $# -eq 2 -a "$1" == "A" ]; then - AFILE=$2 - if read LINE2; then - set - $LINE2 - if [ $# -eq 1 ]; then - echo $AFILE $1 >>$FLIST - elif [ $# -eq 2 ]; then - echo $AFILE >>$FLIST - LINE=$LINE2 - ldone="" - fi - else - echo $AFILE >>$FLIST - fi - fi - done - done < $FLIST.temp - hg status $STATUS_REV -rn | $FILTER > $FLIST.temp - while read RFILE; do - grep "$RFILE" $FLIST >/dev/null - if [ $? -eq 1 ]; then - echo $RFILE >>$FLIST - fi - done < $FLIST.temp - rm -f $FLIST.temp - fi -} - -function env_from_flist -{ - [[ -r $FLIST ]] || return - - # - # Use "eval" to set env variables that are listed in the file - # list. Then copy those into our local versions of those - # variables if they have not been set already. - # - eval `sed -e "s/#.*$//" $FLIST | grep = ` - - [[ -z $codemgr_ws && -n $CODEMGR_WS ]] && codemgr_ws=$CODEMGR_WS - - # - # Check to see if CODEMGR_PARENT is set in the flist file. - # - [[ -z $codemgr_parent && -n $CODEMGR_PARENT ]] && \ - codemgr_parent=$CODEMGR_PARENT -} - -# -# detect_scm -# -# We dynamically test the SCM type; this allows future extensions to -# new SCM types -# -function detect_scm -{ - if hg root >/dev/null ; then - print "mercurial" - else - print "unknown" - fi -} - -function look_for_prog -{ - typeset path - typeset ppath - typeset progname=$1 - - DEVTOOLS= - OS=`uname` - if [[ "$OS" == "SunOS" ]]; then - DEVTOOLS="/java/devtools/`uname -p`/bin" - elif [[ "$OS" == "Linux" ]]; then - DEVTOOLS="/java/devtools/linux/bin" - fi - - ppath=$PATH - ppath=$ppath:/usr/sfw/bin:/usr/bin:/usr/sbin - ppath=$ppath:/opt/teamware/bin:/opt/onbld/bin - ppath=$ppath:/opt/onbld/bin/`uname -p` - ppath=$ppath:/java/devtools/share/bin:$DEVTOOLS - - PATH=$ppath prog=`whence $progname` - if [[ -n $prog ]]; then - print $prog - fi -} - -# -# Find the parent for $1 -# -function find_outrev -{ - crev=$1 - prev=`hg log -r $crev --template '{parents}\n'` - if [[ -z "$prev" ]] - then - # No specific parent means previous changeset is parent - prev=`expr $crev - 1` - else - # Format is either of the following two: - # 546:7df6fcf1183b - # 548:16f1915bb5cd 547:ffaa4e775815 - prev=`echo $prev | sed -e 's/\([0-9]*\):.*/\1/'` - fi - print $prev -} - -function extract_ssh_infos -{ - CMD=$1 - if expr "$CMD" : 'ssh://[^/]*@' >/dev/null; then - ssh_user=`echo $CMD | sed -e 's/ssh:\/\/\(.*\)@.*/\1/'` - ssh_host=`echo $CMD | sed -e 's/ssh:\/\/.*@\([^/]*\)\/.*/\1/'` - ssh_dir=`echo $CMD | sed -e 's/ssh:\/\/.*@[^/]*\/\(.*\)/\1/'` - else - ssh_user= - ssh_host=`echo $CMD | sed -e 's/ssh:\/\/\([^/]*\)\/.*/\1/'` - ssh_dir=`echo $CMD | sed -e 's/ssh:\/\/[^/]*\/\(.*\)/\1/'` - fi - -} - -function build_old_new_mercurial -{ - olddir=$1 - newdir=$2 - DIR=$3 - F=$4 - # - # new version of the file. - # - rm -rf $newdir/$DIR/$F - if [ -f $F ]; then - cp $F $newdir/$DIR/$F - fi - - # - # Old version of the file. - # - rm -rf $olddir/$DIR/$F - - if [ -n "$PWS" ]; then - if expr "$PWS" : 'ssh://' >/dev/null - then - extract_ssh_infos $PWS - if [ -n "$ssh_user" ]; then - parent="ssh -l $ssh_user $ssh_host hg -R $ssh_dir --cwd $ssh_dir" - else - parent="ssh $ssh_host hg -R $ssh_dir --cwd $ssh_dir" - fi - else - parent="hg -R $PWS --cwd $PWS" - fi - else - parent="" - fi - - if [ -z "$rename" ]; then - if [ -n "$rflag" ]; then - parentrev=$PARENT_REV - elif [ "$HG_LIST_FROM_COMMIT" -eq 1 ]; then - parentrev=$OUTREV - else - if [[ -n $HG_BRANCH ]]; then - parentrev=$HG_BRANCH - else - parentrev="tip" - fi - fi - - if [ -n "$parentrev" ]; then - if [ -z "$parent" ]; then - hg cat --rev $parentrev --output $olddir/$DIR/$F $F 2>/dev/null - else - # when specifying a workspace we have to provide - # the full path - $parent cat --rev $parentrev --output $olddir/$DIR/$F $DIR/$F 2>/dev/null - fi - fi - else - # It's a rename (or a move), or a copy, so let's make sure we move - # to the right directory first, then restore it once done - current_dir=`pwd` - hg_root=`hg root` - cd $CWS - if [ -n "$rflag" ]; then - parentrev=$PARENT_REV - elif [ "$HG_LIST_FROM_COMMIT" -eq 1 ]; then - parentrev=$OUTREV - fi - if [ -z "$parentrev" ]; then - parentrev=`hg log -l1 $PDIR/$PF | $AWK -F: '/changeset/ {print $2}'` - fi - if [ -n "$parentrev" ]; then - mkdir -p $olddir/$PDIR - if [ -z "$parent" ]; then - hg cat -R $hg_root --rev $parentrev --output $olddir/$PDIR/$PF $PDIR/$PF 2>/dev/null - else - $parent cat --rev $parentrev --output $olddir/$PDIR/$PF $PDIR/$PF 2>/dev/null - fi - fi - cd $current_dir - fi -} - -function build_old_new -{ - if [[ $SCM_MODE == "mercurial" ]]; then - build_old_new_mercurial $@ - fi -} - - -# -# Usage message. -# -function usage -{ - print "Usage:\twebrev [options] - webrev [options] ( | - ) - -Options: - -v: Print the version of this tool. - -b: Do not ignore changes in the amount of white space. - -c : Include link to CR (aka bugid) in the main page. - -i : Include in the index.html file. - -o : Output webrev to specified directory. - -p : Use specified parent wkspc or basis for comparison - -u : Use that username instead of 'guessing' one. - -m: Forces the use of Mercurial - -Mercurial only options: - -r rev: Compare against a specified revision - -N: Skip 'hg outgoing', use only 'hg status' - -f: Use the forest extension - -Arguments: - : Optional file containing list of files to include in webrev - -: read list of files to include in webrev from standard input - -Environment: - WDIR: Control the output directory. - WEBREV_BUGURL: Control the URL prefix for bugids. - -" - - exit 2 -} - -# -# -# Main program starts here -# -# -LANG="C" -LC_ALL="C" -export LANG LC_ALL -trap "rm -f /tmp/$$.* ; exit" 0 1 2 3 15 - -set +o noclobber - -[[ -z $WDIFF ]] && WDIFF=`look_for_prog wdiff` -[[ -z $CODEREVIEW ]] && CODEREVIEW=`look_for_prog codereview` -[[ -z $PS2PDF ]] && PS2PDF=`look_for_prog ps2pdf` -[[ -z $PERL ]] && PERL=`look_for_prog perl` -[[ -z $SCCS ]] && SCCS=`look_for_prog sccs` -[[ -z $AWK ]] && AWK=`look_for_prog nawk` -[[ -z $AWK ]] && AWK=`look_for_prog gawk` -[[ -z $AWK ]] && AWK=`look_for_prog awk` -[[ -z $JAR ]] && JAR=`look_for_prog jar` -[[ -z $ZIP ]] && ZIP=`look_for_prog zip` -[[ -z $GETENT ]] && GETENT=`look_for_prog getent` -[[ -z $WGET ]] && WGET=`look_for_prog wget` - -if uname | grep CYGWIN >/dev/null -then - ISWIN=1 - # Under windows mercurial outputs '\' instead of '/' - FILTER="tr '\\\\' '/'" -else - FILTER="cat" -fi - -if [[ ! -x $PERL ]]; then - print -u2 "Error: No perl interpreter found. Exiting." - exit 1 -fi - -# -# These aren't fatal, but we want to note them to the user. -# -# [[ ! -x $CODEREVIEW ]] && print -u2 "WARNING: codereview(1) not found." -# [[ ! -x $PS2PDF ]] && print -u2 "WARNING: ps2pdf(1) not found." -# [[ ! -x $WDIFF ]] && print -u2 "WARNING: wdiff not found." - -# Declare global total counters. -integer TOTL TINS TDEL TMOD TUNC - -flist_mode= -flist_file= -bflag= -iflag= -oflag= -pflag= -uflag= -Oflag= -rflag= -Nflag= -forestflag= -while getopts "c:i:o:p:r:u:mONvfb" opt -do - case $opt in - b) bflag=1;; - - i) iflag=1 - INCLUDE_FILE=$OPTARG;; - - o) oflag=1 - WDIR=$OPTARG;; - - p) pflag=1 - codemgr_parent=$OPTARG;; - - u) uflag=1 - username=$OPTARG;; - - c) if [[ -z $CRID ]]; then - CRID=$OPTARG - else - CRID="$CRID $OPTARG" - fi;; - - m) SCM_MODE="mercurial";; - - O) Oflag=1;; # ignored (bugs are now all visible at bugs.openjdk.java.net) - - N) Nflag=1;; - - f) forestflag=1;; - - r) rflag=1 - PARENT_REV=$OPTARG;; - - v) print "$0 version: $WEBREV_UPDATED";; - - - ?) usage;; - esac -done - -FLIST=/tmp/$$.flist -HG_LIST_FROM_COMMIT= - -if [[ -n $forestflag && -n $rflag ]]; then - print "The -r flag is incompatible with the use of forests" - exit 2 -fi - -# -# If this manually set as the parent, and it appears to be an earlier webrev, -# then note that fact and set the parent to the raw_files/new subdirectory. -# -if [[ -n $pflag && -d $codemgr_parent/raw_files/new ]]; then - parent_webrev="$codemgr_parent" - codemgr_parent="$codemgr_parent/raw_files/new" -fi - -shift $(($OPTIND - 1)) - -if [[ $1 == "-" ]]; then - cat > $FLIST - flist_mode="stdin" - flist_done=1 - shift -elif [[ -n $1 ]]; then - if [[ ! -r $1 ]]; then - print -u2 "$1: no such file or not readable" - usage - fi - cat $1 > $FLIST - flist_mode="file" - flist_file=$1 - flist_done=1 - shift -else - flist_mode="auto" -fi - -# -# Before we go on to further consider -l and -w, work out which SCM we think -# is in use. -# -if [[ -z $SCM_MODE ]]; then - SCM_MODE=`detect_scm $FLIST` -fi -if [[ $SCM_MODE == "unknown" ]]; then - print -u2 "Unable to determine SCM type currently in use." - print -u2 "For mercurial: webrev runs 'hg root'." - exit 1 -fi - -print -u2 " SCM detected: $SCM_MODE" - - -if [[ $SCM_MODE == "mercurial" ]]; then - # - # determine Workspace and parent workspace paths - # - CWS=`hg root | $FILTER` - if [[ -n $pflag && -z "$PWS" ]]; then - OUTPWS=$codemgr_parent - # Let's try to expand it if it's an alias defined in [paths] - tmp=`hg path $OUTPWS 2>/dev/null | $FILTER` - if [[ -n $tmp ]]; then - OUTPWS="$tmp" - fi - if [[ -n $rflag ]]; then - if expr "$codemgr_parent" : 'ssh://.*' >/dev/null; then - PWS=$codemgr_parent - else - PWS=`hg -R "$codemgr_parent" root 2>/dev/null | $FILTER` - fi - fi - fi - # - # OUTPWS is the parent repository to use when using 'hg outgoing' - # - if [[ -z $Nflag ]]; then - if [[ -n $forestflag ]]; then - # - # for forest we have to rely on properly set default and - # default-push because they can be different from the top one. - # unless of course it was explicitly specified with -p - if [[ -z $pflag ]]; then - OUTPWS= - fi - else - # - # Unfortunately mercurial is bugged and doesn't handle - # aliases correctly in 'hg path default' - # So let's do it ourselves. Sigh... - if [[ -z "$OUTPWS" ]]; then - OUTPWS=`grep default-push $CWS/.hg/hgrc | $AWK '{print $3}' | $FILTER` - fi - # Still empty, means no default-push - if [[ -z "$OUTPWS" ]]; then - OUTPWS=`grep 'default =' $CWS/.hg/hgrc | $AWK '{print $3}' | $FILTER` - fi - # Let's try to expand it if it's an alias defined in [paths] - tmp=`hg path $OUTPWS 2>/dev/null | $FILTER` - if [[ -n $tmp ]]; then - OUTPWS="$tmp" - fi - fi - fi - # - # OUTPWS may contain username:password, let's make sure we remove the - # sensitive information before we print out anything in the HTML - # - OUTPWS2=$OUTPWS - if [[ -n $OUTPWS ]]; then - if [[ `expr "$OUTPWS" : '.*://[^/]*@.*'` -gt 0 ]]; then - # Remove everything between '://' and '@' - OUTPWS2=`echo $OUTPWS | sed -e 's/\(.*:\/\/\).*@\(.*\)/\1\2/'` - fi - fi - - if [[ -z $HG_BRANCH ]]; then - HG_BRANCH=`hg branch` - if [ "$HG_BRANCH" == "default" ]; then - # - # 'default' means no particular branch, so let's cancel that - # - HG_BRANCH= - fi - fi - - if [[ -z $forestflag ]]; then - if [[ -z $Nflag ]]; then - # - # If no "-N", always do "hg outgoing" against parent - # repository to determine list of outgoing revisions. - # - ALL_CREV=`hg outgoing -q --template '{rev}\n' $OUTPWS | sort -n` - if [[ -n $ALL_CREV ]]; then - FIRST_CREV=`echo "$ALL_CREV" | head -1` - # - # If no "-r", choose revision to compare against by - # finding the latest revision not in the outgoing list. - # - if [[ -z $rflag ]]; then - OUTREV=`find_outrev "$FIRST_CREV"` - if [[ -n $OUTREV ]]; then - HG_LIST_FROM_COMMIT=1 - fi - fi - fi - elif [[ -n $rflag ]]; then - # - # If skipping "hg outgoing" but still comparing against a - # specific revision (not the tip), set revision for comment - # accumulation. - # - FIRST_CREV=`hg log --rev $PARENT_REV --template '{rev}'` - FIRST_CREV=`expr $FIRST_CREV + 1` - fi - fi - #Let's check if a merge is needed, if so, issue a warning - PREV=`hg parent | grep '^tag:.*tip$'` - if [[ -z $PREV ]]; then - print "WARNING: parent rev is not tip. Maybe an update or merge is needed" - fi -fi - -if [[ $flist_mode == "stdin" ]]; then - print -u2 " File list from: standard input" -elif [[ $flist_mode == "file" ]]; then - print -u2 " File list from: $flist_file" -fi - -if [[ $# -gt 0 ]]; then - print -u2 "WARNING: unused arguments: $*" -fi - -if [[ $SCM_MODE == "mercurial" ]]; then - if [[ -z $flist_done ]]; then - flist_from_mercurial $PWS - fi -fi - -# -# If the user didn't specify a -i option, check to see if there is a -# webrev-info file in the workspace directory. -# -if [[ -z $iflag && -r "$CWS/webrev-info" ]]; then - iflag=1 - INCLUDE_FILE="$CWS/webrev-info" -fi - -if [[ -n $iflag ]]; then - if [[ ! -r $INCLUDE_FILE ]]; then - print -u2 "include file '$INCLUDE_FILE' does not exist or is" \ - "not readable." - exit 1 - else - # - # $INCLUDE_FILE may be a relative path, and the script alters - # PWD, so we just stash a copy in /tmp. - # - cp $INCLUDE_FILE /tmp/$$.include - fi -fi - -# -# Output directory. -# -if [[ -z $WDIR ]]; then - WDIR=$CWS/webrev -else - # If the output directory doesn't end with '/webrev' or '/webrev/' - # then add '/webrev'. This is for backward compatibility - if ! expr $WDIR : '.*/webrev/\?$' >/dev/null - then - WDIR=$WDIR/webrev - fi -fi -# WDIR=${WDIR:-$CWS/webrev} - -# -# Name of the webrev, derived from the workspace name; in the -# future this could potentially be an option. -# -# Let's keep what's after the last '/' -WNAME=${CWS##*/} - -# -# If WDIR doesn't start with '/' or 'x:' prepend the current dir -# -if [ ${WDIR%%/*} ]; then - if [[ -n $ISWIN ]]; then - if [ ${WDIR%%[A-Za-z]:*} ]; then - WDIR=$PWD/$WDIR - fi - else - WDIR=$PWD/$WDIR - fi -fi - -if [[ ! -d $WDIR ]]; then - mkdir -p $WDIR - [[ $? != 0 ]] && exit 1 -fi - -# -# Summarize what we're going to do. -# -print " Workspace: $CWS" -if [[ -n $parent_webrev ]]; then - print "Compare against: webrev at $parent_webrev" -elif [[ -n $OUTPWS2 ]]; then - print "Compare against: $OUTPWS2" -fi -if [[ -n $HG_BRANCH ]]; then - print " Branch: $HG_BRANCH" -fi -if [[ -n $rflag ]]; then - print "Compare against version: $PARENT_REV" -fi -[[ -n $INCLUDE_FILE ]] && print " Including: $INCLUDE_FILE" -print " Output to: $WDIR" - -# -# Save the file list in the webrev dir -# -[[ ! $FLIST -ef $WDIR/file.list ]] && cp $FLIST $WDIR/file.list - -# -# Bug IDs will be replaced by a URL. Order of precedence -# is: default location, $WEBREV_BUGURL -# -BUGURL='https://bugs.openjdk.java.net/browse/' -[[ -n $WEBREV_BUGURL ]] && BUGURL="$WEBREV_BUGURL" -IDPREFIX='JDK-' - - -rm -f $WDIR/$WNAME.patch -rm -f $WDIR/$WNAME.changeset -rm -f $WDIR/$WNAME.ps -rm -f $WDIR/$WNAME.pdf - -touch $WDIR/$WNAME.patch - -print " Output Files:" - -# -# Clean up the file list: Remove comments, blank lines and env variables. -# -sed -e "s/#.*$//" -e "/=/d" -e "/^[ ]*$/d" $FLIST > /tmp/$$.flist.clean -FLIST=/tmp/$$.flist.clean - -# -# Clean up residual raw files -# -if [ -d $WDIR/raw_files ]; then - rm -rf $WDIR/raw_files 2>/dev/null -fi - -# -# Should we ignore changes in white spaces when generating diffs? -# -if [[ -n $bflag ]]; then - DIFFOPTS="-t" -else - DIFFOPTS="-bt" -fi -# -# First pass through the files: generate the per-file webrev HTML-files. -# -while read LINE -do - set - $LINE - P=$1 - - if [[ $1 == "Revision:" ]]; then - OUTREV=$2 - continue - fi - # - # Normally, each line in the file list is just a pathname of a - # file that has been modified or created in the child. A file - # that is renamed in the child workspace has two names on the - # line: new name followed by the old name. - # - oldname="" - oldpath="" - rename= - if [[ $# -eq 2 ]]; then - PP=$2 # old filename - oldname=" (was $PP)" - oldpath="$PP" - rename=1 - PDIR=${PP%/*} - if [[ $PDIR == $PP ]]; then - PDIR="." # File at root of workspace - fi - - PF=${PP##*/} - - DIR=${P%/*} - if [[ $DIR == $P ]]; then - DIR="." # File at root of workspace - fi - - F=${P##*/} - else - DIR=${P%/*} - if [[ "$DIR" == "$P" ]]; then - DIR="." # File at root of workspace - fi - - F=${P##*/} - - PP=$P - PDIR=$DIR - PF=$F - fi - - # Make the webrev directory if necessary as it may have been - # removed because it was empty - if [ ! -d $CWS/$DIR ]; then - mkdir -p $CWS/$DIR - fi - - COMM=`getcomments html $P $PP` - - print "\t$P$oldname\n\t\t\c" - - # Make the webrev mirror directory if necessary - mkdir -p $WDIR/$DIR - - # cd to the directory so the names are short - cd $CWS/$DIR - - # - # We stash old and new files into parallel directories in /tmp - # and do our diffs there. This makes it possible to generate - # clean looking diffs which don't have absolute paths present. - # - olddir=$WDIR/raw_files/old - newdir=$WDIR/raw_files/new - mkdir -p $olddir - mkdir -p $newdir - mkdir -p $olddir/$PDIR - mkdir -p $newdir/$DIR - - build_old_new $olddir $newdir $DIR $F - - if [[ ! -f $F && ! -f $olddir/$DIR/$F ]]; then - print "*** Error: file not in parent or child" - continue - fi - - cd $WDIR/raw_files - ofile=old/$PDIR/$PF - nfile=new/$DIR/$F - - mv_but_nodiff= - cmp $ofile $nfile > /dev/null 2>&1 - if [[ $? == 0 && $rename == 1 ]]; then - mv_but_nodiff=1 - fi - - # - # Cleaning up - # - rm -f $WDIR/$DIR/$F.cdiff.html - rm -f $WDIR/$DIR/$F.udiff.html - rm -f $WDIR/$DIR/$F.wdiff.html - rm -f $WDIR/$DIR/$F.sdiff.html - rm -f $WDIR/$DIR/$F-.html - rm -f $WDIR/$DIR/$F.html - - its_a_jar= - if expr $F : '.*\.jar' \| $F : '.*\.zip' >/dev/null; then - its_a_jar=1 - # It's a JAR or ZIP file, let's do it differently - if [[ -z $JAR ]]; then - print "No access to jar, so can't produce diffs for jar or zip files" - else - if [ -f $ofile ]; then - $JAR -tvf $ofile >"$ofile".lst - fi - if [ -f $nfile ]; then - $JAR -tvf $nfile >"$nfile".lst - fi - - if [[ -f $ofile && -f $nfile && -z $mv_but_nodiff ]]; then - - ${CDIFFCMD:-diff -bt -C 5} $ofile.lst $nfile.lst > $WDIR/$DIR/$F.cdiff - diff_to_html $F $DIR/$F "C" "$COMM" < $WDIR/$DIR/$F.cdiff \ - > $WDIR/$DIR/$F.cdiff.html - print " cdiffs\c" - - ${UDIFFCMD:-diff -bt -U 5} $ofile.lst $nfile.lst > $WDIR/$DIR/$F.udiff - diff_to_html $F $DIR/$F "U" "$COMM" < $WDIR/$DIR/$F.udiff \ - > $WDIR/$DIR/$F.udiff.html - - print " udiffs\c" - - if [[ -x $WDIFF ]]; then - $WDIFF -c "$COMM" \ - -t "$WNAME Wdiff $DIR/$F" $ofile.lst $nfile.lst > \ - $WDIR/$DIR/$F.wdiff.html 2>/dev/null - if [[ $? -eq 0 ]]; then - print " wdiffs\c" - else - print " wdiffs[fail]\c" - fi - fi - - sdiff_to_html $ofile $nfile $F $DIR "$COMM" \ - > $WDIR/$DIR/$F.sdiff.html - print " sdiffs\c" - - print " frames\c" - - rm -f $WDIR/$DIR/$F.cdiff $WDIR/$DIR/$F.udiff - - difflines $ofile.lst $nfile.lst > $WDIR/$DIR/$F.count - - elif [[ -f $ofile && -f $nfile && -n $mv_but_nodiff ]]; then - # renamed file: may also have differences - difflines $ofile.lst $nfile.lst > $WDIR/$DIR/$F.count - elif [[ -f $nfile ]]; then - # new file: count added lines - difflines /dev/null $nfile.lst > $WDIR/$DIR/$F.count - elif [[ -f $ofile ]]; then - # old file: count deleted lines - difflines $ofile.lst /dev/null > $WDIR/$DIR/$F.count - fi - fi - else - - # - # If we have old and new versions of the file then run the - # appropriate diffs. This is complicated by a couple of factors: - # - # - renames must be handled specially: we emit a 'remove' - # diff and an 'add' diff - # - new files and deleted files must be handled specially - # - Solaris patch(1m) can't cope with file creation - # (and hence renames) as of this writing. - # - To make matters worse, gnu patch doesn't interpret the - # output of Solaris diff properly when it comes to - # adds and deletes. We need to do some "cleansing" - # transformations: - # [to add a file] @@ -1,0 +X,Y @@ --> @@ -0,0 +X,Y @@ - # [to del a file] @@ -X,Y +1,0 @@ --> @@ -X,Y +0,0 @@ - # - cleanse_rmfile="sed 's/^\(@@ [0-9+,-]*\) [0-9+,-]* @@$/\1 +0,0 @@/'" - cleanse_newfile="sed 's/^@@ [0-9+,-]* \([0-9+,-]* @@\)$/@@ -0,0 \1/'" - - if [[ ! "$HG_LIST_FROM_COMMIT" -eq 1 || ! $flist_mode == "auto" ]]; - then - # Only need to generate a patch file here if there are no commits in outgoing - # or if we've specified a file list - rm -f $WDIR/$DIR/$F.patch - if [[ -z $rename ]]; then - if [ ! -f $ofile ]; then - diff -u /dev/null $nfile | sh -c "$cleanse_newfile" \ - > $WDIR/$DIR/$F.patch - elif [ ! -f $nfile ]; then - diff -u $ofile /dev/null | sh -c "$cleanse_rmfile" \ - > $WDIR/$DIR/$F.patch - else - diff -u $ofile $nfile > $WDIR/$DIR/$F.patch - fi - else - diff -u $ofile /dev/null | sh -c "$cleanse_rmfile" \ - > $WDIR/$DIR/$F.patch - - diff -u /dev/null $nfile | sh -c "$cleanse_newfile" \ - >> $WDIR/$DIR/$F.patch - - fi - - - # - # Tack the patch we just made onto the accumulated patch for the - # whole wad. - # - cat $WDIR/$DIR/$F.patch >> $WDIR/$WNAME.patch - fi - - print " patch\c" - - if [[ -f $ofile && -f $nfile && -z $mv_but_nodiff ]]; then - - ${CDIFFCMD:-diff -bt -C 5} $ofile $nfile > $WDIR/$DIR/$F.cdiff - diff_to_html $F $DIR/$F "C" "$COMM" < $WDIR/$DIR/$F.cdiff \ - > $WDIR/$DIR/$F.cdiff.html - print " cdiffs\c" - - ${UDIFFCMD:-diff -bt -U 5} $ofile $nfile > $WDIR/$DIR/$F.udiff - diff_to_html $F $DIR/$F "U" "$COMM" < $WDIR/$DIR/$F.udiff \ - > $WDIR/$DIR/$F.udiff.html - - print " udiffs\c" - - if [[ -x $WDIFF ]]; then - $WDIFF -c "$COMM" \ - -t "$WNAME Wdiff $DIR/$F" $ofile $nfile > \ - $WDIR/$DIR/$F.wdiff.html 2>/dev/null - if [[ $? -eq 0 ]]; then - print " wdiffs\c" - else - print " wdiffs[fail]\c" - fi - fi - - sdiff_to_html $ofile $nfile $F $DIR "$COMM" \ - > $WDIR/$DIR/$F.sdiff.html - print " sdiffs\c" - - print " frames\c" - - rm -f $WDIR/$DIR/$F.cdiff $WDIR/$DIR/$F.udiff - - difflines $ofile $nfile > $WDIR/$DIR/$F.count - - elif [[ -f $ofile && -f $nfile && -n $mv_but_nodiff ]]; then - # renamed file: may also have differences - difflines $ofile $nfile > $WDIR/$DIR/$F.count - elif [[ -f $nfile ]]; then - # new file: count added lines - difflines /dev/null $nfile > $WDIR/$DIR/$F.count - elif [[ -f $ofile ]]; then - # old file: count deleted lines - difflines $ofile /dev/null > $WDIR/$DIR/$F.count - fi - fi - # - # Now we generate the postscript for this file. We generate diffs - # only in the event that there is delta, or the file is new (it seems - # tree-killing to print out the contents of deleted files). - # - if [[ -f $nfile ]]; then - ocr=$ofile - [[ ! -f $ofile ]] && ocr=/dev/null - - if [[ -z $mv_but_nodiff ]]; then - textcomm=`getcomments text $P $PP` - if [[ -x $CODEREVIEW ]]; then - $CODEREVIEW -y "$textcomm" \ - -e $ocr $nfile \ - > /tmp/$$.psfile 2>/dev/null && - cat /tmp/$$.psfile >> $WDIR/$WNAME.ps - if [[ $? -eq 0 ]]; then - print " ps\c" - else - print " ps[fail]\c" - fi - fi - fi - fi - - if [[ -f $ofile && -z $mv_but_nodiff ]]; then - if [[ -n $its_a_jar ]]; then - source_to_html Old $P < $ofile.lst > $WDIR/$DIR/$F-.html - else - source_to_html Old $P < $ofile > $WDIR/$DIR/$F-.html - fi - print " old\c" - fi - - if [[ -f $nfile ]]; then - if [[ -n $its_a_jar ]]; then - source_to_html New $P < $nfile.lst > $WDIR/$DIR/$F.html - else - source_to_html New $P < $nfile > $WDIR/$DIR/$F.html - fi - print " new\c" - fi - - print -done < $FLIST - -# Create the new style mercurial patch here using hg export -r [all-revs] -g -o $CHANGESETPATH -if [[ $SCM_MODE == "mercurial" ]]; then - if [[ "$HG_LIST_FROM_COMMIT" -eq 1 && $flist_mode == "auto" ]]; then - EXPORTCHANGESET="$WNAME.changeset" - CHANGESETPATH=${WDIR}/${EXPORTCHANGESET} - rm -f $CHANGESETPATH - touch $CHANGESETPATH - if [[ -n $ALL_CREV ]]; then - rev_opt= - for rev in $ALL_CREV; do - rev_opt="$rev_opt --rev $rev" - done - elif [[ -n $FIRST_CREV ]]; then - rev_opt="--rev $FIRST_CREV" - fi - - if [[ -n $rev_opt ]]; then - (cd $CWS;hg export -g $rev_opt -o $CHANGESETPATH) - echo "Created changeset: $CHANGESETPATH" 1>&2 - # Use it in place of the jdk.patch created above - rm -f $WDIR/$WNAME.patch - fi - set +x - fi -fi - -frame_nav_js > $WDIR/ancnav.js -frame_navigation > $WDIR/ancnav.html - -if [[ -f $WDIR/$WNAME.ps && -x $CODEREVIEW && -x $PS2PDF ]]; then - print " Generating PDF: \c" - fix_postscript $WDIR/$WNAME.ps | $PS2PDF - > $WDIR/$WNAME.pdf - print "Done." -fi - -# Now build the index.html file that contains -# links to the source files and their diffs. - -cd $CWS - -# Save total changed lines for Code Inspection. -print "$TOTL" > $WDIR/TotalChangedLines - -print " index.html: \c" -INDEXFILE=$WDIR/index.html -exec 3<&1 # duplicate stdout to FD3. -exec 1<&- # Close stdout. -exec > $INDEXFILE # Open stdout to index file. - -print "$HTML" -print "" -print "$STDHEAD" -print "$WNAME" -print "" -print "" -print "
" -print "

Code Review for $WNAME

" - -print "" - -if [[ -z $uflag ]]; then - if [[ $SCM_MODE == "mercurial" ]]; then - # - # Let's try to extract the user name from the .hgrc file - # - username=`grep '^username' $HOME/.hgrc | sed 's/^username[ ]*=[ ]*\(.*\)/\1/'` - fi - - if [[ -z $username ]]; then - # - # Figure out the username and gcos name. To maintain compatibility - # with passwd(4), we must support '&' substitutions. - # - username=`id | cut -d '(' -f 2 | cut -d ')' -f 1` - if [[ -x $GETENT ]]; then - realname=`$GETENT passwd $username | cut -d':' -f 5 | cut -d ',' -f 1` - fi - userupper=`print "$username" | sed 's/\<./\u&/g'` - realname=`print $realname | sed s/\&/$userupper/` - fi -fi - -date="on `date`" - -if [[ -n "$username" && -n "$realname" ]]; then - print "" - print "" -elif [[ -n "$username" ]]; then - print "" -fi - -print "" -if [[ -n $parent_webrev ]]; then - print "" -if [[ -n $rflag ]]; then - print "" -elif [[ -n $OUTREV ]]; then - if [[ -z $forestflag ]]; then - print "" - fi -fi -if [[ -n $HG_BRANCH ]]; then - print "" -fi - -print "" - -if [[ -f $WDIR/$WNAME.patch ]]; then - print "" -elif [[ -f $CHANGESETPATH ]]; then - print "" -fi - -if [[ -f $WDIR/$WNAME.pdf ]]; then - print "" -fi - -if [[ -n "$iflag" ]]; then - print "" -fi -# Add links to referenced CRs, if any -# URL has a like: -# <title>[#JDK-8024688] b106-lambda: j.u.Map.merge doesn't work as specified if contains key:null pair - Java Bug System -# we format this to: -# JDK-8024688: b106-lambda: j.u.Map.merge doesn't work as specified if contains key:null pair -if [[ -n $CRID ]]; then - for id in $CRID - do - #add "JDK-" to raw bug id for openjdk.java.net links. - id=`echo ${id} | sed 's/^\([0-9]\{5,\}\)$/JDK-\1/'` - - print "
Prepared by:$realname ($username) $date
Prepared by:$username $date
Workspace:$CWS
Compare against:" - print "webrev at $parent_webrev" -else - if [[ -n $OUTPWS2 ]]; then - print "
Compare against:" - print "$OUTPWS2" - fi -fi -print "
Compare against version:$PARENT_REV
Compare against version:$OUTREV
Branch:$HG_BRANCH
Summary of changes:" -printCI $TOTL $TINS $TDEL $TMOD $TUNC -print "
Patch of changes:" - print "$WNAME.patch
Changeset:" - print "$EXPORTCHANGESET
Printable review:" - print "$WNAME.pdf
Author comments:
" - cat /tmp/$$.include - print "
Bug id:" - url="${BUGURL}${id}" - - if [[ -n $WGET ]]; then - msg=`$WGET --timeout=10 --tries=1 -q $url -O - | grep '' | sed 's/<title>\[#\(.*\)\] \(.*\) - Java Bug System<\/title>/\1 : \2/' | html_dequote | html_quote` - fi - if [[ -z $msg ]]; then - msg="${id}" - fi - - print "<a href=\"$url\">$msg</a>" - - print "</td></tr>" - done -fi -print "<tr><th>Legend:</th><td>" -print "<b>Modified file</b><br><font color=red><b>Deleted file</b></font><br><font color=green><b>New file</b></font></td></tr>" -print "</table>" -print "</div>" - -# -# Second pass through the files: generate the rest of the index file -# -while read LINE -do - set - $LINE - if [[ $1 == "Revision:" ]]; then - FIRST_CREV=`expr $3 + 1` - continue - fi - P=$1 - - if [[ $# == 2 ]]; then - PP=$2 - oldname=" <i>(was $PP)</i>" - - else - PP=$P - oldname="" - fi - - DIR=${P%/*} - if [[ $DIR == $P ]]; then - DIR="." # File at root of workspace - fi - - # Avoid processing the same file twice. - # It's possible for renamed files to - # appear twice in the file list - - F=$WDIR/$P - - print "<p><code>" - - # If there's a diffs file, make diffs links - - NODIFFS= - if [[ -f $F.cdiff.html ]]; then - print "<a href=\"$P.cdiff.html\">Cdiffs</a>" - print "<a href=\"$P.udiff.html\">Udiffs</a>" - - if [[ -f $F.wdiff.html && -x $WDIFF ]]; then - print "<a href=\"$P.wdiff.html\">Wdiffs</a>" - fi - - print "<a href=\"$P.sdiff.html\">Sdiffs</a>" - - print "<a href=\"$P.frames.html\">Frames</a>" - else - NODIFFS=1 - print " ------ ------ ------" - - if [[ -x $WDIFF ]]; then - print " ------" - fi - - print " ------" - fi - - # If there's an old file, make the link - - NOOLD= - if [[ -f $F-.html ]]; then - print "<a href=\"$P-.html\">Old</a>" - else - NOOLD=1 - print " ---" - fi - - # If there's an new file, make the link - - NONEW= - if [[ -f $F.html ]]; then - print "<a href=\"$P.html\">New</a>" - else - NONEW=1 - print " ---" - fi - - if [[ -f $F.patch ]]; then - print "<a href=\"$P.patch\">Patch</a>" - else - print " -----" - fi - - if [[ -f $WDIR/raw_files/new/$P ]]; then - print "<a href=\"raw_files/new/$P\">Raw</a>" - else - print " ---" - fi - print "</code>" - if [[ -n $NODIFFS && -z $oldname ]]; then - if [[ -n $NOOLD ]]; then - print "<font color=green><b>$P</b></font>" - elif [[ -n $NONEW ]]; then - print "<font color=red><b>$P</b></font>" - fi - else - print "<b>$P</b> $oldname" - fi - - print "</p><blockquote>\c" - # Insert delta comments if any - comments=`getcomments html $P $PP` - if [ -n "$comments" ]; then - print "<pre>$comments</pre>" - fi - - # Add additional comments comment - - print "<!-- Add comments to explain changes in $P here -->" - - # Add count of changes. - - if [[ -f $F.count ]]; then - cat $F.count - rm $F.count - fi - print "</blockquote>" -done < $FLIST - -print -print -print "<hr />" -print "<p style=\"font-size: small\">" -print "This code review page was prepared using <b>$0</b>" -print "(vers $WEBREV_UPDATED)." -print "</body>" -print "</html>" - -if [[ -n $ZIP ]]; then - # Let's generate a zip file for convenience - cd $WDIR/.. - if [ -f webrev.zip ]; then - rm webrev.zip - fi - $ZIP -r webrev webrev >/dev/null 2>&1 -fi - -exec 1<&- # Close FD 1. -exec 1<&3 # dup FD 3 to restore stdout. -exec 3<&- # close FD 3. - -print "Done." -print "Output to: $WDIR" diff --git a/nashorn/.hgtags b/nashorn/.hgtags index 0d739aa62f6..3d90b565999 100644 --- a/nashorn/.hgtags +++ b/nashorn/.hgtags @@ -230,3 +230,8 @@ f0d3ac2474ee755b1180ec71bcdfa190845b17eb jdk8-b115 8d014b039b44c23fa520ce20c2c27f7aa91441e9 jdk8-b118 c3343930c73c58a22c1d58719bb988aeb25a871f jdk8-b119 55cbc2d00c93f82513ce33819d41dc67e71aaefd jdk8-b120 +32631eed0fad2b31346eb41b29a50227bd29e2ec jdk8-b121 +9d112a0e7df737f3b1fa2a021d5bb350ed56c1b7 jdk8-b122 +688f4167f92188482b0d80e315c72f726c6d5ff6 jdk8-b123 +32631eed0fad2b31346eb41b29a50227bd29e2ec jdk9-b00 +65347535840f045f2cd4341d7466c51009b1b06f jdk9-b01 diff --git a/nashorn/.jcheck/conf b/nashorn/.jcheck/conf index 6d0dbe48e36..5c6f62dc12c 100644 --- a/nashorn/.jcheck/conf +++ b/nashorn/.jcheck/conf @@ -1 +1 @@ -project=jdk8 +project=jdk9 diff --git a/nashorn/bin/jjs.bat b/nashorn/bin/jjs.bat deleted file mode 100644 index 3c1c1595c47..00000000000 --- a/nashorn/bin/jjs.bat +++ /dev/null @@ -1,27 +0,0 @@ -rem -rem Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. -rem DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -rem -rem This code is free software; you can redistribute it and/or modify it -rem under the terms of the GNU General Public License version 2 only, as -rem published by the Free Software Foundation. Oracle designates this -rem particular file as subject to the "Classpath" exception as provided -rem by Oracle in the LICENSE file that accompanied this code. -rem -rem This code is distributed in the hope that it will be useful, but WITHOUT -rem ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -rem FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -rem version 2 for more details (a copy is included in the LICENSE file that -rem accompanied this code). -rem -rem You should have received a copy of the GNU General Public License version -rem 2 along with this work; if not, write to the Free Software Foundation, -rem Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -rem -rem Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -rem or visit www.oracle.com if you need additional information or have any -rem questions. -rem -@echo off - -java -Xms2G -Xmx2G -XX:-TieredCompilation -server -esa -ea -Djava.ext.dirs=%~dp0\..\dist -XX:+HeapDumpOnOutOfMemoryError -Dnashorn.debug=true -Djava.lang.invoke.MethodHandle.DEBUG_NAMES=false jdk.nashorn.tools.Shell diff --git a/nashorn/bin/jjssecure.bat b/nashorn/bin/jjssecure.bat deleted file mode 100644 index f8da10aaaf6..00000000000 --- a/nashorn/bin/jjssecure.bat +++ /dev/null @@ -1,27 +0,0 @@ -rem -rem Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. -rem DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -rem -rem This code is free software; you can redistribute it and/or modify it -rem under the terms of the GNU General Public License version 2 only, as -rem published by the Free Software Foundation. Oracle designates this -rem particular file as subject to the "Classpath" exception as provided -rem by Oracle in the LICENSE file that accompanied this code. -rem -rem This code is distributed in the hope that it will be useful, but WITHOUT -rem ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -rem FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -rem version 2 for more details (a copy is included in the LICENSE file that -rem accompanied this code). -rem -rem You should have received a copy of the GNU General Public License version -rem 2 along with this work; if not, write to the Free Software Foundation, -rem Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -rem -rem Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -rem or visit www.oracle.com if you need additional information or have any -rem questions. -rem -@echo off - -java -Xms2G -Xmx2G -XX:-TieredCompilation -server -esa -ea -Djava.security.properties=%~dp0\..\make\java.security.override -Djava.ext.dirs=%~dp0\..\dist -XX:+HeapDumpOnOutOfMemoryError -Dnashorn.debug=true -Djava.lang.invoke.MethodHandle.DEBUG_NAMES=false -Dnashorn.home=%~dp0\.. -Djava.security.manager jdk.nashorn.tools.Shell diff --git a/nashorn/bin/nashorn.bat b/nashorn/bin/nashorn.bat deleted file mode 100644 index 2961ac699a4..00000000000 --- a/nashorn/bin/nashorn.bat +++ /dev/null @@ -1,27 +0,0 @@ -rem -rem Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. -rem DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -rem -rem This code is free software; you can redistribute it and/or modify it -rem under the terms of the GNU General Public License version 2 only, as -rem published by the Free Software Foundation. Oracle designates this -rem particular file as subject to the "Classpath" exception as provided -rem by Oracle in the LICENSE file that accompanied this code. -rem -rem This code is distributed in the hope that it will be useful, but WITHOUT -rem ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -rem FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -rem version 2 for more details (a copy is included in the LICENSE file that -rem accompanied this code). -rem -rem You should have received a copy of the GNU General Public License version -rem 2 along with this work; if not, write to the Free Software Foundation, -rem Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -rem -rem Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -rem or visit www.oracle.com if you need additional information or have any -rem questions. -rem -@echo off - -jrunscript -J-Xms2G -J-Xmx2G -J-XX:-TieredCompilation -J-server -J-esa -J-ea -J-Djava.ext.dirs=%~dp0\..\dist -J-XX:+HeapDumpOnOutOfMemoryError -J-Dnashorn.debug=true -J-Djava.lang.invoke.MethodHandle.DEBUG_NAMES=false -l nashorn diff --git a/nashorn/bin/nashornsecure.bat b/nashorn/bin/nashornsecure.bat deleted file mode 100644 index 5a4eca63c64..00000000000 --- a/nashorn/bin/nashornsecure.bat +++ /dev/null @@ -1,27 +0,0 @@ -rem -rem Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. -rem DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -rem -rem This code is free software; you can redistribute it and/or modify it -rem under the terms of the GNU General Public License version 2 only, as -rem published by the Free Software Foundation. Oracle designates this -rem particular file as subject to the "Classpath" exception as provided -rem by Oracle in the LICENSE file that accompanied this code. -rem -rem This code is distributed in the hope that it will be useful, but WITHOUT -rem ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -rem FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -rem version 2 for more details (a copy is included in the LICENSE file that -rem accompanied this code). -rem -rem You should have received a copy of the GNU General Public License version -rem 2 along with this work; if not, write to the Free Software Foundation, -rem Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -rem -rem Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -rem or visit www.oracle.com if you need additional information or have any -rem questions. -rem -@echo off - -jrunscript -J-Djava.security.properties=%~dp0\..\make\java.security.override -J-Djava.security.manager -J-Xms2G -J-Xmx2G -J-XX:-TieredCompilation -J-server -J-esa -J-ea -J-Djava.ext.dirs=%~dp0\..\dist -J-XX:+HeapDumpOnOutOfMemoryError -J-Dnashorn.debug=true -J-Djava.lang.invoke.MethodHandle.DEBUG_NAMES=false -l nashorn diff --git a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/MemberInfo.java b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/MemberInfo.java index 3fdd7c686bb..c43bdf52512 100644 --- a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/MemberInfo.java +++ b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/MemberInfo.java @@ -279,10 +279,6 @@ public final class MemberInfo implements Cloneable { } } } else if (kind == Kind.FUNCTION) { - final Type returnType = Type.getReturnType(javaDesc); - if (! returnType.toString().equals(OBJECT_DESC)) { - error("return value should be of Object type, found" + returnType); - } final Type[] argTypes = Type.getArgumentTypes(javaDesc); if (argTypes.length < 1) { error("function methods should have at least 1 arg"); diff --git a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/MethodGenerator.java b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/MethodGenerator.java index 475d7328c69..479d1d31f21 100644 --- a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/MethodGenerator.java +++ b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/MethodGenerator.java @@ -349,19 +349,19 @@ public class MethodGenerator extends MethodVisitor { // invokes, field get/sets void invokeInterface(final String owner, final String method, final String desc) { - super.visitMethodInsn(INVOKEINTERFACE, owner, method, desc); + super.visitMethodInsn(INVOKEINTERFACE, owner, method, desc, true); } void invokeVirtual(final String owner, final String method, final String desc) { - super.visitMethodInsn(INVOKEVIRTUAL, owner, method, desc); + super.visitMethodInsn(INVOKEVIRTUAL, owner, method, desc, false); } void invokeSpecial(final String owner, final String method, final String desc) { - super.visitMethodInsn(INVOKESPECIAL, owner, method, desc); + super.visitMethodInsn(INVOKESPECIAL, owner, method, desc, false); } void invokeStatic(final String owner, final String method, final String desc) { - super.visitMethodInsn(INVOKESTATIC, owner, method, desc); + super.visitMethodInsn(INVOKESTATIC, owner, method, desc, false); } void putStatic(final String owner, final String field, final String desc) { @@ -413,7 +413,7 @@ public class MethodGenerator extends MethodVisitor { super.visitMethodInsn(INVOKEVIRTUAL, "java/io/PrintStream", "println", - "(Ljava/lang/String;)V"); + "(Ljava/lang/String;)V", false); } // print the object on the top of the stack @@ -426,6 +426,6 @@ public class MethodGenerator extends MethodVisitor { super.visitMethodInsn(INVOKEVIRTUAL, "java/io/PrintStream", "println", - "(Ljava/lang/Object;)V"); + "(Ljava/lang/Object;)V", false); } } diff --git a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ScriptClassInstrumentor.java b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ScriptClassInstrumentor.java index 72250de79bc..0ec233ae8c8 100644 --- a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ScriptClassInstrumentor.java +++ b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ScriptClassInstrumentor.java @@ -146,16 +146,16 @@ public class ScriptClassInstrumentor extends ClassVisitor { // call $clinit$ just before return from <clinit> if (isStaticInit && opcode == RETURN) { super.visitMethodInsn(INVOKESTATIC, scriptClassInfo.getJavaName(), - $CLINIT$, DEFAULT_INIT_DESC); + $CLINIT$, DEFAULT_INIT_DESC, false); } super.visitInsn(opcode); } @Override - public void visitMethodInsn(final int opcode, final String owner, final String name, final String desc) { + public void visitMethodInsn(final int opcode, final String owner, final String name, final String desc, final boolean itf) { if (isConstructor && opcode == INVOKESPECIAL && INIT.equals(name) && SCRIPTOBJECT_TYPE.equals(owner)) { - super.visitMethodInsn(opcode, owner, name, desc); + super.visitMethodInsn(opcode, owner, name, desc, false); if (memberCount > 0) { // initialize @Property fields if needed @@ -166,7 +166,7 @@ public class ScriptClassInstrumentor extends ClassVisitor { super.visitTypeInsn(NEW, clazz); super.visitInsn(DUP); super.visitMethodInsn(INVOKESPECIAL, clazz, - INIT, DEFAULT_INIT_DESC); + INIT, DEFAULT_INIT_DESC, false); super.visitFieldInsn(PUTFIELD, scriptClassInfo.getJavaName(), memInfo.getJavaName(), memInfo.getJavaDesc()); } @@ -180,7 +180,7 @@ public class ScriptClassInstrumentor extends ClassVisitor { } } } else { - super.visitMethodInsn(opcode, owner, name, desc); + super.visitMethodInsn(opcode, owner, name, desc, itf); } } diff --git a/nashorn/make/build-benchmark.xml b/nashorn/make/build-benchmark.xml index 8f2296b028e..8225df1cf0c 100644 --- a/nashorn/make/build-benchmark.xml +++ b/nashorn/make/build-benchmark.xml @@ -239,7 +239,7 @@ </antcall> </target> - <target name="octane-regexp-octane-v8" depends="jar"> + <target name="octane-regexp-v8" depends="jar"> <antcall target="run-octane-v8"> <param name="octane-tests" value="regexp"/> </antcall> @@ -291,17 +291,56 @@ </antcall> </target> + <!-- splay --> + <target name="octane-typescript" depends="jar"> + <antcall target="run-octane"> + <param name="octane-tests" value="typescript"/> + </antcall> + </target> + + <target name="octane-typescript-v8" depends="jar"> + <antcall target="run-octane-v8"> + <param name="octane-typescript" value="typescript"/> + </antcall> + </target> + + <target name="octane-typescript-rhino" depends="jar"> + <antcall target="run-octane-rhino"> + <param name="octane-tests" value="typescript"/> + </antcall> + </target> + + <!-- zlib --> + <target name="octane-zlib" depends="jar"> + <antcall target="run-octane"> + <param name="octane-tests" value="zlib"/> + </antcall> + </target> + + <target name="octane-zlib-v8" depends="jar"> + <antcall target="run-octane-v8"> + <param name="octane-typescript" value="zlib"/> + </antcall> + </target> + + <target name="octane-zlib-rhino" depends="jar"> + <antcall target="run-octane-rhino"> + <param name="octane-tests" value="zlib"/> + </antcall> + </target> + <!-- run octane benchmarks in a single process --> <target name="octane-single-process" depends="octane-init"> <antcall target="run-octane"/> </target> - <!-- mandreel excluded due to OOM --> + <!-- zlib excluded due to missing implementation of 'read' --> <target name="octane-separate-process" depends= "octane-box2d, octane-code-load, octane-crypto, octane-deltablue, octane-earley-boyer, octane-gbemu, - octane-navier-stokes, octane-pdfjs, octane-raytrace, - octane-regexp, octane-richards, octane-splay"/> + octane-mandreel, octane-navier-stokes, octane-pdfjs, + octane-raytrace, octane-regexp, octane-richards, + octane-splay, octane-typescript"/> <target name="--single-process" unless="${octane-test-sys-prop.separate.process}"> <antcall target="octane-single-process"/> @@ -330,6 +369,9 @@ dir="."> <jvmarg line="${ext.class.path}"/> <jvmarg line="${run.test.jvmargs.octane} -Xms${run.test.xms} -Xmx${run.test.xmx}"/> + <syspropertyset> + <propertyref prefix="nashorn."/> + </syspropertyset> <arg value="${octane-test-sys-prop.test.js.framework}"/> <arg value="--"/> <arg value="${octane-tests}"/> diff --git a/nashorn/make/build.xml b/nashorn/make/build.xml index 7d1f42aea0c..93342248de5 100644 --- a/nashorn/make/build.xml +++ b/nashorn/make/build.xml @@ -66,13 +66,16 @@ <condition property="exclude.list" value="./exclude/exclude_list_cc.txt" else="./exclude/exclude_list.txt"> <istrue value="${make.code.coverage}" /> </condition> + + <condition property="jfr.options" value="${run.test.jvmargs.jfr}" else=""> + <istrue value="${jfr}"/> + </condition> </target> <target name="init" depends="init-conditions, init-cc"> - <!-- extends jvm args --> - <property name="run.test.jvmargs" value="${run.test.jvmargs.main} ${run.test.cc.jvmargs}"/> - <property name="run.test.jvmargs.octane" value="${run.test.jvmargs.octane.main} ${run.test.cc.jvmargs}" /> + <property name="run.test.jvmargs" value="${run.test.jvmargs.main} ${run.test.cc.jvmargs} ${jfr.options}"/> + <property name="run.test.jvmargs.octane" value="${run.test.jvmargs.octane.main} ${run.test.cc.jvmargs} ${jfr.options}"/> <echo message="run.test.jvmargs=${run.test.jvmargs}"/> <echo message="run.test.jvmargs.octane=${run.test.jvmargs.octane}"/> @@ -301,6 +304,10 @@ grant codeBase "file:/${basedir}/test/script/basic/classloader.js" { permission java.lang.RuntimePermission "nashorn.JavaReflection"; }; +grant codeBase "file:/${basedir}/test/script/markdown.js" { + permission java.io.FilePermission "${basedir}/test/script/external/showdown/-", "read"; +}; + </echo> <replace file="${build.dir}/nashorn.policy"><replacetoken>\</replacetoken><replacevalue>/</replacevalue></replace> <!--hack for Windows - to make URLs with normal path separators --> @@ -316,6 +323,7 @@ grant codeBase "file:/${basedir}/test/script/basic/classloader.js" { <available file="${test.external.dir}/yui" property="test-sys-prop.external.yui"/> <available file="${test.external.dir}/jquery" property="test-sys-prop.external.jquery"/> <available file="${test.external.dir}/test262" property="test-sys-prop.external.test262"/> + <available file="${test.external.dir}/showdown" property="test-sys-prop.external.markdown"/> </target> <target name="check-testng" unless="testng.available"> @@ -338,6 +346,9 @@ grant codeBase "file:/${basedir}/test/script/basic/classloader.js" { verbose="${testng.verbose}" haltonfailure="true" useDefaultListeners="false" listeners="${testng.listeners}" workingDir="${basedir}"> <jvmarg line="${ext.class.path}"/> <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs}"/> + <propertyset> + <propertyref prefix="nashorn."/> + </propertyset> <propertyset> <propertyref prefix="test-sys-prop."/> <mapper from="test-sys-prop.*" to="*" type="glob"/> @@ -393,6 +404,25 @@ grant codeBase "file:/${basedir}/test/script/basic/classloader.js" { </testng> </target> + <target name="testmarkdown" depends="jar, check-testng, check-external-tests, compile-test, generate-policy-file" if="testng.available"> + <fileset id="test.classes" dir="${build.test.classes.dir}"> + <include name="**/framework/*Test.class"/> + </fileset> + + <testng outputdir="${build.test.results.dir}" classfilesetref="test.classes" + verbose="${testng.verbose}" haltonfailure="true" useDefaultListeners="false" listeners="${testng.listeners}" workingDir="${basedir}"> + <jvmarg line="${ext.class.path}"/> + <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs}"/> + <propertyset> + <propertyref prefix="testmarkdown-test-sys-prop."/> + <mapper from="testmarkdown-test-sys-prop.*" to="*" type="glob"/> + </propertyset> + <classpath> + <pathelement path="${run.test.classpath}"/> + </classpath> + </testng> + </target> + <target name="test262" depends="jar, check-testng, check-external-tests, compile-test, generate-policy-file" if="testng.available"> <fileset id="test.classes" dir="${build.test.classes.dir}"> <include name="**/framework/*Test.class"/> @@ -402,6 +432,9 @@ grant codeBase "file:/${basedir}/test/script/basic/classloader.js" { verbose="${testng.verbose}" haltonfailure="true" useDefaultListeners="false" listeners="${testng.listeners}" workingDir="${basedir}"> <jvmarg line="${ext.class.path}"/> <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs}"/> + <propertyset> + <propertyref prefix="nashorn."/> + </propertyset> <propertyset> <propertyref prefix="test262-test-sys-prop."/> <mapper from="test262-test-sys-prop.*" to="*" type="glob"/> @@ -537,6 +570,11 @@ grant codeBase "file:/${basedir}/test/script/basic/classloader.js" { <mkdir dir="${test.external.dir}/yui"/> <get src="http://yui.yahooapis.com/3.5.1/build/yui/yui.js" dest="${test.external.dir}/yui" skipexisting="true" ignoreerrors="true"/> <get src="http://yui.yahooapis.com/3.5.1/build/yui/yui-min.js" dest="${test.external.dir}/yui" skipexisting="true" ignoreerrors="true"/> + + <!-- showdown --> + <mkdir dir="${test.external.dir}/showdown"/> + <get src="https://raw.github.com/coreyti/showdown/master/src/showdown.js" dest="${test.external.dir}/showdown" skipexisting="true" ignoreerrors="true"/> + <get src="https://raw.github.com/coreyti/showdown/master/src/extensions/table.js" dest="${test.external.dir}/showdown" skipexisting="true" ignoreerrors="true"/> </target> diff --git a/nashorn/make/project.properties b/nashorn/make/project.properties index c3ffca4ec68..ad36744836b 100644 --- a/nashorn/make/project.properties +++ b/nashorn/make/project.properties @@ -71,6 +71,9 @@ fxshell.classes.dir = ${build.dir}/fxshell/classes fxshell.dir = tools/fxshell fxshell.jar = ${dist.dir}/nashornfx.jar +# configuration for java flight recorder +run.test.jvmargs.jfr=-XX:+UnlockCommercialFeatures -XX:+FlightRecorder -XX:FlightRecorderOptions=defaultrecording=true,disk=true,dumponexit=true,dumponexitpath=${build.dir},stackdepth=128 + # jars refererred file.reference.testng.jar=test/lib/testng.jar @@ -119,6 +122,7 @@ test.external.dir=test/script/external test262.dir=${test.external.dir}/test262 test262.suite.dir=${test262.dir}/test/suite testjfx.dir=${test.script.dir}/jfx +testmarkdown.dir=${test.script.dir}/markdown test-sys-prop.test.dir=${test.dir} test-sys-prop.test.js.roots=${test.basic.dir} ${test.error.dir} ${test.sandbox.dir} ${test.trusted.dir} @@ -209,6 +213,16 @@ test262-test-sys-prop.test.js.framework=\ ${test262.dir}/test/harness/framework.js \ ${test262.dir}/test/harness/sta.js +# testmarkdown test root +testmarkdown-test-sys-prop.test.js.roots=${testmarkdown.dir} + +# execute testmarkdown tests in shared nashorn context or not? +testmarkdown-test-sys-prop.test.js.shared.context=false + +# framework root for markdown script tests +testmarkdown-test-sys-prop.test.js.framework=\ + ${test.script.dir}${file.separator}markdown.js + # testjfx test root testjfx-test-sys-prop.test.js.roots=${testjfx.dir} diff --git a/nashorn/src/jdk/nashorn/api/scripting/NashornException.java b/nashorn/src/jdk/nashorn/api/scripting/NashornException.java index d5ec5bb4a60..a5f8c24a2e6 100644 --- a/nashorn/src/jdk/nashorn/api/scripting/NashornException.java +++ b/nashorn/src/jdk/nashorn/api/scripting/NashornException.java @@ -29,6 +29,7 @@ import java.util.ArrayList; import java.util.List; import jdk.nashorn.internal.codegen.CompilerConstants; import jdk.nashorn.internal.runtime.ECMAErrors; +import jdk.nashorn.internal.runtime.ScriptObject; /** * This is base exception for all Nashorn exceptions. These originate from @@ -44,11 +45,13 @@ import jdk.nashorn.internal.runtime.ECMAErrors; @SuppressWarnings("serial") public abstract class NashornException extends RuntimeException { // script file name - private final String fileName; + private String fileName; // script line number - private final int line; + private int line; // script column number - private final int column; + private int column; + // underlying ECMA error object - lazily initialized + private Object ecmaError; /** script source name used for "engine.js" */ public static final String ENGINE_SCRIPT_SOURCE_NAME = "nashorn:engine/resources/engine.js"; @@ -121,6 +124,15 @@ public abstract class NashornException extends RuntimeException { return fileName; } + /** + * Set the source file name for this {@code NashornException} + * + * @param fileName the file name + */ + public final void setFileName(final String fileName) { + this.fileName = fileName; + } + /** * Get the line number for this {@code NashornException} * @@ -130,15 +142,33 @@ public abstract class NashornException extends RuntimeException { return line; } + /** + * Set the line number for this {@code NashornException} + * + * @param line the line number + */ + public final void setLineNumber(final int line) { + this.line = line; + } + /** * Get the column for this {@code NashornException} * - * @return the column + * @return the column number */ public final int getColumnNumber() { return column; } + /** + * Set the column for this {@code NashornException} + * + * @param column the column number + */ + public final void setColumnNumber(final int column) { + this.column = column; + } + /** * Returns array javascript stack frames from the given exception object. * @@ -155,6 +185,11 @@ public abstract class NashornException extends RuntimeException { if (methodName.equals(CompilerConstants.RUN_SCRIPT.symbolName())) { methodName = "<program>"; } + + if (methodName.contains(CompilerConstants.ANON_FUNCTION_PREFIX.symbolName())) { + methodName = "<anonymous>"; + } + filtered.add(new StackTraceElement(className, methodName, st.getFileName(), st.getLineNumber())); } @@ -188,4 +223,43 @@ public abstract class NashornException extends RuntimeException { } return buf.toString(); } + + protected Object getThrown() { + return null; + } + + protected NashornException initEcmaError(final ScriptObject global) { + if (ecmaError != null) { + return this; // initialized already! + } + + final Object thrown = getThrown(); + if (thrown instanceof ScriptObject) { + setEcmaError(ScriptObjectMirror.wrap(thrown, global)); + } else { + setEcmaError(thrown); + } + + return this; + } + + /** + * Return the underlying ECMA error object, if available. + * + * @return underlying ECMA Error object's mirror or whatever was thrown + * from script such as a String, Number or a Boolean. + */ + public Object getEcmaError() { + return ecmaError; + } + + /** + * Return the underlying ECMA error object, if available. + * + * @param ecmaError underlying ECMA Error object's mirror or whatever was thrown + * from script such as a String, Number or a Boolean. + */ + public void setEcmaError(final Object ecmaError) { + this.ecmaError = ecmaError; + } } diff --git a/nashorn/src/jdk/nashorn/api/scripting/NashornScriptEngine.java b/nashorn/src/jdk/nashorn/api/scripting/NashornScriptEngine.java index d0fb0c31832..8028cce229e 100644 --- a/nashorn/src/jdk/nashorn/api/scripting/NashornScriptEngine.java +++ b/nashorn/src/jdk/nashorn/api/scripting/NashornScriptEngine.java @@ -476,16 +476,19 @@ public final class NashornScriptEngine extends AbstractScriptEngine implements C private Object invokeImpl(final Object selfObject, final String name, final Object... args) throws ScriptException, NoSuchMethodException { name.getClass(); // null check + ScriptObject invokeGlobal = null; ScriptObjectMirror selfMirror = null; if (selfObject instanceof ScriptObjectMirror) { selfMirror = (ScriptObjectMirror)selfObject; if (! isOfContext(selfMirror.getHomeGlobal(), nashornContext)) { throw new IllegalArgumentException(getMessage("script.object.from.another.engine")); } + invokeGlobal = selfMirror.getHomeGlobal(); } else if (selfObject instanceof ScriptObject) { // invokeMethod called from script code - in which case we may get 'naked' ScriptObject // Wrap it with oldGlobal to make a ScriptObjectMirror for the same. final ScriptObject oldGlobal = Context.getGlobal(); + invokeGlobal = oldGlobal; if (oldGlobal == null) { throw new IllegalArgumentException(getMessage("no.current.nashorn.global")); } @@ -498,6 +501,7 @@ public final class NashornScriptEngine extends AbstractScriptEngine implements C } else if (selfObject == null) { // selfObject is null => global function call final ScriptObject ctxtGlobal = getNashornGlobalFrom(context); + invokeGlobal = ctxtGlobal; selfMirror = (ScriptObjectMirror)ScriptObjectMirror.wrap(ctxtGlobal, ctxtGlobal); } @@ -509,7 +513,7 @@ public final class NashornScriptEngine extends AbstractScriptEngine implements C if (cause instanceof NoSuchMethodException) { throw (NoSuchMethodException)cause; } - throwAsScriptException(e); + throwAsScriptException(e, invokeGlobal); throw new AssertionError("should not reach here"); } } @@ -543,7 +547,7 @@ public final class NashornScriptEngine extends AbstractScriptEngine implements C } return ScriptObjectMirror.translateUndefined(ScriptObjectMirror.wrap(ScriptRuntime.apply(script, ctxtGlobal), ctxtGlobal)); } catch (final Exception e) { - throwAsScriptException(e); + throwAsScriptException(e, ctxtGlobal); throw new AssertionError("should not reach here"); } finally { if (globalChanged) { @@ -552,7 +556,7 @@ public final class NashornScriptEngine extends AbstractScriptEngine implements C } } - private static void throwAsScriptException(final Exception e) throws ScriptException { + private static void throwAsScriptException(final Exception e, final ScriptObject global) throws ScriptException { if (e instanceof ScriptException) { throw (ScriptException)e; } else if (e instanceof NashornException) { @@ -560,6 +564,7 @@ public final class NashornScriptEngine extends AbstractScriptEngine implements C final ScriptException se = new ScriptException( ne.getMessage(), ne.getFileName(), ne.getLineNumber(), ne.getColumnNumber()); + ne.initEcmaError(global); se.initCause(e); throw se; } else if (e instanceof RuntimeException) { @@ -605,7 +610,7 @@ public final class NashornScriptEngine extends AbstractScriptEngine implements C return nashornContext.compileScript(source, newGlobal); } catch (final Exception e) { - throwAsScriptException(e); + throwAsScriptException(e, newGlobal); throw new AssertionError("should not reach here"); } finally { if (globalChanged) { @@ -621,6 +626,11 @@ public final class NashornScriptEngine extends AbstractScriptEngine implements C continue; } + // skip check for default methods - non-abstract, interface methods + if (! Modifier.isAbstract(method.getModifiers())) { + continue; + } + Object obj = sobj.get(method.getName()); if (! (obj instanceof ScriptFunction)) { return false; diff --git a/nashorn/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java b/nashorn/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java index 911f1663cb6..01f72c0008f 100644 --- a/nashorn/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java +++ b/nashorn/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java @@ -108,6 +108,8 @@ public final class ScriptObjectMirror extends AbstractJSObject implements Bindin } throw new RuntimeException("not a function: " + toString()); + } catch (final NashornException ne) { + throw ne.initEcmaError(global); } catch (final RuntimeException | Error e) { throw e; } catch (final Throwable t) { @@ -135,6 +137,8 @@ public final class ScriptObjectMirror extends AbstractJSObject implements Bindin } throw new RuntimeException("not a constructor: " + toString()); + } catch (final NashornException ne) { + throw ne.initEcmaError(global); } catch (final RuntimeException | Error e) { throw e; } catch (final Throwable t) { @@ -182,6 +186,8 @@ public final class ScriptObjectMirror extends AbstractJSObject implements Bindin } throw new NoSuchMethodException("No such function " + functionName); + } catch (final NashornException ne) { + throw ne.initEcmaError(global); } catch (final RuntimeException | Error e) { throw e; } catch (final Throwable t) { @@ -717,6 +723,8 @@ public final class ScriptObjectMirror extends AbstractJSObject implements Bindin } try { return callable.call(); + } catch (final NashornException ne) { + throw ne.initEcmaError(global); } catch (final RuntimeException e) { throw e; } catch (final Exception e) { diff --git a/nashorn/src/jdk/nashorn/internal/codegen/Attr.java b/nashorn/src/jdk/nashorn/internal/codegen/Attr.java index f1ced8ada06..177cfef4e4b 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/Attr.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/Attr.java @@ -766,7 +766,7 @@ final class Attr extends NodeOperatorVisitor<LexicalContext> { symbol.setType(Type.OBJECT); } - returnType = Type.widest(returnTypes.pop(), symbol.getSymbolType()); + returnType = widestReturnType(returnTypes.pop(), symbol.getSymbolType()); } else { returnType = Type.OBJECT; //undefined } @@ -1433,10 +1433,30 @@ final class Attr extends NodeOperatorVisitor<LexicalContext> { ensureTypeNotUnknown(trueExpr); ensureTypeNotUnknown(falseExpr); - final Type type = Type.widest(trueExpr.getType(), falseExpr.getType()); + final Type type = widestReturnType(trueExpr.getType(), falseExpr.getType()); return end(ensureSymbol(type, ternaryNode)); } + /** + * When doing widening for return types of a function or a ternary operator, it is not valid to widen a boolean to + * anything other than Object. Also, widening a numeric type to an object type must widen to Object proper and not + * any more specific subclass (e.g. widest of int/long/double and String is Object). + * @param t1 type 1 + * @param t2 type 2 + * @return wider of t1 and t2, except if one is boolean and the other is neither boolean nor unknown, or if one is + * numeric and the other is neither numeric nor unknown in which case {@code Type.OBJECT} is returned. + */ + private static Type widestReturnType(final Type t1, final Type t2) { + if (t1.isUnknown()) { + return t2; + } else if (t2.isUnknown()) { + return t1; + } else if (t1.isBoolean() != t2.isBoolean() || t1.isNumeric() != t2.isNumeric()) { + return Type.OBJECT; + } + return Type.widest(t1, t2); + } + private void initCompileConstant(final CompilerConstants cc, final Block block, final int flags) { final Class<?> type = cc.type(); // Must not call this method for constants with no explicit types; use the one with (..., Type) signature instead. diff --git a/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java b/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java index c3b1dbe2656..6ad92829bfe 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java @@ -2023,8 +2023,6 @@ final class CodeGenerator extends NodeOperatorVisitor<CodeGeneratorLexicalContex return false; } - method._new(ECMAException.class).dup(); - final Source source = lc.getCurrentFunction().getSource(); final Expression expression = throwNode.getExpression(); @@ -2037,7 +2035,7 @@ final class CodeGenerator extends NodeOperatorVisitor<CodeGeneratorLexicalContex method.load(source.getName()); method.load(line); method.load(column); - method.invoke(ECMAException.THROW_INIT); + method.invoke(ECMAException.CREATE); method.athrow(); diff --git a/nashorn/src/jdk/nashorn/internal/codegen/CodeGeneratorLexicalContext.java b/nashorn/src/jdk/nashorn/internal/codegen/CodeGeneratorLexicalContext.java index d27bdd953ec..dcf1b1ba5cd 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/CodeGeneratorLexicalContext.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/CodeGeneratorLexicalContext.java @@ -158,7 +158,7 @@ final class CodeGeneratorLexicalContext extends LexicalContext { if (scopeCalls.containsKey(scopeCall)) { return scopeCalls.get(scopeCall); } - scopeCall.setClassAndName(unit, getCurrentFunction().uniqueName("scopeCall")); + scopeCall.setClassAndName(unit, getCurrentFunction().uniqueName(":scopeCall")); scopeCalls.put(scopeCall, scopeCall); return scopeCall; } @@ -177,7 +177,7 @@ final class CodeGeneratorLexicalContext extends LexicalContext { if (scopeCalls.containsKey(scopeCall)) { return scopeCalls.get(scopeCall); } - scopeCall.setClassAndName(unit, getCurrentFunction().uniqueName("scopeCall")); + scopeCall.setClassAndName(unit, getCurrentFunction().uniqueName(":scopeCall")); scopeCalls.put(scopeCall, scopeCall); return scopeCall; } diff --git a/nashorn/src/jdk/nashorn/internal/codegen/Compiler.java b/nashorn/src/jdk/nashorn/internal/codegen/Compiler.java index 24173c3e710..b53b8fdf423 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/Compiler.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/Compiler.java @@ -85,6 +85,8 @@ public final class Compiler { private Source source; + private String sourceName; + private final Map<String, byte[]> bytecode; private final Set<CompileUnit> compileUnits; @@ -267,6 +269,7 @@ public final class Compiler { append('$'). append(safeSourceName(functionNode.getSource())); this.source = functionNode.getSource(); + this.sourceName = functionNode.getSourceName(); this.scriptName = sb.toString(); } @@ -573,7 +576,7 @@ public final class Compiler { } private CompileUnit initCompileUnit(final String unitClassName, final long initialWeight) { - final ClassEmitter classEmitter = new ClassEmitter(env, source.getName(), unitClassName, strict); + final ClassEmitter classEmitter = new ClassEmitter(env, sourceName, unitClassName, strict); final CompileUnit compileUnit = new CompileUnit(unitClassName, classEmitter, initialWeight); classEmitter.begin(); diff --git a/nashorn/src/jdk/nashorn/internal/codegen/CompilerConstants.java b/nashorn/src/jdk/nashorn/internal/codegen/CompilerConstants.java index fb347c75afb..16f08b82e17 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/CompilerConstants.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/CompilerConstants.java @@ -41,6 +41,7 @@ import jdk.nashorn.internal.runtime.Source; */ public enum CompilerConstants { + /** the __FILE__ variable */ __FILE__, @@ -75,7 +76,7 @@ public enum CompilerConstants { DEFAULT_SCRIPT_NAME("Script"), /** function prefix for anonymous functions */ - FUNCTION_PREFIX("function$"), + ANON_FUNCTION_PREFIX("L:"), /** method name for Java method that is script entry point */ RUN_SCRIPT("runScript"), @@ -149,26 +150,31 @@ public enum CompilerConstants { ALLOCATE("allocate"), /** prefix for split methods, @see Splitter */ - SPLIT_PREFIX("$split"), + SPLIT_PREFIX(":split"), /** prefix for split array method and slot */ - SPLIT_ARRAY_ARG("split_array", 3), + SPLIT_ARRAY_ARG(":split_array", 3), /** get string from constant pool */ - GET_STRING("$getString"), + GET_STRING(":getString"), /** get map */ - GET_MAP("$getMap"), + GET_MAP(":getMap"), /** get map */ - SET_MAP("$setMap"), + SET_MAP(":setMap"), /** get array prefix */ - GET_ARRAY_PREFIX("$get"), + GET_ARRAY_PREFIX(":get"), /** get array suffix */ GET_ARRAY_SUFFIX("$array"); + /** + * Prefix used for internal methods generated in script clases. + */ + public static final String INTERNAL_METHOD_PREFIX = ":"; + private final String symbolName; private final Class<?> type; private final int slot; diff --git a/nashorn/src/jdk/nashorn/internal/codegen/MethodEmitter.java b/nashorn/src/jdk/nashorn/internal/codegen/MethodEmitter.java index 9b6d12aae88..91129ece26a 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/MethodEmitter.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/MethodEmitter.java @@ -1130,7 +1130,11 @@ public class MethodEmitter implements Emitter { popType(Type.OBJECT); } - method.visitMethodInsn(opcode, className, methodName, methodDescriptor); + if (opcode == INVOKEINTERFACE) { + method.visitMethodInsn(opcode, className, methodName, methodDescriptor, true); + } else { + method.visitMethodInsn(opcode, className, methodName, methodDescriptor, false); + } if (returnType != null) { pushType(returnType); diff --git a/nashorn/src/jdk/nashorn/internal/codegen/types/Type.java b/nashorn/src/jdk/nashorn/internal/codegen/types/Type.java index e7c789535d7..4799c264196 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/types/Type.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/types/Type.java @@ -261,7 +261,7 @@ public abstract class Type implements Comparable<Type>, BytecodeOps { } static void invokeStatic(final MethodVisitor method, final Call call) { - method.visitMethodInsn(INVOKESTATIC, call.className(), call.name(), call.descriptor()); + method.visitMethodInsn(INVOKESTATIC, call.className(), call.name(), call.descriptor(), false); } /** diff --git a/nashorn/src/jdk/nashorn/internal/ir/FunctionNode.java b/nashorn/src/jdk/nashorn/internal/ir/FunctionNode.java index b0998ae1911..1437eb40384 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/FunctionNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/FunctionNode.java @@ -29,6 +29,7 @@ import java.util.Collections; import java.util.EnumSet; import java.util.HashSet; import java.util.List; +import java.util.Objects; import java.util.Set; import jdk.nashorn.internal.codegen.CompileUnit; import jdk.nashorn.internal.codegen.Compiler; @@ -138,6 +139,9 @@ public final class FunctionNode extends LexicalContextExpression implements Flag /** Function flags. */ private final int flags; + /** //@ sourceURL or //# sourceURL for program function nodes */ + private final String sourceURL; + private final int lineNumber; /** Is anonymous function flag. */ @@ -223,6 +227,7 @@ public final class FunctionNode extends LexicalContextExpression implements Flag * @param parameters parameter list * @param kind kind of function as in {@link FunctionNode.Kind} * @param flags initial flags + * @param sourceURL sourceURL specified in script (optional) */ public FunctionNode( final Source source, @@ -235,7 +240,8 @@ public final class FunctionNode extends LexicalContextExpression implements Flag final String name, final List<IdentNode> parameters, final FunctionNode.Kind kind, - final int flags) { + final int flags, + final String sourceURL) { super(token, finish); this.source = source; @@ -250,6 +256,7 @@ public final class FunctionNode extends LexicalContextExpression implements Flag this.compilationState = EnumSet.of(CompilationState.INITIALIZED); this.declaredSymbols = new HashSet<>(); this.flags = flags; + this.sourceURL = sourceURL; this.compileUnit = null; this.body = null; this.snapshot = null; @@ -260,6 +267,7 @@ public final class FunctionNode extends LexicalContextExpression implements Flag final FunctionNode functionNode, final long lastToken, final int flags, + final String sourceURL, final String name, final Type returnType, final CompileUnit compileUnit, @@ -271,6 +279,7 @@ public final class FunctionNode extends LexicalContextExpression implements Flag super(functionNode); this.lineNumber = functionNode.lineNumber; this.flags = flags; + this.sourceURL = sourceURL; this.name = name; this.returnType = returnType; this.compileUnit = compileUnit; @@ -307,6 +316,38 @@ public final class FunctionNode extends LexicalContextExpression implements Flag return source; } + /** + * get source name - sourceURL or name derived from Source. + * + * @return name for the script source + */ + public String getSourceName() { + return (sourceURL != null)? sourceURL : source.getName(); + } + + /** + * get the sourceURL + * @return the sourceURL + */ + public String getSourceURL() { + return sourceURL; + } + + /** + * Set the sourceURL + * + * @param lc lexical context + * @param newSourceURL source url string to set + * @return function node or a new one if state was changed + */ + public FunctionNode setSourceURL(final LexicalContext lc, final String newSourceURL) { + if (Objects.equals(sourceURL, newSourceURL)) { + return this; + } + + return Node.replaceInLexicalContext(lc, this, new FunctionNode(this, lastToken, flags, newSourceURL, name, returnType, compileUnit, compilationState, body, parameters, null, hints)); + } + /** * Returns the line number. * @return the line number. @@ -335,7 +376,7 @@ public final class FunctionNode extends LexicalContextExpression implements Flag if (this.snapshot == null) { return this; } - return Node.replaceInLexicalContext(lc, this, new FunctionNode(this, lastToken, flags, name, returnType, compileUnit, compilationState, body, parameters, null, hints)); + return Node.replaceInLexicalContext(lc, this, new FunctionNode(this, lastToken, flags, sourceURL, name, returnType, compileUnit, compilationState, body, parameters, null, hints)); } /** @@ -351,7 +392,7 @@ public final class FunctionNode extends LexicalContextExpression implements Flag if (isProgram() || parameters.isEmpty()) { return this; //never specialize anything that won't be recompiled } - return Node.replaceInLexicalContext(lc, this, new FunctionNode(this, lastToken, flags, name, returnType, compileUnit, compilationState, body, parameters, this, hints)); + return Node.replaceInLexicalContext(lc, this, new FunctionNode(this, lastToken, flags, sourceURL, name, returnType, compileUnit, compilationState, body, parameters, this, hints)); } /** @@ -409,7 +450,7 @@ public final class FunctionNode extends LexicalContextExpression implements Flag } final EnumSet<CompilationState> newState = EnumSet.copyOf(this.compilationState); newState.add(state); - return Node.replaceInLexicalContext(lc, this, new FunctionNode(this, lastToken, flags, name, returnType, compileUnit, newState, body, parameters, snapshot, hints)); + return Node.replaceInLexicalContext(lc, this, new FunctionNode(this, lastToken, flags, sourceURL, name, returnType, compileUnit, newState, body, parameters, snapshot, hints)); } /** @@ -430,7 +471,7 @@ public final class FunctionNode extends LexicalContextExpression implements Flag if (this.hints == hints) { return this; } - return Node.replaceInLexicalContext(lc, this, new FunctionNode(this, lastToken, flags, name, returnType, compileUnit, compilationState, body, parameters, snapshot, hints)); + return Node.replaceInLexicalContext(lc, this, new FunctionNode(this, lastToken, flags, sourceURL, name, returnType, compileUnit, compilationState, body, parameters, snapshot, hints)); } /** @@ -483,7 +524,7 @@ public final class FunctionNode extends LexicalContextExpression implements Flag if (this.flags == flags) { return this; } - return Node.replaceInLexicalContext(lc, this, new FunctionNode(this, lastToken, flags, name, returnType, compileUnit, compilationState, body, parameters, snapshot, hints)); + return Node.replaceInLexicalContext(lc, this, new FunctionNode(this, lastToken, flags, sourceURL, name, returnType, compileUnit, compilationState, body, parameters, snapshot, hints)); } @Override @@ -593,7 +634,7 @@ public final class FunctionNode extends LexicalContextExpression implements Flag if(this.body == body) { return this; } - return Node.replaceInLexicalContext(lc, this, new FunctionNode(this, lastToken, flags | (body.needsScope() ? FunctionNode.HAS_SCOPE_BLOCK : 0), name, returnType, compileUnit, compilationState, body, parameters, snapshot, hints)); + return Node.replaceInLexicalContext(lc, this, new FunctionNode(this, lastToken, flags | (body.needsScope() ? FunctionNode.HAS_SCOPE_BLOCK : 0), sourceURL, name, returnType, compileUnit, compilationState, body, parameters, snapshot, hints)); } /** @@ -688,7 +729,7 @@ public final class FunctionNode extends LexicalContextExpression implements Flag if (this.lastToken == lastToken) { return this; } - return Node.replaceInLexicalContext(lc, this, new FunctionNode(this, lastToken, flags, name, returnType, compileUnit, compilationState, body, parameters, snapshot, hints)); + return Node.replaceInLexicalContext(lc, this, new FunctionNode(this, lastToken, flags, sourceURL, name, returnType, compileUnit, compilationState, body, parameters, snapshot, hints)); } /** @@ -710,7 +751,7 @@ public final class FunctionNode extends LexicalContextExpression implements Flag if (this.name.equals(name)) { return this; } - return Node.replaceInLexicalContext(lc, this, new FunctionNode(this, lastToken, flags, name, returnType, compileUnit, compilationState, body, parameters, snapshot, hints)); + return Node.replaceInLexicalContext(lc, this, new FunctionNode(this, lastToken, flags, sourceURL, name, returnType, compileUnit, compilationState, body, parameters, snapshot, hints)); } /** @@ -760,7 +801,7 @@ public final class FunctionNode extends LexicalContextExpression implements Flag if (this.parameters == parameters) { return this; } - return Node.replaceInLexicalContext(lc, this, new FunctionNode(this, lastToken, flags, name, returnType, compileUnit, compilationState, body, parameters, snapshot, hints)); + return Node.replaceInLexicalContext(lc, this, new FunctionNode(this, lastToken, flags, sourceURL, name, returnType, compileUnit, compilationState, body, parameters, snapshot, hints)); } /** @@ -825,6 +866,7 @@ public final class FunctionNode extends LexicalContextExpression implements Flag this, lastToken, flags, + sourceURL, name, type, compileUnit, @@ -863,7 +905,7 @@ public final class FunctionNode extends LexicalContextExpression implements Flag if (this.compileUnit == compileUnit) { return this; } - return Node.replaceInLexicalContext(lc, this, new FunctionNode(this, lastToken, flags, name, returnType, compileUnit, compilationState, body, parameters, snapshot, hints)); + return Node.replaceInLexicalContext(lc, this, new FunctionNode(this, lastToken, flags, sourceURL, name, returnType, compileUnit, compilationState, body, parameters, snapshot, hints)); } /** diff --git a/nashorn/src/jdk/nashorn/internal/objects/Global.java b/nashorn/src/jdk/nashorn/internal/objects/Global.java index 0a09370aac9..819095c05e4 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/Global.java +++ b/nashorn/src/jdk/nashorn/internal/objects/Global.java @@ -44,6 +44,7 @@ import java.util.concurrent.Callable; import java.util.concurrent.ConcurrentHashMap; import jdk.internal.dynalink.linker.GuardedInvocation; import jdk.internal.dynalink.linker.LinkRequest; +import jdk.nashorn.internal.lookup.Lookup; import jdk.nashorn.internal.objects.annotations.Attribute; import jdk.nashorn.internal.objects.annotations.Property; import jdk.nashorn.internal.objects.annotations.ScriptClass; @@ -364,6 +365,11 @@ public final class Global extends ScriptObject implements GlobalObject, Scope { private ScriptObject builtinFloat32Array; private ScriptObject builtinFloat64Array; + /* + * ECMA section 13.2.3 The [[ThrowTypeError]] Function Object + */ + private ScriptFunction typeErrorThrower; + private PropertyMap accessorPropertyDescriptorMap; private PropertyMap arrayBufferViewMap; private PropertyMap dataPropertyDescriptorMap; @@ -1114,6 +1120,10 @@ public final class Global extends ScriptObject implements GlobalObject, Scope { return builtinArray; } + ScriptFunction getTypeErrorThrower() { + return typeErrorThrower; + } + /** * Called from compiled script code to test if builtin has been overridden * @@ -1695,8 +1705,25 @@ public final class Global extends ScriptObject implements GlobalObject, Scope { initScripting(env); } - if (Context.DEBUG && System.getSecurityManager() == null) { - initDebug(); + if (Context.DEBUG) { + boolean debugOkay; + final SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + try { + sm.checkPermission(new RuntimePermission(Context.NASHORN_DEBUG_MODE)); + debugOkay = true; + } catch (final SecurityException ignored) { + // if no permission, don't initialize Debug object + debugOkay = false; + } + + } else { + debugOkay = true; + } + + if (debugOkay) { + initDebug(); + } } copyBuiltins(); @@ -2000,6 +2027,13 @@ public final class Global extends ScriptObject implements GlobalObject, Scope { anon.set("constructor", builtinFunction, false); anon.deleteOwnProperty(anon.getMap().findProperty("prototype")); + // use "getter" so that [[ThrowTypeError]] function's arity is 0 - as specified in step 10 of section 13.2.3 + this.typeErrorThrower = new ScriptFunctionImpl("TypeErrorThrower", Lookup.TYPE_ERROR_THROWER_GETTER, null, null, false, false, false); + typeErrorThrower.setPrototype(UNDEFINED); + // Non-constructor built-in functions do not have "prototype" property + typeErrorThrower.deleteOwnProperty(typeErrorThrower.getMap().findProperty("prototype")); + typeErrorThrower.preventExtensions(); + // now initialize Object this.builtinObject = (ScriptFunction)initConstructor("Object"); final ScriptObject ObjectPrototype = getObjectPrototype(); diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeError.java b/nashorn/src/jdk/nashorn/internal/objects/NativeError.java index d3e2effed3f..0541084d8bf 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/NativeError.java +++ b/nashorn/src/jdk/nashorn/internal/objects/NativeError.java @@ -38,7 +38,6 @@ import jdk.nashorn.internal.objects.annotations.Function; import jdk.nashorn.internal.objects.annotations.Property; import jdk.nashorn.internal.objects.annotations.ScriptClass; import jdk.nashorn.internal.objects.annotations.Where; -import jdk.nashorn.internal.objects.ScriptFunctionImpl; import jdk.nashorn.internal.runtime.ECMAException; import jdk.nashorn.internal.runtime.JSType; import jdk.nashorn.internal.runtime.PropertyMap; @@ -75,7 +74,7 @@ public final class NativeError extends ScriptObject { static final String FILENAME = "__fileName__"; /** Message property name */ - @Property(name = NativeError.MESSAGE) + @Property(name = NativeError.MESSAGE, attributes = Attribute.NOT_ENUMERABLE) public Object instMessage; /** ECMA 15.11.4.2 Error.prototype.name */ @@ -86,6 +85,10 @@ public final class NativeError extends ScriptObject { @Property(attributes = Attribute.NOT_ENUMERABLE, where = Where.PROTOTYPE) public Object message; + /** Nashorn extension: underlying exception */ + @Property(attributes = Attribute.NOT_ENUMERABLE) + public Object nashornException; + // initialized by nasgen private static PropertyMap $nasgenmap$; @@ -93,6 +96,7 @@ public final class NativeError extends ScriptObject { return $nasgenmap$; } + @SuppressWarnings("LeakingThisInConstructor") private NativeError(final Object msg, final ScriptObject proto, final PropertyMap map) { super(proto, map); if (msg != UNDEFINED) { @@ -100,6 +104,7 @@ public final class NativeError extends ScriptObject { } else { this.delete(NativeError.MESSAGE, false); } + initException(this); } NativeError(final Object msg, final Global global) { @@ -129,6 +134,14 @@ public final class NativeError extends ScriptObject { return new NativeError(msg); } + // This is called NativeError, NativeTypeError etc. to + // associate a ECMAException with the ECMA Error object. + @SuppressWarnings("unused") + static void initException(final ScriptObject self) { + // ECMAException constructor has side effects + new ECMAException(self, null); + } + /** * Nashorn extension: Error.captureStackTrace. Capture stack trace at the point of call into the Error object provided. * @@ -136,16 +149,17 @@ public final class NativeError extends ScriptObject { * @param errorObj the error object * @return undefined */ - @SuppressWarnings("unused") @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) public static Object captureStackTrace(final Object self, final Object errorObj) { Global.checkObject(errorObj); final ScriptObject sobj = (ScriptObject)errorObj; - new ECMAException(sobj, null); //constructor has side effects - sobj.delete("stack", false); - final ScriptFunction getStack = ScriptFunctionImpl.makeFunction("getStack", GET_STACK); - final ScriptFunction setStack = ScriptFunctionImpl.makeFunction("setStack", SET_STACK); - sobj.addOwnProperty("stack", Attribute.NOT_ENUMERABLE, getStack, setStack); + initException(sobj); + sobj.delete(STACK, false); + if (! sobj.has("stack")) { + final ScriptFunction getStack = ScriptFunctionImpl.makeFunction("getStack", GET_STACK); + final ScriptFunction setStack = ScriptFunctionImpl.makeFunction("setStack", SET_STACK); + sobj.addOwnProperty("stack", Attribute.NOT_ENUMERABLE, getStack, setStack); + } return UNDEFINED; } @@ -226,7 +240,11 @@ public final class NativeError extends ScriptObject { public static Object setLineNumber(final Object self, final Object value) { Global.checkObject(self); final ScriptObject sobj = (ScriptObject)self; - sobj.set(LINENUMBER, value, false); + if (sobj.hasOwnProperty(LINENUMBER)) { + sobj.put(LINENUMBER, value, false); + } else { + sobj.addOwnProperty(LINENUMBER, Attribute.NOT_ENUMERABLE, value); + } return value; } @@ -254,7 +272,11 @@ public final class NativeError extends ScriptObject { public static Object setColumnNumber(final Object self, final Object value) { Global.checkObject(self); final ScriptObject sobj = (ScriptObject)self; - sobj.set(COLUMNNUMBER, value, false); + if (sobj.hasOwnProperty(COLUMNNUMBER)) { + sobj.put(COLUMNNUMBER, value, false); + } else { + sobj.addOwnProperty(COLUMNNUMBER, Attribute.NOT_ENUMERABLE, value); + } return value; } @@ -282,7 +304,11 @@ public final class NativeError extends ScriptObject { public static Object setFileName(final Object self, final Object value) { Global.checkObject(self); final ScriptObject sobj = (ScriptObject)self; - sobj.set(FILENAME, value, false); + if (sobj.hasOwnProperty(FILENAME)) { + sobj.put(FILENAME, value, false); + } else { + sobj.addOwnProperty(FILENAME, Attribute.NOT_ENUMERABLE, value); + } return value; } @@ -304,10 +330,12 @@ public final class NativeError extends ScriptObject { final Object exception = ECMAException.getException(sobj); if (exception instanceof Throwable) { - return getScriptStackString(sobj, (Throwable)exception); + Object value = getScriptStackString(sobj, (Throwable)exception); + sobj.put(STACK, value, false); + return value; } - return ""; + return UNDEFINED; } /** diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeEvalError.java b/nashorn/src/jdk/nashorn/internal/objects/NativeEvalError.java index 89e9485fd9d..df8164c1119 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/NativeEvalError.java +++ b/nashorn/src/jdk/nashorn/internal/objects/NativeEvalError.java @@ -44,7 +44,7 @@ import jdk.nashorn.internal.runtime.ScriptObject; public final class NativeEvalError extends ScriptObject { /** message property in instance */ - @Property(name = NativeError.MESSAGE) + @Property(name = NativeError.MESSAGE, attributes = Attribute.NOT_ENUMERABLE) public Object instMessage; /** error name property */ @@ -55,6 +55,10 @@ public final class NativeEvalError extends ScriptObject { @Property(attributes = Attribute.NOT_ENUMERABLE, where = Where.PROTOTYPE) public Object message; + /** Nashorn extension: underlying exception */ + @Property(attributes = Attribute.NOT_ENUMERABLE) + public Object nashornException; + // initialized by nasgen private static PropertyMap $nasgenmap$; @@ -62,6 +66,7 @@ public final class NativeEvalError extends ScriptObject { return $nasgenmap$; } + @SuppressWarnings("LeakingThisInConstructor") private NativeEvalError(final Object msg, final ScriptObject proto, final PropertyMap map) { super(proto, map); if (msg != UNDEFINED) { @@ -69,6 +74,7 @@ public final class NativeEvalError extends ScriptObject { } else { this.delete(NativeError.MESSAGE, false); } + NativeError.initException(this); } NativeEvalError(final Object msg, final Global global) { diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeJavaImporter.java b/nashorn/src/jdk/nashorn/internal/objects/NativeJavaImporter.java index c2d2bd10e81..dd9231d9386 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/NativeJavaImporter.java +++ b/nashorn/src/jdk/nashorn/internal/objects/NativeJavaImporter.java @@ -133,6 +133,11 @@ public final class NativeJavaImporter extends ScriptObject { return createAndSetProperty(desc) ? super.lookup(desc, request) : super.noSuchMethod(desc, request); } + @Override + protected Object invokeNoSuchProperty(final String name) { + return createProperty(name); + } + private boolean createAndSetProperty(final CallSiteDescriptor desc) { final String name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND); final Object value = createProperty(name); diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeMath.java b/nashorn/src/jdk/nashorn/internal/objects/NativeMath.java index cc50fbb4f00..ec53965ad1b 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/NativeMath.java +++ b/nashorn/src/jdk/nashorn/internal/objects/NativeMath.java @@ -92,7 +92,7 @@ public final class NativeMath extends ScriptObject { * @return abs of value */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) - public static Object abs(final Object self, final Object x) { + public static double abs(final Object self, final Object x) { return Math.abs(JSType.toNumber(x)); } @@ -144,7 +144,7 @@ public final class NativeMath extends ScriptObject { * @return acos of argument */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) - public static Object acos(final Object self, final Object x) { + public static double acos(final Object self, final Object x) { return Math.acos(JSType.toNumber(x)); } @@ -170,7 +170,7 @@ public final class NativeMath extends ScriptObject { * @return asin of argument */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) - public static Object asin(final Object self, final Object x) { + public static double asin(final Object self, final Object x) { return Math.asin(JSType.toNumber(x)); } @@ -196,7 +196,7 @@ public final class NativeMath extends ScriptObject { * @return atan of argument */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) - public static Object atan(final Object self, final Object x) { + public static double atan(final Object self, final Object x) { return Math.atan(JSType.toNumber(x)); } @@ -223,7 +223,7 @@ public final class NativeMath extends ScriptObject { * @return atan2 of x and y */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) - public static Object atan2(final Object self, final Object y, final Object x) { + public static double atan2(final Object self, final Object y, final Object x) { return Math.atan2(JSType.toNumber(y), JSType.toNumber(x)); } @@ -250,7 +250,7 @@ public final class NativeMath extends ScriptObject { * @return ceil of argument */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) - public static Object ceil(final Object self, final Object x) { + public static double ceil(final Object self, final Object x) { return Math.ceil(JSType.toNumber(x)); } @@ -302,7 +302,7 @@ public final class NativeMath extends ScriptObject { * @return cos of argument */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) - public static Object cos(final Object self, final Object x) { + public static double cos(final Object self, final Object x) { return Math.cos(JSType.toNumber(x)); } @@ -328,7 +328,7 @@ public final class NativeMath extends ScriptObject { * @return exp of argument */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) - public static Object exp(final Object self, final Object x) { + public static double exp(final Object self, final Object x) { return Math.exp(JSType.toNumber(x)); } @@ -341,7 +341,7 @@ public final class NativeMath extends ScriptObject { * @return floor of argument */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) - public static Object floor(final Object self, final Object x) { + public static double floor(final Object self, final Object x) { return Math.floor(JSType.toNumber(x)); } @@ -393,7 +393,7 @@ public final class NativeMath extends ScriptObject { * @return log of argument */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) - public static Object log(final Object self, final Object x) { + public static double log(final Object self, final Object x) { return Math.log(JSType.toNumber(x)); } @@ -419,7 +419,7 @@ public final class NativeMath extends ScriptObject { * @return the largest of the arguments, {@link Double#NEGATIVE_INFINITY} if no args given, or identity if one arg is given */ @Function(arity = 2, attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) - public static Object max(final Object self, final Object... args) { + public static double max(final Object self, final Object... args) { switch (args.length) { case 0: return Double.NEGATIVE_INFINITY; @@ -497,7 +497,7 @@ public final class NativeMath extends ScriptObject { * @return the smallest of the arguments, {@link Double#NEGATIVE_INFINITY} if no args given, or identity if one arg is given */ @Function(arity = 2, attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) - public static Object min(final Object self, final Object... args) { + public static double min(final Object self, final Object... args) { switch (args.length) { case 0: return Double.POSITIVE_INFINITY; @@ -576,7 +576,7 @@ public final class NativeMath extends ScriptObject { * @return x raised to the power of y */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) - public static Object pow(final Object self, final Object x, final Object y) { + public static double pow(final Object self, final Object x, final Object y) { return Math.pow(JSType.toNumber(x), JSType.toNumber(y)); } @@ -602,7 +602,7 @@ public final class NativeMath extends ScriptObject { * @return random number in the range [0..1) */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) - public static Object random(final Object self) { + public static double random(final Object self) { return Math.random(); } @@ -615,7 +615,7 @@ public final class NativeMath extends ScriptObject { * @return x rounded */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) - public static Object round(final Object self, final Object x) { + public static double round(final Object self, final Object x) { final double d = JSType.toNumber(x); if (Math.getExponent(d) >= 52) { return d; @@ -632,7 +632,7 @@ public final class NativeMath extends ScriptObject { * @return sin of x */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) - public static Object sin(final Object self, final Object x) { + public static double sin(final Object self, final Object x) { return Math.sin(JSType.toNumber(x)); } @@ -658,7 +658,7 @@ public final class NativeMath extends ScriptObject { * @return sqrt of x */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) - public static Object sqrt(final Object self, final Object x) { + public static double sqrt(final Object self, final Object x) { return Math.sqrt(JSType.toNumber(x)); } @@ -684,7 +684,7 @@ public final class NativeMath extends ScriptObject { * @return tan of x */ @Function(attributes = Attribute.NOT_ENUMERABLE, where=Where.CONSTRUCTOR) - public static Object tan(final Object self, final Object x) { + public static double tan(final Object self, final Object x) { return Math.tan(JSType.toNumber(x)); } diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeRangeError.java b/nashorn/src/jdk/nashorn/internal/objects/NativeRangeError.java index d51a0c09d41..a71b28b19c2 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/NativeRangeError.java +++ b/nashorn/src/jdk/nashorn/internal/objects/NativeRangeError.java @@ -44,7 +44,7 @@ import jdk.nashorn.internal.runtime.ScriptObject; public final class NativeRangeError extends ScriptObject { /** message property in instance */ - @Property(name = NativeError.MESSAGE) + @Property(name = NativeError.MESSAGE, attributes = Attribute.NOT_ENUMERABLE) public Object instMessage; /** error name property */ @@ -55,6 +55,10 @@ public final class NativeRangeError extends ScriptObject { @Property(attributes = Attribute.NOT_ENUMERABLE, where = Where.PROTOTYPE) public Object message; + /** Nashorn extension: underlying exception */ + @Property(attributes = Attribute.NOT_ENUMERABLE) + public Object nashornException; + // initialized by nasgen private static PropertyMap $nasgenmap$; @@ -62,6 +66,7 @@ public final class NativeRangeError extends ScriptObject { return $nasgenmap$; } + @SuppressWarnings("LeakingThisInConstructor") private NativeRangeError(final Object msg, final ScriptObject proto, final PropertyMap map) { super(proto, map); if (msg != UNDEFINED) { @@ -69,6 +74,7 @@ public final class NativeRangeError extends ScriptObject { } else { this.delete(NativeError.MESSAGE, false); } + NativeError.initException(this); } NativeRangeError(final Object msg, final Global global) { diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeReferenceError.java b/nashorn/src/jdk/nashorn/internal/objects/NativeReferenceError.java index a269b51520a..d02a325055b 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/NativeReferenceError.java +++ b/nashorn/src/jdk/nashorn/internal/objects/NativeReferenceError.java @@ -44,7 +44,7 @@ import jdk.nashorn.internal.runtime.ScriptObject; public final class NativeReferenceError extends ScriptObject { /** message property in instance */ - @Property(name = NativeError.MESSAGE) + @Property(name = NativeError.MESSAGE, attributes = Attribute.NOT_ENUMERABLE) public Object instMessage; /** error name property */ @@ -55,6 +55,10 @@ public final class NativeReferenceError extends ScriptObject { @Property(attributes = Attribute.NOT_ENUMERABLE, where = Where.PROTOTYPE) public Object message; + /** Nashorn extension: underlying exception */ + @Property(attributes = Attribute.NOT_ENUMERABLE) + public Object nashornException; + // initialized by nasgen private static PropertyMap $nasgenmap$; @@ -62,6 +66,7 @@ public final class NativeReferenceError extends ScriptObject { return $nasgenmap$; } + @SuppressWarnings("LeakingThisInConstructor") private NativeReferenceError(final Object msg, final ScriptObject proto, final PropertyMap map) { super(proto, map); if (msg != UNDEFINED) { @@ -69,6 +74,7 @@ public final class NativeReferenceError extends ScriptObject { } else { this.delete(NativeError.MESSAGE, false); } + NativeError.initException(this); } NativeReferenceError(final Object msg, final Global global) { diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeStrictArguments.java b/nashorn/src/jdk/nashorn/internal/objects/NativeStrictArguments.java index de6e4b51435..b81cc2afad4 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/NativeStrictArguments.java +++ b/nashorn/src/jdk/nashorn/internal/objects/NativeStrictArguments.java @@ -76,7 +76,7 @@ public final class NativeStrictArguments extends ScriptObject { super(proto, map); setIsArguments(); - final ScriptFunction func = ScriptFunctionImpl.getTypeErrorThrower(); + final ScriptFunction func = Global.instance().getTypeErrorThrower(); // We have to fill user accessor functions late as these are stored // in this object rather than in the PropertyMap of this object. setUserAccessors("caller", func, func); diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeSyntaxError.java b/nashorn/src/jdk/nashorn/internal/objects/NativeSyntaxError.java index 45920ba7aec..5d71ade7d38 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/NativeSyntaxError.java +++ b/nashorn/src/jdk/nashorn/internal/objects/NativeSyntaxError.java @@ -44,7 +44,7 @@ import jdk.nashorn.internal.runtime.ScriptObject; public final class NativeSyntaxError extends ScriptObject { /** message property in instance */ - @Property(name = NativeError.MESSAGE) + @Property(name = NativeError.MESSAGE, attributes = Attribute.NOT_ENUMERABLE) public Object instMessage; /** error name property */ @@ -55,6 +55,10 @@ public final class NativeSyntaxError extends ScriptObject { @Property(attributes = Attribute.NOT_ENUMERABLE, where = Where.PROTOTYPE) public Object message; + /** Nashorn extension: underlying exception */ + @Property(attributes = Attribute.NOT_ENUMERABLE) + public Object nashornException; + // initialized by nasgen private static PropertyMap $nasgenmap$; @@ -62,6 +66,7 @@ public final class NativeSyntaxError extends ScriptObject { return $nasgenmap$; } + @SuppressWarnings("LeakingThisInConstructor") NativeSyntaxError(final Object msg, final Global global) { super(global.getSyntaxErrorPrototype(), global.getSyntaxErrorMap()); if (msg != UNDEFINED) { @@ -69,6 +74,7 @@ public final class NativeSyntaxError extends ScriptObject { } else { this.delete(NativeError.MESSAGE, false); } + NativeError.initException(this); } private NativeSyntaxError(final Object msg) { diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeTypeError.java b/nashorn/src/jdk/nashorn/internal/objects/NativeTypeError.java index 2b2308b143e..8857da7142d 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/NativeTypeError.java +++ b/nashorn/src/jdk/nashorn/internal/objects/NativeTypeError.java @@ -44,7 +44,7 @@ import jdk.nashorn.internal.runtime.ScriptObject; public final class NativeTypeError extends ScriptObject { /** message property in instance */ - @Property(name = NativeError.MESSAGE) + @Property(name = NativeError.MESSAGE, attributes = Attribute.NOT_ENUMERABLE) public Object instMessage; /** error name property */ @@ -55,6 +55,10 @@ public final class NativeTypeError extends ScriptObject { @Property(attributes = Attribute.NOT_ENUMERABLE, where = Where.PROTOTYPE) public Object message; + /** Nashorn extension: underlying exception */ + @Property(attributes = Attribute.NOT_ENUMERABLE) + public Object nashornException; + // initialized by nasgen private static PropertyMap $nasgenmap$; @@ -62,6 +66,7 @@ public final class NativeTypeError extends ScriptObject { return $nasgenmap$; } + @SuppressWarnings("LeakingThisInConstructor") NativeTypeError(final Object msg, final Global global) { super(global.getTypeErrorPrototype(), global.getTypeErrorMap()); if (msg != UNDEFINED) { @@ -69,6 +74,7 @@ public final class NativeTypeError extends ScriptObject { } else { delete(NativeError.MESSAGE, false); } + NativeError.initException(this); } private NativeTypeError(final Object msg) { diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeURIError.java b/nashorn/src/jdk/nashorn/internal/objects/NativeURIError.java index 2caf136954d..7ff6c196e3f 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/NativeURIError.java +++ b/nashorn/src/jdk/nashorn/internal/objects/NativeURIError.java @@ -43,7 +43,7 @@ import jdk.nashorn.internal.runtime.ScriptObject; public final class NativeURIError extends ScriptObject { /** message property in instance */ - @Property(name = NativeError.MESSAGE) + @Property(name = NativeError.MESSAGE, attributes = Attribute.NOT_ENUMERABLE) public Object instMessage; /** error name property */ @@ -54,6 +54,10 @@ public final class NativeURIError extends ScriptObject { @Property(attributes = Attribute.NOT_ENUMERABLE, where = Where.PROTOTYPE) public Object message; + /** Nashorn extension: underlying exception */ + @Property(attributes = Attribute.NOT_ENUMERABLE) + public Object nashornException; + // initialized by nasgen private static PropertyMap $nasgenmap$; @@ -61,6 +65,7 @@ public final class NativeURIError extends ScriptObject { return $nasgenmap$; } + @SuppressWarnings("LeakingThisInConstructor") NativeURIError(final Object msg, final Global global) { super(global.getURIErrorPrototype(), global.getURIErrorMap()); if (msg != UNDEFINED) { @@ -68,6 +73,7 @@ public final class NativeURIError extends ScriptObject { } else { this.delete(NativeError.MESSAGE, false); } + NativeError.initException(this); } private NativeURIError(final Object msg) { diff --git a/nashorn/src/jdk/nashorn/internal/objects/ScriptFunctionImpl.java b/nashorn/src/jdk/nashorn/internal/objects/ScriptFunctionImpl.java index 638d18a2087..f0bea3a6e33 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/ScriptFunctionImpl.java +++ b/nashorn/src/jdk/nashorn/internal/objects/ScriptFunctionImpl.java @@ -170,26 +170,6 @@ public class ScriptFunctionImpl extends ScriptFunction { boundfunctionmap$.setIsShared(); } - // function object representing TypeErrorThrower - private static ScriptFunction typeErrorThrower; - - /* - * ECMA section 13.2.3 The [[ThrowTypeError]] Function Object - */ - static synchronized ScriptFunction getTypeErrorThrower() { - if (typeErrorThrower == null) { - // use "getter" so that [[ThrowTypeError]] function's arity is 0 - as specified in step 10 of section 13.2.3 - final ScriptFunctionImpl func = new ScriptFunctionImpl("TypeErrorThrower", Lookup.TYPE_ERROR_THROWER_GETTER, null, null, false, false, false); - func.setPrototype(UNDEFINED); - // Non-constructor built-in functions do not have "prototype" property - func.deleteOwnProperty(func.getMap().findProperty("prototype")); - func.preventExtensions(); - typeErrorThrower = func; - } - - return typeErrorThrower; - } - private static PropertyMap createStrictModeMap(final PropertyMap map) { final int flags = Property.NOT_ENUMERABLE | Property.NOT_CONFIGURABLE; PropertyMap newMap = map; @@ -313,12 +293,13 @@ public class ScriptFunctionImpl extends ScriptFunction { // We have to fill user accessor functions late as these are stored // in this object rather than in the PropertyMap of this object. + final ScriptFunction errorThrower = global.getTypeErrorThrower(); if (findProperty("arguments", true) != null) { - setUserAccessors("arguments", getTypeErrorThrower(), getTypeErrorThrower()); + setUserAccessors("arguments", errorThrower, errorThrower); } if (findProperty("caller", true) != null) { - setUserAccessors("caller", getTypeErrorThrower(), getTypeErrorThrower()); + setUserAccessors("caller", errorThrower, errorThrower); } } } diff --git a/nashorn/src/jdk/nashorn/internal/parser/AbstractParser.java b/nashorn/src/jdk/nashorn/internal/parser/AbstractParser.java index 587ae869ef6..d4a42ba4497 100644 --- a/nashorn/src/jdk/nashorn/internal/parser/AbstractParser.java +++ b/nashorn/src/jdk/nashorn/internal/parser/AbstractParser.java @@ -26,6 +26,7 @@ package jdk.nashorn.internal.parser; import static jdk.nashorn.internal.parser.TokenType.COMMENT; +import static jdk.nashorn.internal.parser.TokenType.DIRECTIVE_COMMENT; import static jdk.nashorn.internal.parser.TokenType.EOF; import static jdk.nashorn.internal.parser.TokenType.EOL; import static jdk.nashorn.internal.parser.TokenType.IDENT; @@ -84,6 +85,9 @@ public abstract class AbstractParser { /** Is this parser running under strict mode? */ protected boolean isStrictMode; + /** //@ sourceURL or //# sourceURL */ + protected String sourceURL; + /** * Construct a parser. * @@ -156,17 +160,38 @@ public abstract class AbstractParser { protected final TokenType nextOrEOL() { do { nextToken(); - } while (type == COMMENT); + if (type == DIRECTIVE_COMMENT) { + checkDirectiveComment(); + } + } while (type == COMMENT || type == DIRECTIVE_COMMENT); return type; } + // sourceURL= after directive comment + private static final String SOURCE_URL_PREFIX = "sourceURL="; + + // currently only @sourceURL=foo supported + private void checkDirectiveComment() { + // if already set, ignore this one + if (sourceURL != null) { + return; + } + + final String comment = (String) lexer.getValueOf(token, isStrictMode); + final int len = comment.length(); + // 4 characters for directive comment marker //@\s or //#\s + if (len > 4 && comment.substring(4).startsWith(SOURCE_URL_PREFIX)) { + sourceURL = comment.substring(4 + SOURCE_URL_PREFIX.length()); + } + } + /** * Seek next token. * * @return tokenType of next token. */ - private final TokenType nextToken() { + private TokenType nextToken() { // Capture last token tokenType. last = type; if (type != EOF) { diff --git a/nashorn/src/jdk/nashorn/internal/parser/Lexer.java b/nashorn/src/jdk/nashorn/internal/parser/Lexer.java index a01705dd956..653f04c02f5 100644 --- a/nashorn/src/jdk/nashorn/internal/parser/Lexer.java +++ b/nashorn/src/jdk/nashorn/internal/parser/Lexer.java @@ -27,6 +27,7 @@ package jdk.nashorn.internal.parser; import static jdk.nashorn.internal.parser.TokenType.ADD; import static jdk.nashorn.internal.parser.TokenType.COMMENT; +import static jdk.nashorn.internal.parser.TokenType.DIRECTIVE_COMMENT; import static jdk.nashorn.internal.parser.TokenType.DECIMAL; import static jdk.nashorn.internal.parser.TokenType.EOF; import static jdk.nashorn.internal.parser.TokenType.EOL; @@ -434,12 +435,18 @@ public class Lexer extends Scanner { if (ch1 == '/') { // Skip over //. skip(2); + + boolean directiveComment = false; + if ((ch0 == '#' || ch0 == '@') && (ch1 == ' ')) { + directiveComment = true; + } + // Scan for EOL. while (!atEOF() && !isEOL(ch0)) { skip(1); } // Did detect a comment. - add(COMMENT, start); + add(directiveComment? DIRECTIVE_COMMENT : COMMENT, start); return true; } else if (ch1 == '*') { // Skip over /*. @@ -1623,6 +1630,8 @@ public class Lexer extends Scanner { return valueOfPattern(start, len); // RegexToken::LexerToken case XML: return valueOfXML(start, len); // XMLToken::LexerToken + case DIRECTIVE_COMMENT: + return source.getString(start, len); default: break; } diff --git a/nashorn/src/jdk/nashorn/internal/parser/Parser.java b/nashorn/src/jdk/nashorn/internal/parser/Parser.java index 8e04fdceda7..60cbaccb68e 100644 --- a/nashorn/src/jdk/nashorn/internal/parser/Parser.java +++ b/nashorn/src/jdk/nashorn/internal/parser/Parser.java @@ -26,7 +26,7 @@ package jdk.nashorn.internal.parser; import static jdk.nashorn.internal.codegen.CompilerConstants.EVAL; -import static jdk.nashorn.internal.codegen.CompilerConstants.FUNCTION_PREFIX; +import static jdk.nashorn.internal.codegen.CompilerConstants.ANON_FUNCTION_PREFIX; import static jdk.nashorn.internal.codegen.CompilerConstants.RUN_SCRIPT; import static jdk.nashorn.internal.parser.TokenType.ASSIGN; import static jdk.nashorn.internal.parser.TokenType.CASE; @@ -389,7 +389,9 @@ loop: sb.append(parentFunction.getName()).append('$'); } - sb.append(ident != null ? ident.getName() : FUNCTION_PREFIX.symbolName()); + assert ident.getName() != null; + sb.append(ident.getName()); + final String name = namespace.uniqueName(sb.toString()); assert parentFunction != null || name.equals(RUN_SCRIPT.symbolName()) : "name = " + name;// must not rename runScript(). @@ -419,7 +421,8 @@ loop: name, parameters, kind, - flags); + flags, + sourceURL); lc.push(functionNode); // Create new block, and just put it on the context stack, restoreFunctionNode() will associate it with the @@ -638,6 +641,10 @@ loop: script = restoreFunctionNode(script, token); //commit code script = script.setBody(lc, script.getBody().setNeedsScope(lc)); + // user may have directive comment to set sourceURL + if (sourceURL != null) { + script = script.setSourceURL(lc, sourceURL); + } return script; } @@ -2132,11 +2139,20 @@ loop: final String setterName = setIdent.getPropertyName(); final IdentNode setNameNode = new IdentNode(((Node)setIdent).getToken(), finish, NameCodec.encode("set " + setterName)); expect(LPAREN); - final IdentNode argIdent = getIdent(); - verifyStrictIdent(argIdent, "setter argument"); + // be sloppy and allow missing setter parameter even though + // spec does not permit it! + final IdentNode argIdent; + if (type == IDENT || isNonStrictModeIdent()) { + argIdent = getIdent(); + verifyStrictIdent(argIdent, "setter argument"); + } else { + argIdent = null; + } expect(RPAREN); List<IdentNode> parameters = new ArrayList<>(); - parameters.add(argIdent); + if (argIdent != null) { + parameters.add(argIdent); + } functionNode = functionBody(getSetToken, setNameNode, parameters, FunctionNode.Kind.SETTER); return new PropertyNode(propertyToken, finish, setIdent, null, null, functionNode); @@ -2448,7 +2464,7 @@ loop: // name is null, generate anonymous name boolean isAnonymous = false; if (name == null) { - final String tmpName = "_L" + functionLine; + final String tmpName = ANON_FUNCTION_PREFIX.symbolName() + functionLine; name = new IdentNode(functionToken, Token.descPosition(functionToken), tmpName); isAnonymous = true; } diff --git a/nashorn/src/jdk/nashorn/internal/parser/TokenType.java b/nashorn/src/jdk/nashorn/internal/parser/TokenType.java index 6287a234cf2..5c696cb92b7 100644 --- a/nashorn/src/jdk/nashorn/internal/parser/TokenType.java +++ b/nashorn/src/jdk/nashorn/internal/parser/TokenType.java @@ -41,10 +41,14 @@ import static jdk.nashorn.internal.parser.TokenKind.UNARY; */ @SuppressWarnings("javadoc") public enum TokenType { - ERROR (SPECIAL, null), - EOF (SPECIAL, null), - EOL (SPECIAL, null), - COMMENT (SPECIAL, null), + ERROR (SPECIAL, null), + EOF (SPECIAL, null), + EOL (SPECIAL, null), + COMMENT (SPECIAL, null), + // comments of the form //@ foo=bar or //# foo=bar + // These comments are treated as special instructions + // to the lexer, parser or codegenerator. + DIRECTIVE_COMMENT (SPECIAL, null), NOT (UNARY, "!", 14, false), NE (BINARY, "!=", 9, true), diff --git a/nashorn/src/jdk/nashorn/internal/runtime/Context.java b/nashorn/src/jdk/nashorn/internal/runtime/Context.java index c9deee3501d..1817ca928ba 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/Context.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/Context.java @@ -91,6 +91,11 @@ public final class Context { */ public static final String NASHORN_JAVA_REFLECTION = "nashorn.JavaReflection"; + /** + * Permission to enable nashorn debug mode. + */ + public static final String NASHORN_DEBUG_MODE = "nashorn.debugMode"; + // nashorn load psuedo URL prefixes private static final String LOAD_CLASSPATH = "classpath:"; private static final String LOAD_FX = "fx:"; diff --git a/nashorn/src/jdk/nashorn/internal/runtime/ECMAErrors.java b/nashorn/src/jdk/nashorn/internal/runtime/ECMAErrors.java index 0ff843a4271..754ebbf955f 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/ECMAErrors.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/ECMAErrors.java @@ -30,6 +30,7 @@ import java.util.Locale; import java.util.ResourceBundle; import jdk.nashorn.api.scripting.NashornException; import jdk.nashorn.internal.scripts.JS; +import jdk.nashorn.internal.codegen.CompilerConstants; /** * Helper class to throw various standard "ECMA error" exceptions such as Error, ReferenceError, TypeError etc. @@ -401,7 +402,7 @@ public final class ECMAErrors { final String className = frame.getClassName(); // Look for script package in class name (into which compiler puts generated code) - if (className.startsWith(scriptPackage)) { + if (className.startsWith(scriptPackage) && !frame.getMethodName().startsWith(CompilerConstants.INTERNAL_METHOD_PREFIX)) { final String source = frame.getFileName(); /* * Make sure that it is not some Java code that Nashorn has in that package! diff --git a/nashorn/src/jdk/nashorn/internal/runtime/ECMAException.java b/nashorn/src/jdk/nashorn/internal/runtime/ECMAException.java index a32e721cc46..c900963de4a 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/ECMAException.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/ECMAException.java @@ -25,7 +25,7 @@ package jdk.nashorn.internal.runtime; -import static jdk.nashorn.internal.codegen.CompilerConstants.constructorNoLookup; +import static jdk.nashorn.internal.codegen.CompilerConstants.staticCallNoLookup; import static jdk.nashorn.internal.codegen.CompilerConstants.virtualField; import static jdk.nashorn.internal.runtime.ScriptRuntime.UNDEFINED; @@ -44,9 +44,9 @@ import jdk.nashorn.internal.codegen.CompilerConstants.FieldAccess; @SuppressWarnings("serial") public final class ECMAException extends NashornException { /** - * Method handle pointing to the constructor {@link ECMAException#ECMAException(Object, String, int, int)}, + * Method handle pointing to the constructor {@link ECMAException#create(Object, String, int, int)}, */ - public static final Call THROW_INIT = constructorNoLookup(ECMAException.class, Object.class, String.class, int.class, int.class); + public static final Call CREATE = staticCallNoLookup(ECMAException.class, "create", ECMAException.class, Object.class, String.class, int.class, int.class); /** Field handle to the{@link ECMAException#thrown} field, so that it can be accessed from generated code */ public static final FieldAccess THROWN = virtualField(ECMAException.class, "thrown", Object.class); @@ -57,23 +57,21 @@ public final class ECMAException extends NashornException { public final Object thrown; /** - * Constructor. This is called from generated code to implement the {@code throw} - * instruction from generated script code + * Constructor. Called from the factory method 'create'. * * @param thrown object to be thrown * @param fileName script file name * @param line line number of throw * @param column column number of throw */ - public ECMAException(final Object thrown, final String fileName, final int line, final int column) { + private ECMAException(final Object thrown, final String fileName, final int line, final int column) { super(ScriptRuntime.safeToString(thrown), asThrowable(thrown), fileName, line, column); this.thrown = thrown; setExceptionToThrown(); } /** - * Constructor. This is called from runtime code in Nashorn to throw things like - * type errors. + * Constructor. This is called from the runtime code. * * @param thrown object to be thrown * @param cause Java exception that triggered this throw @@ -84,10 +82,40 @@ public final class ECMAException extends NashornException { setExceptionToThrown(); } + /** + * Factory method to retrieve the underlying exception or create an exception. + * This method is called from the generated code. + * + * @param thrown object to be thrown + * @param fileName script file name + * @param line line number of throw + * @param column column number of throw + * @return ECMAException object + */ + public static ECMAException create(final Object thrown, final String fileName, final int line, final int column) { + // If thrown object is an Error or sub-object like TypeError, then + // an ECMAException object has been already initialized at constructor. + if (thrown instanceof ScriptObject) { + ScriptObject sobj = (ScriptObject)thrown; + Object exception = getException(sobj); + if (exception instanceof ECMAException) { + // copy over file name, line number and column number. + final ECMAException ee = (ECMAException)exception; + ee.setFileName(fileName); + ee.setLineNumber(line); + ee.setColumnNumber(column); + return ee; + } + } + + return new ECMAException(thrown, fileName, line, column); + } + /** * Get the thrown object * @return thrown object */ + @Override public Object getThrown() { return thrown; } @@ -256,6 +284,8 @@ public final class ECMAException extends NashornException { final ScriptObject sobj = (ScriptObject)thrown; if (!sobj.has(EXCEPTION_PROPERTY)) { sobj.addOwnProperty(EXCEPTION_PROPERTY, Property.NOT_ENUMERABLE, this); + } else { + sobj.set(EXCEPTION_PROPERTY, this, false); } } } diff --git a/nashorn/src/jdk/nashorn/internal/runtime/FindProperty.java b/nashorn/src/jdk/nashorn/internal/runtime/FindProperty.java index c14accb7c4e..87a8c74849a 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/FindProperty.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/FindProperty.java @@ -112,7 +112,7 @@ public final class FindProperty { return property != null && property.hasGetterFunction(prototype) ? self : prototype; } - /** + /** * Return the appropriate receiver for a setter. * @return appropriate receiver */ @@ -172,5 +172,20 @@ public final class FindProperty { property.setObjectValue(getSetterReceiver(), getOwner(), value, strict); } + /** + * Get the number of objects in the prototype chain between the {@code self} and the + * {@code owner} objects. + * @return the prototype chain length + */ + int getProtoChainLength() { + assert self != null; + int length = 0; + for (ScriptObject obj = self; obj != prototype; obj = obj.getProto()) { + assert !(obj instanceof WithObject); + ++length; + } + return length; + } + } diff --git a/nashorn/src/jdk/nashorn/internal/runtime/NativeJavaPackage.java b/nashorn/src/jdk/nashorn/internal/runtime/NativeJavaPackage.java index 99ba9e19fa5..a5abacb2134 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/NativeJavaPackage.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/NativeJavaPackage.java @@ -196,26 +196,15 @@ public final class NativeJavaPackage extends ScriptObject { @Override public GuardedInvocation noSuchProperty(final CallSiteDescriptor desc, final LinkRequest request) { final String propertyName = desc.getNameToken(2); - final String fullName = name.isEmpty() ? propertyName : name + "." + propertyName; - - final Context context = Context.getContextTrusted(); - - Class<?> javaClass = null; - try { - javaClass = context.findClass(fullName); - } catch (final NoClassDefFoundError | ClassNotFoundException e) { - //ignored - } - - if (javaClass == null) { - set(propertyName, new NativeJavaPackage(fullName, getProto()), false); - } else { - set(propertyName, StaticClass.forClass(javaClass), false); - } - + createProperty(propertyName); return super.lookup(desc, request); } + @Override + protected Object invokeNoSuchProperty(final String name) { + return createProperty(name); + } + @Override public GuardedInvocation noSuchMethod(final CallSiteDescriptor desc, final LinkRequest request) { return noSuchProperty(desc, request); @@ -224,4 +213,26 @@ public final class NativeJavaPackage extends ScriptObject { private static MethodHandle findOwnMH(final String name, final Class<?> rtype, final Class<?>... types) { return MH.findStatic(MethodHandles.lookup(), NativeJavaPackage.class, name, MH.type(rtype, types)); } + + private Object createProperty(final String propertyName) { + final String fullName = name.isEmpty() ? propertyName : name + "." + propertyName; + final Context context = Context.getContextTrusted(); + + Class<?> javaClass = null; + try { + javaClass = context.findClass(fullName); + } catch (final NoClassDefFoundError | ClassNotFoundException e) { + //ignored + } + + final Object propertyValue; + if (javaClass == null) { + propertyValue = new NativeJavaPackage(fullName, getProto()); + } else { + propertyValue = StaticClass.forClass(javaClass); + } + + set(propertyName, propertyValue, false); + return propertyValue; + } } diff --git a/nashorn/src/jdk/nashorn/internal/runtime/ScriptObject.java b/nashorn/src/jdk/nashorn/internal/runtime/ScriptObject.java index 02160d69eee..4b85ed4ed5c 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/ScriptObject.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/ScriptObject.java @@ -143,6 +143,8 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr private static final MethodHandle TRUNCATINGFILTER = findOwnMH("truncatingFilter", Object[].class, int.class, Object[].class); private static final MethodHandle KNOWNFUNCPROPGUARD = findOwnMH("knownFunctionPropertyGuard", boolean.class, Object.class, PropertyMap.class, MethodHandle.class, Object.class, ScriptFunction.class); + private static final ArrayList<MethodHandle> protoFilters = new ArrayList<>(); + /** Method handle for getting a function argument at a given index. Used from MapCreator */ public static final Call GET_ARGUMENT = virtualCall(MethodHandles.lookup(), ScriptObject.class, "getArgument", Object.class, int.class); @@ -1711,6 +1713,44 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr return getter.replaceMethods(MH.foldArguments(invoker, argDroppingGetter), getter.getGuard()); } + /** + * Test whether this object contains in its prototype chain or is itself a with-object. + * @return true if a with-object was found + */ + final boolean hasWithScope() { + if (isScope()) { + for (ScriptObject obj = this; obj != null; obj = obj.getProto()) { + if (obj instanceof WithObject) { + return true; + } + } + } + return false; + } + + /** + * Add a filter to the first argument of {@code methodHandle} that calls its {@link #getProto()} method + * {@code depth} times. + * @param methodHandle a method handle + * @param depth distance to target prototype + * @return the filtered method handle + */ + static MethodHandle addProtoFilter(final MethodHandle methodHandle, final int depth) { + if (depth == 0) { + return methodHandle; + } + final int listIndex = depth - 1; // We don't need 0-deep walker + MethodHandle filter = listIndex < protoFilters.size() ? protoFilters.get(listIndex) : null; + + if(filter == null) { + filter = addProtoFilter(GETPROTO, depth - 1); + protoFilters.add(null); + protoFilters.set(listIndex, filter); + } + + return MH.filterArguments(methodHandle, 0, filter.asType(filter.type().changeReturnType(methodHandle.type().parameterType(0)))); + } + /** * Find the appropriate GET method for an invoke dynamic call. * @@ -1722,7 +1762,7 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr */ protected GuardedInvocation findGetMethod(final CallSiteDescriptor desc, final LinkRequest request, final String operator) { final String name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND); - if (request.isCallSiteUnstable()) { + if (request.isCallSiteUnstable() || hasWithScope()) { return findMegaMorphicGetMethod(desc, name, "getMethod".equals(operator)); } @@ -1748,22 +1788,24 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr final Property property = find.getProperty(); methodHandle = find.getGetter(returnType); + final boolean noGuard = ObjectClassGenerator.OBJECT_FIELDS_ONLY && NashornCallSiteDescriptor.isFastScope(desc) && !property.canChangeType(); // getMap() is fine as we have the prototype switchpoint depending on where the property was found - final MethodHandle guard = NashornGuards.getMapGuard(getMap()); + final MethodHandle guard = noGuard ? null : NashornGuards.getMapGuard(getMap()); if (methodHandle != null) { assert methodHandle.type().returnType().equals(returnType); if (find.isSelf()) { - return new GuardedInvocation(methodHandle, ObjectClassGenerator.OBJECT_FIELDS_ONLY && - NashornCallSiteDescriptor.isFastScope(desc) && !property.canChangeType() ? null : guard); + return new GuardedInvocation(methodHandle, guard); } - final ScriptObject prototype = find.getOwner(); - - if (!property.hasGetterFunction(prototype)) { - methodHandle = bindTo(methodHandle, prototype); + if (!property.hasGetterFunction(find.getOwner())) { + // If not a scope bind to actual prototype as changing prototype will change the property map. + // For scopes we install a filter that replaces the self object with the prototype owning the property. + methodHandle = isScope() ? + addProtoFilter(methodHandle, find.getProtoChainLength()) : + bindTo(methodHandle, find.getOwner()); } - return new GuardedInvocation(methodHandle, getMap().getProtoGetSwitchPoint(proto, name), guard); + return new GuardedInvocation(methodHandle, noGuard ? null : getMap().getProtoGetSwitchPoint(proto, name), guard); } assert !NashornCallSiteDescriptor.isFastScope(desc); @@ -1833,7 +1875,7 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr */ protected GuardedInvocation findSetMethod(final CallSiteDescriptor desc, final LinkRequest request) { final String name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND); - if (request.isCallSiteUnstable()) { + if (request.isCallSiteUnstable() || hasWithScope()) { return findMegaMorphicSetMethod(desc, name); } @@ -1888,7 +1930,9 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr final ScriptObject obj = (ScriptObject)self; final boolean isStrict = NashornCallSiteDescriptor.isStrict(desc); if (!obj.isExtensible()) { - throw typeError("object.non.extensible", desc.getNameToken(2), ScriptRuntime.safeToString(obj)); + if (isStrict) { + throw typeError("object.non.extensible", desc.getNameToken(2), ScriptRuntime.safeToString(obj)); + } } else if (obj.compareAndSetMap(oldMap, newMap)) { setter.invokeExact(self, value); } else { @@ -2049,12 +2093,13 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr return createEmptyGetter(desc, name); } + /** * Invoke fall back if a property is not found. * @param name Name of property. * @return Result from call. */ - private Object invokeNoSuchProperty(final String name) { + protected Object invokeNoSuchProperty(final String name) { final FindProperty find = findProperty(NO_SUCH_PROPERTY_NAME, true); if (find != null) { @@ -2759,7 +2804,8 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr public final void setObject(final FindProperty find, final boolean strict, final String key, final Object value) { FindProperty f = find; - if (f != null && f.isInherited() && !(f.getProperty() instanceof UserAccessorProperty)) { + if (f != null && f.isInherited() && !(f.getProperty() instanceof UserAccessorProperty) && !isScope()) { + // Setting a property should not modify the property in prototype unless this is a scope object. f = null; } diff --git a/nashorn/src/jdk/nashorn/internal/runtime/SetMethodCreator.java b/nashorn/src/jdk/nashorn/internal/runtime/SetMethodCreator.java index 777254d831c..7390aadd0cd 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/SetMethodCreator.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/SetMethodCreator.java @@ -151,10 +151,12 @@ final class SetMethodCreator { assert methodHandle != null; assert property != null; - final ScriptObject prototype = find.getOwner(); final MethodHandle boundHandle; - if (!property.hasSetterFunction(prototype) && find.isInherited()) { - boundHandle = ScriptObject.bindTo(methodHandle, prototype); + if (!property.hasSetterFunction(find.getOwner()) && find.isInherited()) { + // Bind or add prototype filter depending on whether this is a scope object. + boundHandle = sobj.isScope() ? + ScriptObject.addProtoFilter(methodHandle, find.getProtoChainLength()): + ScriptObject.bindTo(methodHandle, find.getOwner()); } else { boundHandle = methodHandle; } diff --git a/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterBytecodeGenerator.java b/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterBytecodeGenerator.java index 5b8d4cfe3f0..ef2a6829a25 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterBytecodeGenerator.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterBytecodeGenerator.java @@ -317,7 +317,7 @@ final class JavaAdapterBytecodeGenerator { final InstructionAdapter mv = new InstructionAdapter(cw.visitMethod(ACC_STATIC, CLASS_INIT, Type.getMethodDescriptor(Type.VOID_TYPE), null, null)); - mv.invokestatic(SERVICES_CLASS_TYPE_NAME, "getClassOverrides", GET_CLASS_INITIALIZER_DESCRIPTOR); + mv.invokestatic(SERVICES_CLASS_TYPE_NAME, "getClassOverrides", GET_CLASS_INITIALIZER_DESCRIPTOR, false); final Label initGlobal; if(samName != null) { // If the class is a SAM, allow having a ScriptFunction passed as class overrides @@ -333,7 +333,7 @@ final class JavaAdapterBytecodeGenerator { if(mi.getName().equals(samName)) { mv.dup(); mv.aconst(Type.getMethodType(mi.type.toMethodDescriptorString())); - mv.invokestatic(SERVICES_CLASS_TYPE_NAME, "getHandle", GET_HANDLE_FUNCTION_DESCRIPTOR); + mv.invokestatic(SERVICES_CLASS_TYPE_NAME, "getHandle", GET_HANDLE_FUNCTION_DESCRIPTOR, false); } else { mv.visitInsn(ACONST_NULL); } @@ -350,7 +350,7 @@ final class JavaAdapterBytecodeGenerator { mv.dup(); mv.aconst(mi.getName()); mv.aconst(Type.getMethodType(mi.type.toMethodDescriptorString())); - mv.invokestatic(SERVICES_CLASS_TYPE_NAME, "getHandle", GET_HANDLE_OBJECT_DESCRIPTOR); + mv.invokestatic(SERVICES_CLASS_TYPE_NAME, "getHandle", GET_HANDLE_OBJECT_DESCRIPTOR, false); mv.putstatic(generatedClassName, mi.methodHandleClassFieldName, METHOD_HANDLE_TYPE_DESCRIPTOR); } @@ -367,7 +367,7 @@ final class JavaAdapterBytecodeGenerator { private static void invokeGetGlobalWithNullCheck(final InstructionAdapter mv) { invokeGetGlobal(mv); mv.dup(); - mv.invokevirtual(OBJECT_TYPE_NAME, "getClass", GET_CLASS_METHOD_DESCRIPTOR); // check against null Context + mv.invokevirtual(OBJECT_TYPE_NAME, "getClass", GET_CLASS_METHOD_DESCRIPTOR, false); // check against null Context mv.pop(); } @@ -424,7 +424,7 @@ final class JavaAdapterBytecodeGenerator { mv.load(offset, argType); offset += argType.getSize(); } - mv.invokespecial(superClassName, INIT, originalCtorType.getDescriptor()); + mv.invokespecial(superClassName, INIT, originalCtorType.getDescriptor(), false); endInitMethod(mv); } @@ -477,7 +477,7 @@ final class JavaAdapterBytecodeGenerator { mv.load(offset, argType); offset += argType.getSize(); } - mv.invokespecial(superClassName, INIT, originalCtorType.getDescriptor()); + mv.invokespecial(superClassName, INIT, originalCtorType.getDescriptor(), false); // Get a descriptor to the appropriate "JavaAdapterFactory.getHandle" method. final String getHandleDescriptor = fromFunction ? GET_HANDLE_FUNCTION_DESCRIPTOR : GET_HANDLE_OBJECT_DESCRIPTOR; @@ -496,7 +496,7 @@ final class JavaAdapterBytecodeGenerator { mv.aconst(mi.getName()); } mv.aconst(Type.getMethodType(mi.type.toMethodDescriptorString())); - mv.invokestatic(SERVICES_CLASS_TYPE_NAME, "getHandle", getHandleDescriptor); + mv.invokestatic(SERVICES_CLASS_TYPE_NAME, "getHandle", getHandleDescriptor, false); } mv.putfield(generatedClassName, mi.methodHandleInstanceFieldName, METHOD_HANDLE_TYPE_DESCRIPTOR); } @@ -520,11 +520,11 @@ final class JavaAdapterBytecodeGenerator { } private static void invokeGetGlobal(final InstructionAdapter mv) { - mv.invokestatic(CONTEXT_TYPE_NAME, "getGlobal", GET_GLOBAL_METHOD_DESCRIPTOR); + mv.invokestatic(CONTEXT_TYPE_NAME, "getGlobal", GET_GLOBAL_METHOD_DESCRIPTOR, false); } private static void invokeSetGlobal(final InstructionAdapter mv) { - mv.invokestatic(CONTEXT_TYPE_NAME, "setGlobal", SET_GLOBAL_METHOD_DESCRIPTOR); + mv.invokestatic(CONTEXT_TYPE_NAME, "setGlobal", SET_GLOBAL_METHOD_DESCRIPTOR, false); } /** @@ -647,11 +647,11 @@ final class JavaAdapterBytecodeGenerator { // If the super method is abstract, throw an exception mv.anew(UNSUPPORTED_OPERATION_TYPE); mv.dup(); - mv.invokespecial(UNSUPPORTED_OPERATION_TYPE_NAME, INIT, VOID_NOARG_METHOD_DESCRIPTOR); + mv.invokespecial(UNSUPPORTED_OPERATION_TYPE_NAME, INIT, VOID_NOARG_METHOD_DESCRIPTOR, false); mv.athrow(); } else { // If the super method is not abstract, delegate to it. - emitSuperCall(mv, name, methodDesc); + emitSuperCall(mv, method.getDeclaringClass(), name, methodDesc); } final Label setupGlobal = new Label(); @@ -728,7 +728,7 @@ final class JavaAdapterBytecodeGenerator { // Invoke the target method handle final Label tryBlockStart = new Label(); mv.visitLabel(tryBlockStart); - mv.invokevirtual(METHOD_HANDLE_TYPE.getInternalName(), "invokeExact", type.toMethodDescriptorString()); + mv.invokevirtual(METHOD_HANDLE_TYPE.getInternalName(), "invokeExact", type.toMethodDescriptorString(), false); final Label tryBlockEnd = new Label(); mv.visitLabel(tryBlockEnd); emitFinally(mv, currentGlobalVar, globalsDifferVar); @@ -744,7 +744,7 @@ final class JavaAdapterBytecodeGenerator { mv.anew(RUNTIME_EXCEPTION_TYPE); mv.dupX1(); mv.swap(); - mv.invokespecial(RUNTIME_EXCEPTION_TYPE_NAME, INIT, Type.getMethodDescriptor(Type.VOID_TYPE, THROWABLE_TYPE)); + mv.invokespecial(RUNTIME_EXCEPTION_TYPE_NAME, INIT, Type.getMethodDescriptor(Type.VOID_TYPE, THROWABLE_TYPE), false); // Fall through to rethrow handler } else { throwableHandler = null; @@ -830,12 +830,12 @@ final class JavaAdapterBytecodeGenerator { SUPER_PREFIX + name, methodDesc, null, getExceptionNames(method.getExceptionTypes()))); mv.visitCode(); - emitSuperCall(mv, name, methodDesc); + emitSuperCall(mv, method.getDeclaringClass(), name, methodDesc); endMethod(mv); } - private void emitSuperCall(final InstructionAdapter mv, final String name, final String methodDesc) { + private void emitSuperCall(final InstructionAdapter mv, final Class owner, final String name, final String methodDesc) { mv.visitVarInsn(ALOAD, 0); int nextParam = 1; final Type methodType = Type.getMethodType(methodDesc); @@ -843,7 +843,13 @@ final class JavaAdapterBytecodeGenerator { mv.load(nextParam, t); nextParam += t.getSize(); } - mv.invokespecial(superClassName, name, methodDesc); + + // default method - non-abstract, interface method + if (Modifier.isInterface(owner.getModifiers())) { + mv.invokespecial(Type.getInternalName(owner), name, methodDesc, false); + } else { + mv.invokespecial(superClassName, name, methodDesc, false); + } mv.areturn(methodType.getReturnType()); } diff --git a/nashorn/src/jdk/nashorn/internal/runtime/linker/ReflectionCheckLinker.java b/nashorn/src/jdk/nashorn/internal/runtime/linker/ReflectionCheckLinker.java index 39f9364233d..6772cbee037 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/linker/ReflectionCheckLinker.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/linker/ReflectionCheckLinker.java @@ -75,7 +75,8 @@ final class ReflectionCheckLinker implements TypeBasedGuardingDynamicLinker{ if ((self instanceof Class) && Modifier.isPublic(((Class<?>)self).getModifiers())) { final CallSiteDescriptor desc = requestWithoutContext.getCallSiteDescriptor(); if(CallSiteDescriptorFactory.tokenizeOperators(desc).contains("getProp")) { - if ("static".equals(desc.getNameToken(CallSiteDescriptor.NAME_OPERAND))) { + if (desc.getNameTokenCount() > CallSiteDescriptor.NAME_OPERAND && + "static".equals(desc.getNameToken(CallSiteDescriptor.NAME_OPERAND))) { if (Context.isAccessibleClass((Class<?>)self) && !isReflectionClass((Class<?>)self)) { // If "getProp:static" passes access checks, allow access. return; diff --git a/nashorn/test/script/basic/JDK-8010731.js b/nashorn/test/script/basic/JDK-8010731.js new file mode 100644 index 00000000000..532cf135e81 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8010731.js @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * JDK-8010731: Nashorn exposes internal symbols such as __callee__, __scope__ to scripts + * + * @test + * @run + */ + +function checkCallee() { + var x = arguments[0]; // force __callee__ (renamed as :callee) + + print(__callee__); +} + +try { + checkCallee(); + fail("Should have thrown ReferenceError for __callee__"); +} catch (e) { + if (! (e instanceof ReferenceError)) { + fail("ReferenceError expected, got " + e); + } +} + +function checkScope() { + var x = 334; + + function inner() { + var y = x * x; // force __scope__ (renamed as :scope") + print(__scope__); + } + + inner(); +} + +try { + checkScope(); + fail("Should have thrown ReferenceError for __scope__"); +} catch (e) { + if (! (e instanceof ReferenceError)) { + fail("ReferenceError expected, got " + e); + } +} diff --git a/nashorn/test/script/basic/JDK-8025515.js b/nashorn/test/script/basic/JDK-8025515.js index f3d7cee47c0..29574d2a86a 100644 --- a/nashorn/test/script/basic/JDK-8025515.js +++ b/nashorn/test/script/basic/JDK-8025515.js @@ -30,13 +30,23 @@ // Make sure synthetic names of anonymous functions have correct line numbers +function getFirstScriptFrame(stack) { + for (frameNum in stack) { + var frame = stack[frameNum]; + if (frame.className.startsWith("jdk.nashorn.internal.scripts.Script$")) { + return frame; + } + } +} + function testMethodName(f, expected) { try { f(); fail("expected error"); } catch (e) { - var stack = e.getStackTrace(); - if (stack[0].methodName !== expected) { + var stack = e.nashornException.getStackTrace(); + var name = getFirstScriptFrame(stack).methodName; + if (name !== expected) { fail("got " + stack[0].methodName + ", expected " + expected); } } @@ -44,15 +54,15 @@ function testMethodName(f, expected) { testMethodName(function() { return a.b.c; -}, "_L45"); +}, "L:55"); -testMethodName(function() { throw new Error() }, "_L49"); +testMethodName(function() { throw new Error() }, "L:59"); var f = (function() { return function() { a.b.c; }; })(); -testMethodName(f, "_L51$_L52"); +testMethodName(f, "L:61$L:62"); testMethodName((function() { return function() { return a.b.c; }; -})(), "_L56$_L57"); +})(), "L:66$L:67"); diff --git a/nashorn/test/script/basic/JDK-8029364.js b/nashorn/test/script/basic/JDK-8029364.js new file mode 100644 index 00000000000..dfa8ea9de4f --- /dev/null +++ b/nashorn/test/script/basic/JDK-8029364.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * JDK-8029364: NashornException to expose thrown object + * + * @test + * @run + */ + +var m = new javax.script.ScriptEngineManager(); +var e = m.getEngineByName("nashorn"); +var g = e.eval("this"); +try { + e.eval("var e = new Error('foo'); e.bar = 33; throw e"); +} catch (se) { + // ScriptException instance's cause is a NashornException + print(se.getClass()); + var cause = se.cause; + print(cause.getClass()); + // NashornException instance has 'ecmaError' bean getter + print(cause.ecmaError); + // access to underlying ECMA Error object + print(cause.ecmaError instanceof g.Error); + print(cause.ecmaError.name); + print(cause.ecmaError.message); + print(cause.ecmaError.bar); +} + diff --git a/nashorn/test/script/basic/JDK-8029364.js.EXPECTED b/nashorn/test/script/basic/JDK-8029364.js.EXPECTED new file mode 100644 index 00000000000..d01bb9ee0b7 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8029364.js.EXPECTED @@ -0,0 +1,7 @@ +class javax.script.ScriptException +class jdk.nashorn.internal.runtime.ECMAException +Error: foo +true +Error +foo +33 diff --git a/nashorn/test/script/basic/JDK-8029467.js b/nashorn/test/script/basic/JDK-8029467.js new file mode 100644 index 00000000000..ad7f2fde6bb --- /dev/null +++ b/nashorn/test/script/basic/JDK-8029467.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * JDK-8029467: Widening of booleans causes bad results + * + * @test + * @run + */ + +print((function (x) { return x ? true : 0 })(true)) +print((function (x) { if(x) { return true } else { return 0 } })(true)) +print(typeof (function (x) { return x ? 1 : "123" })(true) === "number") +print(typeof (function (x) { if(x) { return 1 } else { return "123" } })(true) === "number") diff --git a/nashorn/test/script/basic/JDK-8029467.js.EXPECTED b/nashorn/test/script/basic/JDK-8029467.js.EXPECTED new file mode 100644 index 00000000000..1140ff52e2b --- /dev/null +++ b/nashorn/test/script/basic/JDK-8029467.js.EXPECTED @@ -0,0 +1,4 @@ +true +true +true +true diff --git a/nashorn/test/script/basic/JDK-8029667.js b/nashorn/test/script/basic/JDK-8029667.js new file mode 100644 index 00000000000..c0c2d156200 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8029667.js @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * JDK-8029667: Prototype linking is incorrect + * + * @test + * @run + */ + +function f(x) { + return (function inner() { + var y; (function dummy() { return y })() // force own scope for the inner function + with({}) { // 'with' block turns off fast scopes + return x + } + })(); +} +print(f(1)); +print(f(2)); + +function g(x) { + (function inner() { + var y; (function dummy() { return y })() // force own scope for the inner function + with({}) { // 'with' block turns off fast scopes + // Test setter as well as getter + x = x + 2; + } + })(); + print(x); +} + +g(1); +g(2); + +var withScopes = [{ func: function() { print("called 1");} }, { func: function() { print("called 2");} }]; + +for(var i in withScopes) { + with (withScopes[i]) { + var main = function() { + var frame; // <---- this local variable caused scope to be not set properly prior to fix + + function callFunc() { + frame = func(); + } + + callFunc(); + } + } + main(); +} + +for(var i in withScopes) { + with (withScopes[i]) { + var main = function() { + var frame; // <---- this local variable caused scope to be not set properly prior to fix + + function callFunc() { + frame = func = i; + } + + callFunc(); + } + } + main(); +} + +print(withScopes[0].func); +print(withScopes[1].func); + + diff --git a/nashorn/test/script/basic/JDK-8029667.js.EXPECTED b/nashorn/test/script/basic/JDK-8029667.js.EXPECTED new file mode 100644 index 00000000000..8aa78efed12 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8029667.js.EXPECTED @@ -0,0 +1,8 @@ +1 +2 +3 +4 +called 1 +called 2 +0 +1 diff --git a/nashorn/test/script/basic/JDK-8030182.js b/nashorn/test/script/basic/JDK-8030182.js new file mode 100644 index 00000000000..f3c492d41b2 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8030182.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * JDK-8030182: scopeCall with -1 as line number + * + * @test + * @run + */ + +function func() { + throw new Error("Strange..."); +} + +var f2 = func; +var f3 = func; +var f4 = func; +var f5 = func; + +// check that "scopeCall" or some such internal method +// does not appear in script stack trace. +try { + func(); +} catch(err) { + print(err.stack.replace(/\\/g, '/')); +} diff --git a/nashorn/test/script/basic/JDK-8030182.js.EXPECTED b/nashorn/test/script/basic/JDK-8030182.js.EXPECTED new file mode 100644 index 00000000000..d12b6d7fd72 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8030182.js.EXPECTED @@ -0,0 +1,3 @@ +Error: Strange... + at func (test/script/basic/JDK-8030182.js:32) + at <program> (test/script/basic/JDK-8030182.js:43) diff --git a/nashorn/test/script/basic/JDK-8030182_2.js b/nashorn/test/script/basic/JDK-8030182_2.js new file mode 100644 index 00000000000..de507e1dad4 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8030182_2.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * JDK-8030182: scopeCall with -1 as line number + * + * @test + * @run + */ + +var str = ""; + +// large code to force splitting +for (i = 0; i < 1000; ++i) + str +="o = new Object()\n"; + +str +="g()"; + +// check that "$split" or some such internal method +// does not appear in script stack trace!! +try { + eval(str); +} catch (e) { + print(e.stack.replace(/\\/g, '/')); +} + diff --git a/nashorn/test/script/basic/JDK-8030182_2.js.EXPECTED b/nashorn/test/script/basic/JDK-8030182_2.js.EXPECTED new file mode 100644 index 00000000000..772e504d917 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8030182_2.js.EXPECTED @@ -0,0 +1,3 @@ +ReferenceError: "g" is not defined + at <program> (test/script/basic/JDK-8030182_2.js#42:4<eval>@0:-1) + at <program> (test/script/basic/JDK-8030182_2.js:42) diff --git a/langtools/test/tools/javac/varargs/warning/Warn1.java b/nashorn/test/script/basic/JDK-8030809.js similarity index 71% rename from langtools/test/tools/javac/varargs/warning/Warn1.java rename to nashorn/test/script/basic/JDK-8030809.js index 8ffaabfbe11..01c7687c08a 100644 --- a/langtools/test/tools/javac/varargs/warning/Warn1.java +++ b/nashorn/test/script/basic/JDK-8030809.js @@ -1,42 +1,41 @@ /* - * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. - * + * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). - * + * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * + * * Please 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 5035307 - * @summary fixed-arity warning given too often - * @author gafter +/** + * JDK-8030809: Anonymous functions should not be shown with internal names in script stack trace * - * @compile -Werror -source 1.4 -Xlint:-options Warn1.java + * @test + * @run */ -package varargs.warning.warn1; - -import java.util.List; -import java.util.Arrays; - -class Warn1 { - void f(String[] args) { - List l = java.util.Arrays.asList(args); - } +function func() { + (function() { + throw new Error(); + })(); +} + +try { + func(); +} catch (e) { + print(e.stack.replace(/\\/g, '/')); } diff --git a/nashorn/test/script/basic/JDK-8030809.js.EXPECTED b/nashorn/test/script/basic/JDK-8030809.js.EXPECTED new file mode 100644 index 00000000000..6d2ee69b12a --- /dev/null +++ b/nashorn/test/script/basic/JDK-8030809.js.EXPECTED @@ -0,0 +1,4 @@ +Error + at <anonymous> (test/script/basic/JDK-8030809.js:33) + at func (test/script/basic/JDK-8030809.js:32) + at <program> (test/script/basic/JDK-8030809.js:38) diff --git a/nashorn/test/script/basic/JDK-8031317.js b/nashorn/test/script/basic/JDK-8031317.js new file mode 100644 index 00000000000..240a63377a4 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8031317.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * JDK-8031317: SyntaxError when property setter has no parameter + * + * @test + * @run + */ + +var obj = { + get toto() { + print("in getter for 'toto'"); + }, + set toto() { + print("in setter for 'toto'"); + } +} + +obj.toto; +obj.toto = 344; diff --git a/nashorn/test/script/basic/JDK-8031317.js.EXPECTED b/nashorn/test/script/basic/JDK-8031317.js.EXPECTED new file mode 100644 index 00000000000..dda72eae985 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8031317.js.EXPECTED @@ -0,0 +1,2 @@ +in getter for 'toto' +in setter for 'toto' diff --git a/nashorn/test/script/basic/JDK-8031359.js b/nashorn/test/script/basic/JDK-8031359.js new file mode 100644 index 00000000000..278fd7d2f32 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8031359.js @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * JDK-8031359: Invocable.getInterface() works incorrectly if interface has default methods + * + * @test + * @run + */ + +var func = new java.util.function.Function() { + apply: function(arg) { + print("func called with " + arg); + return arg.toUpperCase(); + } +}; + +// Function.andThen is a default method +func.andThen(func)("hello"); + +// Function.compose is another default method +func.compose(new java.util.function.Function() { + apply: function(arg) { + print("compose called with " + arg); + return arg.charAt(0); + } +})("hello"); + +var func2 = new java.util.function.Function() { + apply: function(arg) { + print("I am func2: " + arg); + return arg; + }, + + andThen: function(func) { + print("This is my andThen!"); + return func; + } +}; + +func2.apply("hello"); +func2.andThen(func); diff --git a/nashorn/test/script/basic/JDK-8031359.js.EXPECTED b/nashorn/test/script/basic/JDK-8031359.js.EXPECTED new file mode 100644 index 00000000000..3fb72f1bc33 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8031359.js.EXPECTED @@ -0,0 +1,6 @@ +func called with hello +func called with HELLO +compose called with hello +func called with h +I am func2: hello +This is my andThen! diff --git a/nashorn/test/script/basic/JDK-8031715.js b/nashorn/test/script/basic/JDK-8031715.js new file mode 100644 index 00000000000..19994f51f58 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8031715.js @@ -0,0 +1,49 @@ +/* + * 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. + */ + +/** + * JDK-8031715: Indexed access to java package not working + * @test + * @run + */ + +print(java["net"]); +print(java["net"]["URL"]); +print(java["net"].URL); +print(java.net["URL"]); + +var is = "InputStream"; +var io = "io"; + +print(java.io[is]); +print(java[io]); +print(java[io][is]); + +var ji = new JavaImporter(java.util, java.io); +print(ji["InputStream"]); +print(ji['Vector']); + +var hash = "Hashtable"; +var printStream = "PrintStream"; +print(ji[hash]); +print(ji[printStream]); diff --git a/nashorn/test/script/basic/JDK-8031715.js.EXPECTED b/nashorn/test/script/basic/JDK-8031715.js.EXPECTED new file mode 100644 index 00000000000..1a71de34110 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8031715.js.EXPECTED @@ -0,0 +1,11 @@ +[JavaPackage java.net] +[JavaClass java.net.URL] +[JavaClass java.net.URL] +[JavaClass java.net.URL] +[JavaClass java.io.InputStream] +[JavaPackage java.io] +[JavaClass java.io.InputStream] +[JavaClass java.io.InputStream] +[JavaClass java.util.Vector] +[JavaClass java.util.Hashtable] +[JavaClass java.io.PrintStream] diff --git a/nashorn/test/script/basic/JDK-8031983.js b/nashorn/test/script/basic/JDK-8031983.js new file mode 100644 index 00000000000..f0bfca13164 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8031983.js @@ -0,0 +1,55 @@ +/* + * 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. + */ + +/** + * JDK-8031983: Error objects should capture stack at the constructor + * + * @test + * @run + */ + +var e = new Error(); +print("hello"); + +try { + throw e; +} catch (e) { + print(e.lineNumber); + print(e.stack.replace(/\\/g, '/')); +} + +Error.captureStackTrace(e); +try { + throw e; +} catch (e) { + print(e.lineNumber); + print(e.stack.replace(/\\/g, '/')); +} + +var obj = {}; +Error.captureStackTrace(obj); +try { + throw obj; +} catch (e) { + print(e.stack.replace(/\\/g, '/')); +} diff --git a/nashorn/test/script/basic/JDK-8031983.js.EXPECTED b/nashorn/test/script/basic/JDK-8031983.js.EXPECTED new file mode 100644 index 00000000000..9d62db31954 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8031983.js.EXPECTED @@ -0,0 +1,9 @@ +hello +35 +Error + at <program> (test/script/basic/JDK-8031983.js:31) +43 +Error + at <program> (test/script/basic/JDK-8031983.js:41) +[object Object] + at <program> (test/script/basic/JDK-8031983.js:50) diff --git a/nashorn/test/script/basic/JDK-8032004.js b/nashorn/test/script/basic/JDK-8032004.js new file mode 100644 index 00000000000..2995566c50a --- /dev/null +++ b/nashorn/test/script/basic/JDK-8032004.js @@ -0,0 +1,43 @@ +/* + * 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. + */ + +/** + * JDK-8032004: instance property "message" of Error objects should be non-enumerable + * + * @test + * @run + */ + +function check(obj) { + if (obj.propertyIsEnumerable("message")) { + fail(obj.name + " object's message property is enumerable!"); + } +} + +check(new Error("test")); +check(new EvalError("test")); +check(new RangeError("test")); +check(new ReferenceError("test")); +check(new SyntaxError("test")); +check(new TypeError("test")); +check(new URIError("test")); diff --git a/nashorn/test/script/basic/JDK-8032068.js b/nashorn/test/script/basic/JDK-8032068.js new file mode 100644 index 00000000000..570789d737d --- /dev/null +++ b/nashorn/test/script/basic/JDK-8032068.js @@ -0,0 +1,56 @@ +/* + * 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. + */ + +/** + * JDK-8032068: implement @sourceURL and #sourceURL directives. + * + * @test + * @run + */ + + +try { + Function("throw new Error();\n//# sourceURL=foo.js")(); +} catch (e) { + print(e.stack.replace(/\\/g, '/')); +} + +try { + eval("function g() { throw Error('x');\n } g();\n//# sourceURL=bar.js"); +} catch (e) { + print(e.stack.replace(/\\/g, '/')); +} + +// check @sourceURL for compatibility +try { + Function("throw new Error();\n//@ sourceURL=foo2.js")(); +} catch (e) { + print(e.stack.replace(/\\/g, '/')); +} + +try { + eval("function g() { throw Error('x');\n } g();\n//@ sourceURL=bar2.js"); +} catch (e) { + print(e.stack.replace(/\\/g, '/')); +} + diff --git a/nashorn/test/script/basic/JDK-8032068.js.EXPECTED b/nashorn/test/script/basic/JDK-8032068.js.EXPECTED new file mode 100644 index 00000000000..b8891eee077 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8032068.js.EXPECTED @@ -0,0 +1,14 @@ +Error + at <anonymous> (foo.js:2) + at <program> (test/script/basic/JDK-8032068.js:33) +Error: x + at g (bar.js:1) + at <program> (bar.js:2) + at <program> (test/script/basic/JDK-8032068.js:39) +Error + at <anonymous> (foo2.js:2) + at <program> (test/script/basic/JDK-8032068.js:46) +Error: x + at g (bar2.js:1) + at <program> (bar2.js:2) + at <program> (test/script/basic/JDK-8032068.js:52) diff --git a/nashorn/test/script/basic/NASHORN-111.js.EXPECTED b/nashorn/test/script/basic/NASHORN-111.js.EXPECTED index 287f25580c4..0967ef424bc 100644 --- a/nashorn/test/script/basic/NASHORN-111.js.EXPECTED +++ b/nashorn/test/script/basic/NASHORN-111.js.EXPECTED @@ -1 +1 @@ -{"message":"type error"} +{} diff --git a/nashorn/test/script/basic/NASHORN-441.js.EXPECTED b/nashorn/test/script/basic/NASHORN-441.js.EXPECTED index de9ea224be4..c0038426b2b 100644 --- a/nashorn/test/script/basic/NASHORN-441.js.EXPECTED +++ b/nashorn/test/script/basic/NASHORN-441.js.EXPECTED @@ -12,6 +12,6 @@ finally 4 try 5 rethrow 5 finally 5 -Error: try 5 thrown in line 71 +Error: try 5 thrown in line 74 try 6 finally 6 diff --git a/nashorn/test/script/basic/compile-octane-splitter.js.EXPECTED b/nashorn/test/script/basic/compile-octane-splitter.js.EXPECTED index 153524c70b4..9e4920dcfbf 100644 --- a/nashorn/test/script/basic/compile-octane-splitter.js.EXPECTED +++ b/nashorn/test/script/basic/compile-octane-splitter.js.EXPECTED @@ -1,13 +1,14 @@ -Compiled OK: box2d -Compiled OK: code-load -Compiled OK: crypto -Compiled OK: deltablue -Compiled OK: earley-boyer -Compiled OK: gbemu -Compiled OK: mandreel -Compiled OK: navier-stokes -Compiled OK: pdfjs -Compiled OK: raytrace -Compiled OK: regexp -Compiled OK: richards -Compiled OK: splay +[box2d] Compiled OK +[code-load] Compiled OK +[crypto] Compiled OK +[deltablue] Compiled OK +[earley-boyer] Compiled OK +[gbemu] Compiled OK +[mandreel] Compiled OK +[navier-stokes] Compiled OK +[pdfjs] Compiled OK +[raytrace] Compiled OK +[regexp] Compiled OK +[richards] Compiled OK +[splay] Compiled OK +[typescript] Compiled OK diff --git a/nashorn/test/script/basic/compile-octane.js.EXPECTED b/nashorn/test/script/basic/compile-octane.js.EXPECTED index 153524c70b4..9e4920dcfbf 100644 --- a/nashorn/test/script/basic/compile-octane.js.EXPECTED +++ b/nashorn/test/script/basic/compile-octane.js.EXPECTED @@ -1,13 +1,14 @@ -Compiled OK: box2d -Compiled OK: code-load -Compiled OK: crypto -Compiled OK: deltablue -Compiled OK: earley-boyer -Compiled OK: gbemu -Compiled OK: mandreel -Compiled OK: navier-stokes -Compiled OK: pdfjs -Compiled OK: raytrace -Compiled OK: regexp -Compiled OK: richards -Compiled OK: splay +[box2d] Compiled OK +[code-load] Compiled OK +[crypto] Compiled OK +[deltablue] Compiled OK +[earley-boyer] Compiled OK +[gbemu] Compiled OK +[mandreel] Compiled OK +[navier-stokes] Compiled OK +[pdfjs] Compiled OK +[raytrace] Compiled OK +[regexp] Compiled OK +[richards] Compiled OK +[splay] Compiled OK +[typescript] Compiled OK diff --git a/nashorn/test/script/basic/run-octane.js b/nashorn/test/script/basic/run-octane.js index b730040e4c5..840f07b743f 100644 --- a/nashorn/test/script/basic/run-octane.js +++ b/nashorn/test/script/basic/run-octane.js @@ -26,19 +26,22 @@ */ var tests = [ - {file:"box2d",suite:"Box2DBenchmark"}, - {file:"code-load",suite:"CodeLoad"}, - {file:"crypto",suite:"Crypto"}, - {file:"deltablue",suite:"DeltaBlue"}, - {file:"earley-boyer", suite:"EarleyBoyer"}, - {file:"gbemu", suite:"GameboyBenchmark"}, - {file:"mandreel", suite:"MandreelBenchmark"}, - {file:"navier-stokes", suite:"NavierStokes"}, - {file:"pdfjs", suite:"PdfJS"}, - {file:"raytrace", suite:"RayTrace"}, - {file:"regexp", suite:"RegExpSuite"}, - {file:"richards", suite:"Richards"}, - {file:"splay", suite:"Splay"} + {name:"box2d", files:["box2d.js"], suite:"Box2DBenchmark"}, + {name:"code-load", files:["code-load.js"], suite:"CodeLoad"}, + {name:"crypto", files:["crypto.js"], suite:"Crypto"}, + {name:"deltablue", files:["deltablue.js"], suite:"DeltaBlue"}, + {name:"earley-boyer", files:["earley-boyer.js"], suite:"EarleyBoyer"}, + {name:"gbemu", files:["gbemu-part1.js", "gbemu-part2.js"], suite:"GameboyBenchmark"}, + {name:"mandreel", files:["mandreel.js"], suite:"MandreelBenchmark"}, + {name:"navier-stokes", files:["navier-stokes.js"], suite:"NavierStokes"}, + {name:"pdfjs", files:["pdfjs.js"], suite:"PdfJS"}, + {name:"raytrace", files:["raytrace.js"], suite:"RayTrace"}, + {name:"regexp", files:["regexp.js"], suite:"RegExpSuite"}, + {name:"richards", files:["richards.js"], suite:"Richards"}, + {name:"splay", files:["splay.js"], suite:"Splay"}, + {name:"typescript", files:["typescript.js", "typescript-input.js", "typescript-compiler.js"], suite:"typescript"} + //zlib currently disabled - requires read + // {name:"zlib", files:["zlib.js", "zlib-data.js"], suite:"zlib"}, ]; var dir = (typeof(__DIR__) == 'undefined') ? "test/script/basic/" : __DIR__; @@ -58,26 +61,36 @@ function should_compile_only(name) { return (typeof compile_only !== 'undefined') } -function run_one_benchmark(arg, iters) { - var file_name; - var file = (arg.file + ".js").split('/'); +function load_bench(arg) { + + for (var idx = 0; idx < arg.files.length; idx++) { + var f = arg.files[idx]; + var file = f.split('/'); + var file_name = path + file[file.length - 1]; - file_name = path + file[file.length - 1]; - - var compile_and_return = should_compile_only(file_name); - if (compile_and_return) { - if (typeof compile_only === 'undefined') { //for a run, skip compile onlies, don't even compile them - return; + var compile_and_return = should_compile_only(file_name); + if (compile_and_return) { + if (typeof compile_only === 'undefined') { //for a run, skip compile onlies, don't even compile them + return true; + } } + + print_verbose(arg, "loading '" + arg.name + "' [" + f + "]..."); + load(file_name); } - - print_verbose("Loading... " + file_name); - load(file_name); - + if (compile_and_return) { - print_always("Compiled OK: " + arg.file); - return; + print_always(arg, "Compiled OK"); } + return !compile_and_return; + +} + +function run_one_benchmark(arg, iters) { + + if (!load_bench(arg)) { + return; + } var success = true; var current_name; @@ -95,9 +108,13 @@ function run_one_benchmark(arg, iters) { try { for (var x = 0; x < benchmarks.length ; x++) { + //do warmup run + //reset random number generator needed as of octane 9 before each run + BenchmarkSuite.ResetRNG(); benchmarks[x].Setup(); } - print_verbose("Running '" + arg.file + "' for " + iters + " iterations of no less than " + min_time + " seconds (" + runtime + ")"); + BenchmarkSuite.ResetRNG(); + print_verbose(arg, "running '" + arg.name + "' for " + iters + " iterations of no less than " + min_time + " seconds (" + runtime + ")"); var scores = []; @@ -112,6 +129,9 @@ function run_one_benchmark(arg, iters) { do { for (var i = 0; i < len; i++) { benchmarks[i].run(); + //important - no timing here like elapsed = new Date() - start, as in the + //original harness. This will make timing very non-deterministic. + //NOTHING else must live in this loop } ops += len; elapsed = new Date - start; @@ -120,7 +140,7 @@ function run_one_benchmark(arg, iters) { var score = ops / elapsed * 1000 * 60; scores.push(score); var name = it == 0 ? "warmup" : "iteration " + it; - print_verbose("[" + arg.file + "] " + name + " finished " + score.toFixed(0) + " ops/minute"); + print_verbose(arg, name + " finished " + score.toFixed(0) + " ops/minute"); } for (var x = 0; x < benchmarks.length ; x++) { @@ -140,20 +160,20 @@ function run_one_benchmark(arg, iters) { scores = [0]; } - var res = "[" + arg.file + "] " + mean_score.toFixed(0); + var res = mean_score.toFixed(0); if (verbose) { res += " ops/minute (" + min_score.toFixed(0) + "-" + max_score.toFixed(0) + "), warmup=" + scores[0].toFixed(0); } - print_always(res); + print_always(arg, res); } -function print_always(x) { - print(x); +function print_always(arg, x) { + print("[" + arg.name + "] " + x); } -function print_verbose(x) { +function print_verbose(arg, x) { if (verbose) { - print(x); + print_always(arg, x) } } @@ -209,7 +229,7 @@ for (var i = 0; i < args.length; i++) { } else { var found = false; for (j in tests) { - if (tests[j].file === arg) { + if (tests[j].name === arg) { tests_found.push(tests[j]); found = true; break; @@ -221,7 +241,7 @@ for (var i = 0; i < args.length; i++) { if (j != 0) { str += ", "; } - str += "'" + tests[j].file + "'"; + str += "'" + tests[j].name + "'"; } throw str; } diff --git a/langtools/test/tools/doclint/html/AAA.java b/nashorn/test/script/markdown.js similarity index 76% rename from langtools/test/tools/doclint/html/AAA.java rename to nashorn/test/script/markdown.js index 3880733edc9..c2ba57c9b25 100644 --- a/langtools/test/tools/doclint/html/AAA.java +++ b/nashorn/test/script/markdown.js @@ -1,35 +1,38 @@ /* * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. - * + * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). - * + * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * + * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /** - * @test - * @bug 8006728 - * @summary temporarily workaround jtreg problems for doclint tests in othervm + * Base library for Showdown markdown engine Nashorn testing. + * @subtest + * + * */ -// dummy test/class to be compiled before other tests in this directory -// see JDK-8006730 -public class AAA { - public static void main(String... args) { } +load(__DIR__ + "external/showdown/showdown.js"); +var shdwn = Showdown; +var window = { + Showdown: shdwn } +load(__DIR__ + "external/showdown/table.js"); +var converter = new Showdown.converter({extensions: ['table']}); diff --git a/langtools/test/tools/javac/Capture.java b/nashorn/test/script/markdown/anchors-by-reference.js similarity index 61% rename from langtools/test/tools/javac/Capture.java rename to nashorn/test/script/markdown/anchors-by-reference.js index e2baa883e5e..ea284fcd655 100644 --- a/langtools/test/tools/javac/Capture.java +++ b/nashorn/test/script/markdown/anchors-by-reference.js @@ -1,46 +1,33 @@ /* - * Copyright (c) 2002, 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. - * + * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). - * + * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * + * * Please 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 4441338 4994508 - * @summary Captured variable synthetic parameters should be passed before explicit params. - * @author gafter +/** + * Test for Showdown markdown parser work with Nashorn. * - * @compile -source 1.4 -target 1.4 Capture.java - * @run main Capture + * @test + * @run */ -public class Capture { - final int k; - Capture(int n) { - k = n; - } - public static void main(String args[]) { - final int j; - int k1 = new Capture(2 + (j=3)){ - int get () {return k+j;} - }.get(); - if (k1 != 8) throw new Error("k1 = " + k1); - } -} +var input = "\nThis is [an example][id] reference-style link.\nThis is [another] [foo] reference-style link.\nThis is [a third][bar] reference-style link.\nThis is [a fourth][4] reference-style link.\n\n [id]: http://example.com/ \"Optional Title Here\"\n [foo]: http://example.com/ (Optional Title Here)\n [bar]: http://example.com/ (Optional Title Here)\n [4]: <http://example.com/>\n \"Optional Title Here\""; +var output = converter.makeHtml(input); +print(output); diff --git a/nashorn/test/script/markdown/anchors-by-reference.js.EXPECTED b/nashorn/test/script/markdown/anchors-by-reference.js.EXPECTED new file mode 100644 index 00000000000..6115d50e302 --- /dev/null +++ b/nashorn/test/script/markdown/anchors-by-reference.js.EXPECTED @@ -0,0 +1,4 @@ +<p>This is <a href="http://example.com/" title="Optional Title Here">an example</a> reference-style link. +This is <a href="http://example.com/" title="Optional Title Here">another</a> reference-style link. +This is <a href="http://example.com/" title="Optional Title Here">a third</a> reference-style link. +This is <a href="http://example.com/" title="Optional Title Here">a fourth</a> reference-style link.</p> diff --git a/nashorn/test/script/markdown/automatic-anchors.js b/nashorn/test/script/markdown/automatic-anchors.js new file mode 100644 index 00000000000..d34ce77f317 --- /dev/null +++ b/nashorn/test/script/markdown/automatic-anchors.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 for Showdown markdown parser work with Nashorn. + * + * @test + * @run + */ + +var input = "\n<http://example.com/>"; +var output = converter.makeHtml(input); +print(output); diff --git a/nashorn/test/script/markdown/automatic-anchors.js.EXPECTED b/nashorn/test/script/markdown/automatic-anchors.js.EXPECTED new file mode 100644 index 00000000000..6de71a9d275 --- /dev/null +++ b/nashorn/test/script/markdown/automatic-anchors.js.EXPECTED @@ -0,0 +1 @@ +<p><a href="http://example.com/">http://example.com/</a></p> diff --git a/nashorn/test/script/markdown/blockquote-nested-markdown.js b/nashorn/test/script/markdown/blockquote-nested-markdown.js new file mode 100644 index 00000000000..818ea0f32dc --- /dev/null +++ b/nashorn/test/script/markdown/blockquote-nested-markdown.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 for Showdown markdown parser work with Nashorn. + * + * @test + * @run + */ + +var input = "> ## This is a header.\n>\n> 1. This is the first list item.\n> 2. This is the second list item.\n>\n> Here's some example code:\n>\n> return shell_exec(\"echo $input | $markdown_script\");"; +var output = converter.makeHtml(input); +print(output); diff --git a/nashorn/test/script/markdown/blockquote-nested-markdown.js.EXPECTED b/nashorn/test/script/markdown/blockquote-nested-markdown.js.EXPECTED new file mode 100644 index 00000000000..b32199cead1 --- /dev/null +++ b/nashorn/test/script/markdown/blockquote-nested-markdown.js.EXPECTED @@ -0,0 +1,13 @@ +<blockquote> + <h2 id="thisisaheader">This is a header.</h2> + + <ol> + <li>This is the first list item.</li> + <li>This is the second list item.</li> + </ol> + + <p>Here's some example code:</p> + +<pre><code>return shell_exec("echo $input | $markdown_script"); +</code></pre> +</blockquote> diff --git a/nashorn/test/script/markdown/blockquote.js b/nashorn/test/script/markdown/blockquote.js new file mode 100644 index 00000000000..7167a911a05 --- /dev/null +++ b/nashorn/test/script/markdown/blockquote.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 for Showdown markdown parser work with Nashorn. + * + * @test + * @run + */ + +var input = " \n > This is a multi line blockquote test\n >\n > With more than one line."; +var output = converter.makeHtml(input); +print(output); diff --git a/nashorn/test/script/markdown/blockquote.js.EXPECTED b/nashorn/test/script/markdown/blockquote.js.EXPECTED new file mode 100644 index 00000000000..c4956bbe5cf --- /dev/null +++ b/nashorn/test/script/markdown/blockquote.js.EXPECTED @@ -0,0 +1,5 @@ +<blockquote> + <p>This is a multi line blockquote test</p> + + <p>With more than one line.</p> +</blockquote> diff --git a/nashorn/test/script/markdown/code-block-html-escape.js b/nashorn/test/script/markdown/code-block-html-escape.js new file mode 100644 index 00000000000..dff9329f38f --- /dev/null +++ b/nashorn/test/script/markdown/code-block-html-escape.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 for Showdown markdown parser work with Nashorn. + * + * @test + * @run + */ + +var input = "\nThis is some HTML:\n\n <h1>Heading</h1>"; +var output = converter.makeHtml(input); +print(output); diff --git a/nashorn/test/script/markdown/code-block-html-escape.js.EXPECTED b/nashorn/test/script/markdown/code-block-html-escape.js.EXPECTED new file mode 100644 index 00000000000..028f874db70 --- /dev/null +++ b/nashorn/test/script/markdown/code-block-html-escape.js.EXPECTED @@ -0,0 +1,4 @@ +<p>This is some HTML:</p> + +<pre><code><h1>Heading</h1> +</code></pre> diff --git a/nashorn/test/script/markdown/code-block.js b/nashorn/test/script/markdown/code-block.js new file mode 100644 index 00000000000..e4c7413aaf3 --- /dev/null +++ b/nashorn/test/script/markdown/code-block.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 for Showdown markdown parser work with Nashorn. + * + * @test + * @run + */ + +var input = "\nThis is a normal paragraph:\n\n This is a code block."; +var output = converter.makeHtml(input); +print(output); diff --git a/nashorn/test/script/markdown/code-block.js.EXPECTED b/nashorn/test/script/markdown/code-block.js.EXPECTED new file mode 100644 index 00000000000..3e56099735f --- /dev/null +++ b/nashorn/test/script/markdown/code-block.js.EXPECTED @@ -0,0 +1,4 @@ +<p>This is a normal paragraph:</p> + +<pre><code>This is a code block. +</code></pre> diff --git a/nashorn/test/script/markdown/doubline-list.js b/nashorn/test/script/markdown/doubline-list.js new file mode 100644 index 00000000000..4a5736c9472 --- /dev/null +++ b/nashorn/test/script/markdown/doubline-list.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 for Showdown markdown parser work with Nashorn. + * + * @test + * @run + */ + +var input = "\n * Bird\n\n * Magic"; +var output = converter.makeHtml(input); +print(output); diff --git a/nashorn/test/script/markdown/doubline-list.js.EXPECTED b/nashorn/test/script/markdown/doubline-list.js.EXPECTED new file mode 100644 index 00000000000..1065a44547e --- /dev/null +++ b/nashorn/test/script/markdown/doubline-list.js.EXPECTED @@ -0,0 +1,4 @@ +<ul> +<li><p>Bird</p></li> +<li><p>Magic</p></li> +</ul> diff --git a/nashorn/test/script/markdown/emphasis.js b/nashorn/test/script/markdown/emphasis.js new file mode 100644 index 00000000000..b9db46cdda4 --- /dev/null +++ b/nashorn/test/script/markdown/emphasis.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 for Showdown markdown parser work with Nashorn. + * + * @test + * @run + */ + +var input = "\n*important*\n\n_important_\n\nthis mid*important*sentence"; +var output = converter.makeHtml(input); +print(output); diff --git a/nashorn/test/script/markdown/emphasis.js.EXPECTED b/nashorn/test/script/markdown/emphasis.js.EXPECTED new file mode 100644 index 00000000000..a1fda4ab651 --- /dev/null +++ b/nashorn/test/script/markdown/emphasis.js.EXPECTED @@ -0,0 +1,5 @@ +<p><em>important</em></p> + +<p><em>important</em></p> + +<p>this mid<em>important</em>sentence</p> diff --git a/nashorn/test/script/markdown/escaped-number-period.js b/nashorn/test/script/markdown/escaped-number-period.js new file mode 100644 index 00000000000..5f477449af1 --- /dev/null +++ b/nashorn/test/script/markdown/escaped-number-period.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 for Showdown markdown parser work with Nashorn. + * + * @test + * @run + */ + +var input = "It happened in 1986\. What a great season."; +var output = converter.makeHtml(input); +print(output); diff --git a/nashorn/test/script/markdown/escaped-number-period.js.EXPECTED b/nashorn/test/script/markdown/escaped-number-period.js.EXPECTED new file mode 100644 index 00000000000..0ea83bac1bd --- /dev/null +++ b/nashorn/test/script/markdown/escaped-number-period.js.EXPECTED @@ -0,0 +1 @@ +<p>It happened in 1986. What a great season.</p> diff --git a/nashorn/test/script/markdown/escaping.js b/nashorn/test/script/markdown/escaping.js new file mode 100644 index 00000000000..077df7ecfcb --- /dev/null +++ b/nashorn/test/script/markdown/escaping.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 for Showdown markdown parser work with Nashorn. + * + * @test + * @run + */ + +var input = "\nThese should all be escaped:\n\n\\\n\n\`\n\n\*\n\n\_\n\n\{\n\n\}\n\n\[\n\n\]\n\n\(\n\n\)\n\n\#\n\n\+\n\n\-\n\n\.\n\n\!"; +var output = converter.makeHtml(input); +print(output); diff --git a/nashorn/test/script/markdown/escaping.js.EXPECTED b/nashorn/test/script/markdown/escaping.js.EXPECTED new file mode 100644 index 00000000000..1ac6a291997 --- /dev/null +++ b/nashorn/test/script/markdown/escaping.js.EXPECTED @@ -0,0 +1,31 @@ +<p>These should all be escaped:</p> + +<p>\</p> + +<p>`</p> + +<p>*</p> + +<p>_</p> + +<p>{</p> + +<p>}</p> + +<p>[</p> + +<p>]</p> + +<p>(</p> + +<p>)</p> + +<p>#</p> + +<p>+</p> + +<p>-</p> + +<p>.</p> + +<p>!</p> diff --git a/nashorn/test/script/markdown/github-style-at-start.js b/nashorn/test/script/markdown/github-style-at-start.js new file mode 100644 index 00000000000..0a99bec2b51 --- /dev/null +++ b/nashorn/test/script/markdown/github-style-at-start.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 for Showdown markdown parser work with Nashorn. + * + * @test + * @run + */ + +var input = "```\nfunction MyFunc(a) {\n // ...\n}\n```\n\nThat is some code!"; +var output = converter.makeHtml(input); +print(output); diff --git a/nashorn/test/script/markdown/github-style-at-start.js.EXPECTED b/nashorn/test/script/markdown/github-style-at-start.js.EXPECTED new file mode 100644 index 00000000000..4f119a7697a --- /dev/null +++ b/nashorn/test/script/markdown/github-style-at-start.js.EXPECTED @@ -0,0 +1,6 @@ +<pre><code>function MyFunc(a) { + // ... +} +</code></pre> + +<p>That is some code!</p> diff --git a/nashorn/test/script/markdown/github-style-codeblock.js b/nashorn/test/script/markdown/github-style-codeblock.js new file mode 100644 index 00000000000..32341892605 --- /dev/null +++ b/nashorn/test/script/markdown/github-style-codeblock.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 for Showdown markdown parser work with Nashorn. + * + * @test + * @run + */ + +var input = "\nDefine a function in javascript:\n\n```\nfunction MyFunc(a) {\n var s = '`';\n}\n```\n\nAnd some HTML\n\n```html\n<div>HTML!</div>\n```"; +var output = converter.makeHtml(input); +print(output); diff --git a/nashorn/test/script/markdown/github-style-codeblock.js.EXPECTED b/nashorn/test/script/markdown/github-style-codeblock.js.EXPECTED new file mode 100644 index 00000000000..5daca2f94ae --- /dev/null +++ b/nashorn/test/script/markdown/github-style-codeblock.js.EXPECTED @@ -0,0 +1,11 @@ +<p>Define a function in javascript:</p> + +<pre><code>function MyFunc(a) { + var s = '`'; +} +</code></pre> + +<p>And some HTML</p> + +<pre><code class="html"><div>HTML!</div> +</code></pre> diff --git a/nashorn/test/script/markdown/github-style-linebreaks.js b/nashorn/test/script/markdown/github-style-linebreaks.js new file mode 100644 index 00000000000..c912bee06f9 --- /dev/null +++ b/nashorn/test/script/markdown/github-style-linebreaks.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 for Showdown markdown parser work with Nashorn. + * + * @test + * @run + */ + +var input = "```\ncode can go here\nthis is rendered on a second line\n```"; +var output = converter.makeHtml(input); +print(output); diff --git a/nashorn/test/script/markdown/github-style-linebreaks.js.EXPECTED b/nashorn/test/script/markdown/github-style-linebreaks.js.EXPECTED new file mode 100644 index 00000000000..276dbf03cb8 --- /dev/null +++ b/nashorn/test/script/markdown/github-style-linebreaks.js.EXPECTED @@ -0,0 +1,3 @@ +<pre><code>code can go here +this is rendered on a second line +</code></pre> diff --git a/nashorn/test/script/markdown/h1-with-double-hash.js b/nashorn/test/script/markdown/h1-with-double-hash.js new file mode 100644 index 00000000000..bd965702922 --- /dev/null +++ b/nashorn/test/script/markdown/h1-with-double-hash.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 for Showdown markdown parser work with Nashorn. + * + * @test + * @run + */ + +var input = "# This is an H1 #"; +var output = converter.makeHtml(input); +print(output); diff --git a/nashorn/test/script/markdown/h1-with-double-hash.js.EXPECTED b/nashorn/test/script/markdown/h1-with-double-hash.js.EXPECTED new file mode 100644 index 00000000000..ab5b5555dd5 --- /dev/null +++ b/nashorn/test/script/markdown/h1-with-double-hash.js.EXPECTED @@ -0,0 +1 @@ +<h1 id="thisisanh1">This is an H1</h1> diff --git a/nashorn/test/script/markdown/h1-with-equals.js b/nashorn/test/script/markdown/h1-with-equals.js new file mode 100644 index 00000000000..54ee9628f50 --- /dev/null +++ b/nashorn/test/script/markdown/h1-with-equals.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 for Showdown markdown parser work with Nashorn. + * + * @test + * @run + */ + +var input = "This is an H1\n============="; +var output = converter.makeHtml(input); +print(output); diff --git a/nashorn/test/script/markdown/h1-with-equals.js.EXPECTED b/nashorn/test/script/markdown/h1-with-equals.js.EXPECTED new file mode 100644 index 00000000000..ab5b5555dd5 --- /dev/null +++ b/nashorn/test/script/markdown/h1-with-equals.js.EXPECTED @@ -0,0 +1 @@ +<h1 id="thisisanh1">This is an H1</h1> diff --git a/nashorn/test/script/markdown/h1-with-single-hash.js b/nashorn/test/script/markdown/h1-with-single-hash.js new file mode 100644 index 00000000000..3559c22f615 --- /dev/null +++ b/nashorn/test/script/markdown/h1-with-single-hash.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 for Showdown markdown parser work with Nashorn. + * + * @test + * @run + */ + +var input = "# This is an H1"; +var output = converter.makeHtml(input); +print(output); diff --git a/nashorn/test/script/markdown/h1-with-single-hash.js.EXPECTED b/nashorn/test/script/markdown/h1-with-single-hash.js.EXPECTED new file mode 100644 index 00000000000..ab5b5555dd5 --- /dev/null +++ b/nashorn/test/script/markdown/h1-with-single-hash.js.EXPECTED @@ -0,0 +1 @@ +<h1 id="thisisanh1">This is an H1</h1> diff --git a/nashorn/test/script/markdown/h2-with-dashes.js b/nashorn/test/script/markdown/h2-with-dashes.js new file mode 100644 index 00000000000..016502f60d4 --- /dev/null +++ b/nashorn/test/script/markdown/h2-with-dashes.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 for Showdown markdown parser work with Nashorn. + * + * @test + * @run + */ + +var input = "This is an H2\n-------------"; +var output = converter.makeHtml(input); +print(output); diff --git a/nashorn/test/script/markdown/h2-with-dashes.js.EXPECTED b/nashorn/test/script/markdown/h2-with-dashes.js.EXPECTED new file mode 100644 index 00000000000..375a0d06ba8 --- /dev/null +++ b/nashorn/test/script/markdown/h2-with-dashes.js.EXPECTED @@ -0,0 +1 @@ +<h2 id="thisisanh2">This is an H2</h2> diff --git a/nashorn/test/script/markdown/h2-with-double-hash.js b/nashorn/test/script/markdown/h2-with-double-hash.js new file mode 100644 index 00000000000..246c1701f5d --- /dev/null +++ b/nashorn/test/script/markdown/h2-with-double-hash.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 for Showdown markdown parser work with Nashorn. + * + * @test + * @run + */ + +var input = "## This is an H2 ##"; +var output = converter.makeHtml(input); +print(output); diff --git a/nashorn/test/script/markdown/h2-with-double-hash.js.EXPECTED b/nashorn/test/script/markdown/h2-with-double-hash.js.EXPECTED new file mode 100644 index 00000000000..375a0d06ba8 --- /dev/null +++ b/nashorn/test/script/markdown/h2-with-double-hash.js.EXPECTED @@ -0,0 +1 @@ +<h2 id="thisisanh2">This is an H2</h2> diff --git a/nashorn/test/script/markdown/h2-with-single-hash.js b/nashorn/test/script/markdown/h2-with-single-hash.js new file mode 100644 index 00000000000..d1f7f000c44 --- /dev/null +++ b/nashorn/test/script/markdown/h2-with-single-hash.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 for Showdown markdown parser work with Nashorn. + * + * @test + * @run + */ + +var input = "## This is an H2"; +var output = converter.makeHtml(input); +print(output); diff --git a/nashorn/test/script/markdown/h2-with-single-hash.js.EXPECTED b/nashorn/test/script/markdown/h2-with-single-hash.js.EXPECTED new file mode 100644 index 00000000000..375a0d06ba8 --- /dev/null +++ b/nashorn/test/script/markdown/h2-with-single-hash.js.EXPECTED @@ -0,0 +1 @@ +<h2 id="thisisanh2">This is an H2</h2> diff --git a/nashorn/test/script/markdown/h3-with-double-hash.js b/nashorn/test/script/markdown/h3-with-double-hash.js new file mode 100644 index 00000000000..e60e00988cb --- /dev/null +++ b/nashorn/test/script/markdown/h3-with-double-hash.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 for Showdown markdown parser work with Nashorn. + * + * @test + * @run + */ + +var input = "### This is an H3 ###"; +var output = converter.makeHtml(input); +print(output); diff --git a/nashorn/test/script/markdown/h3-with-double-hash.js.EXPECTED b/nashorn/test/script/markdown/h3-with-double-hash.js.EXPECTED new file mode 100644 index 00000000000..13f8c9e7a59 --- /dev/null +++ b/nashorn/test/script/markdown/h3-with-double-hash.js.EXPECTED @@ -0,0 +1 @@ +<h3 id="thisisanh3">This is an H3</h3> diff --git a/nashorn/test/script/markdown/h3-with-single-hash.js b/nashorn/test/script/markdown/h3-with-single-hash.js new file mode 100644 index 00000000000..6af497079d0 --- /dev/null +++ b/nashorn/test/script/markdown/h3-with-single-hash.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 for Showdown markdown parser work with Nashorn. + * + * @test + * @run + */ + +var input = "### This is an H3"; +var output = converter.makeHtml(input); +print(output); diff --git a/nashorn/test/script/markdown/h3-with-single-hash.js.EXPECTED b/nashorn/test/script/markdown/h3-with-single-hash.js.EXPECTED new file mode 100644 index 00000000000..13f8c9e7a59 --- /dev/null +++ b/nashorn/test/script/markdown/h3-with-single-hash.js.EXPECTED @@ -0,0 +1 @@ +<h3 id="thisisanh3">This is an H3</h3> diff --git a/nashorn/test/script/markdown/h4-with-single-hash.js b/nashorn/test/script/markdown/h4-with-single-hash.js new file mode 100644 index 00000000000..01bc08e0a58 --- /dev/null +++ b/nashorn/test/script/markdown/h4-with-single-hash.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 for Showdown markdown parser work with Nashorn. + * + * @test + * @run + */ + +var input = "#### This is an H4"; +var output = converter.makeHtml(input); +print(output); diff --git a/nashorn/test/script/markdown/h4-with-single-hash.js.EXPECTED b/nashorn/test/script/markdown/h4-with-single-hash.js.EXPECTED new file mode 100644 index 00000000000..165b4ef2f46 --- /dev/null +++ b/nashorn/test/script/markdown/h4-with-single-hash.js.EXPECTED @@ -0,0 +1 @@ +<h4 id="thisisanh4">This is an H4</h4> diff --git a/nashorn/test/script/markdown/h5-with-single-hash.js b/nashorn/test/script/markdown/h5-with-single-hash.js new file mode 100644 index 00000000000..5fe8638bf8b --- /dev/null +++ b/nashorn/test/script/markdown/h5-with-single-hash.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 for Showdown markdown parser work with Nashorn. + * + * @test + * @run + */ + +var input = "##### This is an H5"; +var output = converter.makeHtml(input); +print(output); diff --git a/nashorn/test/script/markdown/h5-with-single-hash.js.EXPECTED b/nashorn/test/script/markdown/h5-with-single-hash.js.EXPECTED new file mode 100644 index 00000000000..28eac14834e --- /dev/null +++ b/nashorn/test/script/markdown/h5-with-single-hash.js.EXPECTED @@ -0,0 +1 @@ +<h5 id="thisisanh5">This is an H5</h5> diff --git a/nashorn/test/script/markdown/h6-with-single-hash.js b/nashorn/test/script/markdown/h6-with-single-hash.js new file mode 100644 index 00000000000..b1f20f5c8fe --- /dev/null +++ b/nashorn/test/script/markdown/h6-with-single-hash.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 for Showdown markdown parser work with Nashorn. + * + * @test + * @run + */ + +var input = "###### This is an H6"; +var output = converter.makeHtml(input); +print(output); diff --git a/nashorn/test/script/markdown/h6-with-single-hash.js.EXPECTED b/nashorn/test/script/markdown/h6-with-single-hash.js.EXPECTED new file mode 100644 index 00000000000..47574cc5b92 --- /dev/null +++ b/nashorn/test/script/markdown/h6-with-single-hash.js.EXPECTED @@ -0,0 +1 @@ +<h6 id="thisisanh6">This is an H6</h6> diff --git a/nashorn/test/script/markdown/horizontal-rules.js b/nashorn/test/script/markdown/horizontal-rules.js new file mode 100644 index 00000000000..af2cabb91a2 --- /dev/null +++ b/nashorn/test/script/markdown/horizontal-rules.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 for Showdown markdown parser work with Nashorn. + * + * @test + * @run + */ + +var input = "\n* * *\n\n***\n\n*****\n\n- - -\n\n---------------------------------------\n"; +var output = converter.makeHtml(input); +print(output); diff --git a/nashorn/test/script/markdown/horizontal-rules.js.EXPECTED b/nashorn/test/script/markdown/horizontal-rules.js.EXPECTED new file mode 100644 index 00000000000..aaef23eb8bb --- /dev/null +++ b/nashorn/test/script/markdown/horizontal-rules.js.EXPECTED @@ -0,0 +1,9 @@ +<hr /> + +<hr /> + +<hr /> + +<hr /> + +<hr /> diff --git a/nashorn/test/script/markdown/html5-strutural-tags.js b/nashorn/test/script/markdown/html5-strutural-tags.js new file mode 100644 index 00000000000..3bc4aad54bf --- /dev/null +++ b/nashorn/test/script/markdown/html5-strutural-tags.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 for Showdown markdown parser work with Nashorn. + * + * @test + * @run + */ + +var input = "\nThese HTML5 tags should pass through just fine.\n\n<section>hello</section>\n<header>head</header>\n<footer>footsies</footer>\n<nav>navigation</nav>\n<article>read me</article>\n<aside>ignore me</aside>\n<article>read\nme</article>\n<aside>\nignore me\n</aside>\n\nthe end"; +var output = converter.makeHtml(input); +print(output); diff --git a/nashorn/test/script/markdown/html5-strutural-tags.js.EXPECTED b/nashorn/test/script/markdown/html5-strutural-tags.js.EXPECTED new file mode 100644 index 00000000000..528731f56ef --- /dev/null +++ b/nashorn/test/script/markdown/html5-strutural-tags.js.EXPECTED @@ -0,0 +1,22 @@ +<p>These HTML5 tags should pass through just fine.</p> + +<section>hello</section> + +<header>head</header> + +<footer>footsies</footer> + +<nav>navigation</nav> + +<article>read me</article> + +<aside>ignore me</aside> + +<article>read +me</article> + +<aside> +ignore me +</aside> + +<p>the end</p> diff --git a/nashorn/test/script/markdown/images.js b/nashorn/test/script/markdown/images.js new file mode 100644 index 00000000000..da2a16a29ff --- /dev/null +++ b/nashorn/test/script/markdown/images.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 for Showdown markdown parser work with Nashorn. + * + * @test + * @run + */ + +var input = "\n![Alt text](/path/to/img.jpg)\n\n![Alt text](/path/to/img.jpg \"Optional title\")\n\n![Alt text][id]\n\n [id]: url/to/image \"Optional title attribute\""; +var output = converter.makeHtml(input); +print(output); diff --git a/nashorn/test/script/markdown/images.js.EXPECTED b/nashorn/test/script/markdown/images.js.EXPECTED new file mode 100644 index 00000000000..7df585521d9 --- /dev/null +++ b/nashorn/test/script/markdown/images.js.EXPECTED @@ -0,0 +1,5 @@ +<p><img src="/path/to/img.jpg" alt="Alt text" title="" /></p> + +<p><img src="/path/to/img.jpg" alt="Alt text" title="Optional title" /></p> + +<p><img src="url/to/image" alt="Alt text" title="Optional title attribute" /></p> diff --git a/nashorn/test/script/markdown/implicit-anchors.js b/nashorn/test/script/markdown/implicit-anchors.js new file mode 100644 index 00000000000..ba627fb9cb4 --- /dev/null +++ b/nashorn/test/script/markdown/implicit-anchors.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 for Showdown markdown parser work with Nashorn. + * + * @test + * @run + */ + +var input = "\nSearch the web at [Google][] or [Daring Fireball][].\n\n [Google]: http://google.com/\n [Daring Fireball]: http://daringfireball.net/"; +var output = converter.makeHtml(input); +print(output); diff --git a/nashorn/test/script/markdown/implicit-anchors.js.EXPECTED b/nashorn/test/script/markdown/implicit-anchors.js.EXPECTED new file mode 100644 index 00000000000..01e62d9af84 --- /dev/null +++ b/nashorn/test/script/markdown/implicit-anchors.js.EXPECTED @@ -0,0 +1 @@ +<p>Search the web at <a href="http://google.com/">Google</a> or <a href="http://daringfireball.net/">Daring Fireball</a>.</p> diff --git a/nashorn/test/script/markdown/inline-anchors.js b/nashorn/test/script/markdown/inline-anchors.js new file mode 100644 index 00000000000..90fe181271c --- /dev/null +++ b/nashorn/test/script/markdown/inline-anchors.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 for Showdown markdown parser work with Nashorn. + * + * @test + * @run + */ + +var input = "\nThis is [an example](http://example.com/ \"Title\") inline link.\n\n[This link](http://example.net/) has no title attribute."; +var output = converter.makeHtml(input); +print(output); diff --git a/nashorn/test/script/markdown/inline-anchors.js.EXPECTED b/nashorn/test/script/markdown/inline-anchors.js.EXPECTED new file mode 100644 index 00000000000..52f90ed319d --- /dev/null +++ b/nashorn/test/script/markdown/inline-anchors.js.EXPECTED @@ -0,0 +1,3 @@ +<p>This is <a href="http://example.com/" title="Title">an example</a> inline link.</p> + +<p><a href="http://example.net/">This link</a> has no title attribute.</p> diff --git a/nashorn/test/script/markdown/inline-code.js b/nashorn/test/script/markdown/inline-code.js new file mode 100644 index 00000000000..6ab4f4f657e --- /dev/null +++ b/nashorn/test/script/markdown/inline-code.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 for Showdown markdown parser work with Nashorn. + * + * @test + * @run + */ + +var input = "\nCreate a new `function`.\n\nUse the backtick in MySQL syntax ``SELECT `column` FROM whatever``.\n\nA single backtick in a code span: `` ` ``\n\nA backtick-delimited string in a code span: `` `foo` ``\n\nPlease don't use any `<blink>` tags.\n\n`—` is the decimal-encoded equivalent of `—`."; +var output = converter.makeHtml(input); +print(output); diff --git a/nashorn/test/script/markdown/inline-code.js.EXPECTED b/nashorn/test/script/markdown/inline-code.js.EXPECTED new file mode 100644 index 00000000000..ebb7fdc0dca --- /dev/null +++ b/nashorn/test/script/markdown/inline-code.js.EXPECTED @@ -0,0 +1,11 @@ +<p>Create a new <code>function</code>.</p> + +<p>Use the backtick in MySQL syntax <code>SELECT `column` FROM whatever</code>.</p> + +<p>A single backtick in a code span: <code>`</code></p> + +<p>A backtick-delimited string in a code span: <code>`foo`</code></p> + +<p>Please don't use any <code><blink></code> tags.</p> + +<p><code>&#8212;</code> is the decimal-encoded equivalent of <code>&mdash;</code>.</p> diff --git a/nashorn/test/script/markdown/inline-style-tag.js b/nashorn/test/script/markdown/inline-style-tag.js new file mode 100644 index 00000000000..a97ba64a5e5 --- /dev/null +++ b/nashorn/test/script/markdown/inline-style-tag.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 for Showdown markdown parser work with Nashorn. + * + * @test + * @run + */ + +var input = "\n<style>\n p { line-height: 20px; }\n</style>\n\nAn exciting sentence."; +var output = converter.makeHtml(input); +print(output); diff --git a/nashorn/test/script/markdown/inline-style-tag.js.EXPECTED b/nashorn/test/script/markdown/inline-style-tag.js.EXPECTED new file mode 100644 index 00000000000..1006aa8fac4 --- /dev/null +++ b/nashorn/test/script/markdown/inline-style-tag.js.EXPECTED @@ -0,0 +1,5 @@ +<style> + p { line-height: 20px; } +</style> + +<p>An exciting sentence.</p> diff --git a/nashorn/test/script/markdown/lazy-blockquote.js b/nashorn/test/script/markdown/lazy-blockquote.js new file mode 100644 index 00000000000..274121658f2 --- /dev/null +++ b/nashorn/test/script/markdown/lazy-blockquote.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 for Showdown markdown parser work with Nashorn. + * + * @test + * @run + */ + +var input = "\n > This is a multi line blockquote test\n\n > With more than one line."; +var output = converter.makeHtml(input); +print(output); diff --git a/nashorn/test/script/markdown/lazy-blockquote.js.EXPECTED b/nashorn/test/script/markdown/lazy-blockquote.js.EXPECTED new file mode 100644 index 00000000000..c4956bbe5cf --- /dev/null +++ b/nashorn/test/script/markdown/lazy-blockquote.js.EXPECTED @@ -0,0 +1,5 @@ +<blockquote> + <p>This is a multi line blockquote test</p> + + <p>With more than one line.</p> +</blockquote> diff --git a/nashorn/test/script/markdown/list-with-blockquote.js b/nashorn/test/script/markdown/list-with-blockquote.js new file mode 100644 index 00000000000..fa0044e616a --- /dev/null +++ b/nashorn/test/script/markdown/list-with-blockquote.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 for Showdown markdown parser work with Nashorn. + * + * @test + * @run + */ + +var input = "* A list item with a blockquote:\n\n > This is a blockquote\n > inside a list item."; +var output = converter.makeHtml(input); +print(output); diff --git a/nashorn/test/script/markdown/list-with-blockquote.js.EXPECTED b/nashorn/test/script/markdown/list-with-blockquote.js.EXPECTED new file mode 100644 index 00000000000..7f18f5c11aa --- /dev/null +++ b/nashorn/test/script/markdown/list-with-blockquote.js.EXPECTED @@ -0,0 +1,8 @@ +<ul> +<li><p>A list item with a blockquote:</p> + +<blockquote> + <p>This is a blockquote + inside a list item.</p> +</blockquote></li> +</ul> diff --git a/nashorn/test/script/markdown/list-with-code.js b/nashorn/test/script/markdown/list-with-code.js new file mode 100644 index 00000000000..61cc1e9befb --- /dev/null +++ b/nashorn/test/script/markdown/list-with-code.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 for Showdown markdown parser work with Nashorn. + * + * @test + * @run + */ + +var input = "* A list item with code:\n\n alert('Hello world!');"; +var output = converter.makeHtml(input); +print(output); diff --git a/nashorn/test/script/markdown/list-with-code.js.EXPECTED b/nashorn/test/script/markdown/list-with-code.js.EXPECTED new file mode 100644 index 00000000000..566fdae96a8 --- /dev/null +++ b/nashorn/test/script/markdown/list-with-code.js.EXPECTED @@ -0,0 +1,6 @@ +<ul> +<li><p>A list item with code:</p> + +<pre><code>alert('Hello world!'); +</code></pre></li> +</ul> diff --git a/nashorn/test/script/markdown/multi-paragraph-list.js b/nashorn/test/script/markdown/multi-paragraph-list.js new file mode 100644 index 00000000000..23ba37319e0 --- /dev/null +++ b/nashorn/test/script/markdown/multi-paragraph-list.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 for Showdown markdown parser work with Nashorn. + * + * @test + * @run + */ + +var input = "\n 1. This is a major bullet point.\n\n That contains multiple paragraphs.\n\n 2. And another line"; +var output = converter.makeHtml(input); +print(output); diff --git a/nashorn/test/script/markdown/multi-paragraph-list.js.EXPECTED b/nashorn/test/script/markdown/multi-paragraph-list.js.EXPECTED new file mode 100644 index 00000000000..3d751c503f5 --- /dev/null +++ b/nashorn/test/script/markdown/multi-paragraph-list.js.EXPECTED @@ -0,0 +1,6 @@ +<ol> +<li><p>This is a major bullet point.</p> + +<p>That contains multiple paragraphs.</p></li> +<li><p>And another line</p></li> +</ol> diff --git a/nashorn/test/script/markdown/multiline-unordered-list.js b/nashorn/test/script/markdown/multiline-unordered-list.js new file mode 100644 index 00000000000..bb1c2337e4a --- /dev/null +++ b/nashorn/test/script/markdown/multiline-unordered-list.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 for Showdown markdown parser work with Nashorn. + * + * @test + * @run + */ + +var input = "\n - This line spans\n more than one line and is lazy\n - Similar to this line"; +var output = converter.makeHtml(input); +print(output); diff --git a/nashorn/test/script/markdown/multiline-unordered-list.js.EXPECTED b/nashorn/test/script/markdown/multiline-unordered-list.js.EXPECTED new file mode 100644 index 00000000000..fb2a58e0e7d --- /dev/null +++ b/nashorn/test/script/markdown/multiline-unordered-list.js.EXPECTED @@ -0,0 +1,5 @@ +<ul> +<li>This line spans +more than one line and is lazy</li> +<li>Similar to this line</li> +</ul> diff --git a/nashorn/test/script/markdown/nested-blockquote.js b/nashorn/test/script/markdown/nested-blockquote.js new file mode 100644 index 00000000000..e447494a58e --- /dev/null +++ b/nashorn/test/script/markdown/nested-blockquote.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 for Showdown markdown parser work with Nashorn. + * + * @test + * @run + */ + +var input = "\n > This is a multi line blockquote test\n >\n > > And nesting!\n >\n > With more than one line."; +var output = converter.makeHtml(input); +print(output); diff --git a/nashorn/test/script/markdown/nested-blockquote.js.EXPECTED b/nashorn/test/script/markdown/nested-blockquote.js.EXPECTED new file mode 100644 index 00000000000..0b004934473 --- /dev/null +++ b/nashorn/test/script/markdown/nested-blockquote.js.EXPECTED @@ -0,0 +1,9 @@ +<blockquote> + <p>This is a multi line blockquote test</p> + + <blockquote> + <p>And nesting!</p> + </blockquote> + + <p>With more than one line.</p> +</blockquote> diff --git a/nashorn/test/script/markdown/ordered-list-same-number.js b/nashorn/test/script/markdown/ordered-list-same-number.js new file mode 100644 index 00000000000..00d05d2ae2a --- /dev/null +++ b/nashorn/test/script/markdown/ordered-list-same-number.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 for Showdown markdown parser work with Nashorn. + * + * @test + * @run + */ + +var input = "\n 1. Red\n 1. Green\n 1. Blue"; +var output = converter.makeHtml(input); +print(output); diff --git a/nashorn/test/script/markdown/ordered-list-same-number.js.EXPECTED b/nashorn/test/script/markdown/ordered-list-same-number.js.EXPECTED new file mode 100644 index 00000000000..b1abb536d96 --- /dev/null +++ b/nashorn/test/script/markdown/ordered-list-same-number.js.EXPECTED @@ -0,0 +1,5 @@ +<ol> +<li>Red</li> +<li>Green</li> +<li>Blue</li> +</ol> diff --git a/nashorn/test/script/markdown/ordered-list-wrong-numbers.js b/nashorn/test/script/markdown/ordered-list-wrong-numbers.js new file mode 100644 index 00000000000..2592020bbee --- /dev/null +++ b/nashorn/test/script/markdown/ordered-list-wrong-numbers.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 for Showdown markdown parser work with Nashorn. + * + * @test + * @run + */ + +var input = "\n 8. Red\n 1. Green\n 3. Blue"; +var output = converter.makeHtml(input); +print(output); diff --git a/nashorn/test/script/markdown/ordered-list-wrong-numbers.js.EXPECTED b/nashorn/test/script/markdown/ordered-list-wrong-numbers.js.EXPECTED new file mode 100644 index 00000000000..b1abb536d96 --- /dev/null +++ b/nashorn/test/script/markdown/ordered-list-wrong-numbers.js.EXPECTED @@ -0,0 +1,5 @@ +<ol> +<li>Red</li> +<li>Green</li> +<li>Blue</li> +</ol> diff --git a/nashorn/test/script/markdown/ordered-list.js b/nashorn/test/script/markdown/ordered-list.js new file mode 100644 index 00000000000..d79529f1c06 --- /dev/null +++ b/nashorn/test/script/markdown/ordered-list.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 for Showdown markdown parser work with Nashorn. + * + * @test + * @run + */ + +var input = "\n 1. Red\n 2. Green\n 3. Blue"; +var output = converter.makeHtml(input); +print(output); diff --git a/nashorn/test/script/markdown/ordered-list.js.EXPECTED b/nashorn/test/script/markdown/ordered-list.js.EXPECTED new file mode 100644 index 00000000000..b1abb536d96 --- /dev/null +++ b/nashorn/test/script/markdown/ordered-list.js.EXPECTED @@ -0,0 +1,5 @@ +<ol> +<li>Red</li> +<li>Green</li> +<li>Blue</li> +</ol> diff --git a/nashorn/test/script/markdown/relative-anchors.js b/nashorn/test/script/markdown/relative-anchors.js new file mode 100644 index 00000000000..7bfe01a6675 --- /dev/null +++ b/nashorn/test/script/markdown/relative-anchors.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 for Showdown markdown parser work with Nashorn. + * + * @test + * @run + */ + +var input = "\nSee my [About](/about/) page for details."; +var output = converter.makeHtml(input); +print(output); diff --git a/nashorn/test/script/markdown/relative-anchors.js.EXPECTED b/nashorn/test/script/markdown/relative-anchors.js.EXPECTED new file mode 100644 index 00000000000..6db73dc48c8 --- /dev/null +++ b/nashorn/test/script/markdown/relative-anchors.js.EXPECTED @@ -0,0 +1 @@ +<p>See my <a href="/about/">About</a> page for details.</p> diff --git a/nashorn/test/script/markdown/simple-paragraph.js b/nashorn/test/script/markdown/simple-paragraph.js new file mode 100644 index 00000000000..218918b7de2 --- /dev/null +++ b/nashorn/test/script/markdown/simple-paragraph.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 for Showdown markdown parser work with Nashorn. + * + * @test + * @run + */ + +var input = "\nHello, world!"; +var output = converter.makeHtml(input); +print(output); diff --git a/nashorn/test/script/markdown/simple-paragraph.js.EXPECTED b/nashorn/test/script/markdown/simple-paragraph.js.EXPECTED new file mode 100644 index 00000000000..7ce535433d8 --- /dev/null +++ b/nashorn/test/script/markdown/simple-paragraph.js.EXPECTED @@ -0,0 +1 @@ +<p>Hello, world!</p> diff --git a/nashorn/test/script/markdown/strong.js b/nashorn/test/script/markdown/strong.js new file mode 100644 index 00000000000..a1778726640 --- /dev/null +++ b/nashorn/test/script/markdown/strong.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 for Showdown markdown parser work with Nashorn. + * + * @test + * @run + */ + +var input = "\n**important**\n\n__important__\n\nreally **freaking**strong"; +var output = converter.makeHtml(input); +print(output); diff --git a/nashorn/test/script/markdown/strong.js.EXPECTED b/nashorn/test/script/markdown/strong.js.EXPECTED new file mode 100644 index 00000000000..5bcc675613d --- /dev/null +++ b/nashorn/test/script/markdown/strong.js.EXPECTED @@ -0,0 +1,5 @@ +<p><strong>important</strong></p> + +<p><strong>important</strong></p> + +<p>really <strong>freaking</strong>strong</p> diff --git a/nashorn/test/script/markdown/table-basic.js b/nashorn/test/script/markdown/table-basic.js new file mode 100644 index 00000000000..f2b9a3742e5 --- /dev/null +++ b/nashorn/test/script/markdown/table-basic.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 for Showdown markdown parser work with Nashorn. + * + * @test + * @run + */ + +var input = "| First Header | Second Header |\n| ------------- | ------------- |\n| Row 1 Cell 1 | Row 1 Cell 2 |\n| Row 2 Cell 1 | Row 2 Cell 2 |\n"; +var output = converter.makeHtml(input); +print(output); diff --git a/nashorn/test/script/markdown/table-basic.js.EXPECTED b/nashorn/test/script/markdown/table-basic.js.EXPECTED new file mode 100644 index 00000000000..d909e65b45d --- /dev/null +++ b/nashorn/test/script/markdown/table-basic.js.EXPECTED @@ -0,0 +1,21 @@ +<table> +<thead> +<tr> +<th id="first_header" style="text-align:left;"> First Header </th> +<th id="second_header" style="text-align:left;"> Second Header </th> +</tr> +</thead> + +<tbody> +<tr> +<td style="text-align:left;"><p>Row 1 Cell 1 </p></td> +<td style="text-align:left;"><p>Row 1 Cell 2 </p></td> +</tr> + +<tr> +<td style="text-align:left;"><p>Row 2 Cell 1 </p></td> +<td style="text-align:left;"><p>Row 2 Cell 2 </p></td> +</tr> + +</tbody> +</table> diff --git a/nashorn/test/script/markdown/table-large.js b/nashorn/test/script/markdown/table-large.js new file mode 100644 index 00000000000..ad7554d06d4 --- /dev/null +++ b/nashorn/test/script/markdown/table-large.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 for Showdown markdown parser work with Nashorn. + * + * @test + * @run + */ + +var input = "| First Header | Second Header | Third Header | Fourth Header |\n| ------------- | ------------- | ------------ | ------------- |\n| Row 1 Cell 1 | Row 1 Cell 2 | Row 1 Cell 3 | Row 1 Cell 4 |\n| Row 2 Cell 1 | Row 2 Cell 2 | Row 2 Cell 3 | Row 2 Cell 4 |\n| Row 3 Cell 1 | Row 3 Cell 2 | Row 3 Cell 3 | Row 3 Cell 4 |\n| Row 4 Cell 1 | Row 4 Cell 2 | Row 4 Cell 3 | Row 4 Cell 4 |\n| Row 5 Cell 1 | Row 5 Cell 2 | Row 5 Cell 3 | Row 5 Cell 4 |\n"; +var output = converter.makeHtml(input); +print(output); diff --git a/nashorn/test/script/markdown/table-large.js.EXPECTED b/nashorn/test/script/markdown/table-large.js.EXPECTED new file mode 100644 index 00000000000..332bdab6e85 --- /dev/null +++ b/nashorn/test/script/markdown/table-large.js.EXPECTED @@ -0,0 +1,48 @@ +<table> +<thead> +<tr> +<th id="first_header" style="text-align:left;"> First Header </th> +<th id="second_header" style="text-align:left;"> Second Header </th> +<th id="third_header" style="text-align:left;"> Third Header </th> +<th id="fourth_header" style="text-align:left;"> Fourth Header </th> +</tr> +</thead> + +<tbody> +<tr> +<td style="text-align:left;"><p>Row 1 Cell 1 </p></td> +<td style="text-align:left;"><p>Row 1 Cell 2 </p></td> +<td style="text-align:left;"><p>Row 1 Cell 3 </p></td> +<td style="text-align:left;"><p>Row 1 Cell 4 </p></td> +</tr> + +<tr> +<td style="text-align:left;"><p>Row 2 Cell 1 </p></td> +<td style="text-align:left;"><p>Row 2 Cell 2 </p></td> +<td style="text-align:left;"><p>Row 2 Cell 3 </p></td> +<td style="text-align:left;"><p>Row 2 Cell 4 </p></td> +</tr> + +<tr> +<td style="text-align:left;"><p>Row 3 Cell 1 </p></td> +<td style="text-align:left;"><p>Row 3 Cell 2 </p></td> +<td style="text-align:left;"><p>Row 3 Cell 3 </p></td> +<td style="text-align:left;"><p>Row 3 Cell 4 </p></td> +</tr> + +<tr> +<td style="text-align:left;"><p>Row 4 Cell 1 </p></td> +<td style="text-align:left;"><p>Row 4 Cell 2 </p></td> +<td style="text-align:left;"><p>Row 4 Cell 3 </p></td> +<td style="text-align:left;"><p>Row 4 Cell 4 </p></td> +</tr> + +<tr> +<td style="text-align:left;"><p>Row 5 Cell 1 </p></td> +<td style="text-align:left;"><p>Row 5 Cell 2 </p></td> +<td style="text-align:left;"><p>Row 5 Cell 3 </p></td> +<td style="text-align:left;"><p>Row 5 Cell 4 </p></td> +</tr> + +</tbody> +</table> diff --git a/nashorn/test/script/markdown/table-with-equals.js b/nashorn/test/script/markdown/table-with-equals.js new file mode 100644 index 00000000000..574223956d6 --- /dev/null +++ b/nashorn/test/script/markdown/table-with-equals.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 for Showdown markdown parser work with Nashorn. + * + * @test + * @run + */ + +var input = "| First Header | Second Header |\n| ============= | ============= |\n| Row 1 Cell 1 | Row 1 Cell 2 |\n| Row 2 Cell 1 | Row 2 Cell 2 |\n"; +var output = converter.makeHtml(input); +print(output); diff --git a/nashorn/test/script/markdown/table-with-equals.js.EXPECTED b/nashorn/test/script/markdown/table-with-equals.js.EXPECTED new file mode 100644 index 00000000000..d909e65b45d --- /dev/null +++ b/nashorn/test/script/markdown/table-with-equals.js.EXPECTED @@ -0,0 +1,21 @@ +<table> +<thead> +<tr> +<th id="first_header" style="text-align:left;"> First Header </th> +<th id="second_header" style="text-align:left;"> Second Header </th> +</tr> +</thead> + +<tbody> +<tr> +<td style="text-align:left;"><p>Row 1 Cell 1 </p></td> +<td style="text-align:left;"><p>Row 1 Cell 2 </p></td> +</tr> + +<tr> +<td style="text-align:left;"><p>Row 2 Cell 1 </p></td> +<td style="text-align:left;"><p>Row 2 Cell 2 </p></td> +</tr> + +</tbody> +</table> diff --git a/nashorn/test/script/markdown/unordered-list-asterisk.js b/nashorn/test/script/markdown/unordered-list-asterisk.js new file mode 100644 index 00000000000..8e2c01b10e5 --- /dev/null +++ b/nashorn/test/script/markdown/unordered-list-asterisk.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 for Showdown markdown parser work with Nashorn. + * + * @test + * @run + */ + +var input = "\n * Red\n * Green\n * Blue"; +var output = converter.makeHtml(input); +print(output); diff --git a/nashorn/test/script/markdown/unordered-list-asterisk.js.EXPECTED b/nashorn/test/script/markdown/unordered-list-asterisk.js.EXPECTED new file mode 100644 index 00000000000..b445990aede --- /dev/null +++ b/nashorn/test/script/markdown/unordered-list-asterisk.js.EXPECTED @@ -0,0 +1,5 @@ +<ul> +<li>Red</li> +<li>Green</li> +<li>Blue</li> +</ul> diff --git a/nashorn/test/script/markdown/unordered-list-minus.js b/nashorn/test/script/markdown/unordered-list-minus.js new file mode 100644 index 00000000000..19bcbac7085 --- /dev/null +++ b/nashorn/test/script/markdown/unordered-list-minus.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 for Showdown markdown parser work with Nashorn. + * + * @test + * @run + */ + +var input = "\n - Red\n - Green\n - Blue"; +var output = converter.makeHtml(input); +print(output); diff --git a/nashorn/test/script/markdown/unordered-list-minus.js.EXPECTED b/nashorn/test/script/markdown/unordered-list-minus.js.EXPECTED new file mode 100644 index 00000000000..b445990aede --- /dev/null +++ b/nashorn/test/script/markdown/unordered-list-minus.js.EXPECTED @@ -0,0 +1,5 @@ +<ul> +<li>Red</li> +<li>Green</li> +<li>Blue</li> +</ul> diff --git a/nashorn/test/script/markdown/unordered-list-plus.js b/nashorn/test/script/markdown/unordered-list-plus.js new file mode 100644 index 00000000000..55b4dfb8fa9 --- /dev/null +++ b/nashorn/test/script/markdown/unordered-list-plus.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 for Showdown markdown parser work with Nashorn. + * + * @test + * @run + */ + +var input = "\n + Red\n + Green\n + Blue"; +var output = converter.makeHtml(input); +print(output); diff --git a/nashorn/test/script/markdown/unordered-list-plus.js.EXPECTED b/nashorn/test/script/markdown/unordered-list-plus.js.EXPECTED new file mode 100644 index 00000000000..b445990aede --- /dev/null +++ b/nashorn/test/script/markdown/unordered-list-plus.js.EXPECTED @@ -0,0 +1,5 @@ +<ul> +<li>Red</li> +<li>Green</li> +<li>Blue</li> +</ul> diff --git a/nashorn/test/script/markdown/url-with-parenthesis.js b/nashorn/test/script/markdown/url-with-parenthesis.js new file mode 100644 index 00000000000..dc6ce740938 --- /dev/null +++ b/nashorn/test/script/markdown/url-with-parenthesis.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 for Showdown markdown parser work with Nashorn. + * + * @test + * @run + */ + +var input = "\nThere's an [episode](http://en.memory-alpha.org/wiki/Darmok_(episode)) of Star Trek: The Next Generation"; +var output = converter.makeHtml(input); +print(output); diff --git a/nashorn/test/script/markdown/url-with-parenthesis.js.EXPECTED b/nashorn/test/script/markdown/url-with-parenthesis.js.EXPECTED new file mode 100644 index 00000000000..9e1e7cc9966 --- /dev/null +++ b/nashorn/test/script/markdown/url-with-parenthesis.js.EXPECTED @@ -0,0 +1 @@ +<p>There's an <a href="http://en.memory-alpha.org/wiki/Darmok_(episode)">episode</a> of Star Trek: The Next Generation</p> diff --git a/nashorn/test/script/sandbox/JDK-8031106.js b/nashorn/test/script/sandbox/JDK-8031106.js new file mode 100644 index 00000000000..d5d83f6927f --- /dev/null +++ b/nashorn/test/script/sandbox/JDK-8031106.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * JDK-8031106: Nashorn: IndexOutOfBoundsException in NashornCallSiteDescriptor.getNameToken() + * + * @test + * @run + */ + +var cl = new java.lang.Object().getClass(); +try { + cl["forName"]; + fail("Should have thrown exception!"); +} catch (e) { + if (! (e instanceof java.lang.SecurityException)) { + fail("SecurityException expected, got " + e); + } +} diff --git a/nashorn/test/script/trusted/JDK-8032060.js b/nashorn/test/script/trusted/JDK-8032060.js new file mode 100644 index 00000000000..8cb350cc238 --- /dev/null +++ b/nashorn/test/script/trusted/JDK-8032060.js @@ -0,0 +1,72 @@ +/* + * 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. + */ + +/** + * JDK-8032060: PropertyMap of Error objects is not stable + * + * @test + * @option -Dnashorn.debug=true + * @fork + * @run + */ + +function checkMap(e1, e2) { + if (! Debug.identical(Debug.map(e1), Debug.map(e2))) { + fail("e1 and e2 have different maps"); + } + + var m1, m2; + + try { + throw e1 + } catch (e) { + m1 = Debug.map(e) + } + + try { + throw e2 + } catch (e) { + m2 = Debug.map(e) + } + + if (! Debug.identical(m1, m2)) { + fail("e1 and e2 have different maps after being thrown"); + } +} + +checkMap(new Error(), new Error()); +checkMap(new EvalError(), new EvalError()); +checkMap(new RangeError(), new RangeError()); +checkMap(new ReferenceError(), new ReferenceError()); +checkMap(new SyntaxError(), new SyntaxError()); +checkMap(new TypeError(), new TypeError()); +checkMap(new URIError(), new URIError()); + +// now try with message param +checkMap(new Error("x"), new Error("y")); +checkMap(new EvalError("x"), new EvalError("y")); +checkMap(new RangeError("x"), new RangeError("y")); +checkMap(new ReferenceError("x"), new ReferenceError("y")); +checkMap(new SyntaxError("x"), new SyntaxError("y")); +checkMap(new TypeError("x"), new TypeError("y")); +checkMap(new URIError("x"), new URIError("y")); diff --git a/nashorn/test/src/jdk/nashorn/api/scripting/InvocableTest.java b/nashorn/test/src/jdk/nashorn/api/scripting/InvocableTest.java index fad3f3722b1..a6722f571f5 100644 --- a/nashorn/test/src/jdk/nashorn/api/scripting/InvocableTest.java +++ b/nashorn/test/src/jdk/nashorn/api/scripting/InvocableTest.java @@ -26,6 +26,7 @@ package jdk.nashorn.api.scripting; import java.util.Objects; +import java.util.function.Function; import javax.script.Invocable; import javax.script.ScriptContext; import javax.script.ScriptEngine; @@ -522,4 +523,16 @@ public class InvocableTest { Assert.assertEquals(itf.test1(42, "a", "b"), "i == 42, strings instanceof java.lang.String[] == true, strings == [a, b]"); Assert.assertEquals(itf.test2(44, "c", "d", "e"), "arguments[0] == 44, arguments[1] instanceof java.lang.String[] == true, arguments[1] == [c, d, e]"); } + + @Test + @SuppressWarnings("unchecked") + public void defaultMethodTest() throws ScriptException { + final ScriptEngineManager m = new ScriptEngineManager(); + final ScriptEngine e = m.getEngineByName("nashorn"); + final Invocable inv = (Invocable) e; + + Object obj = e.eval("({ apply: function(arg) { return arg.toUpperCase(); }})"); + Function<String, String> func = inv.getInterface(obj, Function.class); + assertEquals(func.apply("hello"), "HELLO"); + } }