Skip to content

Apache Lucene open-source search software

Remove deprecations in expressions (#14641)

Uwe Schindlerc87f02285efe
diff --git a/lucene/expressions/src/java/org/apache/lucene/expressions/js/JavascriptCompiler.java b/lucene/expressions/src/java/org/apache/lucene/expressions/js/JavascriptCompiler.java
index cbcf2992506..a4d5c4111e5 100644
--- a/lucene/expressions/src/java/org/apache/lucene/expressions/js/JavascriptCompiler.java
+++ b/lucene/expressions/src/java/org/apache/lucene/expressions/js/JavascriptCompiler.java
@@ -160,29 +160,6 @@ public final class JavascriptCompiler {
return compile(sourceText, functions, false);
}
- /**
- * Converts a legacy map with reflective {@link java.lang.reflect.Method} functions to {@code
- * Map<String,MethodHandle} for use with {@link #compile(String, Map)}.
- *
- * @param functions a map with only public and accessible reflective methods
- * @return a new (modifiable) map with the same function declarations, but converted to {@link
- * MethodHandle}
- * @throws IllegalAccessException if any of the methods in {@code functions} are not accessible by
- * the public {@link Lookup}.
- * @deprecated Only use this to convert Lucene 9.x or earlier legacy code. For new code use {@link
- * MethodHandle}.
- */
- @Deprecated
- public static Map<String, MethodHandle> convertLegacyFunctions(
- Map<String, java.lang.reflect.Method> functions) throws IllegalAccessException {
- final var lookup = MethodHandles.publicLookup();
- final Map<String, MethodHandle> newMap = new HashMap<>();
- for (var e : functions.entrySet()) {
- newMap.put(e.getKey(), lookup.unreflect(e.getValue()));
- }
- return newMap;
- }
-
/**
* Compiles the given expression with the supplied custom functions.
*
diff --git a/lucene/expressions/src/test/org/apache/lucene/expressions/js/TestCustomFunctions.java b/lucene/expressions/src/test/org/apache/lucene/expressions/js/TestCustomFunctions.java
index 5fee6c58103..315b1dbd42c 100644
--- a/lucene/expressions/src/test/org/apache/lucene/expressions/js/TestCustomFunctions.java
+++ b/lucene/expressions/src/test/org/apache/lucene/expressions/js/TestCustomFunctions.java
@@ -292,20 +292,4 @@ public class TestCustomFunctions extends CompilerTestCase {
Expression expr = compile("foo.bar() + bar.foo(7)", functions);
assertEquals(16, expr.evaluate(null), DELTA);
}
-
- public void testLegacyFunctions() throws Exception {
- var functions =
- Map.of("foo", TestCustomFunctions.class.getMethod("oneArgMethod", double.class));
- var newFunctions = JavascriptCompiler.convertLegacyFunctions(functions);
- newFunctions.putAll(JavascriptCompiler.DEFAULT_FUNCTIONS);
- Expression expr = compile("foo(3) + abs(-7)", newFunctions);
- assertEquals(13, expr.evaluate(null), DELTA);
- }
-
- public void testInvalidLegacyFunctions() throws Exception {
- var functions = Map.of("foo", TestCustomFunctions.class.getMethod("nonStaticMethod"));
- var newFunctions = JavascriptCompiler.convertLegacyFunctions(functions);
- newFunctions.putAll(JavascriptCompiler.DEFAULT_FUNCTIONS);
- expectThrows(IllegalArgumentException.class, () -> compile("foo(3) + abs(-7)", newFunctions));
- }
}