什么是Java罐子有重复类的含义是什么? [英] What are the implications of having duplicate classes in java jar?

查看:219
本文介绍了什么是Java罐子有重复类的含义是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用蚂蚁构建Java jar文件。我需要使用zipfileset SRC =xxx.jarzipfileset SRC =yyy.jar无一不xxx.jar和yyy.jar包括其他罐子具有相同的完全限定类名的类。因此产生的JAR文件重复类名。什么是有重复的可能产生的影响?

I am building java jar file using ant. I need to include additional jars using "zipfileset src="xxx.jar" "zipfileset src="yyy.jar" and both xxx.jar and yyy.jar have the classes with the SAME fully-qualified class names. So the resulting jar file has duplicate class names. What are the possible implications of having duplicates?

感谢您。

推荐答案

如果他们的重复的实现,没有什么&ndash的;它不会不管里面装

If they're duplicate implementations, nothing–it wouldn't matter which is loaded.

如果没有,你在类加载顺序的怜悯,不是你想可能会得到不同的版本。

If not, you're at the mercy of class load order, and may get a different version than you want.

它的的指定路径条目将按照所列的顺序进行搜索(按的这个类路径文档)。但如果你在classpath中创建的完全控制,这只是相关的(不像一个Web应用程序,例如)。

It is specified that classpath entries will be searched in the order listed (as per this classpath doc). but that's only relevant if you're in complete control of classpath creation (unlike in a web app, for example).

(带该类路径通配符使订单不确定性的警告。)

这篇关于什么是Java罐子有重复类的含义是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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