Re: Pre-processing during build

From: "Markus KARG" <markus(at)headcrashing(dot)eu>
To: "'List'" <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Pre-processing during build
Date: 2015-06-16 19:26:12
Message-ID: 004b01d0a86a$4e9e6eb0$ebdb4c10$@eu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Vladimir,

you misunderstood my proposal. I do not want to have multiple versions of the same class. I want ONLY JDBC42 API compiled down to Java 6 byte code in one single JAR. JDBC42 is backwards compatible to all older JDBC levels, and Java 7 and 8 can load Java 6 byte code.

Also the idea is NOT to allow Java 6 and 7 clients to INVOKE JDBC42 but just to load the JAR and invoke e. g. JDBC4 methods that are part of JDBC42 still (again, it's backwards compatible).

Regarding your example: A Java 7 client will never try to call that methods as Java 7 clients do not even know that such a method exist. Only Java 8 clients will know. That method is more than clearly marked as "since 1.8" so a Java 7 application programmer does not even KNOW about it pure existence!

So it boils down to verification and I doubt that the bytecode verifier will try to actually load java.sql.Type class. Have you really tried this out or do you have another link where it is written that the byte code verifier will CHECK the existence of a parameter class when it verifies the loaded class?

Regards
Markus

-----Original Message-----
From: Vladimir Sitnikov [mailto:sitnikov(dot)vladimir(at)gmail(dot)com]
Sent: Dienstag, 16. Juni 2015 00:48
To: Dave Cramer
Cc: Markus KARG; List
Subject: Re: [JDBC] Pre-processing during build

Marcus,

>Has anybody tried whether it is possible to simply load a JRE8-JDBC42.jar on JRE6?

As you are a fan of JEPs, you might know of
http://openjdk.java.net/jeps/238 : Multi-Version JAR Files
It does not "just work" yet.

Suppose you want implement PreparedStatement(...java.sql.SQLType)
features of JDBC 4.2 (see [1]).
Even if you compile that with target 1.7, JRE 7 might fail to load the
class as it won't be able to validate what that SQLType is. It just
does not exist in JRE7.

As far as I understand, the only manageable way of using "new
features" in "JDK6-7 jars" is to isolate JDK8-using methods to
JDK8-only-loaded classes. For instance, PreparedStatement41.java and
PreparedStatement42.java

[1]: https://docs.oracle.com/javase/8/docs/api/java/sql/PreparedStatement.html#setObject-int-java.lang.Object-java.sql.SQLType-

Vladimir

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Markus KARG 2015-06-16 19:30:46 Re: Pre-processing during build
Previous Message Markus KARG 2015-06-16 19:18:17 Re: Pre-processing during build