Jochen Theodorou wrote: > Sent: Thursday, April 16, 2009 20:58 > To: jvm-languages@googlegroups.com > Subject: [jvm-l] Re: bootstrap class loader > > > Jeroen Frijters schrieb: > > 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) > > yes, but is that specified?
No, it isn't. There isn't any specified way to do what you want, because the whole notion of a bootstrap class loader is under specified. I'm pretty sure it's legal for a VM to have no bootstrap class loader (i.e. only a system class loader). But in that case you can't make the distinction anyway, so for most scenarios the above should do what you want (unless you absolutely need to prevent loading "user" classes, in which case you should fail to run on a VM that doesn't make a distinction between "user" and "system" classes). Regards, Jeroen --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---