aboutsummaryrefslogtreecommitdiffstats
path: root/tests/ltw/callMunging/case1/HierMain.java
blob: 8fdb1c570296105cca2080155959766fe199d542 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import java.lang.reflect.Method;
import java.net.URLClassLoader;
import java.net.URL;
import java.io.File;
import org.aspectj.weaver.loadtime.WeavingURLClassLoader;

public class HierMain {

  public static void main(String []argv) {
	  try {
		  System.out.println("into:main");
		  ClassLoader baseLoader = HierMain.class.getClassLoader(); 
		  URL base = baseLoader.getResource("HierMain.class");
		  String urlstr = base.toExternalForm();
		  int idx = urlstr.indexOf("classes.jar!");
		  String sub = urlstr.substring("jar:".length(), idx)+"/sub.hiddenjar";
		  URL subUrls[] = new URL[] { new URL(sub) };
		  WeavingURLClassLoader loader = new WeavingURLClassLoader(subUrls, baseLoader);
		  Class clazzA = Class.forName("A", false, loader);
		  Method clazzAMethod = clazzA.getMethod("method",null);
		  clazzAMethod.invoke(clazzA.newInstance(),null);
		  System.out.println("leave:main");
	  } catch (Throwable t) {
		  t.printStackTrace();
	  }
  }
  
}