RFR: JDK-8315248: AssertionError in Name.compareTo [v2]

ExE Boss duke at openjdk.org
Wed Aug 30 23:46:17 UTC 2023

On Wed, 30 Aug 2023 17:52:55 GMT, Jonathan Gibbons <jjg at openjdk.org> wrote:

>> Please review a small fix to avoid an `AssertionError` coming out of `CharSequence.compare` for two `CharSequence` objects obtained from different instances of the `javax.lang.model` API.
>> Full details in the JBS issue and comments.
>> There are some minor cleanup edits as well, and some improvements to the code to throw AssertionError in a few places.
> Jonathan Gibbons has updated the pull request incrementally with one additional commit since the last revision:
>   Address review feedback

src/jdk.compiler/share/classes/com/sun/tools/javac/util/Utf8NameTable.java line 116:

> 114:                 return Convert.utf2string(getByteData(), getByteOffset(), getByteLength(), Convert.Validation.NONE);
> 115:             } catch (InvalidUtfException e) {
> 116:                 throw new AssertionError("invalid UTF8 data", e);

Note that this can simply use `throw new AssertionError(e)`, as the `AssertionError(Object)` constructor calls `Throwable::initCause` when the `Object` parameter is a `Throwable`:


PR Review Comment: https://git.openjdk.org/jdk/pull/15478#discussion_r1310950231

More information about the compiler-dev mailing list