You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by joern turner <jo...@web.de> on 2004/01/14 02:28:56 UTC

[jxpath] patch for MethodLookupUtils.lookupStaticMethod

hello,

found a problem in MethodLookupUtils when defining a custom function 
with no arguments cause the passed parameter array is null in that case.

a simple test for null and providing an empty Class array in this case 
solves the issue.


     public static Method lookupStaticMethod(
         Class targetClass,
         String name,
         Object[] parameters)
     {
         boolean tryExact = true;

         Class types[];
         if(parameters==null){
             types = new Class[0];
         }else{
             int count = parameters.length;
             types = new Class[count];
             for (int i = 0; i < count; i++) {
                 Object param = parameters[i];
                 if (param != null) {
                     types[i] = param.getClass();
                 }
                 else {
                     types[i] = null;
                     tryExact = false;
                 }
             }
         }
	....

Regards,

Joern Turner


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: [jxpath] patch for MethodLookupUtils.lookupStaticMethod

Posted by joern turner <jo...@web.de>.
Dmitri Plotnikov wrote:

> Joern,
> 
> I have updated the code to allow null as the argument "parameters".
thanks, so i can throw away my patch.

Regards,

Joern
> 
> - Dmitri
> 
> ----- Original Message ----- 
> From: "__matthewHawthorne" <ma...@phreaker.net>
> To: "Jakarta Commons Users List" <co...@jakarta.apache.org>
> Sent: Tuesday, January 13, 2004 9:12 PM
> Subject: Re: [jxpath] patch for MethodLookupUtils.lookupStaticMethod
> 
> 
> 
>>If you can, create a patch and submit it to Bugzilla.  That way, it
>>won't get lost in the mix.
>>
>>
>>joern turner wrote:
>>
>>>hello,
>>>
>>>found a problem in MethodLookupUtils when defining a custom function
>>>with no arguments cause the passed parameter array is null in that case.
>>>
>>>a simple test for null and providing an empty Class array in this case
>>>solves the issue.
>>>
>>>
>>>    public static Method lookupStaticMethod(
>>>        Class targetClass,
>>>        String name,
>>>        Object[] parameters)
>>>    {
>>>        boolean tryExact = true;
>>>
>>>        Class types[];
>>>        if(parameters==null){
>>>            types = new Class[0];
>>>        }else{
>>>            int count = parameters.length;
>>>            types = new Class[count];
>>>            for (int i = 0; i < count; i++) {
>>>                Object param = parameters[i];
>>>                if (param != null) {
>>>                    types[i] = param.getClass();
>>>                }
>>>                else {
>>>                    types[i] = null;
>>>                    tryExact = false;
>>>                }
>>>            }
>>>        }
>>>    ....
>>>
>>>Regards,
>>>
>>>Joern Turner
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>
>>
>>
>>
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: [jxpath] patch for MethodLookupUtils.lookupStaticMethod

Posted by joern turner <jo...@web.de>.
Dmitri Plotnikov wrote:

> Joern,
> 
> I have updated the code to allow null as the argument "parameters".
thanks, so i can throw away my patch.

Regards,

Joern
> 
> - Dmitri
> 
> ----- Original Message ----- 
> From: "__matthewHawthorne" <ma...@phreaker.net>
> To: "Jakarta Commons Users List" <co...@jakarta.apache.org>
> Sent: Tuesday, January 13, 2004 9:12 PM
> Subject: Re: [jxpath] patch for MethodLookupUtils.lookupStaticMethod
> 
> 
> 
>>If you can, create a patch and submit it to Bugzilla.  That way, it
>>won't get lost in the mix.
>>
>>
>>joern turner wrote:
>>
>>>hello,
>>>
>>>found a problem in MethodLookupUtils when defining a custom function
>>>with no arguments cause the passed parameter array is null in that case.
>>>
>>>a simple test for null and providing an empty Class array in this case
>>>solves the issue.
>>>
>>>
>>>    public static Method lookupStaticMethod(
>>>        Class targetClass,
>>>        String name,
>>>        Object[] parameters)
>>>    {
>>>        boolean tryExact = true;
>>>
>>>        Class types[];
>>>        if(parameters==null){
>>>            types = new Class[0];
>>>        }else{
>>>            int count = parameters.length;
>>>            types = new Class[count];
>>>            for (int i = 0; i < count; i++) {
>>>                Object param = parameters[i];
>>>                if (param != null) {
>>>                    types[i] = param.getClass();
>>>                }
>>>                else {
>>>                    types[i] = null;
>>>                    tryExact = false;
>>>                }
>>>            }
>>>        }
>>>    ....
>>>
>>>Regards,
>>>
>>>Joern Turner
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>
>>
>>
>>
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Re: [jxpath] patch for MethodLookupUtils.lookupStaticMethod

Posted by Dmitri Plotnikov <dm...@apache.org>.
Joern,

I have updated the code to allow null as the argument "parameters".

- Dmitri

----- Original Message ----- 
From: "__matthewHawthorne" <ma...@phreaker.net>
To: "Jakarta Commons Users List" <co...@jakarta.apache.org>
Sent: Tuesday, January 13, 2004 9:12 PM
Subject: Re: [jxpath] patch for MethodLookupUtils.lookupStaticMethod


> If you can, create a patch and submit it to Bugzilla.  That way, it
> won't get lost in the mix.
>
>
> joern turner wrote:
> > hello,
> >
> > found a problem in MethodLookupUtils when defining a custom function
> > with no arguments cause the passed parameter array is null in that case.
> >
> > a simple test for null and providing an empty Class array in this case
> > solves the issue.
> >
> >
> >     public static Method lookupStaticMethod(
> >         Class targetClass,
> >         String name,
> >         Object[] parameters)
> >     {
> >         boolean tryExact = true;
> >
> >         Class types[];
> >         if(parameters==null){
> >             types = new Class[0];
> >         }else{
> >             int count = parameters.length;
> >             types = new Class[count];
> >             for (int i = 0; i < count; i++) {
> >                 Object param = parameters[i];
> >                 if (param != null) {
> >                     types[i] = param.getClass();
> >                 }
> >                 else {
> >                     types[i] = null;
> >                     tryExact = false;
> >                 }
> >             }
> >         }
> >     ....
> >
> > Regards,
> >
> > Joern Turner
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Re: [jxpath] patch for MethodLookupUtils.lookupStaticMethod

Posted by Dmitri Plotnikov <dm...@apache.org>.
Joern,

I have updated the code to allow null as the argument "parameters".

- Dmitri

----- Original Message ----- 
From: "__matthewHawthorne" <ma...@phreaker.net>
To: "Jakarta Commons Users List" <co...@jakarta.apache.org>
Sent: Tuesday, January 13, 2004 9:12 PM
Subject: Re: [jxpath] patch for MethodLookupUtils.lookupStaticMethod


> If you can, create a patch and submit it to Bugzilla.  That way, it
> won't get lost in the mix.
>
>
> joern turner wrote:
> > hello,
> >
> > found a problem in MethodLookupUtils when defining a custom function
> > with no arguments cause the passed parameter array is null in that case.
> >
> > a simple test for null and providing an empty Class array in this case
> > solves the issue.
> >
> >
> >     public static Method lookupStaticMethod(
> >         Class targetClass,
> >         String name,
> >         Object[] parameters)
> >     {
> >         boolean tryExact = true;
> >
> >         Class types[];
> >         if(parameters==null){
> >             types = new Class[0];
> >         }else{
> >             int count = parameters.length;
> >             types = new Class[count];
> >             for (int i = 0; i < count; i++) {
> >                 Object param = parameters[i];
> >                 if (param != null) {
> >                     types[i] = param.getClass();
> >                 }
> >                 else {
> >                     types[i] = null;
> >                     tryExact = false;
> >                 }
> >             }
> >         }
> >     ....
> >
> > Regards,
> >
> > Joern Turner
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: [jxpath] patch for MethodLookupUtils.lookupStaticMethod

Posted by __matthewHawthorne <ma...@phreaker.net>.
If you can, create a patch and submit it to Bugzilla.  That way, it 
won't get lost in the mix.


joern turner wrote:
> hello,
> 
> found a problem in MethodLookupUtils when defining a custom function 
> with no arguments cause the passed parameter array is null in that case.
> 
> a simple test for null and providing an empty Class array in this case 
> solves the issue.
> 
> 
>     public static Method lookupStaticMethod(
>         Class targetClass,
>         String name,
>         Object[] parameters)
>     {
>         boolean tryExact = true;
> 
>         Class types[];
>         if(parameters==null){
>             types = new Class[0];
>         }else{
>             int count = parameters.length;
>             types = new Class[count];
>             for (int i = 0; i < count; i++) {
>                 Object param = parameters[i];
>                 if (param != null) {
>                     types[i] = param.getClass();
>                 }
>                 else {
>                     types[i] = null;
>                     tryExact = false;
>                 }
>             }
>         }
>     ....
> 
> Regards,
> 
> Joern Turner


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: [jxpath] patch for MethodLookupUtils.lookupStaticMethod

Posted by joern turner <jo...@web.de>.
Michael Nascimento Santos wrote:

> But wouldn't it work if you were passing an empty array instead of null?
that's what i doing here...

couldn't find a hook on the callers side.
> 
> I don't know how this class is used, so, I may be saying something wrong...
i'm absolutely no jxpath wizard but looked for a quick fix of the 
problem - and at least it works for me and makes my testcase pass :)

Joern

> 
> []s
> Michael
> 
> ----- Original Message ----- 
> From: "joern turner" <jo...@web.de>
> To: <co...@jakarta.apache.org>
> Sent: Tuesday, January 13, 2004 10:28 PM
> Subject: [jxpath] patch for MethodLookupUtils.lookupStaticMethod
> 
> 
> 
>>hello,
>>
>>found a problem in MethodLookupUtils when defining a custom function 
>>with no arguments cause the passed parameter array is null in that case.
>>
>>a simple test for null and providing an empty Class array in this case 
>>solves the issue.
>>
>>
>>     public static Method lookupStaticMethod(
>>         Class targetClass,
>>         String name,
>>         Object[] parameters)
>>     {
>>         boolean tryExact = true;
>>
>>         Class types[];
>>         if(parameters==null){
>>             types = new Class[0];
>>         }else{
>>             int count = parameters.length;
>>             types = new Class[count];
>>             for (int i = 0; i < count; i++) {
>>                 Object param = parameters[i];
>>                 if (param != null) {
>>                     types[i] = param.getClass();
>>                 }
>>                 else {
>>                     types[i] = null;
>>                     tryExact = false;
>>                 }
>>             }
>>         }
>>....
>>
>>Regards,
>>
>>Joern Turner
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: [jxpath] patch for MethodLookupUtils.lookupStaticMethod

Posted by Michael Nascimento Santos <mi...@hotmail.com>.
But wouldn't it work if you were passing an empty array instead of null?

I don't know how this class is used, so, I may be saying something wrong...

[]s
Michael

----- Original Message ----- 
From: "joern turner" <jo...@web.de>
To: <co...@jakarta.apache.org>
Sent: Tuesday, January 13, 2004 10:28 PM
Subject: [jxpath] patch for MethodLookupUtils.lookupStaticMethod


> hello,
> 
> found a problem in MethodLookupUtils when defining a custom function 
> with no arguments cause the passed parameter array is null in that case.
> 
> a simple test for null and providing an empty Class array in this case 
> solves the issue.
> 
> 
>      public static Method lookupStaticMethod(
>          Class targetClass,
>          String name,
>          Object[] parameters)
>      {
>          boolean tryExact = true;
> 
>          Class types[];
>          if(parameters==null){
>              types = new Class[0];
>          }else{
>              int count = parameters.length;
>              types = new Class[count];
>              for (int i = 0; i < count; i++) {
>                  Object param = parameters[i];
>                  if (param != null) {
>                      types[i] = param.getClass();
>                  }
>                  else {
>                      types[i] = null;
>                      tryExact = false;
>                  }
>              }
>          }
> ....
> 
> Regards,
> 
> Joern Turner
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org