Skip to content

Instantly share code, notes, and snippets.

@dushmis
Last active December 21, 2015 09:29
Show Gist options
  • Save dushmis/6285690 to your computer and use it in GitHub Desktop.
Save dushmis/6285690 to your computer and use it in GitHub Desktop.
Custome Class Loader
public class CustomeClassLoader_T{
static class CustomClassLoader extends ClassLoader {
String host;
int port;
public Class findClass(String name) {
byte[] b = loadClassData(name);
return b!=null?defineClass(name, b, 0, b.length):null;//or throw, return null for this example
}
private byte[] loadClassData(String name) {
// load the class data from the connection
return null;
}
}
public static void main(String... arg){
Class r = new CustomeClassLoader_T.CustomClassLoader().findClass("com.x.MyClass");
System.out.println(r);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment