-
Notifications
You must be signed in to change notification settings - Fork 746
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multi-Release jar experiments #4521
Closed
Closed
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
f208837
Multi-Release jar experiments
cushon 645b7d4
Require a toolchain for 24
cushon f8d424b
Update ci.yml
cushon 863f653
Update ci.yml
cushon 671f00f
Update ci.yml
cushon a7163fb
Update ci.yml
cushon 3282ac9
Update ci.yml
cushon 99e30ae
Update ci.yml
cushon 705d027
Update ci.yml
cushon e4f8aad
24 config
cushon 7bf5598
.
cushon 7b382a9
.
cushon 7104b12
.
cushon 1f4a9c6
.
cushon 2a7963b
.
cushon 326f6f3
.
cushon 69a4825
.
cushon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
57 changes: 57 additions & 0 deletions
57
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,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); | ||
} | ||
} |
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
57 changes: 57 additions & 0 deletions
57
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,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); | ||
} | ||
} |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recall once running a benchmark, on the basis of which I concluded that the JVM may be smart enough to conclude that in a scenario such as this one, the
String
constructor doesn't need to make a defensive copy of the provided array, as it'll hold the only remaining reference. Still, perhaps it's nicer to instead do:(And likewise for the Java 24 variant below.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, good point. I had separately been considering refactoring this to pass through a
VisitorState
to these methods instead ofType
, which would allow usingbuffer.toName(Names)
as the comment here notes. I'll take a look at finishing that.