[
https://issues.apache.org/jira/browse/LUCENE-7966?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16169476#comment-16169476
]
Uwe Schindler commented on LUCENE-7966:
---------------------------------------
Hi,
I took Robert's latest patch, committed it to my Github fork and developed it a
bit more: I added a stub generator (that can only be used with Java 9) to
generate stub classes that only have the Java 9 signatures, but no private
stuff or method bodies. This is done by a groovy script, that can be executed
(requires Java 9 as JAVA_HOME): {{ant generate-java9-stubs}}. The files
generated by this are committed, so nobody needs java 9 to compile lucene. The
license should be no problem, as no code is involved. This is mentioned in the
{{README.txt}} in the folder. The stub classes are compiled with class version
of Java 8.
When compiling the MR-JAR, the standard Java compiler is used, but we prepend
our stub classes to the bootclasspath of javac. This allows us to compile the
MR-JAR file also with Java 8. If Java 9 is detected, we don't add anything to
bootclasspath.
The branch is here:
https://github.com/apache/lucene-solr/compare/master...uschindler:jira/LUCENE-7966
> build mr-jar and use some java 9 methods if available
> -----------------------------------------------------
>
> Key: LUCENE-7966
> URL: https://issues.apache.org/jira/browse/LUCENE-7966
> Project: Lucene - Core
> Issue Type: Improvement
> Components: general/build
> Reporter: Robert Muir
> Attachments: LUCENE-7966.patch, LUCENE-7966.patch, LUCENE-7966.patch,
> LUCENE-7966.patch, LUCENE-7966.patch
>
>
> 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:
> {code}
> 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
> {code}
> 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.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]