This post originated from an RSS feed registered with Java Buzz
by Tim Vernum.
Original Post: Converting Java 8 syntax to Java 7
Feed Title: A word used to describe something
Feed URL: http://blog.adjective.org/feed/category/Development/rss2
Feed Description: Tim's random musings on software development, java, jetty and other such frivolities.
A project I was working on finished up abruptly, and I found myself with
some spare time over the last few weeks, so I decided to test out a new idea -
a utility to convert Java 8 syntax into Java 7
For the most part, this is simply an experiment - to see how difficult it
would be to write such a utility (and the short answer is that it's difficult
to do well, but certainly not impossible), but it has the potential to be
useful for supporting lambda-based code in environments that do not (yet) have
support for Java 8.
I have a working prototype, that supports conversion of a subset of Java 8
features. And by a subset, I mean essentially 1...
It can convert a variable declaration for a functional interface with a
lambda initializer into a anonymous inner class. e.g.
Callable<String> callable = () -> "abc" ;
is converted to
Callable<String> callable = new Callable<String>() {
public String call() throws java.lang.Exception {
return "abc";
}
};
It's a long way from being feature complete, but it's usable (within the
scope of what has been implemented). It looks like I'll be starting a new role
next week, so that may reduce my time to work on this project for a little
while - I wanted to get it published before that happened.