Anonymous class in global context

Harish Krishnaswamy <[email protected]>
Newsgroups gmane.comp.java.beanshell.devel
Message-ID <[email protected]>
Hi,

I am unable to run the following script from an embedded interpreter.

attr = new test.SampleAttribute("arg1", "arg2")
{
    run()
    {
        print("running");
    }
};

attr.run();

I get the following exception:

Sourced file: eval stream : Typed variable declaration : Error 
constructing inner class instance: bsh.ReflectError: Can't find 
constructor: global$1( java.lang.String, java.lang.String ) in class: 
global$1 : at Line: 5 : in file: eval stream : new SampleAttribute ( 
"arg1" , "arg2" ) {

    at bsh.BSHAllocationExpression.constructWithClassBody(Unknown Source)
    at bsh.BSHAllocationExpression.objectAllocation(Unknown Source)
    at bsh.BSHAllocationExpression.eval(Unknown Source)
    at bsh.BSHPrimaryExpression.eval(Unknown Source)
    at bsh.BSHPrimaryExpression.eval(Unknown Source)
    at bsh.BSHVariableDeclarator.eval(Unknown Source)
    at bsh.BSHTypedVariableDeclaration.eval(Unknown Source)
    at bsh.Interpreter.eval(Unknown Source)
    at bsh.Interpreter.eval(Unknown Source)
    at bsh2.TestBlock.main(TestBlock.java:31)
Exception in thread "main"

Apparently, it is extending the default global class and is unable to 
find the constructor. Is there a workaround for this situation?

Thanks,
Harish



-------------------------------------------------------
This SF.Net email is sponsored by OSTG. Have you noticed the changes on
Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now,
one more big change to announce. We are now OSTG- Open Source Technology
Group. Come see the changes on the new OSTG site. www.ostg.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.