Skip to content

Commit c6913dd

Browse files
author
Mihail Slavchev
committed
bug fix: use class cache to resolve classes loaded from non-default class loader
1 parent 58d938a commit c6913dd

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

src/src/com/tns/MethodResolver.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
import java.util.HashMap;
1111
import java.util.Map;
1212

13+
import android.util.Log;
14+
1315
class MethodResolver
1416
{
1517
private static Map<String, String> primitiveTypesSignature = new HashMap<String, String>();
@@ -106,10 +108,14 @@ public static String getTypeSignature(Class<?> type)
106108
return array + signature;
107109
}
108110

109-
static String resolveMethodOverload(String className, String methodName, Object[] args) throws ClassNotFoundException
111+
static String resolveMethodOverload(HashMap<String, Class<?>> classCache, String className, String methodName, Object[] args) throws ClassNotFoundException
110112
{
111113
String methodSig = null;
112-
Class<?> clazz = Class.forName(className);
114+
Class<?> clazz = classCache.get(className);
115+
if (clazz == null)
116+
{
117+
clazz = Class.forName(className);
118+
}
113119
int argLength = (args != null) ? args.length : 0;
114120

115121
ArrayList<Tuple<Method, Integer>> candidates = new ArrayList<Tuple<Method, Integer>>();

src/src/com/tns/Platform.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ public static void APP_FAIL(String message)
710710
public static String resolveMethodOverload(String className, String methodName, Object[] args) throws Exception
711711
{
712712
if (IsLogEnabled) Log.d(DEFAULT_LOG_TAG, "resolveMethodOverload: Resolving method " + methodName + " on class " + className);
713-
String res = MethodResolver.resolveMethodOverload(className, methodName, args);
713+
String res = MethodResolver.resolveMethodOverload(classCache, className, methodName, args);
714714
if (IsLogEnabled) Log.d(DEFAULT_LOG_TAG, "resolveMethodOverload: method found :" + res);
715715
if (res == null)
716716
{

0 commit comments

Comments
 (0)