Java lambda表达式和switch语句会导致eclipse崩溃正常吗?

前端之家收集整理的这篇文章主要介绍了Java lambda表达式和switch语句会导致eclipse崩溃正常吗?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我只是无法弄清楚是什么导致了 eclipse中的stackoverflow问题.其实我确实知道,但我不知道为什么.我试过以下:

>重新启动我的电脑 – 呃
> Eclipse.exe -clean
>重新安装了一个新的日食
>每次都测试完全相同的代码,每次完全相同的代码看起来都会导致eclipse崩溃.代码是lambda表达式.在我按下句号键“.”之前一切正常.用于在switch语句中完成代码.

我的代码是:

albumList.getSelectionModel().selectedItemProperty()
        .addListener((ObservableValue obs,AbstractAlbum oldAlbum,AbstractAlbum selectedAlbum) -> {
     switch (type){
         test. // It doesn't matter what variable I use,valid or not,after the dot,eclipse crashes       
     }
});

我发现我的代码没有任何问题.我在这里遵循了这个教程:http://code.makery.ch/java/javafx-8-tutorial-intro/也有一个lambda表达式.我尝试在此代码添加一个开关,然后再次崩溃:

lastNameColumn.setCellValueFactory(cellData -> {
    switch (type){
        test. // again it crashed after a dot
    }
});

有人可以确认他们是否可以复制这个?我正在使用一个全新的Eclipse:Luna for java developer 64x – 最新的软件包.这是日食的日志:

!ENTRY org.eclipse.ui 4 0 2014-11-28 22:19:08.889
!MESSAGE Unhandled event loop exception
!STACK 0
org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.StackOverflowError)
    at org.eclipse.swt.SWT.error(SWT.java:4441)
    at org.eclipse.swt.SWT.error(SWT.java:4356)
    at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:139)
    at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4147)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3764)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1151)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1032)
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:148)
    at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:636)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:579)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:135)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
Caused by: java.lang.StackOverflowError
    at org.eclipse.jdt.internal.codeassist.UnresolvedReferenceNameFinder.visit(UnresolvedReferenceNameFinder.java:292)
    at org.eclipse.jdt.internal.compiler.ast.Block.traverse(Block.java:138)
    at org.eclipse.jdt.internal.compiler.ast.Initializer.traverse(Initializer.java:130)
    at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse(TypeDeclaration.java:1427)
    at org.eclipse.jdt.internal.compiler.ast.QualifiedAllocationExpression.traverse(QualifiedAllocationExpression.java:603)
    at org.eclipse.jdt.internal.compiler.ast.LambdaExpression.traverse(LambdaExpression.java:645)
    at org.eclipse.jdt.internal.compiler.ast.MessageSend.traverse(MessageSend.java:1015)
    at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.traverse(MethodDeclaration.java:347)
    at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse(TypeDeclaration.java:1434)
    at org.eclipse.jdt.internal.compiler.ast.QualifiedAllocationExpression.traverse(QualifiedAllocationExpression.java:603)
    at org.eclipse.jdt.internal.compiler.ast.LambdaExpression.traverse(LambdaExpression.java:645)
    at org.eclipse.jdt.internal.compiler.ast.MessageSend.traverse(MessageSend.java:1015)
    at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.traverse(MethodDeclaration.java:347)
    at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse(TypeDeclaration.java:1434)
    at org.eclipse.jdt.internal.compiler.ast.QualifiedAllocationExpression.traverse(QualifiedAllocationExpression.java:603)
    at org.eclipse.jdt.internal.compiler.ast.LambdaExpression.traverse(LambdaExpression.java:645)
    at org.eclipse.jdt.internal.compiler.ast.MessageSend.traverse(MessageSend.java:1015)
    at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.traverse(MethodDeclaration.java:347)
    at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse(TypeDeclaration.java:1434)
    at org.eclipse.jdt.internal.compiler.ast.QualifiedAllocationExpression.traverse(QualifiedAllocationExpression.java:603)

解决方法

也许时间可以治愈所有伤口? 原文链接:https://www.f2er.com/java/129145.html

猜你在找的Java相关文章