RFR (XS): 8160024 jdb returns invalid argument count if first parameter to Arrays.asList is null

Daniel D. Daugherty daniel.daugherty at oracle.com
Tue Nov 1 22:03:33 UTC 2016


On 11/1/16 6:58 AM, serguei.spitsyn at oracle.com wrote:
> Please, review this small fix.
>
> Bug: https://bugs.openjdk.java.net/browse/JDK-8160024
>
> JDK webrev:
> http://cr.openjdk.java.net/~sspitsyn/webrevs/2016/hotspot/8160024-JDI-eval.jdk1/ 
>

src/jdk.jdi/share/classes/com/sun/tools/jdi/MethodImpl.java
     L318:         if (nthArgValue == null && argCount == paramCount) {
     L319:             // The only one varargs parameter is null
         Perhaps this comment rewrite:
                       // We have one varargs parameter and it is null
                       // so we don't have to do anything.

     L322:         Type nthArgType = (nthArgValue == null) ? null : 
nthArgValue.type();
         Perhaps add this comment above L322:
                   // If the first varargs parameter is null, then don't
                   // access its type since it can't be an array.

     L347:         argArray.setValues(0, arguments, paramCount - 1, count);
         Looks like setValues() will happily copy any null values that
         happen to be in the arguments List to the argArray. Good.

test/com/sun/jdi/EvalArraysAsList.sh
     No comments.

Thumbs up, but I thought we weren't suppose to add any more
new shell script tests... :-)

Dan


>
> The bug is confidential, so the RFR is sent to the confidential mailing
> lists.
>
>
> Summary:
>
>   The JDI incorrectly evaluates the expression: Arrays.asList(null, "a").
>   The root cause is a special case in the method 
> MethodImpl.handleVarArgs()
>   that has been corrected in order to fix the problem.
>
>   New unit test is included: jdk/test/com/sun/jdi/EvalArraysAsList.sh
>
> Testing:
>   Ran new unit test, Jtreg com/sun/jdi and nsk.jdi.testlist.
>   All tests are passed.
>
> Thanks,
> Serguei
>



More information about the serviceability-dev mailing list