5.1.7 Forbidden Conversions
- There is no permitted conversion from any reference type to any primitive type.
- Except for the string conversions, there is no permitted conversion from any primitive type to any reference type.
- There is no permitted conversion from the null type to any primitive type.
- There is no permitted conversion to the null type other than the identity conversion.
- There is no permitted conversion to the type
boolean
other than the identity conversion.
- There is no permitted conversion from the type
boolean
other than the identity conversion and string conversion.
- There is no permitted conversion other than string conversion from class type S to a different class type T if S is not a subclass of T and T is not a subclass of S.
- There is no permitted conversion from class type S to interface type K if S is
final
and does not implement K.
- There is no permitted conversion from class type S to any array type if S is not
Object
.
- There is no permitted conversion other than string conversion from interface type J to class type T if T is
final
and does not implement J.
- There is no permitted conversion from interface type J to interface type K if J and K declare methods with the same signature but different return types.
- There is no permitted conversion from any array type to any class type other than
Object
or String
.
- There is no permitted conversion from any array type to any interface type, except to the interface type
Cloneable
, which is implemented by all arrays.
- There is no permitted conversion from array type SC
[]
to array type TC[]
if there is no permitted conversion other than a string conversion from SC to TC.