From 8ee1faafdd31d2b7f9e39f06f4d6966511684e7d Mon Sep 17 00:00:00 2001 From: Pasam Soujanya Date: Mon, 9 Dec 2024 19:56:15 +0530 Subject: [PATCH] Remove IBM-1047 export option and generate makefiles on JDK21+ z/OS in IBM-1047 encoding Signed-off-by: Pasam Soujanya --- makefile | 8 -------- src/org/openj9/envInfo/EnvDetector.java | 13 +++++++++++-- src/org/testKitGen/MkGen.java | 25 ++++++++++++++++++++++--- src/org/testKitGen/ModesDictionary.java | 2 +- src/org/testKitGen/UtilsGen.java | 8 +++++--- 5 files changed, 39 insertions(+), 17 deletions(-) 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..b0aff779 100644 --- a/src/org/openj9/envInfo/EnvDetector.java +++ b/src/org/openj9/envInfo/EnvDetector.java @@ -16,6 +16,7 @@ import java.io.FileOutputStream; import java.io.OutputStreamWriter; +import java.nio.charset.Charset; import java.io.IOException; import java.io.BufferedWriter; @@ -82,7 +83,11 @@ private static void getJavaInfo() { */ BufferedWriter output = null; try { - output = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("autoGenEnv.mk"))); + if ((javaVersionInfo >= 21) && SPECInfo.contains("zos")) { + output = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("autoGenEnv.mk"), Charset.forName("IBM-1047"))); + } else { + output = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("autoGenEnv.mk"))); + } output.write("########################################################\n"); output.write("# This is an auto generated file. Please do NOT modify!\n"); output.write("########################################################\n"); @@ -94,7 +99,11 @@ private static void getJavaInfo() { output.write(JDK_VENDOR); output.write(TEST_FLAG); output.close(); - output = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("AQACert.log"))); + if ((javaVersionInfo >= 21) && SPECInfo.contains("zos")) { + output = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("AQACert.log"), Charset.forName("IBM-1047"))); + } else { + output = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("AQACert.log"))); + } output.write(JAVA_VERSION); output.write(RELEASE_INFO); output.close(); diff --git a/src/org/testKitGen/MkGen.java b/src/org/testKitGen/MkGen.java index 15ed029c..f1d39542 100644 --- a/src/org/testKitGen/MkGen.java +++ b/src/org/testKitGen/MkGen.java @@ -14,8 +14,12 @@ package org.testKitGen; +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; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -27,6 +31,7 @@ public class MkGen { private List subdirs; private String makeFile; private PlaylistInfo pli; + private Writer writer; public MkGen(Arguments arg, TestTarget tt, PlaylistInfo pli, String makeFile, List dirList, List subdirs) { this.arg = arg; @@ -46,7 +51,7 @@ public void start() { } private void writeVars() { - try (FileWriter f = new FileWriter(makeFile)) { + try (Writer f = getWriterObject(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 = getWriterObject(makeFile)) { if (!pli.getIncludeList().isEmpty()) { for (String include : pli.getIncludeList()) { f.write("-include " + include + "\n\n"); @@ -251,4 +256,18 @@ private void writeTargets() { System.exit(1); } } + + public Writer getWriterObject(String filetype) { + try { + if (arg.getSpec().toLowerCase().contains("zos") && (arg.getJdkVersion().matches("2\\d"))) { + writer = new OutputStreamWriter(new FileOutputStream(filetype, true), Charset.forName("IBM-1047")); + } else { + writer = new FileWriter(filetype, true); + } + } catch(IOException e) { + e.printStackTrace(); + System.exit(1); + } + return writer; + } } \ No newline at end of file diff --git a/src/org/testKitGen/ModesDictionary.java b/src/org/testKitGen/ModesDictionary.java index 7ddfa383..173f1c81 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\\d"))) { 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..671eb2ee 100644 --- a/src/org/testKitGen/UtilsGen.java +++ b/src/org/testKitGen/UtilsGen.java @@ -15,13 +15,14 @@ package org.testKitGen; import java.io.File; -import java.io.FileWriter; import java.io.IOException; +import java.io.Writer; import java.util.List; public class UtilsGen { private Arguments arg; private ModesDictionary md; + private MkGen mg; private String utilsMk; private String rerunMk; private List ignoreOnRerunList; @@ -29,6 +30,7 @@ public class UtilsGen { public UtilsGen(Arguments arg, ModesDictionary md, List ignoreOnRerunList) { this.arg = arg; this.md = md; + this.mg = new MkGen(arg, null, null, rerunMk, ignoreOnRerunList, ignoreOnRerunList); this.utilsMk = arg.getProjectRootDir() + "/TKG/" + Constants.UTILSMK; this.rerunMk = arg.getProjectRootDir() + "/TKG/" + Constants.RERUNMK; this.ignoreOnRerunList = ignoreOnRerunList; @@ -40,7 +42,7 @@ public void generateFiles() { } private void generateUtil() { - try (FileWriter f = new FileWriter(utilsMk)) { + try (Writer f = mg.getWriterObject(utilsMk)) { f.write(Constants.HEADERCOMMENTS); f.write("TOTALCOUNT := " + TestInfo.numOfTests() + "\n"); f.write("PLATFORM=\n"); @@ -56,7 +58,7 @@ private void generateUtil() { } private void generateRerun() { - try (FileWriter f = new FileWriter(rerunMk)) { + try (Writer f = mg.getWriterObject(rerunMk)) { f.write(Constants.HEADERCOMMENTS); String ignoreOnRerunStr = String.join(",", ignoreOnRerunList); f.write("IGNORE_ON_RERUN=");