Skip to content

Creating a Fake of a class with an inner class causes an IncompatibleClassChangeError #558

@lstreepy

Description

@lstreepy

Please provide the following information:

  • Version of JMockit that was used:
    JMockit 1.38 (also tested against 1.39 and 1.41)
    Gradle 4.8
    JVM: 1.8.0_152 (Oracle Corporation 25.152-b16)
    OS: Windows 7 6.1 amd64
    TestNG: 6.8

  • Description of the problem:

Producing a Fake of a class with an inner class causes an IncompatibleClassChangeError, this is the actual error message:
java.lang.IncompatibleClassChangeError: reproducer.InnerClassesTests$Base and reproducer.InnerClassesTests$Base$InnerClass disagree on InnerClasses attribute

This failure cam into being at version 1.38, and still appears to exist in 1.41.

This appears to be a regression, as it previously worked on JMockit version 1.21.

Here's a quick reproducer:

package reproducer;

import mockit.Mock;
import mockit.MockUp;
import org.testng.annotations.Test;

/**
 * Test to show that producing a Fake of a class with an inner class causes an IncompatibleClassChangeError.
 * This failure came into being at version 1.38, and still appears to exist in 1.41.
 */
public class InnerClassesTests
{
    public static class Base
    {
        void doSomething()
        {
        }

        class InnerClass
        {
        }
    }

    @Test
    public void testInnerClassFailure()
    {
        new MockUp<Base>()
        {
            @Mock
            void doSomething()
            {
                // Just need to get the class processed
            }
        };

        Base.InnerClass.class.getDeclaringClass(); // causes IncompatibleClassChangeError
    }
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions