aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2004-07-26 16:14:26 +0000
committerchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2004-07-26 16:14:26 +0000
commitfedf39720fa22fab916ee254aaac6137c7469e09 (patch)
treeb693c520384fcecfd78781e0da7a665bd6edcaab
parent7c1450fd7d23d45faf7036f9467c820a91d99202 (diff)
downloadjavassist-fedf39720fa22fab916ee254aaac6137c7469e09.tar.gz
javassist-fedf39720fa22fab916ee254aaac6137c7469e09.zip
fixed Bugs item #993090
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@117 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
-rw-r--r--src/main/javassist/Loader.java22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/main/javassist/Loader.java b/src/main/javassist/Loader.java
index d8ee1ccf..91ae21bb 100644
--- a/src/main/javassist/Loader.java
+++ b/src/main/javassist/Loader.java
@@ -303,26 +303,40 @@ public class Loader extends ClassLoader {
* If the source throws an exception, this returns null.
*
* <p>This method can be overridden by a subclass of
- * <code>Loader</code>.
+ * <code>Loader</code>. Note that the overridden method must not throw
+ * an exception when it just fails to find a class file.
+ *
+ * @return null if the specified class could not be found.
+ * @throws ClassNotFoundException if an exception is thrown while
+ * obtaining a class file.
*/
- protected Class findClass(String name) {
+ protected Class findClass(String name) throws ClassNotFoundException {
byte[] classfile;
try {
if (source != null) {
if (translator != null)
translator.onLoad(source, name);
- classfile = source.get(name).toBytecode();
+ try {
+ classfile = source.get(name).toBytecode();
+ }
+ catch (NotFoundException e) {
+ return null;
+ }
}
else {
String jarname = "/" + name.replace('.', '/') + ".class";
InputStream in = this.getClass().getResourceAsStream(jarname);
+ if (in == null)
+ return null;
classfile = ClassPoolTail.readStream(in);
}
}
catch (Exception e) {
- return null;
+ throw new ClassNotFoundException(
+ "caught an exception while obtaining a class file for "
+ + name, e);
}
int i = name.lastIndexOf('.');