使用新的java 8 Optional.map在启动时导致服务器错误

使用新的java 8 Optional.map在启动时导致服务器错误,java,jetty,java-8,Java,Jetty,Java 8,我的团队刚刚升级到java 8,其中一些代码java.util.Optional映射代码似乎是罪魁祸首 我们有很多这样的代码行,当然,如果我们把它们注释掉,服务器就可以正常启动了 然而,我在其他组项目中使用了这个可选映射sytax,当您升级到java8时,它从未出现过问题 有什么想法吗?运行码头-9.2.5.v20141112 // this one definitely causes the server from starting up // if you comment it out it

我的团队刚刚升级到java 8,其中一些代码java.util.Optional映射代码似乎是罪魁祸首

我们有很多这样的代码行,当然,如果我们把它们注释掉,服务器就可以正常启动了

然而,我在其他组项目中使用了这个可选映射sytax,当您升级到java8时,它从未出现过问题

有什么想法吗?运行码头-9.2.5.v20141112

// this one definitely causes the server from starting up
// if you comment it out it start up just fine
java.util.Optional<DateRange> Dates = _obj.map(FactoryObject::getEntity).map(Entity::getDates);   

从错误来看,spring框架似乎正在尝试做一些事情。你可能也想从这个角度来调查。是的,这很奇怪。其中还有一些错误项,表示某个类服务具有相同的项目…与我的新类代码完全无关的是无法自动连接…以及其他一些bean错误。这是一个非常奇怪的问题,因为就像我说的,如果我注释掉_obj.map(..)行,它工作得很好。这是您使用的方法引用,而不是可选本身。可能与您最终使用的过时字节码生成库有关。@MarkoTopolnik我想您已经了解了一些事情。你能详细说明一下你所说的方法引用是什么意思吗?其中一些对象来自我们使用的不同组。我已经更新到jetty 9.x和mvn3以及所有java 8::javac,并在本地设置了字节码,服务器在本地框上运行find。
FactoryObject::getEntity
是一个方法引用,它在类代码中的存在会导致使用java 8特有的新功能。这会混淆旧的字节码操作代码。顺便说一句,您发布的堆栈跟踪只指向一行,在该行中异常被重新调用,因此它对于完整的诊断不是很有用。
mlWebApplicationContext   - Exception encountered during context initialization - cancelling refresh attempt
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘MyclassService’: Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: protected my project.namespace.service.ServiceUtil my project.namespace.service.ServiceUtil.impl.MyclassService.serviceUtil; nested exception is java.lang.VerifyError: Expecting a stackmap frame at branch target 143
Exception Details:
 Reason:
    Expected stackmap frame at this location.
  Bytecode:
    0x0000000: 2b3a 072c 3a08 b202 5c2a 2a19 0719 08b8
    0x0000010: 0262 3a09 b802 7707 bd00 0b3a 0a19 0a03
    0x0000020: 2a53 190a 0419 0753 190a 0519 0853 190a
    0x0000030: 0619 0953 bb02 6759 190a b702 6a13 026b
    0x0000040: b602 71b2 027d 59c7 0025 5712 a113 027e
    0x0000050: 05bd 0280 5903 1301 2e53 5904 1213 53b6
    0x0000060: 0284 1302 79b6 028a 59b3 027d 00c0 0279
    0x0000070: b602 90c0 0013 b0

        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:542) ~[spring-beans-4.1.0.RELEASE.jar:4.1.0.RELEASE]
        at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87) ~[spring-beans-4.1.0.RELEASE.jar:4.1.0.RELEASE]
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:323) ~[spring-beans-4.1.0.RELEASE.jar:4.1.0.RELEASE]
        ... 60 common frames omitted
Caused by: java.lang.VerifyError: Expecting a stackmap frame at branch target 108
Exception Details:
  Location: