Details
-
Improvement
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
New
Description
See background: http://openjdk.java.net/jeps/238
It would be nice to use some of the newer array methods and range checking methods in java 9 for example, without waiting for lucene 10 or something. If we build an MR-jar, we can start migrating our code to use java 9 methods right now, it will use optimized methods from java 9 when thats available, otherwise fall back to java 8 code.
This patch adds:
Objects.checkIndex(int,int) Objects.checkFromToIndex(int,int,int) Objects.checkFromIndexSize(int,int,int) Arrays.mismatch(byte[],int,int,byte[],int,int) Arrays.compareUnsigned(byte[],int,int,byte[],int,int) Arrays.equal(byte[],int,int,byte[],int,int) // did not add char/int/long/short/etc but of course its possible if needed
It sets these up in org.apache.lucene.future as 1-1 mappings to java methods. This way, we can simply directly replace call sites with java 9 methods when java 9 is a minimum. Simple 1-1 mappings mean also that we only have to worry about testing that our java 8 fallback methods work.
I found that many of the current byte array methods today are willy-nilly and very lenient for example, passing invalid offsets at times and relying on compare methods not throwing exceptions, etc. I fixed all the instances in core/codecs but have not looked at the problems with AnalyzingSuggester. Also SimpleText still uses a silly method in ArrayUtil in similar crazy way, have not removed that one yet.
Attachments
Attachments
Issue Links
- breaks
-
LUCENE-8156 patch-mrjar-classes fails if an old version of ASM is on the Ant classpath
- Closed
- is related to
-
LUCENE-7968 AnalyzingSuggester's comparator compares incorrectly
- Closed
-
LUCENE-8154 TODO List when upgrading to Java 9 as minimum requirement
- Resolved
-
LUCENE-8155 Add Java 9 support to smoke tester
- Closed
- supercedes
-
LUCENE-3654 Optimize BytesRef comparator to use Unsafe long based comparison (when possible)
- Resolved