From 137cecfb50d63288d390e05be8644404dac2e466 Mon Sep 17 00:00:00 2001 From: Pasam Soujanya Date: Thu, 12 Dec 2024 16:28:42 +0530 Subject: [PATCH 1/2] Remove IBM-1047 export options and create test config files in EBCDIC for JDK21+ on z/OS Signed-off-by: Pasam Soujanya --- makefile | 8 -------- src/org/openj9/envInfo/EnvDetector.java | 10 ++++----- src/org/openj9/envInfo/Utility.java | 27 +++++++++++++++++++++++++ src/org/testKitGen/MkGen.java | 13 ++++++++---- src/org/testKitGen/ModesDictionary.java | 2 +- src/org/testKitGen/UtilsGen.java | 12 ++++++++--- 6 files changed, 50 insertions(+), 22 deletions(-) create mode 100644 src/org/openj9/envInfo/Utility.java diff --git a/makefile b/makefile index 882e3950..8ee20d2e 100644 --- a/makefile +++ b/makefile @@ -38,16 +38,8 @@ endif UNAME := uname UNAME_OS := $(shell $(UNAME) -s | cut -f1 -d_) -$(info UNAME_OS is $(UNAME_OS)) ifeq ($(findstring CYGWIN,$(UNAME_OS)), CYGWIN) LIB_DIR:=$(shell cygpath -w $(LIB_DIR)) -else ifeq ($(UNAME_OS),OS/390) -# The issue is still being investigated. See backlog/issues/1424 -# set -Dfile.encoding=IBM-1047 for JDK21+ zOS for now -ifeq ($(shell test $(JDK_VERSION) -ge 21; echo $$?),0) -export IBM_JAVA_OPTIONS="-Dfile.encoding=IBM-1047" -$(info export IBM_JAVA_OPTIONS="-Dfile.encoding=IBM-1047") -endif endif export LIB_DIR:=$(subst \,/,$(LIB_DIR)) diff --git a/src/org/openj9/envInfo/EnvDetector.java b/src/org/openj9/envInfo/EnvDetector.java index 391bf8cf..67d93cc1 100644 --- a/src/org/openj9/envInfo/EnvDetector.java +++ b/src/org/openj9/envInfo/EnvDetector.java @@ -14,10 +14,8 @@ package org.openj9.envInfo; -import java.io.FileOutputStream; -import java.io.OutputStreamWriter; import java.io.IOException; -import java.io.BufferedWriter; +import java.io.Writer; public class EnvDetector { static boolean isMachineInfo = false; @@ -80,9 +78,9 @@ private static void getJavaInfo() { /** * autoGenEnv.mk file will be created to store auto detected java info. */ - BufferedWriter output = null; + Writer output = null; try { - output = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("autoGenEnv.mk"))); + output = Utility.getWriterObject(javaVersionInfo, SPECInfo, "autoGenEnv.mk"); output.write("########################################################\n"); output.write("# This is an auto generated file. Please do NOT modify!\n"); output.write("########################################################\n"); @@ -94,7 +92,7 @@ private static void getJavaInfo() { output.write(JDK_VENDOR); output.write(TEST_FLAG); output.close(); - output = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("AQACert.log"))); + output = Utility.getWriterObject(javaVersionInfo, SPECInfo, "AQACert.log"); output.write(JAVA_VERSION); output.write(RELEASE_INFO); output.close(); diff --git a/src/org/openj9/envInfo/Utility.java b/src/org/openj9/envInfo/Utility.java new file mode 100644 index 00000000..1873d3d8 --- /dev/null +++ b/src/org/openj9/envInfo/Utility.java @@ -0,0 +1,27 @@ +package org.openj9.envInfo; + +import java.io.FileOutputStream; +import java.io.FileWriter; +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.io.Writer; +import java.nio.charset.Charset; + +public class Utility { + + public static Writer writer; + + public static Writer getWriterObject(int jdkVersion, String SpecInfo, String fileName) { + try { + if (SpecInfo.toLowerCase().contains("zos") && (jdkVersion >= 21)) { + writer = new OutputStreamWriter(new FileOutputStream(fileName, true), Charset.forName("IBM-1047")); + } else { + writer = new FileWriter(fileName, true); + } + } catch(IOException e) { + e.printStackTrace(); + System.exit(1); + } + return writer; + } +} diff --git a/src/org/testKitGen/MkGen.java b/src/org/testKitGen/MkGen.java index 15ed029c..c37e23b3 100644 --- a/src/org/testKitGen/MkGen.java +++ b/src/org/testKitGen/MkGen.java @@ -14,14 +14,18 @@ package org.testKitGen; -import java.io.FileWriter; import java.io.IOException; +import java.io.Writer; import java.util.ArrayList; import java.util.Collections; import java.util.List; +import org.openj9.envInfo.JavaInfo; +import org.openj9.envInfo.Utility; + public class MkGen { private Arguments arg; + private JavaInfo jInfo; private TestTarget tt; private List dirList; private List subdirs; @@ -30,6 +34,7 @@ public class MkGen { public MkGen(Arguments arg, TestTarget tt, PlaylistInfo pli, String makeFile, List dirList, List subdirs) { this.arg = arg; + this.jInfo = new JavaInfo(); this.tt = tt; this.dirList = dirList; this.subdirs = subdirs; @@ -46,7 +51,7 @@ public void start() { } private void writeVars() { - try (FileWriter f = new FileWriter(makeFile)) { + try (Writer f = Utility.getWriterObject(jInfo.getJDKVersion(), arg.getSpec(), makeFile)) { String realtiveRoot = ""; int subdirlevel = dirList.size(); if (subdirlevel == 0) { @@ -72,7 +77,7 @@ private void writeVars() { } } - private void writeSingleTest(List testsInPlaylist, TestInfo testInfo, FileWriter f) throws IOException { + private void writeSingleTest(List testsInPlaylist, TestInfo testInfo, Writer f) throws IOException { for (Variation var : testInfo.getVars()) { // Generate make target String testTargetName = var.getSubTestName(); @@ -227,7 +232,7 @@ private void writeSingleTest(List testsInPlaylist, TestInfo testInfo, Fi } private void writeTargets() { - try (FileWriter f = new FileWriter(makeFile, true)) { + try (Writer f = Utility.getWriterObject(jInfo.getJDKVersion(), arg.getSpec(), makeFile)) { if (!pli.getIncludeList().isEmpty()) { for (String include : pli.getIncludeList()) { f.write("-include " + include + "\n\n"); diff --git a/src/org/testKitGen/ModesDictionary.java b/src/org/testKitGen/ModesDictionary.java index 7ddfa383..c36b5a4b 100644 --- a/src/org/testKitGen/ModesDictionary.java +++ b/src/org/testKitGen/ModesDictionary.java @@ -98,7 +98,7 @@ private void parseInvalidSpec(Element modes) throws IOException { ArrayList specs = new ArrayList(); int lineNum = 0; BufferedReader reader = null; - if (arg.getSpec().toLowerCase().contains("zos")) { + if (arg.getSpec().toLowerCase().contains("zos") && !(arg.getJdkVersion().matches("[2-9][0-9]"))) { reader = Files.newBufferedReader(Paths.get(ottawaCsv), Charset.forName("IBM-1047")); } else { reader = Files.newBufferedReader(Paths.get(ottawaCsv)); diff --git a/src/org/testKitGen/UtilsGen.java b/src/org/testKitGen/UtilsGen.java index 990b4fed..cb1ef247 100644 --- a/src/org/testKitGen/UtilsGen.java +++ b/src/org/testKitGen/UtilsGen.java @@ -15,13 +15,18 @@ package org.testKitGen; import java.io.File; -import java.io.FileWriter; import java.io.IOException; +import java.io.Writer; import java.util.List; +import org.openj9.envInfo.JavaInfo; +import org.openj9.envInfo.Utility; + + public class UtilsGen { private Arguments arg; private ModesDictionary md; + private JavaInfo jInfo; private String utilsMk; private String rerunMk; private List ignoreOnRerunList; @@ -29,6 +34,7 @@ public class UtilsGen { public UtilsGen(Arguments arg, ModesDictionary md, List ignoreOnRerunList) { this.arg = arg; this.md = md; + this.jInfo = new JavaInfo(); this.utilsMk = arg.getProjectRootDir() + "/TKG/" + Constants.UTILSMK; this.rerunMk = arg.getProjectRootDir() + "/TKG/" + Constants.RERUNMK; this.ignoreOnRerunList = ignoreOnRerunList; @@ -40,7 +46,7 @@ public void generateFiles() { } private void generateUtil() { - try (FileWriter f = new FileWriter(utilsMk)) { + try (Writer f = Utility.getWriterObject(jInfo.getJDKVersion(), arg.getSpec(), utilsMk)) { f.write(Constants.HEADERCOMMENTS); f.write("TOTALCOUNT := " + TestInfo.numOfTests() + "\n"); f.write("PLATFORM=\n"); @@ -56,7 +62,7 @@ private void generateUtil() { } private void generateRerun() { - try (FileWriter f = new FileWriter(rerunMk)) { + try (Writer f = Utility.getWriterObject(jInfo.getJDKVersion(), arg.getSpec(), rerunMk)) { f.write(Constants.HEADERCOMMENTS); String ignoreOnRerunStr = String.join(",", ignoreOnRerunList); f.write("IGNORE_ON_RERUN="); From a95bb77b2b4bea8b14877eb2f5b7b46af944e249 Mon Sep 17 00:00:00 2001 From: Pasam Soujanya Date: Tue, 17 Dec 2024 09:43:07 +0530 Subject: [PATCH 2/2] Remove using IBM_JAVA_OPTIONS --- src/org/testKitGen/ModesDictionary.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/org/testKitGen/ModesDictionary.java b/src/org/testKitGen/ModesDictionary.java index c36b5a4b..166cf28a 100644 --- a/src/org/testKitGen/ModesDictionary.java +++ b/src/org/testKitGen/ModesDictionary.java @@ -29,12 +29,14 @@ import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; +import org.openj9.envInfo.JavaInfo; import org.w3c.dom.Element; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; public class ModesDictionary { private Arguments arg; + private JavaInfo jInfo; private String modesXml; private String ottawaCsv; private Map spec2platMap; @@ -44,6 +46,7 @@ public class ModesDictionary { public ModesDictionary(Arguments arg) { this.arg = arg; + jInfo = new JavaInfo(); modesXml= arg.getProjectRootDir() + "/TKG/" + Constants.MODESXML; ottawaCsv = arg.getProjectRootDir() + "/TKG/" + Constants.OTTAWACSV; spec2platMap = new HashMap(); @@ -98,7 +101,7 @@ private void parseInvalidSpec(Element modes) throws IOException { ArrayList specs = new ArrayList(); int lineNum = 0; BufferedReader reader = null; - if (arg.getSpec().toLowerCase().contains("zos") && !(arg.getJdkVersion().matches("[2-9][0-9]"))) { + if (arg.getSpec().toLowerCase().contains("zos") && !(jInfo.getJDKVersion() >= 21)) { reader = Files.newBufferedReader(Paths.get(ottawaCsv), Charset.forName("IBM-1047")); } else { reader = Files.newBufferedReader(Paths.get(ottawaCsv));