2 Replies Latest reply: Mar 30, 2012 7:31 AM by Shing Hing Man RSS

Downcast in bind clause

Anton Ryabtsev Newbie

Hi,

 

Is it possible to do downcast in the bind clause of a rule?

 

like this:

 

RULE rule

CLASS Foo

METHOD bar

AT ENTRY

BIND child : HashMap  = $input;

IF true

DO traceln("yes, it works!" + child)

ENDRULE

 

 

public class Foo {

    public void bar(Map input) {
        System.out.println("");
    }

}

 

  • 1. Re: Downcast in bind clause
    Andrew Dinn Master

    Hi Anton,

     

    Anton Ryabtsev wrote:

     

    Hi,

     

    Is it possible to do downcast in the bind clause of a rule?

     

    At present no. However, I have been thinking for quite a while about providing some sort of support for downcasting.

     

    I have not proposed/implemented anything yet because it's not necessarily clear to me how to provide this capability, in particular how to deal with cast exceptions (it's not trappng these that I am concerned with, rather providing a clean way for rules to cope with the consequences).

     

    So, if you can provide me with some idea of what you want to do, why you want to do it and how you would like it to behave I would be glad to consider this as input to any requirements for an implementation. Community software is supposed to serve a community so any input yoou can provide will be very interesting.

  • 2. Re: Downcast in bind clause
    Shing Hing Man Newbie

    I would also like to be able to downcast in the BIND clause.

     

    I am using Byteman as a debugging tool to collect intermediate values of a

    long calculation, which  is spreaded across several classes.

     

    My current  work around is to have the  downcasting done  in a custom Java class, and this makes my

    custom class to depend  on the  code, which I try to debug.  I can live with the above.

    But it would be better to do downcast in the BIND clause,as I would have less code to maintain

    and less dependency.  

     

     

    Without downcasting, I would have to collect the intermediate values when it is calculated.

    This would result in more rules.

     

     

    In my case, if there is a class cast exception, it is acceptable that  it is not catched.