Skip to content

Commit 8846073

Browse files
committed
Remove IBM-1047 export options and create test config files in EBCDIC for JDK21+ on z/OS
Signed-off-by: Pasam Soujanya <[email protected]>
1 parent 83caa30 commit 8846073

File tree

6 files changed

+50
-22
lines changed

6 files changed

+50
-22
lines changed

Diff for: makefile

-8
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,8 @@ endif
3838

3939
UNAME := uname
4040
UNAME_OS := $(shell $(UNAME) -s | cut -f1 -d_)
41-
$(info UNAME_OS is $(UNAME_OS))
4241
ifeq ($(findstring CYGWIN,$(UNAME_OS)), CYGWIN)
4342
LIB_DIR:=$(shell cygpath -w $(LIB_DIR))
44-
else ifeq ($(UNAME_OS),OS/390)
45-
# The issue is still being investigated. See backlog/issues/1424
46-
# set -Dfile.encoding=IBM-1047 for JDK21+ zOS for now
47-
ifeq ($(shell test $(JDK_VERSION) -ge 21; echo $$?),0)
48-
export IBM_JAVA_OPTIONS="-Dfile.encoding=IBM-1047"
49-
$(info export IBM_JAVA_OPTIONS="-Dfile.encoding=IBM-1047")
50-
endif
5143
endif
5244

5345
export LIB_DIR:=$(subst \,/,$(LIB_DIR))

Diff for: src/org/openj9/envInfo/EnvDetector.java

+4-6
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@
1414

1515
package org.openj9.envInfo;
1616

17-
import java.io.FileOutputStream;
18-
import java.io.OutputStreamWriter;
1917
import java.io.IOException;
20-
import java.io.BufferedWriter;
18+
import java.io.Writer;
2119

2220
public class EnvDetector {
2321
static boolean isMachineInfo = false;
@@ -80,9 +78,9 @@ private static void getJavaInfo() {
8078
/**
8179
* autoGenEnv.mk file will be created to store auto detected java info.
8280
*/
83-
BufferedWriter output = null;
81+
Writer output = null;
8482
try {
85-
output = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("autoGenEnv.mk")));
83+
output = Utility.getWriterObject(javaVersionInfo, SPECInfo, "autoGenEnv.mk");
8684
output.write("########################################################\n");
8785
output.write("# This is an auto generated file. Please do NOT modify!\n");
8886
output.write("########################################################\n");
@@ -94,7 +92,7 @@ private static void getJavaInfo() {
9492
output.write(JDK_VENDOR);
9593
output.write(TEST_FLAG);
9694
output.close();
97-
output = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("AQACert.log")));
95+
output = Utility.getWriterObject(javaVersionInfo, SPECInfo, "AQACert.log");
9896
output.write(JAVA_VERSION);
9997
output.write(RELEASE_INFO);
10098
output.close();

Diff for: src/org/openj9/envInfo/Utility.java

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package org.openj9.envInfo;
2+
3+
import java.io.FileOutputStream;
4+
import java.io.FileWriter;
5+
import java.io.IOException;
6+
import java.io.OutputStreamWriter;
7+
import java.io.Writer;
8+
import java.nio.charset.Charset;
9+
10+
public class Utility {
11+
12+
public static Writer writer;
13+
14+
public static Writer getWriterObject(int jdkVersion, String SpecInfo, String fileName) {
15+
try {
16+
if (SpecInfo.toLowerCase().contains("zos") && (jdkVersion >= 21)) {
17+
writer = new OutputStreamWriter(new FileOutputStream(fileName, true), Charset.forName("IBM-1047"));
18+
} else {
19+
writer = new FileWriter(fileName, true);
20+
}
21+
} catch(IOException e) {
22+
e.printStackTrace();
23+
System.exit(1);
24+
}
25+
return writer;
26+
}
27+
}

Diff for: src/org/testKitGen/MkGen.java

+9-4
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,18 @@
1414

1515
package org.testKitGen;
1616

17-
import java.io.FileWriter;
1817
import java.io.IOException;
18+
import java.io.Writer;
1919
import java.util.ArrayList;
2020
import java.util.Collections;
2121
import java.util.List;
2222

23+
import org.openj9.envInfo.JavaInfo;
24+
import org.openj9.envInfo.Utility;
25+
2326
public class MkGen {
2427
private Arguments arg;
28+
private JavaInfo jInfo;
2529
private TestTarget tt;
2630
private List<String> dirList;
2731
private List<String> subdirs;
@@ -30,6 +34,7 @@ public class MkGen {
3034

3135
public MkGen(Arguments arg, TestTarget tt, PlaylistInfo pli, String makeFile, List<String> dirList, List<String> subdirs) {
3236
this.arg = arg;
37+
this.jInfo = new JavaInfo();
3338
this.tt = tt;
3439
this.dirList = dirList;
3540
this.subdirs = subdirs;
@@ -46,7 +51,7 @@ public void start() {
4651
}
4752

4853
private void writeVars() {
49-
try (FileWriter f = new FileWriter(makeFile)) {
54+
try (Writer f = Utility.getWriterObject(jInfo.getJDKVersion(), arg.getSpec(), makeFile)) {
5055
String realtiveRoot = "";
5156
int subdirlevel = dirList.size();
5257
if (subdirlevel == 0) {
@@ -72,7 +77,7 @@ private void writeVars() {
7277
}
7378
}
7479

75-
private void writeSingleTest(List<String> testsInPlaylist, TestInfo testInfo, FileWriter f) throws IOException {
80+
private void writeSingleTest(List<String> testsInPlaylist, TestInfo testInfo, Writer f) throws IOException {
7681
for (Variation var : testInfo.getVars()) {
7782
// Generate make target
7883
String testTargetName = var.getSubTestName();
@@ -244,7 +249,7 @@ private void writeSingleTest(List<String> testsInPlaylist, TestInfo testInfo, Fi
244249
}
245250

246251
private void writeTargets() {
247-
try (FileWriter f = new FileWriter(makeFile, true)) {
252+
try (Writer f = Utility.getWriterObject(jInfo.getJDKVersion(), arg.getSpec(), makeFile)) {
248253
if (!pli.getIncludeList().isEmpty()) {
249254
for (String include : pli.getIncludeList()) {
250255
f.write("-include " + include + "\n\n");

Diff for: src/org/testKitGen/ModesDictionary.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ private void parseInvalidSpec(Element modes) throws IOException {
9898
ArrayList<String> specs = new ArrayList<String>();
9999
int lineNum = 0;
100100
BufferedReader reader = null;
101-
if (arg.getSpec().toLowerCase().contains("zos")) {
101+
if (arg.getSpec().toLowerCase().contains("zos") && !(arg.getJdkVersion().matches("[2-9][0-9]"))) {
102102
reader = Files.newBufferedReader(Paths.get(ottawaCsv), Charset.forName("IBM-1047"));
103103
} else {
104104
reader = Files.newBufferedReader(Paths.get(ottawaCsv));

Diff for: src/org/testKitGen/UtilsGen.java

+9-3
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,26 @@
1515
package org.testKitGen;
1616

1717
import java.io.File;
18-
import java.io.FileWriter;
1918
import java.io.IOException;
19+
import java.io.Writer;
2020
import java.util.List;
2121

22+
import org.openj9.envInfo.JavaInfo;
23+
import org.openj9.envInfo.Utility;
24+
25+
2226
public class UtilsGen {
2327
private Arguments arg;
2428
private ModesDictionary md;
29+
private JavaInfo jInfo;
2530
private String utilsMk;
2631
private String rerunMk;
2732
private List<String> ignoreOnRerunList;
2833

2934
public UtilsGen(Arguments arg, ModesDictionary md, List<String> ignoreOnRerunList) {
3035
this.arg = arg;
3136
this.md = md;
37+
this.jInfo = new JavaInfo();
3238
this.utilsMk = arg.getProjectRootDir() + "/TKG/" + Constants.UTILSMK;
3339
this.rerunMk = arg.getProjectRootDir() + "/TKG/" + Constants.RERUNMK;
3440
this.ignoreOnRerunList = ignoreOnRerunList;
@@ -40,7 +46,7 @@ public void generateFiles() {
4046
}
4147

4248
private void generateUtil() {
43-
try (FileWriter f = new FileWriter(utilsMk)) {
49+
try (Writer f = Utility.getWriterObject(jInfo.getJDKVersion(), arg.getSpec(), utilsMk)) {
4450
f.write(Constants.HEADERCOMMENTS);
4551
f.write("TOTALCOUNT := " + TestInfo.numOfTests() + "\n");
4652
f.write("PLATFORM=\n");
@@ -56,7 +62,7 @@ private void generateUtil() {
5662
}
5763

5864
private void generateRerun() {
59-
try (FileWriter f = new FileWriter(rerunMk)) {
65+
try (Writer f = Utility.getWriterObject(jInfo.getJDKVersion(), arg.getSpec(), rerunMk)) {
6066
f.write(Constants.HEADERCOMMENTS);
6167
String ignoreOnRerunStr = String.join(",", ignoreOnRerunList);
6268
f.write("IGNORE_ON_RERUN=");

0 commit comments

Comments
 (0)