8139986: Store debug level in java.vm.debug and conditionally print in "java -version"
Co-authored-by: Kumar Srinivasan <kumar.x.srinivasan@oracle.com> Reviewed-by: ihse, dcubed, ksrini, dholmes
This commit is contained in:
parent
321ddf167f
commit
20cb4ca730
@ -98,7 +98,15 @@ public class Version {
|
||||
|
||||
/* Second line: runtime version (ie, libraries). */
|
||||
|
||||
ps.print(java_runtime_name + " (build " + java_runtime_version);
|
||||
String jdk_debug_level = System.getProperty("jdk.debug", "release");
|
||||
/* Debug level is not printed for "release" builds */
|
||||
if ("release".equals(jdk_debug_level)) {
|
||||
jdk_debug_level = "";
|
||||
} else {
|
||||
jdk_debug_level = jdk_debug_level + " ";
|
||||
}
|
||||
|
||||
ps.print(java_runtime_name + " (" + jdk_debug_level + "build " + java_runtime_version);
|
||||
|
||||
if (java_runtime_name.indexOf("Embedded") != -1 && isHeadless) {
|
||||
// embedded builds report headless state
|
||||
@ -110,7 +118,7 @@ public class Version {
|
||||
String java_vm_name = System.getProperty("java.vm.name");
|
||||
String java_vm_version = System.getProperty("java.vm.version");
|
||||
String java_vm_info = System.getProperty("java.vm.info");
|
||||
ps.println(java_vm_name + " (build " + java_vm_version + ", " +
|
||||
ps.println(java_vm_name + " (" + jdk_debug_level + "build " + java_vm_version + ", " +
|
||||
java_vm_info + ")");
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ public class Platform {
|
||||
private static final String osName = System.getProperty("os.name");
|
||||
private static final String dataModel = System.getProperty("sun.arch.data.model");
|
||||
private static final String vmVersion = System.getProperty("java.vm.version");
|
||||
private static final String javaVersion = System.getProperty("java.version");
|
||||
private static final String jdkDebug = System.getProperty("jdk.debug");
|
||||
private static final String osArch = System.getProperty("os.arch");
|
||||
private static final String vmName = System.getProperty("java.vm.name");
|
||||
private static final String userName = System.getProperty("user.name");
|
||||
@ -99,8 +99,7 @@ public class Platform {
|
||||
}
|
||||
|
||||
public static boolean isDebugBuild() {
|
||||
return (vmVersion.toLowerCase().contains("debug") ||
|
||||
javaVersion.toLowerCase().contains("debug"));
|
||||
return (jdkDebug.toLowerCase().contains("debug"));
|
||||
}
|
||||
|
||||
public static String getVMVersion() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* 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,7 +23,7 @@
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 6545058 6611182 8016209
|
||||
* @bug 6545058 6611182 8016209 8139986
|
||||
* @summary validate and test -version, -fullversion, and internal, as well as
|
||||
* sanity checks if a tool can be launched.
|
||||
* @compile VersionCheck.java
|
||||
@ -115,12 +115,20 @@ public class VersionCheck extends TestHelper {
|
||||
static String refVersion;
|
||||
static String refFullVersion;
|
||||
|
||||
static String getAllVersionLines(String... argv) {
|
||||
return getVersion0(true, argv);
|
||||
}
|
||||
|
||||
static String getVersion(String... argv) {
|
||||
return getVersion0(false, argv);
|
||||
}
|
||||
|
||||
static String getVersion0(boolean allLines, String... argv) {
|
||||
TestHelper.TestResult tr = doExec(argv);
|
||||
StringBuilder out = new StringBuilder();
|
||||
// remove the HotSpot line
|
||||
for (String x : tr.testOutput) {
|
||||
if (!x.matches(".*Client.*VM.*|.*Server.*VM.*")) {
|
||||
if (allLines || !x.matches(".*Client.*VM.*|.*Server.*VM.*")) {
|
||||
out = out.append(x + "\n");
|
||||
}
|
||||
}
|
||||
@ -202,6 +210,28 @@ public class VersionCheck extends TestHelper {
|
||||
return failcount == 0;
|
||||
}
|
||||
|
||||
static boolean testDebugVersion() {
|
||||
String jdkType = System.getProperty("jdk.debug", "release");
|
||||
String versionLines = getAllVersionLines(javaCmd, "-version");
|
||||
if ("release".equals(jdkType)) {
|
||||
jdkType = "";
|
||||
} else {
|
||||
jdkType = jdkType + " ";
|
||||
}
|
||||
String tofind = "(" + jdkType + "build";
|
||||
int idx = versionLines.indexOf(tofind);
|
||||
if (idx < 0) {
|
||||
System.out.println("Did not find first instance of " + tofind);
|
||||
return false;
|
||||
}
|
||||
idx = versionLines.indexOf(tofind, idx + 1);
|
||||
if (idx < 0) {
|
||||
System.out.println("Did not find first instance of " + tofind);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Initialize
|
||||
static void init() {
|
||||
refVersion = getVersion(javaCmd, "-version");
|
||||
@ -212,7 +242,8 @@ public class VersionCheck extends TestHelper {
|
||||
init();
|
||||
if (compareJVersionStrings() &&
|
||||
compareInternalStrings() &&
|
||||
testToolVersion()) {
|
||||
testToolVersion() &&
|
||||
testDebugVersion()) {
|
||||
System.out.println("All Version string comparisons: PASS");
|
||||
} else {
|
||||
throw new AssertionError("Some tests failed");
|
||||
@ -220,7 +251,7 @@ public class VersionCheck extends TestHelper {
|
||||
}
|
||||
|
||||
static class ToolFilter implements FileFilter {
|
||||
final Iterable<String> exclude ;
|
||||
final Iterable<String> exclude;
|
||||
protected ToolFilter(String... exclude) {
|
||||
List<String> tlist = new ArrayList<>();
|
||||
this.exclude = tlist;
|
||||
|
Loading…
x
Reference in New Issue
Block a user