Skip to content
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

Add module-info.java to checker-qual #6326

Merged
merged 13 commits into from
Mar 6, 2024
7 changes: 6 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,9 @@ task allJavadoc(type: Javadoc, group: 'Documentation') {
}

classpath = configurations.allProjects
// disable interpreting module-info.java files until all sub-modules support them
modularity.inferModulePath = false

doLast {
copy {
from 'docs/logo/Checkmark/CFCheckmark_favicon.png'
Expand Down Expand Up @@ -613,6 +616,8 @@ def createJavadocTask(taskName, taskDescription, memberLevel) {
}

classpath = configurations.allProjects
// disable interpreting module-info.java files until all sub-modules support them
modularity.inferModulePath = false

destinationDir.deleteDir()
options.memberLevel = memberLevel
Expand Down Expand Up @@ -805,7 +810,7 @@ subprojects {
manifest {
attributes('Implementation-Version': "${project.version}")
attributes('Implementation-URL': 'https://checkerframework.org')
if (! archiveFileName.get().endsWith('source.jar')) {
if (! archiveFileName.get().endsWith('source.jar') && ! archiveFileName.get().startsWith('checker-qual')) {
attributes('Automatic-Module-Name': 'org.checkerframework.' + project.name.replaceAll('-', '.'))
}
if (archiveFileName.get().startsWith('checker-qual') || archiveFileName.get().startsWith('checker-util')) {
Expand Down
27 changes: 27 additions & 0 deletions checker-qual/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,33 @@ plugins {
id("biz.aQute.bnd.builder") version "6.4.0"
}

sourceSets {
main {
java {
exclude 'module-info.java'
}
}
module_info {
java {
srcDirs ('src/main')
}
}
}

task compileJava9(type: JavaCompile) {
source = sourceSets.module_info.java
destinationDirectory = sourceSets.main.output.classesDirs[0]
classpath = configurations.allProjects
options.release = 9
}

compileJava {
dependsOn compileJava9
}

javadoc {
modularity.inferModulePath = false
}

jar {
manifest {
Expand Down
44 changes: 44 additions & 0 deletions checker-qual/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* This module contains annotations (type qualifiers) that a programmer writes to specify Java code
* for type-checking by the Checker Framework.
*/
module org.checkerframework.checker.qual {
// javadoc-only dependencies
requires static java.compiler;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is really for Javadoc only, wouldn't it be cleaner to remove those requires static statements and replace them by --add-reads options when invoking the javadoc tool?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically, you can even skip the --add-reads because the javadoc phase does not read the module descriptor (due to circular dependencies which are not allowed with JPMS).

I mainly added them to be as explicit as possible with the dependency declarations. For example, IntelliJ would flag even more references if these dependencies were not specified. I don't know how well IDEs are able to include phase-specific build-flags.

Do you have any issues with these declarations? As far as I know, requires static should not affect dependent modules.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issue that I'm aware of for now. I thought that those declarations are a risk, because the code could accidentally use those dependencies without warning from the compiler. The argument about being explicit can also be turned the other way around, i.e. they are not describing the reality if the code has no dependency to those modules. Anyway, this is not a major issue.

requires static java.desktop;
requires static jdk.compiler;

// the .jar file (for the Automatic-Module-Name) is not ready during javadoc
// requires static org.checkerframework.checker;

exports org.checkerframework.checker.builder.qual;
exports org.checkerframework.checker.calledmethods.qual;
exports org.checkerframework.checker.compilermsgs.qual;
exports org.checkerframework.checker.fenum.qual;
exports org.checkerframework.checker.formatter.qual;
exports org.checkerframework.checker.guieffect.qual;
exports org.checkerframework.checker.i18n.qual;
exports org.checkerframework.checker.i18nformatter.qual;
exports org.checkerframework.checker.index.qual;
exports org.checkerframework.checker.initialization.qual;
exports org.checkerframework.checker.interning.qual;
exports org.checkerframework.checker.lock.qual;
exports org.checkerframework.checker.mustcall.qual;
exports org.checkerframework.checker.nullness.qual;
exports org.checkerframework.checker.optional.qual;
exports org.checkerframework.checker.propkey.qual;
exports org.checkerframework.checker.regex.qual;
exports org.checkerframework.checker.signature.qual;
exports org.checkerframework.checker.signedness.qual;
exports org.checkerframework.checker.tainting.qual;
exports org.checkerframework.checker.units.qual;
exports org.checkerframework.common.aliasing.qual;
exports org.checkerframework.common.initializedfields.qual;
exports org.checkerframework.common.reflection.qual;
exports org.checkerframework.common.returnsreceiver.qual;
exports org.checkerframework.common.subtyping.qual;
exports org.checkerframework.common.util.count.report.qual;
exports org.checkerframework.common.value.qual;
exports org.checkerframework.dataflow.qual;
exports org.checkerframework.framework.qual;
}
1 change: 1 addition & 0 deletions docs/manual/contributors.tex
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
Mahmood Ali,
Manu Sridharan,
Mark Roberts,
Markus Frohme,
Martin Kellogg,
Matt Mullen,
Maximilian Gama,
Expand Down