Introduction to OOP Chapter 25: Reflection and Introspection : next previous audio real text

Class Loading

Java has a class named ClassLoader that allows you to define a class from an array of bytes:
class SimpleClassLoader extends ClassLoader {
	public Class getClass (String name) {
		Class theClass = null;
		try {
			File f = new File(name);
			InputStream is = new FileInputStream(f);
			int bufsize = (int) f.length();
			byte buf [] = new byte[bufsize];, 0, bufsize);
			theClass = defineClass (null, buf, 0, buf.length);
		} catch (Exception e) {
			System.err.println("Error during load " + e);
		return theClass;
Once you have a class, you can create instances, or execute methods.
Intro OOP, Chapter 25, Slide 09