Skip to content

Commit

Permalink
8301119: Support for GB18030-2022
Browse files Browse the repository at this point in the history
Reviewed-by: alanb, coffeys, lancea
  • Loading branch information
naotoj committed Feb 27, 2023
1 parent 55e6bb6 commit a253b46
Show file tree
Hide file tree
Showing 14 changed files with 232 additions and 156 deletions.
12 changes: 6 additions & 6 deletions make/data/charsetmapping/charsets
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -476,6 +476,11 @@ charset x-IBM874 IBM874
alias ibm-874
alias 874

# alias for GB18030 is generated at runtime
charset GB18030 GB18030
package sun.nio.cs
type source

########################################################
#
# charsets provided by ExtendedCharsets provider.
Expand Down Expand Up @@ -563,11 +568,6 @@ charset GBK GBK # Simplified Chinese
alias windows-936
alias CP936

charset GB18030 GB18030
package sun.nio.cs.ext
type template
alias gb18030-2000

charset GB2312 EUC_CN
package sun.nio.cs.ext
type dbcs
Expand Down
1 change: 0 additions & 1 deletion make/data/charsetmapping/stdcs-aix
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ Big5_HKSCS
EUC_CN
EUC_KR
GBK
GB18030
IBM856
IBM921
IBM922
Expand Down
1 change: 0 additions & 1 deletion make/data/charsetmapping/stdcs-linux
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ EUC_JP_LINUX
EUC_JP_Open
EUC_TW
GBK
GB18030
ISO_8859_11
ISO_8859_3
ISO_8859_6
Expand Down
26 changes: 0 additions & 26 deletions make/data/charsetmapping/stdcs-solaris

This file was deleted.

1 change: 0 additions & 1 deletion make/data/charsetmapping/stdcs-windows
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# generate these charsets into sun.nio.cs
#
GBK
GB18030
Johab
MS1255
MS1256
Expand Down
38 changes: 23 additions & 15 deletions make/jdk/src/classes/build/tools/charsetmapping/SPI.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -50,18 +50,19 @@ public static void genClass(String type,
out.println(line);
} else {
charsets.values()
.stream()
.filter(cs -> cs.pkgName.equals("sun.nio.cs.ext") &&
!cs.isInternal &&
(cs.os == null || cs.os.equals(os)))
.forEach( cs -> {
out.printf(" charset(\"%s\", \"%s\",%n", cs.csName, cs.clzName);
out.printf(" new String[] {%n");
for (String alias : cs.aliases) {
out.printf(" \"%s\",%n", alias);
}
out.printf(" });%n%n");
});
.stream()
.filter(cs -> cs.pkgName.equals("sun.nio.cs.ext") &&
!cs.isInternal &&
(cs.os == null || cs.os.equals(os)))
.forEach( cs -> {
out.printf(" charset(\"%s\", \"%s\",%n", cs.csName, cs.clzName);
out.printf(" new String[] {%n");
for (String alias : cs.aliases) {
out.printf(" \"%s\",%n",
alias);
}
out.printf(" });%n%n");
});
}
}
} else if (type.startsWith("stdcs")) { // StandardCharsets.java
Expand Down Expand Up @@ -93,8 +94,15 @@ public static void genClass(String type,
.filter(cs -> cs.pkgName.equals("sun.nio.cs"))
.forEach( cs -> {
if (cs.aliases == null || cs.aliases.length == 0) {
out.printf(" static String[] aliases_%s() { return null; }%n%n",
cs.clzName);
if (cs.csName.equals("GB18030")) {
out.printf(" static String[] aliases_GB18030() { return new String[] {%n");
out.printf(" GB18030.IS_2000 ? \"gb18030-2000\" : \"gb18030-2022\"%n");
out.printf(" };%n");
out.printf(" }%n%n");
} else {
out.printf(" static String[] aliases_%s() { return null; }%n%n",
cs.clzName);
}
} else {
boolean methodEnd = true;
// non-final for SJIS and MS932 to support sun.nio.cs.map
Expand Down

3 comments on commit a253b46

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gnu-andrew
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk17u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on a253b46 May 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gnu-andrew Could not automatically backport a253b460 to openjdk/jdk17u-dev due to conflicts in the following files:

  • make/data/charsetmapping/charsets
  • test/jdk/java/nio/charset/Charset/RegisteredCharsets.java

Please fetch the appropriate branch/commit and manually resolve these conflicts by using the following commands in your personal fork of openjdk/jdk17u-dev. Note: these commands are just some suggestions and you can use other equivalent commands you know.

# Fetch the up-to-date version of the target branch
$ git fetch --no-tags https://git.openjdk.org/jdk17u-dev.git master:master

# Check out the target branch and create your own branch to backport
$ git checkout master
$ git checkout -b gnu-andrew-backport-a253b460

# Fetch the commit you want to backport
$ git fetch --no-tags https://git.openjdk.org/jdk.git a253b4602147633a3d2e83775d1feef4f12a5272

# Backport the commit
$ git cherry-pick --no-commit a253b4602147633a3d2e83775d1feef4f12a5272
# Resolve conflicts now

# Commit the files you have modified
$ git add files/with/resolved/conflicts
$ git commit -m 'Backport a253b4602147633a3d2e83775d1feef4f12a5272'

Once you have resolved the conflicts as explained above continue with creating a pull request towards the openjdk/jdk17u-dev with the title Backport a253b4602147633a3d2e83775d1feef4f12a5272.

Please sign in to comment.