Java 9模块和类路径地狱:类名冲突 [英] Java 9 modules and classpath hell: conflicting class names

查看:147
本文介绍了Java 9模块和类路径地狱:类名冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据说Java 9模块将解决类路径问题。
但是,我正在考虑以下情况:
模块A使用模块B和C。两个模块都将导出具有相同名称和包的类。

It is said that java 9 modules will solve classpath hell. However, I am thinking about the following situation: Module A uses modules B and C. Both modules will export a class with same name and package. How will the classloading issue be solved here?

推荐答案

在Java 9模块系统中禁止这种情况。如果同一层中的两个模块具有相同的软件包,则Java 9将在启动时失败,并显示以下错误:

This situation is forbidden in the Java 9 module system. If two modules in the same layer have the same package, Java 9 will fail at startup with an error:

java.lang.LayerInstantiationException:
    Package <package_name> in both module <moduleB_name> and module <moduleC_name>

这篇关于Java 9模块和类路径地狱:类名冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆