designwizard icon indicating copy to clipboard operation
designwizard copied to clipboard

Throws ArrayIndexOutOfBoundsException in ClassReader.readClass() when calling the method ASMExtractor.processClass()

Open tacianosilva opened this issue 9 years ago • 2 comments

The Design Wizard is throwing exception when trying to process classes. This occurs in some projects, perhaps with class with large number of rows.

The error occurred during the extraction of facts with DesignWizard from the project's GitHub cloned. In the directory resources/testFiles/ was made the project's clone.

git clone [email protected]:cliffmaury/angular-spring4-stack.git

So, in the directory angular-spring4-stack run mvn compile. And call the DesignWizard constructor for extracting facts.

@Test(expected = ArrayIndexOutOfBoundsException.class)
public void test() {
    DesignWizard dw;
    String classpath;
    try {
        classpath = "resources/testFiles/angular-spring4-stack/target/classes";
        dw = new DesignWizard(classpath);
    } catch (IOException e) {
        e.printStackTrace();
    } catch (ArrayIndexOutOfBoundsException e) {
        e.printStackTrace();
        throw e;
    }
}

The exception stack trace:

java.lang.ArrayIndexOutOfBoundsException: 43776
    at org.objectweb.asm.ClassReader.readClass(Unknown Source)
    at org.objectweb.asm.ClassReader.accept(Unknown Source)
    at org.objectweb.asm.ClassReader.accept(Unknown Source)
    at org.designwizard.extractor.asm.ASMExtractor.processClass(ASMExtractor.java:114)
    at org.designwizard.extractor.asm.ASMExtractor.processDir(ASMExtractor.java:64)
    at org.designwizard.extractor.asm.ASMExtractor.processDir(ASMExtractor.java:72)
    at org.designwizard.extractor.asm.ASMExtractor.processDir(ASMExtractor.java:72)
    at org.designwizard.extractor.asm.ASMExtractor.processDir(ASMExtractor.java:72)
    at org.designwizard.extractor.asm.ASMExtractor.processDir(ASMExtractor.java:72)
    at org.designwizard.extractor.asm.ASMExtractor.processDir(ASMExtractor.java:72)
    at org.designwizard.extractor.asm.ASMExtractor.processDir(ASMExtractor.java:72)
    at org.designwizard.extractor.asm.ASMExtractor.processDir(ASMExtractor.java:72)
    at org.designwizard.design.manager.DesignManager.extractFactsFromClassesDir(DesignManager.java:143)
    at org.designwizard.design.manager.DesignManager.extractFacts(DesignManager.java:85)
    at org.designwizard.api.DesignWizard.<init>(DesignWizard.java:57)
    at br.edu.ufcg.splab.designtests.DesignWizardDecorator.<init>(DesignWizardDecorator.java:21)
    at br.edu.ufcg.splab.designtests.RulesVerifier.processarProjeto(RulesVerifier.java:88)
    at br.edu.ufcg.splab.designtests.RulesVerifier.processarArquivo(RulesVerifier.java:64)
    at br.edu.ufcg.splab.designtests.RulesVerifier.main(RulesVerifier.java:41)

tacianosilva avatar Oct 19 '15 17:10 tacianosilva

I read some problems related to this bug, and i figured out what is occuring, asm-3.1 doesn't support lambdas expression available in JDK 8.

For your problem there are two solutions:

  1. Update to asm-5.0.1 or higher; (recommeded) or
  2. Change the compiler of the angular-spring4-stack project to JDK 7 or JDK 6.

I think it's better to either update DesignWizard with the asm dependency or update the README file, adding the information that DesignWizard doesn't support project that uses lambda expressions.

catharinequintans avatar Apr 18 '16 20:04 catharinequintans

Asm5.1 also occurs this exception.

dengshiwei avatar Sep 12 '18 10:09 dengshiwei