geronimo-xbean-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1539009 - /geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/XbeanAsmParameterNameLoader.java
Date Tue, 05 Nov 2013 14:26:13 GMT
Author: rmannibucau
Date: Tue Nov  5 14:26:13 2013
New Revision: 1539009

URL: http://svn.apache.org/r1539009
Log:
XBEAN-254 trying to avoid index issues in xbean asm parameter loader

Modified:
    geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/XbeanAsmParameterNameLoader.java

Modified: geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/XbeanAsmParameterNameLoader.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/XbeanAsmParameterNameLoader.java?rev=1539009&r1=1539008&r2=1539009&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/XbeanAsmParameterNameLoader.java
(original)
+++ geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/XbeanAsmParameterNameLoader.java
Tue Nov  5 14:26:13 2013
@@ -266,13 +266,16 @@ public class XbeanAsmParameterNameLoader
                 final List<String> parameterNames;
                 final boolean isStaticMethod;
 
+                final int paramLen;
                 if (methodName.equals("<init>")) {
                     Constructor constructor = constructorMap.get(desc);
                     if (constructor == null) {
                         return null;
                     }
-                    parameterNames = new ArrayList<String>(constructor.getParameterTypes().length);
-                    parameterNames.addAll(Collections.<String>nCopies(constructor.getParameterTypes().length,
null));
+
+                    paramLen = constructor.getParameterTypes().length;
+                    parameterNames = new ArrayList<String>(paramLen);
+                    parameterNames.addAll(Collections.<String>nCopies(paramLen, null));
                     constructorParameters.put(constructor, parameterNames);
                     isStaticMethod = false;
                 } else {
@@ -280,8 +283,10 @@ public class XbeanAsmParameterNameLoader
                     if (method == null) {
                         return null;
                     }
-                    parameterNames = new ArrayList<String>(method.getParameterTypes().length);
-                    parameterNames.addAll(Collections.<String>nCopies(method.getParameterTypes().length,
null));
+
+                    paramLen = method.getParameterTypes().length;
+                    parameterNames = new ArrayList<String>(paramLen);
+                    parameterNames.addAll(Collections.<String>nCopies(paramLen, null));
                     methodParameters.put(method, parameterNames);
                     isStaticMethod = Modifier.isStatic(method.getModifiers());
                 }
@@ -290,10 +295,14 @@ public class XbeanAsmParameterNameLoader
                     // assume static method until we get a first parameter name
                     public void visitLocalVariable(String name, String description, String
signature, Label start, Label end, int index) {
                         if (isStaticMethod) {
-                            parameterNames.set(index, name);
+                            if (paramLen > index) {
+                                parameterNames.set(index, name);
+                            }
                         } else if (index > 0) {
                             // for non-static the 0th arg is "this" so we need to offset
by -1
-                            parameterNames.set(index - 1, name);
+                            if (paramLen >= index) {
+                                parameterNames.set(index - 1, name);
+                            }
                         }
                     }
                 };



Mime
View raw message