-
Notifications
You must be signed in to change notification settings - Fork 373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
jdk8 implements the same default method signature of different interface now got error #22
Comments
i dont know whats you said; |
@yjqg6666 If you have 2 different interfaces, and they both have a default method with the same signature, and you try to implement both of those interfaces in the same class, you will get a compile time error - as you have demonstrated. This has always been an issue for interfaces (2 interfaces with identical method signatures can't be implemented in the same class). Default methods aren't really any different in this regard. Default methods are still public signatures on the interface - they just happen to have some behaviour attached to them now. I'm not sure if that's what you are trying to point out, or if you have a different issue. Can you clarify some? |
https://github.com/shekhargulati/java8-the-missing-tutorial/blob/master/01-default-static-interface-methods.md
Rule 3: Otherwise, the class has to call the desired implementation unambiguously
Running with
openjdk version "1.8.0_144"
OpenJDK Runtime Environment (Zulu 8.23.0.3-macosx) (build 1.8.0_144-b01)
OpenJDK 64-Bit Server VM (Zulu 8.23.0.3-macosx) (build 25.144-b01, mixed mode)
will got error:
Error:(7, 8) java: class com.example.Test inherits unrelated defaults for test() from types com.example.TestAInterface and com.example.TestBInterface
The text was updated successfully, but these errors were encountered: