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

Remove -Dfile.encoding=IBM-1047 for JDK21 zOS #608

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
11 changes: 4 additions & 7 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,15 @@ 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
else ifeq ($(UNAME), OS/390)
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")
JVM_OPTIONS:= "-Dfile.encoding=IBM-1047"
endif
endif


export LIB_DIR:=$(subst \,/,$(LIB_DIR))
$(info LIB_DIR is set to $(LIB_DIR))

Expand Down Expand Up @@ -90,7 +87,7 @@ compile: buildListGen
# If AUTO_DETECT is turned on, compile and execute envDetector in build_envInfo.xml.
#######################################
envDetect: compileTools
${TEST_JDK_HOME}$(D)bin$(D)java -cp .$(D)bin$(D)TestKitGen.jar org.openj9.envInfo.EnvDetector
${TEST_JDK_HOME}$(D)bin$(D)java ${JVM_OPTIONS} -cp .$(D)bin$(D)TestKitGen.jar org.openj9.envInfo.EnvDetector

#######################################
# Generate refined BUILD_LIST.
Expand Down
25 changes: 22 additions & 3 deletions src/org/testKitGen/MkGen.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -27,6 +31,7 @@ public class MkGen {
private List<String> subdirs;
private String makeFile;
private PlaylistInfo pli;
private Writer writer;

public MkGen(Arguments arg, TestTarget tt, PlaylistInfo pli, String makeFile, List<String> dirList, List<String> subdirs) {
this.arg = arg;
Expand All @@ -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) {
Expand All @@ -72,7 +77,7 @@ private void writeVars() {
}
}

private void writeSingleTest(List<String> testsInPlaylist, TestInfo testInfo, FileWriter f) throws IOException {
private void writeSingleTest(List<String> testsInPlaylist, TestInfo testInfo, Writer f) throws IOException {
for (Variation var : testInfo.getVars()) {
// Generate make target
String testTargetName = var.getSubTestName();
Expand Down Expand Up @@ -227,7 +232,7 @@ private void writeSingleTest(List<String> 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");
Expand All @@ -251,4 +256,18 @@ private void writeTargets() {
System.exit(1);
}
}

public Writer getWriterObject(String filetype) {
try {
if (arg.getSpec().toLowerCase().contains("zos") && (arg.getJdkVersion().equals("21"))) {
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;
}
}
2 changes: 1 addition & 1 deletion src/org/testKitGen/ModesDictionary.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ private void parseInvalidSpec(Element modes) throws IOException {
ArrayList<String> specs = new ArrayList<String>();
int lineNum = 0;
BufferedReader reader = null;
if (arg.getSpec().toLowerCase().contains("zos")) {
if (arg.getSpec().toLowerCase().contains("zos") && !(arg.getJdkVersion().equals("21"))) {
reader = Files.newBufferedReader(Paths.get(ottawaCsv), Charset.forName("IBM-1047"));
} else {
reader = Files.newBufferedReader(Paths.get(ottawaCsv));
Expand Down
7 changes: 4 additions & 3 deletions src/org/testKitGen/UtilsGen.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> ignoreOnRerunList;
Expand All @@ -40,7 +41,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");
Expand All @@ -56,7 +57,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=");
Expand Down