equalsverifier: ReflectionException: Cannot read class file for some JDK9 classes

What steps will reproduce the problem?

Run JOSM JUnit tests with JDK9: https://josm.openstreetmap.de/jenkins/job/Java-EarlyAccess-JOSM/jdk=JDK9/lastCompletedBuild/testReport/

What is the code that triggers this problem? (first case)

@FunctionalInterface
public interface Destroyable {
    void destroy();
}

public abstract class JosmAction extends javax.swing.AbstractAction implements Destroyable {
}

public class CombineWayAction extends JosmAction {

    /**
     * A pair of nodes.
     */
    public static class NodePair {
        private final Node a;
        private final Node b;

        /**
         * Constructs a new {@code NodePair}.
         * @param a The first node
         * @param b The second node
         */
        public NodePair(Node a, Node b) {
            this.a = a;
            this.b = b;
        }

        @Override
        public int hashCode() {
            return Objects.hash(a, b);
        }

        @Override
        public boolean equals(Object obj) {
            if (this == obj) return true;
            if (obj == null || getClass() != obj.getClass()) return false;
            NodePair nodePair = (NodePair) obj;
            return Objects.equals(a, nodePair.a) && Objects.equals(b, nodePair.b);
        }
    }
}

    /**
     * Unit test of methods {@link NodePair#equals} and {@link NodePair#hashCode}.
     */
    @Test
    public void testEqualsContract() {
        EqualsVerifier.forClass(NodePair.class).usingGetClass()
            .withPrefabValues(Node.class, new Node(1), new Node(2))
            .verify();
    }

What is the code that triggers this problem? (second case)

public class ExtensionFileFilter extends javax.swing.filechooser.FileFilter implements java.io.FileFilter {

    private final String extensions;
    private final String description;
    private final String defaultExtension;

    @Override
    public int hashCode() {
        return Objects.hash(extensions, description, defaultExtension);
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) return true;
        if (obj == null || getClass() != obj.getClass()) return false;
        ExtensionFileFilter that = (ExtensionFileFilter) obj;
        return Objects.equals(extensions, that.extensions) &&
               Objects.equals(description, that.description) &&
               Objects.equals(defaultExtension, that.defaultExtension);
    }
}

    /**
     * Unit test of methods {@link ExtensionFileFilter#equals} and {@link ExtensionFileFilter#hashCode}.
     */
    @Test
    public void testEqualsContract() {
        EqualsVerifier.forClass(ExtensionFileFilter.class).usingGetClass()
            .verify();
    }

What error message or stack trace does EqualsVerifier give?

junit.framework.AssertionFailedError: ReflectionException: Cannot read class file for AbstractAction.
Suppress Warning.ANNOTATION to skip annotation processing phase.
    at nl.jqno.equalsverifier.EqualsVerifier.handleError(EqualsVerifier.java:381)
    at nl.jqno.equalsverifier.EqualsVerifier.verify(EqualsVerifier.java:370)
    at org.openstreetmap.josm.actions.CombineWayActionTest.testEqualsContract(CombineWayActionTest.java:67)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(java.base@9-ea/Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(java.base@9-ea/NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(java.base@9-ea/DelegatingMethodAccessorImpl.java:43)

junit.framework.AssertionFailedError: ReflectionException: Cannot read class file for FileFilter.
Suppress Warning.ANNOTATION to skip annotation processing phase.
    at nl.jqno.equalsverifier.EqualsVerifier.handleError(EqualsVerifier.java:381)
    at nl.jqno.equalsverifier.EqualsVerifier.verify(EqualsVerifier.java:370)
    at org.openstreetmap.josm.actions.ExtensionFileFilterTest.testEqualsContract(ExtensionFileFilterTest.java:45)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(java.base@9-ea/Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(java.base@9-ea/NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(java.base@9-ea/DelegatingMethodAccessorImpl.java:43)

What did you expect?

Test success, like with JDK8

Which version of EqualsVerifier are you using?

2.1.5

Please provide any additional information below.

Complete source code: https://josm.openstreetmap.de/browser/josm/trunk/src/org/openstreetmap/josm/actions/CombineWayAction.java https://josm.openstreetmap.de/browser/josm/trunk/src/org/openstreetmap/josm/actions/ExtensionFileFilter.java

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 19 (19 by maintainers)

Commits related to this issue

Most upvoted comments

Again, thanks for the heads-up; we’ve been waiting for this for quite a while 😃. I’ll try it out this weekend!