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

Java 9+ Illegal reflective access on java.time.OffsetDateTime #217

Closed
eggilbert opened this issue Oct 30, 2018 · 4 comments
Closed

Java 9+ Illegal reflective access on java.time.OffsetDateTime #217

eggilbert opened this issue Oct 30, 2018 · 4 comments
Labels

Comments

@eggilbert
Copy link
Contributor

I stumbled across another instance of #214 and friends for java.time.OffsetDateTime 😿

It looks like most of the java.time package has prefab values already (like LocalDateTime and ZonedDateTime), but not the OffsetXYZ variants. Can these be added?

Apologies for creating another issue here. I was running things with --illegal-access=warn before reporting #214 to try and include everything at once, but either I wasn't using java.time.OffsetDateTime yet at the time or somehow missed it in the output. I was surprised when there were still warnings after pulling in the new 3.0.1 release.

What steps will reproduce the problem?

Use EqualsVerifier on a class containing java.time.OffsetDateTime.

What is the code that triggers this problem?

package my.company;

import nl.jqno.equalsverifier.EqualsVerifier;
import nl.jqno.equalsverifier.Warning;
import org.junit.jupiter.api.Test;

import java.time.OffsetDateTime;
import java.util.Objects;

class OffsetDateTimeTest {
    static class POJO {
        private OffsetDateTime field;

        public OffsetDateTime getField() {
            return field;
        }

        public void setField(OffsetDateTime field) {
            this.field = field;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            POJO pojo = (POJO) o;
            return Objects.equals(field, pojo.field);
        }

        @Override
        public int hashCode() {
            return Objects.hash(field);
        }
    }

    @Test
    void equalsContract() {
        EqualsVerifier.forClass(POJO.class)
            .usingGetClass()
            .suppress(Warning.NONFINAL_FIELDS)
            .verify();
    }
}

What error message or stack trace does EqualsVerifier give?

WARNING: Illegal reflective access by nl.jqno.equalsverifier.internal.reflection.FieldAccessor (...) to field java.time.OffsetDateTime.dateTime
WARNING: Illegal reflective access by nl.jqno.equalsverifier.internal.reflection.FieldAccessor (...) to field java.time.OffsetDateTime.offset

What did you expect?

No compiler warnings emitted

Which version of EqualsVerifier are you using?

3.0.1

Please provide any additional information below.

Running on OpenJDK 11

@jqno
Copy link
Owner

jqno commented Oct 30, 2018

Thanks for letting me know about this! I don't mind the extra issue.

However, I still have a lot of things going on so I might not get to it super quickly. (PRs are always welcome though 😉)

@jqno jqno added the accepted label Oct 30, 2018
jqno pushed a commit that referenced this issue Oct 31, 2018
Add prefab values for other java.time classes
@jqno
Copy link
Owner

jqno commented Oct 31, 2018

Thanks for the PR! I'll try to squeeze in a release in the next few days.

@eggilbert
Copy link
Contributor Author

Thanks, that would be great 👍

@jqno
Copy link
Owner

jqno commented Oct 31, 2018

Released! 🎉

@jqno jqno closed this as completed Oct 31, 2018
akhalikov pushed a commit to akhalikov/equalsverifier that referenced this issue Nov 6, 2019
akhalikov pushed a commit to akhalikov/equalsverifier that referenced this issue Nov 6, 2019
Add prefab values for other java.time classes
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