0

While reading the data from excel using below I am getting the warnings: I am using JDK 12.0.1

public static void main(String[] args) throws FileNotFoundException {
    File src = new File("FilePath");
    FileInputStream fis = new FileInputStream(src);
    try {
    wb = new XSSFWorkbook(fis);
    sheet = wb.getSheet("Contacts");
    }
    catch (IOException e) 
    {
        e.getMessage();
    }

}
    public static String getdata(int rowNum, int colNum) throws IOException {
    cell = sheet.getRow(rowNum).getCell(colNum);
    String cellData =cell.getStringCellValue();
    return cellData;

}

}

Warnings: WARNING: An illegal reflective access operation has occurred

WARNING: Illegal reflective access by org.apache.poi.openxml4j.util.ZipSecureFile$1 (file:/C:/Users/.m2/repository/org/apache/poi/poi-ooxml/3.17/poi-ooxml-3.17.jar) to field java.io.FilterInputStream.in

WARNING: Please consider reporting this to the maintainers of org.apache.poi.openxml4j.util.ZipSecureFile$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

Tester
  • 67
  • 1
  • 9

1 Answers1

1

From the Apache POI FAQ at https://poi.apache.org/help/faq.html (emphasis added):

  1. Can Apache POI be compiled/used with Java 11?

Including the existing binaries on Java 11 as normal jar-files should work when using recent versions of Apache POI. You may see some warnings about illegal reflective access, but it should work fine despite those. We are working on getting the code changed so we avoid discouraged accesses in the future.

We also did some work to verify that compilation with Java 11 is working and that all unit-tests pass. So Apache POI should be ready to be used with current Java 11 releases.

NOTE: Apache POI does not yet fully support the Java module system as Apache POI is still supporting previous Java versions and the module system cannot be fully supported while maintaining such support. We are working on adding support for automatic modules.

FYI, jaxb in current versions also causes some warnings about reflective access, we cannot fix those until jaxb >= 2.4.0 is available, see https://stackoverflow.com/a/50251510/411846 for details, you can set a system property "com.sun.xml.bind.v2.bytecode.ClassTailor.noOptimize" to avoid this warning.

For compiling Apache POI, you should use at least version 4.1.0 when it becomes available or a recent trunk checkout until then.

racraman
  • 4,410
  • 1
  • 12
  • 15