From c533d05d55f28631a1606323b613b91f5a1097e4 Mon Sep 17 00:00:00 2001 From: Thomas Watson Date: Tue, 17 Dec 2019 15:43:59 -0600 Subject: Bug 558371 - Avoid use of MethodHandle Use of method handles does not seem to improve performance. In my testing it actually makes things slower on Java 8. Particularly the use of MethodHandle for calling the constructor for the value to match against. Substrate also doesn't like the use of MethodHandles in the FilterImpl. For now I think we should avoid using them unless they show a clear performance win. Change-Id: I220cb2cde0a7c5bf948db6e34f8d337e3a4ce0f8 Signed-off-by: Thomas Watson --- .../src/org/eclipse/osgi/internal/framework/FilterImpl.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/FilterImpl.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/FilterImpl.java index 96b87ce00..f718ea1fe 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/FilterImpl.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/FilterImpl.java @@ -14,10 +14,8 @@ package org.eclipse.osgi.internal.framework; -import static java.lang.invoke.MethodHandles.publicLookup; import static java.util.Objects.requireNonNull; -import java.lang.invoke.MethodHandle; import java.lang.reflect.AccessibleObject; import java.lang.reflect.Constructor; import java.lang.reflect.Method; @@ -787,8 +785,7 @@ public abstract class FilterImpl implements Filter { if (Modifier.isStatic(method.getModifiers()) && target.isAssignableFrom(method.getReturnType())) { setAccessible(method); try { - MethodHandle mh = publicLookup().unreflect(method); - return mh.invoke(value2.trim()); + return method.invoke(null, value2.trim()); } catch (Error e) { throw e; } catch (Throwable e) { @@ -806,8 +803,7 @@ public abstract class FilterImpl implements Filter { } setAccessible(constructor); try { - MethodHandle mh = publicLookup().unreflectConstructor(constructor); - return mh.invoke(value2.trim()); + return constructor.newInstance(value2.trim()); } catch (Error e) { throw e; } catch (Throwable e) { -- cgit v1.2.1