On Wed, 24 Apr 2024 08:29:56 GMT, Evemose <[email protected]> wrote:
>> src/java.base/share/classes/java/util/ArrayList.java line 380:
>>
>>> 378: }
>>> 379:
>>> 380: int findLastIndexInRange(Predicate<? super E> filter, int start,
>>> int end) {
>>
>> Suggestion:
>>
>> private int findLastIndexInRange(Predicate<? super E> filter, int start,
>> int end) {
>
> Yeah i thought about it but indexOfRange isnt private here so either there is
> a point in it or its just legacy without any particular meaning
It is legacy to avoid bridge generation from the SubList.
Before introduction of nestmates in JDK 11, private methods and fields called
by inner classes should be declared package-private, as javac has to generate
bridge methods at each call site to abide to JVM rules (inner classes are just
another class in the package so couldn't call private methods).
This is also the reason you can see patterns like
private static class Holder {
static final Value instance = Value.initialize();
}
where the `static final` is not `private` qualified.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/18639#discussion_r1577751899