Quantcast

Problem with constant defined in interface defined in class

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Problem with constant defined in interface defined in class

Hacim Bengali
Hi,

I have a problem with a constant defined in an interface which is
defined in a class.

When the following program is run I get the output
"interface constant=null" instead of the expected out "interface
constant=constant":

import bsh.EvalError;
import bsh.Interpreter;

public class BshInterfaceConstantTest
{
        public static void main(String[] args) throws EvalError
        {
                Interpreter interpreter = new Interpreter();
                interpreter.setStrictJava(true);
               
                String script =
                        "class FooBar {"
                        +"  interface Bla {"
                        +"    String CONSTANT = \"constant\";"
                        +"  }"
                        +"  public void perform() {"
                        +"    System.out.println(\"interface constant=\"+Bla.CONSTANT);"
                        +"  }"
                        +"}"

                        +"new FooBar().perform();";
               
                interpreter.eval(script);
        }
}

What is wrong with it?

Best regards
Hacim

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Beanshell-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users
Loading...