Skip to content

Parsing bug with sealed interfaces / StackOverflowError #272

@kmartin88

Description

@kmartin88

Hi

we ran into a problem with qdox leading to a StackOverflowError when calling the method isA(String fullyQualifiedName) on an instance of DefaultJavaClass. This was happening because this instance contained a reference to itself in its implementz list.

We looked a bit further as to why this is happening and found out that the parser does something weird in combination with sealed interfaces.
With this code:

public class Outer {
    public sealed interface TheInterface permits Subclass1, Subclass2, Subclass3 {

    }

    public static non-sealed class Subclass1 implements TheInterface {

    }

    public static non-sealed class Subclass2 implements TheInterface {

    }

    public static non-sealed class Subclass3 implements TheInterface {

    }

}

and then creating a JavaProjectBuilder with the source directory of this file added to the source tree, calling getClasses on the resulting JavaProjectBuilder you get 5 objects of type JavaClass:

  • Outer
  • TheInterface
  • Subclass1
  • Subclass2
  • Subclass3

The list called implementz of Subclass1 has a size of 4, containing references to TheInterface, Subclass1, Subclass2, Subclass3. The other ones seem to be correct, only having TheInterface as parent. It seems to only affect the first class coming after the interface.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions