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

Illegal reflective access #336

Closed
klitoskyriacou opened this issue Aug 18, 2020 · 2 comments
Closed

Illegal reflective access #336

klitoskyriacou opened this issue Aug 18, 2020 · 2 comments

Comments

@klitoskyriacou
Copy link

What steps will reproduce the problem?

Calling EqualsVerifier.forClass(TestClass.class).verify();

What is the code that triggers this problem?

Any class that contains a java.net.InetSocketAddress as a field.

Provide an example of a complete class (equals method, hashCode method, relevant fields) and a call to EqualsVerifier.

import nl.jqno.equalsverifier.EqualsVerifier;
import org.junit.Test;

import java.net.InetSocketAddress;

public class EVTest {

static final class TestClass {
    private final InetSocketAddress socketAddress;
    public TestClass(InetSocketAddress socketAddress) {
        this.socketAddress = socketAddress;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        TestClass testClass = (TestClass) o;
        return socketAddress != null ? socketAddress.equals(testClass.socketAddress) : testClass.socketAddress == null;
    }

    @Override
    public int hashCode() {
        return socketAddress != null ? socketAddress.hashCode() : 0;
    }
}

@Test
public void testEqualsAndHashCode() {
    EqualsVerifier.forClass(TestClass.class).verify();
}

}

What error message or stack trace does EqualsVerifier give?

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by nl.jqno.equalsverifier.internal.reflection.FieldAccessor (file:/.../equalsverifier-3.4.1.jar) to field java.net.InetSocketAddress$InetSocketAddressHolder.hostname
WARNING: Please consider reporting this to the maintainers of nl.jqno.equalsverifier.internal.reflection.FieldAccessor
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

What did you expect?

No such warning.

Which version of EqualsVerifier are you using?

3.4.1

Please provide any additional information below.

@klitoskyriacou
Copy link
Author

btw, using Java 14. But issue is probably reproducible from Java 9 onwards.

@jqno
Copy link
Owner

jqno commented Aug 20, 2020

I've just released a new version, 3.4.2, which adds a prefab value for this.

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

No branches or pull requests

2 participants