[
https://issues.apache.org/jira/browse/GROOVY-12392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18113377#comment-18113377
]
ASF GitHub Bot commented on GROOVY-12392:
-----------------------------------------
daniellansun opened a new pull request, #2915:
URL: https://github.com/apache/groovy/pull/2915
https://issues.apache.org/jira/browse/GROOVY-12392
> NativeImageMetadataGenerator references deprecated-for-removal Java9
> --------------------------------------------------------------------
>
> Key: GROOVY-12392
> URL: https://issues.apache.org/jira/browse/GROOVY-12392
> Project: Groovy
> Issue Type: Bug
> Reporter: Daniel Sun
> Priority: Major
>
> h3. Context
> GROOVY-11906 deprecated {{org.codehaus.groovy.vmplugin.v9.Java9}} with
> {{forRemoval = true}} and made {{Java17}} the only {{VMPluginFactory}} entry
> point. GROOVY-12365 later added {{NativeImageMetadataGenerator}}, which still
> called {{Java9.class.getName()}} to register default-import class lookups
> ({{groovy.lang.GroovySystem}} and {{groovy.beans.ListenerList}}).
> Those names are loaded through {{GroovyClassLoader.loadClass}}, so they are
> not constant {{Class.forName}} arguments GraalVM can fold. The generator must
> emit {{typeReached}} metadata for them.
> h3. Problem
> {{compileJava}} with {{-Xlint:deprecation}} reports two {{removal}} warnings,
> which GitHub Actions surfaces as annotations:
> {noformat}
> NativeImageMetadataGenerator.java: warning: [removal] Java9 in
> org.codehaus.groovy.vmplugin.v9 has been deprecated and marked for removal
> addName(Java9.class.getName(), GroovySystem.class.getName(), NONE);
> NativeImageMetadataGenerator.java: warning: [removal] Java9 in
> org.codehaus.groovy.vmplugin.v9 has been deprecated and marked for removal
> addName(Java9.class.getName(), "groovy.beans.ListenerList", NONE);
> {noformat}
> Separately, {{Java9.checkAccessible}} looks up JDK 8 packages that are now
> concealed or exported-but-not-open with
> {{ConcurrentHashMap.computeIfAbsent}}. Callers only test {{contains()}}, so a
> miss inserts an empty mutable {{HashSet}} into a map that is otherwise filled
> once at class init.
> h3. Expected
> * Building groovy-core does not emit {{removal}} warnings for {{Java9}}.
> * Default-import reachability metadata is conditional on {{Java17}}, the
> plugin Groovy 6 actually constructs, and is generated as its own family
> rather than as a rider on invokedynamic metadata.
> * Unknown module names are not inserted into the package-list maps.
> h3. Proposed change
> * Register the two lookups under {{Java17.class.getName()}} in a dedicated
> {{defaultImportClassLookups()}} step of {{generate()}}.
> * Replace the two {{computeIfAbsent}} helpers with
> {{getOrDefault(module.getName(), Set.of())}}.
> h3. Related
> GROOVY-11906, GROOVY-12365
--
This message was sent by Atlassian Jira
(v8.20.10#820010)