Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 14b60e74 authored by Vasu Nori's avatar Vasu Nori
Browse files

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.
parent d2b41b6e
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -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>
+17 −2
Original line number Diff line number Diff line
@@ -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() {
    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();
        }
    }

    /**
+8 −1
Original line number Diff line number Diff line
@@ -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) {