Lambda expression throws exception

I just started a new vaadin project with maven (com.vaadin: vaadin-archetype-application@7.2.6 ).

In the standard MyVaadinUI.java I replaced Butten.ClickListener() with a lambda expression, after which I get an exception while package jetty:run

Before:

 Button button = new Button("Click Me"); button.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { layout.addComponent(new Label("Thank you for clicking")); } }); layout.addComponent(button); 

After:

 Button button = new Button("Click Me"); button.addClickListener(event -> layout.addComponent(new Label("Thank you for clicking"))); layout.addComponent(button); 

An exception:

 2014-08-26 13:23:30.069:WARN:oeja.AnnotationParser:EXCEPTION java.lang.ArrayIndexOutOfBoundsException: 1612 at org.objectweb.asm.ClassReader.readClass(Unknown Source) at org.objectweb.asm.ClassReader.accept(Unknown Source) at org.objectweb.asm.ClassReader.accept(Unknown Source) at org.eclipse.jetty.annotations.AnnotationParser.scanClass(AnnotationParser.java:899) at org.eclipse.jetty.annotations.AnnotationParser.parse(AnnotationParser.java:755) at org.eclipse.jetty.annotations.AnnotationParser.parse(AnnotationParser.java:744) at org.eclipse.jetty.annotations.AnnotationParser.parse(AnnotationParser.java:744) at org.mortbay.jetty.plugin.MavenAnnotationConfiguration.doParse(MavenAnnotationConfiguration.java:73) at org.mortbay.jetty.plugin.MavenAnnotationConfiguration.parseWebInfClasses(MavenAnnotationConfiguration.java:52) at org.eclipse.jetty.annotations.AnnotationConfiguration.configure(AnnotationConfiguration.java:119) at org.eclipse.jetty.webapp.WebAppContext.configure(WebAppContext.java:468) at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1237) at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:717) at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:494) at org.mortbay.jetty.plugin.JettyWebAppContext.doStart(JettyWebAppContext.java:298) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64) at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:229) at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:172) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64) at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:229) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64) at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:95) at org.eclipse.jetty.server.Server.doStart(Server.java:282) at org.mortbay.jetty.plugin.JettyServer.doStart(JettyServer.java:65) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64) at org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:520) at org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:365) at org.mortbay.jetty.plugin.JettyRunMojo.execute(JettyRunMojo.java:523) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:347) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:582) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214) at org.apache.maven.cli.MavenCli.main(MavenCli.java:158) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) at org.codehaus.classworlds.Launcher.main(Launcher.java:46) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134) 

I am using IntelliJ13.1 with JDK8 on OSX

+6
source share
2 answers

I ran into this problem when I deployed the application to the berth 8.12.x I solved the problem by upgrading to berth 9.2.x (Yes, lambdas are used in the application)

+4
source

I read many pages about this problem because I met it too.

For me, the solution was simple, but hard to find. I am using jetty-8.1.10 with asm-3.3.1, as well as with primary-5.1.

The problem occurs when you have lambda expressions in any of the annotated classes or in any class referenced by the annotated ones.

Just changing the code from Java 8 compliance to Java 7 (lambda expressions in normal Java 7 code), the warnings are gone. This is only possible for debugging org.objectweb.asm.ClassReader .

Greetings.

+3
source

Source: https://habr.com/ru/post/974365/


All Articles