Skip to content

Commit d69eb5f

Browse files
author
Vincent Potucek
committed
[openrewrite] initial merge and Java8toJava11
Signed-off-by: Vincent Potucek <vpotucek@me.com>
1 parent 0d4cf65 commit d69eb5f

File tree

68 files changed

+386
-330
lines changed

Some content is hidden

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

68 files changed

+386
-330
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

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88

99
# intellij
1010
.idea/ant.xml
11-
.idea/codestream.xml
11+
.idea/checkstyle-idea.xml
1212
.idea/codeStyleSettings.xml
13+
.idea/codestream.xml
1314
.idea/compiler.xml
1415
.idea/copyright
1516
.idea/dataSources.ids
@@ -21,6 +22,7 @@
2122
.idea/libraries
2223
.idea/misc.xml
2324
.idea/modules.xml
25+
.idea/palantir-java-format.xml
2426
.idea/shelf
2527
.idea/tasks.xml
2628
.idea/uiDesigner.xml

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: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@
128128
import java.util.concurrent.atomic.AtomicBoolean;
129129
import java.util.stream.IntStream;
130130
import java.util.stream.Stream;
131-
import java.util.stream.StreamSupport;
132131
import javax.lang.model.element.Element;
133132
import javax.lang.model.element.ElementKind;
134133
import javax.lang.model.element.Modifier;
@@ -1097,7 +1096,7 @@ private static List<? extends AnnotationTree> findAnnotationsTree(Tree tree) {
10971096
}
10981097

10991098
private static @Nullable Tree suppressibleNode(TreePath path, VisitorState state) {
1100-
return StreamSupport.stream(path.spliterator(), false)
1099+
return Streams.stream(path)
11011100
.filter(
11021101
tree ->
11031102
tree instanceof MethodTree
@@ -1132,7 +1131,7 @@ public static SuggestedFix.Builder addValuesToAnnotationArgument(
11321131
.replaceFirst("\\(\\)", "(" + parameterPrefix + newArgument(newValues) + ")"));
11331132
}
11341133
Optional<ExpressionTree> maybeExistingArgument = findArgument(annotation, parameterName);
1135-
if (!maybeExistingArgument.isPresent()) {
1134+
if (maybeExistingArgument.isEmpty()) {
11361135
return SuggestedFix.builder()
11371136
.prefixWith(
11381137
annotation.getArguments().getFirst(),
@@ -1192,7 +1191,7 @@ public static SuggestedFix.Builder updateAnnotationArgumentValues(
11921191
+ ')');
11931192
}
11941193
Optional<ExpressionTree> maybeExistingArgument = findArgument(annotation, parameterName);
1195-
if (!maybeExistingArgument.isPresent()) {
1194+
if (maybeExistingArgument.isEmpty()) {
11961195
return SuggestedFix.builder()
11971196
.prefixWith(
11981197
annotation.getArguments().getFirst(),

check_api/src/main/java/com/google/errorprone/matchers/method/MethodInvocationMatcher.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ public static Matcher<ExpressionTree> compile(Iterable<Rule> rules) {
483483
// First collect all the nodes that accept any token at all
484484
for (Node node : curr) {
485485
for (Map.Entry<Optional<Token>, Node> entry : nfa.row(node).entrySet()) {
486-
if (!entry.getKey().isPresent()) {
486+
if (entry.getKey().isEmpty()) {
487487
acceptsAny.add(entry.getValue());
488488
}
489489
}

0 commit comments

Comments
 (0)