RFR: 8310843: Reimplement ByteArray and ByteArrayLittleEndian with Unsafe [v10]
Uwe Schindler
uschindler at openjdk.org
Fri Jul 21 18:54:45 UTC 2023
On Fri, 21 Jul 2023 15:14:23 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
>> So have you thought of making this low-level classes public so we outside users no longer need to deal with VarHandles?
> I believe this is beyond the scope of this PR.
Sure, I brought this up here but yes, it is not really the scope of this PR. It is just another idea that this class could be of more wide use although outside of this PR and also outside of Lucene. Actually it would be nice to have it public, but I know this involves creating a JEP and so on. If there's interest I could start on proposing something like this on mailing list, later creating a JEP or whatever else is needed.
P.S.: Actually for a 3rd party user the whole thing is not much complicated. You only need a class to allocate the VarHandles and then use them from code, you don't even need the wrapper methods (although the ymake it nicer to read and you don't need the cast of return value). As there is no security involved, one can have those VarHandles as public static fields in some utility class: https://lucene.apache.org/core/9_7_0/core/org/apache/lucene/util/BitUtil.html; Usage of them is quite simple then: https://github.com/apache/lucene/blob/59c56a0aed9a43d24c676376b5d50c5c6518e3bc/lucene/core/src/java/org/apache/lucene/store/ByteArrayDataInput.java#L96 (there are many of those throughout Lucene's code)
So I agree with your ideas, we have to decide what is best for this PR. I tend to think that those 2 options are good:
- Use ByteBuffer in classfile API
- commit the PR as proposed here (looks fine to me).
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/14636#discussion_r1270985286
More information about the core-libs-dev
mailing list