You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PreferJavaUtilObjectsEquals does not check for existing equals method #434
What is the smallest, simplest way to reproduce the problem?
I haven't compiled this, but I hope the point gets across: the unconditional static import of java.util.Objects.equals is shadowed by the existing equals method
With the example above I see one equals(Object) method and an import of an equals(Object, Object) method, that I think would not clash here because of the differing number of arguments; Does your experience there differ?
I found the original code again! The number of arguments does seem to be an issue for Java, the (IntelliJ) error message is "Expected 1 arguments but found 2", so I assume java cannot handle the same method name, defined in a class and statically imported from somewhere else with a different number of parameters.
Maven error is:
[ERROR] /C:/Users/.../A.java:[63,16] method equals in class com.myorg.A cannot be applied to given types;
required: java.lang.Object
found: com.myorg.Foo,com.myorg.Foo
reason: actual and formal argument lists differ in length
I've observed this in the original code with a custom type (Foo) and Strings. I hope this helps, let me know if you can't reproduce this.
Activity
Support NewClass in MethodMatcher and ChangeMethodName
timtebeek commentedon May 6, 2024
Hi! Thanks for the report; I'm looking at your samples and how we've implemented this recipe
rewrite-migrate-java/src/main/resources/META-INF/rewrite/no-guava.yml
Lines 189 to 194 in c82c73a
With the example above I see one
equals(Object)method and an import of anequals(Object, Object)method, that I think would not clash here because of the differing number of arguments; Does your experience there differ?timo-abele commentedon May 6, 2024
I found the original code again! The number of arguments does seem to be an issue for Java, the (IntelliJ) error message is "Expected 1 arguments but found 2", so I assume java cannot handle the same method name, defined in a class and statically imported from somewhere else with a different number of parameters.
Maven error is:
I've observed this in the original code with a custom type (Foo) and Strings. I hope this helps, let me know if you can't reproduce this.
Support NewClass in MethodMatcher and ChangeMethodName (#4168)