Sorry, hate to follow-up myself: please find the planned changes enclosed.

---rony


Rony G. Flatscher wrote:

Hi there,

there are two problems with 'EngineUtils.java':

  1. the Accessible-functionality is not available on Java 1.1.8 (I
     know, *very* old, yet still people use it): for that reason there
     is a static method which tests for the availability of that
     method, which then later is used for determining how to invoke a
     method;
  2. there are two kind of bugs: if the boxed primitive datatypes do
     not yield a matching signature, then the types are "unboxed", but
     the tests for Integer, Long are missing; the other error has to do
     with not checking for the boxed datatype Character, such that
     "char" are not accounted for in signatures.

In any case # 2 should get applied and commited (plain bug fixes).

Still, what about # 1: it really is only necessary for supporting Java 1.1. It would be great though, if we did support all Java versions as long as possible, at least with BSF 2.0 (= Apache BSF).

What do you think?

If I do not hear anything by Saturday, I would apply the changes and commit them.

Regards,

---rony

4c4
<  * Copyright (c) 2002 The Apache Software Foundation.  All rights
---
>  * Copyright (c) 2004 The Apache Software Foundation.  All rights
78,96d77
<   // ---rgf, 2003-02-13, determine whether changing accessibility of Methods 
is possible
<   static boolean bMethodHasSetAccessible=false;
<
<   // ---rgf, 2003-02-13, determine whether changing accessibility of Methods 
is possible
<   static {
<       Class mc=Method.class;            // get the "Method" class object
<       Class arg[]={boolean.class};      // define an array with the primitive 
"boolean" pseudo class object
<       try {
<           Object o=mc.getMethod("setAccessible", arg ); // is this method 
available?
<           bMethodHasSetAccessible=true; // no exception, hence method exists
<       }
<       catch (Exception e)
<       {
<           bMethodHasSetAccessible=false;// exception occurred, hence method 
does not exist
<       }
<   }
<
<   //////////////////////////////////////////////////////////////////////////
<
168c152,153
<           Method m;
---
>             Method m = null;
>
179,180c164
<             if (args[i] instanceof Number)
<             {
---
>                         if (args[i] instanceof Number) {
184,195c168,172
<               if      (args[i] instanceof Byte)    argTypes[i] = byte.class;
<                     // 2005-06-08, rgf, *must* be given, or signatures not 
found!
<               else if (args[i] instanceof Short  ) argTypes[i] = short.class;
<               else if (args[i] instanceof Integer) argTypes[i] = int.class;
<               else if (args[i] instanceof Long)    argTypes[i] = long.class;
<
<               else if (args[i] instanceof Float)   argTypes[i] = float.class;
<               else if (args[i] instanceof Double ) argTypes[i] = double.class;
<             }
<             else if (args[i] instanceof Boolean)   argTypes[i] = 
boolean.class;
<             // ---rgf, handle also the case of "Character"
<             else if (args[i] instanceof Character) argTypes[i] = char.class;
---
>                             argTypes[i] = byte.class;
>                             if(args[i] instanceof Float)
>                                 argTypes[i] = float.class;
>                             else if(args[i] instanceof Double)
>                                 argTypes[i] = double.class;
197,199c174,180
<
<           m = MethodUtils.getMethod (beanClass, methodName, argTypes,
<                                          isStaticOnly);
---
>                         else if (args[i] instanceof Boolean)
>                             argTypes[i] = boolean.class;
>                         else if (args[i] instanceof Character)
>                             argTypes[i] = char.class;
>                     }
>                     m = MethodUtils.getMethod (beanClass, methodName,
>                                                argTypes, isStaticOnly);
207d187
<       try {
209,221d188
<       }
<       catch (Exception e3)                   // 2003-02-23, --rgf, maybe an 
IllegalAccessException?
<       {
<           if (e3 instanceof IllegalAccessException &&
<               bMethodHasSetAccessible &&
<               Modifier.isPublic(m.getModifiers())   )   // if a public method 
allow access to it
<           {
<               m.setAccessible(true);        // allow unconditional access to 
method
<           return m.invoke (bean, args);
<           }
<           // re-throw the exception
<           throw e3;
<       }
273,276c241
<             if (args[i] instanceof Number) {
<               // byte is convertible to all primitive numeric types,
<               // so this'll find anything in that order and the
<               // actual type will be that specified by the method decl
---
>                         if (args[i] instanceof Number)
278c243
<             } else if (args[i] instanceof Boolean) {
---
>                         else if (args[i] instanceof Boolean)
279a245,246
>                         else if (args[i] instanceof Character)
>                             argTypes[i] = char.class;

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to