Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Z5KQV-0002VD-SR for pgsql-jdbc@arkaria.postgresql.org; Wed, 17 Jun 2015 20:59:15 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Z5KQV-0002oj-6c for pgsql-jdbc@arkaria.postgresql.org; Wed, 17 Jun 2015 20:59:15 +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 1Z5KQU-0002oc-9q for pgsql-jdbc@postgresql.org; Wed, 17 Jun 2015 20:59:14 +0000 Received: from smtprelay04.ispgateway.de ([80.67.31.27]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1Z5KQR-00023u-F8 for pgsql-jdbc@postgresql.org; Wed, 17 Jun 2015 20:59:13 +0000 Received: from [88.66.14.101] (helo=Zauselmaus) by smtprelay04.ispgateway.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.84) (envelope-from ) id 1Z5KQQ-0000JP-G2 for pgsql-jdbc@postgresql.org; Wed, 17 Jun 2015 22:59:10 +0200 From: "Markus KARG" To: "'List'" References: <000c01d0a7b6$97571ee0$c6055ca0$@eu> <005101d0a86a$f18ffe90$d4affbb0$@eu> <60b20bb834cf54db8232239b9c27fcc2@imap.procolix.com> <2e15428aa0cf241e6cd9b951ba96140b@imap.procolix.com> <5d539d76f4ccb9a59abc57d5d99c4d92@imap.procolix.com> In-Reply-To: <5d539d76f4ccb9a59abc57d5d99c4d92@imap.procolix.com> Subject: Re: Pre-processing during build Date: Wed, 17 Jun 2015 22:59:18 +0200 Organization: Markus KARG, Staatl. gepr. Inf. Message-ID: <006601d0a940$7a418620$6ec49260$@eu> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: AdCo9X61fgyegPZnRgC3Nq28fd/unwASl34A Content-Language: de X-AVK-Virus-Check: AVA 25.1869;71FD75 X-AVK-Spam-Check: 1; str=0001.0A0C0202.5581DF9E.00C2,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0; F1206 X-Df-Sender: bWFya3VzQGhlYWRjcmFzaGluZy5ldQ== X-Pg-Spam-Score: -2.6 (--) 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. >=20 > 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. Yay, seems you finally noticed we guys at the Java EE EGs are not so dumb a= s people might think! Honestly, what do you think what we actually invented= default methods for if not for this case...? ;-) >You'd still need reflection or an other trick to decide based on the Java version which classes (Statement, PreparedStatement, ResultSet, etc) to instantiate. Only in case of one single driver name and not wanting to provide a propert= y telling the JDBC version. Also not in case of separate driver names like = "Jdbc3Driver". In fact I do not see any difference in providing a list of s= eparate downloads compared to a list of separate driver names. --=20 Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc