coherence-community / oracle-bedrock

Oracle Bedrock
Other
55 stars 31 forks source link

Correct Existing Deferred implementation to permit broader casting of returned types #342

Closed brianoliver closed 8 years ago

brianoliver commented 8 years ago

The Existing class currently only permits specifying a custom Class that is a sub-class of the specified value. While this is fine for most use-cases, it fails to allow up-casting.

For example, the following won't compile because Object is not a sub-class of String.

Existing<Object> = new Existing("Hello", Object.class);

However, it's perfectly legal to perform a cast like this: Object object = (Object)"Hello";

Resolving this issue is important as it will allow future casting between types, specially from Object to something else and vice-versa.

The change in method signature is completely backwards compatible as it simply removes a type restriction.