Path: csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!news.swapon.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Eric Sosman Newsgroups: comp.lang.java.programmer Subject: Re: [JLS] new long[0][ -1 ] Date: Fri, 10 Jul 2015 08:02:57 -0400 Organization: A noiseless patient Spider Lines: 26 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Fri, 10 Jul 2015 12:01:37 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="858a9d65d95f4ea4d355bd116aa2cdbf"; logging-data="19793"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19AqKZtsLOHOtpsb/whmsk0" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.0.1 In-Reply-To: Cancel-Lock: sha1:vggnGNVh60uMe6j5Sh4JaurmnqY= Xref: csiph.com comp.lang.java.programmer:31978 On 7/10/2015 7:52 AM, Andreas Leitgeb wrote: > I've had a look at the JLS to find out about the more or less special > case of a 2-dimensional array, whose first(outer) dimension is 0, but > I didn't find any extra mention of that case. > > From what I read, it would evaluate *all* the dimensions, then check > if any of them is negative. > > But if first dimension is 0, then the loop shown in the "equivalent as"- > code sample would not get its body run even once, so actually it wouldn't > even notice if any of the further dimensions was negative. > > What would be an accurate *purely JLS-based* prediction for > new long[0][-1] > (not caring about actual existing JVM implementations) ? Intriguing question, but easily answered. 15.10.2, second bullet, second sub-bullet: "Next, the values of the dimension expressions are checked. If the value of any DimExpr expression is less than zero, then a NegativeArraySizeException is thrown." -- esosman@comcast-dot-net.invalid "Don't be afraid of work. Make work afraid of you." -- TLM