Skip to content

Commit f8424a9

Browse files
committed
Merge 1.19.2 into 1.20
2 parents c15b95e + 237239d commit f8424a9

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

common/src/main/java/org/embeddedt/modernfix/searchtree/REIBackedSearchTree.java

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,13 @@
1414

1515
import java.lang.invoke.MethodHandle;
1616
import java.lang.invoke.MethodHandles;
17+
import java.lang.invoke.MethodType;
1718
import java.lang.reflect.Method;
1819
import java.util.ArrayList;
1920
import java.util.Collections;
2021
import java.util.List;
22+
import java.util.function.Function;
23+
import java.util.function.Predicate;
2124
import java.util.function.Supplier;
2225
import java.util.function.UnaryOperator;
2326

@@ -107,9 +110,22 @@ private static AsyncSearchManager createSearchManager() {
107110
throw new RuntimeException(e);
108111
}
109112
};
110-
return new AsyncSearchManager(stackListSupplier, () -> {
113+
Supplier<Predicate<Boolean>> shouldShowStack = () -> {
111114
return Predicates.alwaysTrue();
112-
}, normalizeOperator);
115+
};
116+
try {
117+
try {
118+
// Old constructor taking Supplier as first arg
119+
MethodHandle cn = MethodHandles.publicLookup().findConstructor(AsyncSearchManager.class, MethodType.methodType(void.class, Supplier.class, Supplier.class, UnaryOperator.class));
120+
return (AsyncSearchManager)cn.invoke(stackListSupplier, shouldShowStack, normalizeOperator);
121+
} catch(NoSuchMethodException e) {
122+
// New constructor taking Function as first arg
123+
MethodHandle cn = MethodHandles.publicLookup().findConstructor(AsyncSearchManager.class, MethodType.methodType(void.class, Function.class, Supplier.class, UnaryOperator.class));
124+
return (AsyncSearchManager)cn.invoke((Function<?, ?>)o -> stackListSupplier.get(), shouldShowStack, normalizeOperator);
125+
}
126+
} catch(Throwable mhThrowable) {
127+
throw new ReflectiveOperationException(mhThrowable);
128+
}
113129
} catch(ReflectiveOperationException e) {
114130
throw new RuntimeException(e);
115131
}

0 commit comments

Comments
 (0)