Skip to content

Commit c87f022

Browse files
authored
Remove deprecations in expressions (#14641)
1 parent ebc6350 commit c87f022

File tree

2 files changed

+0
-39
lines changed

2 files changed

+0
-39
lines changed

lucene/expressions/src/java/org/apache/lucene/expressions/js/JavascriptCompiler.java

-23
Original file line numberDiff line numberDiff line change
@@ -160,29 +160,6 @@ public static Expression compile(String sourceText, Map<String, MethodHandle> fu
160160
return compile(sourceText, functions, false);
161161
}
162162

163-
/**
164-
* Converts a legacy map with reflective {@link java.lang.reflect.Method} functions to {@code
165-
* Map<String,MethodHandle} for use with {@link #compile(String, Map)}.
166-
*
167-
* @param functions a map with only public and accessible reflective methods
168-
* @return a new (modifiable) map with the same function declarations, but converted to {@link
169-
* MethodHandle}
170-
* @throws IllegalAccessException if any of the methods in {@code functions} are not accessible by
171-
* the public {@link Lookup}.
172-
* @deprecated Only use this to convert Lucene 9.x or earlier legacy code. For new code use {@link
173-
* MethodHandle}.
174-
*/
175-
@Deprecated
176-
public static Map<String, MethodHandle> convertLegacyFunctions(
177-
Map<String, java.lang.reflect.Method> functions) throws IllegalAccessException {
178-
final var lookup = MethodHandles.publicLookup();
179-
final Map<String, MethodHandle> newMap = new HashMap<>();
180-
for (var e : functions.entrySet()) {
181-
newMap.put(e.getKey(), lookup.unreflect(e.getValue()));
182-
}
183-
return newMap;
184-
}
185-
186163
/**
187164
* Compiles the given expression with the supplied custom functions.
188165
*

lucene/expressions/src/test/org/apache/lucene/expressions/js/TestCustomFunctions.java

-16
Original file line numberDiff line numberDiff line change
@@ -292,20 +292,4 @@ public void testNamespacesWithoutDirectMH() throws Exception {
292292
Expression expr = compile("foo.bar() + bar.foo(7)", functions);
293293
assertEquals(16, expr.evaluate(null), DELTA);
294294
}
295-
296-
public void testLegacyFunctions() throws Exception {
297-
var functions =
298-
Map.of("foo", TestCustomFunctions.class.getMethod("oneArgMethod", double.class));
299-
var newFunctions = JavascriptCompiler.convertLegacyFunctions(functions);
300-
newFunctions.putAll(JavascriptCompiler.DEFAULT_FUNCTIONS);
301-
Expression expr = compile("foo(3) + abs(-7)", newFunctions);
302-
assertEquals(13, expr.evaluate(null), DELTA);
303-
}
304-
305-
public void testInvalidLegacyFunctions() throws Exception {
306-
var functions = Map.of("foo", TestCustomFunctions.class.getMethod("nonStaticMethod"));
307-
var newFunctions = JavascriptCompiler.convertLegacyFunctions(functions);
308-
newFunctions.putAll(JavascriptCompiler.DEFAULT_FUNCTIONS);
309-
expectThrows(IllegalArgumentException.class, () -> compile("foo(3) + abs(-7)", newFunctions));
310-
}
311295
}

0 commit comments

Comments
 (0)