Adopting SequencedCollection via multi-release jars?

Kevin Bourrillion kevin.bourrillion at oracle.com
Thu Feb 6 15:29:01 UTC 2025


Thanks Fabian!

I am trying to get a conversation going about this, and I really appreciate this prod. The fact that a library API like Guava's still can’t use APIs from Java 9 (7 years later) is pretty sad.

I am pretty sure there won't be any quick fixes, but I do think we need to push on this somehow.

I hope I can come back with something useful to say, but it will probably take some time.




> On Feb 4, 2025, at 8:36 AM, Fabian Meumertzheim <fabian at buildbuddy.io> wrote:
> 
> Guava provides immutable collections such as ImmutableList that are
> naturally sequenced. It would be useful to integrate it with Java 21's
> SequencedCollection interface. However, Guava needs to keep supporting
> Java 11 for the foreseeable future.
> 
> An idea that may allow Guava to remain compatible but still adopt
> SequencedCollection today would be to have classes implement a
> vendored and renamed version of the SequencedCollection interface and
> "override" it with an interface that extends the actual
> SequencedCollection interface in the 21 subdirectory of a
> multi-release JAR. However, the JAR specification states that:
> 
> "The public API exported by the classes in a multi-release JAR file
> must be exactly the same across versions, ..."
> 
> Would the public API be considered to be identical in the case where
> only the hierarchy of implemented interfaces changes? If not, is there
> another supported way for a class to start implementing
> SequencedCollection while remaining compatible with JDK versions that
> don't provide the interface yet?
> 
> Best,
> Fabian



More information about the core-libs-dev mailing list