diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 06f89f32281..bb5caa9e35d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -52,6 +52,18 @@ jobs: access_token: ${{ github.token }} - name: 'Check out repository' uses: actions/checkout@v3 + - name: 'Set up JDK 11' + uses: actions/setup-java@v4 + with: + java-version: 11 + distribution: 'zulu' + cache: 'maven' + - name: 'Set up JDK 24 from jdk.java.net' + uses: oracle-actions/setup-java@v1 + with: + website: jdk.java.net + release: 24 + cache: 'maven' - name: 'Set up JDK ${{ matrix.java }} from jdk.java.net' if: ${{ matrix.java == 'EA' }} uses: oracle-actions/setup-java@v1 @@ -63,9 +75,7 @@ jobs: if: ${{ matrix.java != 'EA' }} uses: actions/setup-java@v4 with: - java-version: | - 11 - ${{ matrix.java }} + java-version: ${{ matrix.java }} distribution: 'zulu' cache: 'maven' - name: 'Install' diff --git a/bnd.bnd b/bnd.bnd new file mode 100644 index 00000000000..8f44eafbfc8 --- /dev/null +++ b/bnd.bnd @@ -0,0 +1 @@ +-fixupmessages: "Classes found in the wrong directory"; restrict:=error; is:=warning diff --git a/check_api/pom.xml b/check_api/pom.xml index 21c7a05fcd5..ece5c1d39cd 100644 --- a/check_api/pom.xml +++ b/check_api/pom.xml @@ -163,8 +163,36 @@ + + + default-compile + + + 11 + + + + + java24 + + + 24 + + + + ${basedir}/src/main/java24 + + + ${project.build.outputDirectory}/META-INF/versions/24 + + + + + diff --git a/check_api/src/main/java/com/google/errorprone/util/ErrorProneSignatureGenerator.java b/check_api/src/main/java/com/google/errorprone/util/ErrorProneSignatureGenerator.java new file mode 100644 index 00000000000..9206dd13719 --- /dev/null +++ b/check_api/src/main/java/com/google/errorprone/util/ErrorProneSignatureGenerator.java @@ -0,0 +1,57 @@ +/* + * Copyright 2024 The Error Prone Authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.errorprone.util; + +import com.sun.tools.javac.code.Types; +import com.sun.tools.javac.util.Name; + +import java.util.Arrays; + +import static java.nio.charset.StandardCharsets.UTF_8; + +class ErrorProneSignatureGenerator extends Types.SignatureGenerator { + + private final com.sun.tools.javac.util.ByteBuffer buffer = + new com.sun.tools.javac.util.ByteBuffer(); + + protected ErrorProneSignatureGenerator(Types types) { + super(types); + } + + @Override + protected void append(char ch) { + buffer.appendByte(ch); + } + + @Override + protected void append(byte[] ba) { + buffer.appendBytes(ba); + } + + @Override + protected void append(Name name) { + buffer.appendName(name); + } + + @Override + public String toString() { + // We could use buffer.toName(Names), but we want a string anyways and this + // avoids plumbing a Context or instances of Names through. + // Names always uses UTF-8 internally. + return new String(Arrays.copyOf(buffer.elems, buffer.length), UTF_8); + } +} diff --git a/check_api/src/main/java/com/google/errorprone/util/Signatures.java b/check_api/src/main/java/com/google/errorprone/util/Signatures.java index eae84060f2c..416b27ea92a 100644 --- a/check_api/src/main/java/com/google/errorprone/util/Signatures.java +++ b/check_api/src/main/java/com/google/errorprone/util/Signatures.java @@ -16,7 +16,6 @@ package com.google.errorprone.util; -import static java.nio.charset.StandardCharsets.UTF_8; import static java.util.stream.Collectors.joining; import com.sun.tools.javac.code.BoundKind; @@ -25,60 +24,25 @@ import com.sun.tools.javac.code.Type; import com.sun.tools.javac.code.Types; import com.sun.tools.javac.code.Types.DefaultTypeVisitor; -import com.sun.tools.javac.code.Types.SignatureGenerator; import com.sun.tools.javac.util.Name; -import java.util.Arrays; /** Signature generation. */ public final class Signatures { /** Returns the binary names of the class. */ public static String classDescriptor(Type type, Types types) { - SigGen sig = new SigGen(types); + ErrorProneSignatureGenerator sig = new ErrorProneSignatureGenerator(types); sig.assembleClassSig(types.erasure(type)); return sig.toString(); } /** Returns a JVMS 4.3.3 method descriptor. */ public static String descriptor(Type type, Types types) { - SigGen sig = new SigGen(types); + ErrorProneSignatureGenerator sig = new ErrorProneSignatureGenerator(types); sig.assembleSig(types.erasure(type)); return sig.toString(); } - private static class SigGen extends SignatureGenerator { - - private final com.sun.tools.javac.util.ByteBuffer buffer = - new com.sun.tools.javac.util.ByteBuffer(); - - protected SigGen(Types types) { - super(types); - } - - @Override - protected void append(char ch) { - buffer.appendByte(ch); - } - - @Override - protected void append(byte[] ba) { - buffer.appendBytes(ba); - } - - @Override - protected void append(Name name) { - buffer.appendName(name); - } - - @Override - public String toString() { - // We could use buffer.toName(Names), but we want a string anyways and this - // avoids plumbing a Context or instances of Names through. - // Names always uses UTF-8 internally. - return new String(Arrays.copyOf(buffer.elems, buffer.length), UTF_8); - } - } - /** * Pretty-prints a method signature for use in diagnostics. * diff --git a/check_api/src/main/java24/com/google/errorprone/util/ErrorProneSignatureGenerator.java b/check_api/src/main/java24/com/google/errorprone/util/ErrorProneSignatureGenerator.java new file mode 100644 index 00000000000..f897daf5da7 --- /dev/null +++ b/check_api/src/main/java24/com/google/errorprone/util/ErrorProneSignatureGenerator.java @@ -0,0 +1,57 @@ +/* + * Copyright 2024 The Error Prone Authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.errorprone.util; + +import com.sun.tools.javac.code.Types; +import com.sun.tools.javac.util.Name; + +import java.util.Arrays; + +import static java.nio.charset.StandardCharsets.UTF_8; + +class ErrorProneSignatureGenerator extends Types.SignatureGenerator { + + private final com.sun.tools.javac.util.ByteBuffer buffer = + new com.sun.tools.javac.util.ByteBuffer(); + + protected ErrorProneSignatureGenerator(Types types) { + types.super(); + } + + @Override + protected void append(char ch) { + buffer.appendByte(ch); + } + + @Override + protected void append(byte[] ba) { + buffer.appendBytes(ba); + } + + @Override + protected void append(Name name) { + buffer.appendName(name); + } + + @Override + public String toString() { + // We could use buffer.toName(Names), but we want a string anyways and this + // avoids plumbing a Context or instances of Names through. + // Names always uses UTF-8 internally. + return new String(Arrays.copyOf(buffer.elems, buffer.length), UTF_8); + } +} diff --git a/pom.xml b/pom.xml index 1a2615bb86d..2992590fe2c 100644 --- a/pom.xml +++ b/pom.xml @@ -180,7 +180,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.10.1 + 3.13.0 11 11 @@ -264,6 +264,26 @@ false + + org.apache.maven.plugins + maven-toolchains-plugin + 3.2.0 + + + + 11 + 24 + + + + + + + toolchain + + + +