[jira] [Commented] (GROOVY-9401) JsonOutput.prettyPrint generates string with null bytes on OpenJ9 JVM

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (GROOVY-9401) JsonOutput.prettyPrint generates string with null bytes on OpenJ9 JVM

Marcin Zajaczkowski (Jira)

    [ https://issues.apache.org/jira/browse/GROOVY-9401?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17037981#comment-17037981 ]

Giovanni Pardini commented on GROOVY-9401:
------------------------------------------

Looks like {{DirectFastStringService}} directly accesses the internal field {{private final char[] value}} of the {{String}} class. However, in the OpenJ9 implementation of {{String}} that field is not meant to be directly accessed (for example, it may be compressed). See the implementation of method {{char[] toCharArray()}} at https://github.com/eclipse/openj9/blob/d8e6e0f0bc709693994a1a797524696ce721bef8/jcl/src/java.base/share/classes/java/lang/String.java#L6607

> JsonOutput.prettyPrint generates string with null bytes on OpenJ9 JVM
> ---------------------------------------------------------------------
>
>                 Key: GROOVY-9401
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9401
>             Project: Groovy
>          Issue Type: Bug
>          Components: JSON
>    Affects Versions: 2.5.9
>         Environment: Ubuntu 18.04.4 LTS
> JVM
> DEB package: adoptopenjdk-8-openj9 8u242-b08.openj9-0.18.1-2
> openjdk version "1.8.0_242"
> OpenJDK Runtime Environment (build 1.8.0_242-b08)
> Eclipse OpenJ9 VM (build openj9-0.18.1, JRE 1.8.0 Linux amd64-64-Bit Compressed References 20200122_511 (JIT enabled, AOT enabled)
> OpenJ9   - 51a5857d2
> OMR      - 7a1b0239a
> JCL      - 8cf8a30581 based on jdk8u242-b08)
>            Reporter: Giovanni Pardini
>            Priority: Major
>             Fix For: 3.0.0
>
>
> Using OpenJDK with Eclipse OpenJ9 JVM from [https://adoptopenjdk.net/,] the method JsonOutput.prettyPrint() generates a string which contains null bytes.
> h3. {{TEST CODE}}
> {code:groovy}
> import groovy.json.JsonOutput
> String s = JsonOutput.prettyPrint('{"id":123}')
> println s.getBytes().encodeHex().toString()
> println s
> {code}
> h3. {{OUTPUT}}
> {code}
> 7b0a20202020226964223a20313233000000000000000000000000000a7d
> {
>     "id": 123
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)