Class ByteClassLoader


  • public class ByteClassLoader
    extends ClassLoader
    A subclass of ClassLoader that can take a byte[] containing a class file.
    • Constructor Detail

      • ByteClassLoader

        public ByteClassLoader​(File binaryFile)
        Constructor that reads data from a file.
        Parameters:
        binaryFile - A file containing a Java class.
      • ByteClassLoader

        public ByteClassLoader​(byte[] bytes)
        Constructor taking a class as an array of bytes.
        Parameters:
        bytes - Array of bytes containing a class definition.
    • Method Detail

      • defineClass

        public Class defineClass()
        Define the class that this class loader knows about. The name of the class is taken from the data given in the constructor.

        Note that this does *not* override any of the java.lang.ClassLoader#defineClass methods. Calling this method directly is the only way to get the class defined by this classloader.

        Returns:
        A new Class object for this class.