Search Postgresql Archives

Re: Pl/java in 8.4 bet1 sources compilation failed

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Craig Ringer wrote:

Perhaps a stupid question, but isn't the `-source' parameter to javac
intended to mask new features and such for just the purpose of compiling
older sources on a new JDK?


The -source argument only controls language features, not interface/class definitions. java.sql.* provides interfaces that drivers must implement. When they add new functions to those interfaces you have to implement those, otherwise the compile fails saying that the class doesn't implement the specified interface. Sometimes you can implement new interface functions so that the code can compile in either version, but not always. Consider the following two cases:

1) JDBC4 has added a new method to java.sql.Array named "void free()". This can be implemented for JDBC3 and there's no problem that the JDBC3 class implements an additional method that's only required by JDBC4. The code can be compiled against either JDK version.

2) JDBC4 has added a new interface, java.sql.SQLXML, and added methods to java.sql.ResultSet to retrieve SQLXML objects. You can't add a method "SQLXML getSQLXML(int)" to your JDBC3 class because it doesn't know anything about SQLXML at all because it isn't defined by JDBC3. For this we must add code that is only compiled if we're building with a JDK that has JDBC4.

The JDBC driver does this by defining a hierarchy:

AbstractJdbc2ResultSet
|__Jdbc2ResultSet
|__AbstractJdbc3ResultSet
   |__Jdbc3ResultSet
   |__AbstractJdbc4ResultSet
      |__Jdbc4ResultSet

AbstractJdbc4ResultSet will have the getSQLXML method and the JdbcXResultSet classes will be just stubs that officially implement the java.sql.ResultSet interface.

If we're building a JDBC3 driver we'll compile AbstractJdbc2ResultSet, AbstractJdbc3ResultSet, and Jdbc3ResultSet and when asked for a ResultSet instance we'll return a Jdbc3ResultSet. When building a JDBC4 driver we'll then exclude Jdbc3ResultSet and compile AbstractJdbc4ResultSet and Jdbc4ResultSet and when asked for ResultSet instance we'll return a Jdbc4ResultSet.

By using this inheritance we can conditionally compile entire classes which is easy to do with ant rather than trying to implement something like #ifdef which is ugly to do with ant's copy with filtering task.

Unfortunately pljava currently has no such infrastructure.

Kris Jurka


--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux