Skip to content

fix: use equals() instead of == to compare Method instances#84

Open
vpa1977 wants to merge 1 commit intomstrobel:developfrom
vpa1977:use_equals
Open

fix: use equals() instead of == to compare Method instances#84
vpa1977 wants to merge 1 commit intomstrobel:developfrom
vpa1977:use_equals

Conversation

@vpa1977
Copy link

@vpa1977 vpa1977 commented Feb 10, 2026

Building procyon with Java 25 results in the following failure:

com.strobel.reflection.SignatureTests > testSignatureOfGenericMethodInGenericDefinition FAILED
org.junit.ComparisonFailure: expected:<<T:Ljava/lang/Object;>[TT;> but was:<[TT;>
at org.junit.Assert.assertEquals(Assert.java:117)
at org.junit.Assert.assertEquals(Assert.java:146)
at com.strobel.reflection.SignatureTests.testSignatureOfGenericMethodInGenericDefinition(SignatureTests.java:71)

This is caused by == used instead of equals() to compare Method instances. java.lang.reflect does not guarantee that Method instances are singletons.

Building procyon with Java 25 results in the following failure:

com.strobel.reflection.SignatureTests > testSignatureOfGenericMethodInGenericDefinition FAILED
    org.junit.ComparisonFailure: expected:<[<T:Ljava/lang/Object;>]([TT;)[TT;> but was:<[]([TT;)[TT;>
        at org.junit.Assert.assertEquals(Assert.java:117)
        at org.junit.Assert.assertEquals(Assert.java:146)
        at com.strobel.reflection.SignatureTests.testSignatureOfGenericMethodInGenericDefinition(SignatureTests.java:71)

This is caused by == used instead of equals() to compare Method instances.
java.lang.reflect does not guarantee that Method instances are singletons.
@vpa1977 vpa1977 changed the title fix: use equals() instead of == to compare Method fix: use equals() instead of == to compare Method instances Feb 10, 2026
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

Successfully merging this pull request may close these issues.

1 participant