-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set language level to 17 in java parser and upgrade the dependency (#223
) Fixes #88 This PR sets parser configuration to `17` to enable Annotator to work on source code written in java 17. To support java 17 sources, we are only required to update java parser configuration, no change in `core` implementation is required. Our default java version for publishing/compiling/testing is 11. This PR adds a CI job (named `parser-coinfiguration-17`) to specifically execute tests in `Java17Test` with java version 17. Please note this PR also upgrades `javaparser` dependency to `3.25.7`.
- Loading branch information
1 parent
67e2ded
commit 5c95d42
Showing
10 changed files
with
262 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
annotator-core/src/test/java/edu/ucr/cs/riple/core/Java17Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* MIT License | ||
* | ||
* Copyright (c) 2023 Nima Karimipour | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
|
||
package edu.ucr.cs.riple.core; | ||
|
||
import edu.ucr.cs.riple.core.tools.TReport; | ||
import edu.ucr.cs.riple.injector.location.OnField; | ||
import java.util.Set; | ||
import org.junit.Test; | ||
|
||
/** | ||
* Tests in this class are related to Java 17 features. These tests include blocks of code that are | ||
* not syntactically supported by java 11. | ||
*/ | ||
public class Java17Test extends AnnotatorBaseCoreTest { | ||
|
||
public Java17Test() { | ||
super("java-17"); | ||
} | ||
|
||
@Test | ||
public void patternMatchingInJava17Test() { | ||
coreTestHelper | ||
.onTarget() | ||
.withSourceLines( | ||
"Main.java", | ||
"package test;", | ||
"public class Main {", | ||
" Object f1, f2, f3, f4;", | ||
" void foo() {", | ||
" // this block is not supported by java 11", | ||
" if(f1 instanceof String s) { }", | ||
" }", | ||
"}") | ||
.withExpectedReports( | ||
new TReport(new OnField("Main.java", "test.Main", Set.of("f1", "f2", "f3", "f4")), -4)) | ||
.start(); | ||
} | ||
} |
83 changes: 83 additions & 0 deletions
83
annotator-core/src/test/resources/templates/java-17/build.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* Copyright (c) 2023 Nima Karimipour | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
|
||
import net.ltgt.gradle.errorprone.CheckSeverity | ||
|
||
plugins{ | ||
id "net.ltgt.errorprone" version "2.0.1" apply false | ||
} | ||
|
||
subprojects { | ||
apply plugin: "java" | ||
apply plugin: "net.ltgt.errorprone" | ||
|
||
repositories { | ||
mavenLocal() | ||
mavenCentral() | ||
google() | ||
} | ||
|
||
def libraryloader = project.getProperty("library-model-loader-path") | ||
|
||
repositories { | ||
mavenLocal() | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
if(project.name != "Target"){ | ||
compileOnly project(":Target") | ||
annotationProcessor files(libraryloader) | ||
} | ||
annotationProcessor "com.uber.nullaway:nullaway:" + System.getenv('NULLAWAY_TEST_VERSION') | ||
annotationProcessor "edu.ucr.cs.riple.annotator:annotator-scanner:" + System.getenv('ANNOTATOR_VERSION') | ||
|
||
// to add @Initializer | ||
compileOnly 'com.uber.nullaway:nullaway-annotations:0.10.10' | ||
// to add jetbrains annotations (testing type use vs type declaration) | ||
compileOnly 'org.jetbrains:annotations:24.0.0' | ||
compileOnly "org.jspecify:jspecify:0.3.0" | ||
compileOnly "com.google.code.findbugs:jsr305:3.0.2" | ||
errorprone "com.google.errorprone:error_prone_core:2.3.2" | ||
errorproneJavac "com.google.errorprone:javac:9+181-r4173-1" | ||
} | ||
|
||
tasks.withType(JavaCompile) { | ||
// remove the if condition if you want to run NullAway on test code | ||
if (!name.toLowerCase().contains("test")) { | ||
options.errorprone.disableAllChecks = true | ||
options.errorprone.disableAllWarnings = true | ||
options.errorprone { | ||
check("NullAway", CheckSeverity.WARN) | ||
check("AnnotatorScanner", CheckSeverity.WARN) | ||
option("NullAway:AnnotatedPackages", "test") | ||
option("NullAway:SerializeFixMetadata", "true") | ||
option("NullAway:FixSerializationConfigPath", project.getProperty(project.name + "-nullaway-config-path")) | ||
option("NullAway:AcknowledgeLibraryModelsOfAnnotatedCode", "true") | ||
option("AnnotatorScanner:ConfigPath", project.getProperty(project.name + "-scanner-config-path")) | ||
} | ||
} | ||
options.compilerArgs << "-Xmaxerrs" << "100000" | ||
options.compilerArgs << "-Xmaxwarns" << "100000" | ||
options.fork = true | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
annotator-core/src/test/resources/templates/java-17/settings.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* MIT License | ||
* | ||
* Copyright (c) 2023 Nima Karimipour | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
|
||
rootProject.name = 'java-17' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,6 +66,7 @@ subprojects { proj -> | |
} | ||
} | ||
} | ||
options.fork = true | ||
} | ||
|
||
repositories { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.