Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(0.24.0) Update JavaRuntimeVersion test (jrvTest) to handle more variants #11675

Merged
merged 1 commit into from
Jan 18, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2001, 2018 IBM Corp. and others
* Copyright (c) 2001, 2021 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand All @@ -23,27 +23,45 @@
public class JavaRuntimeVersion {

/**
* example java.runtime.version: pxa6460sr11-20120403_01 (SR11)
* example java.runtime.version's:
* 1.8.0_272-b10
* 8.0.7.0 - pxa6480sr7-20200922_01(SR7)
* 11.0.10-internal
* 11.0.10+5
* obsolete: pxa6460sr11-20120403_01 (SR11)
*/
public static void main(String[] args) {
String runTimeVersion =System.getProperty("java.runtime.version");
String runTimeVersion = System.getProperty("java.runtime.version");

System.out.println("java.runtime.version is:" + runTimeVersion);

String[] properties = runTimeVersion.split("\\s|-");
if (properties.length < 2) {
throw new IllegalArgumentException (
"cannot locate platform info/time stamp from " + runTimeVersion);
String[] versionParts = properties[0].split("\\+");
if (versionParts.length > 2) {
throw new IllegalArgumentException ("invalid version: " + properties[0]);
}
String intialVersion = versionParts[0];
if (intialVersion.startsWith("1.8") || intialVersion.startsWith("8.")) {
// Java 8 can have an underscore
if (!intialVersion.matches("[1-9][0-9\\.]+") && !intialVersion.matches("[1-9][0-9\\.]+_[1-9][0-9]*")) {
throw new IllegalArgumentException ("invalid version: " + intialVersion);
}
} else {
if (!intialVersion.matches("[1-9][0-9\\.]+")) {
throw new IllegalArgumentException ("invalid version: " + intialVersion);
}
}

if ((versionParts.length > 1) && !versionParts[1].matches("[1-9][0-9]*")) {
throw new IllegalArgumentException ("invalid build: " + versionParts[1]);
}

System.out.println("Version: " + properties[0]);
for (int i = 1; i < properties.length; i++) {
System.out.println("optional: " + properties[i]);
}
String plat = properties[0];
String time = properties[1];

System.out.println("Plat: " + plat);
System.out.println("TimeStamp: " + time);

System.out.println("JavaRuntimeVersion Test OK");


}

}