如何将反编译.class修复为.java错误

时间:2019-03-10 16:54:53

标签: java bytecode converters

我尝试将.class文件转换为.java文件,但是转换后,我注意到某些代码未转换,并在注释/*Error*/下写为字节码。为:

/* Error */
private LineData getDataSetPrHour(LinkedHashMap<String, Float> paramLinkedHashMap, String paramString) {
    // Byte code:
    //   0: new 340 java/util/ArrayList
    //   3: dup
    //   4: invokespecial 341   java/util/ArrayList:<init>  ()V
    //   7: astore_3
    //   8: aload_0
    //   9: new 340 java/util/ArrayList
    //   12: dup
    //   13: invokespecial 341  java/util/ArrayList:<init>  ()V
    //   16: putfield 323   no/fault/oilwidget/ChartFragment:labels Ljava/util/ArrayList;
    //   19: aload_1
    //   20: invokevirtual 347  java/util/LinkedHashMap:size    ()I
    //   23: iconst_1
    //   24: isub
    //   25: istore 4
    //   27: aload_1
    //   28: invokevirtual 351  java/util/LinkedHashMap:entrySet    ()Ljava/util/Set;
    //   31: invokeinterface 357 1 0
    //   36: astore 5
    //   38: iconst_0
    //   39: istore 6
    //   41: aload 5
    //   43: invokeinterface 363 1 0
    //   48: istore 7
    //   50: aconst_null
    //   51: astore 8
    //   53: iload 7
    //   55: ifeq +426 -> 481
    //   58: aload 5
    //   60: invokeinterface 367 1 0
    //   65: checkcast 369  java/util/Map$Entry
    //   68: astore 10
    //   70: aload 10
    //   72: invokeinterface 372 1 0
    //   77: checkcast 131  java/lang/String
    //   80: astore 11
    //   82: aload_3
    //   83: new 374    com/github/mikephil/charting/data/Entry
    //   86: dup
    //   87: aload 10
    //   89: invokeinterface 377 1 0
    //   94: checkcast 379  java/lang/Float
    //   97: invokevirtual 383  java/lang/Float:floatValue  ()F
    //   100: iload 6
    //   102: invokespecial 386 com/github/mikephil/charting/data/Entry:<init>  (FI)V
    //   105: invokevirtual 389 java/util/ArrayList:add (Ljava/lang/Object;)Z
    //   108: pop
    //   109: aload_2
    //   110: ldc_w 391
    //   113: invokevirtual 276 java/lang/String:equals (Ljava/lang/Object;)Z
    //   116: ifne +223 -> 339
    //   119: aload_2
    //   120: ldc_w 393
    //   123: invokevirtual 276 java/lang/String:equals (Ljava/lang/Object;)Z
    //   126: ifeq +6 -> 132
    //   129: goto +210 -> 339
    //   132: aload_2
    //   133: ldc_w 395
    //   136: invokevirtual 276 java/lang/String:equals (Ljava/lang/Object;)Z
    //   139: ifne +53 -> 192
    //   142: aload_2
    //   143: ldc_w 397
    //   146: invokevirtual 276 java/lang/String:equals (Ljava/lang/Object;)Z
    //   149: ifne +43 -> 192
    //   152: aload_2
    //   153: ldc_w 399
    //   156: invokevirtual 276 java/lang/String:equals (Ljava/lang/Object;)Z
    //   159: ifne +33 -> 192
    //   162: aload_2
    //   163: ldc_w 401
    //   166: invokevirtual 276 java/lang/String:equals (Ljava/lang/Object;)Z
    //   169: ifeq +6 -> 175
    //   172: goto +20 -> 192
    //   175: aload_2
    //   176: ldc_w 403
    //   179: invokevirtual 276 java/lang/String:equals (Ljava/lang/Object;)Z
    //   182: ifeq +264 -> 446
    //   185: aload 11
    //   187: astore 8
    //   189: goto +257 -> 446
    //   192: new 405   java/text/SimpleDateFormat
    //   195: dup
    //   196: ldc_w 407
    //   199: invokespecial 409 java/text/SimpleDateFormat:<init>   (Ljava/lang/String;)V
    //   202: astore 18
    //   204: aload 18
    //   206: aload 11
    //   208: invokevirtual 413 java/text/SimpleDateFormat:parse    (Ljava/lang/String;)Ljava/util/Date;
    //   211: astore 19
    //   213: goto +7 -> 220
    //   216: aload 8
    //   218: astore 19
    //   220: aload_0
    //   221: invokevirtual 152 no/fault/oilwidget/ChartFragment:getActivity    ()Landroid/app/Activity;
    //   224: invokestatic 419  android/text/format/DateFormat:getDateFormat    (Landroid/content/Context;)Ljava/text/DateFormat;
    //   227: astore 20
    //   229: iload 6
    //   231: ifne +48 -> 279
    //   234: new 421   java/lang/StringBuilder
    //   237: dup
    //   238: invokespecial 422 java/lang/StringBuilder:<init>  ()V
    //   241: astore 21
    //   243: aload 21
    //   245: ldc_w 424
    //   248: invokevirtual 428 java/lang/StringBuilder:append  (Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   251: pop
    //   252: aload 21
    //   254: aload 20
    //   256: aload 19
    //   258: invokevirtual 434 java/text/DateFormat:format (Ljava/util/Date;)Ljava/lang/String;
    //   261: invokevirtual 428 java/lang/StringBuilder:append  (Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   264: pop
    //   265: aload 21
    //   267: invokevirtual 438 java/lang/StringBuilder:toString    ()Ljava/lang/String;
    //   270: astore 24
    //   272: aload 24
    //   274: astore 8
    //   276: goto +170 -> 446
    //   279: iload 6
    //   281: iload 4
    //   283: if_icmpne +44 -> 327
    //   286: new 421   java/lang/StringBuilder
    //   289: dup
    //   290: invokespecial 422 java/lang/StringBuilder:<init>  ()V
    //   293: astore 25
    //   295: aload 25
    //   297: aload 20
    //   299: aload 19
    //   301: invokevirtual 434 java/text/DateFormat:format (Ljava/util/Date;)Ljava/lang/String;
    //   304: invokevirtual 428 java/lang/StringBuilder:append  (Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   307: pop
    //   308: aload 25
    //   310: ldc_w 440
    //   313: invokevirtual 428 java/lang/StringBuilder:append  (Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   316: pop
    //   317: aload 25
    //   319: invokevirtual 438 java/lang/StringBuilder:toString    ()Ljava/lang/String;
    //   322: astore 24
    //   324: goto -52 -> 272
    //   327: aload 20
    //   329: aload 19
    //   331: invokevirtual 434 java/text/DateFormat:format (Ljava/util/Date;)Ljava/lang/String;
    //   334: astore 24
    //   336: goto -64 -> 272
    //   339: iload 6
    //   341: ifne +26 -> 367
    //   344: aload_0
    //   345: invokevirtual 152 no/fault/oilwidget/ChartFragment:getActivity    ()Landroid/app/Activity;
    //   348: aload 11
    //   350: ldc_w 442
    //   353: ldc_w 444
    //   356: ldc_w 446
    //   359: invokestatic 452  no/fault/oilwidget/com/util:formatUTCDateStrToHourStr   (Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
    //   362: astore 8
    //   364: goto +82 -> 446
    //   367: iload 6
    //   369: iload 4
    //   371: if_icmpne +55 -> 426
    //   374: new 421   java/lang/StringBuilder
    //   377: dup
    //   378: invokespecial 422 java/lang/StringBuilder:<init>  ()V
    //   381: astore 13
    //   383: aload 13
    //   385: aload_0
    //   386: invokevirtual 152 no/fault/oilwidget/ChartFragment:getActivity    ()Landroid/app/Activity;
    //   389: aload 11
    //   391: ldc_w 442
    //   394: ldc_w 444
    //   397: ldc_w 446
    //   400: invokestatic 452  no/fault/oilwidget/com/util:formatUTCDateStrToHourStr   (Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
    //   403: invokevirtual 428 java/lang/StringBuilder:append  (Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   406: pop
    //   407: aload 13
    //   409: ldc_w 454
    //   412: invokevirtual 428 java/lang/StringBuilder:append  (Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   415: pop
    //   416: aload 13
    //   418: invokevirtual 438 java/lang/StringBuilder:toString    ()Ljava/lang/String;
    //   421: astore 8
    //   423: goto +23 -> 446
    //   426: aload_0
    //   427: invokevirtual 152 no/fault/oilwidget/ChartFragment:getActivity    ()Landroid/app/Activity;
    //   430: aload 11
    //   432: ldc_w 442
    //   435: ldc_w 444
    //   438: ldc_w 446
    //   441: invokestatic 452  no/fault/oilwidget/com/util:formatUTCDateStrToHourStr   (Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
    //   444: astore 8
    //   446: aload 8
    //   448: ifnull +16 -> 464
    //   451: aload_0
    //   452: getfield 323  no/fault/oilwidget/ChartFragment:labels Ljava/util/ArrayList;
    //   455: aload 8
    //   457: invokevirtual 389 java/util/ArrayList:add (Ljava/lang/Object;)Z
    //   460: pop
    //   461: goto +14 -> 475
    //   464: aload_0
    //   465: getfield 323  no/fault/oilwidget/ChartFragment:labels Ljava/util/ArrayList;
    //   468: ldc_w 456
    //   471: invokevirtual 389 java/util/ArrayList:add (Ljava/lang/Object;)Z
    //   474: pop
    //   475: iinc 6 1
    //   478: goto -437 -> 41
    //   481: new 458   com/github/mikephil/charting/data/LineDataSet
    //   484: dup
    //   485: aload_3
    //   486: aload 8
    //   488: invokespecial 461 com/github/mikephil/charting/data/LineDataSet:<init>    (Ljava/util/List;Ljava/lang/String;)V
    //   491: astore 9
    //   493: aload 9
    //   495: iconst_1
    //   496: invokevirtual 464 com/github/mikephil/charting/data/LineDataSet:setDrawCubic  (Z)V
    //   499: aload 9
    //   501: aload_0
    //   502: getfield 72   no/fault/oilwidget/ChartFragment:filled Z
    //   505: invokevirtual 467 com/github/mikephil/charting/data/LineDataSet:setDrawFilled (Z)V
    //   508: aload_0
    //   509: getfield 70   no/fault/oilwidget/ChartFragment:dark_mode  Z
    //   512: ifeq +74 -> 586
    //   515: aload 9
    //   517: aload_0
    //   518: invokevirtual 152 no/fault/oilwidget/ChartFragment:getActivity    ()Landroid/app/Activity;
    //   521: ldc_w 468
    //   524: invokestatic 210  android/support/v4/content/ContextCompat:getColor   (Landroid/content/Context;I)I
    //   527: invokevirtual 471 com/github/mikephil/charting/data/LineDataSet:setValueTextColor (I)V
    //   530: aload 9
    //   532: aload_0
    //   533: invokevirtual 152 no/fault/oilwidget/ChartFragment:getActivity    ()Landroid/app/Activity;
    //   536: ldc_w 472
    //   539: invokestatic 210  android/support/v4/content/ContextCompat:getColor   (Landroid/content/Context;I)I
    //   542: invokevirtual 475 com/github/mikephil/charting/data/LineDataSet:setFillColor  (I)V
    //   545: aload 9
    //   547: aload_0
    //   548: invokevirtual 152 no/fault/oilwidget/ChartFragment:getActivity    ()Landroid/app/Activity;
    //   551: ldc_w 476
    //   554: invokestatic 210  android/support/v4/content/ContextCompat:getColor   (Landroid/content/Context;I)I
    //   557: invokevirtual 479 com/github/mikephil/charting/data/LineDataSet:setColor  (I)V
    //   560: aload 9
    //   562: aload_0
    //   563: invokevirtual 152 no/fault/oilwidget/ChartFragment:getActivity    ()Landroid/app/Activity;
    //   566: ldc_w 480
    //   569: invokestatic 210  android/support/v4/content/ContextCompat:getColor   (Landroid/content/Context;I)I
    //   572: invokevirtual 483 com/github/mikephil/charting/data/LineDataSet:setCircleColor    (I)V
    //   575: aload 9
    //   577: sipush 255
    //   580: invokevirtual 486 com/github/mikephil/charting/data/LineDataSet:setFillAlpha  (I)V
    //   583: goto +63 -> 646
    //   586: aload 9
    //   588: aload_0
    //   589: invokevirtual 152 no/fault/oilwidget/ChartFragment:getActivity    ()Landroid/app/Activity;
    //   592: ldc_w 487
    //   595: invokestatic 210  android/support/v4/content/ContextCompat:getColor   (Landroid/content/Context;I)I
    //   598: invokevirtual 471 com/github/mikephil/charting/data/LineDataSet:setValueTextColor (I)V
    //   601: aload 9
    //   603: aload_0
    //   604: invokevirtual 152 no/fault/oilwidget/ChartFragment:getActivity    ()Landroid/app/Activity;
    //   607: ldc_w 488
    //   610: invokestatic 210  android/support/v4/content/ContextCompat:getColor   (Landroid/content/Context;I)I
    //   613: invokevirtual 475 com/github/mikephil/charting/data/LineDataSet:setFillColor  (I)V
    //   616: aload 9
    //   618: aload_0
    //   619: invokevirtual 152 no/fault/oilwidget/ChartFragment:getActivity    ()Landroid/app/Activity;
    //   622: ldc_w 489
    //   625: invokestatic 210  android/support/v4/content/ContextCompat:getColor   (Landroid/content/Context;I)I
    //   628: invokevirtual 479 com/github/mikephil/charting/data/LineDataSet:setColor  (I)V
    //   631: aload 9
    //   633: aload_0
    //   634: invokevirtual 152 no/fault/oilwidget/ChartFragment:getActivity    ()Landroid/app/Activity;
    //   637: ldc_w 490
    //   640: invokestatic 210  android/support/v4/content/ContextCompat:getColor   (Landroid/content/Context;I)I
    //   643: invokevirtual 483 com/github/mikephil/charting/data/LineDataSet:setCircleColor    (I)V
    //   646: aload 9
    //   648: ldc_w 491
    //   651: invokevirtual 494 com/github/mikephil/charting/data/LineDataSet:setCircleSize (F)V
    //   654: aload 9
    //   656: ldc -25
    //   658: invokevirtual 497 com/github/mikephil/charting/data/LineDataSet:setValueTextSize  (F)V
    //   661: aload 9
    //   663: iconst_0
    //   664: invokevirtual 500 com/github/mikephil/charting/data/LineDataSet:setDrawHorizontalHighlightIndicator   (Z)V
    //   667: aload 9
    //   669: iconst_0
    //   670: invokevirtual 503 com/github/mikephil/charting/data/LineDataSet:setDrawVerticalHighlightIndicator (Z)V
    //   673: aload 9
    //   675: new 12    no/fault/oilwidget/ChartFragment$4
    //   678: dup
    //   679: aload_0
    //   680: invokespecial 505 no/fault/oilwidget/ChartFragment$4:<init>   (Lno/fault/oilwidget/ChartFragment;)V
    //   683: invokevirtual 509 com/github/mikephil/charting/data/LineDataSet:setValueFormatter (Lcom/github/mikephil/charting/formatter/ValueFormatter;)V
    //   686: new 511   com/github/mikephil/charting/data/LineData
    //   689: dup
    //   690: aload_0
    //   691: getfield 323  no/fault/oilwidget/ChartFragment:labels Ljava/util/ArrayList;
    //   694: aload 9
    //   696: invokespecial 514 com/github/mikephil/charting/data/LineData:<init>   (Ljava/util/List;Lcom/github/mikephil/charting/data/LineDataSet;)V
    //   699: areturn
    // Local variable table:
    //   start  length  slot    name    signature
    //   0  700 0   this    ChartFragment
    //   0  700 1   paramLinkedHashMap  LinkedHashMap<String, Float>
    //   0  700 2   paramString String
    //   7  479 3   localArrayList  ArrayList
    //   25 347 4   i   int
    //   36 23  5   localIterator   java.util.Iterator
    //   39 437 6   j   int
    //   48 6   7   bool    boolean
    //   51 436 8   localObject1    Object
    //   491    204 9   localLineDataSet    com.github.mikephil.charting.data.LineDataSet
    //   68 20  10  localEntry  java.util.Map.Entry
    //   80 351 11  str1    String
    //   381    36  13  localStringBuilder1 StringBuilder
    //   202    3   18  localSimpleDateFormat   java.text.SimpleDateFormat
    //   211    119 19  localObject2    Object
    //   216    1   19  localParseException java.text.ParseException
    //   227    101 20  localDateFormat java.text.DateFormat
    //   241    25  21  localStringBuilder2 StringBuilder
    //   270    65  24  str2    String
    //   293    25  25  localStringBuilder3 StringBuilder
    // Exception table:
    //   from   to  target  type
    //   204    213 216 java/text/ParseException
    return null;
}

如何将这些代码转换为Java?

在线/离线翻译代码的地方。

1 个答案:

答案 0 :(得分:1)

这意味着您正在使用的反编译器无法反编译所讨论的方法。您可以尝试使用其他反编译器。一些反编译器比其他反编译器更好,每个反编译器都有优点和缺点。特别是Krakatau decompiler应该很容易处理您发布的代码,尽管很难设置,尤其是在反编译android代码时。 Krakatau可以处理几乎所有不使用invokedynamic的事物。它甚至可以反编译混淆的代码,尽管结果不如传统反编译器那么好。