Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed1.swip.net!newsfeed3.funet.fi!newsfeeds.funet.fi!feeder2.news.elisa.fi!uutiset.elisa.fi!7564ea0f!not-for-mail Newsgroups: alt.comp.lang.borland-delphi,comp.lang.c,comp.lang.java.programmer From: Heikki Kallasjoki Subject: Re: Oracle/Google demonstrate human beings cannot write 10 lines of code without making a mistake ;) References: <29308868.1994.1337265697084.JavaMail.geo-discussion-forums@pbcuc6> <84131$4fb54067$5419acc3$20839@cache90.multikabel.net> <4e980$4fb56cac$5419acc3$13190@cache60.multikabel.net> Organization: nonexistent Followup-To: comp.lang.java.programmer User-Agent: slrn/pre1.0.0-18 (Linux) Message-ID: Lines: 32 Date: Fri, 18 May 2012 07:22:40 GMT NNTP-Posting-Host: 91.156.75.88 X-Complaints-To: newsmaster@saunalahti.com X-Trace: uutiset.elisa.fi 1337325760 91.156.75.88 (Fri, 18 May 2012 10:22:40 EEST) NNTP-Posting-Date: Fri, 18 May 2012 10:22:40 EEST Xref: csiph.com comp.lang.c:20973 comp.lang.java.programmer:14613 On 2012-05-17, Skybuck Flying wrote: > To me it appears as if rangeCheck is some low level operating system code or > memory management code to try and prevent the os or applications from > crashing or exploits from taking over the system. > > It would be interesting to know where this "rangeCheck" function is from. AFAIK, it's originally from TimSort, the sorting algorithm used in Java nowadays. See http://gee.cs.oswego.edu/cgi-bin/viewcvs.cgi/jsr166/src/main/java/util/TimSort.java?view=co -- rangeCheck is at the end of the file. It's not low-level at all; the sandboxing is enforced by the Java VM. It's just used once to check the arguments of sort(), before starting the actual work, presumably in order to get more sensible-looking exceptions that it might otherwise produce. > I would not be surprised that the functions you mentioned would be the cause > of many bugs in java programs. > > Almost seems like a deliberate design to make java programs crash... perhaps Strongly disagree. I wouldn't be surprised if the number of places where half-open intervals are used would outnumber the uses of fully inclusive ranges, though a thorough survey is outside the scope of this message. I can only think of PHP range() and Perl "a..b" notation offhand. I'm sure more can be found; but then again, that applies also to half-open ranges, for which C++ (STL), JavaScript, Python and Java have already been mentioned. -- Heikki Kallasjoki