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

org.w3c.dom.Element: Cannot inject classes into the bootstrap class loader #174

Closed
phura10 opened this issue Aug 22, 2017 · 3 comments
Closed
Labels

Comments

@phura10
Copy link

phura10 commented Aug 22, 2017

What steps will reproduce the problem?

Running EqualsVerifier on a class with an org.w3c.dom.Element field.

Having an org.w3c.dom.Element in the class make the equals verification fails.

What is the code that triggers this problem?

package org.testequals;

import org.w3c.dom.Element;

public class TestEquals {

    private Element element1;
    private int element2;

    public TestEquals() {
        super();
    }

    public TestEquals(final Element element1, final int element2) {
        super();
        this.element1 = element1;
        this.element2 = element2;
    }

    public Element getElement1() {
        return this.element1;
    }

    public void setElement1(final Element element1) {
        this.element1 = element1;
    }

    public int getElement2() {
        return this.element2;
    }

    public void setElement2(final int element2) {
        this.element2 = element2;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = (prime * result) + ((this.element1 == null) ? 0 : this.element1.hashCode());
        result = (prime * result) + this.element2;
        return result;
    }

    @Override
    public boolean equals(final Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final TestEquals other = (TestEquals) obj;
        if (this.element1 == null) {
            if (other.element1 != null) {
                return false;
            }
        } else if (!this.element1.equals(other.element1)) {
            return false;
        }
        if (this.element2 != other.element2) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "TestEquals [element1=" + this.element1 + ", element2=" + this.element2 + "]";
    }

}

What error message or stack trace does EqualsVerifier give?

java.lang.AssertionError: IllegalArgumentException: Cannot inject classes into the bootstrap class loader
For more information, go to: http://www.jqno.nl/equalsverifier/errormessages
            at nl.jqno.equalsverifier.EqualsVerifier.handleError(EqualsVerifier.java:389)
            at nl.jqno.equalsverifier.EqualsVerifier.verify(EqualsVerifier.java:378)
            at org.testequals.POJOUnitTest.testEqualsMethod(POJOUnitTest.java:179)
            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:497)
            at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
            at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
            at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
            at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
            at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
            at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
            at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
            at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
            at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
            at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
            at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
            at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
            at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
            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:459)
            at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
            at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
            at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: java.lang.IllegalArgumentException: Cannot inject classes into the bootstrap class loader
            at nl.jqno.equalsverifier.internal.lib.bytebuddy.dynamic.loading.ClassInjector$UsingReflection.<init>(ClassInjector.java:129)
            at nl.jqno.equalsverifier.internal.lib.bytebuddy.dynamic.loading.ClassLoadingStrategy$Default$InjectionDispatcher.load(ClassLoadingStrategy.java:184)
            at nl.jqno.equalsverifier.internal.lib.bytebuddy.dynamic.TypeResolutionStrategy$Passive.initialize(TypeResolutionStrategy.java:79)
            at nl.jqno.equalsverifier.internal.lib.bytebuddy.dynamic.DynamicType$Default$Unloaded.load(DynamicType.java:4376)
            at nl.jqno.equalsverifier.internal.reflection.Instantiator.giveDynamicSubclass(Instantiator.java:102)
            at nl.jqno.equalsverifier.internal.reflection.Instantiator.of(Instantiator.java:62)
            at nl.jqno.equalsverifier.internal.reflection.ClassAccessor.buildObjectAccessor(ClassAccessor.java:340)
            at nl.jqno.equalsverifier.internal.reflection.ClassAccessor.getRedAccessor(ClassAccessor.java:269)
            at nl.jqno.equalsverifier.internal.reflection.ClassAccessor.getRedObject(ClassAccessor.java:257)
            at nl.jqno.equalsverifier.internal.prefabvalues.factories.FallbackFactory.giveInstances(FallbackFactory.java:99)
            at nl.jqno.equalsverifier.internal.prefabvalues.factories.FallbackFactory.createValues(FallbackFactory.java:54)
            at nl.jqno.equalsverifier.internal.prefabvalues.PrefabValues.createTuple(PrefabValues.java:170)
            at nl.jqno.equalsverifier.internal.prefabvalues.PrefabValues.realizeCacheFor(PrefabValues.java:153)
            at nl.jqno.equalsverifier.internal.prefabvalues.factories.FallbackFactory.traverseFields(FallbackFactory.java:92)
            at nl.jqno.equalsverifier.internal.prefabvalues.factories.FallbackFactory.createValues(FallbackFactory.java:53)
            at nl.jqno.equalsverifier.internal.prefabvalues.PrefabValues.createTuple(PrefabValues.java:170)
            at nl.jqno.equalsverifier.internal.prefabvalues.PrefabValues.realizeCacheFor(PrefabValues.java:153)
            at nl.jqno.equalsverifier.internal.prefabvalues.PrefabValues.giveTuple(PrefabValues.java:101)
            at nl.jqno.equalsverifier.internal.prefabvalues.PrefabValues.giveRed(PrefabValues.java:78)
            at nl.jqno.equalsverifier.internal.checkers.AbstractDelegationChecker.check(AbstractDelegationChecker.java:53)
            at nl.jqno.equalsverifier.EqualsVerifier.verifyWithoutExamples(EqualsVerifier.java:413)
            at nl.jqno.equalsverifier.EqualsVerifier.performVerification(EqualsVerifier.java:399)
            at nl.jqno.equalsverifier.EqualsVerifier.verify(EqualsVerifier.java:372)
            ... 24 more

What did you expect?

The test ending without errors.

Which version of EqualsVerifier are you using?

2.3.2

Please provide any additional information below.

The test to have this error is:

@Test
    public void testEqualsMethod() {

        EqualsVerifier.forClass(TestEquals.class).usingGetClass()
                .suppress(Warning.NONFINAL_FIELDS).verify();

    }

Thank you for your time.

jqno added a commit that referenced this issue Aug 23, 2017
@jqno jqno added the accepted label Aug 23, 2017
@jqno
Copy link
Owner

jqno commented Aug 23, 2017

Thanks for letting me know about this. I've reproduced and fixed the issue.
I'll make a release of it some time later this week.

@phura10
Copy link
Author

phura10 commented Aug 23, 2017

Thank you for the quick answer and resolution! I will use that new release when it were ready.

@jqno
Copy link
Owner

jqno commented Aug 24, 2017

Version 2.3.3 is ready for you!

@jqno jqno closed this as completed Aug 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants