-
Notifications
You must be signed in to change notification settings - Fork 746
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set up support for Multi-Release jars in Error Prone
and use it to work around a breaking change in `SignatureGenerator`. #3756 PiperOrigin-RevId: 661672308
- Loading branch information
Showing
6 changed files
with
170 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
-fixupmessages: "Classes found in the wrong directory"; restrict:=error; is:=warning |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
check_api/src/main/java/com/google/errorprone/util/ErrorProneSignatureGenerator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* 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 com.sun.tools.javac.util.Names; | ||
|
||
class ErrorProneSignatureGenerator extends Types.SignatureGenerator { | ||
|
||
private final com.sun.tools.javac.util.ByteBuffer buffer = | ||
new com.sun.tools.javac.util.ByteBuffer(); | ||
|
||
private final Names names; | ||
|
||
protected ErrorProneSignatureGenerator(Types types, Names names) { | ||
super(types); | ||
this.names = names; | ||
} | ||
|
||
@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); | ||
} | ||
|
||
@SuppressWarnings("CatchingUnchecked") // handles InvalidUtfException on JDK 21+ | ||
@Override | ||
public String toString() { | ||
try { | ||
return buffer.toName(names).toString(); | ||
} catch (Exception e) { | ||
throw new AssertionError(e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
check_api/src/main/java24/com/google/errorprone/util/ErrorProneSignatureGenerator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* 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 com.sun.tools.javac.util.Names; | ||
|
||
class ErrorProneSignatureGenerator extends Types.SignatureGenerator { | ||
|
||
private final com.sun.tools.javac.util.ByteBuffer buffer = | ||
new com.sun.tools.javac.util.ByteBuffer(); | ||
|
||
private final Names names; | ||
|
||
protected ErrorProneSignatureGenerator(Types types, Names names) { | ||
types.super(); | ||
this.names = names; | ||
} | ||
|
||
@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); | ||
} | ||
|
||
@SuppressWarnings("CatchingUnchecked") // handles InvalidUtfException on JDK 21+ | ||
@Override | ||
public String toString() { | ||
try { | ||
return buffer.toName(names).toString(); | ||
} catch (Exception e) { | ||
throw new AssertionError(e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters