Hi Jochen,

Maybe I'm misunderstanding you, but isn't it as simple as this:

public class test
{
  public static void main(String[] args) throws Exception
  {
    ClassLoader cl = new ClassLoader(null) { };
    System.out.println(cl.loadClass("java.lang.Object"));
    System.out.println(cl.loadClass("test"));
  }
}

The cl ClassLoader will only load bootstrap classes. If you run this the result 
is:
class java.lang.Object
Exception in thread "main" java.lang.ClassNotFoundException: test
        at java.lang.ClassLoader.findClass(ClassLoader.java:359)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
        at test.main(test.java:7)

Regards,
Jeroen

> -----Original Message-----
> From: jvm-languages@googlegroups.com [mailto:jvm-
> langua...@googlegroups.com] On Behalf Of Jochen Theodorou
> Sent: Thursday, April 16, 2009 03:04
> To: jvm-languages@googlegroups.com
> Subject: [jvm-l] bootstrap class loader
> 
> 
> Hi all,
> 
> it seems the spec isn't all too clear in that area. For our compiler we
> would need a ClassLoader that does not load class that are given as
> classpath.... I guess I am not very clear....
> 
> java -cp A.jar foo.Bar
> 
> we now need the class loader that is allowed to laod classes from
> rt.jar, but does not laod classes from A.jar. It seems the spec says
> for
> 1.2 that the bootstrap class loader will not do that, but how to get a
> hand on it? Giving null as parent seems to result in the system class
> loader, which is the one that loads the classes from A.jar... so it is
> the wrong one.
> 
> Is there any way to do this?
> 
> bye blackdrag
> 
> --
> Jochen "blackdrag" Theodorou
> The Groovy Project Tech Lead (http://groovy.codehaus.org)
> http://blackdragsview.blogspot.com/
> 
> 
> 

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "JVM 
Languages" group.
To post to this group, send email to jvm-languages@googlegroups.com
To unsubscribe from this group, send email to 
jvm-languages+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/jvm-languages?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to