ddp 02/05/10 07:45:56
Modified: src/java/org/apache/bcel/util ClassLoader.java
Log:
Fixed: Was using the SystemClassLoader when loading a class that
is ignored by the ClassLoader. Now, it uses "deferTo".
Revision Changes Path
1.4 +31 -11 jakarta-bcel/src/java/org/apache/bcel/util/ClassLoader.java
Index: ClassLoader.java
===================================================================
RCS file: /home/cvs/jakarta-bcel/src/java/org/apache/bcel/util/ClassLoader.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ClassLoader.java 8 May 2002 20:59:29 -0000 1.3
+++ ClassLoader.java 10 May 2002 14:45:56 -0000 1.4
@@ -79,7 +79,7 @@
* where to use the system class loader in the constructor. The default value contains
* "java.", "sun.", "javax."</p>
*
- * @version $Id: ClassLoader.java,v 1.3 2002/05/08 20:59:29 ddp Exp $
+ * @version $Id: ClassLoader.java,v 1.4 2002/05/10 14:45:56 ddp Exp $
* @author <A HREF="mailto:[email protected]">M. Dahm</A>
* @see JavaWrapper
* @see ClassPath
@@ -89,23 +89,42 @@
private String[] ignored_packages = {
"java.", "javax.", "sun."
};
- private Repository repository = null;
+ private Repository repository =
+ SyntheticRepository.getInstance();
+ private java.lang.ClassLoader deferTo = ClassLoader.getSystemClassLoader();
public ClassLoader() {
}
+ public ClassLoader( java.lang.ClassLoader deferTo ) {
+ this.deferTo = deferTo;
+ this.repository = new ClassLoaderRepository( deferTo );
+ }
+
/** @param ignored_packages classes contained in these packages will be loaded
* with the system class loader
*/
public ClassLoader(String[] ignored_packages) {
- String[] new_p = new String[ignored_packages.length + this.ignored_packages.length];
+ addIgnoredPkgs( ignored_packages );
+ }
- System.arraycopy(this.ignored_packages, 0, new_p, 0, this.ignored_packages.length);
- System.arraycopy(ignored_packages, 0, new_p, this.ignored_packages.length,
- ignored_packages.length);
+ public ClassLoader( java.lang.ClassLoader deferTo,
+ String [] ignored_packages ) {
+ this.deferTo = deferTo;
+ this.repository = new ClassLoaderRepository( deferTo );
+
+ addIgnoredPkgs( ignored_packages );
+ }
+
+ private void addIgnoredPkgs( String[] ignored_packages ) {
+ String[] new_p = new String[ignored_packages.length + this.ignored_packages.length];
+
+ System.arraycopy(this.ignored_packages, 0, new_p, 0, this.ignored_packages.length);
+ System.arraycopy(ignored_packages, 0, new_p, this.ignored_packages.length,
+ ignored_packages.length);
- this.ignored_packages = new_p;
- }
+ this.ignored_packages = new_p;
+ }
protected Class loadClass(String class_name, boolean resolve)
throws ClassNotFoundException
@@ -120,7 +139,7 @@
*/
for(int i=0; i < ignored_packages.length; i++) {
if(class_name.startsWith(ignored_packages[i])) {
- cl = Class.forName(class_name);
+ cl = deferTo.loadClass(class_name);
break;
}
}
@@ -133,8 +152,9 @@
if(class_name.indexOf("$$BCEL$$") >= 0)
clazz = createClass(class_name);
else { // Fourth try: Load classes via repository
- if((clazz = org.apache.bcel.Repository.lookupClass(class_name)) != null)
- clazz = modifyClass(clazz);
+ if ( (clazz = repository.loadClass( class_name )) != null) {
+ clazz = modifyClass( clazz );
+ }
else
throw new ClassNotFoundException(class_name);
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.