Package rife.tools

Class ClassBytesLoader

java.lang.Object
rife.tools.ClassBytesLoader

public class ClassBytesLoader extends Object
Utility class to load the bytes of class files.
Since:
1.0
  • Constructor Details

    • ClassBytesLoader

      public ClassBytesLoader(ClassLoader classLoader)
      Instantiates a new bytes loader for class files.
      Parameters:
      classLoader - the classloader that should be used to search for the classes
      Since:
      1.0
  • Method Details

    • getClassBytes

      public byte[] getClassBytes(String classFileName) throws ClassNotFoundException
      Retrieves a byte array that contains the bytecode for a specific Java class.
      Parameters:
      classFileName - the file name of the class whose bytes should be loaded, note that this is not the Java FQN (rife.Version), but the real name of the file resource (rife/Version.java)
      Returns:
      an array with the bytes of the class; or

      null if no bytes could be loaded

      Throws:
      ClassNotFoundException
      Since:
      1.0
      See Also:
    • getClassBytes

      public byte[] getClassBytes(String classFileName, URL classResource) throws ClassNotFoundException
      Retrieves a byte array that contains the bytecode for a specific Java class.
      Parameters:
      classFileName - the file name of the class whose bytes should be loaded, note that this is not the Java FQN (rife.Version), but the real name of the file resource (rife/Version.java)
      classResource - the resource that can be used to load the class bytes from if it couldn't be obtained by using the file name, if no resource is provided and the bytes couldn't be loaded by simply using the class' file name, a resource will be looked up for the file name through the class loader that was provided to the constructor
      Returns:
      an array with the bytes of the class; or

      null if no bytes could be loaded

      Throws:
      ClassNotFoundException
      Since:
      1.0
      See Also: