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

InetAddress: Cannot inject classes into the bootstrap class loader #168

Closed
MrCreosote opened this issue Apr 3, 2017 · 3 comments
Closed
Labels

Comments

@MrCreosote
Copy link

What steps will reproduce the problem?

Running EqualsVerifier on a class with an InetAddress field.

Changing the code below to wrap a String vs. an InetAddress makes the test pass.

What is the code that triggers this problem?

import java.net.InetAddress;

import nl.jqno.equalsverifier.EqualsVerifier;

public class TempTest {

	final InetAddress ia;

	private TempTest(InetAddress ia) {
		this.ia = ia;
	}

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

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		TempTest other = (TempTest) obj;
		if (ia == null) {
			if (other.ia != null) {
				return false;
			}
		} else if (!ia.equals(other.ia)) {
			return false;
		}
		return true;
	}
	
	public static void main(String[] args) {
		EqualsVerifier.forClass(TempTest.class).usingGetClass().verify();
	}
	
}

What error message or stack trace does EqualsVerifier give?

Exception in thread "main" 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:355)
	at nl.jqno.equalsverifier.EqualsVerifier.verify(EqualsVerifier.java:344)
	at TempTest.main(TempTest.java:46)
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.jav
a:127)
	at nl.jqno.equalsverifier.internal.lib.bytebuddy.dynamic.loading.ClassLoadingStrategy$Default$InjectionDispatcher.load(
ClassLoadingStrategy.java:184)
	at nl.jqno.equalsverifier.internal.lib.bytebuddy.dynamic.loading.ClassLoadingStrategy$Default.load(ClassLoadingStrategy
.java:120)
	at nl.jqno.equalsverifier.internal.lib.bytebuddy.dynamic.TypeResolutionStrategy$Passive.initialize(TypeResolutionStrate
gy.java:79)
	at nl.jqno.equalsverifier.internal.lib.bytebuddy.dynamic.DynamicType$Default$Unloaded.load(DynamicType.java:4352)
	at nl.jqno.equalsverifier.internal.Instantiator.giveDynamicSubclass(Instantiator.java:98)
	at nl.jqno.equalsverifier.internal.Instantiator.of(Instantiator.java:58)
	at nl.jqno.equalsverifier.internal.ClassAccessor.buildObjectAccessor(ClassAccessor.java:334)
	at nl.jqno.equalsverifier.internal.ClassAccessor.getRedAccessor(ClassAccessor.java:263)
	at nl.jqno.equalsverifier.internal.ClassAccessor.getRedObject(ClassAccessor.java:251)
	at nl.jqno.equalsverifier.internal.prefabvalues.factories.FallbackFactory.giveInstances(FallbackFactory.java:98)
	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.factories.AbstractReflectiveGenericFactory.determineAndCacheActualTypeT
ag(AbstractReflectiveGenericFactory.java:61)
	at nl.jqno.equalsverifier.internal.prefabvalues.factories.AbstractReflectiveGenericFactory.determineAndCacheActualTypeT
ag(AbstractReflectiveGenericFactory.java:52)
	at nl.jqno.equalsverifier.internal.prefabvalues.factories.CollectionFactory.createValues(CollectionFactory.java:36)
	at nl.jqno.equalsverifier.internal.prefabvalues.PrefabValues.createTuple(PrefabValues.java:166)
	at nl.jqno.equalsverifier.internal.prefabvalues.PrefabValues.realizeCacheFor(PrefabValues.java:153)
	at nl.jqno.equalsverifier.internal.prefabvalues.factories.FallbackFactory.traverseFields(FallbackFactory.java:91)
	at nl.jqno.equalsverifier.internal.prefabvalues.factories.FallbackFactory.createValues(FallbackFactory.java:52)
	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:91)
	at nl.jqno.equalsverifier.internal.prefabvalues.factories.FallbackFactory.createValues(FallbackFactory.java:52)
	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.AbstractDelegationChecker.check(AbstractDelegationChecker.java:51)
	at nl.jqno.equalsverifier.EqualsVerifier.verifyWithoutExamples(EqualsVerifier.java:379)
	at nl.jqno.equalsverifier.EqualsVerifier.performVerification(EqualsVerifier.java:365)
	at nl.jqno.equalsverifier.EqualsVerifier.verify(EqualsVerifier.java:338)
	... 1 more

What did you expect?

The test to pass.

Which version of EqualsVerifier are you using?

2.2.1

Please provide any additional information below.

None. Thanks yet again for EV, it's great.

@jqno jqno added the accepted label Apr 3, 2017
@jqno
Copy link
Owner

jqno commented Apr 3, 2017

Thanks for the detailed report. I was able to reproduce it. I'll let you know as soon as I have a fix.

@jqno
Copy link
Owner

jqno commented Apr 3, 2017

I've just released version 2.2.2, which contains a fix.

@jqno jqno closed this as completed Apr 3, 2017
@MrCreosote
Copy link
Author

Wow, that's quite the response time there. Thanks! I'll try it out when it's up on maven repo.

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