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

[jira] [Resolved] (GROOVY-10690) dump() method produces errors

     [ https://issues.apache.org/jira/browse/GROOVY-10690?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul King resolved GROOVY-10690.
--------------------------------
    Fix Version/s: 5.0.0-alpha-1
                   4.0.4
         Assignee: Paul King
       Resolution: Fixed

The error messages within the dump are "kind of" by design. They handle numerous scenarios including infinitely recursive structures and so forth. But where the cause is well known, there is no harm in doing better.

I think we should come back and clean up for Groovy 5 to have better ways to override the behavior, e.g. explicitly look for say a File#dump DGM or potentially looking for JavaBean getters instead of fields. For now, it's a little cleaner:
{code:java}
<java.io.File@135957 path=inaccessible status=inaccessible prefixLength=inaccessible filePath=inaccessible>
{code}

> dump() method produces errors
> -----------------------------
>
>                 Key: GROOVY-10690
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10690
>             Project: Groovy
>          Issue Type: Bug
>          Components: groovy-jdk
>    Affects Versions: 4.0.3
>         Environment: java --version
> openjdk 17.0.3 2022-04-19
> OpenJDK Runtime Environment Temurin-17.0.3+7 (build 17.0.3+7)
> OpenJDK 64-Bit Server VM Temurin-17.0.3+7 (build 17.0.3+7, mixed mode, sharing)
>            Reporter: Alexander Veit
>            Assignee: Paul King
>            Priority: Major
>             Fix For: 5.0.0-alpha-1, 4.0.4
>
>
> Groovy GDK method {{dump()}} produces errors at least since Jave version 16.
> Example:
> {code:java}
> println(new File("foo").dump())
> {code}
> produces
> {noformat}
> <java.io.File@135957 path=java.lang.IllegalAccessException: class org.codehaus.groovy.runtime.DefaultGroovyMethods
>  cannot access a member of class java.io.File (in module java.base) with modifiers "private final"
>  status=java.lang.IllegalAccessException: class org.codehaus.groovy.runtime.DefaultGroovyMethods cannot access a
>  member of class java.io.File (in module java.base) with modifiers "private transient" prefixLength=java.lang.IllegalAccessException:
>  class org.codehaus.groovy.runtime.DefaultGroovyMethods cannot access a member of class java.io.File (in module java.base)
>  with modifiers "private final transient" filePath=java.lang.IllegalAccessException: class org.codehaus.groovy.runtime.DefaultGroovyMethods
>  cannot access a member of class java.io.File (in module java.base) with modifiers "private transient volatile">
> {noformat}
> To me the best solution would be to respect Java's access modifiers.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)