Opened 19 years ago

Closed 19 years ago

#1106 closed defect (fixed)

Compatibility issues between java mapscript 4.2.X and 4.4.0

Reported by: unicoletti Owned by: sgillies@…
Priority: high Milestone:
Component: MapScript-SWIG Version: 4.4
Severity: major Keywords:
Cc:

Description

When upgrading from Java mapscript 4.2.X to 4.4.0 my application failed to compile.
The problem lies in the new pointObj constructor that takes four arguments
(x,y,x,m) in place of the three (x,y,z) in previous versions.

Side note:
While this is a minor annoyance that is easy to fix, incompatibility between
different versions seems to be a pattern in java mapscript. In fact I had a
similar problem when upgrading from 4.0 to 4.2, and in that case I simply
changed my code (a very small code base) to be 4.2 compliant. Now that the
application is reaching maturity playing catch up with mapscript is becoming
more and more difficult, so I think we should work out a test suite for Java
mapscript that will make it easier to spot issues like this. Let me know what
your opinions are on this topic.

Attachments (2)

patchPointObj-compatibility.diff (915 bytes ) - added by unicoletti 19 years ago.
This patch introduces a backwards compatible contructor for pointObj in Java mapscript
MakePoint.java (310 bytes ) - added by unicoletti 19 years ago.
Small program to test pointObj constructor.

Download all attachments as: .zip

Change History (8)

by unicoletti, 19 years ago

This patch introduces a backwards compatible contructor for pointObj in Java mapscript

comment:1 by sdlime, 19 years ago

Component: MapScriptMapScript-SWIG
Owner: changed from sdlime to sgillies@…

comment:2 by sgillies@…, 19 years ago

The problem is that the old code was

   pointObj(x, y, m)

and now that we have Z for points in mapserver, it has been changed to
 
   pointObj(x, y, z, m)

In the Python case, swig emits constructors in which arguments with specified
values are *optional*.  The pointObj constructors is defined in point.i as

   pointObj(double x=-1, double y=-1, double z=0, double m=0)

so for Python we can do

   >>> p = pointObj()  # same as -1,-1,0,0
   >>> p = pointObj(10,10) # same as 10,10,0,0

It seems to be that there are no optional arguments for Java?

comment:3 by unicoletti, 19 years ago

Default arguments support for Java has been introduced in swig 1.3.23.
See
http://www.swig.org/Doc1.3/SWIGPlus.html#SWIGPlus_default_args

for more info. Upgrading swig is a bit difficult at the moment for me as gentoo
still ships 1.3.21 and 1.3.22 is unstable.

comment:4 by sgillies@…, 19 years ago

Status: newassigned
Umberto, I didn't realize that SWIG would generate multiple pointObj constructors
based on the signatures.  This is good :)

I have moved the Java pointObj constructors into java/javaextend.i to keep the
point.i file as simple as possible.

Can you test this for me?

comment:5 by unicoletti, 19 years ago

OK, it works.

I have written a small java program that can be used to test this patch, I
attach it. It can go in mapscript/java/examples.
No modifications to Makefile are required as the only requirement is that it
compiles.

by unicoletti, 19 years ago

Attachment: MakePoint.java added

Small program to test pointObj constructor.

comment:6 by sgillies@…, 19 years ago

Resolution: fixed
Status: assignedclosed
thanks, Umberto!  I committed to branch 4-4 and HEAD and am closing down this
bug.

Note: See TracTickets for help on using tickets.