Skip to content

Commit 65a02da

Browse files
committed
8303476: Add the runtime version in the release file of a JDK image
Backport-of: 32247c336a189a40f696626a2578c65535ef6376
1 parent 07993bf commit 65a02da

File tree

2 files changed

+36
-12
lines changed

2 files changed

+36
-12
lines changed

make/ReleaseFile.gmk

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ define create-info-file
5151
$(if $(VENDOR_VERSION_STRING), \
5252
$(call info-file-item, "IMPLEMENTOR_VERSION", "$(VENDOR_VERSION_STRING)"))
5353
$(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
54+
$(call info-file-item, "JAVA_RUNTIME_VERSION", "$(VERSION_STRING)")
5455
$(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
5556
$(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
5657
$(call info-file-item, "LIBC", "$(RELEASE_FILE_LIBC)")

test/jdk/build/releaseFile/CheckSource.java renamed to test/jdk/build/releaseFile/CheckReleaseFile.java

+35-12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
21
/*
3-
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
43
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
54
*
65
* This code is free software; you can redistribute it and/or modify it
@@ -24,9 +23,9 @@
2423

2524
/*
2625
* @test
27-
* @bug 8193660
28-
* @summary Check SOURCE line in "release" file for closedjdk
29-
* @run main CheckSource
26+
* @bug 8193660 8303476
27+
* @summary Check SOURCE line and JAVA_RUNTIME_VERSION in "release" file
28+
* @run main CheckReleaseFile
3029
*/
3130

3231
import java.io.BufferedReader;
@@ -37,18 +36,21 @@
3736
import java.util.regex.Matcher;
3837
import java.util.regex.Pattern;
3938

40-
public class CheckSource {
39+
public class CheckReleaseFile {
4140

4241
public static final String SRC_HASH_REGEXP = ":((hg)|(git)):[a-z0-9]*\\+?";
4342

44-
CheckSource(String dataFile, boolean isOpenJDK) {
43+
private final boolean isOpenJDK;
44+
CheckReleaseFile(String dataFile, boolean isOpenJDK) {
45+
this.isOpenJDK = isOpenJDK;
4546
// Read data files
46-
readFile(dataFile, isOpenJDK);
47+
readFile(dataFile);
4748
}
4849

49-
private void readFile(String fileName, boolean isOpenJDK) {
50+
private void readFile(String fileName) {
5051
String fishForSOURCE = null;
5152
String implementor = null;
53+
String runtimeVersion = null;
5254

5355
File file = new File(fileName);
5456

@@ -78,6 +80,12 @@ private void readFile(String fileName, boolean isOpenJDK) {
7880
implementor = readIn;
7981
continue;
8082
}
83+
84+
// grab JAVA_RUNTIME_VERSION line
85+
if (readIn.startsWith("JAVA_RUNTIME_VERSION=")) {
86+
runtimeVersion = readIn;
87+
continue;
88+
}
8189
}
8290
} catch (FileNotFoundException fileExcept) {
8391
throw new RuntimeException("File " + fileName +
@@ -91,6 +99,23 @@ private void readFile(String fileName, boolean isOpenJDK) {
9199
if (fishForSOURCE == null) {
92100
throw new RuntimeException("SOURCE line was not found!");
93101
}
102+
103+
// Check if implementor is Oracle
104+
boolean isOracle = (implementor != null) && implementor.contains("Oracle Corporation");
105+
checkSource(fishForSOURCE, isOracle);
106+
107+
if (runtimeVersion == null) {
108+
throw new RuntimeException("JAVA_RUNTIME_VERSION line was not found!");
109+
}
110+
String expected = "JAVA_RUNTIME_VERSION=\"" + Runtime.version() + "\"";
111+
if (!expected.equals(runtimeVersion)) {
112+
throw new RuntimeException("Mismatched runtime version: " +
113+
runtimeVersion + " expected: " + expected);
114+
}
115+
}
116+
117+
private void checkSource(String fishForSOURCE, boolean isOracle) {
118+
94119
System.out.println("The source string found: " + fishForSOURCE);
95120

96121
// Extract the value of SOURCE=
@@ -101,8 +126,6 @@ private void readFile(String fileName, boolean isOpenJDK) {
101126
}
102127
String valueString = valueMatcher.group(1);
103128

104-
// Check if implementor is Oracle
105-
boolean isOracle = (implementor != null) && implementor.contains("Oracle Corporation");
106129

107130
String[] values = valueString.split(" ");
108131

@@ -144,6 +167,6 @@ public static void main(String args[]) {
144167
System.out.println("JDK Path : " + jdkPath);
145168
System.out.println("Runtime Name : " + runtime);
146169

147-
new CheckSource(jdkPath + "/release", runtime.contains("OpenJDK"));
170+
new CheckReleaseFile(jdkPath + "/release", runtime.contains("OpenJDK"));
148171
}
149172
}

0 commit comments

Comments
 (0)