siom79 / japicmp

Comparison of two versions of a jar archive
https://siom79.github.io/japicmp
Apache License 2.0
701 stars 107 forks source link

StackOverflow exception on a code analysis #309

Closed jrfaller closed 2 years ago

jrfaller commented 2 years ago

Hi!

When trying to analyze a project of mine I run over a StackOverflow exception. Here is the config:

I think I have managed to devise a test case that reproduces the problem, as follows:

@Test
    public void testStackOverflow() throws Exception {
        JarArchiveComparatorOptions jarArchiveComparatorOptions = new JarArchiveComparatorOptions();
        jarArchiveComparatorOptions.setAccessModifier(AccessModifier.PRIVATE);
        List<JApiClass> jApiClasses = ClassesHelper.compareClasses(jarArchiveComparatorOptions, new ClassesHelper.ClassesGenerator() {
            @Override
            public List<CtClass> createOldClasses(ClassPool classPool) throws Exception {
                CtClass superInterface = CtInterfaceBuilder.create().name("I").addToClassPool(classPool);
                CtMethodBuilder.create().returnType(CtClass.voidType).publicAccess().abstractMethod().name("method").addToClass(superInterface);
                CtClass subClass = CtClassBuilder.create().name("C").implementsInterface(superInterface).addToClassPool(classPool);
                return Arrays.asList(superInterface, subClass);
            }

            @Override
            public List<CtClass> createNewClasses(ClassPool classPool) throws Exception {
                CtClass superInterface = CtInterfaceBuilder.create().name("C").addToClassPool(classPool);
                CtMethodBuilder.create().returnType(CtClass.voidType).publicAccess().abstractMethod().name("method").addToClass(superInterface);
                CtClass subClass = CtClassBuilder.create().name("I").implementsInterface(superInterface).addToClassPool(classPool);
                return Arrays.asList(superInterface, subClass);
            }
        });
        JApiClass jApiClass = getJApiClass(jApiClasses, "I");
        JApiMethod jApiMethod = getJApiMethod(jApiClass.getMethods(), "method");
    }

Cheers!

siom79 commented 2 years ago

Fixed: 0.15.5

jrfaller commented 2 years ago

Awesome, thanks a lot!!