Help please,

 

Is it possible to use a method or variable that is in scope in class A from a script that is evaluated in an Interpreter that is in scope in class A?

 

As in the following example:

 

class A {

 

            private void helloWorld( ){

                        System.out.println(“hello world”);

            }

 

            public static void main(String[] args) {

                        bsh.Interpreter i = new bsh.Interpreter();

try {

Object obj = i.eval( helloWorld( ) );

}

catch (bsh.TargetError te) { }

catch (bsh.EvalError ee)  { }

            }

 

}

 

As I understand there is a set(String, Object) function to pass in variables, but is there a way to “pass in” methods; perhaps some kind of method pointers?

 

 

Many Thanks,

 

James