[prev in list] [next in list] [prev in thread] [next in thread]
List: velocity-dev
Subject: cvs commit: jakarta-velocity/src/java/org/apache/velocity/util/introspection MethodMap.java
From: geirm () apache ! org
Date: 2002-07-25 2:58:08
[Download RAW message or body]
geirm 2002/07/24 19:58:08
Modified: src/java/org/apache/velocity/util/introspection
MethodMap.java
Log:
hopefully safe fix for problem when trying to find a method when we
are passing a null
Revision Changes Path
1.15 +32 -10 jakarta-velocity/src/java/org/apache/velocity/util/introspection/MethodMap.java
Index: MethodMap.java
===================================================================
RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/util/introspection/MethodMap.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- MethodMap.java 23 Mar 2002 13:30:57 -0000 1.14
+++ MethodMap.java 25 Jul 2002 02:58:08 -0000 1.15
@@ -162,9 +162,13 @@
for(int i = 0; i < l; ++i)
{
Object arg = args[i];
- // A null argument is always treated as being a generic Object.
- classes[i] =
- arg == null ? java.lang.Object.class : arg.getClass();
+
+ /*
+ * if we are careful down below, a null argument goes in there
+ * so we can know that the null was passed to the method
+ */
+ classes[i] =
+ arg == null ? null : arg.getClass();
}
return getMostSpecific(methodList, classes);
@@ -380,12 +384,20 @@
*/
private static boolean isMethodInvocationConvertible(Class formal,
Class actual)
- {
+ {
+ /*
+ * if it's a null, it means the arg was null
+ */
+ if (actual == null && !formal.isPrimitive())
+ {
+ return true;
+ }
+
/*
* Check for identity or widening reference conversion
*/
- if(formal.isAssignableFrom(actual))
+ if (actual != null && formal.isAssignableFrom(actual))
{
return true;
}
@@ -395,7 +407,7 @@
* actual parameters are never primitives.
*/
- if(formal.isPrimitive())
+ if (formal.isPrimitive())
{
if(formal == Boolean.TYPE && actual == Boolean.class)
return true;
@@ -424,7 +436,8 @@
actual == Long.class || actual == Integer.class ||
actual == Short.class || actual == Byte.class))
return true;
- }
+ }
+
return false;
}
@@ -444,10 +457,19 @@
*/
private static boolean isStrictMethodInvocationConvertible(Class formal,
Class actual)
- {
+ {
+ /*
+ * we shouldn't get a null into, but if so
+ */
+ if (actual == null && !formal.isPrimitive())
+ {
+ return true;
+ }
+
/*
* Check for identity or widening reference conversion
- */
+ */
+
if(formal.isAssignableFrom(actual))
{
return true;
--
To unsubscribe, e-mail: <mailto:velocity-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:velocity-dev-help@jakarta.apache.org>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic