Class ClassFileLocator.Simple

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, ClassFileLocator
    Enclosing interface:
    ClassFileLocator

    public static class ClassFileLocator.Simple
    extends java.lang.Object
    implements ClassFileLocator
    A simple class file locator that returns class files from a selection of given types.
    • Constructor Detail

      • Simple

        public Simple​(java.util.Map<java.lang.String,​byte[]> classFiles)
        Creates a new simple class file locator.
        Parameters:
        classFiles - The class files that are known to this class file locator mapped by their type name.
    • Method Detail

      • of

        public static ClassFileLocator of​(java.lang.String typeName,
                                          byte[] binaryRepresentation)
        Creates a class file locator for a single known type.
        Parameters:
        typeName - The name of the type.
        binaryRepresentation - The binary representation of the type.
        Returns:
        An appropriate class file locator.
      • of

        public static ClassFileLocator of​(java.lang.String typeName,
                                          byte[] binaryRepresentation,
                                          ClassFileLocator fallback)
        Creates a class file locator for a single known type with an additional fallback locator.
        Parameters:
        typeName - The name of the type.
        binaryRepresentation - The binary representation of the type.
        fallback - The class file locator to query in case that a lookup triggers any other type.
        Returns:
        An appropriate class file locator.
      • of

        public static ClassFileLocator of​(DynamicType dynamicType)
        Creates a class file locator that represents all types of a dynamic type.
        Parameters:
        dynamicType - The dynamic type to represent.
        Returns:
        A class file locator representing the dynamic type's types.
      • of

        public static ClassFileLocator of​(java.util.Map<TypeDescription,​byte[]> binaryRepresentations)
        Creates a class file locator that represents all types of a dynamic type.
        Parameters:
        binaryRepresentations - The binary representation of all types.
        Returns:
        A class file locator representing the dynamic type's types.
      • locate

        public ClassFileLocator.Resolution locate​(java.lang.String typeName)
        Description copied from interface: ClassFileLocator
        Locates the class file for a given type and returns the binary data of the class file.
        Specified by:
        locate in interface ClassFileLocator
        Parameters:
        typeName - The name of the type to locate a class file representation for.
        Returns:
        Any binary representation of the type which might be illegal.
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable