java - 反编译器返回的仅注释方法是什么?

标签 java android bytecode

我正在查看银行 Android 应用程序的源代码,我发现其中大多数都有一些不执行任何操作的方法,并且在它们内部只有一些奇怪的注释掉代码。

看这个例子:

/* Error */
  public final void b()
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 68 example/com/PackagePMB:y    Lc/y;
    //   4: ifnonnull +15 -> 19
    //   7: aload_0
    //   8: new 640 c/y
    //   11: dup
    //   12: aload_0
    //   13: invokespecial 643  c/y:<init>  (Lc/w;)V
    //   16: putfield 68    example/com/PackagePMB:y    Lc/y;
    //   19: getstatic 645  c/g:m   B
    //   22: ifeq +18 -> 40
    //   25: aload_0
    //   26: getfield 174   example/com/PackagePMB:p    Ljava/util/Stack;
    //   29: invokevirtual 648  java/util/Stack:size    ()I
    //   32: ifle +8 -> 40
    //   35: aload_0
    //   36: invokevirtual 457  example/com/PackagePMB:j    ()V
    //   39: return
    //   40: aload_0
    //   41: getfield 174   example/com/PackagePMB:p    Ljava/util/Stack;
    //   44: invokevirtual 651  java/util/Stack:removeAllElements   ()V
    //   47: aload_0
    //   48: getfield 176   example/com/PackagePMB:u    Lc/ag;
    //   51: aload_0
    //   52: getfield 558   example/com/PackagePMB:f    Lc/c;
    //   55: invokevirtual 190  c/ag:a  (Landroid/view/View;)V
    //   58: aload_0
    //   59: getfield 176   example/com/PackagePMB:u    Lc/ag;
    //   62: invokevirtual 192  c/ag:b  ()V
    //   65: new 653    c/p
    //   68: dup
    //   69: getstatic 61   example/com/PackagePMB:a    Lexample/com/PackagePMB;
    //   72: invokespecial 654  c/p:<init>  (Landroid/content/Context;)V
    //   75: astore_1
    //   76: aload_1
    //   77: invokevirtual 655  c/p:a   ()V
    //   80: aload_1
    //   81: invokevirtual 656  c/p:b   ()V
    //   84: aload_1
    //   85: invokevirtual 660  c/p:getReadableDatabase ()Landroid/database/sqlite/SQLiteDatabase;
    //   88: astore 10
    //   90: aload 10
    //   92: ldc_w 662
    //   95: iconst_0
    //   96: anewarray 128  java/lang/String
    //   99: invokevirtual 668  android/database/sqlite/SQLiteDatabase:rawQuery (Ljava/lang/String;[Ljava/lang/String;)Landroid/database/Cursor;
    //   102: astore 11
    //   104: aload 11
    //   106: invokeinterface 673 1 0
    //   111: ifle +55 -> 166
    //   114: aload_0
    //   115: new 282   java/lang/StringBuilder
    //   118: dup
    //   119: ldc_w 675
    //   122: invokespecial 285 java/lang/StringBuilder:<init>  (Ljava/lang/String;)V
    //   125: aload 11
    //   127: invokeinterface 673 1 0
    //   132: invokevirtual 289 java/lang/StringBuilder:append  (I)Ljava/lang/StringBuilder;
    //   135: ldc_w 677
    //   138: invokevirtual 294 java/lang/StringBuilder:append  (Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   141: invokevirtual 297 java/lang/StringBuilder:toString    ()Ljava/lang/String;
    //   144: iconst_1
    //   145: invokestatic 683  android/widget/Toast:makeText   (Landroid/content/Context;Ljava/lang/CharSequence;I)Landroid/widget/Toast;
    //   148: invokevirtual 686 android/widget/Toast:show   ()V
    //   151: iconst_0
    //   152: istore 12
    //   154: iload 12
    //   156: aload 11
    //   158: invokeinterface 673 1 0
    //   163: if_icmplt +75 -> 238
    //   166: aload 10
    //   168: invokevirtual 689 android/database/sqlite/SQLiteDatabase:close    ()V
    //   171: aload_1
    //   172: invokevirtual 690 c/p:close   ()V
    //   175: new 653   c/p
    //   178: dup
    //   179: getstatic 61  example/com/PackagePMB:a    Lexample/com/PackagePMB;
    //   182: invokespecial 654 c/p:<init>  (Landroid/content/Context;)V
    //   185: astore 5
    //   187: aload 5
    //   189: invokevirtual 656 c/p:b   ()V
    //   192: aload 5
    //   194: invokevirtual 693 c/p:getWritableDatabase ()Landroid/database/sqlite/SQLiteDatabase;
    //   197: astore 6
    //   199: aload 6
    //   201: ldc_w 695
    //   204: ldc_w 697
    //   207: iconst_0
    //   208: anewarray 128 java/lang/String
    //   211: invokevirtual 701 android/database/sqlite/SQLiteDatabase:delete   (Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)I
    //   214: pop
    //   215: aload 6
    //   217: invokevirtual 689 android/database/sqlite/SQLiteDatabase:close    ()V
    //   220: aload 5
    //   222: invokevirtual 690 c/p:close   ()V
    //   225: return
    //   226: astore_2
    //   227: new 703   java/lang/Error
    //   230: dup
    //   231: ldc_w 705
    //   234: invokespecial 706 java/lang/Error:<init>  (Ljava/lang/String;)V
    //   237: athrow
    //   238: aload 11
    //   240: iload 12
    //   242: invokeinterface 709 2 0
    //   247: pop
    //   248: aload_0
    //   249: aload 11
    //   251: aload 11
    //   253: ldc_w 711
    //   256: invokeinterface 714 2 0
    //   261: invokeinterface 717 2 0
    //   266: aload 11
    //   268: aload 11
    //   270: ldc_w 719
    //   273: invokeinterface 714 2 0
    //   278: invokeinterface 717 2 0
    //   283: iconst_0
    //   284: invokestatic 616  java/lang/Boolean:valueOf   (Z)Ljava/lang/Boolean;
    //   287: invokespecial 618 example/com/PackagePMB:a    (Ljava/lang/String;Ljava/lang/String;Ljava/lang/Boolean;)V
    //   290: iinc 12 1
    //   293: goto -139 -> 154
    //   296: astore 4
    //   298: aload_1
    //   299: invokevirtual 690 c/p:close   ()V
    //   302: goto -127 -> 175
    //   305: astore_3
    //   306: aload_1
    //   307: invokevirtual 690 c/p:close   ()V
    //   310: aload_3
    //   311: athrow
    //   312: astore 8
    //   314: aload 6
    //   316: invokevirtual 689 android/database/sqlite/SQLiteDatabase:close    ()V
    //   319: aload 5
    //   321: invokevirtual 690 c/p:close   ()V
    //   324: return
    //   325: astore 7
    //   327: aload 6
    //   329: invokevirtual 689 android/database/sqlite/SQLiteDatabase:close    ()V
    //   332: aload 5
    //   334: invokevirtual 690 c/p:close   ()V
    //   337: aload 7
    //   339: athrow
    // Local variable table:
    //   start  length  slot    name    signature
    //   0  340 0   this    ParsianPMB
    //   75 232 1   localp1 c.p
    //   226    1   2   localIOException    IOException
    //   305    6   3   localObject1    Object
    //   296    1   4   localSQLException1  android.database.SQLException
    //   185    148 5   localp2 c.p
    //   197    131 6   localSQLiteDatabase1    android.database.sqlite.SQLiteDatabase
    //   325    13  7   localObject2    Object
    //   312    1   8   localSQLException2  android.database.SQLException
    //   88 79  10  localSQLiteDatabase2    android.database.sqlite.SQLiteDatabase
    //   102    167 11  localCursor android.database.Cursor
    //   152    139 12  i1  int
    // Exception table:
    //   from   to  target  type
    //   76 80  226 java/io/IOException
    //   80 151 296 android/database/SQLException
    //   154    166 296 android/database/SQLException
    //   166    171 296 android/database/SQLException
    //   238    290 296 android/database/SQLException
    //   80 151 305 finally
    //   154    166 305 finally
    //   166    171 305 finally
    //   238    290 305 finally
    //   199    215 312 android/database/SQLException
    //   199    215 325 finally
  }

这些是什么?为什么编译器不跳过这些注释? 因为我从 apk 文件中提取了它,而classes.dex是一个编译文件,所以里面不应该有任何注释,因为编译器会跳过它们。但在本例中它没有,它们作为主代码存在!

有人对这些方法有任何了解吗?

这个方法没有得到任何东西,不返回任何东西,也不做任何事情!

如果这是反编译器的错误,无法反编译此方法,那么我如何对我自己的方法执行相同的操作,以便反编译器无法反编译它们?

最佳答案

What are these?

原始字节码的转储。

why these comments were not skipped by the compiler?

很可能是因为反编译器无法将字节码解码为 Java。

because I extracted this from an apk file, and classes.dex is a compiled file, so there should not be any comments inside it, because the compiler skips them. but in this case it didn't and they are there as a main code!

这些不是来自原始来源的评论。正如你所说,此类注释不在字节码中。

does anyone have any idea about these kind of methods?

是的,开发代码的人。名为 b() 的方法更有可能被混淆以使其更难破解。

this method doesn't get anything ,doesn't return anything and doesn't do anything!

我确信字节码会做一些事情。

if this is an error by decompiler that couldn't decompile this method, then how can I do the same thing to my own methods so that decompilers can't decompile them?

使用混淆器。

关于java - 反编译器返回的仅注释方法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24618840/

相关文章:

java - 如何避免 Spring 缓存中区分大小写的键?

Android 视频录制 - mediaRecorder.start 上的 IllegalStateException

android - 带有 TabLayout 的 ViewPager 问题与 AnimatedVectorDrawable

java - 单击 ListView 将 Firebase 数据从一个 Activity 传递到另一个 Activity

java - 有哪些有趣、免费、开源的 Java 动态分析工具?

java - 从字节码获取调用层次结构(在 Eclipse 中)

java - 使用 viewPager 时从不可见的 fragment 中隐藏 View

java - URLConnection,为什么有两个不同的超时? (连接并阅读)

java - 在运行时(动态地)创建简单的 POJO 类(字节码)

java - Android sqlite 数据库 - 如何显示 ListView 在滚动末尾添加 “Load more items”