Skip to content

Commit

Permalink
fix: Make Flow compatible with ASM versions older than 9 (#15770)
Browse files Browse the repository at this point in the history
* fix: Make Flow compatible with ASM framework

Solution for #15625, until payara/Payara#6127 is fixed.

* Simplifications

* Change getter names and add final

* fix formatting
  • Loading branch information
mshabarov authored Jan 31, 2023
1 parent cc9a426 commit 353f300
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,19 @@ public enum SortDirection {
/**
* Ascending (e.g. A-Z, 1..9) sort order
*/
ASCENDING {
@Override
public SortDirection getOpposite() {
return DESCENDING;
}
},
ASCENDING,

/**
* Descending (e.g. Z-A, 9..1) sort order
*/
DESCENDING {
@Override
public SortDirection getOpposite() {
return ASCENDING;
}
};
DESCENDING;

/**
* Get the sort direction that is the direct opposite to this one.
*
* @return a sort direction value
*/
public abstract SortDirection getOpposite();
public SortDirection getOpposite() {
return ASCENDING.equals(this) ? DESCENDING : ASCENDING;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.WeakHashMap;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -51,8 +52,63 @@ public class ComponentTracker {
/**
* Represents a location in the source code.
*/
public record Location(String className, String filename, String methodName, int lineNumber)
implements Serializable {
public static class Location implements Serializable {
private final String className;
private final String filename;
private final String methodName;
private final int lineNumber;

public Location(String className, String filename, String methodName,
int lineNumber) {
this.className = className;
this.filename = filename;
this.methodName = methodName;
this.lineNumber = lineNumber;
}

public String className() {
return className;
}

public String filename() {
return filename;
}

public String methodName() {
return methodName;
}

public int lineNumber() {
return lineNumber;
}

@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;

Location location = (Location) o;

if (lineNumber != location.lineNumber)
return false;
if (!Objects.equals(className, location.className))
return false;
if (!Objects.equals(filename, location.filename))
return false;
return Objects.equals(methodName, location.methodName);
}

@Override
public int hashCode() {
int result = className != null ? className.hashCode() : 0;
result = 31 * result + (filename != null ? filename.hashCode() : 0);
result = 31 * result
+ (methodName != null ? methodName.hashCode() : 0);
result = 31 * result + lineNumber;
return result;
}
}

/**
Expand Down

0 comments on commit 353f300

Please sign in to comment.