发生了非法的反射访问操作 Apache POI。

9

我正在使用Apache POI处理Excel文件,但是在Java 9中会出现这个消息。根据这篇文章JDK9:发生了非法的反射访问操作。org.python.core.PySystemState,我们应该等待开发人员解决此问题,但是我应该在我的新生产版本中保留它吗?我认为如果我忽略警告,那应该不会有问题。

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.apache.poi.util.DocumentHelper (file:/T:/Workspace/Java/Sections%20Manager/libs/poi/poi-ooxml-3.17.jar) to method com.sun.org.apache.xerces.internal.util.SecurityManager.setEntityExpansionLimit(int)
WARNING: Please consider reporting this to the maintainers of org.apache.poi.util.DocumentHelper
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

3
只是简单介绍一下Java 9的支持情况,以及如果您可以使用夜间构建 - http://apache-poi.1045710.n5.nabble.com/support-for-Java-9-td5729928.html。无论如何,是否继续使用这些警告取决于您的决定,我们其余的人只能根据您想要在生产中使用此代码的时间和目的来发表意见。 - Naman
2
如果我是你,我会至少在Apache POI问题跟踪器中创建一个错误(假设没有错误)。 - Alan Bateman
请参阅 https://bz.apache.org/bugzilla/show_bug.cgi?id=62151 和 https://bz.apache.org/bugzilla/show_bug.cgi?id=61572。另外,为了支持Java 10,还有https://bz.apache.org/bugzilla/show_bug.cgi?id=62187。 - centic
2个回答

6

添加更新后的"poi-ooxml"依赖项,即可解决上述所有警告。

<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi-ooxml</artifactId>
    <version>4.1.0</version>
</dependency>

谢谢!更新版本是4.1.2,解决了我的问题。 - MarkHu

2
我遇到的错误是: 警告:发生了非法反射访问操作 警告:org.apache.poi.util.DocumentHelper(file:/D:/Libary/poi-3.12/poi-ooxml-3.12-20150511.jar)通过非法反射访问方法com.sun.org.apache.xerces.internal.util.SecurityManager.setEntityExpansionLimit(int) 警告:请考虑向org.apache.poi.util.DocumentHelper的维护者报告此问题 警告:使用--illegal-access=warn启用进一步非法反射访问操作的警告 警告:所有非法访问操作将在未来的版本中被拒绝
请使用poi-3.6或更高版本,我使用的是poi-3。

1
没有必要重复错误信息 - 它与原帖相同(只有文件路径不同)。 - barbsan
我正在使用poi 3.8,但我仍然遇到了这个错误。 - ML72

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接