2010-12-06 03:21:09 +00:00
|
|
|
/* Copyright (c) 2008-2010, Avian Contributors
|
2008-02-19 18:06:52 +00:00
|
|
|
|
|
|
|
Permission to use, copy, modify, and/or distribute this software
|
|
|
|
for any purpose with or without fee is hereby granted, provided
|
|
|
|
that the above copyright notice and this permission notice appear
|
|
|
|
in all copies.
|
|
|
|
|
|
|
|
There is NO WARRANTY for this software. See license.txt for
|
|
|
|
details. */
|
|
|
|
|
2009-05-26 03:36:29 +00:00
|
|
|
package avian;
|
2007-07-30 23:19:05 +00:00
|
|
|
|
2007-08-10 23:45:47 +00:00
|
|
|
import java.net.URL;
|
|
|
|
import java.net.MalformedURLException;
|
2010-12-06 00:40:50 +00:00
|
|
|
import java.util.Collection;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Enumeration;
|
2007-08-10 23:45:47 +00:00
|
|
|
|
2007-07-30 23:19:05 +00:00
|
|
|
public class SystemClassLoader extends ClassLoader {
|
2010-09-14 16:49:41 +00:00
|
|
|
private native VMClass findVMClass(String name)
|
2010-09-01 16:13:52 +00:00
|
|
|
throws ClassNotFoundException;
|
|
|
|
|
|
|
|
protected Class findClass(String name) throws ClassNotFoundException {
|
|
|
|
return getClass(findVMClass(name));
|
|
|
|
}
|
2007-07-30 23:19:05 +00:00
|
|
|
|
2010-09-10 21:05:29 +00:00
|
|
|
public static native Class getClass(VMClass vmClass);
|
|
|
|
|
2010-09-14 16:49:41 +00:00
|
|
|
private native VMClass findLoadedVMClass(String name);
|
2010-09-01 16:13:52 +00:00
|
|
|
|
|
|
|
protected Class reallyFindLoadedClass(String name){
|
|
|
|
VMClass c = findLoadedVMClass(name);
|
|
|
|
return c == null ? null : getClass(c);
|
|
|
|
}
|
2007-08-10 23:45:47 +00:00
|
|
|
|
2011-03-26 01:14:21 +00:00
|
|
|
private native String resourceURLPrefix(String name);
|
2007-08-10 23:45:47 +00:00
|
|
|
|
|
|
|
protected URL findResource(String name) {
|
2011-03-26 01:14:21 +00:00
|
|
|
String prefix = resourceURLPrefix(name);
|
|
|
|
if (prefix != null) {
|
2007-08-10 23:45:47 +00:00
|
|
|
try {
|
2011-03-26 01:14:21 +00:00
|
|
|
return new URL(prefix + name);
|
2007-08-10 23:45:47 +00:00
|
|
|
} catch (MalformedURLException ignored) { }
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
2010-12-06 00:40:50 +00:00
|
|
|
|
|
|
|
protected Enumeration<URL> findResources(String name) {
|
|
|
|
Collection<URL> urls = new ArrayList(1);
|
|
|
|
URL url = findResource(name);
|
|
|
|
if (url != null) {
|
|
|
|
urls.add(url);
|
|
|
|
}
|
|
|
|
return Collections.enumeration(urls);
|
|
|
|
}
|
2007-07-30 23:19:05 +00:00
|
|
|
}
|