简体   繁体   English

Java 构建问题 - Java 8 到 Java 11 迁移

[英]Java build issues - Java 8 to Java 11 migration

We're migrating from Java 8 to Java 11.我们正在从 Java 8 迁移到 Java 11。
We have a legacy project Y which depends on another legacy project X.我们有一个遗留项目 Y,它依赖于另一个遗留项目 X。
The project X has no sources, it's just a collection of about 300 jars.项目X没有来源,它只是大约300个jars的集合。
The build is ant-based, no maven.该构建是基于蚂蚁的,没有 maven。

I cannot build the project Y now with JDK 11 (neither in Eclipse, nor externally)我现在无法使用 JDK 11 构建项目 Y(在 Eclipse 中,也没有在外部)
because it says "The package org.w3c.dom is accessible from more than one module: , java.xml"因为它说“package org.w3c.dom 可以从多个模块访问:java.xml”

I get this error in Eclipse on a line which does import org.w3c.dom.Document;我在 Eclipse 的行中收到此错误,该行确实import org.w3c.dom.Document;

When I do an external build (with ant, outside of Eclipse) I can build successfully (with basically the same build.xml as under JDK 8)?!当我进行外部构建(使用 ant,在 Eclipse 之外)时,我可以成功构建(使用与 JDK 8 下基本相同的 build.xml)?! How come only Eclipse is complaining?.为什么只有 Eclipse 在抱怨? Is it because of this javac bug which I reference below.是因为我在下面引用的这个 javac 错误。

I was reading here (these are directly related to my issues):我在这里阅读(这些与我的问题直接相关):

https://stackoverflow.com/a/53824670/2300597 https://stackoverflow.com/a/53824670/2300597
The package org.w3c.dom is accessible from more than one module: <unnamed>, java.xml package org.w3c.dom 可从多个模块访问:<未命名>、java.xml
http://mail.openjdk.java.net/pipermail/jigsaw-dev/2018-December/014077.html http://mail.openjdk.java.net/pipermail/jigsaw-dev/2018-December/014077.html

but I am still unable to fix these build issues.但我仍然无法解决这些构建问题。
I tried 7-8 different things but nothing helps.我尝试了 7-8 种不同的东西,但没有任何帮助。

I think the clash is between org.w3c.dom package from some of these 300 jars and the same package in the JDK module java.xml . I think the clash is between org.w3c.dom package from some of these 300 jars and the same package in the JDK module java.xml .

The weird thing is that org.w3c.dom.Document doesn't seem to be present in any of these 300 jars, it's just that other classes from the same package are present in jars.奇怪的是, org.w3c.dom.Document似乎不存在于这 300 个 jars 中的任何一个中,只是来自同一 package 的其他类存在于 ZBE1587EA25D1C06C0B7D8Z3C 中。

I am deadlocked, I see no way to fix this.我陷入僵局,我看不出有什么办法解决这个问题。
I cannot lightly change project X because it's a shared library used by multiple legacy projects.我不能轻易更改项目 X,因为它是多个旧项目使用的共享库。
On the other hand, I cannot remove java.xml module from the build path of project Y.另一方面,我无法从项目 Y 的构建路径中删除java.xml模块。
So I don't know how to approach this.所以我不知道如何处理这个问题。

Isn't there some way to just say: OK, use the classes from the JDK first, then use those from the JARs (even though they share the same package, they are not the same class).是不是有什么办法可以说:好的,首先使用JDK中的类,然后使用JARs中的那些(即使它们共享相同的package,它们也不是同一个类)。

What is the right way to fix these errors?解决这些错误的正确方法是什么?

Starting from version 9 Java supports JPMS (Java Platform Module System).从版本 9 Java 开始支持 JPMS(Java 平台模块系统)。

In the Java Platform Module System it is not allowed to use the same package in more than one module.在 Java 平台模块系统中,不允许在多个模块中使用相同的 package。 So, the solution is to find modules (jars) that exports this package org.w3c.dom and to remove one of the modules or package in it.因此,解决方案是找到导出此 package org.w3c.dom的模块(jar)并删除其中一个模块或 package。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM