|
14 | 14 |
|
15 | 15 | import java.lang.invoke.MethodHandle; |
16 | 16 | import java.lang.invoke.MethodHandles; |
| 17 | +import java.lang.invoke.MethodType; |
17 | 18 | import java.lang.reflect.Method; |
18 | 19 | import java.util.ArrayList; |
19 | 20 | import java.util.Collections; |
20 | 21 | import java.util.List; |
| 22 | +import java.util.function.Function; |
| 23 | +import java.util.function.Predicate; |
21 | 24 | import java.util.function.Supplier; |
22 | 25 | import java.util.function.UnaryOperator; |
23 | 26 |
|
@@ -107,9 +110,22 @@ private static AsyncSearchManager createSearchManager() { |
107 | 110 | throw new RuntimeException(e); |
108 | 111 | } |
109 | 112 | }; |
110 | | - return new AsyncSearchManager(stackListSupplier, () -> { |
| 113 | + Supplier<Predicate<Boolean>> shouldShowStack = () -> { |
111 | 114 | 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 | + } |
113 | 129 | } catch(ReflectiveOperationException e) { |
114 | 130 | throw new RuntimeException(e); |
115 | 131 | } |
|
0 commit comments