Support private methods in interfaces
zbynek opened this issue · 4 comments
GWT version: 2.11
Browser (with version): all
Operating System: all
Description
As of Java 9 this is supported in Java: https://docs.oracle.com/en/java/javase/14/language/small-language-changes.html, but GWT support is missing
Steps to reproduce
Try compiling code with
public interface Greeter {
public static String greet() {return concat("Hello", "World");}
private static String concat(String a, String b) { return a + b; }
}
The following appears in log:
Illegal modifier for the interface method concat; only public, abstract, default, static and strictfp are permitted
Known workarounds
Make method public
Links to further discussions
I can't reproduce - are you sure you have sourceLevel set high enough? At this time, it still defaults to 8
, you might want to set it to the java version in the rest of your project (or to auto
to just use the jdk version that you're running with). Can you confirm?
I do however see a bug where interfaces annotated with jstype will appear to error out on private members:
gwt/dev/core/src/com/google/gwt/dev/jjs/impl/JsInteropRestrictionChecker.java
Lines 411 to 414 in 5e87768
In this case however, the error actually means "you forgot @JsOverlay
" - but it is the same error message you get if you don't add default
to a method with a body, so I still don't think there is a bug here (so much as a less helpful error message).
Indeed, sourceLevel
was missing 🤦
What is "strictfp" in the error message?
What is "strictfp" in the error message?
https://docs.oracle.com/javase/specs/jls/se7/html/jls-8.html#jls-8.4.3.5