# HG changeset patch # User jiangli # Date 1461182678 14400 # Node ID 58732890050dd94f927b2e550eabe4c4e7c79e86 # Parent ddb53593fc101eaa9270d4ef013d99f8f0c34cf8 8154457: runtime/SharedArchiveFile/SharedStrings Shared string table stats missing Summary: Added more information when print out message reporting disabling the shared strings at CDS dump time. Reviewed-by: lfoltan, hseigel, mseledtsov, gtriantafill diff -r ddb53593fc10 -r 58732890050d hotspot/src/share/vm/classfile/stringTable.cpp --- a/hotspot/src/share/vm/classfile/stringTable.cpp Wed Apr 20 19:54:51 2016 +0300 +++ b/hotspot/src/share/vm/classfile/stringTable.cpp Wed Apr 20 16:04:38 2016 -0400 @@ -730,8 +730,12 @@ if (soc->writing()) { if (!(UseG1GC && UseCompressedOops && UseCompressedClassPointers)) { if (PrintSharedSpaces) { - tty->print_cr("Shared strings are excluded from the archive as UseG1GC, " - "UseCompressedOops and UseCompressedClassPointers are required."); + tty->print_cr( + "Shared strings are excluded from the archive as UseG1GC, " + "UseCompressedOops and UseCompressedClassPointers are required." + "Current settings: UseG1GC=%s, UseCompressedOops=%s, UseCompressedClassPointers=%s.", + BOOL_TO_STR(UseG1GC), BOOL_TO_STR(UseCompressedOops), + BOOL_TO_STR(UseCompressedClassPointers)); } } else { int num_buckets = the_table()->number_of_entries() / diff -r ddb53593fc10 -r 58732890050d hotspot/test/runtime/SharedArchiveFile/SharedStrings.java --- a/hotspot/test/runtime/SharedArchiveFile/SharedStrings.java Wed Apr 20 19:54:51 2016 +0300 +++ b/hotspot/test/runtime/SharedArchiveFile/SharedStrings.java Wed Apr 20 16:04:38 2016 -0400 @@ -40,37 +40,51 @@ public class SharedStrings { public static void main(String[] args) throws Exception { + boolean test_runtime = true; ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./SharedStrings.jsa", + "-XX:+UseG1GC", + "-XX:+UseCompressedOops", "-XX:+PrintSharedSpaces", // Needed for bootclasspath match, for CDS to work with WhiteBox API "-Xbootclasspath/a:" + ClassFileInstaller.getJarPath("whitebox.jar"), "-Xshare:dump"); - new OutputAnalyzer(pb.start()) - .shouldContain("Loading classes to share") - .shouldContain("Shared string table stats") - .shouldHaveExitValue(0); + OutputAnalyzer dumpOutput = new OutputAnalyzer(pb.start()); + try { + dumpOutput.shouldContain("Loading classes to share"); + dumpOutput.shouldContain("Shared string table stats"); + dumpOutput.shouldHaveExitValue(0); + } catch (RuntimeException e) { + if (dumpOutput.getOutput().indexOf("Shared strings are excluded") != -1 || + dumpOutput.getOutput().indexOf("Cannot dump shared archive") != -1) { + test_runtime = false; + } else { + throw new RuntimeException("Unexpected failure"); + } + } - pb = ProcessTools.createJavaProcessBuilder( - "-XX:+UnlockDiagnosticVMOptions", - "-XX:SharedArchiveFile=./SharedStrings.jsa", - // these are required modes for shared strings - "-XX:+UseCompressedOops", "-XX:+UseG1GC", - // needed for access to white box test API - "-Xbootclasspath/a:" + ClassFileInstaller.getJarPath("whitebox.jar"), - "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", - "-Xshare:on", "-showversion", "SharedStringsWb"); + if (test_runtime) { + pb = ProcessTools.createJavaProcessBuilder( + "-XX:+UnlockDiagnosticVMOptions", + "-XX:SharedArchiveFile=./SharedStrings.jsa", + // these are required modes for shared strings + "-XX:+UseCompressedOops", "-XX:+UseG1GC", + // needed for access to white box test API + "-Xbootclasspath/a:" + ClassFileInstaller.getJarPath("whitebox.jar"), + "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", + "-Xshare:on", "-showversion", "SharedStringsWb"); - OutputAnalyzer output = new OutputAnalyzer(pb.start()); + OutputAnalyzer output = new OutputAnalyzer(pb.start()); - try { - output.shouldContain("sharing"); - output.shouldHaveExitValue(0); - } catch (RuntimeException e) { - output.shouldContain("Unable to use shared archive"); - output.shouldHaveExitValue(1); + try { + output.shouldContain("sharing"); + output.shouldHaveExitValue(0); + } catch (RuntimeException e) { + output.shouldContain("Unable to use shared archive"); + output.shouldHaveExitValue(1); + } } } }