Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore implements ContainerRenderer<C, T> on AbstractJsonViewContainerRenderer<C,T> #598

Open
jamesfredley opened this issue Dec 10, 2024 · 2 comments
Assignees

Comments

@jamesfredley
Copy link
Contributor

The interface XXX cannot be implemented more than once with different arguments.

implements ContainerRenderer<C, T> was causing Render to be implement more than once. It is currently removed from class AbstractJsonViewContainerRenderer<C,T>

https://github.com/grails/grails-views/pull/581/files#diff-b2646b6110b34798952582e9a501678112c0ed5d810ac556902857099652a31e

@jamesfredley
Copy link
Contributor Author

This would require changes to ContainerRenderer in grails-core.

A start: grails/grails-core@7.0.x...convert-ContainerRender-to-trait

which resulted in a deeper rabbit hole with Groovy Traits called from Java:

                Caused by:
                java.lang.NoClassDefFoundError: grails/web/mime/MimeTypeProvider$Trait$Helper
                    at org.grails.plugins.databinding.DataBindingConfiguration.xmlDataBindingSourceCreator(DataBindingConfiguration.java:68)
                    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.lambda$instantiate$0(SimpleInstantiationStrategy.java:171)
                    ... 45 more
                    Caused by:
                    java.lang.ClassNotFoundException: grails.web.mime.MimeTypeProvider$Trait$Helper
                        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
                        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
                        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
                        ... 47 more (edited) 

@jdaugherty
Copy link
Contributor

I looked into this one. It's tough. It's Java code DataBindingUtils.java calling the groovy code that's failing.

Here's the grails-views code before 7.0 code:

abstract class AbstractJsonViewContainerRenderer<C,T> extends DefaultJsonRenderer<T> implements ContainerRenderer<C, T>

By specifying both interfaces, it means there are 2 identical methods returning different values. This isn't supported by Groovy 4. It's only supported by traits and loading the Groovy Object from Java code is failling. In groovy 3, it would have picked just the last interface when a method conflicts.

Maybe we shouldn't use generics, that's how others like this are working:

    class AtomCollectionRenderer extends AtomRenderer implements ContainerRenderer 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

No branches or pull requests

2 participants