From 69b4cbe0be6c62aadd9ccf19c86be3c7a42ebbb4 Mon Sep 17 00:00:00 2001 From: Stephan Schroevers Date: Sat, 10 Aug 2024 23:13:23 +0200 Subject: [PATCH] Make the build JDK 22-compatible (#1277) And verify the build with JDK 22.0.2. --- .github/workflows/build.yml | 2 +- .../refaster/plugin/RefasterRuleCompilerTaskListener.java | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 888d6cfc470..0a11222c4a1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,7 +10,7 @@ jobs: strategy: matrix: os: [ ubuntu-22.04 ] - jdk: [ 17.0.10, 21.0.2 ] + jdk: [ 17.0.10, 21.0.2, 22.0.2 ] distribution: [ temurin ] experimental: [ false ] include: diff --git a/refaster-compiler/src/main/java/tech/picnic/errorprone/refaster/plugin/RefasterRuleCompilerTaskListener.java b/refaster-compiler/src/main/java/tech/picnic/errorprone/refaster/plugin/RefasterRuleCompilerTaskListener.java index dbef9d0e44e..e9cd1a4461a 100644 --- a/refaster-compiler/src/main/java/tech/picnic/errorprone/refaster/plugin/RefasterRuleCompilerTaskListener.java +++ b/refaster-compiler/src/main/java/tech/picnic/errorprone/refaster/plugin/RefasterRuleCompilerTaskListener.java @@ -21,7 +21,6 @@ import com.sun.tools.javac.code.Symbol.PackageSymbol; import com.sun.tools.javac.main.JavaCompiler; import com.sun.tools.javac.util.Context; -import com.sun.tools.javac.util.Name; import java.io.IOException; import java.io.ObjectOutput; import java.io.ObjectOutputStream; @@ -137,10 +136,10 @@ private static String toPackageName(ClassSymbol symbol) { return enclosingPackage == null ? "" : enclosingPackage.toString(); } - private static CharSequence toSimpleFlatName(ClassSymbol symbol) { - Name flatName = symbol.flatName(); + private static String toSimpleFlatName(ClassSymbol symbol) { + String flatName = symbol.flatName().toString(); int lastDot = flatName.lastIndexOf((byte) '.'); - return lastDot < 0 ? flatName : flatName.subSequence(lastDot + 1, flatName.length()); + return lastDot < 0 ? flatName : flatName.substring(lastDot + 1); } private static void outputCodeTransformer(CodeTransformer codeTransformer, FileObject target)