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. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
