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

ASF GitHub Bot commented on GROOVY-9646:
----------------------------------------

paulk-asert opened a new pull request, #3341:
URL: https://github.com/apache/groovy/pull/3341

   [GROOVY-9646](https://issues.apache.org/jira/browse/GROOVY-9646)
   
   Formatting a value initialised `ResolveVisitor` through a static block in 
`FormatHelper`, and that ran the default-import file-system scan. Programs that 
format values but never compile anything paid for a scan they did not use.
   
   ## Changes
   
   - `ResolveVisitor`: the scan and its two maps move into a lazy holder, so 
the scan runs when the first type is resolved through the default imports. Both 
maps are still built from one scan result, which keeps the identity check from 
GROOVY-12725.
   - `FormatHelper`: the default imports are read in a small holder on the 
first `typeName` call, so plain formatting no longer loads `ResolveVisitor`.
   - `Groovy12725`: its reflective field lookup now goes through the holder. No 
assertions changed.
   - `Groovy9646`: new fresh-JVM tests. The formatting and 
`MissingMethodException` tests fail without the fix. The third checks that 
compiling still resolves default imports.
   
   ## Startup
   
   Median whole-process time, 40 fresh JVMs per case on JDK 17, compared with 
the base commit:
   
   | Scenario | Before | After |
   |---|---|---|
   | Format a value | 215 ms | 154 ms |
   | Build a `MissingMethodException` message | 210 ms | 163 ms |
   | Compile a script (control) | 406 ms | 410 ms |
   
   A repeat run agreed. The compile difference is within noise.
   
   ## Testing
   
   - `./gradlew build --continue -x checkstyleMain` passes.
   - `:checkstyleGate` and `:codenarcGate` pass.
   - `:checkstyleMain` was excluded locally because its worker runs out of 
heap, with or without this change.
   
   ## Known limits
   
   A message that needs a type name, such as a `MissingMethodException`, still 
initialises `ResolveVisitor`, but it no longer runs the scan.
   
   A backport to `GROOVY_6_0_X` will follow once this is merged.
   




> Using Closure (Groovy Construction like []) triggers loading of all 
> FileSystemProviders
> ---------------------------------------------------------------------------------------
>
>                 Key: GROOVY-9646
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9646
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 3.0.4
>            Reporter: Andrew Malyhin
>            Priority: Major
>
> After migration from Groovy 2.5.10 and jdk8 to Groovy 3.0.4 and jdk 11 we 
> have faced the issue: the first using of closure inits FileSystemProviders 
> from classpath which are not required: 
> There are two traces that show initializing of 
> org.apache.sshd.common.file.root.RootedFileSystemProvider just calling 
> {code:java}
>  at 
> logback.LogbackConfigurator.configureConsoleAppender(LogbackConfigurator.java:67)
>  at 
> logback.LogbackConfigurator.configureConsoleAppender(LogbackConfigurator.java:67)
>  at logback.LogbackConfigurator.configure(LogbackConfigurator.java:33) at 
> ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:156)
>  at org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:84) at 
> org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:55) at 
> org.slf4j.LoggerFactory.bind(LoggerFactory.java:150) at 
> org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:124) at 
> org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:417) at 
> org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:362) at 
> org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:388) at 
> org.apache.sshd.common.file.root.RootedFileSystemProvider.<init>(RootedFileSystemProvider.java:70)
>  at 
> java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native
>  Method) at 
> java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
>  at 
> java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
>  at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490) 
> at 
> java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:779)
>  at 
> java.base/java.util.ServiceLoader$ProviderImpl.get(ServiceLoader.java:721) at 
> java.base/java.util.ServiceLoader$3.next(ServiceLoader.java:1394) at 
> java.base/java.nio.file.spi.FileSystemProvider.loadInstalledProviders(FileSystemProvider.java:155)
>  at 
> java.base/java.nio.file.spi.FileSystemProvider$1.run(FileSystemProvider.java:205)
>  at 
> java.base/java.nio.file.spi.FileSystemProvider$1.run(FileSystemProvider.java:202)
>  at java.base/java.security.AccessController.doPrivileged(Native Method) at 
> java.base/java.nio.file.spi.FileSystemProvider.installedProviders(FileSystemProvider.java:202)
>  at java.base/java.nio.file.FileSystems.newFileSystem(FileSystems.java:341) 
> at java.base/java.nio.file.FileSystems.newFileSystem(FileSystems.java:293) at 
> org.codehaus.groovy.vmplugin.v9.ClassFinder.newFileSystem(ClassFinder.java:161)
>  at org.codehaus.groovy.vmplugin.v9.ClassFinder.find(ClassFinder.java:118) at 
> org.codehaus.groovy.vmplugin.v9.ClassFinder.find(ClassFinder.java:107) at 
> org.codehaus.groovy.vmplugin.v9.Java9.doFindClasses(Java9.java:106) at 
> org.codehaus.groovy.vmplugin.v9.Java9.getDefaultImportClasses(Java9.java:85) 
> at 
> org.codehaus.groovy.control.ResolveVisitor.<clinit>(ResolveVisitor.java:641) 
> at org.codehaus.groovy.runtime.InvokerHelper.<clinit>(InvokerHelper.java:807) 
> at 
> groovy.lang.GroovyObjectSupport.getDefaultMetaClass(GroovyObjectSupport.java:44)
>  at groovy.lang.GroovyObjectSupport.<init>(GroovyObjectSupport.java:31) at 
> groovy.lang.Closure.<init>(Closure.java:211) at 
> groovy.lang.Closure.<init>(Closure.java:228) at 
> groovy.lang.Closure$1.<init>(Closure.java:193) at 
> groovy.lang.Closure.<clinit>(Closure.java:193){code}
> and
> {code:java}
>  at 
> logback.LogbackConfigurator.configureConsoleAppender(LogbackConfigurator.java:67)
>  at 
> logback.LogbackConfigurator.configureConsoleAppender(LogbackConfigurator.java:67)
>  at logback.LogbackConfigurator.configure(LogbackConfigurator.java:33) at 
> ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:156)
>  at org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:84) at 
> org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:55) at 
> org.slf4j.LoggerFactory.bind(LoggerFactory.java:150) at 
> org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:124) at 
> org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:417) at 
> org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:362) at 
> org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:388) at 
> org.apache.sshd.common.file.root.RootedFileSystemProvider.<init>(RootedFileSystemProvider.java:70)
>  at 
> java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native
>  Method) at 
> java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
>  at 
> java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
>  at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490) 
> at 
> java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:779)
>  at 
> java.base/java.util.ServiceLoader$ProviderImpl.get(ServiceLoader.java:721) at 
> java.base/java.util.ServiceLoader$3.next(ServiceLoader.java:1394) at 
> java.base/java.nio.file.spi.FileSystemProvider.loadInstalledProviders(FileSystemProvider.java:155)
>  at 
> java.base/java.nio.file.spi.FileSystemProvider$1.run(FileSystemProvider.java:205)
>  at 
> java.base/java.nio.file.spi.FileSystemProvider$1.run(FileSystemProvider.java:202)
>  at java.base/java.security.AccessController.doPrivileged(Native Method) at 
> java.base/java.nio.file.spi.FileSystemProvider.installedProviders(FileSystemProvider.java:202)
>  at java.base/java.nio.file.FileSystems.newFileSystem(FileSystems.java:341) 
> at java.base/java.nio.file.FileSystems.newFileSystem(FileSystems.java:293) at 
> org.codehaus.groovy.vmplugin.v9.ClassFinder.newFileSystem(ClassFinder.java:161)
>  at org.codehaus.groovy.vmplugin.v9.ClassFinder.find(ClassFinder.java:118) at 
> org.codehaus.groovy.vmplugin.v9.ClassFinder.find(ClassFinder.java:107) at 
> org.codehaus.groovy.vmplugin.v9.Java9.doFindClasses(Java9.java:106) at 
> org.codehaus.groovy.vmplugin.v9.Java9.getDefaultImportClasses(Java9.java:85) 
> at 
> org.codehaus.groovy.control.ResolveVisitor.<clinit>(ResolveVisitor.java:641) 
> at org.codehaus.groovy.runtime.InvokerHelper.<clinit>(InvokerHelper.java:807) 
> at 
> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.createList(ScriptBytecodeAdapter.java:623)
> {code}
> Thanks



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to