pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
JDK 1.5 beta2 and generics
4+ messages / 2 participants
[nested] [flat]

* JDK 1.5 beta2 and generics
@ 2004-06-17 22:02  Kris Jurka <books@ejurka.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Kris Jurka @ 2004-06-17 22:02 UTC (permalink / raw)
  To: pgsql-jdbc


The recent JDK 1.5 beta2 is unable to compile the jdbc driver because it 
modifies the interfaces that currently take a java.util.Map object to take 
a specific type of Map.  This results in the existing classes not 
implementing the interfaces anymore.  Any ideas on how to fix this 
cleanly?  I don't want to see ant having to add/remove comments to all 
of these files, but nothing else occurs to me.

Below are the actual compile errors and a link to one of the new method 
signatures javadocs.

Kris Jurka

http://java.sun.com/j2se/1.5.0/docs/api/java/sql/Array.html#getArray(long,%20int,%20java.util.Map)

compile:
    [javac] Compiling 77 source files to 
/home/jurka/cvs/pg/official/74/src/interfaces/jdbc/build
    [javac] 
/home/jurka/cvs/pg/official/74/src/interfaces/jdbc/org/postgresql/jdbc2/Array.java:35: 
org.postgresql.jdbc2.Array is not abstract and does not override abstract 
method 
getResultSet(long,int,java.util.Map<java.lang.String,java.lang.Class<?>>) 
in java.sql.Array
    [javac] public class Array implements java.sql.Array
    [javac]        ^
    [javac] 
/home/jurka/cvs/pg/official/74/src/interfaces/jdbc/org/postgresql/jdbc2/optional/PGObjectFactory.java:18: 
org.postgresql.jdbc2.optional.PGObjectFactory is not abstract and does not 
override abstract method 
getObjectInstance(java.lang.Object,javax.naming.Name,javax.naming.Context,java.util.Hashtable<java.lang.String,?>) 
in javax.naming.spi.ObjectFactory
    [javac] public class PGObjectFactory implements ObjectFactory
    [javac]        ^
    [javac] 
/home/jurka/cvs/pg/official/74/src/interfaces/jdbc/org/postgresql/jdbc3/Jdbc3CallableStatement.java:10: 
org.postgresql.jdbc3.Jdbc3CallableStatement is not abstract and does not 
override abstract method 
getObject(java.lang.String,java.util.Map<java.lang.String,java.lang.Class<?>>) 
in java.sql.CallableStatement
    [javac] public class Jdbc3CallableStatement extends 
org.postgresql.jdbc3.AbstractJdbc3Statement implements 
java.sql.CallableStatement
    [javac]        ^
    [javac] 
/home/jurka/cvs/pg/official/74/src/interfaces/jdbc/org/postgresql/jdbc3/Jdbc3Connection.java:11: 
org.postgresql.jdbc3.Jdbc3Connection is not abstract and does not override 
abstract method 
setTypeMap(java.util.Map<java.lang.String,java.lang.Class<?>>) in 
java.sql.Connection
    [javac] public class Jdbc3Connection extends 
org.postgresql.jdbc3.AbstractJdbc3Connection implements 
java.sql.Connection
    [javac]        ^
    [javac] 
/home/jurka/cvs/pg/official/74/src/interfaces/jdbc/org/postgresql/jdbc3/Jdbc3ResultSet.java:14: 
org.postgresql.jdbc3.Jdbc3ResultSet is not abstract and does not override 
abstract method 
getObject(java.lang.String,java.util.Map<java.lang.String,java.lang.Class<?>>) 
in java.sql.ResultSet
    [javac] public class Jdbc3ResultSet extends 
org.postgresql.jdbc3.AbstractJdbc3ResultSet implements java.sql.ResultSet
    [javac]        ^
    [javac] Note: * uses or overrides a deprecated API.
    [javac] Note: Recompile with -Xlint:deprecation for details.
    [javac] Note: Some input files use unchecked or unsafe operations.
    [javac] Note: Recompile with -Xlint:unchecked for details.
    [javac] 5 errors




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: JDK 1.5 beta2 and generics
@ 2004-06-18 07:43  Kris Jurka <books@ejurka.com>
  parent: Kris Jurka <books@ejurka.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Kris Jurka @ 2004-06-18 07:43 UTC (permalink / raw)
  To: pgsql-jdbc



On Thu, 17 Jun 2004, Kris Jurka wrote:

> The recent JDK 1.5 beta2 is unable to compile the jdbc driver because it 
> modifies the interfaces that currently take a java.util.Map object to take 
> a specific type of Map.  This results in the existing classes not 
> implementing the interfaces anymore.  Any ideas on how to fix this 
> cleanly?  I don't want to see ant having to add/remove comments to all 
> of these files, but nothing else occurs to me.
> 

After some prompting I've investigated what the actual changes required 
are and the attached patch shows only minor changes to method signatures 
are needed, but it does touch eight files, which is in my estimation a 
lot.

Kris Jurka

Attachments:

jdk15.patch (text/plain, 9.0K) download ? build.local.properties ? built ? jdbcbuild.sh ? org/postgresql/test/jdbc2/.GetXXXTest.java.swp Index: org/postgresql/jdbc2/AbstractJdbc2Connection.java =================================================================== RCS file: /usr/local/cvsroot/pgjdbc/pgjdbc/org/postgresql/jdbc2/AbstractJdbc2Connection.java,v retrieving revision 1.9 diff -c -r1.9 AbstractJdbc2Connection.java *** org/postgresql/jdbc2/AbstractJdbc2Connection.java 11 Jun 2004 11:45:49 -0000 1.9 --- org/postgresql/jdbc2/AbstractJdbc2Connection.java 18 Jun 2004 07:29:58 -0000 *************** *** 47,53 **** } ! public void setTypeMap(java.util.Map map) throws SQLException { typemap = map; } --- 47,53 ---- } ! public void setTypeMap(java.util.Map<String,Class<?>> map) throws SQLException { typemap = map; } Index: org/postgresql/jdbc2/AbstractJdbc2ResultSet.java =================================================================== RCS file: /usr/local/cvsroot/pgjdbc/pgjdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java,v retrieving revision 1.38 diff -c -r1.38 AbstractJdbc2ResultSet.java *** org/postgresql/jdbc2/AbstractJdbc2ResultSet.java 16 Jun 2004 05:10:15 -0000 1.38 --- org/postgresql/jdbc2/AbstractJdbc2ResultSet.java 18 Jun 2004 07:29:58 -0000 *************** *** 425,431 **** } ! public Object getObject(String columnName, java.util.Map map) throws SQLException { return getObject(findColumn(columnName), map); } --- 425,431 ---- } ! public Object getObject(String columnName, java.util.Map<String,Class<?>> map) throws SQLException { return getObject(findColumn(columnName), map); } *************** *** 436,442 **** * an object based on that mapping. The class must implement the SQLData * interface. */ ! public Object getObject(int i, java.util.Map map) throws SQLException { throw org.postgresql.Driver.notImplemented(); } --- 436,442 ---- * an object based on that mapping. The class must implement the SQLData * interface. */ ! public Object getObject(int i, java.util.Map<String,Class<?>> map) throws SQLException { throw org.postgresql.Driver.notImplemented(); } Index: org/postgresql/jdbc2/AbstractJdbc2Statement.java =================================================================== RCS file: /usr/local/cvsroot/pgjdbc/pgjdbc/org/postgresql/jdbc2/AbstractJdbc2Statement.java,v retrieving revision 1.23 diff -c -r1.23 AbstractJdbc2Statement.java *** org/postgresql/jdbc2/AbstractJdbc2Statement.java 8 Jun 2004 00:01:48 -0000 1.23 --- org/postgresql/jdbc2/AbstractJdbc2Statement.java 18 Jun 2004 07:29:58 -0000 *************** *** 447,453 **** throw Driver.notImplemented(); } ! public Object getObject(int i, java.util.Map map) throws SQLException { throw Driver.notImplemented(); } --- 447,453 ---- throw Driver.notImplemented(); } ! public Object getObject(int i, java.util.Map<String,Class<?>> map) throws SQLException { throw Driver.notImplemented(); } Index: org/postgresql/jdbc2/Array.java =================================================================== RCS file: /usr/local/cvsroot/pgjdbc/pgjdbc/org/postgresql/jdbc2/Array.java,v retrieving revision 1.24 diff -c -r1.24 Array.java *** org/postgresql/jdbc2/Array.java 13 Jan 2004 03:07:09 -0000 1.24 --- org/postgresql/jdbc2/Array.java 18 Jun 2004 07:29:58 -0000 *************** *** 68,79 **** return getArray( index, count, null ); } ! public Object getArray(Map map) throws SQLException { return getArray( 1, 0, map ); } ! public Object getArray(long index, int count, Map map) throws SQLException { if ( map != null ) // For now maps aren't supported. throw org.postgresql.Driver.notImplemented(); --- 68,79 ---- return getArray( index, count, null ); } ! public Object getArray(Map<String,Class<?>> map) throws SQLException { return getArray( 1, 0, map ); } ! public Object getArray(long index, int count, Map<String,Class<?>> map) throws SQLException { if ( map != null ) // For now maps aren't supported. throw org.postgresql.Driver.notImplemented(); *************** *** 218,229 **** return getResultSet( index, count, null ); } ! public java.sql.ResultSet getResultSet(Map map) throws SQLException { return getResultSet( 1, 0, map ); } ! public java.sql.ResultSet getResultSet(long index, int count, java.util.Map map) throws SQLException { Object array = getArray( index, count, map ); Vector rows = new Vector(); --- 218,229 ---- return getResultSet( index, count, null ); } ! public java.sql.ResultSet getResultSet(Map<String,Class<?>> map) throws SQLException { return getResultSet( 1, 0, map ); } ! public java.sql.ResultSet getResultSet(long index, int count, java.util.Map<String,Class<?>> map) throws SQLException { Object array = getArray( index, count, map ); Vector rows = new Vector(); Index: org/postgresql/jdbc2/optional/PGObjectFactory.java =================================================================== RCS file: /usr/local/cvsroot/pgjdbc/pgjdbc/org/postgresql/jdbc2/optional/PGObjectFactory.java,v retrieving revision 1.4 diff -c -r1.4 PGObjectFactory.java *** org/postgresql/jdbc2/optional/PGObjectFactory.java 8 Jun 2004 00:01:48 -0000 1.4 --- org/postgresql/jdbc2/optional/PGObjectFactory.java 18 Jun 2004 07:29:58 -0000 *************** *** 22,28 **** * ignored. */ public Object getObjectInstance(Object obj, Name name, Context nameCtx, ! Hashtable environment) throws Exception { Reference ref = (Reference)obj; if (ref.getClassName().equals(SimpleDataSource.class.getName())) --- 22,28 ---- * ignored. */ public Object getObjectInstance(Object obj, Name name, Context nameCtx, ! Hashtable<String,?> environment) throws Exception { Reference ref = (Reference)obj; if (ref.getClassName().equals(SimpleDataSource.class.getName())) Index: org/postgresql/jdbc3/AbstractJdbc3Statement.java =================================================================== RCS file: /usr/local/cvsroot/pgjdbc/pgjdbc/org/postgresql/jdbc3/AbstractJdbc3Statement.java,v retrieving revision 1.5 diff -c -r1.5 AbstractJdbc3Statement.java *** org/postgresql/jdbc3/AbstractJdbc3Statement.java 8 Jun 2004 00:01:48 -0000 1.5 --- org/postgresql/jdbc3/AbstractJdbc3Statement.java 18 Jun 2004 07:29:58 -0000 *************** *** 1198,1204 **** * @see #setObject * @since 1.4 */ ! public Object getObject (String parameterName, java.util.Map map) throws SQLException { throw org.postgresql.Driver.notImplemented(); } --- 1198,1204 ---- * @see #setObject * @since 1.4 */ ! public Object getObject (String parameterName, java.util.Map<String,Class<?>> map) throws SQLException { throw org.postgresql.Driver.notImplemented(); } Index: org/postgresql/jdbc3/Jdbc3ObjectFactory.java =================================================================== RCS file: /usr/local/cvsroot/pgjdbc/pgjdbc/org/postgresql/jdbc3/Jdbc3ObjectFactory.java,v retrieving revision 1.1 diff -c -r1.1 Jdbc3ObjectFactory.java *** org/postgresql/jdbc3/Jdbc3ObjectFactory.java 25 Sep 2002 07:01:30 -0000 1.1 --- org/postgresql/jdbc3/Jdbc3ObjectFactory.java 18 Jun 2004 07:29:58 -0000 *************** *** 18,24 **** * ignored. */ public Object getObjectInstance(Object obj, Name name, Context nameCtx, ! Hashtable environment) throws Exception { Reference ref = (Reference) obj; if (ref.getClassName().equals(Jdbc3SimpleDataSource.class.getName())) --- 18,24 ---- * ignored. */ public Object getObjectInstance(Object obj, Name name, Context nameCtx, ! Hashtable<String,?> environment) throws Exception { Reference ref = (Reference) obj; if (ref.getClassName().equals(Jdbc3SimpleDataSource.class.getName())) Index: org/postgresql/test/util/MiniJndiContextFactory.java =================================================================== RCS file: /usr/local/cvsroot/pgjdbc/pgjdbc/org/postgresql/test/util/MiniJndiContextFactory.java,v retrieving revision 1.1 diff -c -r1.1 MiniJndiContextFactory.java *** org/postgresql/test/util/MiniJndiContextFactory.java 25 Sep 2002 07:01:31 -0000 1.1 --- org/postgresql/test/util/MiniJndiContextFactory.java 18 Jun 2004 07:29:58 -0000 *************** *** 14,20 **** */ public class MiniJndiContextFactory implements InitialContextFactory { ! public Context getInitialContext(Hashtable environment) throws NamingException { return new MiniJndiContext(); --- 14,20 ---- */ public class MiniJndiContextFactory implements InitialContextFactory { ! public Context getInitialContext(Hashtable<String,?> environment) throws NamingException { return new MiniJndiContext();
^ permalink raw reply [nested|flat] 4+ messages in thread

* Re: JDK 1.5 beta2 and generics
@ 2004-06-18 11:51  Dave Cramer <pg@fastcrypt.com>
  parent: Kris Jurka <books@ejurka.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Dave Cramer @ 2004-06-18 11:51 UTC (permalink / raw)
  To: Kris Jurka <books@ejurka.com>; +Cc: pgsql-jdbc

Kris,

How does the 1.3, 1.4 driver handle this ?

Dave
On Fri, 2004-06-18 at 03:43, Kris Jurka wrote:
> On Thu, 17 Jun 2004, Kris Jurka wrote:
> 
> > The recent JDK 1.5 beta2 is unable to compile the jdbc driver because it 
> > modifies the interfaces that currently take a java.util.Map object to take 
> > a specific type of Map.  This results in the existing classes not 
> > implementing the interfaces anymore.  Any ideas on how to fix this 
> > cleanly?  I don't want to see ant having to add/remove comments to all 
> > of these files, but nothing else occurs to me.
> > 
> 
> After some prompting I've investigated what the actual changes required 
> are and the attached patch shows only minor changes to method signatures 
> are needed, but it does touch eight files, which is in my estimation a 
> lot.
> 
> Kris Jurka
> 
> !DSPAM:40d2a08b226721437050288!
> 
> ______________________________________________________________________
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
> 
>                http://archives.postgresql.org
> 
> 
> !DSPAM:40d2a08b226721437050288!
-- 
Dave Cramer
519 939 0336
ICQ # 14675561




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: JDK 1.5 beta2 and generics
@ 2004-06-18 16:30  Kris Jurka <books@ejurka.com>
  parent: Dave Cramer <pg@fastcrypt.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Kris Jurka @ 2004-06-18 16:30 UTC (permalink / raw)
  To: Dave Cramer <pg@fastcrypt.com>; +Cc: pgsql-jdbc



On Fri, 18 Jun 2004, Dave Cramer wrote:

> Kris,
> 
> How does the 1.3, 1.4 driver handle this ?

In the past they haven't touched the API without a new JDBC version.  Our 
model handles this cleanly with a separate directory/implementation for 
the new part of the API.  The problem here is that they have changed the 
method signature's specified in an interface without changing the API 
version.

Note that this is only a problem for implementors, not callers.  
The weak generic type checking allows for instance a method like
func(Hashtable<String,String>) to be called with func(new Hashtable()).  
It doesn't require the caller to alter their passed data type only the 
implementor to match the stricter method signature.

Kris Jurka



^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2004-06-18 16:30 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-06-17 22:02 JDK 1.5 beta2 and generics Kris Jurka <books@ejurka.com>
2004-06-18 07:43 ` Kris Jurka <books@ejurka.com>
2004-06-18 11:51   ` Dave Cramer <pg@fastcrypt.com>
2004-06-18 16:30     ` Kris Jurka <books@ejurka.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox