Re: Pre-processing during build - Mailing list pgsql-jdbc

From Markus KARG
Subject Re: Pre-processing during build
Date
Msg-id 004b01d0a86a$4e9e6eb0$ebdb4c10$@eu
Whole thread Raw
In response to Re: Pre-processing during build  (Vladimir Sitnikov <sitnikov.vladimir@gmail.com>)
Responses Re: Pre-processing during build  (Mark Rotteveel <mark@lawinegevaar.nl>)
List pgsql-jdbc
Vladimir,

you misunderstood my proposal. I do not want to have multiple versions of the same class. I want ONLY JDBC42 API
compileddown to Java 6 byte code in one single JAR. JDBC42 is backwards compatible to all older JDBC levels, and Java 7
and8 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
methodsthat 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
sucha method exist. Only Java 8 clients will know. That method is more than clearly marked as "since 1.8" so a Java 7
applicationprogrammer 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.
Haveyou really tried this out or do you have another link where it is written that the byte code verifier will CHECK
theexistence of a parameter class when it verifies the loaded class? 

Regards
Markus

-----Original Message-----
From: Vladimir Sitnikov [mailto:sitnikov.vladimir@gmail.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



pgsql-jdbc by date:

Previous
From: "Markus KARG"
Date:
Subject: Re: Pre-processing during build
Next
From: "Markus KARG"
Date:
Subject: Re: Pre-processing during build