Ticket #3899 (closed defect: invalid)

Opened 2 years ago

Last modified 2 years ago

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

PatternTest.java Download (0.8 KB) - added by sholl 2 years ago.

Change History

Changed 2 years ago by sholl

Changed 2 years ago by sholl

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

Thanks for looking into this.

Best

Stephan

Changed 2 years ago by unicoletti

  • status changed from new to closed
  • resolution set to invalid

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.