From b6a675cf1d471a2341258f9f56c783cf8e3b4768 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 18 Apr 2019 23:22:01 +0100 Subject: [PATCH] Add potential incompatibility info for Java std::vector wrappers --- CHANGES.current | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 3c819bd88..9633d07e7 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1390,6 +1390,35 @@ Version 4.0.0 (in progress) 2017-05-26: Volker Diels-Grabsch, vadz [Java] #842 Extend from java.util.AbstractList<> and implement java.util.RandomAccess for std::vector wrappers. This notably allows to iterate over wrapped vectors in a natural way. + Note that boxed types are now used in the Java layer when wrapping vector of C primitive + types, for example. This may introduce some subtle incompatibilities due to some + differences in how Java converts boxed types and unboxed types. For example, + + int i=0; + double d1 = i; // ok + Double d2 = i; // error: incompatible types: int cannot be converted to Double + + This can be a problem when calling the add and set functions. A suggested backwards + compatible workaround is to use something like (shown for std::vector: + + #if defined(SWIGJAVA) + // Add in old api that uses non-boxed types + %extend std::vector { + %proxycode %{ + public void add(double x) { + add(Double.valueOf(x)); + } + public void set(int i, double val) { + set(i, Double.valueOf(val)); + } + %} + } + #endif + + %include "std_vector.i" + %template(VectorDouble) std::vector; + + *** POTENTIAL INCOMPATIBILITY *** 2017-05-30: davidcl [Scilab] #994 Undefined symbol error when loading in Scilab 6