This code fails with IllegalArgumentException:
var pattern = new java.util.ArrayList();
pattern.add(1.0);
pattern.add(1.0);
new QPen().setDashPattern(list);
The fix is:
var pattern = new java.util.ArrayList();
pattern.add(new java.lang.Double(1));
pattern.add(new java.lang.Double(1));
new QPen().setDashPattern(list);
The root reasons for the problem are:
- java generics type erasure means that jambi's java.util.List<double>
is seen as java.util.List from our side (from qt4dotnet)
- Therefore we can push anything onto a list, and pass it to
setDashPattern with no static typechecking
- When we push a 1.0 onto the list, it gets boxed, but does *not* get
boxed into a java.lang.Double object - it gets boxed into a
.NETSystem.Double object
- jambi of course barfs on that System.Double since it expects a
java.lang.Double
- we workaround it by doing the java-style boxing by hand.