Home:ALL Converter>lucene java11 WARNING?

lucene java11 WARNING?

Ask Time:2020-05-26T02:58:16         Author:asma bzd

Json Formatter

I have this really simple java Lucene code that works in my friends PC but it makes a lot of errors for me ... we all use Lucene 5.3.1, I think that the problem is my jdk11

package project;
import java.io.IOException;

import java.nio.file.Path;
import java.nio.file.Paths;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.IntField;
import org.apache.lucene.document.TextField;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FSDirectory;
public class Act1 {
public static void main(String[] args) throws
IOException {
Document doc = new Document();
Field titre = new TextField("Titre", "mon A staticestimation technique",Field.Store.YES);
Field ref = new IntField("Year", 2001,Field.Store.YES);
Field auteurs = new TextField("Auteurs","TaewhanKim, Ki-Seok Chung, C. L. Liu",Field.Store.YES);
doc.add(titre);
doc.add(ref);
doc.add(auteurs);
Path p = Paths.get("C:\\Users\\user\\Desktop\\abc");
Directory dir = FSDirectory.open(p);
StandardAnalyzer analyzer = new StandardAnalyzer();
IndexWriterConfig config = new IndexWriterConfig(analyzer);
IndexWriter index = new IndexWriter(dir, config);
index.addDocument(doc);
index.close();
}
}

but it make those errors

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.apache.lucene.store.MMapDirectory$1 (file:/C:/Users/user/Downloads/lucene-5.3.1/core/lucene-core-5.3.1.jar) to method java.nio.DirectByteBuffer.cleaner()
WARNING: Please consider reporting this to the maintainers of org.apache.lucene.store.MMapDirectory$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Exception in thread "main" java.io.IOException: Unable to unmap the mapped buffer: MMapIndexInput(path="C:\Users\user\Desktop\abc\_1_Lucene50_0.doc")
    at org.apache.lucene.store.MMapDirectory$2.freeBuffer(MMapDirectory.java:329)
    at org.apache.lucene.store.ByteBufferIndexInput.freeBuffer(ByteBufferIndexInput.java:376)
    at org.apache.lucene.store.ByteBufferIndexInput.close(ByteBufferIndexInput.java:355)
    at org.apache.lucene.codecs.lucene50.Lucene50CompoundFormat.write(Lucene50CompoundFormat.java:92)
    at org.apache.lucene.index.IndexWriter.createCompoundFile(IndexWriter.java:4680)
    at org.apache.lucene.index.DocumentsWriterPerThread.sealFlushedSegment(DocumentsWriterPerThread.java:492)
    at org.apache.lucene.index.DocumentsWriterPerThread.flush(DocumentsWriterPerThread.java:459)
    at org.apache.lucene.index.DocumentsWriter.doFlush(DocumentsWriter.java:503)
    at org.apache.lucene.index.DocumentsWriter.flushAllThreads(DocumentsWriter.java:615)
    at org.apache.lucene.index.IndexWriter.doFlush(IndexWriter.java:3121)
    at org.apache.lucene.index.IndexWriter.flush(IndexWriter.java:3096)
    at org.apache.lucene.index.IndexWriter.shutdown(IndexWriter.java:1078)
    at org.apache.lucene.index.IndexWriter.close(IndexWriter.java:1123)
    at projet.Act1.main(Act1.java:31)
Caused by: java.lang.IllegalAccessException: class org.apache.lucene.store.MMapDirectory$2$1 cannot access class jdk.internal.ref.Cleaner (in module java.base) because module java.base does not export jdk.internal.ref to unnamed module @6e8dacdf
    at java.base/jdk.internal.reflect.Reflection.newIllegalAccessException(Reflection.java:361)
    at java.base/java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:591)
    at java.base/java.lang.reflect.Method.invoke(Method.java:558)
    at org.apache.lucene.store.MMapDirectory$2$1.run(MMapDirectory.java:322)
    at org.apache.lucene.store.MMapDirectory$2$1.run(MMapDirectory.java:314)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at org.apache.lucene.store.MMapDirectory$2.freeBuffer(MMapDirectory.java:314)
    ... 13 more

please help me to fix this problem ... and plz if there is anyone who is good in java and Lucene help I'm struggling I have a mini java/Lucene project and because of covid19 we didn't had any course... as you can see I can't even write a simple code

Author:asma bzd,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/62008933/lucene-java11-warning
yy