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.
diff --git a/api/current.xml b/api/current.xml
index d74127a..28a7168 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -55017,7 +55017,7 @@
volatile="false"
static="false"
final="false"
- deprecated="not deprecated"
+ deprecated="deprecated"
visibility="protected"
>
</field>
@@ -55027,7 +55027,7 @@
volatile="false"
static="false"
final="false"
- deprecated="not deprecated"
+ deprecated="deprecated"
visibility="protected"
>
</field>
@@ -55037,7 +55037,7 @@
volatile="false"
static="false"
final="false"
- deprecated="not deprecated"
+ deprecated="deprecated"
visibility="protected"
>
</field>
diff --git a/core/java/android/database/sqlite/SQLiteCompiledSql.java b/core/java/android/database/sqlite/SQLiteCompiledSql.java
index a7a1d9a..486ad20 100644
--- a/core/java/android/database/sqlite/SQLiteCompiledSql.java
+++ b/core/java/android/database/sqlite/SQLiteCompiledSql.java
@@ -28,6 +28,8 @@
*/
/* package */ class SQLiteCompiledSql {
+ private static final String TAG = "SQLiteCompiledSql";
+
/** The database this program is compiled against. */
/* package */ SQLiteDatabase mDatabase;
@@ -44,11 +46,17 @@
*/
/* 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 @@
* 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 63acab7..389e15e 100644
--- a/core/java/android/database/sqlite/SQLiteProgram.java
+++ b/core/java/android/database/sqlite/SQLiteProgram.java
@@ -21,7 +21,10 @@
*/
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 @@
/**
* 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 @@
/**
* 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) {