Skip to content

Commit 6896381

Browse files
author
Vincent Potucek
committed
[rewrite] Add Java8toJava11
Signed-off-by: Vincent Potucek <vpotucek@me.com>
1 parent c0877ea commit 6896381

File tree

13 files changed

+85
-16
lines changed

13 files changed

+85
-16
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

check_api/pom.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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>

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<>();

core/pom.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@
7474
<artifactId>pcollections</artifactId>
7575
<version>4.0.1</version>
7676
</dependency>
77+
<dependency>
78+
<groupId>jakarta.annotation</groupId>
79+
<artifactId>jakarta.annotation-api</artifactId>
80+
<version>1.3.5</version>
81+
<scope>provided</scope>
82+
</dependency>
7783
<dependency>
7884
<!-- Apache 2.0 -->
7985
<groupId>com.google.guava</groupId>
@@ -99,6 +105,11 @@
99105
<artifactId>dataflow-errorprone</artifactId>
100106
<version>${dataflow.version}</version>
101107
</dependency>
108+
<dependency>
109+
<groupId>jakarta.inject</groupId>
110+
<artifactId>jakarta.inject-api</artifactId>
111+
<version>1.0.3</version>
112+
</dependency>
102113
<dependency>
103114
<!-- Apache 2.0 -->
104115
<groupId>com.google.auto.value</groupId>

core/src/main/java/com/google/errorprone/bugpatterns/checkreturnvalue/ExternalCanIgnoreReturnValue.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
import com.sun.tools.javac.util.List;
3838
import java.io.IOException;
3939
import java.io.UncheckedIOException;
40-
import java.nio.file.Paths;
40+
import java.nio.file.Path;
4141
import java.util.Optional;
4242
import java.util.stream.Stream;
4343

@@ -98,13 +98,13 @@ enum ConfigParser {
9898
AS_STRINGS {
9999
@Override
100100
MethodPredicate load(String file) throws IOException {
101-
return configByInterpretingMethodsAsStrings(MoreFiles.asCharSource(Paths.get(file), UTF_8));
101+
return configByInterpretingMethodsAsStrings(MoreFiles.asCharSource(Path.of(file), UTF_8));
102102
}
103103
},
104104
PARSE_TOKENS {
105105
@Override
106106
MethodPredicate load(String file) throws IOException {
107-
return configByParsingApiObjects(MoreFiles.asCharSource(Paths.get(file), UTF_8));
107+
return configByParsingApiObjects(MoreFiles.asCharSource(Path.of(file), UTF_8));
108108
}
109109
};
110110

core/src/test/java/com/google/errorprone/ErrorProneJavacPluginTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
import java.nio.file.FileSystem;
5151
import java.nio.file.Files;
5252
import java.nio.file.Path;
53-
import java.nio.file.Paths;
5453
import java.util.jar.JarEntry;
5554
import java.util.jar.JarOutputStream;
5655
import java.util.stream.Stream;
@@ -215,7 +214,7 @@ public void applyToPatchFile() throws IOException {
215214
assertThat(
216215
Files.readAllLines(patchFile, UTF_8).stream()
217216
.filter(l -> l.startsWith("--- "))
218-
.map(l -> Paths.get(l.substring("--- ".length())).getFileName().toString())
217+
.map(l -> Path.of(l.substring("--- ".length())).getFileName().toString())
219218
.collect(toImmutableList()))
220219
.containsExactly("A.java", "B.java");
221220
}

core/src/test/java/com/google/errorprone/bugpatterns/apidiff/CompilationBuilderHelpers.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import java.nio.file.FileVisitResult;
3232
import java.nio.file.Files;
3333
import java.nio.file.Path;
34-
import java.nio.file.Paths;
3534
import java.nio.file.SimpleFileVisitor;
3635
import java.nio.file.StandardOpenOption;
3736
import java.nio.file.attribute.BasicFileAttributes;
@@ -62,7 +61,7 @@ public SourceBuilder(File tempFolder) {
6261

6362
@CanIgnoreReturnValue
6463
public SourceBuilder addSourceLines(String name, String... lines) throws IOException {
65-
Path filePath = Paths.get(tempFolder.getAbsolutePath(), name);
64+
Path filePath = Path.of(tempFolder.getAbsolutePath(), name);
6665
sources.add(filePath);
6766
Files.write(filePath, Arrays.asList(lines), UTF_8, StandardOpenOption.CREATE);
6867
return this;

docgen/src/main/java/com/google/errorprone/BugPatternFileGenerator.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import java.io.Writer;
3434
import java.nio.file.Files;
3535
import java.nio.file.Path;
36-
import java.nio.file.Paths;
3736
import java.util.ArrayList;
3837
import java.util.Arrays;
3938
import java.util.HashMap;
@@ -110,7 +109,7 @@ public boolean processLine(String line) throws IOException {
110109
}
111110

112111
// replace spaces in filename with underscores
113-
Path checkPath = Paths.get(pattern.name.replace(' ', '_') + ".md");
112+
Path checkPath = Path.of(pattern.name.replace(' ', '_') + ".md");
114113

115114
try (Writer writer = Files.newBufferedWriter(outputDir.resolve(checkPath), UTF_8)) {
116115

docgen/src/main/java/com/google/errorprone/DocGenTool.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
import java.nio.charset.StandardCharsets;
3535
import java.nio.file.Files;
3636
import java.nio.file.Path;
37-
import java.nio.file.Paths;
3837
import java.util.HashSet;
3938
import java.util.List;
4039
import java.util.Set;
@@ -93,15 +92,15 @@ public static void main(String[] args) throws IOException {
9392
Options options = new Options();
9493
new JCommander(options).parse(args);
9594

96-
Path bugPatterns = Paths.get(options.bugPatterns);
95+
Path bugPatterns = Path.of(options.bugPatterns);
9796
if (!Files.exists(bugPatterns)) {
9897
usage("Cannot find bugPatterns file: " + options.bugPatterns);
9998
}
100-
Path explanationDir = Paths.get(options.explanations);
99+
Path explanationDir = Path.of(options.explanations);
101100
if (!Files.exists(explanationDir)) {
102101
usage("Cannot find explanations dir: " + options.explanations);
103102
}
104-
Path wikiDir = Paths.get(options.docsRepository);
103+
Path wikiDir = Path.of(options.docsRepository);
105104
Files.createDirectories(wikiDir);
106105
Path bugpatternDir = wikiDir.resolve("bugpattern");
107106
if (!Files.exists(bugpatternDir)) {

0 commit comments

Comments
 (0)