MMCoreJ: Switch to SWIG 4 with compatibility tweak #699
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
MMCoreJ is currently built with SWIG 2-3 (2 on Windows, 3 on macOS, but it makes little difference).
SWIG 4 replaced the
std::vectorandstd::mapwrappers with versions that fit better into Java by extendingjava.util.Listandjava.util.Map.This results in the generated Java API from being incompatible with that generated by SWIG 2-3, in the following ways (based on japicmp output; see #37 for full details):
*Vector, with*=Boolean,Char,Double,Long,Str,Unsignedlong(and producing that many empty/zero elements) was removedadd()andset()was changed from primitive to boxed (for all butStrVector); these methods also newly have a return valueget()now returns boxed, rather than primitive, typesize()andcapacity()now returnintrather thanlongreserve()now takesintrather thanlongStrMapget()takesObjectinstead ofString(source-compatible but not binary-compatible)set()is replaced byput()del()is removed (in favor ofremove())has_key()is replaced bycontainsKey()empty()is replaced byisEmpty()size()now returnsintrather thanlong(I'm ignoring backward-compatible changes, and incompatible changes to generated classes that should not be considered part of the API, such as
MMCoreJJNI.)This PR explicitly adds back the
*Vectorconstructors takinglong. This was enough to get all of our Java modules inmicro-managerto compile (as of this writing).For the remaining incompatibilities, I suggest that we leave them alone:
The changes from unboxed to boxed types and from
longtointmay cause compile errors under certain usage, but they do not cause any silent change in semantics. And they are hopefully even less likely to cause errors in BeanShell scripts.I'm inclined leave
StrMapalone, sinceStrMapis not actually used as a parameter or return value to any API methods (currently, at least). Even if there is code that uses it, it will at most get a compile error that should be easy to fix.Before merging:
swig-doc-converter(used by apidoc CI) work with SWIG 4 output?micro-managerrepo needs SWIG 4Closes #37.