Menu

#35 Array initializer may not contain null

closed-fixed
nobody
General (151)
5
2001-06-02
2001-05-17
No

x = new String[] {null, "foo"} gets the following error in bsh-1.01:

java.lang.NullPointerException at java.lang.reflect.Array.newArray(Native Method) at java.lang.reflect.Array.newInstance(Array.java:54) at bsh.BSHArrayInitializer.eval(BSHArrayInitializer.java:47) at bsh.BSHArrayDimensions.eval(BSHArrayDimensions.java:48) at bsh.BSHArrayDimensions.eval(BSHArrayDimensions.java:36) at bsh.BSHAllocationExpression.objectArrayAllocation(BSHAllocationExpression.java:82) at bsh.BSHAllocationExpression.eval(BSHAllocationExpression.java:40) at bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:48)
The problem appears to be in BSHArrayInitializer.eval(). It should probably use the "baseType" input parameter instead of the type of the first initializer as the type for the "initializers" array.

Discussion

  • Pat Niemeyer

    Pat Niemeyer - 2001-06-02

    Logged In: YES
    user_id=18885

    Fixed in 1.1a11

     
  • Pat Niemeyer

    Pat Niemeyer - 2001-06-02
    • status: open --> closed-fixed
     

Log in to post a comment.

MongoDB Logo MongoDB