You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by Kathey Marsden <km...@sbcglobal.net> on 2007/10/09 21:37:12 UTC
Should BrokeredStatement.isClosed() be public?
BrokeredStatement implements an isClosed() method with protected access.
That method is overridden with a public isClosed() in
BrokeredStatement40. Testing with a new 1.6 jdk this leads to a
IllegalAccessError when stmt.isClosed() is accessed. Should
BrokeredStatement.isClosed() be public? This patch seems to make the
error go away. If noone objects, I'll run tests and commit.
Thanks
Kathey
+++ java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement.java
(working copy)
@@ -566,7 +566,7 @@
* <code>false</code> otherwise
* @exception SQLException not-implemented exception
*/
- protected boolean isClosed() throws SQLException {
+ public boolean isClosed() throws SQLException {
// Not implemented since we cannot forward the call to a JDBC
// 4.0 method from this class. This dummy implementation is
// provided here so that checkIfClosed() can be implemented
Re: Should BrokeredStatement.isClosed() be public?
Posted by Kathey Marsden <km...@sbcglobal.net>.
Knut Anders Hatlen wrote:
> Kathey Marsden <km...@sbcglobal.net> writes:
>
> I am not sure why the jvm is accessing the parent class's method
> during runtime, is that a JVM bug that it does?
>
>
> I think so. FWIW, I don't see the error when I run your test program in
> my environment (OpenSolaris, Sun Java 1.6.0_02).
>
>
Thanks Knut. I filed a bug against the jvm where I am seeing the error.
We'll see what they say.
Kathey
Re: Should BrokeredStatement.isClosed() be public?
Posted by Knut Anders Hatlen <Kn...@Sun.COM>.
Kathey Marsden <km...@sbcglobal.net> writes:
> Without access change output:
> The following program gives:
> Exception in thread "main" java.lang.IllegalAccessError
> at
> AbstractAccessError.main(AbstractAccessError.java:13)
>
> With access change output:
> [C:/kmarsden/repro/brokclosed] java AbstractAccessError
> stmt.isClosed():false
>
> I am not sure why the jvm is accessing the parent class's method
> during runtime, is that a JVM bug that it does?
I think so. FWIW, I don't see the error when I run your test program in
my environment (OpenSolaris, Sun Java 1.6.0_02).
--
Knut Anders
Re: Should BrokeredStatement.isClosed() be public?
Posted by Kathey Marsden <km...@sbcglobal.net>.
Daniel John Debrunner wrote:
>
> Before changing the access, it should be determined why that method is
> being called directly from user code in JDK6.
>
> In a JDK 6 environment I assume that the code should be using a
> BrokeredStatement40. If user code is calling the
> BrokeredStatement.isClosed() method then that indicates that instead a
> BrokeredStatement object is being used, that would be a bug.
>
Below is the user code that invokes the exception. Once I make the
change that BrokeredStatement.isClosed() is public then the program runs
normally and calls
BrokeredStatement40.isClosed()
import org.apache.derby.jdbc.EmbeddedXADataSource40;
import java.sql.*;
import javax.sql.*;
public class AbstractAccessError {
public static void main(String[] args) throws Exception {
EmbeddedXADataSource40 ds = new EmbeddedXADataSource40();
ds.setDatabaseName("wombat");
ds.setCreateDatabase("create");
XAConnection xaConn = ds.getXAConnection();
Connection conn = xaConn.getConnection();
Statement stmt = conn.createStatement();
System.out.println("stmt.isClosed():" + stmt.isClosed());
}
}
Without access change output:
The following program gives:
Exception in thread "main" java.lang.IllegalAccessError
at
AbstractAccessError.main(AbstractAccessError.java:13)
With access change output:
[C:/kmarsden/repro/brokclosed] java AbstractAccessError
stmt.isClosed():false
I am not sure why the jvm is accessing the parent class's method during
runtime, is that a JVM bug that it does?
Kathey
Re: Should BrokeredStatement.isClosed() be public?
Posted by Daniel John Debrunner <dj...@apache.org>.
Kathey Marsden wrote:
> BrokeredStatement implements an isClosed() method with protected access.
> That method is overridden with a public isClosed() in
> BrokeredStatement40. Testing with a new 1.6 jdk this leads to a
> IllegalAccessError when stmt.isClosed() is accessed. Should
> BrokeredStatement.isClosed() be public? This patch seems to make the
> error go away. If noone objects, I'll run tests and commit.
I object!
Before changing the access, it should be determined why that method is
being called directly from user code in JDK6.
In a JDK 6 environment I assume that the code should be using a
BrokeredStatement40. If user code is calling the
BrokeredStatement.isClosed() method then that indicates that instead a
BrokeredStatement object is being used, that would be a bug.
Dan.