You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2018/03/05 10:22:51 UTC

[1/2] groovy git commit: Fix ArrayIndexOutOfBoundsException in CallSiteWriter.getCreateArraySignature()(closes #669)

Repository: groovy
Updated Branches:
  refs/heads/master 10c6ef9cc -> 50ebdf164


Fix ArrayIndexOutOfBoundsException in CallSiteWriter.getCreateArraySignature()(closes #669)

It would throw ArrayIndexOutOfBoundsException if the numberOfArguments exceed 255,
but there is no check for array index and it's hard to get the root cause to users.

We should throw a more readable exception here.


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/52bb559c
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/52bb559c
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/52bb559c

Branch: refs/heads/master
Commit: 52bb559c4700b62a79d51ee33b4a25bd7ed00d83
Parents: 10c6ef9
Author: liningrui <li...@baidu.com>
Authored: Fri Mar 2 11:44:23 2018 +0800
Committer: sunlan <su...@apache.org>
Committed: Mon Mar 5 18:18:31 2018 +0800

----------------------------------------------------------------------
 .../java/org/codehaus/groovy/classgen/asm/CallSiteWriter.java   | 5 +++++
 1 file changed, 5 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/52bb559c/src/main/java/org/codehaus/groovy/classgen/asm/CallSiteWriter.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/classgen/asm/CallSiteWriter.java b/src/main/java/org/codehaus/groovy/classgen/asm/CallSiteWriter.java
index 3e3f0e1..334eebd 100644
--- a/src/main/java/org/codehaus/groovy/classgen/asm/CallSiteWriter.java
+++ b/src/main/java/org/codehaus/groovy/classgen/asm/CallSiteWriter.java
@@ -70,6 +70,11 @@ public class CallSiteWriter {
     
     private static String [] sig = new String [255];
     private static String getCreateArraySignature(int numberOfArguments) {
+        if (numberOfArguments >= 255) {
+            throw new IllegalArgumentException(String.format(
+                      "The max number of arguments is 255, actual got %s",
+                      numberOfArguments);
+        }
         if (sig[numberOfArguments] == null) {
             StringBuilder sb = new StringBuilder("(");
             for (int i = 0; i != numberOfArguments; ++i) {


[2/2] groovy git commit: Fix a syntax error and trivial refactor

Posted by su...@apache.org.
Fix a syntax error and trivial refactor


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/50ebdf16
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/50ebdf16
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/50ebdf16

Branch: refs/heads/master
Commit: 50ebdf1649cf3a7c8c3ce1afcfb888ff8f954766
Parents: 52bb559
Author: sunlan <su...@apache.org>
Authored: Mon Mar 5 18:22:29 2018 +0800
Committer: sunlan <su...@apache.org>
Committed: Mon Mar 5 18:22:29 2018 +0800

----------------------------------------------------------------------
 .../org/codehaus/groovy/classgen/asm/CallSiteWriter.java  | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/50ebdf16/src/main/java/org/codehaus/groovy/classgen/asm/CallSiteWriter.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/classgen/asm/CallSiteWriter.java b/src/main/java/org/codehaus/groovy/classgen/asm/CallSiteWriter.java
index 334eebd..d4ddc94 100644
--- a/src/main/java/org/codehaus/groovy/classgen/asm/CallSiteWriter.java
+++ b/src/main/java/org/codehaus/groovy/classgen/asm/CallSiteWriter.java
@@ -67,13 +67,13 @@ import static org.objectweb.asm.Opcodes.RETURN;
  * use this class in your code
  */
 public class CallSiteWriter {
-    
-    private static String [] sig = new String [255];
+    private static final int SIG_ARRAY_LENGTH = 255;
+    private static String [] sig = new String [SIG_ARRAY_LENGTH];
     private static String getCreateArraySignature(int numberOfArguments) {
-        if (numberOfArguments >= 255) {
+        if (numberOfArguments >= SIG_ARRAY_LENGTH) {
             throw new IllegalArgumentException(String.format(
-                      "The max number of arguments is 255, actual got %s",
-                      numberOfArguments);
+                      "The max number of arguments is %s, actual got %s",
+                        SIG_ARRAY_LENGTH, numberOfArguments));
         }
         if (sig[numberOfArguments] == null) {
             StringBuilder sb = new StringBuilder("(");