Thread: BUG #7577: JDBC Driver - Compiled with Java 7
The following bug has been logged on the website: Bug reference: 7577 Logged by: Nic Willemse Email address: nicwillemse@gmail.com PostgreSQL version: 9.1.0 Operating system: Linux Description: = Hi, = I downloaded the JDBC driver located at http://jdbc.postgresql.org/index.html I specifically requested the JDBC3 version as Im running Java version 6. I found that it was compiled using Java 7. I believe that this should be fixed as JDBC3 is supported by java 5 & 6 and it would make more sense to have it compiled to this version. Regards, Nic
To add to this, it's not just a question of making more sense. Compiling the code with Java 7 means the generated class files are version 51, which is not acceptable to a Java 5 JRE - it wants version 49. So the existing pre-built jar cannot simply be dropped into a Java 5 app. To get around this I'm trying to build from source without much more success. When I follow the recommendation of using a 1.5 JDK, for some reason ant still craps out with an UnsupportedClassVersionError. I also tried to hack the build.xml to force compilation with source="1.5" and target="1.5", but then the compilation fails like this: compile: [javac] /opt/sean/software/postgresql-jdbc-9.0-802.src/build.xml:120: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds [javac] Compiling 176 source files to /opt/sean/software/postgresql-jdbc-9.0-802.src/build [javac] warning: [options] bootstrap class path not set in conjunction with -source 1.5 [javac] /opt/sean/software/postgresql-jdbc-9.0-802.src/org/postgresql/Driver.java:47: error: org.postgresql.Driver is not abstract and does not override abstract method getParentLogger() in java.sql.Driver [javac] public class Driver implements java.sql.Driver [javac] ^ [javac] /opt/sean/software/postgresql-jdbc-9.0-802.src/org/postgresql/ds/PGConnectionPoolDataSource.java:39: error: PGConnectionPoolDataSource is not abstract and does not override abstract method getParentLogger() in CommonDataSource [javac] public class PGConnectionPoolDataSource extends BaseDataSource implements Serializable, ConnectionPoolDataSource [javac] ^ [javac] /opt/sean/software/postgresql-jdbc-9.0-802.src/org/postgresql/ds/PGPooledConnection.java:26: error: PGPooledConnection is not abstract and does not override abstract method removeStatementEventListener(StatementEventListener) in PooledConnection etc. Does anyone have a solution for people like me who must use Java 5? Thanks, Sean -- View this message in context: http://postgresql.1045698.n5.nabble.com/BUG-7577-JDBC-Driver-Compiled-with-Java-7-tp5726254p5728220.html Sent from the PostgreSQL - bugs mailing list archive at Nabble.com.
On 10/15/2012 11:10 PM, seancompusult wrote: > Does anyone have a solution for people like me who must use Java 5? I had no problems building current git head of the JDBC driver with Java SE 5, nor the REL_9_2_STABLE branch. export PATH=$HOME/java/jdk1.5.0_22/bin:$HOME/java/jdk1.5.0_22/jre/bin:$PATH; export JAVA_HOME=$HOME/java/jdk1.5.0_22/ ant clean jar -- Craig Ringer
On 12-10-16 12:08 AM, Craig Ringer wrote: > On 10/15/2012 11:10 PM, seancompusult wrote: >> Does anyone have a solution for people like me who must use Java 5? > > I had no problems building current git head of the JDBC driver with > Java SE 5, nor the REL_9_2_STABLE branch. > Ah, quite right. I was having a problem running ant, because it itself was compiled with Java 7. :-( IMO the whole approach of relying on compiling with specific Java versions is flawed, but at least I've gotten past this issue so I'm happy. Thanks for that. Sean
Attachment
On 10/16/2012 08:10 PM, Sean Hogan wrote: > On 12-10-16 12:08 AM, Craig Ringer wrote: >> On 10/15/2012 11:10 PM, seancompusult wrote: >>> Does anyone have a solution for people like me who must use Java 5? >> >> I had no problems building current git head of the JDBC driver with >> Java SE 5, nor the REL_9_2_STABLE branch. >> > > Ah, quite right. I was having a problem running ant, because it itself > was compiled with Java 7. :-( IMO the whole approach of relying on > compiling with specific Java versions is flawed, but at least I've > gotten past this issue so I'm happy. Thanks for that. Yes, it's flawed, but it's also unfortunately necessary. javac offers flags like -source 1.5 -target 1.5 for controlling bytecode generation and source compatibility. That's fine, but it offers absolutely no way to say "treat standard library packages, classes and methods added after Java SE 5 as missing". This means that for testing at least it's required to build with a variety of JDK versions. I agree that it'd be nice to support downlevel class generation for end users. It may even be possible; I haven't dug into build.xml in detail yet. -- Craig Ringer