Author: swd847
Date: 2010-07-30 21:01:13 -0400 (Fri, 30 Jul 2010)
New Revision: 6862
Modified:
java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/url/WeldSEResourceLoader.java
Log:
improve the way weld-se handles optional dependencies
Modified:
java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/url/WeldSEResourceLoader.java
===================================================================
---
java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/url/WeldSEResourceLoader.java 2010-07-30
23:53:22 UTC (rev 6861)
+++
java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/url/WeldSEResourceLoader.java 2010-07-31
01:01:13 UTC (rev 6862)
@@ -23,6 +23,7 @@
import org.jboss.weld.resources.spi.ResourceLoader;
import org.jboss.weld.resources.spi.ResourceLoadingException;
import org.jboss.weld.util.collections.EnumerationList;
+import org.jboss.weld.util.reflection.Reflections;
/**
* A simple resource loader.
@@ -41,14 +42,29 @@
try
{
+ Class<?> clazz = null;
if (Thread.currentThread().getContextClassLoader() != null)
{
- return Thread.currentThread().getContextClassLoader().loadClass(name);
+ clazz = Thread.currentThread().getContextClassLoader().loadClass(name);
}
else
{
- return Class.forName(name);
+ clazz = Class.forName(name);
}
+ // if the class relies on optional dependencies that are not present
+ // then a CNFE can be thrown later in the deployment process when the
+ // Introspector is inspecting the class. We call getMethods, getFields
+ // and getConstructors now over the whole type heirachey to force
+ // these errors to occur early
+ Class<?> obj = clazz;
+ while (obj != null && obj != Object.class)
+ {
+ obj.getDeclaredConstructors();
+ obj.getDeclaredFields();
+ obj.getDeclaredMethods();
+ obj = obj.getSuperclass();
+ }
+ return clazz;
}
catch (ClassNotFoundException e)
{
Show replies by date