Class Plugin.Engine.Target.InMemory

java.lang.Object
net.bytebuddy.build.Plugin.Engine.Target.InMemory
All Implemented Interfaces:
Closeable, AutoCloseable, Plugin.Engine.Target, Plugin.Engine.Target.Sink
Enclosing interface:
Plugin.Engine.Target

@Enhance public static class Plugin.Engine.Target.InMemory extends Object implements Plugin.Engine.Target, Plugin.Engine.Target.Sink
A sink that stores all elements in a memory map.
  • Field Details

    • storage

      @Identity private final Map<String,byte[]> storage
      The map for storing all elements being received.
  • Constructor Details

    • InMemory

      public InMemory()
      Creates a new in-memory storage.
    • InMemory

      public InMemory(Map<String,byte[]> storage)
      Creates a new in-memory storage.
      Parameters:
      storage - The map for storing all elements being received.
  • Method Details

    • write

      public Plugin.Engine.Target.Sink write(@MaybeNull Manifest manifest) throws IOException
      Initializes this target prior to writing.
      Specified by:
      write in interface Plugin.Engine.Target
      Parameters:
      manifest - The manifest for the target or null if no manifest was found.
      Returns:
      The sink to write to.
      Throws:
      IOException - If an I/O error occurs.
    • store

      public void store(Map<TypeDescription,byte[]> binaryRepresentations)
      Stores the supplied binary representation of types in this sink.
      Specified by:
      store in interface Plugin.Engine.Target.Sink
      Parameters:
      binaryRepresentations - The binary representations to store.
    • store

      public void store(ClassFileVersion classFileVersion, Map<TypeDescription,byte[]> binaryRepresentations) throws IOException
      Stores the supplied binary representation of types in this sink.
      Specified by:
      store in interface Plugin.Engine.Target.Sink
      Parameters:
      classFileVersion - The version of the multi-release jar file, which should at least be 8 as previous versions are not recognized by regular class loaders.
      binaryRepresentations - The binary representations to store.
      Throws:
      IOException - If an I/O error occurs.
    • retain

      public void retain(Plugin.Engine.Source.Element element) throws IOException
      Retains the supplied element in its original form.
      Specified by:
      retain in interface Plugin.Engine.Target.Sink
      Parameters:
      element - The element to retain.
      Throws:
      IOException - If an I/O error occurs.
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • getStorage

      public Map<String,byte[]> getStorage()
      Returns the in-memory storage.
      Returns:
      The in-memory storage.
    • toTypeMap

      public Map<String,byte[]> toTypeMap()
      Returns the in-memory storage as a type-map where all non-class files are discarded.
      Returns:
      The in-memory storage as a type map.
    • toTypeMap

      public Map<String,byte[]> toTypeMap(ClassFileVersion classFileVersion)
      Returns the in-memory storage as a type-map where all non-class files are discarded.
      Parameters:
      classFileVersion - The class file version to consider when encountering multi-release class files.
      Returns:
      The in-memory storage as a type map.