-
Bug
-
Resolution: Fixed
-
P4
-
repo-valhalla
-
generic
-
generic
From http://cr.openjdk.java.net/~briangoetz/valhalla/sov/02-object-model.html:
There is one possible incompatibility mode from such a migration – if the client compares the getClass() result with M.class. Pre-migration, an instance of Optional has class Optional.class; once Optional is migrated to an interface, instances of Optional will report some implementation class when queried with getClass.
This incompatibility surrounding use of M.class is the major compatibility cost of the migration approach outlined here. This can be mitigated somewhat by issuing compiling warnings when comparing the getClass() result with == against the class literal for an interface, since this will be known to fail at runtime.
There is one possible incompatibility mode from such a migration – if the client compares the getClass() result with M.class. Pre-migration, an instance of Optional has class Optional.class; once Optional is migrated to an interface, instances of Optional will report some implementation class when queried with getClass.
This incompatibility surrounding use of M.class is the major compatibility cost of the migration approach outlined here. This can be mitigated somewhat by issuing compiling warnings when comparing the getClass() result with == against the class literal for an interface, since this will be known to fail at runtime.