SandMark version 3.0


sandmark.watermark.ct.embed
Class InsertStorageCreators

java.lang.Object
  |
  +--sandmark.watermark.ct.embed.InsertStorageCreators

public class InsertStorageCreators
extends java.lang.Object

We need some kind of structure to store handles to watermark graph components. We can use arrays, vectors, hashtables, etc. At some point these structures need to be created. This class is in charge of inserting code for creating these storage structures.


Field Summary
(package private)  Forest callForest
           
(package private)  ClassFileCollection cfc
           
(package private)  java.util.Properties props
           
(package private)  java.lang.String[][] storageCreators
           
(package private)  java.lang.String watermarkClassName
           
 
Constructor Summary
InsertStorageCreators(ClassFileCollection cfc, java.util.Properties props, java.lang.String[][] storageCreators, Forest callForest)
          We need some kind of structure to store handles to watermark graph components.
 
Method Summary
(package private)  de.fub.bytecode.generic.InstructionList createStorageCreatorCall(java.lang.String methodName, java.lang.String returnType, java.lang.String localName, de.fub.bytecode.generic.ConstantPoolGen cp, de.fub.bytecode.generic.MethodGen mg)
          Return a list of instructions that invoke the method 'methodName', whose signature is "()returnType".
(package private)  ByteCodeLocation getCallForestRoot()
          Return the location in the code where we should insert the calls to Watermark.CreateStorage_X().
 void insert()
          Insert calls to Watermark.CreateStorage_X().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

props

java.util.Properties props

cfc

ClassFileCollection cfc

watermarkClassName

java.lang.String watermarkClassName

storageCreators

java.lang.String[][] storageCreators

callForest

Forest callForest
Constructor Detail

InsertStorageCreators

public InsertStorageCreators(ClassFileCollection cfc,
                             java.util.Properties props,
                             java.lang.String[][] storageCreators,
                             Forest callForest)
We need some kind of structure to store handles to watermark graph components. We can use arrays, vectors, hashtables, etc. At some point these structures need to be created. This class is in charge of inserting code for creating these storage structures.

Method Detail

getCallForestRoot

ByteCodeLocation getCallForestRoot()
Return the location in the code where we should insert the calls to Watermark.CreateStorage_X(). Rather than inserting the calls at the exact bytecode location we go to location 0, the beginning of the method. This avoids the unpleasant situation
     main() {
        P(10);
     }
 
where we might insert the calls between 'push 10' and 'call P'.


insert

public void insert()
            throws java.lang.Exception
Insert calls to Watermark.CreateStorage_X(). The method
    void main() {
       P();
    }
 
should turn into
    void main() {
       java.util.Hashtable sm$hash = Watermark.CreateStorage_sm$hash();
       java.util.Vector sm$vector = Watermark.CreateStorage_sm$vector();
       P();
    }
 
If we're passing storage containers in formal parameters, this will eventually turn into
    void main() {
       java.util.Hashtable sm$hash = Watermark.CreateStorage_sm$hash();
       java.util.Vector sm$vector = Watermark.CreateStorage_sm$vector();
       P(sm$hash,sm$vector);
    }
 storageCreators[][] is an array of quadruples:
   {methodName, returnType, localName, GLOBAL/FORMAL}
 for example
   {"CreateStorage_sm$hash", "java.util.Hashtable", "sm$hash", "FORMAL"}
 
Rather than inserting the calls at the exact bytecode location we go to location 0, the beginning of the method. This avoids the unpleasant situation
     main() {
        P(10);
     }
 
where we might insert the calls between 'push 10' and 'call P'. This is the main entry point to this class.

java.lang.Exception

createStorageCreatorCall

de.fub.bytecode.generic.InstructionList createStorageCreatorCall(java.lang.String methodName,
                                                                 java.lang.String returnType,
                                                                 java.lang.String localName,
                                                                 de.fub.bytecode.generic.ConstantPoolGen cp,
                                                                 de.fub.bytecode.generic.MethodGen mg)
Return a list of instructions that invoke the method 'methodName', whose signature is "()returnType". Store the resulting storage container in local variable 'localName'.

Parameters:
methodName - name of method to be called
returnType - return type of method to be called
localName - name of local to store into
cp - constant pool
mg - method to be edited

SandMark version 3.0

Wed Jan 29 10:30:05 MST 2003