Opened 13 years ago

Closed 13 years ago

#3899 closed defect (invalid)

setPattern using Java MapScript-API throws "incorrect array size" error

Reported by: rrenkert Owned by: unicoletti
Priority: normal Milestone:
Component: MapScript-Java Version: svn-trunk (development)
Severity: normal Keywords:
Cc: sholl

Description

When setting a pattern to a style using Java MapScript the following code throws an error:

--- style.setPatternlength(2); double[] values = new double[] {2.0, 2.0}; style.setPattern(values);

java.lang.IndexOutOfBoundsException: incorrect array size at edu.umn.gis.mapscript.mapscriptJNI.styleObj_pattern_set(Native Method) at edu.umn.gis.mapscript.styleObj.setPattern(styleObj.java:182) ---

The error occurs on different array sizes (tested with 3, 4, 5, 6 elements).

Thanks for fixing!

Regards

Raimund

Attachments (1)

PatternTest.java (799 bytes ) - added by sholl 13 years ago.

Download all attachments as: .zip

Change History (3)

by sholl, 13 years ago

Attachment: PatternTest.java added

comment:1 by sholl, 13 years ago

for easy reproduction of the prpoblem I have added a simple testcase (PatternTest.java) for trying.

Thanks for looking into this.

Best

Stephan

comment:2 by unicoletti, 13 years ago

Resolution: invalid
Status: newclosed

That is the expected result. The pattern array must be exactly 10 in length, like the following:

double[] vals = new double[] {2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0};

or:

double[] vals = new double[] {2.0, 2.0, 0, 0, 0, 0, 0, 0, 0, 0};

because pattern is declared as an array of 10:

double pattern[MS_MAXPATTERNLENGTH];

You can see that this is what is going on by browsing mapscript_wrap.c around line 8259 (mapserver version: trunk, with other versions the lineno might differ).

Closing as invalid.

Note: See TracTickets for help on using tickets.