will java outer class compilation effects inner class

删除回忆录丶 提交于 2019-12-01 06:55:08

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!