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

Regression in Equalsverifier 1.7: java.lang.NoClassDefFoundError #105

Closed
GoogleCodeExporter opened this issue Mar 29, 2015 · 4 comments
Closed

Comments

@GoogleCodeExporter
Copy link

Hi Jan,

I saw you just released version 1.7. Immediately gave it a spin and found that
a number of our tests started failing. The following is a minimal reproduction
case of the issue:

    ===========================================================================
    package com.example;

    import java.util.Comparator;
    import nl.jqno.equalsverifier.EqualsVerifier;
    import org.testng.annotations.Test;

    public final class RegressionTest {
        static final class ProblematicClass {
            private static final Comparator<ProblematicClass> COMPARATOR = Comparator.comparing(o -> 0);

            @Override
            public boolean equals(final Object other) {
                return other instanceof ProblematicClass;
            }

            @Override
            public int hashCode() {
                return 0;
            }
        }

        @Test(groups = "unit")
        public void testEqualsAndHashCodeContract() {
            EqualsVerifier.forClass(ProblematicClass.class).verify();
        }
    }
    ===========================================================================

This is the stacktrace:

java.lang.AssertionError: java.lang.NoClassDefFoundError: 
java/util/Comparator$$Lambda$8/433874882
For more information, go to: http://www.jqno.nl/equalsverifier/errormessages
    at nl.jqno.equalsverifier.EqualsVerifier.handleError(EqualsVerifier.java:414)
    at nl.jqno.equalsverifier.EqualsVerifier.verify(EqualsVerifier.java:400)
    at com.example.RegressionTest.testEqualsAndHashCodeContract(RegressionTest.java:26)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
    at org.testng.TestRunner.privateRun(TestRunner.java:767)
    at org.testng.TestRunner.run(TestRunner.java:617)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
    at org.testng.SuiteRunner.run(SuiteRunner.java:240)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
    at org.testng.TestNG.run(TestNG.java:1057)
    at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
Caused by: java.lang.NoClassDefFoundError: 
java/util/Comparator$$Lambda$8/433874882
    at sun.reflect.GeneratedSerializationConstructorAccessor12.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
    at nl.jqno.equalsverifier.internal.objenesis.instantiator.sun.SunReflectionFactoryInstantiator.newInstance(SunReflectionFactoryInstantiator.java:45)
    at nl.jqno.equalsverifier.internal.objenesis.ObjenesisBase.newInstance(ObjenesisBase.java:73)
    at nl.jqno.equalsverifier.util.Instantiator.instantiate(Instantiator.java:71)
    at nl.jqno.equalsverifier.util.ObjectAccessor.copy(ObjectAccessor.java:94)
    at nl.jqno.equalsverifier.FieldsChecker$ReflexivityFieldCheck.checkValueReflexivity(FieldsChecker.java:297)
    at nl.jqno.equalsverifier.FieldsChecker$ReflexivityFieldCheck.execute(FieldsChecker.java:279)
    at nl.jqno.equalsverifier.FieldInspector.check(FieldInspector.java:37)
    at nl.jqno.equalsverifier.FieldsChecker.check(FieldsChecker.java:62)
    at nl.jqno.equalsverifier.EqualsVerifier.verifyWithExamples(EqualsVerifier.java:460)
    at nl.jqno.equalsverifier.EqualsVerifier.performVerification(EqualsVerifier.java:427)
    at nl.jqno.equalsverifier.EqualsVerifier.verify(EqualsVerifier.java:394)
    ... 25 more

Original issue reported on code.google.com by [email protected] on 4 Mar 2015 at 7:33

@GoogleCodeExporter
Copy link
Author

Hi Stephan,

Thanks for letting me know! I've reproduced the problem. I'll try to fix it 
soon.


Jan

Original comment by [email protected] on 4 Mar 2015 at 8:24

  • Changed state: Accepted
  • Added labels: ****
  • Removed labels: ****

@GoogleCodeExporter
Copy link
Author

Hi Stephan,

Nice catch. The Comparator object was actually a lambda object. EqualsVerifier 
tried to clone it, but was unable to because it's actually a synthetic class.

Anyway, I just released a fix in version 1.7.1.

Original comment by [email protected] on 11 Mar 2015 at 3:15

  • Changed state: Fixed
  • Added labels: ****
  • Removed labels: ****

@GoogleCodeExporter
Copy link
Author

Cool. Upgraded and can confirm my tests now all pass again, as with version 
1.6. Thanks!

Original comment by [email protected] on 11 Mar 2015 at 4:33

  • Added labels: ****
  • Removed labels: ****

@GoogleCodeExporter
Copy link
Author

Thanks for the update! I'm glad to hear it.

Original comment by [email protected] on 11 Mar 2015 at 5:13

  • Added labels: ****
  • Removed labels: ****

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant