bcdev / jpy

A bi-directional Python-Java bridge used to embed Java in CPython or the other way round.
Apache License 2.0
187 stars 37 forks source link

Improve evaluation of method call #89

Open marpet opened 7 years ago

marpet commented 7 years ago

If a java method is called which is overloaded then in certain cases it can happen that more than one compatible is found. Both methods get the same match-value. But actually they are distinguishable.

The example is JAI.create(...) Called from Python: JAI.create("filestore", image, 'image.png', 'PNG') If image is a RenderedImage everything works, but if it is a BufferedImage jpy can't decide which method to call. This create-method exist in two flavours (actually but only two are of interest). JAI.create(String, RenderedImage, Object, Object)--> match-value 100, 90,10,10 for BufferedImage JAI.create(String, Object, Object, Object) --> match-value 100, 90,10,10 for BufferedImage Here the first method should be used because RenderedImage come first in the hierarchy.

If the image is cast to a RenderedImage first then it works.

RenderedImage = jpy.get_type('java.awt.image.RenderedImage')
rendered_image = jpy.cast(image, RenderedImage)
JAI.create("filestore", rendered_image, 'image.png', 'PNG')
MarkWilliamMatthews commented 6 years ago

I have this problem a lot when trying to subset products.

forman commented 6 years ago

@MarkWilliamMatthews could you please provide the code you use to create the subset. The more test cases we have for the issue, the better.