【发布时间】:2019-11-01 06:36:44
【问题描述】:
我正在将一个巨大的单体应用程序从 java 1.7 迁移到 12,并且我希望以正确的方式完成它,并且尽可能少的 hack。理所当然地,我一直遇到这样的错误:
[ERROR] /home/idiot/projects/projects/blah/blah/src/blah/blah/blah/Blah.java:[8,18] package sun.nio.cs.ext is not visible
和
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project blah: Compilation failure
[ERROR] /home/idiot/projects/blah/blah/src/blah/blah/blah/Bblah.java:[152,42] package com.sun.org.apache.xerces.internal.dom is not visible
[ERROR] (package com.sun.org.apache.xerces.internal.dom is declared in module java.xml, which does not export it)
以及诸如此类的警告
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.python.google.common.base.internal.Finalizer (file:/home/idiot/.m2/repository/own/plugin/own-plugin-1.jar) to field java.lang.Thread.inheritableThreadLocals
WARNING: Please consider reporting this to the maintainers of org.python.google.common.base.internal.Finalizer
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
模块化这个庞然大物的网络应用似乎是不可能的,甚至没有合适的教程可供查找。 大多数 google 和 stack 结果都是适用于 pre java 11 环境的解决方案。大多数 google-fu 建议使用正确的包,而不是现在隐藏/过时的包。
挑战和我的问题是,如何找出现在过时的 API 被替换为什么?
有成千上万的文件使用反射,com.sun.org,sun.misc 包,一旦找到找到替换包的步骤,如何解决这个问题?只需手动浏览数千个文件并更新?
【问题讨论】:
标签: java migration openjdk-12