JavaSquidSensor failing with java.lang.StackOverflowError

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

JavaSquidSensor failing with java.lang.StackOverflowError

Vara Prasad
Hello,

In one of the projects, iam getting below error (Using sonar-java-plugin-2.6.jar)

Caused by: java.lang.StackOverflowError
        at com.google.common.collect.Iterators$13.<init>(Iterators.java:1057)
        at com.google.common.collect.Iterators.singletonIterator(Iterators.java:1057)
        at com.google.common.collect.SingletonImmutableList.iterator(SingletonImmutableList.java:55)
        at com.google.common.collect.SingletonImmutableList.iterator(SingletonImmutableList.java:34)
        at org.sonar.java.resolve.Resolve.findMemberType(Resolve.java:226)
        at org.sonar.java.resolve.Resolve.findMemberType(Resolve.java:221)
        at org.sonar.java.resolve.Resolve.findMemberType(Resolve.java:227)
        at org.sonar.java.resolve.Resolve.findMemberType(Resolve.java:221)
        at org.sonar.java.resolve.Resolve.findMemberType(Resolve.java:227)
        at org.sonar.java.resolve.Resolve.findMemberType(Resolve.java:221)
        at org.sonar.java.resolve.Resolve.findMemberType(Resolve.java:227)
        at org.sonar.java.resolve.Resolve.findMemberType(Resolve.java:221)
        at org.sonar.java.resolve.Resolve.findMemberType(Resolve.java:227)
        at org.sonar.java.resolve.Resolve.findMemberType(Resolve.java:221)
---
---
---

I created a sample to simulate the behaviour from my project

My project is having below structure
foo/src/main/java/com/sample/squid_example/pkg1
foo/src/main/java/com/sample/squid_example/pkg2

In pkg1, there an interface B as below

Interface B :
package com.sample.squid_example.pkg1;

public interface B {

        public void foo ();
       
}


In pkg2, there are two classes as below

Class A:
package com.sample.squid_example.pkg2;

import com.sample.squid_example.pkg1.B;

public abstract class A implements B {

        public A () {
                super ();
        }
       
        public void foo() {
               
                System.out.println("Implemented foo");
        }
       
        public abstract void fooA ();

}

Class B :
package com.sample.squid_example.pkg2;

public class B extends A {
       
        public B () {
                super();
        }

        @Override
        public void fooA() {
                System.out.println("in B : fooA");
               
        }

       

}

In Summary,
com.sample.squid_example.pkg2.A implements com.sample.squid_example.pkg1.B
com.sample.squid_example.pkg2.B extends com.sample.squid_example.pkg2.A

The above issue is happening only if the class B from com.sample.squid_example.pkg1 is not available in foo/classes/com/sample/squid_example/pkg1
This is resulting in circular dependency and causing the StackOverflowError error

The below are my project settings

sonar.projectBaseDir=<dir>/foo
sonar.sources=src
sonar.binaries=<dir>/foo/classes
sonar.skipPackageDesign=false

Note - In real time, pkg1 and pkg2 are coming from two different projects and where pkg1 java files/classes are not available for scan.

As a temporary resolution, excluded A.java and the scan is passing.

Perhaps its an issue that the class B is missing (from foo/classes/com/sample/squid_example/pkg1), however I feel the run should report an error and continue rather than completely breaking with a stack overflow.

With Regards,
Vara Prasad.
Reply | Threaded
Open this post in threaded view
|

Re: [sonar-dev] JavaSquidSensor failing with java.lang.StackOverflowError

Nicolas Peru
Hi,
 thanks for your feedback and taking the time to narrow done the issue.

I reproduced the issue with latest version of the plugin.

Issue is due to the unresolved import (because of missing .class file) : B gets wrongly resolved to the class in the same package and you end up in a infinite loop in the symbol resolution.
This is definitely not an easy problem. 

Thanks again.
Cheers,
Nicolas PERU | SonarSource
Senior Developer
http://sonarsource.com


On 9 February 2015 at 11:34, Vara Prasad <[hidden email]> wrote:
Hello,

In one of the projects, iam getting below error (Using
sonar-java-plugin-2.6.jar)

Caused by: java.lang.StackOverflowError
        at
com.google.common.collect.Iterators$13.<init>(Iterators.java:1057)
        at
com.google.common.collect.Iterators.singletonIterator(Iterators.java:1057)
        at
com.google.common.collect.SingletonImmutableList.iterator(SingletonImmutableList.java:55)
        at
com.google.common.collect.SingletonImmutableList.iterator(SingletonImmutableList.java:34)
        at org.sonar.java.resolve.Resolve.findMemberType(Resolve.java:226)
        at org.sonar.java.resolve.Resolve.findMemberType(Resolve.java:221)
        at org.sonar.java.resolve.Resolve.findMemberType(Resolve.java:227)
        at org.sonar.java.resolve.Resolve.findMemberType(Resolve.java:221)
        at org.sonar.java.resolve.Resolve.findMemberType(Resolve.java:227)
        at org.sonar.java.resolve.Resolve.findMemberType(Resolve.java:221)
        at org.sonar.java.resolve.Resolve.findMemberType(Resolve.java:227)
        at org.sonar.java.resolve.Resolve.findMemberType(Resolve.java:221)
        at org.sonar.java.resolve.Resolve.findMemberType(Resolve.java:227)
        at org.sonar.java.resolve.Resolve.findMemberType(Resolve.java:221)
---
---
---

I created a sample to simulate the behaviour from my project

My project is having below structure
foo/src/main/java/com/sample/squid_example/pkg1
foo/src/main/java/com/sample/squid_example/pkg2

In pkg1, there an interface B as below

Interface B :
package com.sample.squid_example.pkg1;

public interface B {

        public void foo ();

}


In pkg2, there are two classes as below

Class A:
package com.sample.squid_example.pkg2;

import com.sample.squid_example.pkg1.B;

public abstract class A implements B {

        public A () {
                super ();
        }

        public void foo() {

                System.out.println("Implemented foo");
        }

        public abstract void fooA ();

}

Class B :
package com.sample.squid_example.pkg2;

public class B extends A {

        public B () {
                super();
        }

        @Override
        public void fooA() {
                System.out.println("in B : fooA");

        }



}

In Summary,
com.sample.squid_example.pkg2.A implements com.sample.squid_example.pkg1.B
com.sample.squid_example.pkg2.B extends com.sample.squid_example.pkg2.A

The above issue is happening only if the class B from
com.sample.squid_example.pkg1 is not available in
foo/classes/com/sample/squid_example/pkg1
This is resulting in circular dependency and causing the StackOverflowError
error

The below are my project settings

sonar.projectBaseDir=<dir>/foo
sonar.sources=src
sonar.binaries=<dir>/foo/classes
sonar.skipPackageDesign=false

Note - In real time, pkg1 and pkg2 are coming from two different projects
and where pkg1 java files/classes are not available for scan.

As a temporary resolution, excluded A.java and the scan is passing.

Perhaps its an issue that the class B is missing (from
foo/classes/com/sample/squid_example/pkg1), however I feel the run should
report an error and continue rather than completely breaking with a stack
overflow.

With Regards,
Vara Prasad.



--
View this message in context: http://sonarqube.15.x6.nabble.com/JavaSquidSensor-failing-with-java-lang-StackOverflowError-tp5032197.html
Sent from the SonarQube Developers mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email