Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 68905 invoked from network); 28 Mar 2006 12:47:15 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 28 Mar 2006 12:47:15 -0000 Received: (qmail 12866 invoked by uid 500); 28 Mar 2006 12:47:14 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 12835 invoked by uid 500); 28 Mar 2006 12:47:14 -0000 Mailing-List: contact derby-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: Delivered-To: mailing list derby-dev@db.apache.org Received: (qmail 12823 invoked by uid 99); 28 Mar 2006 12:47:13 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Mar 2006 04:47:13 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=UNPARSEABLE_RELAY X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [192.18.98.43] (HELO brmea-mail-2.sun.com) (192.18.98.43) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Mar 2006 04:47:12 -0800 Received: from phys-gadget-1 ([129.156.85.171]) by brmea-mail-2.sun.com (8.12.10/8.12.9) with ESMTP id k2SCkK9I025284 for ; Tue, 28 Mar 2006 05:46:51 -0700 (MST) Received: from conversion-daemon.gadget-mail1.uk.sun.com by gadget-mail1.uk.sun.com (iPlanet Messaging Server 5.2 HotFix 1.24 (built Dec 19 2003)) id <0IWU00H018T41J@gadget-mail1.uk.sun.com> (original mail from Knut.Hatlen@Sun.COM) for derby-dev@db.apache.org; Tue, 28 Mar 2006 13:46:43 +0100 (BST) Received: from khepri19 (khepri19.Norway.Sun.COM [129.159.112.231]) by gadget-mail1.uk.sun.com (iPlanet Messaging Server 5.2 HotFix 1.24 (built Dec 19 2003)) with ESMTP id <0IWU00JEP8TUXI@gadget-mail1.uk.sun.com> for derby-dev@db.apache.org; Tue, 28 Mar 2006 13:46:43 +0100 (BST) Date: Tue, 28 Mar 2006 14:46:42 +0200 From: Knut Anders Hatlen Subject: Re: [jira] Updated: (DERBY-1146) Verify that JDBC4 signatures satisfied In-reply-to: <442922F2.4080001@sun.com> To: derby-dev@db.apache.org Cc: Andreas.Korneliussen@Sun.COM Message-id: Organization: Sun Microsystems MIME-version: 1.0 Content-type: text/plain; charset=us-ascii User-Agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/22.0.50 (usg-unix-v) References: <1315148802.1143544280659.JavaMail.jira@ajax> <442922F2.4080001@sun.com> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Andreas Korneliussen writes: > This is very interesting. > > However, isn't it the job of the compiler to figure out that the > signatures of an interface has been implemented ? > > I did the following change to EmbedResultSet40: > > I added "implements java.sql.ResultSet" in the class definition. The > compilation then failed with: > > [javac] > /home/ak136785/devel/derbydev/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet40.java:33: > org.apache.derby.impl.jdbc.EmbedResultSet40 is not abstract and > does not override abstract method > updateNCharacterStream(java.lang.String,java.io.Reader,int) in > java.sql.ResultSet > .. + warnings > > > The base class of EmbedResultSet40 also claims that it implements > java.sql.ResultSet, however it is compiled against a previous jre > version which does not have the new methods. By declaring that the > EmbedResultSet40 class implements java.sql.ResultSet, I make the > compiler check that the class implements the interface when compiling > it with the 1.6 jre. Yes, I have observed this too, and I agree that it is the job of the compiler to check this. However, I think there are some good reasons for having a test as well: 1) Relying on the developers to include "implements java.sql.(...)" in the subclasses is error-prone since the compiler doesn't complain if it's missing. 2) There might be cases where we don't have a separate 4.0 class, either because it's forgotten or because the new JDBC 4.0 methods could be compiled with older JDKs. 3) Writing the test was a lot more fun than going through all classes and adding "implements foo"! :) > I think it would be good for all EmbedXXX40 to declare which interface > they are supposed to implement, and then the compiler will make sure > that all signatures are satisfied. +0.5 It might be a good idea, but it might also just give us a false sense of security. For EmbedResultSet40 this would expose the errors, but it wouldn't help us to find that something is missing in EmbedClob. > Also, I think this also indicates that we should consider using > delegation instead of inheritance for code reuse. +1 -- Knut Anders