OSDN Git Service

Fix bug in PropertyValuesHolder_Delegate method index
authorDiego Perez <diegoperez@google.com>
Tue, 19 Jan 2016 10:42:19 +0000 (10:42 +0000)
committerDiego Perez <diegoperez@google.com>
Tue, 19 Jan 2016 10:42:19 +0000 (10:42 +0000)
The method index in PropertyValuesHolder was using only the method name
+ the number of parameters in the call to index the different properties
methods. This worked ok most of the time because, for a given method
name (let's say setTrimStartOffset), the class is usually the same.
However, if the same method name is used in multiple classes, this will
cause collisions and will most likely crash.

Change-Id: Ie6fa8872c5c5e69e690f4f1bb79191a31bef2a28

tools/layoutlib/bridge/src/android/animation/PropertyValuesHolder_Delegate.java

index 54021c9..28a489a 100644 (file)
@@ -64,7 +64,8 @@ class PropertyValuesHolder_Delegate {
     private static long registerMethod(Class<?> targetClass, String methodName, Class[] types,
             int nArgs) {
         // Encode the number of arguments in the method name
-        String methodIndexName = String.format("%1$s#%2$d", methodName, nArgs);
+        String methodIndexName = String.format("%1$s.%2$s#%3$d", targetClass.getSimpleName(),
+                methodName, nArgs);
         synchronized (sMethodIndexLock) {
             Long methodId = METHOD_NAME_TO_ID.get(methodIndexName);