0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

z/OSにおけるJEP 400 (UTF-8 by Default)の影響とWAS for z/OS Libertyでの検証

Last updated at Posted at 2025-11-14

Java 18より、JEP 400: UTF-8 by Defaultが実装されています。これは、ファイルの読み書きなどで使用されるデフォルトの文字セットがUTF-8になるというもので、z/OS上でもIBM Semeru Runtime Certified Edition for z/OS 21より実装されています。

そこで、具体的にencoding設定がどう変わるのかを確認しました。
(特に、z/OS上のWebSphere Application Server(WAS)は、file.encodingを自身で設定するため、WAS for z/OS Liberty上でも確認しました)

実機確認

確認したJavaバージョン

java version "21.0.8" 2025-07-15
IBM Semeru Runtime Certified Edition for z/OS 21.0.8.0 (build 21.0.8+9)
IBM J9 VM 21.0.8.0 (build z/OS-Release-21.0.8.0-b01, JRE 21 z/OS s390x-64-Bit Compressed References 20250730_39 (JIT enabled, AOT enabled)
OpenJ9   - e44cda8da2f
OMR      - 4824bf33bc9
IBM      - 8e661b7
JCL      - d6a6ca63d4a based on jdk-21.0.8+9)

Javaコマンドで確認

file.encodingが、
IBM SDK for z/OS, Java Technology Edition 8ではIBM-1047でしたが、
IBM Semeru Runtime Certified Edition for z/OS 21ではUTF-8に変わっています。

/usr/lpp/WebSphere/WL250010/wlp/java/21.0/bin/java PrintProperties
sun.jnu.encoding=IBM-1047
stdout.encoding=IBM-1047
file.encoding=UTF-8
os.encoding=ISO8859_1
native.encoding=IBM-1047
stderr.encoding=IBM-1047
ibm.system.encoding=IBM-1047
sun.io.unicode.encoding=UnicodeBig

WAS for z/OS Liberty上で確認

WAS for z/OS Libertyがfile.encodingiso8859-1に変えています。
IBM SDK for z/OS, Java Technology Edition 8で動かした場合も、
IBM Semeru Runtime Certified Edition for z/OS 21で動かした場合も同じです。

$ curl -s -H "accept: application/json" http://xxx.xxx.xxx.xxx:nnnnn/app-name/api/properties/get | jq
{
  "native.encoding": "IBM-1047",
  "file.encoding": "iso8859-1",
  "stderr.encoding": "IBM-1047",
  "ibm.system.encoding": "IBM-1047",
  "sun.jnu.encoding": "IBM-1047",
  "sun.io.unicode.encoding": "UnicodeBig",
  "stdout.encoding": "IBM-1047",
  "os.encoding": "ISO8859_1"

参考)確認に使用したプログラム

Javaコマンドで実行したプログラム

public class PrintProperties {
    public static void main(String[] args) {
        System.getProperties().stringPropertyNames().stream()
        .filter(name -> name.contains("encoding"))
        .forEach(name -> System.out.println(name + "=" + System.getProperty(name)));
    }
}

WAS for z/OS Liberty上で稼働したJakarta RESTful Web Services (JAX-RS) プログラム

package com.demo.rest;

import java.util.Map;
import java.util.stream.Collectors;

import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;

@Path("properties")
public class PrintProperties {
    @GET
    @Path("get")
    public Map<String, String> get() {
        return System.getProperties().stringPropertyNames().stream()
        .filter(name -> name.contains("encoding"))
        .collect(Collectors.toMap(name -> name, System::getProperty));
    }
}

まとめ

まずは簡単にencoding設定を確認してみました。

  • WAS for z/OS Liberty上のアプリケーションでは、JEP 400の影響は基本的にはなさそうです。WAS for z/OS Libertyが独自にfile.encodingを設定しているためです。
  • Javaコマンドを使用している場合は、デフォルトのファイルの読み書きがIBM-1047からUTF-8に変更されます。zFS上のファイルの読み書きで文字化けが発生する可能性があるため、z/OS上でJavaソースコードのコンパイルやスクリプトを実行している場合などは、明示的にencodingを指定する必要があります。
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?