Class PersistentBloatContext

  • All Implemented Interfaces:
    EditorContext, EDU.purdue.cs.bloat.inline.InlineContext
    Direct Known Subclasses:
    CachingBloatContext

    public class PersistentBloatContext
    extends BloatContext
    Maintains all BLOAT data structures as if they were meant to reside in a persistent store. As a result, it keeps every piece of BLOAT data around because it might be needed in the future. No fancing cache maintainence is performed. Because we are going for maximum information we take the closure of classes when working with the class hierarchy.
    • Field Detail

      • classInfos

        protected java.util.Map classInfos
      • methodInfos

        protected java.util.Map methodInfos
      • fieldInfos

        protected java.util.Map fieldInfos
      • classEditors

        protected java.util.Map classEditors
      • methodEditors

        protected java.util.Map methodEditors
      • fieldEditors

        protected java.util.Map fieldEditors
      • DB_COMMIT

        public static boolean DB_COMMIT
    • Constructor Detail

      • PersistentBloatContext

        public PersistentBloatContext​(ClassInfoLoader loader)
        Constructor. Each BloatContext stems from a ClassInfoLoader. Using the loader it can create an Editor and such. Initially, no classes are loaded.
      • PersistentBloatContext

        protected PersistentBloatContext​(ClassInfoLoader loader,
                                         boolean closure)
        Constructor. It is the responsibility of the subclasses to add classes to the hierarchy by calling addClasses.
        Parameters:
        loader - Used to load classes
        closure - Do we look for the maximum number of classes?
    • Method Detail

      • comm

        protected static void comm​(java.lang.String s)
      • addClasses

        protected void addClasses​(java.util.Collection classes)
        Adds a bunch of (names of) classes to the hierarchy.
      • loadClass

        public ClassInfo loadClass​(java.lang.String className)
                            throws java.lang.ClassNotFoundException
        Description copied from interface: EditorContext
        Loads a class into BLOAT
        Throws:
        java.lang.ClassNotFoundException
      • newClassInfo

        public ClassInfo newClassInfo​(int modifiers,
                                      int classIndex,
                                      int superClassIndex,
                                      int[] interfaceIndexes,
                                      java.util.List constants)
        Description copied from interface: EditorContext
        Creates a new ClassInfo
        Parameters:
        modifiers - The modifiers describing the newly-created class
        classIndex - The index of the name of the newly-created class in its constant pool
        superClassIndex - The index of the name of the newly-created class's superclass in its constant pool
        interfaceIndexes - The indexes of the names of the interfaces that the newly-created class implements
        constants - The constant pool for the newly created class (a list of Constants).
      • getHierarchy

        public ClassHierarchy getHierarchy()
        Description copied from interface: EditorContext
        Returns the ClassHierarchy of all classes and interfaces known to BLOAT.
      • newClass

        public ClassEditor newClass​(int modifiers,
                                    java.lang.String className,
                                    Type superType,
                                    Type[] interfaces)
        Description copied from interface: EditorContext
        Returns a ClassEditor for editing a new class with the given name. It will override any class with the given name that is already being edited.
      • editClass

        public ClassEditor editClass​(ClassInfo info)
        Description copied from interface: EditorContext
        Returns a ClassEditor used to edit a class described by a given ClassInfo.
      • editMethod

        public MethodEditor editMethod​(MemberRef method)
                                throws java.lang.NoSuchMethodException
        Description copied from interface: EditorContext
        Returns a MethodEditor for editing a method.
        Throws:
        java.lang.NoSuchMethodException
      • editField

        public FieldEditor editField​(MemberRef field)
                              throws java.lang.NoSuchFieldException
        Description copied from interface: EditorContext
        Returns a FieldEditor for editing a field.
        Throws:
        java.lang.NoSuchFieldException
      • release

        public void release​(ClassInfo info)
        Description copied from interface: EditorContext
        Signals that we are done editing a class. The object used to model it may be reclaimed.
      • release

        public void release​(MethodInfo info)
        Description copied from interface: EditorContext
        Signals that we are done editing a method. The object used to model it may be reclaimed.
      • release

        public void release​(FieldInfo info)
        Description copied from interface: EditorContext
        Signals that we are done editing a field. The object used to model it may be reclaimed.
      • commit

        public void commit​(MethodInfo info)
        Description copied from interface: EditorContext
        Commits the changes made to a method.
      • commit

        public void commit​(FieldInfo info)
        Description copied from interface: EditorContext
        Commits the changes made to a field.
      • commit

        public void commit()
        Description copied from interface: EditorContext
        Commits all changes made to classes, methods, and fields.
      • commitDirty

        public void commitDirty()
        Description copied from class: BloatContext
        Commits all classes, methods, and fields, that have been modified.
        Specified by:
        commitDirty in class BloatContext