AbstractMethodError and JodaTime

80 views
Skip to first unread message

Gerson K.

unread,
Jun 6, 2011, 3:59:27 PM6/6/11
to equalsverifier
Why do I get the following error message?

java.lang.AssertionError: java.lang.AbstractMethodError:
org.joda.time.Chronology.year()Lorg/joda/time/DateTimeField;
For more information, go to: http://code.google.com/p/equalsverifier/wiki/ErrorMessages
at nl.jqno.equalsverifier.util.Assert.fail(Assert.java:96)
at
nl.jqno.equalsverifier.EqualsVerifier.handleError(EqualsVerifier.java:
330)
at nl.jqno.equalsverifier.EqualsVerifier.verify(EqualsVerifier.java:
316)

Jan Ouwens

unread,
Jun 6, 2011, 4:06:40 PM6/6/11
to equalsv...@googlegroups.com
Hi Gerson,

I'm sorry, I don't really have time to investigate this right now;
I'll have to get back to you later this week. In the mean time, can
you show me how you call EqualsVerifier? And maybe post the stacktrace
that's printed when you add .debug() to the call?


Jan

Jan Ouwens

unread,
Jun 13, 2011, 5:38:52 AM6/13/11
to equalsverifier
Hello Gerson,

I've looked at your issue. I can't know for sure I tried the same
thing you dit until I've seen how you actually call EqualsVerifier,
but I did it as follows:

EqualsVerifier.forClass(DateTime.class)
.suppress(Warning.NULL_FIELDS)
.verify();

This way I get an error message that looks a lot like yours.

The call fails on an internal Chronology field. Chronology defines
loads of abstract methods, some of which are called in formatters that
are used in toString methods. Probably EqualsVerifier has found some
problem, and while formatting the error message, it calls the
toString, which throws this error.
EV instantiates objects using reflection instead of via the new
keyword, so objects may not be in a valid state. In most cases this
doesn't matter for testing the equals method, but JodaTime is more
complex.

Fortunately, EV does work on classes that have a JodaTime DateTime
object as an instance field. So I'm assuming you were, in fact,
testing the framework, is that correct?


Regards,
Jan

Karen Christenson

unread,
Jun 21, 2011, 12:41:29 PM6/21/11
to equalsv...@googlegroups.com
Sorry for the very late response.

This is what I tried:
    public void testEqualsContract() {       
        String s1 = "a";
        String s2 = "b";
        String s3 = "c";
        EqualsVerifier.forExamples(s1, s2, s3).verify();
    }

Here is the stacktrace:
java.lang.AssertionError: equals throws ArrayIndexOutOfBoundsException when field value is null.

For more information, go to: http://code.google.com/p/equalsverifier/wiki/ErrorMessages
    at nl.jqno.equalsverifier.util.Assert.fail(Assert.java:96)
    at nl.jqno.equalsverifier.EqualsVerifier.handleError(EqualsVerifier.java:330)
    at nl.jqno.equalsverifier.EqualsVerifier.verify(EqualsVerifier.java:310)
    at gov.fns.platform.common.domain.CommentValueObjectTest.testEqualsContract(CommentValueObjectTest.java:41)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at junit.framework.TestCase.runTest(TestCase.java:154)
    at junit.framework.TestCase.runBare(TestCase.java:127)
    at junit.framework.TestResult$1.protect(TestResult.java:106)
    at junit.framework.TestResult.runProtected(TestResult.java:124)
    at junit.framework.TestResult.run(TestResult.java:109)
    at junit.framework.TestCase.run(TestCase.java:118)
    at junit.framework.TestSuite.runTest(TestSuite.java:208)
    at junit.framework.TestSuite.run(TestSuite.java:203)
    at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

Jan Ouwens

unread,
Jun 21, 2011, 4:43:11 PM6/21/11
to equalsv...@googlegroups.com
Hi Karen,

As I already mentioned[1], EqualsVerifier can't deal with the smart
tricks that String employs. EV aims at the "average case" equals
method, and String is simply not average case.

Of course I could adapt EV to always pass if it's asked to verify
String, but that just seems silly :).


Regards,
Jan

[1] see http://groups.google.com/group/equalsverifier/msg/01fa778e7d88d525

Karen Christenson

unread,
Jun 24, 2011, 12:29:56 PM6/24/11
to equalsv...@googlegroups.com
Sorry I missed you earlier reply.

Does your FAQ include any caution about the limitations about using EV to test strings or how it tests strings? That would be useful.

Thanks.

Jan Ouwens

unread,
Jun 27, 2011, 5:05:58 PM6/27/11
to equalsv...@googlegroups.com
Hi Karen,

In fact, the FAQ does include that :). But I agree it's a bit hard to
find. I've added an extra entry for java.lang.String to the FAQ to
make it more easily accessible.


Regards,
Jan

Reply all
Reply to author
Forward
0 new messages