Class AnonymousClassInfos


  • public class AnonymousClassInfos
    extends Object
    Info about anonymous classes.

    This class will on construction search for all anonymous classes of the main class and calculate superclass, interfaces, all methods signature and all fields signature. Depending on used constructor this is done via reflection from ClassLoader (current loaded state) or from ClassPool via javaassist. Note that ClassPool uses LoadClassPath on the ClassLoader and hence are resources resolved via the ClassLoader. Javaasist resolves the resource and returns bytcode as is in the resource file.

    Use mapPreviousState() to create compatible transition mapping between old state and new state. This mapping is then used by plugin to swap class bytecoded to retain hotswap changes compatible

    Author:
    Jiri Bubnik
    • Field Detail

      • UNIQUE_CLASS_START_INDEX

        public static final int UNIQUE_CLASS_START_INDEX
        See Also:
        Constant Field Values
    • Constructor Detail

      • AnonymousClassInfos

        public AnonymousClassInfos​(ClassLoader classLoader,
                                   String className)
        Create info of the current state from the classloader via reflection.
        Parameters:
        classLoader - classloader to use
        className - main class
      • AnonymousClassInfos

        public AnonymousClassInfos​(ClassPool classPool,
                                   String className)
        Create info of the new state from the classPool via javassist.
        Parameters:
        classPool - classPool to resolve class files
        className - main class
    • Method Detail

      • getAnonymousClassInfo

        public AnonymousClassInfo getAnonymousClassInfo​(String className)
        Returns stored info of an anonymous class
        Parameters:
        className - class name of the anonymous class (Should be in the form of MyClass$3)
        Returns:
        class info x null
      • mapPreviousState

        public void mapPreviousState​(AnonymousClassInfos previousAnonymousClassInfos)
        Set previous class info state and calculate compatible transitions. Usually new state is created from classpool, while old state from classloader.
        Parameters:
        previousAnonymousClassInfos - previous state
      • isCurrent

        public boolean isCurrent​(ClassPool classPool)
        Return true, if last modification timestamp is same as current timestamp of className.
        Parameters:
        classPool - classPool to check className file
        Returns:
        true if is current
      • getCompatibleTransitions

        public Map<AnonymousClassInfo,​AnonymousClassInfo> getCompatibleTransitions()
        Returns calculated compatible transitions.
        Returns:
        calculated compatible transitions.
      • getCompatibleTransition

        public String getCompatibleTransition​(String className)
        Find compatible transition class name.
        Parameters:
        className - name of existing class (old)
        Returns:
        name of compatible new class that should replace old class. Can be null if no compatible class found.