Thursday, 16 June 2016

[Java] How to get all loaded classes in ClassLoader (클래스로더에 올라간 모든 Class 가져오기)


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
public static Vector< Class< ?>> getAllLoadedClasses( ClassLoader classLoader) throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
 Field f = ClassLoader.class.getDeclaredField( "classes");
 f.setAccessible( true);

 return ( Vector< Class< ?>>)f.get( classLoader);

}
 
public static void main( String[] args) throws Exception {
 DorbaeDateUtil.getCurrentDate();
 DorbaeByteUtil.dos2Unix( "%n".getBytes());
  
 java.util.List< Class< ?>> clss = DorbaeClassLoaderUtil.findInheritedClasses( Thread.currentThread().getContextClassLoader(), Object.class);
 for ( int ll = 0; ll < clss.size(); ll++) {
  System.out.println( clss.get( ll).getName());
  
 }
}


No comments:

Post a Comment