Classloader not work on RCP [message #520753] |
Mon, 15 March 2010 04:09  |
Eclipse User |
|
|
|
The following code work on standalone java but not work on RCP
ClassLoader loader = new ClassLoader() {
@Override
protected Class<?> findClass(String name) throws ClassNotFoundException {
InputStream in = null;
try {
in = new BufferedInputStream(new FileInputStream(filename));
ByteArrayOutputStream byteStr = new ByteArrayOutputStream();
int byt = -1;
while ((byt = in.read()) != -1) {
byteStr.write(byt);
}
byte byteArr[] = byteStr.toByteArray();
return defineClass(null, byteArr, 0, byteArr.length);
} catch (final RuntimeException rex) {
throw rex;
} catch (final Exception ex) {
ex.printStackTrace();
throw new ClassNotFoundException(name);
} finally {
if (in != null) {
try {
in.close();
} catch (final IOException ioe) {
ioe.printStackTrace();
}
}
}
}
};
loader.loadClass("garbage").newInstance();
Is there anyone find the problems?
Thanks
Terris
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.06241 seconds