SandMark version 2.0


sandmark.util
Class ClassHierarchy

java.lang.Object
  |
  +--sandmark.util.ClassHierarchy

public class ClassHierarchy
extends java.lang.Object


Field Summary
(package private)  Time bmTime
           
(package private)  Time bTime
           
(package private)  ClassFileCollection cfc
           
(package private)  java.util.Hashtable class2Node
           
(package private)  Time jmTime
           
(package private)  Time jTime
           
(package private)  java.util.Properties props
           
(package private)  Graph tree
           
 
Constructor Summary
ClassHierarchy(ClassFileCollection cfc, java.util.Properties props)
          Build a class hierarchy tree from the classes in cfc.
 
Method Summary
(package private)  Node 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)  Node build(java.lang.String className)
           
(package private)  Node buildJava(java.lang.String className)
           
(package private)  Node buildUser(java.lang.String className)
           
(package private)  void buildUserTree()
           
 boolean classExtends(java.lang.String subClass, java.lang.String superClass)
           
(package private)  Node construct(ClassHierarchyData data, 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(Node node)
           
 Node lookup(java.lang.String className)
           
static void main(java.lang.String[] args)
           
 boolean methodRenameOK(MethodID origMethod, MethodID newMethod)
          Return true 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)
           
(package private)  void superClasses(java.lang.String subClass, java.util.Vector res)
           
static void test1()
           
static void test2(java.lang.String[] args)
           
(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 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

bTime

Time bTime

bmTime

Time bmTime

jTime

Time jTime

jmTime

Time jmTime
Constructor Detail

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 ClassHierarchyData 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.

Method Detail

build

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

build

Node build(java.lang.String className)

addNode

Node addNode(java.lang.String className)

buildUser

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

fixJavaType

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

buildJava

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

construct

Node construct(ClassHierarchyData data,
               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 Node lookup(java.lang.String className)

isSpecialClass

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


isInterface

public boolean isInterface(java.lang.String className)

getMethods

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

buildUserTree

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

loadUserMethods

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

classExtends

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

superClasses

void superClasses(java.lang.String subClass,
                  java.util.Vector res)

superClasses

public java.lang.String[] superClasses(java.lang.String subClass)

subClasses

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

subClasses

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

inheritanceChain

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

overrides

public boolean overrides(MethodID subMethod,
                         MethodID superMethod)

overloads

public boolean overloads(MethodID subMethod,
                         MethodID superMethod)

overrides

public MethodID[] overrides(MethodID subMethod)

allOverrides

public MethodID[] allOverrides(MethodID method)
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.


allOverloads

public MethodID[] allOverloads(MethodID method)

methodRenameOK

public 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.

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

methodRenameOK

public boolean methodRenameOK(MethodID origMethod,
                              MethodID newMethod)
Return true 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 maybe other conditions as well, in particular related to whether a method is static or dynamic.


overridesJavaMethod

public boolean overridesJavaMethod(MethodID suspect)
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

isSpecialMethod

public boolean isSpecialMethod(MethodID origMethod)
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

getMethodsToRename

public MethodID[] getMethodsToRename(MethodID origMethod)

testExtends

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

testSuperClasses

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

testSubClasses

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

testInheritanceChain

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

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)

testOverrides

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

testAllOverrides

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

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)

testGetMethodsToRename

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

test1

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

test2

public static void test2(java.lang.String[] args)
                  throws java.io.IOException
java.io.IOException

main

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

SandMark version 2.0

Mon Jun 17 12:30:47 MST 2002