From 7ef80307548098bbd53e78a310436bef072c0e22 Mon Sep 17 00:00:00 2001 From: Nicolas Geoffray Date: Wed, 3 Apr 2019 17:24:34 +0100 Subject: [PATCH] Use Class.forName instead of ClassLoader.loadClass. Class.forName has a fast path that ClassLoader.loadClass doesn't have yet. Bug: 129834244 Test: m Change-Id: I52427be9dae5acd8eef530f706626246d16dc82a --- core/java/android/view/LayoutInflater.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/core/java/android/view/LayoutInflater.java b/core/java/android/view/LayoutInflater.java index 2ee72bffc9ec0..ae2deb97c7569 100644 --- a/core/java/android/view/LayoutInflater.java +++ b/core/java/android/view/LayoutInflater.java @@ -512,7 +512,7 @@ public abstract class LayoutInflater { String layout = res.getResourceEntryName(resource); try { - Class clazz = mPrecompiledClassLoader.loadClass("" + pkg + ".CompiledView"); + Class clazz = Class.forName("" + pkg + ".CompiledView", false, mPrecompiledClassLoader); Method inflater = clazz.getMethod(layout, Context.class, int.class); View view = (View) inflater.invoke(null, mContext, resource); @@ -731,8 +731,8 @@ public abstract class LayoutInflater { if (constructor == null) { // Class not found in the cache, see if it's real, and try to add it - clazz = mContext.getClassLoader().loadClass( - prefix != null ? (prefix + name) : name).asSubclass(View.class); + clazz = Class.forName(prefix != null ? (prefix + name) : name, false, + mContext.getClassLoader()).asSubclass(View.class); if (mFilter != null && clazz != null) { boolean allowed = mFilter.onLoadClass(clazz); @@ -750,8 +750,8 @@ public abstract class LayoutInflater { Boolean allowedState = mFilterMap.get(name); if (allowedState == null) { // New class -- remember whether it is allowed - clazz = mContext.getClassLoader().loadClass( - prefix != null ? (prefix + name) : name).asSubclass(View.class); + clazz = Class.forName(prefix != null ? (prefix + name) : name, false, + mContext.getClassLoader()).asSubclass(View.class); boolean allowed = clazz != null && mFilter.onLoadClass(clazz); mFilterMap.put(name, allowed);