Jython <---> Java 8 default Interfaces ... No Worky ! :(

I was hoping to wrap up working with the interfaces.  Mats and I made a lot of progress defining how future "attach" will work, and starting to get into the details of implementation.   I have been testing with START_INMOOV.bat script, but now realize there is a rather large issue.

The issue is the new improvement from Java 8 of "default" interface methods are not reachable from Jython !

Part of cleanup was to normalize lots of mrl code.  Normalizing is a very good thing.  Its when we find multiple copies of the same code in different areas.  Multiple copies of the same code is very difficult to maintain and evolve, because if some problem gets fixed in one copy, you are not guaranteed it will be fixed in the other copies.  However, if there is only a single copy it only needs to get "fixed" once !

Java 8 default interface methods allow code to exists without copies, so we were excited to start using this new feature.  But now these methods are "unseen" by Jython :(

What to do ?

I'm not sure, that's why I'm writing this post.  Considering Python is probably the most popular way to interact with MRL it would be very problematic to use default methods.  My only current thought is to try to implement more abstract classes.  This could solve the problem, but its a lot more work, and time, and it will not work for some Services which use multiple interfaces.


Looks like they are sort of aware of it here -> http://bugs.jython.org/issue2403 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Mats's picture

Java 8 interfaces

Hmm. They have been aware of the issue since 2015. I guess waiting for a fix is not an option. The last Jython release is 2.7.0 final from May 2015. 

When we switched to Java8, I updated the JFugue service to use the latest version. So that needs to be reverted if we downgrade to Java7.

The alternative would be to stay on Java8, but avoid the usage of default methods in the interfaces. 

GroG's picture

Aye ! I'm only switching to

Aye ! I'm only switching to find all the defaults... The intent is to still use Java 8 but choose our dependencies carefully

GroG's picture

For Example: I saw this

For Example:

I saw this Lambda expression in Arduino

return pinIndex.entrySet().stream().map(x -> x.getValue()).collect(Collectors.toList());

(I might have added it ... I don't remember :P )

But this seems to be a "silly" use of Java 8 Lambda just to convert a map to a list..

So this one I'll probably replace it with :

return new ArrayList<Value>(pinIndex.values());

The sad part is Interfaces with defaults was going to be a good addition, but I think I can do most (and maybe more) functionality with org.myrobotlab.service.abstracts

70 more to look into ;)