You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Matteo Steccolini (Jira)" <ji...@apache.org> on 2022/05/13 14:19:00 UTC

[jira] [Commented] (GROOVY-8979) JDK 11,java.lang.ClassCastException: class [B cannot be cast to class [C ([B and [C are in module java.base of loader 'bootstrap')

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

Matteo Steccolini commented on GROOVY-8979:
-------------------------------------------

Attached a test case (maven project). With Eclipse Adoptium jdk-11.0.13.8-hotspot:

 
{noformat}
---------------------< test.testgroovy:TestGroovy >---------------------
Building TestGroovy 1.0-SNAPSHOT
--------------------------------[ jar ]------------------------------------ exec-maven-plugin:3.0.0:exec (default-cli) @ TestGroovy ---
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.reflection.CachedClass$3$1 (file:/D:/Dati/m2repository/org/codehaus/groovy/groovy-all/2.3.0/groovy-all-2.3.0.jar) to method java.lang.Object.finalize()
WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.reflection.CachedClass$3$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Exception in thread "main" java.lang.ClassCastException: class [B cannot be cast to class [C ([B and [C are in module java.base of loader 'bootstrap')
    at groovy.json.internal.FastStringUtils$StringImplementation$1.toCharArray(FastStringUtils.java:88)
    at groovy.json.internal.FastStringUtils.toCharArray(FastStringUtils.java:175)
    at groovy.json.internal.BaseJsonParser.parse(BaseJsonParser.java:103)
    at groovy.json.JsonSlurper.parseText(JsonSlurper.java:208)
    at groovy.json.JsonSlurper$parseText.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
    at Script.run(Script.groovy:4)
    at groovy.lang.GroovyShell.evaluate(GroovyShell.java:570)
    at groovy.lang.GroovyShell.evaluate(GroovyShell.java:617)
    at test.testgroovy.TestGroovy.main(TestGroovy.java:10){noformat}
With Oracle jdk 8u201:

 

 
{noformat}
---------------------< test.testgroovy:TestGroovy >---------------------
Building TestGroovy 1.0-SNAPSHOT
--------------------------------[ jar ]------------------------------------ exec-maven-plugin:3.0.0:exec (default-cli) @ TestGroovy ---
ok
------------------------------------------------------------------------
BUILD SUCCESS
------------------------------------------------------------------------
Total time:  1.402 s
Finished at: 2022-05-13T16:12:54+02:00
------------------------------------------------------------------------
 {noformat}
With Eclipse Adoptium jdk-11.0.13.8-hotspot and groovy-all-2.2.2:
{noformat}
---------------------< test.testgroovy:TestGroovy >---------------------
Building TestGroovy 1.0-SNAPSHOT
--------------------------------[ jar ]------------------------------------ exec-maven-plugin:3.0.0:exec (default-cli) @ TestGroovy ---
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.reflection.CachedClass$3$1 (file:/D:/Dati/m2repository/org/codehaus/groovy/groovy-all/2.2.2/groovy-all-2.2.2.jar) to method java.lang.Object.finalize()
WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.reflection.CachedClass$3$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
ok
------------------------------------------------------------------------
BUILD SUCCESS
------------------------------------------------------------------------
Total time:  1.642 s
Finished at: 2022-05-13T16:14:38+02:00
------------------------------------------------------------------------{noformat}
 

> JDK 11,java.lang.ClassCastException: class [B cannot be cast to class [C ([B and [C are in module java.base of loader 'bootstrap')
> ----------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-8979
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8979
>             Project: Groovy
>          Issue Type: Bug
>          Components: JSON
>    Affects Versions: 2.3.0
>         Environment: java version "11.0.2" 2019-01-15 LTS
> Java(TM) SE Runtime Environment 18.9 (build 11.0.2+9-LTS)
> Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.2+9-LTS, mixed mode)
>            Reporter: TarakA
>            Priority: Major
>         Attachments: TestGroovyJsonSlurper.zip
>
>
> cast issue happening while parsing HTTP  response to Java class  in jdk 11, but not in jdk 8.
> please let us know, do you have further questions or advice to fix with JDK 11 
> {code:java}
> Caused by: java.lang.ClassCastException: class [B cannot be cast to class [C ([B and [C are in module java.base of loader 'bootstrap')at deployment.application.war//groovy.json.internal.FastStringUtils$StringImplementation$1.toCharArray(FastStringUtils.java:88)at deployment.application.war//groovy.json.internal.FastStringUtils.toCharArray(FastStringUtils.java:175)at deployment.application.war//groovy.json.internal.BaseJsonParser.parse(BaseJsonParser.java:103)at deployment.application.war//groovy.json.JsonSlurper.parseText(JsonSlurper.java:208)at groovy.json.JsonSlurper$parseText.call(Unknown Source)at deployment.application.war//org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)at deployment.application.war//org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)at deployment.application.war//org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)at deployment.application.war//com.company.agent.commons.services.AuthorizeService.requestToken(AuthrizeService.groovy:76)at deployment.application.war//com.company.agent.commons.services.AuthorizeService.initBean(AuthrizeService.groovy:52)
> {code}



--
This message was sent by Atlassian Jira
(v8.20.7#820007)