-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Java: Add support to ModuleImportDeclaration
#20097
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
ModuleImportDeclaration
16b0695
to
a16147c
Compare
a24e4ae
to
27cb373
Compare
} | ||
} | ||
|
||
// Diagnostic Matches: Unknown location for jdk.internal.RequiresIdentity+Annotation No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an internally generated annotation without a specific source location.
Excluding it from diagnostic will be addressed in a separate PR.
27cb373
to
e4848e0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for Java 25 module import declarations, implementing the new import module
syntax feature. The implementation includes database schema updates, a new ModuleImportDeclaration
class, and comprehensive test coverage.
Key changes:
- Database schema updated to handle the new module import kind (value 6 in imports table)
- Added
ModuleImportDeclaration
class extendingImport
with methods to access module information and imported types/packages - Upgrade/downgrade scripts for database compatibility
Reviewed Changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
java/ql/lib/semmle/code/java/Import.qll | Adds ModuleImportDeclaration class with methods to get module info and imported types/packages |
java/ql/lib/config/semmlecode.dbscheme | Updates imports table schema to include module import kind (6) with documentation |
java/ql/lib/upgrades/.../semmlecode.dbscheme | New schema version adding MODULEIMPORT kind to imports documentation |
java/ql/lib/upgrades/.../old.dbscheme | Previous schema version for upgrade compatibility |
java/ql/lib/upgrades/.../upgrade.properties | Upgrade script properties for module import declarations |
java/downgrades/.../semmlecode.dbscheme | Downgrade schema removing module import support |
java/downgrades/.../upgrade.properties | Downgrade script properties |
java/ql/test/library-tests/module-import-declarations/* | Test files validating module import functionality and expected outputs |
java/ql/lib/change-notes/2025-07-21-module-import-declarations.md | Release note documenting the new feature |
e4848e0
to
3c0b807
Compare
3c0b807
to
ccf5002
Compare
ba93ced
to
564364b
Compare
0877afe
to
75107ba
Compare
a34b362
to
5d2268f
Compare
75107ba
to
8656461
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can only review this at a very shallow level. Someone from @github/codeql-java should probably have a look too.
* A module import declaration, which imports an entire module. | ||
* | ||
* For example, `import module java.base;` imports all packages exported | ||
* by the `java.base module`, making their types available for use. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this maybe supposed to be:
* by the `java.base module`, making their types available for use. | |
* by the `java.base` module, making their types available for use. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment here mentions "types", but below I get a getAnImportedPackage
. So what is actually being imported here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. The declaration makes the exported packages available, and through them the types defined in those packages become accessible for use. I'll rephrase the comment.
27e7c17
to
6d8a014
Compare
exists(Package pkg | | ||
pkg = this.getAnImportedPackage() and | ||
result.getPackage() = pkg | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be more concise and still understandable.
exists(Package pkg | | |
pkg = this.getAnImportedPackage() and | |
result.getPackage() = pkg | |
) | |
result.getPackage() = this.getAnImportedPackage() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change applied, tested, and committed. Thanks 👍
0083d5a
to
d5c5531
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not particularly familiar with this layer of the java library, but it looks pretty inoffensive to me.
d5c5531
to
ed9ed43
Compare
Support for Java 25 module import declarations:
ModuleImportDeclaration
classSee internal PR.