|
26 | 26 | // On a Java 9+ JVM, use the host javac, default source/target, and required module flags. |
27 | 27 | isJava8 = JavaVersion.current() == JavaVersion.VERSION_1_8 |
28 | 28 |
|
| 29 | + isJava16 = JavaVersion.current() == JavaVersion.VERSION_16 |
| 30 | + |
29 | 31 | errorproneJavacVersion = '9+181-r4173-1' |
30 | 32 |
|
31 | 33 | parentDir = file("${rootDir}/../").absolutePath |
@@ -58,6 +60,7 @@ switch (JavaVersion.current()) { |
58 | 60 | break; |
59 | 61 | case JavaVersion.VERSION_1_8: |
60 | 62 | case JavaVersion.VERSION_11: |
| 63 | + case JavaVersion.VERSION_16: |
61 | 64 | break; // Supported versions |
62 | 65 | default: |
63 | 66 | throw new GradleException("Build the Checker Framework with JDK 8 or JDK 11." + |
@@ -354,8 +357,18 @@ def createCheckTypeTask(projectName, taskName, checker, args = []) { |
354 | 357 | } else { |
355 | 358 | options.fork = true |
356 | 359 | options.forkOptions.jvmArgs += [ |
| 360 | + // These are required in Java 16+ because the --illegal-access option is set to deny |
| 361 | + // by default. None of these packages are accessed via reflection, so the module |
| 362 | + // only needs to be exported, but not opened. |
| 363 | + "--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED", |
| 364 | + "--add-exports", "jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED", |
| 365 | + "--add-exports", "jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED", |
| 366 | + "--add-exports", "jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED", |
| 367 | + "--add-exports", "jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED", |
| 368 | + "--add-exports", "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED", |
| 369 | + // Required because the Checker Framework reflectively accesses private members in com.sun.tools.javac.comp. |
357 | 370 | "--add-opens", "jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED", |
358 | | - ] |
| 371 | + ] |
359 | 372 | } |
360 | 373 | } |
361 | 374 | } |
@@ -662,6 +675,9 @@ subprojects { |
662 | 675 | } |
663 | 676 | args += "${formatScriptsHome}/check-google-java-format.py" |
664 | 677 | args += getJavaFilesToFormat(project.name) |
| 678 | + // Since the scripts are downloaded from third-party Github, the environment variable |
| 679 | + // is the only way to add the necessary open: |
| 680 | + environment('JDK_JAVA_OPTIONS', '--add-opens jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED') |
665 | 681 | } |
666 | 682 | ignoreExitValue = true |
667 | 683 | doLast { |
@@ -819,7 +835,16 @@ subprojects { |
819 | 835 | // uses the jdk.jdeps module. |
820 | 836 | "-javacoptions:--add-modules jdk.jdeps", |
821 | 837 | "-javacoptions:--add-exports=jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED", |
| 838 | + "-vmoptions:--add-opens=jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED", |
| 839 | + "-vmoptions:--add-opens=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED", |
| 840 | + "-vmoptions:--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED", |
822 | 841 | "-vmoptions:--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED", |
| 842 | + "-vmoptions:--add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED", |
| 843 | + "-vmoptions:--add-opens=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED", |
| 844 | + "-vmoptions:--add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED", |
| 845 | + "-vmoptions:--add-opens=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED", |
| 846 | + "-vmoptions:--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED", |
| 847 | + "-vmoptions:--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED", |
823 | 848 | ] |
824 | 849 | } |
825 | 850 | if (project.name.is('framework')) { |
@@ -923,7 +948,12 @@ subprojects { |
923 | 948 | tasks.create(name: 'inferenceTests', group: 'Verification') { |
924 | 949 | description 'Run inference tests.' |
925 | 950 | if (project.name.is('checker')) { |
926 | | - dependsOn('ainferTest', 'wpiManyTest', 'wpiPlumeLibTest') |
| 951 | + // TODO JDK16: Use this line instead of the following lines. |
| 952 | + // dependsOn('ainferTest', 'wpiManyTest', 'wpiPlumeLibTest') |
| 953 | + dependsOn('ainferTest', 'wpiPlumeLibTest') |
| 954 | + if (!isJava16) { |
| 955 | + dependsOn('wpiManyTest') |
| 956 | + } |
927 | 957 | } |
928 | 958 | } |
929 | 959 |
|
|
0 commit comments