You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2024/09/04 19:36:00 UTC

[jira] [Updated] (GROOVY-6105) GroovyClassLoader doesn't return compiled classes via getResource(String name) method

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

Eric Milles updated GROOVY-6105:
--------------------------------
    Language: groovy

> GroovyClassLoader doesn't return compiled classes via getResource(String name) method
> -------------------------------------------------------------------------------------
>
>                 Key: GROOVY-6105
>                 URL: https://issues.apache.org/jira/browse/GROOVY-6105
>             Project: Groovy
>          Issue Type: Improvement
>          Components: groovy-runtime
>    Affects Versions: 2.1.3
>            Reporter: Jan Novotný
>            Priority: Major
>         Attachments: CompiledClassesAwareGroovyClassLoader.java
>
>
> Some libraries ask classloader for compiled class files. For example Spring does that during annotation driven autowiring in class org.springframework.core.type.classreading.SimpleMetadataReader
> See stacktrace:
> {noformat}
> java.io.FileNotFoundException: class path resource [com/fg/mock/MainGroovyClass.class] cannot be opened because it does not exist
> 	at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:157)
> 	at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:49)
> 	at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:80)
> 	at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:101)
> 	at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:76)
> 	at org.springframework.context.annotation.ConfigurationClassUtils.checkConfigurationClassCandidate(ConfigurationClassUtils.java:70)
> 	at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:253)
> 	at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:223)
> 	at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:630)
> 	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:461)
> {noformat}
> Standard GroovyClassLoader throws away compiled class bodies after compilation is done and keeps only Class instances in memory. The problem could be solved by attached implementation (though it could be of course written much better).
> With this implementation no exception is thrown from inside Spring and autowiring by annotations finishes ok.
> Maybe you could consider including similar logic in standard GroovyClassLoader?



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