Skip to content

Commit

Permalink
correct interning changes
Browse files Browse the repository at this point in the history
  • Loading branch information
markro49 committed Feb 8, 2024
1 parent 96a43e8 commit 03a20d4
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/main/java/org/apache/bcel/classfile/Constant.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ public abstract class Constant implements Cloneable, Node {
private static BCELComparator<Constant> bcelComparator = new BCELComparator<Constant>() {

@Override
@SuppressWarnings("interning:not.interned") // we want to do a reference comparison
public boolean equals(final Constant a, final Constant b) {
return a.equals(b) || a != null && b != null && Objects.equals(a.toString(), b.toString());
return a == b || a != null && b != null && Objects.equals(a.toString(), b.toString());
}

@Override
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/apache/bcel/classfile/Field.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ public final class Field extends FieldOrMethod {
private static BCELComparator<Field> bcelComparator = new BCELComparator<Field>() {

@Override
@SuppressWarnings("interning:not.interned") // we want to do a reference comparison
public boolean equals(final Field a, final Field b) {
return a.equals(b) || a != null && b != null && Objects.equals(a.getName(), b.getName()) && Objects.equals(a.getSignature(), b.getSignature());
return a == b || a != null && b != null && Objects.equals(a.getName(), b.getName()) && Objects.equals(a.getSignature(), b.getSignature());
}

@Override
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/apache/bcel/classfile/JavaClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@ public class JavaClass extends AccessFlags implements Cloneable, Node, Comparabl
private static BCELComparator<JavaClass> bcelComparator = new BCELComparator<JavaClass>() {

@Override
@SuppressWarnings("interning:not.interned") // we want to do a reference comparison
public boolean equals(final JavaClass a, final JavaClass b) {
return a.equals(b) || a != null && b != null && Objects.equals(a.getClassName(), b.getClassName());
return a == b || a != null && b != null && Objects.equals(a.getClassName(), b.getClassName());
}

@Override
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/apache/bcel/classfile/Method.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ public final class Method extends FieldOrMethod {
private static BCELComparator<Method> bcelComparator = new BCELComparator<Method>() {

@Override
@SuppressWarnings("interning:not.interned") // we want to do a reference comparison
public boolean equals(final Method a, final Method b) {
return a.equals(b) || a != null && b != null && Objects.equals(a.getName(), b.getName()) && Objects.equals(a.getSignature(), b.getSignature());
return a == b || a != null && b != null && Objects.equals(a.getName(), b.getName()) && Objects.equals(a.getSignature(), b.getSignature());
}

@Override
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/apache/bcel/generic/ClassGen.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ public class ClassGen extends AccessFlags implements Cloneable {
private static BCELComparator<ClassGen> bcelComparator = new BCELComparator<ClassGen>() {

@Override
@SuppressWarnings("interning:not.interned") // we want to do a reference comparison
public boolean equals(final ClassGen a, final ClassGen b) {
return a.equals(b) || a != null && b != null && Objects.equals(a.getClassName(), b.getClassName());
return a == b || a != null && b != null && Objects.equals(a.getClassName(), b.getClassName());
}

@Override
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/apache/bcel/generic/FieldGen.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ public class FieldGen extends FieldGenOrMethodGen {
private static BCELComparator<FieldGen> bcelComparator = new BCELComparator<FieldGen>() {

@Override
@SuppressWarnings("interning:not.interned") // we want to do a reference comparison
public boolean equals(final FieldGen a, final FieldGen b) {
return a.equals(b) || a != null && b != null && Objects.equals(a.getName(), b.getName()) && Objects.equals(a.getSignature(), b.getSignature());
return a == b || a != null && b != null && Objects.equals(a.getName(), b.getName()) && Objects.equals(a.getSignature(), b.getSignature());
}

@Override
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/apache/bcel/generic/MethodGen.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,9 @@ static final class BranchTarget {
private static BCELComparator<FieldGenOrMethodGen> bcelComparator = new BCELComparator<FieldGenOrMethodGen>() {

@Override
@SuppressWarnings("interning:not.interned") // we want to do a reference comparison
public boolean equals(final FieldGenOrMethodGen a, final FieldGenOrMethodGen b) {
return a.equals(b) || a != null && b != null && Objects.equals(a.getName(), b.getName()) && Objects.equals(a.getSignature(), b.getSignature());
return a == b || a != null && b != null && Objects.equals(a.getName(), b.getName()) && Objects.equals(a.getSignature(), b.getSignature());
}

@Override
Expand Down

0 comments on commit 03a20d4

Please sign in to comment.