[hg] main-silver: #223728: Varargs methods execution is fixed. T...

  • From:
  • To:
  • Subject: [hg] main-silver: #223728: Varargs methods execution is fixed. T...
  • Date: Tue, 18 Dec 2012 10:38:44 -0800

changeset 08e627deac48 in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/08e627deac48
description:
        #223728: Varargs methods execution is fixed. Test included.

diffstat:

 
debugger.jpda/src/org/netbeans/modules/debugger/jpda/expr/EvaluatorVisitor.java
       |  22 ++++
 
debugger.jpda/test/unit/src/org/netbeans/api/debugger/jpda/testapps/EvaluatorApp.java
 |  48 ++++++++++
 2 files changed, 70 insertions(+), 0 deletions(-)

diffs (104 lines):

diff --git 
a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/expr/EvaluatorVisitor.java
 
b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/expr/EvaluatorVisitor.java
--- 
a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/expr/EvaluatorVisitor.java
+++ 
b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/expr/EvaluatorVisitor.java
@@ -466,6 +466,15 @@
         String typeName = getTypeName(((javax.lang.model.type.ArrayType) 
tm).getComponentType());
         int length = argVals.size() - varIndex;
         ArrayType at = (ArrayType) getOrLoadClass(vm, typeName+"[]", 
evaluationContext);
+        if (length == 1) {
+            Value varArg = argVals.get(varIndex);
+            if (varArg instanceof ArrayReference) {
+                if (dimension(at) == dimension((ArrayType) ((ArrayReference) 
varArg).type())) {
+                    // The argument is already an array corresponding to 
vararg
+                    return null;
+                }
+            }
+        }
         ArrayReference array = createArrayMirrorWithDisabledCollection(at, 
length, evaluationContext);
         List<Value> elements = new ArrayList<Value>(length);
         for (int i = 0; i < length; i++) {
@@ -486,6 +495,19 @@
         return array;
     }
     
+    // Find out the array dimension
+    private static int dimension(ArrayType at) {
+        int d = 1;
+        Type ct;
+        try {
+            while ((ct = at.componentType()) instanceof ArrayType) {
+                d++;
+                at = (ArrayType) ct;
+            }
+        } catch (ClassNotLoadedException ex) {}
+        return d;
+    }
+    
     /*private Method getConcreteMethod(ReferenceType type, String 
methodName, List<? extends ExpressionTree> typeArguments) {
         List<Method> methods = type.methodsByName(methodName);
         String signature = createSignature(typeArguments);
diff --git 
a/debugger.jpda/test/unit/src/org/netbeans/api/debugger/jpda/testapps/EvaluatorApp.java
 
b/debugger.jpda/test/unit/src/org/netbeans/api/debugger/jpda/testapps/EvaluatorApp.java
--- 
a/debugger.jpda/test/unit/src/org/netbeans/api/debugger/jpda/testapps/EvaluatorApp.java
+++ 
b/debugger.jpda/test/unit/src/org/netbeans/api/debugger/jpda/testapps/EvaluatorApp.java
@@ -896,6 +896,38 @@
         return new float[] { methodAutobox2(4, new Long(lx), new 
Float(1.4)), 15f, new Float(1.5) }[0];
     }
     
+    public static String testVarArgs1() throws NoSuchMethodException {
+        return Runtime.class.getMethod("runFinalizersOnExit", 
Boolean.TYPE).getName();
+    }
+    
+    public static String testVarArgs2() throws NoSuchMethodException {
+        return Runtime.class.getMethod("runFinalizersOnExit", new Class[] { 
Boolean.TYPE }).getName();
+    }
+    
+    public static int testVarArgs3() {
+        return count(new String[] { null });
+    }
+    
+    public static int testVarArgs4() {
+        return count(new Object[] { null });
+    }
+    
+    public static int testVarArgs5() {
+        return count(new Object[][][] { new Object[][] { new Object[] {null} 
} });
+    }
+    
+    public static int testVarArgs6() {
+        return count(new Object[][][] { new Object[][] { new Object[] {null} 
} }, new Object[][][] { new Object[][] { new Object[] {null} } });
+    }
+    
+    public static int testVarArgs7() {
+        return count(new String[][] { {"A"}, {"B"} });
+    }
+    
+    public static int testVarArgs8() {
+        return count(new String[] { "A " }, new String[] { "B" });
+    }
+    
     public static String testConversion1() {
         return "a"+10;
     }
@@ -1046,6 +1078,22 @@
         return new Float(((d / l)) * i);
     }
     
+    public static int count(String[]... args) {
+        int c = 0;
+        for (String[] s : args) {
+            c += s.length;
+        }
+        return c;
+    }
+    
+    public static int count(Object[]... args) {
+        int c = 0;
+        for (Object[] s : args) {
+            c += s.length;
+        }
+        return -c;
+    }
+    
     public static class Inner1 {
         public Inner1() {}
         

[hg] main-silver: #223728: Varargs methods execution is fixed. T...

mentlicher 12/18/2012

Project Features

About this Project

Debugger was started in November 2009, is owned by tpavek, and has 29 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20140418.2d69abc). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close