use of com.ibm.dtfj.java.JavaClass in project openj9 by eclipse.
the class JavaClassLoader method getCachedClasses.
/* (non-Javadoc)
* @see com.ibm.dtfj.java.JavaClassLoader#getCachedClasses()
*/
public Iterator getCachedClasses() {
if (null == _cached) {
// a cached class is any class known to the loader
Iterator ids = _classIDs.iterator();
_cached = new ArrayList();
while (ids.hasNext()) {
long oneID = ((Long) ids.next()).longValue();
JavaClass oneClass = _javaVM.getClassForID(oneID);
if (null == oneClass) {
_cached.add(new CorruptData("Cache reference to unknown class " + oneID, null));
} else {
_cached.add(oneClass);
}
}
}
return _cached.iterator();
}
use of com.ibm.dtfj.java.JavaClass in project openj9 by eclipse.
the class JavaClassLoader method findClass.
/* (non-Javadoc)
* @see com.ibm.dtfj.java.JavaClassLoader#findClass(java.lang.String)
*/
public JavaClass findClass(String name) throws CorruptDataException {
Iterator classes = getDefinedClasses();
JavaClass found = null;
while (classes.hasNext() && (null == found)) {
JavaClass one = (JavaClass) classes.next();
if (one.getName().equals(name)) {
found = one;
}
}
return found;
}
use of com.ibm.dtfj.java.JavaClass in project openj9 by eclipse.
the class JCJavaClassLoader method findClass.
/**
*/
public JavaClass findClass(String className) {
JavaClass foundClass = null;
if (fClassNames.containsKey(className)) {
ImagePointer ip = (ImagePointer) fClassNames.get(className);
if (ip != null) {
// By class ID
long id = ip.getAddress();
foundClass = fRuntime.findJavaClass(id);
} else {
// By class name
foundClass = fRuntime.findJavaClass(className);
}
}
return foundClass;
}
use of com.ibm.dtfj.java.JavaClass in project openj9 by eclipse.
the class PHDJavaClass method getReferences.
public Iterator<JavaReference> getReferences() {
final JavaClass source = this;
return new Iterator<JavaReference>() {
int count;
JavaClass sup;
JavaObject load;
{
try {
sup = getSuperclass();
if (sup != null)
count = -1;
} catch (CorruptDataException e) {
}
try {
load = loader.getObject();
if (load != null)
count = -2;
} catch (CorruptDataException e) {
}
}
public boolean hasNext() {
if (count < 0) {
return true;
} else if (refs instanceof LongEnumeration) {
LongEnumeration le = (LongEnumeration) refs;
return le.hasMoreElements();
} else if (refs instanceof long[]) {
long[] arefs = (long[]) refs;
return count < arefs.length;
} else if (refs instanceof int[]) {
int[] arefs = (int[]) refs;
return count < arefs.length;
} else {
return false;
}
}
public JavaReference next() {
if (!hasNext())
throw new NoSuchElementException("" + count++);
long ref;
int refType = PHDJavaReference.REFERENCE_UNKNOWN;
Object cls = null;
if (count == -2) {
cls = load;
++count;
// Skip over the superclass if not present
if (sup == null)
++count;
ref = 0;
refType = PHDJavaReference.REFERENCE_CLASS_LOADER;
} else if (count == -1) {
cls = sup;
++count;
ref = 0;
refType = PHDJavaReference.REFERENCE_SUPERCLASS;
} else {
if (refs instanceof LongEnumeration) {
LongEnumeration le = (LongEnumeration) refs;
ref = le.nextLong();
++count;
} else if (refs instanceof int[]) {
int[] arefs = (int[]) refs;
ref = runtime.expandAddress(arefs[count++]);
} else {
long[] arefs = (long[]) refs;
ref = arefs[count++];
}
cls = runtime.findClass(ref);
}
if (cls != null) {
return new PHDJavaReference(cls, source, PHDJavaReference.REACHABILITY_STRONG, refType, PHDJavaReference.HEAP_ROOT_UNKNOWN, "?");
} else {
return new PHDJavaReference(new PHDJavaObject.Builder((PHDJavaHeap) (runtime.getHeaps().next()), ref, null, PHDJavaObject.NO_HASHCODE, -1).build(), source, PHDJavaReference.REACHABILITY_STRONG, refType, PHDJavaReference.HEAP_ROOT_UNKNOWN, "?");
}
}
public void remove() {
throw new UnsupportedOperationException();
}
};
}
use of com.ibm.dtfj.java.JavaClass in project openj9 by eclipse.
the class PHDJavaClass method getObject.
public JavaObject getObject() throws CorruptDataException {
if (addr == 0)
return null;
if (classObject != null)
return classObject;
JavaClass jlc = runtime.findClass("java/lang/Class");
// Early in initialization the runtime might not know about classes
if (jlc == null)
jlc = loader.findClass("java/lang/Class");
// If the object isn't in the heap at this address then we can't get refs for the object
// Here we presume there won't be any extra references, then in PHDJavaRuntime we look for a real object on the heap.
classObject = new PHDJavaObject.Builder((PHDJavaHeap) (runtime.getHeaps().next()), addr, jlc, flags, hashCode).refsAsArray(new long[0], 0).length(PHDJavaObject.SIMPLE_OBJECT).build();
return classObject;
}
Aggregations