2013-08-29 2 views
0

매우 비정상적으로 동작하는 JavaFx 프로그램이 있습니다.텍스트 필드에서 Enter 키를 누르면 JVM이 충돌합니다.

텍스트 필드에서 Enter 키를 누르면 JVM이 충돌합니다. 이것은 this stackoverflow 질문에서 얻은 간단한 UI 프로그램입니다. 이 결백 한 찾고있는 프로그램에 무엇이 문제가 있습니까?

나는 Lubuntu 12.10JDK 1.7.0_09-b05을 실행 중입니다.

import com.sun.glass.events.KeyEvent; 

import javafx.application.Application; 
import static javafx.application.Application.launch; 
import javafx.event.*; 
import javafx.geometry.Pos; 
import javafx.scene.*; 
import javafx.scene.control.*; 
import javafx.scene.layout.*; 
import javafx.stage.*; 

public class MissingDataDemo extends Application { 
     private static final String[] SAMPLE_TEXT = "Lorem ipsum MISSING dolor sit amet MISSING consectetur adipisicing elit sed do eiusmod tempor incididunt MISSING ut labore et dolore magna aliqua" 
         .split(" "); 

     @Override 
     public void start(Stage primaryStage) { 
       VBox textContainer = new VBox(10); 
       textContainer 
           .setStyle("-fx-background-color: cornsilk; -fx-padding: 10;"); 

       primaryStage.setScene(new Scene(textContainer, 300, 600)); 
       primaryStage.show(); 

       TextLoader textLoader = new TextLoader(SAMPLE_TEXT, textContainer); 
       textLoader.loadText(); 
     } 

     public static void main(String[] args) { 
       launch(args); 
     } 
} 

class TextLoader { 
     private final String[] lines; 
     private final Pane container; 

     TextLoader(final String[] lines, final Pane container) { 
       this.lines = lines; 
       this.container = container; 
     } 

     public void loadText() { 
       for (String nextText : lines) { 
         final Label nextLabel = new Label(); 

         if ("MISSING".equals(nextText)) { 
           nextLabel.setStyle("-fx-background-color: palegreen;"); 

           MissingTextPrompt prompt = new MissingTextPrompt(container 
               .getScene().getWindow()); 

           nextText = prompt.getResult(); 
         } 

         nextLabel.setText(nextText); 

         container.getChildren().add(nextLabel); 
       } 
     } 

     class MissingTextPrompt { 
       private final String result; 

       MissingTextPrompt(Window owner) { 
         final Stage dialog = new Stage(); 

         dialog.setTitle("Enter Missing Text"); 
         dialog.initOwner(owner); 
         dialog.initStyle(StageStyle.UTILITY); 
         dialog.initModality(Modality.WINDOW_MODAL); 
         dialog.setX(owner.getX() + owner.getWidth()); 
         dialog.setY(owner.getY()); 

         final TextField textField = new TextField(); 
         final Button submitButton = new Button("Submit"); 
         submitButton.setDefaultButton(true); 

         submitButton.setOnAction(new EventHandler<ActionEvent>() { 
           @Override 
           public void handle(ActionEvent t) { 
             dialog.close(); 
           } 
         }); 

         textField.setMinHeight(TextField.USE_PREF_SIZE); 

         final VBox layout = new VBox(10); 
         layout.setAlignment(Pos.CENTER_RIGHT); 
         layout.setStyle("-fx-background-color: azure; -fx-padding: 10;"); 
         layout.getChildren().setAll(textField, submitButton); 

         dialog.setScene(new Scene(layout)); 
         dialog.showAndWait(); 

         result = textField.getText(); 
       } 

       private String getResult() { 
         return result; 
       } 
     } 
} 

덤프의 일부 -

# 
# A fatal error has been detected by the Java Runtime Environment: 
# 
# SIGSEGV (0xb) at pc=0xb6cfa39f, pid=14093, tid=1803479872 
# 
# JRE version: 7.0_09-b05 
# Java VM: Java HotSpot(TM) Server VM (23.5-b02 mixed mode linux-x86) 
# Problematic frame: 
# V [libjvm.so+0x42539f] jni_invoke_nonstatic(JNIEnv_*, JavaValue*, _jobject*, JNICallType, _jmethodID*, JNI_ArgumentPusher*, Thread*)+0x2f 
# 
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again 
# 
# If you would like to submit a bug report, please visit: 
# http://bugreport.sun.com/bugreport/crash.jsp 
# 

전체 덤프 here 사용할 수 있습니다.

편집 1 :

오라클 Java 1.7.0_25-b15의 최신 버전으로 실행도 충돌합니다.

편집 2 :

충돌하지 않는 OpenJDK 7u9-2.3.4-0ubuntu1.12.10.1으로 실행하지만, 다음 부여합니다 오류 -

Exception in thread "main" java.lang.RuntimeException: Exception in Application start method 
    at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:403) 
    at com.sun.javafx.application.LauncherImpl.access$000(LauncherImpl.java:47) 
    at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:115) 
    at java.lang.Thread.run(Thread.java:722) 
Caused by: java.lang.NullPointerException 
    at com.sun.glass.ui.gtk.GtkApplication.enterNestedEventLoopImpl(Native Method) 
    at com.sun.glass.ui.gtk.GtkApplication._enterNestedEventLoop(GtkApplication.java:137) 
    at com.sun.glass.ui.Application.enterNestedEventLoop(Application.java:383) 
    at com.sun.glass.ui.EventLoop.enter(EventLoop.java:83) 
    at com.sun.javafx.tk.quantum.QuantumToolkit.enterNestedEventLoop(QuantumToolkit.java:520) 
    at javafx.stage.Stage.showAndWait(Stage.java:397) 
    at com.mango.proengin.ui.user.TextLoader$MissingTextPrompt.<init>(MissingDataDemo.java:96) 
    at com.mango.proengin.ui.user.TextLoader.loadText(MissingDataDemo.java:52) 
    at com.mango.proengin.ui.user.MissingDataDemo.start(MissingDataDemo.java:28) 
    at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:319) 
    at com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:206) 
    at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:173) 
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:76) 
    at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method) 
    at com.sun.glass.ui.gtk.GtkApplication$3$1.run(GtkApplication.java:82) 
    ... 1 more 
+0

편집기에 코드 도구가 있습니다. 왜 pastebin에 링크합니까? 여기에 코드를 붙여주십시오. – BackSlash

+0

JVM을 업데이트 해 보셨습니까? JVM 버전은 꽤 오래된 버전입니다. [Java 7 Update Release Notes] (http://www.oracle.com/technetwork/java/javase/7u-relnotes-515228.html) 페이지에서 최신 버전 정보를 확인할 수 있습니다. – DaoWen

+0

@BackSlash 코드의 크기가 큽니다. 심지어 더 많은 839 라인의 JVM 덤프. –

답변

2

나에게 네이티브 UI 코드의 잠재적 인 스레딩 버그 같은데 -와 윈도우 7의 x64에 문제없이 실행중인 최신 JDK (현재 리눅스 컴퓨터에 액세스 할 필요가 없습니다.)

UI 코드가 pl에서 호출 된 적이있는 비슷한 기괴한 동작을 보았습니다 atform 스레드, 내가 할 수있는 한 여기에서 그런 일은 일어나지 않습니다. 그런데, 비록 (플랫폼 스레드에 있기 때문에) 어쨌든 Platform.runLater()에있는 문제의 코드 조각을 래핑하는 것이 문제를 해결할 수 있다는 것을 발견했거나 최소한 해결해야합니다.

 submitButton.setOnAction(new EventHandler<ActionEvent>() { 
      @Override 
      public void handle(ActionEvent t) { 
       Platform.runLater(new Runnable() { 
        @Override 
        public void run() { 
         dialog.close(); 
        } 
       }); 
      } 
     }); 

이상적이지는 않지만 GTK가 좋아하는 방식으로 스레딩이 변경 될 수 있습니다. 어느 쪽이든, 가능한 한 많은 예제를 간소화하고 (여전히 안정적으로 오류를 얻는 동안) 버그를보고 할 가치가 있습니다.

관련 문제