Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Eric Sosman Newsgroups: comp.lang.java.programmer Subject: Re: Unexpected Boxing Error at Runtime Date: Fri, 5 Jan 2018 11:05:33 -0500 Organization: A noiseless patient Spider Lines: 20 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Fri, 5 Jan 2018 16:05:36 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="3099d834cd1362cb032bab8251561414"; logging-data="31341"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+5WSQoCMfhTt1Vap+oDEbT" User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 In-Reply-To: Content-Language: en-US Cancel-Lock: sha1:/zsiBYU6USyBAPkor50HTrUMoO8= Xref: csiph.com comp.lang.java.programmer:37924 On 1/4/2018 6:13 PM, j4n bur53 wrote: > [...] > So ut seems the if-then-else to gets some type > widening from to Integer. > > This makes it impossible for the compiler to spot > the error. Because usually this is spotted: > >         int foo = null; > >     Error: java: incompatible types: >     cannot be converted to int For contrast, study int foo = (Integer) null; -- esosman@comcast-dot-net.invalid Eleven hundred eleven days to go.