Hi Robert,

This was discussed on core-libs at some point, but I can't find the
thread and the outcome of that conversation right now (damn it).

I believe the answer was that these covariant changes are
forward-compatible so that existing code works with 1.9 and if you're
compiling with backward compatibility in mind you should compile
against the target JDK of your choice.

Dawid

On Mon, Mar 30, 2015 at 4:19 AM, Robert Muir <rcm...@gmail.com> wrote:
> Hi,
>
> If I compile lucene with a java 9 compiler (using -source 1.8 -target
> 1.8 like our build does), then the resulting jar file cannot actually
> be used with a java 8 JVM.
>
> The reason is, in java 9 ByteBuffer.class got some new covariant overrides:
> e.g. ByteBuffer.java has position(int) that returns ByteBuffer, but
> this does not exist on java 8 (the position method is only in
> Buffer.java returning Buffer).
>
> This leads to an exception like this (I am sure there are other
> problems, its just the first one you will hit):
>
> Exception in thread "main" java.lang.NoSuchMethodError:
> java.nio.ByteBuffer.position(I)Ljava/nio/ByteBuffer;
>     at 
> org.apache.lucene.store.ByteBufferIndexInput$SingleBufferImpl.<init>(ByteBufferIndexInput.java:414)
>     at 
> org.apache.lucene.store.ByteBufferIndexInput.newInstance(ByteBufferIndexInput.java:55)
>     at org.apache.lucene.store.MMapDirectory.openInput(MMapDirectory.java:216)
>     at org.apache.lucene.store.Directory.openChecksumInput(Directory.java:110)
>     at org.apache.lucene.index.SegmentInfos.readCommit(SegmentInfos.java:268)
>     at org.apache.lucene.index.SegmentInfos$1.doBody(SegmentInfos.java:359)
>     at org.apache.lucene.index.SegmentInfos$1.doBody(SegmentInfos.java:356)
>     at 
> org.apache.lucene.index.SegmentInfos$FindSegmentsFile.run(SegmentInfos.java:574)
>     at 
> org.apache.lucene.index.SegmentInfos$FindSegmentsFile.run(SegmentInfos.java:526)
>     at 
> org.apache.lucene.index.SegmentInfos.readLatestCommit(SegmentInfos.java:361)
>     at 
> org.apache.lucene.index.DirectoryReader.listCommits(DirectoryReader.java:228)
>
> Is this expected behavior? Do we need to fix our build to also require
> a java 8 JDK on the developers machine, and set bootclasspath, or is
> -source/-target 1.8 supposed to "just work" without it like it did
> before?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
> For additional commands, e-mail: dev-h...@lucene.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org

Reply via email to