将java外部类编译为内部类 [英] will java outer class compilation effects inner class

查看:131
本文介绍了将java外部类编译为内部类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要为websphere提供一个补丁。我有一个主要的java类,它有三个内部类。我对主类的代码更改很少,但对内部类没有任何更改。现在我的问题是,我是否需要将所有内部类和主类文件作为补丁或主类的一部分给予足够的?

I need to give a patch to websphere. where I have a main java class which has three inner classes. I have few code changes to main class but no changes to any inner classes. Now my question is should I need to give all innerclasses along with main class file as a part of patch or main class alone sufficient?

推荐答案

这不是一个权威的答案,但每次我进行这样的修补时,我都复制了所有类(外部内部类),即

This is not an authoritative answer, but every time I did such patching, I copied all the classes (outer and inner classes), i.e.

Outer.class
Outer$1.class     // These indexes might change ...
Outer$2.class     // ... between compilation runs
Outer$Inner.class // This name should never change

当我没有这样做时,通常有一些后期的类加载副作用。在我看来,这通常是因为匿名内部类,它们并不总是重新生成相同的匿名类索引(如 $ 1 $ 2 等),具体取决于他们在 .java 文件中的顺序。

When I didn't do this, there were usually some late classloading side-effects. In my opinion, this most often happened because of anonymous inner classes, which do not always re-generate the same "anonymous class index" (as in $1, $2, etc), depending on their order in the .java file.

所以,可以肯定的是,因为这种补丁无论如何都是一种流氓技术,我总是复制所有类。

So, to be sure, as this sort of patching is quite a hooligan technique anyway, I always copied all of the classes.

这篇关于将java外部类编译为内部类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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