Class does not compile when using the new 'Optional' feature of java 8

3

Good afternoon

I'm using play 2.5.4 with java 8 v01.08.91 And when using some features of java 8 as the class 'Optional' with the 'ifPresent', 'isPresent', or 'get' methods the following error occurs when compiling the java classes

"java.lang.ClassCastException: javassist.bytecode.InterfaceMethodrefInfo cannot be cast to javassist.bytecode.MethodrefInfo"

Specifically, this is the snippet of the problem code:

Optional<AppMobileWrapper> lastSend = appsWrapper.stream()
            .max(Comparator.comparing(f -> f.changeDate));

    lastSend.ifPresent(appMobileWrapper -> {
        returnWrapper.lastDate = DateUtils.currentDateNoTimeZoneString(appMobileWrapper.changeDate);
    });

I've tried everything, I've been looking for a solution for hours. My version of play is updated, java version updated, environment variables are ok and even tried to add the javassist dependency updated in the sbt dependencies and even then it does not work at all. Has anyone experienced this problem?

    
asked by anonymous 17.06.2016 / 21:03

1 answer

1

After an upgrade in play / java, I solved a similar problem following the instructions described on this project issue . In my case, I upgraded javassist to project/plugins.sbt :

libraryDependencies += "org.javassist" % "javassist" % "3.20.0-GA"

Since the same would be used by a sbt plugin at compile time and not at runtime.

    
17.06.2016 / 21:36