{"action":"closed","issue":{"url":"https://api.github.com/repos/jmockit/jmockit1/issues/243","labels_url":"https://api.github.com/repos/jmockit/jmockit1/issues/243/labels{/name}","comments_url":"https://api.github.com/repos/jmockit/jmockit1/issues/243/comments","events_url":"https://api.github.com/repos/jmockit/jmockit1/issues/243/events","html_url":"https://github.com/jmockit/jmockit1/issues/243","id":120305014,"number":243,"title":"ArrayIndexOutOfBoundsException when using @Tested (was: \"Method parameter names counting counts double for reference types\")","user":{"login":"alienisty","id":4103676,"avatar_url":"https://avatars.githubusercontent.com/u/4103676?v=3","gravatar_id":"","url":"https://api.github.com/users/alienisty","html_url":"https://github.com/alienisty","followers_url":"https://api.github.com/users/alienisty/followers","following_url":"https://api.github.com/users/alienisty/following{/other_user}","gists_url":"https://api.github.com/users/alienisty/gists{/gist_id}","starred_url":"https://api.github.com/users/alienisty/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alienisty/subscriptions","organizations_url":"https://api.github.com/users/alienisty/orgs","repos_url":"https://api.github.com/users/alienisty/repos","events_url":"https://api.github.com/users/alienisty/events{/privacy}","received_events_url":"https://api.github.com/users/alienisty/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/jmockit/jmockit1/labels/bug","name":"bug","color":"fc2929"}],"state":"closed","locked":false,"assignee":{"login":"rliesenfeld","id":200378,"avatar_url":"https://avatars.githubusercontent.com/u/200378?v=3","gravatar_id":"","url":"https://api.github.com/users/rliesenfeld","html_url":"https://github.com/rliesenfeld","followers_url":"https://api.github.com/users/rliesenfeld/followers","following_url":"https://api.github.com/users/rliesenfeld/following{/other_user}","gists_url":"https://api.github.com/users/rliesenfeld/gists{/gist_id}","starred_url":"https://api.github.com/users/rliesenfeld/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rliesenfeld/subscriptions","organizations_url":"https://api.github.com/users/rliesenfeld/orgs","repos_url":"https://api.github.com/users/rliesenfeld/repos","events_url":"https://api.github.com/users/rliesenfeld/events{/privacy}","received_events_url":"https://api.github.com/users/rliesenfeld/received_events","type":"User","site_admin":false},"milestone":null,"comments":6,"created_at":"2015-12-04T00:31:35Z","updated_at":"2015-12-12T13:18:37Z","closed_at":"2015-12-12T13:18:37Z","body":"The new `ParameterNames.getSumOfArgumentSizes` method counts double when a parameter is a non array reference type, because, when the code finds the `';'` character, it does not increase `'i'` again after the loop, causing the main loop to read it again and treat it as another parameter.\r\n\r\nThe following call, will reproduce the bug:\r\n`ParameterNames.registerName(\"A\", PUBLIC, \"m1\", \"(Ljava/lang/String;)\", \"J\", \"local\", 2);`\r\n\r\nI also believe that the case for the array would not properly handle arrays of reference types.\r\n\r\nI suggest using the following implementation:\r\n```\r\nprivate static int getSumOfArgumentSizes(@Nonnull String memberDesc)\r\n   {\r\n      int sum = 0;\r\n      int i = 1;\r\n\r\n      while (true) {\r\n         char c = memberDesc.charAt(i);\r\n\r\n         if (c == ')') {\r\n            return sum;\r\n         }\r\n\r\n         if (c == 'L') {\r\n            while (memberDesc.charAt(i) != ';') i++;\r\n            sum++;\r\n         }\r\n         else if (c == '[') {\r\n            while ((c = memberDesc.charAt(i)) == '[') i++;\r\n            continue;\r\n         }\r\n         else if (isDoubleSizeType(c)) {\r\n            sum += 2;\r\n         }\r\n         else {\r\n            sum++;\r\n         }\r\n         i++;\r\n      }\r\n}\r\n```"}}