简体   繁体   English

字母命名Java类文件从何而来?

[英]where do the alphabet naming java class files come from?

guys, I used a decompiler jd-gui today and found something quite weird to me. 伙计们,我今天使用了反编译器jd-gui,发现我觉得很奇怪。

Let's say I have a jar file, lib.jar, I decompiled it. 假设我有一个jar文件lib.jar,我反编译了它。 It came out that there were some class files named like A.class, B.class, a.class, etc, under same package. 结果是,在同一包下有一些类文件,例如A.class,B.class,a.class等。 When I tried to paste the decompiled source files into eclipse project, but IDE said it would not accept A.class and a.class under the same folder. 当我尝试将反编译的源文件粘贴到eclipse项目中时,IDE表示它不会接受同一文件夹下的A.class和a.class。 How could it be? 怎么会这样? I guess no one named his/her class files from a to z. 我猜没有人从a到z命名他/她的课程文件。 But the decompiler told me so. 但是反编译器是这样告诉我的。

Also I tried to import lib.jar in my project, found that I cannot touch any public class or interface under that package where a.class and A.class resides in. No tips came out when I typed into that package, eg, "import firm.tools." 另外,我尝试将lib.jar导入到我的项目中,发现我无法触摸a.class和A.class所在的那个包下的任何公共类或接口。当我键入该包时,没有提示出现,例如,“进口firm.tools。”

Could anyone tell me the reason? 谁能告诉我原因? Thanks in advance, and happy new year! 在此先感谢您,新年快乐!

The jar file you have probably contains obfuscated class files. 您的jar文件可能包含混淆的类文件。 Obfuscated files have identifiers renamed to make them harder to understand by human readers. 混淆文件的标识符已重命名,以使读者难以理解。 (Obfuscation does much more than just rename identifiers, but that's one of the things obfuscation usually does.) (混淆处理不仅仅只是重命名标识符,而且这是混淆处理通常要做的事情之一。)

but IDE said it would not accept A.class and a.class under the same folder. 但是IDE表示将不接受同一文件夹下的A.class和a.class。

This part is likely due to the fact that you're using a case-insensitive filesystem (eg NTFS on Windows). 这部分可能是由于您使用的是不区分大小写的文件系统(例如Windows上的NTFS)。 Thus it isn't possible for the IDE to create distinct files for A.class and a.class since the OS views them as equivalent filenames. 因此,IDE不可能为A.classa.class创建不同的文件,因为OS a.class它们视为等效的文件名。 This is not true for all systems, nor for the Java specification - hence it is possible to define Java classes that differ only in case (though this is not recommended due to the problem you've just illustrated). 并非所有系统都适用,Java规范也不适用-因此可以定义仅在大小写不同的Java类(尽管由于您刚刚说明的问题,不建议这样做)。

(As for the names themselves, I agree with Chris that this is likely the result of obfuscation.) (至于名字本身,我同意克里斯的看法,这可能是混淆的结果。)

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

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