Commit f82aa825 authored by Nate Fischer's avatar Nate Fischer Committed by Commit Bot

AW: do not convert support lib param types

No expected change to behavior, but this should have a slight
performance boost to the support library.

Previously, for each method call on a boundary interface, we would
iterate over method parameter types and convert each type to the
corresponding type visible by delegateLoader. This work is redundant,
because we only ever pass pre-L frameworks types (e.g., WebView, String,
InvocationHandler) and primitives.

This work would not be redundant if we passed BoundaryInterfaces as
parameters to some BoundaryInterface methods, however we don't ever
intend to do so.

Bug: 837820
Test: ./gradlew :webkit:connectedAndroidTest
Change-Id: Icd3bfc620a45f9acd437da514ae5a02b3d8a6b02
Reviewed-on: https://chromium-review.googlesource.com/1054122Reviewed-by: default avatarGustav Sennton <gsennton@chromium.org>
Commit-Queue: Nate Fischer <ntfschr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#558037}
parent b846d870
...@@ -24,17 +24,9 @@ public class BoundaryInterfaceReflectionUtil { ...@@ -24,17 +24,9 @@ public class BoundaryInterfaceReflectionUtil {
throws ClassNotFoundException, NoSuchMethodException { throws ClassNotFoundException, NoSuchMethodException {
Class<?> declaringClass = Class<?> declaringClass =
Class.forName(method.getDeclaringClass().getName(), true, delegateLoader); Class.forName(method.getDeclaringClass().getName(), true, delegateLoader);
Class[] otherSideParameterClasses = method.getParameterTypes(); // We do not need to convert parameter types across ClassLoaders because we never pass
Class[] parameterClasses = new Class[otherSideParameterClasses.length]; // BoundaryInterfaces in methods, but pass InvocationHandlers instead.
for (int n = 0; n < parameterClasses.length; n++) { Class[] parameterClasses = method.getParameterTypes();
Class<?> clazz = otherSideParameterClasses[n];
// Primitive classes are shared between the classloaders - so we can use the same
// primitive class declarations on either side. Non-primitive classes must be looked up
// by name.
parameterClasses[n] = clazz.isPrimitive()
? clazz
: Class.forName(clazz.getName(), true, delegateLoader);
}
return declaringClass.getDeclaredMethod(method.getName(), parameterClasses); return declaringClass.getDeclaredMethod(method.getName(), parameterClasses);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment