Menu

#219 Runtime error (Target Exception) using super

None
closed
nobody
None
5
2018-08-02
2005-06-15
Nigel
No

class t3 {
public String answer = "Yes";

public void w() {
String answer = "No!";
}
}
public class t3ext extends t3 {

public String answer = "No!";

public void w() {
String answer = "Maybe";
System.out.println("Is Nigel best?
> " + super.answer);
}

public static void main(String[] args) {
t3 w = new t3ext();
w.w();
}
}

Process cat exited with code 0

Compiling and running the above with java produdces:
> javac t3ext.java
Process javac exited with code 0
> java t3ext
Is Nigel best? > Yes
Process java exited with code 0

BeanShell has a runtime problem:
> java -classpath ../../bsh-2.0b4.jar bsh.Interpreter
t3ext.java
Class: class t3ext main method threw
exception:Method Invocation w.w : at Line: 23 : in file:
t3ext.java : w .w ( )

Called from method: main : at Line: -1 : in file: <Called
from Java Code> : <Compiled Java Code>
Target exception: Can't reach instance field: answer
from static context: t3ext : at Line: 17 : in file:
t3ext.java : super .answer

Called from method: w : at Line: -1 : in file: <Called from
Java Code> : <Compiled Java Code>

Process java exited with code 0

Discussion

  • nickl-

    nickl- - 2018-08-02
    • status: open --> closed
    • Group: -->
     
  • nickl-

    nickl- - 2018-08-02

    Ticket has been migrated to github.
    Please follow up on this over here: https://github.com/beanshell/beanshell/issues/357

     

Log in to post a comment.