SandMark version 3.0


sandmark.util
Class ClassHierarchy

java.lang.Object
  |
  +--sandmark.util.ClassHierarchy
Direct Known Subclasses:
Test.ClassHierarchy

public class ClassHierarchy
extends java.lang.Object


Field Summary
(package private)  ClassFileCollection cfc
           
(package private)  java.util.Hashtable class2Node
           
(package private)  java.util.Properties props
           
(package private)  Graph tree
           
 
Constructor Summary
ClassHierarchy()
          Null constructor, used for testing purposes.
ClassHierarchy(ClassFileCollection cfc)
           
ClassHierarchy(ClassFileCollection cfc, java.util.Properties props)
          Build a class hierarchy tree from the classes in cfc.
 
Method Summary
(package private)  ClassHierarchyNode addNode(java.lang.String className)
           
 MethodID[] allOverloads(MethodID method)
           
 MethodID[] allOverrides(MethodID method)
          Return all methods overridden by 'method' or which it overrides.
(package private)  void build()
           
(package private)  ClassHierarchyNode build(java.lang.String className)
           
(package private)  ClassHierarchyNode buildJava(java.lang.String className)
           
(package private)  ClassHierarchyNode buildUser(java.lang.String className)
           
(package private)  void buildUserTree()
           
 boolean classExtends(java.lang.String subClass, java.lang.String superClass)
           
(package private)  ClassHierarchyNode construct(ClassHierarchyNode node, java.lang.String className, java.lang.String superClass, boolean isInterface, java.lang.String[] interfaceClasses, MethodID[] methodIDs)
           
(package private)  java.lang.String fixJavaType(java.lang.String T)
           
 MethodID[] getMethods(java.lang.String className)
           
 MethodID[] getMethodsToRename(MethodID origMethod)
           
 java.lang.String[] inheritanceChain(java.lang.String Class)
           
 boolean isInterface(java.lang.String className)
           
 boolean isSpecialClass(java.lang.String className)
          Return true if this is a class we cannot edit, for example one of the standard Java classes.
 boolean isSpecialMethod(MethodID origMethod)
          Checks if the method is a special java method, such as the main method, or an initializer.
(package private)  MethodID[] loadUserMethods(ClassHierarchyNode node)
           
 ClassHierarchyNode lookup(java.lang.String className)
           
static void main(java.lang.String[] args)
           
 boolean methodRenameOK(MethodID origMethod, MethodID newMethod)
          Return false if 'origMethod' is special in some way, i.e. we cannot change its name or signature into 'newMethod'.
 boolean methodRenameOK(MethodID origMethod, java.lang.String newName)
          A convenience version of methodRenameOK(MethodID, MethodID) that is used to test to see if a new method name is ok, given that nothing else about the method changes.
 boolean overloads(MethodID subMethod, MethodID superMethod)
           
 MethodID[] overrides(MethodID subMethod)
           
 boolean overrides(MethodID subMethod, MethodID superMethod)
           
 boolean overridesJavaMethod(MethodID suspect)
          Checks if the method overrides some method (directly or indirectly) in the java.* hierarchy.
 java.lang.String[] subClasses(java.lang.String superClass)
           
(package private)  void subClasses(java.lang.String superClass, java.util.Vector res)
           
 java.lang.String[] superClasses(java.lang.String subClass)
          Return all the classes that extend superClass, directly or indirectly.
(package private)  void superClasses(java.lang.String subClass, java.util.Vector res)
          Return all the classes that subClass extends, directly or indirectly.
static void test1()
           
static void test2(ClassHierarchy ch)
           
(package private) static void testAllOverrides(ClassHierarchy ch, java.lang.String subName, java.lang.String subSig, java.lang.String subClass)
           
(package private) static void testExtends(ClassHierarchy ch, java.lang.String subClass, java.lang.String superClass)
           
(package private) static void testGetMethodsToRename(ClassHierarchy ch, java.lang.String origName, java.lang.String origSig, java.lang.String origClass)
           
(package private) static void testInheritanceChain(ClassHierarchy ch, java.lang.String Class)
           
(package private) static void testMethodRenameOK(ClassHierarchy ch, java.lang.String origName, java.lang.String origSig, java.lang.String origClass, java.lang.String newName, java.lang.String newSig, java.lang.String newClass)
           
(package private) static void testOverrides(ClassHierarchy ch, java.lang.String subName, java.lang.String subSig, java.lang.String subClass)
           
(package private) static void testOverrides(ClassHierarchy ch, java.lang.String subName, java.lang.String subSig, java.lang.String subClass, java.lang.String superName, java.lang.String superSig, java.lang.String superClass)
           
(package private) static void testSubClasses(ClassHierarchy ch, java.lang.String superClass)
           
(package private) static void testSuperClasses(ClassHierarchy ch, java.lang.String subClass)
           
 java.lang.String toDot()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

props

java.util.Properties props

cfc

ClassFileCollection cfc

tree

Graph tree

class2Node

java.util.Hashtable class2Node
Constructor Detail

ClassHierarchy

public ClassHierarchy()
Null constructor, used for testing purposes.


ClassHierarchy

public ClassHierarchy(ClassFileCollection cfc,
                      java.util.Properties props)
               throws java.io.IOException
Build a class hierarchy tree from the classes in cfc. Any standard java classes (java.*, etc) are also included if they can be loaded. Each node in the tree represents a class. The node data is a ClassHierarchyNode object. Outgoing edges represent parent classes, i.e. the superclass and any interface classes. The hashtable class2node maps the class 'x.y.z' to the corresponding node in the tree.


ClassHierarchy

public ClassHierarchy(ClassFileCollection cfc)
               throws java.io.IOException
Method Detail

toDot

public java.lang.String toDot()

build

void build()
     throws java.io.IOException
java.io.IOException

build

ClassHierarchyNode build(java.lang.String className)

addNode

ClassHierarchyNode addNode(java.lang.String className)

buildUser

ClassHierarchyNode buildUser(java.lang.String className)
                       throws java.lang.Exception
java.lang.Exception

fixJavaType

java.lang.String fixJavaType(java.lang.String T)

buildJava

ClassHierarchyNode buildJava(java.lang.String className)
                       throws java.lang.Exception
java.lang.Exception

construct

ClassHierarchyNode construct(ClassHierarchyNode node,
                             java.lang.String className,
                             java.lang.String superClass,
                             boolean isInterface,
                             java.lang.String[] interfaceClasses,
                             MethodID[] methodIDs)
                       throws java.lang.Exception
java.lang.Exception

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

lookup

public ClassHierarchyNode lookup(java.lang.String className)
                          throws ClassHierarchyException
ClassHierarchyException

isSpecialClass

public boolean isSpecialClass(java.lang.String className)
                       throws ClassHierarchyException
Return true if this is a class we cannot edit, for example one of the standard Java classes.

ClassHierarchyException

isInterface

public boolean isInterface(java.lang.String className)
                    throws ClassHierarchyException
ClassHierarchyException

getMethods

public MethodID[] getMethods(java.lang.String className)
                      throws ClassHierarchyException
ClassHierarchyException

buildUserTree

void buildUserTree()
             throws java.io.IOException
java.io.IOException

loadUserMethods

MethodID[] loadUserMethods(ClassHierarchyNode node)
                     throws java.lang.Exception
java.lang.Exception

classExtends

public boolean classExtends(java.lang.String subClass,
                            java.lang.String superClass)
                     throws ClassHierarchyException
ClassHierarchyException

superClasses

void superClasses(java.lang.String subClass,
                  java.util.Vector res)
            throws ClassHierarchyException
Return all the classes that subClass extends, directly or indirectly. subClass is part of this list.

ClassHierarchyException

superClasses

public java.lang.String[] superClasses(java.lang.String subClass)
                                throws ClassHierarchyException
Return all the classes that extend superClass, directly or indirectly. superClass is part of this list.

ClassHierarchyException

subClasses

void subClasses(java.lang.String superClass,
                java.util.Vector res)
          throws ClassHierarchyException
ClassHierarchyException

subClasses

public java.lang.String[] subClasses(java.lang.String superClass)
                              throws ClassHierarchyException
ClassHierarchyException

inheritanceChain

public java.lang.String[] inheritanceChain(java.lang.String Class)
                                    throws ClassHierarchyException
ClassHierarchyException

overrides

public boolean overrides(MethodID subMethod,
                         MethodID superMethod)
                  throws ClassHierarchyException
ClassHierarchyException

overloads

public boolean overloads(MethodID subMethod,
                         MethodID superMethod)
                  throws ClassHierarchyException
ClassHierarchyException

overrides

public MethodID[] overrides(MethodID subMethod)
                     throws ClassHierarchyException
ClassHierarchyException

allOverrides

public MethodID[] allOverrides(MethodID method)
                        throws ClassHierarchyException
Return all methods overridden by 'method' or which it overrides. All methods must have the same signature and name and 'method' must be in a class that extends the other methods, directly or indirectly, or vice versa. In other words, this method returns all the methods in the class hierarchy related to 'method' through overriding.

ClassHierarchyException

allOverloads

public MethodID[] allOverloads(MethodID method)
                        throws ClassHierarchyException
ClassHierarchyException

methodRenameOK

public boolean methodRenameOK(MethodID origMethod,
                              java.lang.String newName)
                       throws ClassHierarchyException
A convenience version of methodRenameOK(MethodID, MethodID) that is used to test to see if a new method name is ok, given that nothing else about the method changes.

Parameters:
origMethod - the method to rename
newName - the proposed new name
Returns:
true if new name does not cause any new conflicts.
ClassHierarchyException

methodRenameOK

public boolean methodRenameOK(MethodID origMethod,
                              MethodID newMethod)
                       throws ClassHierarchyException
Return false if 'origMethod' is special in some way, i.e. we cannot change its name or signature into 'newMethod'. A method name/signature change is illegal * if the original method overrides some method (directly or indirectly) in the java.* hierarchy; * if the new signature overrides a method declared in a superclass. * if the original method is a static or dynamic initializer. There may be other conditions as well, in particular related to whether a method is static or dynamic.

ClassHierarchyException

overridesJavaMethod

public boolean overridesJavaMethod(MethodID suspect)
                            throws ClassHierarchyException
Checks if the method overrides some method (directly or indirectly) in the java.* hierarchy.

Parameters:
suspect - the method in question
Returns:
true if the method overrides a method in the java libraries
ClassHierarchyException

isSpecialMethod

public boolean isSpecialMethod(MethodID origMethod)
                        throws ClassHierarchyException
Checks if the method is a special java method, such as the main method, or an initializer.

Parameters:
origMethod - the method in question
Returns:
true if the method is special and should not be changed
ClassHierarchyException

getMethodsToRename

public MethodID[] getMethodsToRename(MethodID origMethod)
                              throws ClassHierarchyException
ClassHierarchyException

testExtends

static void testExtends(ClassHierarchy ch,
                        java.lang.String subClass,
                        java.lang.String superClass)
                 throws ClassHierarchyException
ClassHierarchyException

testSuperClasses

static void testSuperClasses(ClassHierarchy ch,
                             java.lang.String subClass)
                      throws ClassHierarchyException
ClassHierarchyException

testSubClasses

static void testSubClasses(ClassHierarchy ch,
                           java.lang.String superClass)
                    throws ClassHierarchyException
ClassHierarchyException

testInheritanceChain

static void testInheritanceChain(ClassHierarchy ch,
                                 java.lang.String Class)
                          throws ClassHierarchyException
ClassHierarchyException

testOverrides

static void testOverrides(ClassHierarchy ch,
                          java.lang.String subName,
                          java.lang.String subSig,
                          java.lang.String subClass,
                          java.lang.String superName,
                          java.lang.String superSig,
                          java.lang.String superClass)
                   throws ClassHierarchyException
ClassHierarchyException

testOverrides

static void testOverrides(ClassHierarchy ch,
                          java.lang.String subName,
                          java.lang.String subSig,
                          java.lang.String subClass)
                   throws ClassHierarchyException
ClassHierarchyException

testAllOverrides

static void testAllOverrides(ClassHierarchy ch,
                             java.lang.String subName,
                             java.lang.String subSig,
                             java.lang.String subClass)
                      throws ClassHierarchyException
ClassHierarchyException

testMethodRenameOK

static void testMethodRenameOK(ClassHierarchy ch,
                               java.lang.String origName,
                               java.lang.String origSig,
                               java.lang.String origClass,
                               java.lang.String newName,
                               java.lang.String newSig,
                               java.lang.String newClass)
                        throws ClassHierarchyException
ClassHierarchyException

testGetMethodsToRename

static void testGetMethodsToRename(ClassHierarchy ch,
                                   java.lang.String origName,
                                   java.lang.String origSig,
                                   java.lang.String origClass)
                            throws ClassHierarchyException
ClassHierarchyException

test1

public static void test1()
                  throws java.io.IOException,
                         ClassHierarchyException
java.io.IOException
ClassHierarchyException

test2

public static void test2(ClassHierarchy ch)
                  throws java.io.IOException,
                         ClassHierarchyException
java.io.IOException
ClassHierarchyException

main

public static void main(java.lang.String[] args)
                 throws java.io.IOException,
                        ClassHierarchyException
java.io.IOException
ClassHierarchyException

SandMark version 3.0

Wed Jan 29 10:30:05 MST 2003