简体   繁体   English

加载内部类而不加载封闭类

[英]loading inner class without loading the enclosing class

I was bit confused when is the inner class (non static) gets loaded by the jvm . 当内部类(非静态)被jvm加载时,我有点困惑。 Is it dependent on the outer class. 它是否依赖于外层阶级。 or can it be separately loaded without loading the outer class ? 或者可以在不加载外类的情况下单独加载?

Given that an inner class has a field with reference to an instance of the enclosing class, I don't see how it could be loaded without loading the enclosing class. 由于一个内部类中有一个字段参考封装类的一个实例,我看不出它如何不加载封装类加载。

A static nested class may well be different, as that's genuinely independent of its enclosing class. 静态嵌套类可能不同,因为它真正独立于其封闭类。

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

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