Possible error in the Java Language Specifications

Alex Buckley alex.buckley at oracle.com
Fri Mar 4 22:22:10 UTC 2016


There is no error in the JLS.

There is no cast in 'doubleNum = ShortNum' so casting conversion is not 
relevant; rather, assignment conversion is relevant. If there was a 
cast, then since doubleNum is a double not a Double, Table 5.5-A would 
be relevant rather than 5.5-B.

Alex

On 2/22/2016 5:32 AM, TechnoTux wrote:
> Hi,
>
> in the java language SE 8 specification located at: http://docs.oracle.com/javase/specs/index.html
> in chapter 5 "Conversions and Contexts", page 119: in the Table 5.5-B. Casting conversions to reference types
>
> according to the table numeric reference types (Byte Short Character Integer Long Float Double) don't have casting conversion allowed to primitive value types
> now looking at the following code:
>
> Short ShortNum = 0;
> double doubleNum = 0;
>
> doubleNum = ShortNum;
>
> we see that Short converted to double which is primitive ..
>
>
>
>
> now if i may ask, if my point isn't correct and there is no error in the specifications and since i'm trying to get the OCA 8 certificate then please tell me what the Specification meant by no casting conversion allowed ...?
>


More information about the jls-jvms-spec-comments mailing list