Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
355 views
in Technique[技术] by (71.8m points)

java - Assertion failure in NSEvent?

thanks for taking the time to read this. I'm fairly new to JavaFX and have a weird error in my compiler that I would like some insight on.

Here's the error:

2018-09-13 19:09:36.387 java[8040:660455] unrecognized type is 4294967295
2018-09-13 19:09:36.387 java[8040:660455] *** Assertion failure in -[NSEvent _initWithCGEvent:eventRef:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/AppKit/AppKit-1652/AppKit.subproj/NSEvent.m:1969

Here is the code I am working with: This is in a .java file named applicationSettings

public static double lookupUser(String name, String password) throws IOException {
    InputStream inputStream = applicationSettings.class.getResourceAsStream("/files/users.xlsx");
    XSSFWorkbook workbook = new XSSFWorkbook(inputStream);
    XSSFSheet sheet = workbook.getSheetAt(0);
    Integer lastRow = sheet.getPhysicalNumberOfRows();
    int currentRow = 1;

    while(currentRow < lastRow) {
        if(sheet.getRow(currentRow).getCell(0).getStringCellValue().toLowerCase().equals(name.toLowerCase())) {
            if(sheet.getRow(currentRow).getCell(1).getStringCellValue().toLowerCase().equals(password.toLowerCase())) {
                double accessLevel = sheet.getRow(currentRow).getCell(2).getNumericCellValue();
                System.out.println(accessLevel);
                return accessLevel;
            }
        }
        currentRow++;
    }
    return 4.0;
}

}

This is in a .java file named loginScreen

EventHandler<ActionEvent> loginClicked = new EventHandler<ActionEvent>() {
        public void handle(ActionEvent event) {
            double userFound =  0.0;
            try {
                userFound = applicationSettings.lookupUser(usernameField.getText(), passwordField.getText());
            } catch (IOException e) {
                e.printStackTrace();
            }//END of Try/Catch
            if(userFound == 1.0) { //1 is Admin Access
                //TODO: Implement Login
                System.out.println("Admin Login");
                errorLabel.setVisible(false);

            }else if(userFound == 2.0){ //2 is Elevated Access
                //TODO: Elevated Access
                System.out.println("Elevated Login");
                errorLabel.setVisible(false);

            }else if(userFound == 3.0){ 
                //TODO: Basic Access
                System.out.println("Basic Login");
                errorLabel.setVisible(false);
            }else{//Show Error
                errorLabel.setVisible(true);
                //TODO: Show Error
            }//End If Statement
        }

    };

My Excel File is basically structured like this:

NAME    PASSWORD    ACCESS LEVEL

So for my login it would be like:

Trey Carey  March3199;  1

This isn't going anywhere besides by church where it's not really doing anything besides automating some tedious tasks, so security isn't an issue.

Also, if there's anyway I can clean up some of these if statements and my code in general I would appreciate any tips or help!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Edit 2 13.11.2018: This bug has been officially fixed now in JavaFX 12, was backported to JDK8 and approved to be backported to JFX 11. You can have a look at the bug report to find more information about it.JDK-8211304 Here is a link to the changes they've made. openjfx I'm personally not sure about the current license situation of JDK8 so I would advise to switch to the newest OpenJDK and OpenJFX if possible.

Hey there I'm experiencing the same issue you have and I can constantly reproduce it. The issue appears for me on JavaFX on macOS 10.14. You can simply create an application with a button that opens a second stage. If you invoke stage.showAndWait() (could be related to anything that holds the thread) on the second stage and then switch focus between different applications (I just alt-tab between my JavaFX app and Safari), the JavaFX Application crashes. Also reproducible in any IDE.

I actually found a bug report on the OpenJDK/OpenJFX bug tracker but there isn't much going on at the moment. JDK-8211137 Mac: JVM Crash due to uncaught exception

I don't have a solution yet as I'm having troubles pinning down the exact problem but I found a workaround that works in my specific case.

Edit: If I'm using "stage.show()" I'm only getting the error but when using stage.showAndWait() or anything that does some kind of waiting loop, the application completely crashes.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...