Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Z5KHA-00029X-5a for pgsql-jdbc@arkaria.postgresql.org; Wed, 17 Jun 2015 20:49:36 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Z5KH9-0007rR-MF for pgsql-jdbc@arkaria.postgresql.org; Wed, 17 Jun 2015 20:49:35 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Z5KH8-0007rL-PY for pgsql-jdbc@postgresql.org; Wed, 17 Jun 2015 20:49:35 +0000 Received: from smtprelay06.ispgateway.de ([80.67.31.101]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1Z5KH4-0000QM-IV for pgsql-jdbc@postgresql.org; Wed, 17 Jun 2015 20:49:33 +0000 Received: from [88.66.14.101] (helo=Zauselmaus) by smtprelay06.ispgateway.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.84) (envelope-from ) id 1Z5KH1-0003D1-37 for pgsql-jdbc@postgresql.org; Wed, 17 Jun 2015 22:49:27 +0200 From: "Markus KARG" To: "'List'" References: <000c01d0a7b6$97571ee0$c6055ca0$@eu> <005101d0a86a$f18ffe90$d4affbb0$@eu> <60b20bb834cf54db8232239b9c27fcc2@imap.procolix.com> In-Reply-To: Subject: Re: Pre-processing during build Date: Wed, 17 Jun 2015 22:49:35 +0200 Organization: Markus KARG, Staatl. gepr. Inf. Message-ID: <004f01d0a93f$1e9a3200$5bce9600$@eu> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0050_01D0A94F.E2230200" X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: AdCo7aHbkpf3qBGXR9+nFiyC7oD/vwAUWl5g Content-Language: de X-AVK-Virus-Check: AVA 25.1869;71FD75 X-AVK-Spam-Check: 1; str=0001.0A0C0201.5581DD57.018F,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 This is a multi-part message in MIME format. ------=_NextPart_000_0050_01D0A94F.E2230200 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Can you proof your assumptions using the corrected example: = https://gist.github.com/mkarg/88a89ae0dbffcfb7543e ? =20 From: pgsql-jdbc-owner@postgresql.org = [mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Sehrope Sarkuni Sent: Mittwoch, 17. Juni 2015 13:05 To: Dave Cramer Cc: Mark Rotteveel; List Subject: Re: [JDBC] Pre-processing during build =20 On Wed, Jun 17, 2015 at 6:15 AM, Dave Cramer wrote: I'm not sure this is a great example as Optional itself is a java 8 = construct. =20 Either way Spring is able to do this, as are others? =20 The approach used by Spring won't work for the JDBC driver. The crux of = the issue is that the newest version of the JDBC spec include Java 8 = types in method signatures of public interfaces that exist in Java . = Spring doesn't do that. =20 The public interfaces and classes for the older JDK versions they = support (i.e. 6 or 7) only expose types that exist in those JDK = versions. For older classes they've added internal support for Java 8 = types that is dynamically checked, but it's done by wrapping the = integration in an inner class. Here's an example: = https://github.com/spring-projects/spring-framework/blob/f41de12cf62aebf1= be9b30be590c12eb2c030853/spring-beans/src/main/java/org/springframework/b= eans/AbstractNestablePropertyAccessor.java#L1041 =20 There's no way to make that work when a public interface exposes classes = that won't exist on the run time. It may have been possible with older = upgrades to the JDBC spec (ex: 4 to 4.1) as there weren't any JDK = 1.7-only classes used in methods signatures of existing public = interfaces. Compiling with an older bytecode target would allow and = older JDK to simply ignore those methods as they would not be part of = the public signature. =20 In JDBC 4.2 that's not true though. For example the JDBC 4.2 = PreparedStatement class has a new setObject(...) that uses a Java 8 only = class: =20 PreparedStatment.setObject(int parameterIndex, Object x, SQLType = targetSqlType): = https://docs.oracle.com/javase/8/docs/api/java/sql/PreparedStatement.html= #setObject-int-java.lang.Object-java.sql.SQLType- =20 SQLType (Java 8 only): = https://docs.oracle.com/javase/8/docs/api/java/sql/SQLType.html =20 That method signature can't appear in a driver that is going to be used = in JDK 6 or 7. There's no way to hide it internally as it's part of the = public signature. =20 We're going to need some kind of preprocessing step to handle things = like this. =20 Regards, -- Sehrope Sarkuni Founder & CEO | JackDB, Inc. | https://www.jackdb.com/ =20 ------=_NextPart_000_0050_01D0A94F.E2230200 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Can you proof your assumptions using the corrected example: https://gist.= github.com/mkarg/88a89ae0dbffcfb7543e ?

 

From:= = pgsql-jdbc-owner@postgresql.org [mailto:pgsql-jdbc-owner@postgresql.org] = On Behalf Of Sehrope Sarkuni
Sent: Mittwoch, 17. Juni = 2015 13:05
To: Dave Cramer
Cc: Mark Rotteveel; = List
Subject: Re: [JDBC] Pre-processing during = build

 

On Wed, Jun 17, 2015 at 6:15 AM, Dave Cramer <pg@fastcrypt.com> = wrote:

I'm not sure this is a great example as Optional = itself is a java 8 construct.

 

Either way Spring is able to do this, as are = others?

 

The approach used by Spring won't work for the JDBC = driver. The crux of the issue is that the newest version of the JDBC = spec include Java 8 types in method signatures of public interfaces that = exist in Java . Spring doesn't do that.

 

The public interfaces and classes for the older JDK = versions they support (i.e. 6 or 7) only expose types that exist in = those JDK versions. For older classes they've added internal support for = Java 8 types that is dynamically checked, but it's done by wrapping the = integration in an inner class. Here's an example: https://github.com/spring-projects/spring-framework/blo= b/f41de12cf62aebf1be9b30be590c12eb2c030853/spring-beans/src/main/java/org= /springframework/beans/AbstractNestablePropertyAccessor.java#L1041

 

There's no way to make that work when a public = interface exposes classes that won't exist on the run time. It may have = been possible with older upgrades to the JDBC spec (ex: 4 to 4.1) as = there weren't any JDK 1.7-only classes used in methods signatures of = existing public interfaces. Compiling with an older bytecode target = would allow and older JDK to simply ignore those methods as they would = not be part of the public signature.

 

In JDBC 4.2 that's not true though. For example the = JDBC 4.2 PreparedStatement class has a new setObject(...) that uses a = Java 8 only class:

 

PreparedStatment.setObject(int parameterIndex, Object = x, SQLType targetSqlType): https://docs.oracle.com/javase/8/docs/api/java/sql/Prep= aredStatement.html#setObject-int-java.lang.Object-java.sql.SQLType-

 

 

That method signature can't appear in a driver that is = going to be used in JDK 6 or 7. There's no way to hide it internally as = it's part of the public signature.

 

We're going to need some kind of preprocessing step to = handle things like this.

 

Regards,

=

-- Sehrope = Sarkuni

Founder & CEO | JackDB, = Inc. | https://www.jackdb.com/

=

 

------=_NextPart_000_0050_01D0A94F.E2230200--