rsitze 2002/10/10 11:34:23
Modified: discovery/src/java/org/apache/commons/discovery
ResourceClass.java
Log:
Cause loadClass to force linking of class for JDK14.
Only return classes that really can be loaded,
preventing future surprises..
Revision Changes Path
1.3 +17 -0
jakarta-commons/discovery/src/java/org/apache/commons/discovery/ResourceClass.java
Index: ResourceClass.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/discovery/src/java/org/apache/commons/discovery/ResourceClass.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ResourceClass.java 30 Aug 2002 22:19:33 -0000 1.2
+++ ResourceClass.java 10 Oct 2002 18:34:23 -0000 1.3
@@ -101,6 +101,23 @@
try {
resourceClass = getClassLoader().loadClass(getName());
+
+ /**
+ * Loading the class does not necessarily link it...
+ * and we need to know, at this point in the flow,
+ * if the class is actually loadable or not!
+ *
+ * Force load (for Sun JDK14?):
+ */
+ try {
+ resourceClass.getDeclaredMethod("anyName", new Class[0]);
+ } catch(NoClassDefFoundError e) {
+ // some dependency couldn't be found..
+ // class cannot be loaded.
+ resourceClass = null;
+ } catch(NoSuchMethodException e) {
+ // ignore
+ }
} catch (ClassNotFoundException e) {
resourceClass = null;
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>