[英]will java outer class compilation effects inner class
I need to give a patch to websphere. 我需要给Websphere打补丁。 where I have a main java class which has three inner classes.
在这里,我有一个主要的Java类,其中包含三个内部类。 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), ie 这不是权威性的答案,但是每次我进行此类修补时,我都会复制所有类(外部和内部类),即
Outer.class
Outer$1.class // These indexes might change ...
Outer$2.class // ... between compilation runs
Outer$Inner.class // This name should never change
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. 在我看来,这最常见的原因是匿名内部类,根据它们在
.java
文件中的顺序,它们并不总是重新生成相同的“匿名类索引”(如$1
, $2
等)。
So, to be sure, as this sort of patching is quite a hooligan technique anyway, I always copied all of the classes. 因此,可以肯定的是,由于无论如何这种修补都是流氓技术,因此我总是复制所有类。
内部类就像普通类一样,它隐式地引用了外部类,因此, 如果您确实不更改内部类, 那么只给外部类是安全的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.