Why Observable is still a class in Java 8?

Related Question:

Why is java.util.Observable not an abstract class?

Since we have interfaces which can contains default methods, isn't it a better idea to change Observable to an interface? From a functionality point of view, the Observable "does a thing" but not "is a thing". It should be changed to an interface in Java 8 correct?

Jon Skeet
people
quotationmark

It should be changed to an interface in Java 8 correct?

Not unless you want to break all backwards compatibility, no. If you changed it to an interface, then anything written as:

public class Foo extends Observable

would be broken. I suspect it may well also be invalid in terms of binary compatibility too, but just source incompatibility would be enough to make it a no-go change, IMO.

Likewise:

  • It's currently a concrete class, not an abstract class... so new Observable() is currently valid but wouldn't be as an interface
  • As you say yourself in another answer, the default implementation uses state... so it can't be implemented by interface default methods

people

See more on this question at Stackoverflow