git: openjdk/jdk-sandbox: classfile-api-dev-branch: Add List combining methods to ClassEntry (#35)
Adam Sotona
asotona at openjdk.org
Tue Sep 13 09:27:39 UTC 2022
Changeset: 39fd9298
Author: Dan Heidinga <heidinga at redhat.com>
Committer: Adam Sotona <asotona at openjdk.org>
Date: 2022-09-13 04:33:05 +0000
URL: https://git.openjdk.org/jdk-sandbox/commit/39fd9298d614a070266fb22e4546e288115ed194
Add List combining methods to ClassEntry (#35)
* Add List combining methods to ClassEntry
jdk.classfile.ClassEntry and java.lang.constant.ClassDesc are two ways
of describing similar data. Often when working with Attributes, we need to
create lists that combine ClassEntrys and ClassDescs into a single list
This PR adds support working with such lists by adding 4 static methods
to ClassEntry:
* List<CE> adding(List<CE> base, List<CE> additions)
* List<CE> adding(List<CE> base, CE... additions)
* List<CE> addingSymbols(List<CE> base, List<CD> additions)
* List<CE> addingSymbols(List<CE> base, CD...additions)
This methods convert from CD to CE to create a combined List<CE>.
The methods are null-hostile in the "additions" but do not check for
nulls in the "base" List.
The returned List is mutable so these methods can be common building
blocks for composing with other CE entries.
A test has been added that validates the existing behaviours.
* Return immutable lists rather than mutable ones.
A side-effect of this change is that the `base` List is now null-hostile
as well as the List.copyOf on the comination is null-hostile.
* Implement `List<CE> deduplicate(List<CE>)`
This allows users to add to a list without worrying about the existing
contents and in cases where they wish to apply a "no duplicates" invariant,
they can deduplicate the List
* Implement missing ConcreteEntry equals() methods
* Basic deduplicate() test
! src/java.base/share/classes/jdk/classfile/constantpool/ClassEntry.java
! src/java.base/share/classes/jdk/classfile/impl/ConcreteEntry.java
+ test/jdk/jdk/classfile/ClassEntryTest.java
More information about the jdk-sandbox-changes
mailing list