小弟初学Android,想看看Android某些类的源码,下载好源码并在eclipse当中配置好之后,想查看一下一个类的源码,如:SQLiteOpenHelper这个类.按了F3之后,出现的是这样一个文件SQLiteOpenHelper.class
------------------------------------------
文件SQLiteOpenHelper.class内容如下:
------------------------------------------/*jadclipse*/// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) radix(10) lradix(10) 
// Source File Name:   SQLiteOpenHelper.javapackage android.database.sqlite;import android.content.Context;// Referenced classes of package android.database.sqlite:
//            SQLiteDatabasepublic abstract class SQLiteOpenHelper
{    public SQLiteOpenHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version)
    {
        throw new RuntimeException("Stub!");
    }    public synchronized SQLiteDatabase getWritableDatabase()
    {
        throw new RuntimeException("Stub!");
    }    public synchronized SQLiteDatabase getReadableDatabase()
    {
        throw new RuntimeException("Stub!");
    }    public synchronized void close()
    {
        throw new RuntimeException("Stub!");
    }    public abstract void onCreate(SQLiteDatabase sqlitedatabase);    public abstract void onUpgrade(SQLiteDatabase sqlitedatabase, int i, int j);    public void onOpen(SQLiteDatabase db)
    {
        throw new RuntimeException("Stub!");
    }
}
/*
DECOMPILATION REPORT Decompiled from: C:\android-sdk-windows\platforms\android-4\android.jar
Total time: 16 ms
Jad reported messages/errors:
Exit status: 0
Caught exceptions:
*/
个人理解.class文件不是字节码文件吗?那为什么网上说这里面的就是Android的类的源码了呢?看这个文件里面也没有什么东西啊。

解决方案 »

  1.   

    而我根据这个.class文件找打他对应的.java文件之后,去内容如下:
    ----------------------------------------
    文件SQLiteOpenHelper.java内容如下:
    ----------------------------------------
    /*
     * Copyright (C) 2007 The Android Open Source Project
     *
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     *      http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     */package android.database.sqlite;import android.content.Context;
    import android.database.sqlite.SQLiteDatabase.CursorFactory;
    import android.util.Log;
    public abstract class SQLiteOpenHelper {
        private static final String TAG = SQLiteOpenHelper.class.getSimpleName();    private final Context mContext;
        private final String mName;
        private final CursorFactory mFactory;
        private final int mNewVersion;    private SQLiteDatabase mDatabase = null;
        private boolean mIsInitializing = false;
        public SQLiteOpenHelper(Context context, String name, CursorFactory factory, int version) {
            if (version < 1) throw new IllegalArgumentException("Version must be >= 1, was " + version);        mContext = context;
            mName = name;
            mFactory = factory;
            mNewVersion = version;
        }
        public synchronized SQLiteDatabase getWritableDatabase() {
            if (mDatabase != null && mDatabase.isOpen() && !mDatabase.isReadOnly()) {
                return mDatabase;  // The database is already open for business
            }        if (mIsInitializing) {
                throw new IllegalStateException("getWritableDatabase called recursively");
            }        boolean success = false;
            SQLiteDatabase db = null;
            if (mDatabase != null) mDatabase.lock();
            try {
                mIsInitializing = true;
                if (mName == null) {
                    db = SQLiteDatabase.create(null);
                } else {
                    db = mContext.openOrCreateDatabase(mName, 0, mFactory);
                }            int version = db.getVersion();
                if (version != mNewVersion) {
                    db.beginTransaction();
                    try {
                        if (version == 0) {
                            onCreate(db);
                        } else {
                            if (version > mNewVersion) {
                                Log.wtf(TAG, "Can't downgrade read-only database from version " +
                                        version + " to " + mNewVersion + ": " + db.getPath());
                            }
                            onUpgrade(db, version, mNewVersion);
                        }
                        db.setVersion(mNewVersion);
                        db.setTransactionSuccessful();
                    } finally {
                        db.endTransaction();
                    }
                }            onOpen(db);
                success = true;
                return db;
            } finally {
                mIsInitializing = false;
                if (success) {
                    if (mDatabase != null) {
                        try { mDatabase.close(); } catch (Exception e) { }
                        mDatabase.unlock();
                    }
                    mDatabase = db;
                } else {
                    if (mDatabase != null) mDatabase.unlock();
                    if (db != null) db.close();
                }
            }
        }
         */
        public synchronized SQLiteDatabase getReadableDatabase() {
            if (mDatabase != null && mDatabase.isOpen()) {
                return mDatabase;  // The database is already open for business
            }        if (mIsInitializing) {
                throw new IllegalStateException("getReadableDatabase called recursively");
            }        try {
                return getWritableDatabase();
            } catch (SQLiteException e) {
                if (mName == null) throw e;  // Can't open a temp database read-only!
                Log.e(TAG, "Couldn't open " + mName + " for writing (will try read-only):", e);
            }        SQLiteDatabase db = null;
            try {
                mIsInitializing = true;
                String path = mContext.getDatabasePath(mName).getPath();
                db = SQLiteDatabase.openDatabase(path, mFactory, SQLiteDatabase.OPEN_READONLY);
                if (db.getVersion() != mNewVersion) {
                    throw new SQLiteException("Can't upgrade read-only database from version " +
                            db.getVersion() + " to " + mNewVersion + ": " + path);
                }            onOpen(db);
                Log.w(TAG, "Opened " + mName + " in read-only mode");
                mDatabase = db;
                return mDatabase;
            } finally {
                mIsInitializing = false;
                if (db != null && db != mDatabase) db.close();
            }
        }    /**
         * Close any open database object.
         */
        public synchronized void close() {
            if (mIsInitializing) throw new IllegalStateException("Closed during initialization");        if (mDatabase != null && mDatabase.isOpen()) {
                mDatabase.close();
                mDatabase = null;
            }
        }
        public abstract void onCreate(SQLiteDatabase db);
        public abstract void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion);    public void onOpen(SQLiteDatabase db) {}
    }
    觉得这个文件里面的内容更有用些,才是这个类的源码,为什么在eclipse中显示的源码不是这个文件里面的呢?
    求指教!
      

  2.   

    一般都是这样的啊:比如:TimePicker这个类。
    // Compiled from TimePicker.java (version 1.5 : 49.0, super bit)
    public class android.widget.TimePicker extends android.widget.FrameLayout {
      
      // Method descriptor #13 (Landroid/content/Context;)V
      // Stack: 4, Locals: 2
      public TimePicker(android.content.Context context);
         0  aload_0 [this]
         1  aconst_null
         2  checkcast android.content.Context [1]
         5  aconst_null
         6  checkcast android.util.AttributeSet [2]
         9  iconst_0
        10  invokespecial android.widget.FrameLayout(android.content.Context, android.util.AttributeSet, int) [3]
        13  new java.lang.RuntimeException [4]
        16  dup
        17  ldc <String "Stub!"> [5]
        19  invokespecial java.lang.RuntimeException(java.lang.String) [6]
        22  athrow
          Line numbers:
            [pc: 0, line: 9]
          Local variable table:
            [pc: 0, pc: 23] local: this index: 0 type: android.widget.TimePicker
            [pc: 0, pc: 23] local: context index: 1 type: android.content.Context
      
      // Method descriptor #21 (Landroid/content/Context;Landroid/util/AttributeSet;)V
      // Stack: 4, Locals: 3
      public TimePicker(android.content.Context context, android.util.AttributeSet attrs);
         0  aload_0 [this]
         1  aconst_null
         2  checkcast android.content.Context [1]
         5  aconst_null
         6  checkcast android.util.AttributeSet [2]
         9  iconst_0
        10  invokespecial android.widget.FrameLayout(android.content.Context, android.util.AttributeSet, int) [3]
        13  new java.lang.RuntimeException [4]
        16  dup
        17  ldc <String "Stub!"> [5]
        19  invokespecial java.lang.RuntimeException(java.lang.String) [6]
        22  athrow
          Line numbers:
            [pc: 0, line: 10]
          Local variable table:
            [pc: 0, pc: 23] local: this index: 0 type: android.widget.TimePicker
            [pc: 0, pc: 23] local: context index: 1 type: android.content.Context
            [pc: 0, pc: 23] local: attrs index: 2 type: android.util.AttributeSet
      
      // Method descriptor #24 (Landroid/content/Context;Landroid/util/AttributeSet;I)V
      // Stack: 4, Locals: 4
      public TimePicker(android.content.Context context, android.util.AttributeSet attrs, int defStyle);
         0  aload_0 [this]
         1  aconst_null
         2  checkcast android.content.Context [1]
         5  aconst_null
         6  checkcast android.util.AttributeSet [2]
         9  iconst_0
        10  invokespecial android.widget.
      

  3.   

    SQLiteOpenHelper.java这个里面的内容是源代码
      

  4.   


    楼主问下问什么我的按了F3之后会出现source not found 的提示?是源码没下好?如何下?请求回答
      

  5.   

    /*jadclipse*/// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.看到这了么,这源码是jad反编译出来的,这些类没有被反编译出来