Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java inheritance: the strict default-abstract and default-default conflict rules

Can someone explain "the strict default-abstract and default-default conflict rules" mentioned in the JLS §8.4.8.4.

Are they defined in the JLS? I can't seem to find their definition.

like image 657
olovb Avatar asked May 10 '15 23:05

olovb


Video Answer


1 Answers

I could be wrong, but this is how I interpreted that section.

"default-default" and "default-abstract" are not keywords. They describe two different compilation conflict rules pertaining to default methods in interface.

"default-default" pertaining to a class implementing two or more interfaces that provide default implementations of override equivalent methods while not providing it's own implementation.

"default-abstract" pertaining to a class implementing one interface that provides a default implementation and one or more interfaces not providing default implementations of override equivalent methods.

The exception to these two rules is if a super class of the class in question specifies an abstract method that is override equivalent which trumps the definitions found in any implementing interface.

If the class inherits a concrete override equivalent method from a super class or defines its own then none of these conflicts apply.

like image 171
Smith_61 Avatar answered Oct 20 '22 01:10

Smith_61