学习JVM原理-同一个ClassLoader加载的类,才是同一个类

摘自《深入理解Java虚拟机》周志明著

Object bean = anotherClassLoader.loadClass("Bean").newInstance();  //用自写的Class Loader装载Bean类并生成一个实例
System.out.println(bean instanceof Bean) // 答案将是false! 因为这里的Bean类是用系统默认的Classloader 装载的

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.