From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29111 invoked by alias); 4 Oct 2006 08:37:21 -0000 Received: (qmail 29099 invoked by uid 22791); 4 Oct 2006 08:37:20 -0000 X-Spam-Check-By: sourceware.org Received: from gbenson.demon.co.uk (HELO gbenson.demon.co.uk) (80.177.220.214) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 04 Oct 2006 08:37:18 +0000 Received: from mambo.wire.rat ([192.168.1.6]) by gbenson.demon.co.uk with esmtp (Exim 3.36 #1) id 1GV2Ff-0006C5-00; Wed, 04 Oct 2006 09:37:15 +0100 Received: from mambo.wire.rat (localhost.localdomain [127.0.0.1]) by mambo.wire.rat (8.13.7/8.13.6) with ESMTP id k948bFaT024924; Wed, 4 Oct 2006 09:37:15 +0100 Received: (from gary@localhost) by mambo.wire.rat (8.13.7/8.13.7/Submit) id k948bF6M024923; Wed, 4 Oct 2006 09:37:15 +0100 Date: Wed, 04 Oct 2006 08:37:00 -0000 From: Gary Benson To: java-patches@gcc.gnu.org Subject: Re: FYI: Win32 InetAddress fix (really) Message-ID: <20061004083711.GA24703@redhat.com> Mail-Followup-To: java-patches@gcc.gnu.org References: <4520BD9B.8070802@gmx.ch> <20061002105534.GB4239@redhat.com> <20061003103525.GC6967@redhat.com> <45227D4F.1000906@avtrex.com> <17698.38378.993886.203823@zebedee.pink> <45229C7B.20002@avtrex.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <45229C7B.20002@avtrex.com> X-IsSubscribed: yes Mailing-List: contact java-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: java-patches-owner@gcc.gnu.org X-SW-Source: 2006-q4/txt/msg00016.txt.bz2 David Daney wrote: > Andrew Haley wrote: > > David Daney writes: > > > Gary Benson wrote: > > > > + catch (UnknownHostException e) > > > > + { > > > > + throw new RuntimeException("should never happen", e); > > > > + } > > > > > > Would it be better to throw an InternalError here rather than > > > RuntimeException? If it truly should never happen then it would > > > be an InternalError if it did. If it can happen, then it should > > > be of some type the describes the problem. > > > > AFAICR this is the kind of thing that happens if the IP address of > > the loopback interface doesn't have a resolvable name, > > I guess in this specific case it does not really matter as > it is in a static initializer and the result would be an > ExceptionInInitiazerError either way. > > But in general I don't like the use RuntimeException. It makes me > think that we were too lazy to figure out what to do and took the > easy (but inelegant and probably incorrect) way out by circumventing > java's checked exception requirements. The only time getByAddress() throws an UnknownHostException is when the array of bytes you pass it is is neither 4 or 16 bytes long (for IPv4 and IPv6 addresses respectively). And since we're calling it as getByAddress(new byte[] {127, 0, 0, 1}) it really should never happen. I specifically didn't use InternalError in this case because its javadoc says it's thrown to indicate an error in the VM (which I took to mean the bytecode interpreter) and therefore that InternalError was something that should only be thrown by the VM. But, I suppose in this case the only way this code could be reached is if the VM is broken, so... (The ultimate solution would be to have getByAddress throw an IllegalArgumentException when it's passed an address array of the wrong length, but that's not something we get to fix :/) I'll make it InternalError in Classpath so it gets picked up when I commit the remainder of the InetAddress merge. Cheers, Gary