You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "J. David Beutel (JIRA)" <ji...@apache.org> on 2009/01/24 05:56:00 UTC

[jira] Issue Comment Edited: (DBCP-191) [dbcp] does not compile under the latest unreleased jdk 1.6 / JDBC 4.0

    [ https://issues.apache.org/jira/browse/DBCP-191?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12666833#action_12666833 ] 

david_beutel edited comment on DBCP-191 at 1/23/09 8:54 PM:
---------------------------------------------------------------

This Wrapper implementation in the attached patch doesn't seem to satisfy its interface javadocs:

{code}
public boolean isWrapperFor(Class<?> iface) throws SQLException {
     return _conn.isWrapperFor(iface);
}

public <T> T unwrap(Class<T> iface) throws SQLException {
    return _conn.unwrap(iface);
}
{code}

Wouldn't the following be better?

{code}
public boolean isWrapperFor(Class<?> iface) throws SQLException {
    return iface.isAssignableFrom(getClass()) || _conn.isWrapperFor(iface);
}

public <T> T unwrap(Class<T> iface) throws SQLException {
    if (iface.isAssignableFrom(getClass())) {
        return iface.cast(this);
    } else if (iface.isAssignableFrom(_conn.getClass())) {
        return iface.cast(_conn);
    } else {
        return _conn.unwrap(iface);
    }
}
{code}

(Likewise for DataSource.)  The short-circuiting is important for backwards compatibility, when used with drivers or libraries that don't compile on JDK 1.6.

      was (Author: david_beutel):
    This Wrapper implementation in the attached patch doesn't seem to satisfy its interface javadocs:

+    public boolean isWrapperFor(Class<?> iface) throws SQLException {
+        return _conn.isWrapperFor(iface);
+    }
+
+    public <T> T unwrap(Class<T> iface) throws SQLException {
+        return _conn.unwrap(iface);
+    }


Wouldn't the following be better?

    public boolean isWrapperFor(Class<?> iface) throws SQLException {
        return iface.isAssignableFrom(getClass()) || _conn.isWrapperFor(iface);
    }

    public <T> T unwrap(Class<T> iface) throws SQLException {
        if (iface.isAssignableFrom(getClass())) {
            return iface.cast(this);
        } else if (iface.isAssignableFrom(_conn.getClass())) {
            return iface.cast(_conn);
        } else {
            return _conn.unwrap(iface);
        }
    }

(Likewise for DataSource.)  The short-circuiting is important for backwards compatibility, when used with drivers or libraries that don't compile on JDK 1.6.
  
> [dbcp] does not compile under the latest unreleased jdk 1.6 / JDBC 4.0
> ----------------------------------------------------------------------
>
>                 Key: DBCP-191
>                 URL: https://issues.apache.org/jira/browse/DBCP-191
>             Project: Commons Dbcp
>          Issue Type: Improvement
>         Environment: $ java -version
> java version "1.6.0-rc"
> Java(TM) SE Runtime Environment (build 1.6.0-rc-b87)
> Java HotSpot(TM) Client VM (build 1.6.0-rc-b87, mixed mode, sharing)
> $ java -version
> java version "1.6.0-rc"
> Java(TM) SE Runtime Environment (build 1.6.0-rc-b89)
> Java HotSpot(TM) Client VM (build 1.6.0-rc-b89, mixed mode, sharing)
>            Reporter: Michael Heuer
>             Fix For: 1.3
>
>         Attachments: patch.txt
>
>
> Just a heads up, [dbcp] does not compile under the latest unreleased jdk 1.6 / JDBC 4.0, even with maven.compile.source and maven.compile.target properties set to something appropriate.
> $ maven java:compile
>  __  __
> |  \/  |__ _Apache__ ___
> | |\/| / _` \ V / -_) ' \  ~ intelligent projects ~
> |_|  |_\__,_|\_/\___|_||_|  v. 1.0.2
> java:prepare-filesystem:
>     [mkdir] Created dir: working/commons-dbcp/target/classes
> java:compile:
>     [echo] Compiling to working/commons-dbcp/target/classes
>     [echo]
> ==========================================================
>   NOTE: Targetting JVM 1.6, classes
>   will not run on earlier JVMs
> ==========================================================
>     [javac] Compiling 39 source files to working/commons-dbcp/target/classes
> working/commons-dbcp/src/java/org/apache/commons/dbcp/BasicDataSource.java:43: org.apache.commons.dbcp.BasicDataSource is not abstract and does not override abstract method <T>createQueryObject(java.lang.Class<T>,javax.sql.DataSource) in javax.sql.DataSource
> public class BasicDataSource implements DataSource {
>        ^
> working/commons-dbcp/src/java/org/apache/commons/dbcp/cpdsadapter/ConnectionImpl.java: 40: org.apache.commons.dbcp.cpdsadapter.ConnectionImpl is not abstract and does not override abstract method createStruct(java.lang.String,java.lang.Object[]) in java.sql.Connection
> class ConnectionImpl implements Connection {
> ^
> working/commons-dbcp/src/java/org/apache/commons/dbcp/cpdsadapter/PooledConnectionImpl.java:42: org.apache.commons.dbcp.cpdsadapter.PooledConnectionImpl is not abstract and does not override abstract method removeStatementEventListener(javax.sql.StatementEventListener) in javax.sql.PooledConnection
> class PooledConnectionImpl
> ^
> working/commons-dbcp/src/java/org/apache/commons/dbcp/DelegatingConnection.java:50: org.apache.commons.dbcp.DelegatingConnection is not abstract and does not override abstract method createStruct(java.lang.String,java.lang.Object[]) in java.sql.Connection
> public class DelegatingConnection extends AbandonedTrace
>        ^
> working/commons-dbcp/src/java/org/apache/commons/dbcp/cpdsadapter/DriverAdapterCPDS.java:85: org.apache.commons.dbcp.cpdsadapter.DriverAdapterCPDS is not abstract and does not override abstract method getQueryObjectGenerator() in javax.sql.CommonDataSource
> public class DriverAdapterCPDS
>        ^
> working/commons-dbcp/src/java/org/apache/commons/dbcp/DelegatingStatement.java:45: org.apache.commons.dbcp.DelegatingStatement is not abstract and does not override abstract method isPoolable() in java.sql.Statement
> public class DelegatingStatement extends AbandonedTrace implements Statement {
>        ^
> working/commons-dbcp/src/java/org/apache/commons/dbcp/DelegatingStatement.java:130: isClosed() in org.apache.commons.dbcp.DelegatingStatement cannot implement isClosed() in java.sql.Statement; attempting to assign weaker access privileges; was public
>     protected boolean isClosed() {
>                       ^
> working/commons-dbcp/src/java/org/apache/commons/dbcp/DelegatingPreparedStatement.java:49: org.apache.commons.dbcp.DelegatingPreparedStatement is not abstract and does not override abstract method setCharacterStream(int,java.io.Reader,long) in java.sql.PreparedStatement
> public class DelegatingPreparedStatement extends DelegatingStatement
>        ^
> working/commons-dbcp/src/java/org/apache/commons/dbcp/PoolablePreparedStatement.java:40: org.apache.commons.dbcp.PoolablePreparedStatement is not abstract and does not override abstract method setCharacterStream(int,java.io.Reader,long) in java.sql.PreparedStatement
> public class PoolablePreparedStatement extends DelegatingPreparedStatement implements PreparedStatement {
>        ^
> working/commons-dbcp/src/java/org/apache/commons/dbcp/cpdsadapter/PoolablePreparedStatementStub.java:33: isClosed() in org.apache.commons.dbcp.DelegatingStatement cannot implement isClosed() in java.sql.Statement; attempting to assign weaker access privileges; was public
> class PoolablePreparedStatementStub extends PoolablePreparedStatement {
> ^
> working/commons-dbcp/src/java/org/apache/commons/dbcp/datasources/PerUserPoolDataSource.java:51: org.apache.commons.dbcp.datasources.PerUserPoolDataSource is not abstract and does not override abstract method <T>createQueryObject(java.lang.Class<T>,javax.sql.DataSource) in javax.sql.DataSource
> public class PerUserPoolDataSource
>        ^
> working/commons-dbcp/src/java/org/apache/commons/dbcp/datasources/SharedPoolDataSource.java:45: org.apache.commons.dbcp.datasources.SharedPoolDataSource is not abstract and does not override abstract method
>  <T>createQueryObject(java.lang.Class<T>,javax.sql.DataSource) in javax.sql.DataSource
> public class SharedPoolDataSource
>        ^
> working/commons-dbcp/src/java/org/apache/commons/dbcp/DelegatingCallableStatement.java:52: org.apache.commons.dbcp.DelegatingCallableStatement is not abstract and does not override abstract method setCharacterStream(java.lang.String,java.io.Reader,long) in java.sql.CallableStatement
> public class DelegatingCallableStatement extends DelegatingPreparedStatement
>        ^
> working/commons-dbcp/src/java/org/apache/commons/dbcp/DelegatingResultSet.java:54: org.apache.commons.dbcp.DelegatingResultSet is not abstract and does not override abstract method updateNClob(java.lang.String,java.io.Reader,long) in java.sql.ResultSet
> public class DelegatingResultSet extends AbandonedTrace implements ResultSet {
>        ^
> working/commons-dbcp/src/java/org/apache/commons/dbcp/PoolingConnection.java:41: org.apache.commons.dbcp.PoolingConnection is not abstract and does not override abstract method createStruct(java.lang.String,java.lang.Object[]) in java.sql.Connection
> public class PoolingConnection extends DelegatingConnection implements Connection, KeyedPoolableObjectFactory {
>        ^
> working/commons-dbcp/src/java/org/apache/commons/dbcp/PoolingDataSource.java:44: org.apache.commons.dbcp.PoolingDataSource is not abstract and does not override abstract method <T>createQueryObject(java.lang.Class<T>,javax.sql.DataSource) in javax.sql.DataSource
> public class PoolingDataSource implements DataSource {
>        ^
> Note: Some input files use or override a deprecated API.
> Note: Recompile with -Xlint:deprecation for details.
> Note: Some input files use unchecked or unsafe operations.
> Note: Recompile with -Xlint:unchecked for details.
> 16 errors
> BUILD FAILED
> File...... .maven/cache/maven-java-plugin-1.5/plugin.jelly
> Element... ant:javac
> Line...... 63
> Column.... 48
> Compile failed; see the compiler error output for details.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.