I have the following code in an eclipse application:
import org.eclipse.swt.widgets.Listener; public class X { public void test() { Listener eclipseListener = new Listener() { public void handleEvent(Event evt) { System.err.println("starting"); Y.externalMethod(); System.err.println("finished"); } } } public class Y { public static void externalMethod() { System.err.println("in class Y"); } } When I run method test in class X, I get the following output:
starting
I don't understand why externalMethod didn't run in class Y and why control didn't return to class X (it never prints 'finished' or 'in class Y').
Any ideas about why externalMethod doesn't run? Are anonymous inner classes not permitted to call static methods outside their class? If so, why does this code compile?
eclipseListener.handleEvent(null);and run it. Can you generate an SCCE? May well find the actual problem in the process.