]
Pete Muir commented on JBSEAM-1867:
-----------------------------------
You can't inject a Seam logger into an org.apache.commons.logging.Log object. This
works if you are injecting into a org.jboss.seam.log.Log right?
NPE in org.jboss.seam.util.Reflections when an exception arise while
accessing a static field
---------------------------------------------------------------------------------------------
Key: JBSEAM-1867
URL:
http://jira.jboss.com/jira/browse/JBSEAM-1867
Project: JBoss Seam
Issue Type: Bug
Components: Core
Affects Versions: 2.0.0.BETA1
Environment: MAC OS X 10.4.10, Java(TM) 2 Runtime Environment, Standard Edition
(build 1.5.0_07-164)
Java HotSpot(TM) Client VM (build 1.5.0_07-87, mixed mode, sharing), G5 PPC
Reporter: Thomas Bauer
When an exception is thrown while accessing a static field in
org.jboss.seam.util.Reflections.get/set (org/jboss/seam/util/Reflections line 46 and 60)
the catch-block will throw a NPE when accessing the variable "target" (which is
null):
Static Fields may have target == null (e.g. call from org.jboss.seam.Component:840:
if ( Modifier.isStatic( field.getModifiers() ) )
{
Reflections.setAndWrap(field, null, logInstance); // <== HERE
'null' is passed as target
}
)
public static void set(Field field, Object target, Object value) throws Exception
{
try
{
field.set(target, value);
}
catch (IllegalArgumentException iae)
{
String message = "Could not set field value by reflection: " +
toString(field) +
" on: " + target.getClass().getName(); // <== HERE target ==
null -> NPE!
/* snipped */
}
}
This appears in:
cvs status Reflections.java
===================================================================
File: Reflections.java Status: Up-to-date
Working revision: 1.22
Repository revision: 1.22
/cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/util/Reflections.java,v
Sticky Tag: (none)
Sticky Date: (none)
Sticky Options: (none)
You can reproduce the Bug when creating a bean:
* import org.apache.commons.logging.Log instead of org.jboss.seam.log.Log
* Inject the logger: @Logger private static Log log;
Reflections.java:64: field.set(target, value);
will throw an IllegalArgumentException because it can't assign the object because of
type-mismatch
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: