Re: Pre-processing during build
От | Mark Rotteveel |
---|---|
Тема | Re: Pre-processing during build |
Дата | |
Msg-id | d3d1281d44e89ed904b245293a85e765@imap.procolix.com обсуждение исходный текст |
Ответ на | Re: Pre-processing during build ("Markus KARG" <markus@headcrashing.eu>) |
Ответы |
Re: Pre-processing during build
|
Список | pgsql-jdbc |
On Tue, 16 Jun 2015 21:18:17 +0200, "Markus KARG" <markus@headcrashing.eu> wrote: > To make things a bit more clear: It is NOT about whether or not an > interface method has a parameter of an unknown type. It is solely about > whether that method is actually INVOKED at runtime. As a JDBC42 is unknown > to a JDBC3 client, that client CANNOT invoke that method, hence NEVER a > ClassNotFoundException can ever happen. Actually the cause of the exception > is not even the method invocation but it is solely the instantiation of the > parameter value which happens IN THE CALLER. We're pretty safe I think. So > still I do not see any need for separate JARs for the purpose of serving > multiple JDBC levels, as long as the byte code is Java 6 level. When I tried it in the past (for Jaybird) I ran into problems, it might have been an IncompatibleClassChangeError (or subclass) on classloading time, but I can't remember the exact details. I tried reading the JLS and JVM spec on this point, but I find it hard to come to a conclusion, so I will try a small experiment this weekend. However that is half of your problem. The other half is that you risk using classes, methods or maybe even features that are not available in a lower Java version and that will not be detected compile time, but only at runtime (and not just in newly added JDBC 4.2 methods). On top of that, for a compliant JDBC 4.2 implementation, you must support java.time objects in setObject, getObject, updateObject, etc. If you want to do this in a unified source, you will need to load a delegated implementation that is appropriate for the Java version, otherwise you will get ClassNotFoundException. For example in Jaybird we did this: https://github.com/FirebirdSQL/jaybird/blob/master/src/main/org/firebirdsql/jdbc/field/FBField.java#L739 Which uses (for JDBC 4.2): https://github.com/FirebirdSQL/jaybird/blob/master/src/jdbc_42/org/firebirdsql/jdbc/field/JDBC42ObjectConverter.java And for JDBC 4.1 (and 4.0 in Jaybird 2.2): https://github.com/FirebirdSQL/jaybird/blob/master/src/main/org/firebirdsql/jdbc/field/DefaultObjectConverter.java Mark
В списке pgsql-jdbc по дате отправления: