Skip to content

Commit 353f300

Browse files
authored
fix: Make Flow compatible with ASM versions older than 9 (#15770)
* 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
1 parent cc9a426 commit 353f300

File tree

2 files changed

+63
-15
lines changed

2 files changed

+63
-15
lines changed

flow-data/src/main/java/com/vaadin/flow/data/provider/SortDirection.java

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,27 +26,19 @@ public enum SortDirection {
2626
/**
2727
* Ascending (e.g. A-Z, 1..9) sort order
2828
*/
29-
ASCENDING {
30-
@Override
31-
public SortDirection getOpposite() {
32-
return DESCENDING;
33-
}
34-
},
29+
ASCENDING,
3530

3631
/**
3732
* Descending (e.g. Z-A, 9..1) sort order
3833
*/
39-
DESCENDING {
40-
@Override
41-
public SortDirection getOpposite() {
42-
return ASCENDING;
43-
}
44-
};
34+
DESCENDING;
4535

4636
/**
4737
* Get the sort direction that is the direct opposite to this one.
4838
*
4939
* @return a sort direction value
5040
*/
51-
public abstract SortDirection getOpposite();
41+
public SortDirection getOpposite() {
42+
return ASCENDING.equals(this) ? DESCENDING : ASCENDING;
43+
}
5244
}

flow-server/src/main/java/com/vaadin/flow/component/internal/ComponentTracker.java

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.util.Collections;
2020
import java.util.List;
2121
import java.util.Map;
22+
import java.util.Objects;
2223
import java.util.Optional;
2324
import java.util.WeakHashMap;
2425
import java.util.stream.Collectors;
@@ -51,8 +52,63 @@ public class ComponentTracker {
5152
/**
5253
* Represents a location in the source code.
5354
*/
54-
public record Location(String className, String filename, String methodName, int lineNumber)
55-
implements Serializable {
55+
public static class Location implements Serializable {
56+
private final String className;
57+
private final String filename;
58+
private final String methodName;
59+
private final int lineNumber;
60+
61+
public Location(String className, String filename, String methodName,
62+
int lineNumber) {
63+
this.className = className;
64+
this.filename = filename;
65+
this.methodName = methodName;
66+
this.lineNumber = lineNumber;
67+
}
68+
69+
public String className() {
70+
return className;
71+
}
72+
73+
public String filename() {
74+
return filename;
75+
}
76+
77+
public String methodName() {
78+
return methodName;
79+
}
80+
81+
public int lineNumber() {
82+
return lineNumber;
83+
}
84+
85+
@Override
86+
public boolean equals(Object o) {
87+
if (this == o)
88+
return true;
89+
if (o == null || getClass() != o.getClass())
90+
return false;
91+
92+
Location location = (Location) o;
93+
94+
if (lineNumber != location.lineNumber)
95+
return false;
96+
if (!Objects.equals(className, location.className))
97+
return false;
98+
if (!Objects.equals(filename, location.filename))
99+
return false;
100+
return Objects.equals(methodName, location.methodName);
101+
}
102+
103+
@Override
104+
public int hashCode() {
105+
int result = className != null ? className.hashCode() : 0;
106+
result = 31 * result + (filename != null ? filename.hashCode() : 0);
107+
result = 31 * result
108+
+ (methodName != null ? methodName.hashCode() : 0);
109+
result = 31 * result + lineNumber;
110+
return result;
111+
}
56112
}
57113

58114
/**

0 commit comments

Comments
 (0)