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
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.
Inner class is just like normal class with implicit reference to outer class so I would say it is safe to give only outer class if you really didn't change the inner ones.
来源:https://stackoverflow.com/questions/12915778/will-java-outer-class-compilation-effects-inner-class