[
https://issues.apache.org/jira/browse/GROOVY-9273?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18148518#comment-18148518
]
ASF GitHub Bot commented on GROOVY-9273:
----------------------------------------
daniellansun commented on PR #3235:
URL: https://github.com/apache/groovy/pull/3235#issuecomment-7056685319
Hi Jochen,
Module-info is no longer carried by a synthetic ClassNode. The parser leaves
a ModuleInfoNode on the CompileUnit, and a new phase operation visits that
node. By default it runs before the class operations of the phase, so
resolution of the module graph happens before ResolveVisitor looks at source
classes, and a transform that walks classes never sees the declaration.
Import and type lookup go through ModuleInfoResolveVisitor, which shares
ResolveVisitor’s import walk and lookup context. There is no static or dynamic
compilation of the declaration. Annotation collectors still need a ClassNode,
so one is created only for that expansion and is not added to the module.
module-info.class is written by its own generator, not from inside
AsmClassGenerator.visitClass. The one ordering exception is class generation:
Verifier runs on the ordinary classes first, because the provider checks need
the default-argument constructors and provider() methods it synthesizes, and
the module class file is written immediately after that.
With a module in the sources, ResolveVisitor rejects a type whose package
belongs to an explicit module this module does not read, or that does not
export the package. java.awt.Frame without requires java.desktop fails; with
requires java.desktop it compiles; a compilation with no module-info is
unchanged. Types that no explicit module owns, including the Groovy runtime on
the compilation classpath, stay accessible. Otherwise every Groovy class would
fail on GroovyObject. Class expressions and imports are checked as well, not
only field types and constructors.
I left CompiledClassIndex where it is. The declaration being first-class
does not turn javac’s output into AST nodes, so the index still lives in the
joint compiler, still records this invocation’s in-memory output, still does
not walk the target directory when that output is in memory, still omits
module-info, and is still cleared when a compilation unit is reused.
The PR branch is rebased onto current master.
> Support module descriptor, aka. module-info
> -------------------------------------------
>
> Key: GROOVY-9273
> URL: https://issues.apache.org/jira/browse/GROOVY-9273
> Project: Groovy
> Issue Type: New Feature
> Reporter: Daniel Sun
> Priority: Major
>
> Â
> [https://openjdk.java.net/projects/jigsaw/quick-start]
> [http://tutorials.jenkov.com/java/modules.html#java-module-basics]
> [https://www.oracle.com/corporate/features/understanding-java-9-modules.html]
> [https://www.concretepage.com/java/java-9/java-module]
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)