-
Notifications
You must be signed in to change notification settings - Fork 5
/
ListLoadedClasses.js
50 lines (43 loc) · 1.46 KB
/
ListLoadedClasses.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
var listLoadedClasses = function(doc){
var e = java.lang.Exception;
var Class = java.lang.Class;
var Thread = java.lang.Thread;
var ClassLoader = java.lang.ClassLoader;
var System = java.lang.System;
var Iterator = java.util.Iterator;
try{
var myCL = Thread.currentThread().getContextClassLoader();
var str = "";
while (myCL !== null) {
str += " ClassLoader: " + myCL +" \n";
for (var iter = list(myCL); iter.hasNext();) {
str += " \t" + iter.next() + " \n";
}
myCL = myCL.getParent();
}
logger.info(str);
}catch(e){
}
function list(CL){
var ex = java.lang.Exception;
var Vector = java.util.Vector;
var ClassLoader_classes_field = java.lang.reflect.Field;
try{
var CL_class = CL.getClass();
while (CL_class != java.lang.ClassLoader.class) {
CL_class = CL_class.getSuperclass();
}
ClassLoader_classes_field = CL_class.getDeclaredField("classes");
ClassLoader_classes_field.setAccessible(true);
var classes = ClassLoader_classes_field.get(CL);
return classes.iterator();
}catch(ex){
}
}
return doc;
}