Git Product home page Git Product logo

Comments (11)

sigpwned avatar sigpwned commented on June 27, 2024 17

I was able to work around this issue with a little elbow grease.

I got the same error as above. I looked at the summary file to find the stack trace:

java.lang.RuntimeException: Method code too large!
        at org.objectweb.asm.MethodWriter.getSize(MethodWriter.java:1872)
        at org.objectweb.asm.AsmBridge.sizeOfMethodWriter(AsmBridge.java:28)
        at com.googlecode.d2j.dex.ExDex2Asm.convertCode(ExDex2Asm.java:55)
        at com.googlecode.d2j.dex.Dex2jar$2.convertCode(Dex2jar.java:128)
        at com.googlecode.d2j.dex.Dex2Asm.convertMethod(Dex2Asm.java:509)
        at com.googlecode.d2j.dex.Dex2Asm.convertClass(Dex2Asm.java:406)
        at com.googlecode.d2j.dex.Dex2Asm.convertDex(Dex2Asm.java:422)
        at com.googlecode.d2j.dex.Dex2jar.doTranslate(Dex2jar.java:172)
        at com.googlecode.d2j.dex.Dex2jar.to(Dex2jar.java:272)
        at com.googlecode.dex2jar.tools.Dex2jarCmd.doCommandLine(Dex2jarCmd.java:108)
        at com.googlecode.dex2jar.tools.BaseCmd.doMain(BaseCmd.java:288)
        at com.googlecode.dex2jar.tools.Dex2jarCmd.main(Dex2jarCmd.java:32)

Next, I found the jar file which contains that class in the lib directory: asm-debug-all-4.1.jar. Searching for "asm-debug-all-4.1.jar source code" led me here. The relevant snippet of code that's failing is:

if (code.length > 0) {
    if (code.length > 65536) {
        throw new RuntimeException("Method code too large!"); // CULPRIT
    }
    cw.newUTF8("Code");
    size += 18 + code.length + 8 * handlerCount;

What an odd test! It turns out that the java spec states that java method bodies cannot be longer than 64K, so this library is (rightfully) refusing to compile the method dex2jar has generated under the covers. But we're just trying to look at source code, not compile a program, so we don't care about that limit. Let's work around it.

The Right Thing here would be to pull down the build here, update the code, recompile it, and replace the class file. However, I -- frankly -- couldn't be arsed to do all that, so I took the much more direct (irresponsible, and lazy) approach of editing the byte code by hand.

Here's what I did:

  • Download the latest snapshot as of 2017-02-13, dex2jar-2.1-SNAPSHOT and unzip to $D2JHOME
  • Download a java bytecode editor (I used this one and unzipped to $BEHOME)
  • $ cd $D2JHOME
  • Back up the relevant library file $ cp lib/asm-debug-all-4.1.jar lib/asm-debug-all-4.1.jar.orig
  • $ cd lib
  • Extract the MethodWriter class $ unzip asm-debug-all-4.1.jar org/objectweb/asm/MethodWriter.class
  • Launch the bytecode editor and load org/objectweb/asm/MethodWriter.class (In another terminal, I used $ cd $BEHOME/bin; $ java ee.ioc.cs.jbe.browser.BrowserApplication)
  • In the bytecode editor, navigate to the getSize() method
  • In the bytecode editor, change instruction 23 ldc 65536 to a higher value (Note the code editor tab, I used ldc 524288)
  • Save the change in the bytecode editor
  • Update the MethodWriter class $ zip asm-debug-all-4.1.jar org/objectweb/asm/MethodWriter.class
  • Re-run $ $D2JHOME/d2j-dex2jar.sh application.apk -o application.jar --force
  • If that number doesn't work, try a bigger one!

Really, whether to enforce this limit or not should be an option in the asm-debug-all library. In the meantime, I've attached the updated JAR file here. (I had to rename it to ZIP for GitHub to take the file; you'll need to rename it to JAR after you download it.) Back up the existing asm-debug-all-4.1.jar file, and replace the original with the attached (renamed) file. That should work.

from dex2jar.

ammaratef45 avatar ammaratef45 commented on June 27, 2024 2

@sigpwned
Your solution is awesome but, I'm stuck with a new exception which is

java.lang.ArrayIndexOutOfBoundsException: 255
at org.objectweb.asm.MethodWriter.getSize(MethodWriter.java)
at org.objectweb.asm.ClassWriter.toByteArray(ClassWriter.java:775)
at com.googlecode.d2j.dex.Dex2jar$1$1.visitEnd(Dex2jar.java:101)
at com.googlecode.d2j.dex.Dex2Asm.convertClass(Dex2Asm.java:409)
at com.googlecode.d2j.dex.Dex2Asm.convertDex(Dex2Asm.java:422)
at com.googlecode.d2j.dex.Dex2jar.doTranslate(Dex2jar.java:172)
at com.googlecode.d2j.dex.Dex2jar.to(Dex2jar.java:272)
at com.googlecode.dex2jar.tools.Dex2jarCmd.doCommandLine(Dex2jarCmd.java:108)
at com.googlecode.dex2jar.tools.BaseCmd.doMain(BaseCmd.java:288)
at com.googlecode.dex2jar.tools.Dex2jarCmd.main(Dex2jarCmd.java:32)

I tried to figure it out but I didn't get the point

from dex2jar.

 avatar commented on June 27, 2024 2

@ammaratef45
Use another bytecode editor.
https://github.com/GraxCode/JByteMod-Beta/releases worked for me.

from dex2jar.

pxb1988 avatar pxb1988 commented on June 27, 2024

please also attach the m0.txt in the zip file

from dex2jar.

CalvinEng avatar CalvinEng commented on June 27, 2024

Github doesn't seems to have the option to upload files other than pictures, so I have uploaded the error zip file to google drive. Please look at the attached link.

https://drive.google.com/file/d/0B2U4p41RgtjKRFM2YWIwYW1SanM/view?usp=sharing

from dex2jar.

pxb1988 avatar pxb1988 commented on June 27, 2024

the method Lcom/nxp/nfc/tagwriter/gc;.<clinit>()V contains an array, the array size is huge, so the generated instruction can't fit in a .class method.

from dex2jar.

devpilot avatar devpilot commented on June 27, 2024

Encounted java.lang.RuntimeException: Method code too large!
Uploaded Classes-error.zip on google drive
https://drive.google.com/open?id=0B0uVD6vxUmjySEhJSmVSSVM2eTA

from dex2jar.

TamilanPeriyasamy avatar TamilanPeriyasamy commented on June 27, 2024

Hi pxb thanks for ur good Job .. I am in new for this circle.

I got same issue. How solve... I am use dex2jar 2.0.

from dex2jar.

GroverChouT avatar GroverChouT commented on June 27, 2024

I have same problem. I'm using dex2jar Nightly build for dex2jar 20150601

from dex2jar.

smurfix avatar smurfix commented on June 27, 2024

Same here. Any idea WRT a fix? or a workaround?

from dex2jar.

ZXTube avatar ZXTube commented on June 27, 2024

The asm-debug-all-4.1.jar that @sigpwned attached is outdated by now

So you should use this amazing fork which says that it fixed a lot of things and it fixed this unnecessary exception

from dex2jar.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.