Skip to content

Commit a11c983

Browse files
author
Vincent Potucek
committed
[openrewrite] initial merge and Java8toJava11
Signed-off-by: Vincent Potucek <[email protected]>
1 parent 0d4cf65 commit a11c983

File tree

67 files changed

+416
-446
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+416
-446
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ jobs:
9090
- name: 'Test'
9191
shell: bash
9292
run: mvn test -B
93+
- name: 'SanityCheck'
94+
shell: bash
95+
run: mvn rewrite:dryRun
9396
- name: 'Javadoc'
9497
shell: bash
9598
run: mvn -P '!examples' javadoc:javadoc

.idea/checkstyle-idea.xml

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/palantir-java-format.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

annotation/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
<version>1.0-HEAD-SNAPSHOT</version>
2525
</parent>
2626

27-
<name>@BugPattern annotation</name>
2827
<artifactId>error_prone_annotation</artifactId>
28+
<name>@BugPattern annotation</name>
2929

3030
<licenses>
3131
<license>

annotations/pom.xml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,15 @@
2424
<version>1.0-HEAD-SNAPSHOT</version>
2525
</parent>
2626

27-
<name>error-prone annotations</name>
2827
<artifactId>error_prone_annotations</artifactId>
28+
<name>error-prone annotations</name>
29+
30+
<licenses>
31+
<license>
32+
<name>Apache 2.0</name>
33+
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
34+
</license>
35+
</licenses>
2936

3037
<dependencies>
3138
<dependency>
@@ -36,18 +43,12 @@
3643
</dependency>
3744
</dependencies>
3845

39-
<licenses>
40-
<license>
41-
<name>Apache 2.0</name>
42-
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
43-
</license>
44-
</licenses>
45-
4646
<build>
4747
<plugins>
4848
<plugin>
4949
<groupId>org.apache.maven.plugins</groupId>
5050
<artifactId>maven-compiler-plugin</artifactId>
51+
<version>3.14.1</version>
5152
<configuration>
5253
<compilerArgs combine.self="override" />
5354
</configuration>
@@ -79,6 +80,7 @@
7980
<plugin>
8081
<groupId>org.apache.maven.plugins</groupId>
8182
<artifactId>maven-jar-plugin</artifactId>
83+
<version>3.4.2</version>
8284
<configuration>
8385
<archive>
8486
<manifestEntries>

check_api/pom.xml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
<version>1.0-HEAD-SNAPSHOT</version>
2525
</parent>
2626

27-
<name>error-prone check api</name>
2827
<artifactId>error_prone_check_api</artifactId>
28+
<name>error-prone check api</name>
2929

3030
<licenses>
3131
<license>
@@ -49,6 +49,12 @@
4949
<artifactId>jspecify</artifactId>
5050
<version>${jspecify.version}</version>
5151
</dependency>
52+
<dependency>
53+
<groupId>jakarta.annotation</groupId>
54+
<artifactId>jakarta.annotation-api</artifactId>
55+
<version>1.3.5</version>
56+
<scope>provided</scope>
57+
</dependency>
5258
<dependency>
5359
<!-- GPLv2 with Classpath Exception -->
5460
<groupId>io.github.eisop</groupId>
@@ -103,6 +109,12 @@
103109
<version>${truth.version}</version>
104110
<scope>test</scope>
105111
</dependency>
112+
<dependency>
113+
<groupId>jakarta.inject</groupId>
114+
<artifactId>jakarta.inject-api</artifactId>
115+
<version>1.0.3</version>
116+
<scope>test</scope>
117+
</dependency>
106118
<dependency>
107119
<!-- MIT -->
108120
<groupId>org.mockito</groupId>
@@ -149,6 +161,7 @@
149161
<plugin>
150162
<groupId>org.apache.maven.plugins</groupId>
151163
<artifactId>maven-compiler-plugin</artifactId>
164+
<version>3.14.1</version>
152165
<configuration>
153166
<annotationProcessorPaths>
154167
<path>
@@ -189,7 +202,7 @@
189202
<version>24</version>
190203
</jdkToolchain>
191204
<compileSourceRoots>
192-
<compileSourceRoot>${basedir}/src/main/java24</compileSourceRoot>
205+
<compileSourceRoot>${project.basedir}/src/main/java24</compileSourceRoot>
193206
</compileSourceRoots>
194207
<!-- multiReleaseOutput requires setting release -->
195208
<outputDirectory>${project.build.outputDirectory}/META-INF/versions/24</outputDirectory>

check_api/src/main/java/com/google/errorprone/apply/DescriptionBasedDiff.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import com.sun.tools.javac.tree.EndPosTable;
2727
import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
2828
import java.net.URI;
29-
import java.nio.file.Paths;
29+
import java.nio.file.Path;
3030
import java.util.LinkedHashSet;
3131
import java.util.Objects;
3232
import java.util.Set;
@@ -68,7 +68,7 @@ private DescriptionBasedDiff(
6868
URI sourceFileUri = compilationUnit.getSourceFile().toUri();
6969
this.sourcePath =
7070
(sourceFileUri.isAbsolute() && Objects.equals(sourceFileUri.getScheme(), "file"))
71-
? Paths.get(sourceFileUri).toAbsolutePath().toString()
71+
? Path.of(sourceFileUri).toAbsolutePath().toString()
7272
: sourceFileUri.getPath();
7373
this.ignoreOverlappingFixes = ignoreOverlappingFixes;
7474
this.importsToAdd = new LinkedHashSet<>();

check_api/src/main/java/com/google/errorprone/dataflow/nullnesspropagation/inference/InferredNullability.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,20 +87,18 @@ private Optional<Nullness> getNullness(InferenceVariable iv) {
8787
result =
8888
constraintGraph.predecessors(iv).stream()
8989
.map(this::getNullness)
90-
.filter(Optional::isPresent)
91-
.map(Optional::get)
90+
.flatMap(Optional::stream)
9291
.reduce(Nullness::leastUpperBound); // use least upper bound (lub) to combine
9392
// 2. If not, resolve successors and use them as upper bounds
94-
if (!result.isPresent()) {
93+
if (result.isEmpty()) {
9594
result =
9695
constraintGraph.successors(iv).stream()
9796
.map(this::getNullness)
98-
.filter(Optional::isPresent)
99-
.map(Optional::get)
97+
.flatMap(Optional::stream)
10098
.reduce(Nullness::greatestLowerBound); // use greatest lower bound (glb) to combine
10199
}
102100

103-
checkState(!inferredMemoTable.put(iv, result).isPresent());
101+
checkState(inferredMemoTable.put(iv, result).isEmpty());
104102
return result;
105103
}
106104
}

check_api/src/main/java/com/google/errorprone/dataflow/nullnesspropagation/inference/NullnessQualifierInference.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,14 @@ private void generateConstraintsFromAnnotations(
153153

154154
Optional<Nullness> fromAnnotations =
155155
extractExplicitNullness(declaredType, argSelector.isEmpty() ? decl : null);
156-
if (!fromAnnotations.isPresent()) {
156+
if (fromAnnotations.isEmpty()) {
157157
// Check declared type before inferred type so that type annotations on the declaration take
158158
// precedence (just like declaration annotations) over annotations on the inferred type.
159159
// For instance, we want a @Nullable T m() to take precedence over annotations on T's inferred
160160
// type (e.g., @NotNull String), whether @Nullable is a declaration or type annotation.
161161
fromAnnotations = NullnessAnnotations.fromAnnotationsOn(inferredType);
162162
}
163-
if (!fromAnnotations.isPresent()) {
163+
if (fromAnnotations.isEmpty()) {
164164
if (declaredType instanceof TypeVariable typeVariable) {
165165
// Check bounds second so explicit annotations take precedence. Even for bounds we still use
166166
// equality constraint below since we have to assume the bound as the "worst" case.
@@ -482,7 +482,7 @@ private void generateConstraintsForWrite(
482482
boolean isBound = false;
483483
Optional<Nullness> fromAnnotations =
484484
extractExplicitNullness(lType, argSelector.isEmpty() ? decl : null);
485-
if (!fromAnnotations.isPresent()) {
485+
if (fromAnnotations.isEmpty()) {
486486
if (lType instanceof TypeVariable typeVariable) {
487487
fromAnnotations = NullnessAnnotations.getUpperBound(typeVariable);
488488
isBound = true;

check_api/src/main/java/com/google/errorprone/fixes/SuggestedFixes.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,7 +1132,7 @@ public static SuggestedFix.Builder addValuesToAnnotationArgument(
11321132
.replaceFirst("\\(\\)", "(" + parameterPrefix + newArgument(newValues) + ")"));
11331133
}
11341134
Optional<ExpressionTree> maybeExistingArgument = findArgument(annotation, parameterName);
1135-
if (!maybeExistingArgument.isPresent()) {
1135+
if (maybeExistingArgument.isEmpty()) {
11361136
return SuggestedFix.builder()
11371137
.prefixWith(
11381138
annotation.getArguments().getFirst(),
@@ -1192,7 +1192,7 @@ public static SuggestedFix.Builder updateAnnotationArgumentValues(
11921192
+ ')');
11931193
}
11941194
Optional<ExpressionTree> maybeExistingArgument = findArgument(annotation, parameterName);
1195-
if (!maybeExistingArgument.isPresent()) {
1195+
if (maybeExistingArgument.isEmpty()) {
11961196
return SuggestedFix.builder()
11971197
.prefixWith(
11981198
annotation.getArguments().getFirst(),

0 commit comments

Comments
 (0)