olovb
olovb

Reputation: 2254

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.

Upvotes: 6

Views: 184

Answers (1)

Smith_61
Smith_61

Reputation: 2088

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.

Upvotes: 4

Related Questions