diff options
Diffstat (limited to 'java/src/com/android/inputmethod/compat/CompatUtils.java')
-rw-r--r-- | java/src/com/android/inputmethod/compat/CompatUtils.java | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/java/src/com/android/inputmethod/compat/CompatUtils.java b/java/src/com/android/inputmethod/compat/CompatUtils.java index 07db4a1bb..a8086919c 100644 --- a/java/src/com/android/inputmethod/compat/CompatUtils.java +++ b/java/src/com/android/inputmethod/compat/CompatUtils.java @@ -20,6 +20,7 @@ import android.content.Intent; import android.text.TextUtils; import android.util.Log; +import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -90,6 +91,19 @@ public class CompatUtils { } } + public static Constructor<?> getConstructor(Class<?> targetClass, Class<?>[] types) { + if (targetClass == null || types == null) return null; + try { + return targetClass.getConstructor(types); + } catch (SecurityException e) { + // ignore + return null; + } catch (NoSuchMethodException e) { + // ignore + return null; + } + } + public static Object invoke( Object receiver, Object defaultValue, Method method, Object... args) { if (receiver == null || method == null) return defaultValue; |