TestLeak.java 618 B

12345678910111213141516171819202122232425262728293031323334
  1. import java.net.*;
  2. import java.lang.reflect.Proxy;
  3. public class TestLeak
  4. {
  5. static class MyLoader extends URLClassLoader
  6. {
  7. public MyLoader (URL urls[])
  8. {
  9. super (urls);
  10. }
  11. }
  12. public static void main (String[] args)
  13. {
  14. URLClassLoader ucl =
  15. (URLClassLoader) ClassLoader.getSystemClassLoader();
  16. URL urls[] = ucl.getURLs ();
  17. Class ifaces[] = new Class[1];
  18. ifaces[0] = java.lang.Comparable.class;
  19. try {
  20. for (int i = 0; i < 100; i++)
  21. {
  22. Proxy.getProxyClass (new MyLoader (urls), ifaces);
  23. }
  24. } catch (Exception e) {
  25. e.printStackTrace ();
  26. }
  27. }
  28. }