Campbell Ritchie wrote:You are probably too young to understand public class LSD extends Money.
Unfortunately (or should that be fortunately) not.
Matthew Brown wrote:In other words, would it be a problem to return legacy types as long as they were never referred to as that type?
An interesting point.
Any restrictions on what could be returned would have to be compiler and not runtime restrictions so you would have to allow legacy classes to be returned if referred to by an implemented interface.
Another issue is if a class is marked as Legacy what happens to any class that extends it.
Yes, I think the Java 7 code should be able to return objects of legacy classes via an supported interface. The idea is to break the dependency between Java 7 code and deprecated API. As long as the exposed type is supported in Java 7, there's shouldn't be a problem. It shouldn't matter that the object that extends/implements a deprecated type
Of course there will be backdoors. The Java 7 code will be able to use reflection to call Java 6 methods. But, if someone is dumb or desperate enough to write new code that uses a backdoor takes the risk that they will require rework when they upgrade their 3rd party libraries.
this is supposed to be a surprise, but it smells like a tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop