[foreign-memaccess+abi] RFR: Avoid using StandardCharset in Java code

Jorn Vernee jvernee at openjdk.org
Mon Aug 14 16:58:03 UTC 2023


On Mon, 14 Aug 2023 11:29:54 GMT, Per Minborg <pminborg at openjdk.org> wrote:

> According to a comment in `java.nio.charset.StandardCharsets`, the use of this class should be avoided from elsewhere in the `jdk.base` module. This PR proposes removing all such direct use of said class in Java code (but not in JavaDocs).
> 
> 
> public final class StandardCharsets {
> 
>     // To avoid accidental eager initialization of often unused Charsets
>     // from happening while the VM is booting up, which may delay
>     // initialization of VM components, we should generally avoid depending
>     // on this class from elsewhere in java.base.

src/java.base/share/classes/jdk/internal/foreign/StringSupport.java line 251:

> 249:                 case "UTF-32LE", "UTF-32BE", "UTF-32" -> CharsetKind.QUAD_BYTE;
> 250:                 default -> throw new UnsupportedOperationException("Unsupported charset: " + charset);
> 251:             };

You might want to run the StrLenTest benchmark to see if this change has any effect on it.

-------------

PR Review Comment: https://git.openjdk.org/panama-foreign/pull/864#discussion_r1293723434


More information about the panama-dev mailing list