[jbossseam-issues] [JBoss JIRA] Updated: (JBSEAM-1867) NPE in org.jboss.seam.util.Reflections when an exception arise while accessing a static field
Pete Muir (JIRA)
jira-events at lists.jboss.org
Mon Aug 27 12:58:18 EDT 2007
[ http://jira.jboss.com/jira/browse/JBSEAM-1867?page=all ]
Pete Muir updated JBSEAM-1867:
------------------------------
Fix Version/s: 2.0.0.CR1
Description: NPE thrown in Reflections.set when constructing error message when target is null. target may be null e.g. if field being set is static (was: 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
)
Assignee: Pete Muir
Priority: Minor (was: Major)
> 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
> Assigned To: Pete Muir
> Priority: Minor
> Fix For: 2.0.0.CR1
>
>
> NPE thrown in Reflections.set when constructing error message when target is null. target may be null e.g. if field being set is static
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the seam-issues
mailing list