class BBB{ private static class MyCL extends ClassLoader { @Override protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException { System.out.println("Hi, " + name); return String.class; } } public static void main(String[] args) throws ClassNotFoundException { MyCL cl = new MyCL(); System.out.println(Class.forName("a", true, cl)); }}
Standard input is empty
Hi, a
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)
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!