Same fix I did locally. I havenât gotten into the whole fork/fix/pull mechanics yet - but will try it in the future when I have a proposed fix for something
Your fix is calling the wrong method. The whole point is to call the method in the outer class as the one in the inner class doesnât do the right thing anymore.
âŚwith your change, the click events wonât be fired.
The real question is why isnât Java 8 finding the click() method that is perfectly in scope for the inner class:
If Java 8 changed to the scoping rules then itâs really stupid⌠because protected should be available to both inner classes as well as friendly access to everything else in the package.
But the call youâve changed it do does nothing:
âŚand so breaks a bunch of stuff. Itâs only there to override the superclassâs method.
Iâve just checked Button.java with a fix that hopefully works around this bug in the Java 8 compiler. (I canât see how itâs not a javac bug, anyway.)
Or try my fix⌠because it seems to work fine for the other inner class that doesnât have its own click() method. So I renamed the outer class click() method to runClick() to work around the bug in the Java 8 compiler.
More bytecode does not necessarily means that it takes longer.
BTW
for (int i = 0; i < 10; i++) {}
needs 10 bytecodes per iteration whereas
for (int i = 10; --i >= 0; ) {}
needs only 7
Or do you care about the huge more disk place
Edit: Are you even sure about that; I think you have to push this on the stack for every (non-static) method you are using; therefore you have to push the Outerclassâ this on the stack anyway, which is what a button.this does.
Anyway, itâs cleaner and avoids future issues to just rename the method. Since the Java 7 compiler that I use doesnât have the bug but the Java 8 compiler does have the bug⌠weâd hit this again the next time I refactored and forgot to put the extra garbage at the beginning.
Iâll just make a mental note that Java 8âs method resolution code is broken and try to avoid using the same names for inner/outer class methods in the future.
I might be wrong, but I think that Outerclass.this is the intended way of referencing methods from the outer class (and by intended I mean by James Gosling). My guess is that the âbugâ is on Java7
Itâs the intended way yes, but only for methods with the same signature; so same name and same parameters, so normally click() should work (Donât know what they changed, that it once worked and not now)
Me either. That has worked since Java 1.2 at least (from personal experience) and Java 8 is the first time Iâve seen it not work.
Iâd claim it worked in Java 1.1 but my experience with 1.1 is not extensive enough to be sure that I did that with an inner class. In 1.2 with Swing, I 100% did. So common.