Search in sources :

Example 1 with ImmutableEntryHashSetRVM

use of org.jikesrvm.util.ImmutableEntryHashSetRVM in project JikesRVM by JikesRVM.

the class InterfaceHierarchy method allSubClasses.

/**
 * @param C an interface
 * @return the set of all classes known to extend C
 */
private static ImmutableEntryHashSetRVM<RVMClass> allSubClasses(RVMClass C) {
    ImmutableEntryHashSetRVM<RVMClass> result = new ImmutableEntryHashSetRVM<RVMClass>(5);
    // also add any classes that implement a sub-interface of I.
    for (RVMClass subClass : C.getSubClasses()) {
        result.add(subClass);
        result.addAll(allSubClasses(subClass));
    }
    return result;
}
Also used : ImmutableEntryHashSetRVM(org.jikesrvm.util.ImmutableEntryHashSetRVM) RVMClass(org.jikesrvm.classloader.RVMClass)

Example 2 with ImmutableEntryHashSetRVM

use of org.jikesrvm.util.ImmutableEntryHashSetRVM in project JikesRVM by JikesRVM.

the class InterfaceHierarchy method allImplementors.

/**
 * @return the set of all classes known to implement the interface
 * @param I the implemented interface
 */
private static ImmutableEntryHashSetRVM<RVMClass> allImplementors(RVMClass I) {
    // get the set of classes registered as implementing I
    ImmutableEntryHashSetRVM<RVMClass> result = findOrCreateSet(I);
    // need to do this kludge to avoid recursive concurrent modification
    for (RVMClass subClass : I.getSubClasses()) {
        result.addAll(allImplementors(subClass));
    }
    // also add any sub-classes of these classes.
    // need to cache additions to avoid modifying the set while iterating
    ImmutableEntryHashSetRVM<RVMClass> toAdd = new ImmutableEntryHashSetRVM<RVMClass>(5);
    for (RVMClass c : result) {
        toAdd.addAll(allSubClasses(c));
    }
    result.addAll(toAdd);
    return result;
}
Also used : ImmutableEntryHashSetRVM(org.jikesrvm.util.ImmutableEntryHashSetRVM) RVMClass(org.jikesrvm.classloader.RVMClass)

Aggregations

RVMClass (org.jikesrvm.classloader.RVMClass)2 ImmutableEntryHashSetRVM (org.jikesrvm.util.ImmutableEntryHashSetRVM)2