1 package test; 2 3 public class Baz { 4 public Baz () { 5 System.out.println ("Baz()"); 6 } 7 8 public void baz () { 9 System.out.println ("Baz.baz() : " + this.getClass().getClassLoader ()); 10 11 System.out.println ("Instantiating a class that is already instrumented :"); 12 test.Foo f = new test.Foo (); 13 System.out.println ("Foo was loaded by " + f.getClass().getClassLoader ()); 14 15 try { 16 Class c = (f.getClass().getClassLoader()).loadClass ("test.Foo"); 17 System.out.println (c); 18 19 Object o = c.newInstance (); 20 System.out.println (o instanceof test.Foo); 21 } 22 catch (Exception e) { 23 e.printStackTrace (); 24 } 25 } 26 } 27 | Popular Tags |