Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
lstreepy opened this issue Oct 24, 2018 · 0 comments
Assignees
Labels

Comments

@lstreepy
Copy link

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
    }
}
@rliesenfeld rliesenfeld self-assigned this Oct 25, 2018
@jmockit jmockit locked and limited conversation to collaborators Apr 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests

2 participants