Skip to content
Permalink
Browse files

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
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
  • Loading branch information...
Nicolas Geoffray authored and neobuddy89 committed Apr 3, 2019
1 parent 570c661 commit 816b682d1d88a7b6bc16d46ee6456930676991ed
Showing with 4 additions and 4 deletions.
  1. +4 −4 core/java/android/view/LayoutInflater.java
@@ -603,8 +603,8 @@ public final View createView(String name, String prefix, AttributeSet attrs)

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);
@@ -622,8 +622,8 @@ public final View createView(String name, String prefix, AttributeSet attrs)
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);

0 comments on commit 816b682

Please sign in to comment.
You can’t perform that action at this time.