Package rife.tools
Class ClassBytesLoader
java.lang.Object
rife.tools.ClassBytesLoader
Utility class to load the bytes of class files.
- Since:
- 1.0
-
Constructor Summary
ConstructorDescriptionClassBytesLoader
(ClassLoader classLoader) Instantiates a new bytes loader for class files. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]
getClassBytes
(String classFileName) Retrieves a byte array that contains the bytecode for a specific Java class.byte[]
getClassBytes
(String classFileName, URL classResource) Retrieves a byte array that contains the bytecode for a specific Java class.
-
Constructor Details
-
ClassBytesLoader
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
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
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:
-