diff --git a/src/share/vm/services/gcNotifier.cpp b/src/share/vm/services/gcNotifier.cpp index e6106e29c7d66d7b36769953308a9cf44d33289d..7d1fe5d894447a1a9177634d4b85f3bd30847a57 100644 --- a/src/share/vm/services/gcNotifier.cpp +++ b/src/share/vm/services/gcNotifier.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 @@ -211,9 +211,9 @@ void GCNotifier::sendNotificationInternal(TRAPS) { NotificationMark nm(request); Handle objGcInfo = createGcInfo(request->gcManager, request->gcStatInfo, THREAD); - Handle objName = java_lang_String::create_from_platform_dependent_str(request->gcManager->name(), CHECK); - Handle objAction = java_lang_String::create_from_platform_dependent_str(request->gcAction, CHECK); - Handle objCause = java_lang_String::create_from_platform_dependent_str(request->gcCause, CHECK); + Handle objName = java_lang_String::create_from_str(request->gcManager->name(), CHECK); + Handle objAction = java_lang_String::create_from_str(request->gcAction, CHECK); + Handle objCause = java_lang_String::create_from_str(request->gcCause, CHECK); Klass* k = Management::sun_management_GarbageCollectorImpl_klass(CHECK); instanceKlassHandle gc_mbean_klass(THREAD, k); diff --git a/src/share/vm/services/management.cpp b/src/share/vm/services/management.cpp index 0808ebd0acd4737cec9201f3c1bc5f4ca54fd533..a2c8944ee427d57018de116cf77ae9a89316d457 100644 --- a/src/share/vm/services/management.cpp +++ b/src/share/vm/services/management.cpp @@ -1831,13 +1831,13 @@ class ThreadTimesClosure: public ThreadClosure { private: objArrayHandle _names_strings; char **_names_chars; - typeArrayOop _times; + typeArrayHandle _times; int _names_len; int _times_len; int _count; public: - ThreadTimesClosure(objArrayHandle names, typeArrayOop times); + ThreadTimesClosure(objArrayHandle names, typeArrayHandle times); ~ThreadTimesClosure(); virtual void do_thread(Thread* thread); void do_unlocked(); @@ -1845,9 +1845,9 @@ class ThreadTimesClosure: public ThreadClosure { }; ThreadTimesClosure::ThreadTimesClosure(objArrayHandle names, - typeArrayOop times) { + typeArrayHandle times) { assert(names() != NULL, "names was NULL"); - assert(times != NULL, "times was NULL"); + assert(times() != NULL, "times was NULL"); _names_strings = names; _names_len = names->length(); _names_chars = NEW_C_HEAP_ARRAY(char*, _names_len, mtInternal); @@ -1925,7 +1925,7 @@ JVM_ENTRY(jint, jmm_GetInternalThreadTimes(JNIEnv *env, typeArrayOop ta = typeArrayOop(JNIHandles::resolve_non_null(times)); typeArrayHandle times_ah(THREAD, ta); - ThreadTimesClosure ttc(names_ah, times_ah()); + ThreadTimesClosure ttc(names_ah, times_ah); { MutexLockerEx ml(Threads_lock); Threads::threads_do(&ttc); diff --git a/test/runtime/8000968/Test8000968.sh b/test/runtime/8000968/Test8000968.sh deleted file mode 100644 index cd7183476cf27387debe9e3cf0ca18877ecfa5d8..0000000000000000000000000000000000000000 --- a/test/runtime/8000968/Test8000968.sh +++ /dev/null @@ -1,99 +0,0 @@ -# -# Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please 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 Test8000968.sh -# @bug 8000968 -# @summary NPG: UseCompressedKlassPointers asserts with ObjectAlignmentInBytes=32 -# @run shell Test8000968.sh -# - -if [ "${TESTJAVA}" = "" ] -then - PARENT=`dirname \`which java\`` - TESTJAVA=`dirname ${PARENT}` - printf "TESTJAVA not set, selecting " ${TESTJAVA} - printf " If this is incorrect, try setting the variable manually.\n" -fi - - -# set platform-dependent variables -OS=`uname -s` -case "$OS" in - Windows_* ) - FS="\\" - NULL=NUL - ;; - * ) - FS="/" - NULL=/dev/null - ;; -esac - -JAVA=${TESTJAVA}${FS}bin${FS}java - -# -# See if platform has 64 bit java. -# -${JAVA} ${TESTVMOPTS} -d64 -version 2>&1 | grep -i "does not support" > ${NULL} -if [ "$?" != "1" ] -then - printf "Platform is 32 bit, does not support -XX:ObjectAlignmentInBytes= option.\n" - printf "Passed.\n" - exit 0 -fi - -# -# Test -XX:ObjectAlignmentInBytes with -XX:+UseCompressedKlassPointers -XX:+UseCompressedOops. -# -${JAVA} ${TESTVMOPTS} -d64 -XX:+UseCompressedKlassPointers -XX:+UseCompressedOops -XX:ObjectAlignmentInBytes=16 -version 2>&1 > ${NULL} -if [ "$?" != "0" ] -then - printf "FAILED: -XX:ObjectAlignmentInBytes=16 option did not work.\n" - exit 1 -fi - -${JAVA} ${TESTVMOPTS} -d64 -XX:+UseCompressedKlassPointers -XX:+UseCompressedOops -XX:ObjectAlignmentInBytes=32 -version 2>&1 > ${NULL} -if [ "$?" != "0" ] -then - printf "FAILED: -XX:ObjectAlignmentInBytes=32 option did not work.\n" - exit 1 -fi - -${JAVA} ${TESTVMOPTS} -d64 -XX:+UseCompressedKlassPointers -XX:+UseCompressedOops -XX:ObjectAlignmentInBytes=64 -version 2>&1 > ${NULL} -if [ "$?" != "0" ] -then - printf "FAILED: -XX:ObjectAlignmentInBytes=64 option did not work.\n" - exit 1 -fi - -${JAVA} ${TESTVMOPTS} -d64 -XX:+UseCompressedKlassPointers -XX:+UseCompressedOops -XX:ObjectAlignmentInBytes=128 -version 2>&1 > ${NULL} -if [ "$?" != "0" ] -then - printf "FAILED: -XX:ObjectAlignmentInBytes=128 option did not work.\n" - exit 1 -fi - - -printf "Passed.\n" -exit 0 diff --git a/test/runtime/CompressedOops/CompressedKlassPointerAndOops.java b/test/runtime/CompressedOops/CompressedKlassPointerAndOops.java new file mode 100644 index 0000000000000000000000000000000000000000..dd0c26d9f102a676b0fea6f958ce39b5138e138e --- /dev/null +++ b/test/runtime/CompressedOops/CompressedKlassPointerAndOops.java @@ -0,0 +1,63 @@ +/* + * 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 8000968 + * @key regression + * @summary NPG: UseCompressedKlassPointers asserts with ObjectAlignmentInBytes=32 + * @library /testlibrary + */ + +import com.oracle.java.testlibrary.*; + +public class CompressedKlassPointerAndOops { + + public static void main(String[] args) throws Exception { + + if (!Platform.is64bit()) { + // Can't test this on 32 bit, just pass + System.out.println("Skipping test on 32bit"); + return; + } + + runWithAlignment(16); + runWithAlignment(32); + runWithAlignment(64); + runWithAlignment(128); + } + + private static void runWithAlignment(int alignment) throws Exception { + ProcessBuilder pb; + OutputAnalyzer output; + + pb = ProcessTools.createJavaProcessBuilder( + "-XX:+UseCompressedKlassPointers", + "-XX:+UseCompressedOops", + "-XX:ObjectAlignmentInBytes=" + alignment, + "-version"); + + output = new OutputAnalyzer(pb.start()); + output.shouldHaveExitValue(0); + } +} diff --git a/test/testlibrary/OutputAnalyzerReportingTest.java b/test/testlibrary/OutputAnalyzerReportingTest.java new file mode 100644 index 0000000000000000000000000000000000000000..068f193efcf1420d5a9c59c601749ccc7575c63b --- /dev/null +++ b/test/testlibrary/OutputAnalyzerReportingTest.java @@ -0,0 +1,124 @@ +/* + * 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 the OutputAnalyzer reporting functionality, + * such as printing additional diagnostic info + * (exit code, stdout, stderr, command line, etc.) + * @library /testlibrary + */ + +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; + +import com.oracle.java.testlibrary.OutputAnalyzer; +import com.oracle.java.testlibrary.ProcessTools; + + +public class OutputAnalyzerReportingTest { + + public static void main(String[] args) throws Exception { + // Create the output analyzer under test + String stdout = "aaaaaa"; + String stderr = "bbbbbb"; + OutputAnalyzer output = new OutputAnalyzer(stdout, stderr); + + // Expected summary values should be the same for all cases, + // since the outputAnalyzer object is the same + String expectedExitValue = "-1"; + String expectedSummary = + " stdout: [" + stdout + "];\n" + + " stderr: [" + stderr + "]\n" + + " exitValue = " + expectedExitValue + "\n"; + + + DiagnosticSummaryTestRunner testRunner = + new DiagnosticSummaryTestRunner(); + + // should have exit value + testRunner.init(expectedSummary); + int unexpectedExitValue = 2; + try { + output.shouldHaveExitValue(unexpectedExitValue); + } catch (RuntimeException e) { } + testRunner.closeAndCheckResults(); + + // should not contain + testRunner.init(expectedSummary); + try { + output.shouldNotContain(stdout); + } catch (RuntimeException e) { } + testRunner.closeAndCheckResults(); + + // should contain + testRunner.init(expectedSummary); + try { + output.shouldContain("unexpected-stuff"); + } catch (RuntimeException e) { } + testRunner.closeAndCheckResults(); + + // should not match + testRunner.init(expectedSummary); + try { + output.shouldNotMatch("[a]"); + } catch (RuntimeException e) { } + testRunner.closeAndCheckResults(); + + // should match + testRunner.init(expectedSummary); + try { + output.shouldMatch("[qwerty]"); + } catch (RuntimeException e) { } + testRunner.closeAndCheckResults(); + + } + + private static class DiagnosticSummaryTestRunner { + private ByteArrayOutputStream byteStream = + new ByteArrayOutputStream(10000); + + private String expectedSummary = ""; + private PrintStream errStream; + + + public void init(String expectedSummary) { + this.expectedSummary = expectedSummary; + byteStream.reset(); + errStream = new PrintStream(byteStream); + System.setErr(errStream); + } + + public void closeAndCheckResults() { + // check results + errStream.close(); + String stdErrStr = byteStream.toString(); + if (!stdErrStr.contains(expectedSummary)) { + throw new RuntimeException("The output does not contain " + + "the diagnostic message, or the message is incorrect"); + } + } + } + +} diff --git a/test/testlibrary/com/oracle/java/testlibrary/OutputAnalyzer.java b/test/testlibrary/com/oracle/java/testlibrary/OutputAnalyzer.java index ede667f8e5877083824b61809eed8e22b87d718d..b9e37128d23e0b3e0c75d43fc018cbfe122b6884 100644 --- a/test/testlibrary/com/oracle/java/testlibrary/OutputAnalyzer.java +++ b/test/testlibrary/com/oracle/java/testlibrary/OutputAnalyzer.java @@ -76,7 +76,8 @@ public final class OutputAnalyzer { */ public void shouldContain(String expectedString) { if (!stdout.contains(expectedString) && !stderr.contains(expectedString)) { - throw new RuntimeException("'" + expectedString + "' missing from stdout/stderr: [" + stdout + stderr + "]\n"); + reportDiagnosticSummary(); + throw new RuntimeException("'" + expectedString + "' missing from stdout/stderr \n"); } } @@ -88,7 +89,8 @@ public final class OutputAnalyzer { */ public void stdoutShouldContain(String expectedString) { if (!stdout.contains(expectedString)) { - throw new RuntimeException("'" + expectedString + "' missing from stdout: [" + stdout + "]\n"); + reportDiagnosticSummary(); + throw new RuntimeException("'" + expectedString + "' missing from stdout \n"); } } @@ -100,7 +102,8 @@ public final class OutputAnalyzer { */ public void stderrShouldContain(String expectedString) { if (!stderr.contains(expectedString)) { - throw new RuntimeException("'" + expectedString + "' missing from stderr: [" + stderr + "]\n"); + reportDiagnosticSummary(); + throw new RuntimeException("'" + expectedString + "' missing from stderr \n"); } } @@ -112,10 +115,12 @@ public final class OutputAnalyzer { */ public void shouldNotContain(String notExpectedString) { if (stdout.contains(notExpectedString)) { - throw new RuntimeException("'" + notExpectedString + "' found in stdout: [" + stdout + "]\n"); + reportDiagnosticSummary(); + throw new RuntimeException("'" + notExpectedString + "' found in stdout \n"); } if (stderr.contains(notExpectedString)) { - throw new RuntimeException("'" + notExpectedString + "' found in stderr: [" + stderr + "]\n"); + reportDiagnosticSummary(); + throw new RuntimeException("'" + notExpectedString + "' found in stderr \n"); } } @@ -127,7 +132,8 @@ public final class OutputAnalyzer { */ public void stdoutShouldNotContain(String notExpectedString) { if (stdout.contains(notExpectedString)) { - throw new RuntimeException("'" + notExpectedString + "' found in stdout: [" + stdout + "]\n"); + reportDiagnosticSummary(); + throw new RuntimeException("'" + notExpectedString + "' found in stdout \n"); } } @@ -139,7 +145,8 @@ public final class OutputAnalyzer { */ public void stderrShouldNotContain(String notExpectedString) { if (stderr.contains(notExpectedString)) { - throw new RuntimeException("'" + notExpectedString + "' found in stderr: [" + stderr + "]\n"); + reportDiagnosticSummary(); + throw new RuntimeException("'" + notExpectedString + "' found in stderr \n"); } } @@ -154,9 +161,9 @@ public final class OutputAnalyzer { Matcher stdoutMatcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stdout); Matcher stderrMatcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stderr); if (!stdoutMatcher.find() && !stderrMatcher.find()) { + reportDiagnosticSummary(); throw new RuntimeException("'" + pattern - + "' missing from stdout/stderr: [" + stdout + stderr - + "]\n"); + + "' missing from stdout/stderr \n"); } } @@ -170,8 +177,9 @@ public final class OutputAnalyzer { public void stdoutShouldMatch(String pattern) { Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stdout); if (!matcher.find()) { + reportDiagnosticSummary(); throw new RuntimeException("'" + pattern - + "' missing from stdout: [" + stdout + "]\n"); + + "' missing from stdout \n"); } } @@ -185,8 +193,9 @@ public final class OutputAnalyzer { public void stderrShouldMatch(String pattern) { Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stderr); if (!matcher.find()) { + reportDiagnosticSummary(); throw new RuntimeException("'" + pattern - + "' missing from stderr: [" + stderr + "]\n"); + + "' missing from stderr \n"); } } @@ -200,13 +209,15 @@ public final class OutputAnalyzer { public void shouldNotMatch(String pattern) { Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stdout); if (matcher.find()) { + reportDiagnosticSummary(); throw new RuntimeException("'" + pattern - + "' found in stdout: [" + stdout + "]\n"); + + "' found in stdout \n"); } matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stderr); if (matcher.find()) { + reportDiagnosticSummary(); throw new RuntimeException("'" + pattern - + "' found in stderr: [" + stderr + "]\n"); + + "' found in stderr \n"); } } @@ -220,8 +231,9 @@ public final class OutputAnalyzer { public void stdoutShouldNotMatch(String pattern) { Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stdout); if (matcher.find()) { + reportDiagnosticSummary(); throw new RuntimeException("'" + pattern - + "' found in stdout: [" + stdout + "]\n"); + + "' found in stdout \n"); } } @@ -235,23 +247,45 @@ public final class OutputAnalyzer { public void stderrShouldNotMatch(String pattern) { Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stderr); if (matcher.find()) { + reportDiagnosticSummary(); throw new RuntimeException("'" + pattern - + "' found in stderr: [" + stderr + "]\n"); + + "' found in stderr \n"); } } /** - * Verifiy the exit value of the process + * Verify the exit value of the process * * @param expectedExitValue Expected exit value from process * @throws RuntimeException If the exit value from the process did not match the expected value */ public void shouldHaveExitValue(int expectedExitValue) { if (getExitValue() != expectedExitValue) { - throw new RuntimeException("Exit value " + getExitValue() + " , expected to get " + expectedExitValue); + reportDiagnosticSummary(); + throw new RuntimeException("Expected to get exit value of [" + + expectedExitValue + "]\n"); } } + + /** + * Report summary that will help to diagnose the problem + * Currently includes: + * - standard input produced by the process under test + * - standard output + * - exit code + * Note: the command line is printed by the ProcessTools + */ + private void reportDiagnosticSummary() { + String msg = + " stdout: [" + stdout + "];\n" + + " stderr: [" + stderr + "]\n" + + " exitValue = " + getExitValue() + "\n"; + + System.err.println(msg); + } + + /** * Get the contents of the output buffer (stdout and stderr) * diff --git a/test/testlibrary/com/oracle/java/testlibrary/ProcessTools.java b/test/testlibrary/com/oracle/java/testlibrary/ProcessTools.java index 6e0fdae6564091f55e2a74470fb1c8782822c4d7..56277f046eccf53ee69cabd84bc05b1600964a97 100644 --- a/test/testlibrary/com/oracle/java/testlibrary/ProcessTools.java +++ b/test/testlibrary/com/oracle/java/testlibrary/ProcessTools.java @@ -31,6 +31,7 @@ import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collections; +import java.util.List; import sun.management.VMManagement; @@ -106,6 +107,22 @@ public final class ProcessTools { return pid; } + /** + * Get the string containing input arguments passed to the VM + * + * @return arguments + */ + public static String getVmInputArguments() { + RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean(); + + List args = runtime.getInputArguments(); + StringBuilder result = new StringBuilder(); + for (String arg : args) + result.append(arg).append(' '); + + return result.toString(); + } + /** * Get platform specific VM arguments (e.g. -d64 on 64bit Solaris) * @@ -132,8 +149,13 @@ public final class ProcessTools { Collections.addAll(args, getPlatformSpecificVMArgs()); Collections.addAll(args, command); - return new ProcessBuilder(args.toArray(new String[args.size()])); + // Reporting + StringBuilder cmdLine = new StringBuilder(); + for (String cmd : args) + cmdLine.append(cmd).append(' '); + System.out.println("Command line: [" + cmdLine.toString() + "]"); + return new ProcessBuilder(args.toArray(new String[args.size()])); } }