Skip to content

Groovy with Java OpenCV bindings problem

June 8, 2013

I setup a very simple Groovy / OpenCV example but it throws a java.lang.UnsatisfiedLinkError. This exposed some interoperability issues between Groovy and Java that I was unaware of.

But the same code in Java runs perfectly.

So what’s the fix?

The fix involves exploiting the fact that Groovy doesn’t have package-private methods like Java by default. Instead in Groovy, you would have to use an annotation @PackageScope. But the Groovy Runtime actually interprets Java code as Groovy code, so Java’s package private methods are public in Groovy by default. But that’s not all, even private Java methods are easily accessible by Groovy, and it’s a well known issue in Groovy. GROOVY-1875


From → Java

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: