Skip to content

Commit 261d0f8

Browse files
authored
Replace AutoValue with records (#54)
Both value classes (MethodReference, MethodCalls) are simple data holders with no builders or custom equality, so records map cleanly on Java 26. Drops the auto-value annotation processor, the auto-value-annotations dependency, the jacoco AutoValue_* exclude, and the Error Prone -XepExcludedPaths arg that was only there to ignore AutoValue's generated sources.
1 parent c8c3e27 commit 261d0f8

3 files changed

Lines changed: 9 additions & 44 deletions

File tree

pom.xml

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,14 @@
6363
<compilerArgs>
6464
<arg>-XDcompilePolicy=simple</arg>
6565
<arg>--should-stop=ifError=FLOW</arg>
66-
<arg>-Xplugin:ErrorProne -XepExcludedPaths:.*/target/generated-(test-)?sources/.*</arg>
66+
<arg>-Xplugin:ErrorProne</arg>
6767
</compilerArgs>
6868
<annotationProcessorPaths>
6969
<path>
7070
<groupId>com.google.errorprone</groupId>
7171
<artifactId>error_prone_core</artifactId>
7272
<version>2.49.0</version>
7373
</path>
74-
<path>
75-
<groupId>com.google.auto.value</groupId>
76-
<artifactId>auto-value</artifactId>
77-
<version>${auto-value.version}</version>
78-
</path>
7974
</annotationProcessorPaths>
8075
</configuration>
8176
</plugin>
@@ -120,11 +115,6 @@
120115
<groupId>org.jacoco</groupId>
121116
<artifactId>jacoco-maven-plugin</artifactId>
122117
<version>${jacoco.version}</version>
123-
<configuration>
124-
<excludes>
125-
<exclude>**/AutoValue_*</exclude>
126-
</excludes>
127-
</configuration>
128118
<executions>
129119
<execution>
130120
<goals>
@@ -176,7 +166,6 @@
176166

177167
<properties>
178168
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
179-
<auto-value.version>1.11.1</auto-value.version>
180169
<jacoco.version>0.8.14</jacoco.version>
181170
</properties>
182171

@@ -201,12 +190,6 @@
201190
<artifactId>guice</artifactId>
202191
<version>6.0.0</version>
203192
</dependency>
204-
<dependency>
205-
<groupId>com.google.auto.value</groupId>
206-
<artifactId>auto-value-annotations</artifactId>
207-
<version>${auto-value.version}</version>
208-
<scope>provided</scope>
209-
</dependency>
210193
<dependency>
211194
<groupId>com.google.truth</groupId>
212195
<artifactId>truth</artifactId>

src/main/java/com/google/acai/GuiceberryCompatibilityModule.java

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package com.google.acai;
1818

19-
import com.google.auto.value.AutoValue;
2019
import com.google.inject.AbstractModule;
2120
import com.google.inject.Inject;
2221
import com.google.inject.Injector;
@@ -39,14 +38,14 @@
3938
class GuiceberryCompatibilityModule extends AbstractModule {
4039
private static final String GUICEBRRY_TEST_SCOPED_ANNOTATION = "com.google.guiceberry.TestScoped";
4140
private static final MethodReference GUICEBERRY_ENV_MAIN_RUN =
42-
MethodReference.create("com.google.guiceberry.GuiceBerryEnvMain", "run");
41+
new MethodReference("com.google.guiceberry.GuiceBerryEnvMain", "run");
4342
private static final MethodReference TEST_WRAPPER_RUN_BEFORE_TEST =
44-
MethodReference.create("com.google.guiceberry.TestWrapper", "toRunBeforeTest");
43+
new MethodReference("com.google.guiceberry.TestWrapper", "toRunBeforeTest");
4544
private static final MethodReference TEST_SCOPE_LISTENER_ENTERING_SCOPE =
46-
MethodReference.create(
45+
new MethodReference(
4746
"com.google.inject.testing.guiceberry.TestScopeListener", "enteringScope");
4847
private static final MethodReference TEST_SCOPE_LISTENER_EXITING_SCOPE =
49-
MethodReference.create(
48+
new MethodReference(
5049
"com.google.inject.testing.guiceberry.TestScopeListener", "exitingScope");
5150

5251
@Override
@@ -113,14 +112,5 @@ private static Optional<Class<?>> classForName(String className) {
113112
}
114113
}
115114

116-
@AutoValue
117-
abstract static class MethodReference {
118-
static MethodReference create(String className, String methodName) {
119-
return new AutoValue_GuiceberryCompatibilityModule_MethodReference(className, methodName);
120-
}
121-
122-
abstract String className();
123-
124-
abstract String methodName();
125-
}
115+
record MethodReference(String className, String methodName) {}
126116
}

src/test/java/com/google/acai/AcaiTest.java

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import static org.mockito.Mockito.times;
2323
import static org.mockito.Mockito.verify;
2424

25-
import com.google.auto.value.AutoValue;
2625
import com.google.common.testing.TearDownAccepter;
2726
import com.google.inject.AbstractModule;
2827
import com.google.inject.BindingAnnotation;
@@ -283,20 +282,13 @@ private void afterTest() {
283282
}
284283
}
285284

286-
@AutoValue
287-
abstract static class MethodCalls {
288-
abstract int beforeSuite();
289-
290-
abstract int beforeTest();
291-
292-
abstract int afterTest();
293-
285+
record MethodCalls(int beforeSuite, int beforeTest, int afterTest) {
294286
static MethodCalls create() {
295-
return new AutoValue_AcaiTest_MethodCalls(0, 0, 0);
287+
return new MethodCalls(0, 0, 0);
296288
}
297289

298290
static MethodCalls create(int beforeSuite, int beforeTest, int afterTest) {
299-
return new AutoValue_AcaiTest_MethodCalls(beforeSuite, beforeTest, afterTest);
291+
return new MethodCalls(beforeSuite, beforeTest, afterTest);
300292
}
301293

302294
MethodCalls incrementBeforeSuite() {

0 commit comments

Comments
 (0)