SonarQube Java
  1. SonarQube Java
  2. SONARJAVA-85

Provide contextual information when an ASM Exception is thrown while analysing a java class and don't stop the analysis

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.0
    • Fix Version/s: 1.3
    • Component/s: None
    • Labels:
      None
    • Environment:
    • Number of attachments :
      0

      Description

      We should at least log the java class that can't be read and we should not stop the analysis.

      [sonar:sonar] 13:44:31.786 INFO  jectFileSystemLogger -   /home/sargis/projects/twm3.git/modules/urmcore/Server/test
      [sonar:sonar] 13:44:31.786 INFO  .b.p.SensorsExecutor - Initializer ProjectFileSystemLogger done: 1 ms
      [sonar:sonar] 13:44:31.796 INFO  p.PhasesTimeProfiler - Sensor JavaSourceImporter...
      [sonar:sonar] 13:44:32.088 INFO  p.PhasesTimeProfiler - Sensor JavaSourceImporter done: 292 ms
      [sonar:sonar] 13:44:32.088 INFO  p.PhasesTimeProfiler - Sensor JavaSquidSensor...
      [sonar:sonar] 13:44:32.094 INFO    o.s.java.JavaSquid - Java AST scan...
      [sonar:sonar] 13:44:32.419 INFO    o.s.java.JavaSquid - Java AST scan done: 325 ms
      [sonar:sonar] 13:44:32.421 INFO    o.s.java.JavaSquid - Java bytecode scan...
      
      BUILD FAILED
      /home/sargis/projects/twm3.git/modules/urmcore/build.xml:116: org.sonar.runner.RunnerException: java.lang.ArrayIndexOutOfBoundsException: 3699
      	at org.sonar.runner.Runner.delegateExecution(Runner.java:288)
      	at org.sonar.runner.Runner.execute(Runner.java:151)
      	at org.sonar.ant.SonarTask.launchAnalysis(SonarTask.java:93)
      	at org.sonar.ant.SonarTask.execute(SonarTask.java:75)
      	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
      	at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:601)
      	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
      	at org.apache.tools.ant.Task.perform(Task.java:348)
      	at org.apache.tools.ant.Target.execute(Target.java:392)
      	at org.apache.tools.ant.Target.performTasks(Target.java:413)
      	at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
      	at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
      	at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
      	at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
      	at org.apache.tools.ant.Main.runBuild(Main.java:811)
      	at org.apache.tools.ant.Main.startAnt(Main.java:217)
      	at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
      	at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
      Caused by: java.lang.ArrayIndexOutOfBoundsException: 3699
      	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.sonar.java.bytecode.asm.AsmClassProviderImpl.decoracteAsmClassFromBytecode(AsmClassProviderImpl.java:74)
      	at org.sonar.java.bytecode.asm.AsmClassProviderImpl.getClass(AsmClassProviderImpl.java:54)
      	at org.sonar.java.bytecode.asm.AsmMethodVisitor.visitMethodInsn(AsmMethodVisitor.java:53)
      	at org.objectweb.asm.ClassReader.accept(Unknown Source)
      	at org.objectweb.asm.ClassReader.accept(Unknown Source)
      	at org.sonar.java.bytecode.asm.AsmClassProviderImpl.decoracteAsmClassFromBytecode(AsmClassProviderImpl.java:74)
      	at org.sonar.java.bytecode.asm.AsmClassProviderImpl.getClass(AsmClassProviderImpl.java:54)
      	at org.sonar.java.bytecode.BytecodeScanner.loadByteCodeInformation(BytecodeScanner.java:86)
      	at org.sonar.java.bytecode.BytecodeScanner.scan(BytecodeScanner.java:59)
      	at org.sonar.java.bytecode.BytecodeScanner.scan(BytecodeScanner.java:49)
      	at org.sonar.java.JavaSquid.scanBytecode(JavaSquid.java:105)
      	at org.sonar.java.JavaSquid.scan(JavaSquid.java:93)
      	at org.sonar.plugins.java.JavaSquidSensor.analyse(JavaSquidSensor.java:74)
      	at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:64)
      	at org.sonar.batch.phases.Phases.execute(Phases.java:97)
      	at org.sonar.batch.bootstrap.ProjectModule.doStart(ProjectModule.java:128)
      	at org.sonar.batch.bootstrap.Module.start(Module.java:83)
      	at org.sonar.batch.bootstrap.BatchModule.analyze(BatchModule.java:114)
      	at org.sonar.batch.bootstrap.BatchModule.analyze(BatchModule.java:109)
      	at org.sonar.batch.bootstrap.BatchModule.doStart(BatchModule.java:104)
      	at org.sonar.batch.bootstrap.Module.start(Module.java:83)
      	at org.sonar.batch.bootstrap.BootstrapModule.doStart(BootstrapModule.java:121)
      	at org.sonar.batch.bootstrap.Module.start(Module.java:83)
      	at org.sonar.batch.Batch.execute(Batch.java:104)
      	at org.sonar.runner.internal.batch.Launcher.executeBatch(Launcher.java:69)
      	at org.sonar.runner.internal.batch.Launcher.execute(Launcher.java:61)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:601)
      	at org.sonar.runner.Runner.delegateExecution(Runner.java:285)
      	... 19 more
      
      Total time: 54 seconds
      sargis@sargis:~/projects/twm3.git/modules/urmcore> 
      

        Activity

        Hide
        Sargis Harutyunyan added a comment -

        I tried with 1.6 and 1.7 for:

        <property name="sonar.java.source" value="$

        {source}

        "/>
        <property name="sonar.java.target" value="$

        {target}

        "/>

        result was the same

        Show
        Sargis Harutyunyan added a comment - I tried with 1.6 and 1.7 for: <property name="sonar.java.source" value="$ {source} "/> <property name="sonar.java.target" value="$ {target} "/> result was the same
        Hide
        Freddy Mallet added a comment -

        Hi Sargis, do you use any special java library in your project to generate/instrument the java bytecode ?

        Show
        Freddy Mallet added a comment - Hi Sargis, do you use any special java library in your project to generate/instrument the java bytecode ?
        Hide
        Sargis Harutyunyan added a comment -

        In fact I don't have any instrumentation of bytecode, if you need I can run with logger debug mode to have problematic class file to investigate more, just provide info how to do.

        Show
        Sargis Harutyunyan added a comment - In fact I don't have any instrumentation of bytecode, if you need I can run with logger debug mode to have problematic class file to investigate more, just provide info how to do.
        Hide
        Evgeny Mandrikov added a comment -

        For the record: this exception is a clear indication that class under analysis is malformed/corrupted.

        Show
        Evgeny Mandrikov added a comment - For the record: this exception is a clear indication that class under analysis is malformed/corrupted.
        Hide
        Fabrice Bellingard added a comment -

        Tested

        Show
        Fabrice Bellingard added a comment - Tested

          People

          • Assignee:
            Evgeny Mandrikov
            Reporter:
            Sargis Harutyunyan
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: