Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Z5C2V-0005LA-He for pgsql-jdbc@arkaria.postgresql.org; Wed, 17 Jun 2015 12:01:55 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Z5C2U-0007jm-UV for pgsql-jdbc@arkaria.postgresql.org; Wed, 17 Jun 2015 12:01:54 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Z5C2U-0007jg-An for pgsql-jdbc@postgresql.org; Wed, 17 Jun 2015 12:01:54 +0000 Received: from smtp.procolix.com ([95.215.185.30]) by magus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1Z5C2R-00006Y-K8 for pgsql-jdbc@postgresql.org; Wed, 17 Jun 2015 12:01:53 +0000 Received: from localhost (localhost [127.0.0.1]) by smtp.procolix.com (Postfix) with ESMTP id 9146D43D3C for ; Wed, 17 Jun 2015 14:01:50 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at smtp.procolix.com Received: from smtp.procolix.com ([127.0.0.1]) by localhost (host436.procolix.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id H1hw9ebfwn8R for ; Wed, 17 Jun 2015 14:01:49 +0200 (CEST) Received: from webmail.procolix.com (webmail.procolix.com [95.215.185.106]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: mark@lawinegevaar.nl) by smtp.procolix.com (Postfix) with ESMTPSA id 2506A43CA5 for ; Wed, 17 Jun 2015 14:01:49 +0200 (CEST) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Date: Wed, 17 Jun 2015 14:01:49 +0200 From: Mark Rotteveel To: List Subject: Re: Pre-processing during build In-Reply-To: <2e15428aa0cf241e6cd9b951ba96140b@imap.procolix.com> References: <000c01d0a7b6$97571ee0$c6055ca0$@eu> <005101d0a86a$f18ffe90$d4affbb0$@eu> <60b20bb834cf54db8232239b9c27fcc2@imap.procolix.com> <2e15428aa0cf241e6cd9b951ba96140b@imap.procolix.com> Message-ID: <5d539d76f4ccb9a59abc57d5d99c4d92@imap.procolix.com> X-Sender: mark@lawinegevaar.nl User-Agent: RoundCube Webmail/0.2 X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org On Wed, 17 Jun 2015 13:52:52 +0200, Mark Rotteveel wrote: > That is almost what PostgreSQL uses now, but this is not going to work if > you compile with Java 8 and assume that > org.postgresql.jdbc4.PreparedStatement would then also be new-able when the > same jar is used under Java 6 or 7, because > org.postgresql.jdbc4.PreparedStatement would need to be abstract at compile > time as it doesn't contain the methods required by the Java 8 (JDBC 4.2) > API during compilation. > > So getting this to work would need some form of reflection (to get the > right type at runtime based on the Java version), some preprocessing (as > done currently) to get around the compilation problem or some byte code > generation/modification to "unabstract" > org.postgresql.jdbc4.PreparedStatement after compilation, or some form of > tiered compilation (where the org.postgresql.jdbc4.PreparedStatement is > compiled with Java 7, and org.postgresql.jdbc42.PreparedStatement with Java > 8; this might be more complex than the existing solution. I just realized it might actually work: some (maybe all) methods added in the JDBC API for Java 8 were added as default interface methods (with an implementation that throws UnsupportedOperationException), so compilation would succeed for org.postgresql.jdbc4.PreparedStatement without having an implementation for the new methods. You'd still need reflection or an other trick to decide based on the Java version which classes (Statement, PreparedStatement, ResultSet, etc) to instantiate. Mark -- Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc