summaryrefslogtreecommitdiff
path: root/core/java/android/database/sqlite
diff options
context:
space:
mode:
authorVasu Nori <vnori@google.com>2010-03-01 14:47:47 -0800
committerVasu Nori <vnori@google.com>2010-03-02 11:50:39 -0800
commit14b60e747cdf16b79bb755b42dd766348c4f1880 (patch)
treea9806c7d07ac081cc2a623f983b2f421d582193b /core/java/android/database/sqlite
parentd2b41b6e7d23c4d2cb2b0fb58f2bbef94c95b5d1 (diff)
add warning in finalizer. deprecate protected members.
finalizer shoudl not be called ever. add a warning to say that. adeprecate a few members in SQLiteProgram.java. they should not have had protected access level. shoudl be package.
Diffstat (limited to 'core/java/android/database/sqlite')
-rw-r--r--core/java/android/database/sqlite/SQLiteCompiledSql.java19
-rw-r--r--core/java/android/database/sqlite/SQLiteProgram.java9
2 files changed, 25 insertions, 3 deletions
diff --git a/core/java/android/database/sqlite/SQLiteCompiledSql.java b/core/java/android/database/sqlite/SQLiteCompiledSql.java
index a7a1d9ae6d25..486ad20dcb7f 100644
--- a/core/java/android/database/sqlite/SQLiteCompiledSql.java
+++ b/core/java/android/database/sqlite/SQLiteCompiledSql.java
@@ -28,6 +28,8 @@ import android.util.Log;
*/
/* package */ class SQLiteCompiledSql {
+ private static final String TAG = "SQLiteCompiledSql";
+
/** The database this program is compiled against. */
/* package */ SQLiteDatabase mDatabase;
@@ -44,11 +46,17 @@ import android.util.Log;
*/
/* package */ int nStatement = 0;
+ /** the following are for debugging purposes */
+ private String mSqlStmt = null;
+ private Throwable mStackTrace = null;
+
/** when in cache and is in use, this member is set */
private boolean mInUse = false;
/* package */ SQLiteCompiledSql(SQLiteDatabase db, String sql) {
mDatabase = db;
+ mSqlStmt = sql;
+ mStackTrace = new Exception().fillInStackTrace();
this.nHandle = db.mNativeHandle;
compile(sql, true);
}
@@ -115,8 +123,15 @@ import android.util.Log;
* Make sure that the native resource is cleaned up.
*/
@Override
- protected void finalize() {
- releaseSqlStatement();
+ protected void finalize() throws Throwable {
+ try {
+ if (nStatement == 0) return;
+ // finalizer should NEVER get called
+ Log.w(TAG, "finalizer should never be called. sql: " + mSqlStmt, mStackTrace);
+ releaseSqlStatement();
+ } finally {
+ super.finalize();
+ }
}
/**
diff --git a/core/java/android/database/sqlite/SQLiteProgram.java b/core/java/android/database/sqlite/SQLiteProgram.java
index 63acab767d71..389e15e6935a 100644
--- a/core/java/android/database/sqlite/SQLiteProgram.java
+++ b/core/java/android/database/sqlite/SQLiteProgram.java
@@ -21,7 +21,10 @@ package android.database.sqlite;
*/
public abstract class SQLiteProgram extends SQLiteClosable {
- /** The database this program is compiled against. */
+ /** The database this program is compiled against.
+ * @deprecated do not use this
+ */
+ @Deprecated
protected SQLiteDatabase mDatabase;
/** The SQL used to create this query */
@@ -30,7 +33,9 @@ public abstract class SQLiteProgram extends SQLiteClosable {
/**
* Native linkage, do not modify. This comes from the database and should not be modified
* in here or in the native code.
+ * @deprecated do not use this
*/
+ @Deprecated
protected int nHandle = 0;
/**
@@ -41,7 +46,9 @@ public abstract class SQLiteProgram extends SQLiteClosable {
/**
* SQLiteCompiledSql statement id is populated with the corresponding object from the above
* member. This member is used by the native_bind_* methods
+ * @deprecated do not use this
*/
+ @Deprecated
protected int nStatement = 0;
/* package */ SQLiteProgram(SQLiteDatabase db, String sql) {