You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bsf-dev@jakarta.apache.org by "Rony G. Flatscher" <Ro...@wu-wien.ac.at> on 2005/06/08 22:25:35 UTC

Planned changes on 'EngineUtils.java'

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

Re: Planned changes on 'EngineUtils.java'

Posted by "Victor J. Orlikowski" <vi...@alumni.duke.edu>.
On Sat, Jun 11, 2005 at 02:53:43PM +0200, Rony G. Flatscher wrote:
> Righ, it's the old comment, I left it in there for the review (the 
> assumption of the comment didn't work).
> 

Perfect; not a problem then.

> Well, the strategy here seems to be: if a method with the supplied 
> signature is not found, then "unbox" the primitive datatypes and try 
> whether a method signature exists for them. For that reason it would not 
> be necessary to worry about BigDecimal et.al.: if a programmer uses 
> them, he would be able to get the appropriate primitive datatype 
> renderings off them, which then allows for seeking a method using the 
> primitive datatype signatures in the above section.
> 

Ah - ok - I misunderstood what was going on in the method
resolution here. Fine by me, then.

> Well, probably was a little bit depressed while working on that part of 
> the code...
> ;)
> 

I don't blame you. :)

> Seriously, no specific reason other than serving as an eye-catcher to 
> point to an area where I changed something and wanted others to become 
> aware of it (to double-check).
> 

OK.

> Fine. Thank you very much for your efforts!
> 

No worries. Thanks for providing the unified diff.

Victor
-- 
Victor J. Orlikowski <> victor.j.orlikowski@alumni.duke.edu

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


Re: Planned changes on 'EngineUtils.java'

Posted by "Rony G. Flatscher" <Ro...@wu-wien.ac.at>.
Hi Victor,

... cut ...

>Code doesn't match comment - unless I'm mistaken, checking instanceof Byte won't cover the other numeric types (or a custom subclass of Number).
>  
>
Righ, it's the old comment, I left it in there for the review (the 
assumption of the comment didn't work).

>>+	      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;
>>    
>>
>
>OK - I can buy this - except: what about BigDecimal and BigInteger, and what's the default case (which would handle a custom subclass of Number)?
>  
>
Well, the strategy here seems to be: if a method with the supplied 
signature is not found, then "unbox" the primitive datatypes and try 
whether a method signature exists for them. For that reason it would not 
be necessary to worry about BigDecimal et.al.: if a programmer uses 
them, he would be able to get the appropriate primitive datatype 
renderings off them, which then allows for seeking a method using the 
primitive datatype signatures in the above section.

>>+      catch (Exception e3)                   // 2003-02-23, --rgf, maybe an IllegalAccessException?
>>    
>>
>
>Just stylistic pedantry: why e3?
>  
>
Well, probably was a little bit depressed while working on that part of 
the code...
;)

Seriously, no specific reason other than serving as an eye-catcher to 
point to an area where I changed something and wanted others to become 
aware of it (to double-check).

>Otherwise, I'm happy.
>  
>
Fine. Thank you very much for your efforts!

Regards,

---rony


Re: Planned changes on 'EngineUtils.java'

Posted by "Victor J. Orlikowski" <vi...@alumni.duke.edu>.
On Fri, Jun 10, 2005 at 07:43:36PM +0200, Rony G. Flatscher wrote:
>    Sure, please find it enclosed.
> 

Cool - thanks. My comments are in-line.

> +++ EngineUtils.java	2005-06-07 11:37:28.114998400 +0200
> @@ -1,7 +1,7 @@
>  /*
>   * The Apache Software License, Version 1.1
>   *
> - * Copyright (c) 2004 The Apache Software Foundation.  All rights
> + * Copyright (c) 2002 The Apache Software Foundation.  All rights
>   * reserved.

Yeesh - someone update this for 2005...not something you need to
do - just mentioning it. I'll likely be beat to it.

> -                        if (args[i] instanceof Number) {
> +	    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

Code doesn't match comment - unless I'm mistaken, checking
instanceof Byte won't cover the other numeric types (or a custom
subclass of Number).

> +	      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;

OK - I can buy this - except: what about BigDecimal and
BigInteger, and what's the default case (which would handle a
custom subclass of Number)?

> +      catch (Exception e3)                   // 2003-02-23, --rgf, maybe an IllegalAccessException?

Just stylistic pedantry: why e3?

Otherwise, I'm happy.

Victor
-- 
Victor J. Orlikowski <> victor.j.orlikowski@alumni.duke.edu

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


Re: Planned changes on 'EngineUtils.java'

Posted by "Rony G. Flatscher" <Ro...@wu-wien.ac.at>.
Hi Victor,

>Mind attaching the patch as a unified diff, please? It's easier to read.
>  
>
Sure, please find it enclosed.

There are two things here:

    * bug fixes w.r.t. handling of primitive data types resp. their
      "boxing"/"unboxing",
    * one deals with a pecularity on Java 1.1.8 (yes, very old, yet
      there are people/business still using it); the test in the
      anonymous static block for "setAccessible" is carried out that
      way, in order to allow to determine the availablity also on
      non-Sun-Java compliant implementations of Java.

If you have any questions please let me know.

Regards,

---rony


Re: Planned changes on 'EngineUtils.java'

Posted by "Victor J. Orlikowski" <vi...@alumni.duke.edu>.
On Wed, Jun 08, 2005 at 10:36:11PM +0200, Rony G. Flatscher wrote:
> Sorry, hate to follow-up myself: please find the planned changes enclosed.
> 

Rony,

Mind attaching the patch as a unified diff, please?
It's easier to read.

Thanks,
Victor
-- 
Victor J. Orlikowski <> victor.j.orlikowski@alumni.duke.edu

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


Re: Planned changes on 'EngineUtils.java'

Posted by "Rony G. Flatscher" <Ro...@wu-wien.ac.at>.
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
>