fork(3) download
  1. class BBB
  2. {
  3. private static class MyCL extends ClassLoader
  4. {
  5. @Override
  6. protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException
  7. {
  8. System.out.println("Hi, " + name);
  9. return String.class;
  10. }
  11. }
  12.  
  13. public static void main(String[] args) throws ClassNotFoundException
  14. {
  15. MyCL cl = new MyCL();
  16.  
  17. System.out.println(Class.forName("a", true, cl));
  18.  
  19. }
  20. }
  21.  
Runtime error #stdin #stdout #stderr 0.09s 320320KB
stdin
Standard input is empty
stdout
Hi, a
stderr
Exception in thread "main" java.lang.ClassNotFoundException: a
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:344)
	at BBB.main(Main.java:17)