Re: Pre-processing during build

From: Sehrope Sarkuni <sehrope(at)jackdb(dot)com>
To: Dave Cramer <pg(at)fastcrypt(dot)com>
Cc: Mark Rotteveel <mark(at)lawinegevaar(dot)nl>, List <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Pre-processing during build
Date: 2015-06-17 11:05:29
Message-ID: CAH7T-appNMfqUL+ZnYW=q6Nj9JT3jbkPkMBwK6yT3nKdWrSTAQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

On Wed, Jun 17, 2015 at 6:15 AM, Dave Cramer <pg(at)fastcrypt(dot)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/blob/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/PreparedStatement.html#setObject-int-java.lang.Object-java.sql.SQLType-

SQLType (Java 8 only):
https://docs.oracle.com/javase/8/docs/api/java/sql/SQLType.html

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/

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Mark Rotteveel 2015-06-17 11:12:32 Re: Pre-processing during build
Previous Message Dave Cramer 2015-06-17 10:15:47 Re: Pre-processing during build