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

ArrayIndexOutOfBoundsException with BitSets #86

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

ArrayIndexOutOfBoundsException with BitSets #86

GoogleCodeExporter opened this issue Mar 29, 2015 · 2 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. write a class that references a java.util.BitSet
2. write/generate hashCode equals methods for that class
3. run equalsverifier
4. you get an ArrayIndexOutOfBoundsException:1 at BitSet.java:1024 with a stack 
trace similar to the following:

java.lang.AssertionError: java.lang.ArrayIndexOutOfBoundsException: 1
For more information, go to: http://www.jqno.nl/equalsverifier/errormessages
    at nl.jqno.equalsverifier.EqualsVerifier.handleError(EqualsVerifier.java:347)
    at nl.jqno.equalsverifier.EqualsVerifier.verify(EqualsVerifier.java:333)
    at com.emovimento.stock.commons.bom.recommendations.RecommendationsTest.equalsContract(RecommendationsTest.java:32)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
    at java.util.BitSet.hashCode(BitSet.java:1024)
    at com.emovimento.stock.commons.bom.recommendations.Recommendations.hashCode(Recommendations.java:86)
    at nl.jqno.equalsverifier.ExamplesChecker.checkHashCode(ExamplesChecker.java:187)
    at nl.jqno.equalsverifier.ExamplesChecker.checkSingle(ExamplesChecker.java:92)
    at nl.jqno.equalsverifier.ExamplesChecker.check(ExamplesChecker.java:67)
    at nl.jqno.equalsverifier.EqualsVerifier.verifyWithExamples(EqualsVerifier.java:385)
    at nl.jqno.equalsverifier.EqualsVerifier.performVerification(EqualsVerifier.java:356)
    at nl.jqno.equalsverifier.EqualsVerifier.verify(EqualsVerifier.java:327)
    ... 25 more


Original issue reported on code.google.com by [email protected] on 4 Oct 2013 at 10:54

@GoogleCodeExporter
Copy link
Author

Nice catch, thanks for reporting this! I will fix this in the next release.

In the mean time, you can use the following workaround:

        BitSet red = BitSet.valueOf(new byte[] {0, 0});
        BitSet black = BitSet.valueOf(new byte[] {1, 1});

        EqualsVerifier.forClass(BitSetContainer.class)
                .withPrefabValues(BitSet.class, red, black)
                .verify();


Regards,
Jan

Original comment by [email protected] on 13 Oct 2013 at 11:11

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

@GoogleCodeExporter
Copy link
Author

I've fixed this issue in version 1.4, which is just released.

Original comment by [email protected] on 27 Dec 2013 at 12:30

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

jqno pushed a commit that referenced this issue Aug 23, 2016
- Adjust article styles to correctly display post indexes
- Remove top margin from page titles
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