38 public void update(Observable o, Object data) {
39 initialize(VM.getVM().getTypeDataBase());
40 }
41 });
42 }
43
44 private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
45 Type type = db.lookupType("ClassLoaderDataGraph");
46
47 headField = type.getAddressField("_head");
48 }
49
50 private static AddressField headField;
51
52 public ClassLoaderData getClassLoaderGraphHead() {
53 return ClassLoaderData.instantiateWrapperFor(headField.getValue());
54 }
55
56 /** Lookup an already loaded class in any class loader. */
57 public Klass find(String className) {
58 Symbol sym = VM.getVM().getSymbolTable().probe(className);
59 if (sym == null) return null;
60 for (ClassLoaderData cld = getClassLoaderGraphHead(); cld != null; cld = cld.next()) {
61 Klass k = cld.find(sym);
62 if (k != null) {
63 return k;
64 }
65 }
66 return null;
67 }
68
69 /** Interface for iterating through all classes. */
70 public static interface ClassVisitor {
71 public void visit(Klass k);
72 }
73
74 /** Interface for iterating through all classes and their class
75 loaders in dictionary */
76 public static interface ClassAndLoaderVisitor {
77 public void visit(Klass k, Oop loader);
78 }
79
80 /** Iterate over all klasses - including object, primitive
81 array klasses */
|
38 public void update(Observable o, Object data) {
39 initialize(VM.getVM().getTypeDataBase());
40 }
41 });
42 }
43
44 private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
45 Type type = db.lookupType("ClassLoaderDataGraph");
46
47 headField = type.getAddressField("_head");
48 }
49
50 private static AddressField headField;
51
52 public ClassLoaderData getClassLoaderGraphHead() {
53 return ClassLoaderData.instantiateWrapperFor(headField.getValue());
54 }
55
56 /** Lookup an already loaded class in any class loader. */
57 public Klass find(String className) {
58 for (ClassLoaderData cld = getClassLoaderGraphHead(); cld != null; cld = cld.next()) {
59 Klass k = cld.find(className);
60 if (k != null) {
61 return k;
62 }
63 }
64 return null;
65 }
66
67 /** Interface for iterating through all classes. */
68 public static interface ClassVisitor {
69 public void visit(Klass k);
70 }
71
72 /** Interface for iterating through all classes and their class
73 loaders in dictionary */
74 public static interface ClassAndLoaderVisitor {
75 public void visit(Klass k, Oop loader);
76 }
77
78 /** Iterate over all klasses - including object, primitive
79 array klasses */
|