Skip to content

Get two bytes for the Linux input event type, not four

Component

Type: Bug

Product/Category: JavaFX

Subcategory: Graphics

Release: 8 Update 112 (1.8.0_112)

Operating System: Ubuntu - 64 bit

Details

More details about the problem (★ indicates required fields).

★ Synopsis:

Get two bytes for the Linux input event type, not four

Full OS version:

Ubuntu 16.04.1 LTS with Linux kernel: Linux gx620 4.4.0-45-generic #66-Ubuntu SMP Wed Oct 19 14:12:37 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux.

Additional Configuration Information:

The Java VM is Oracle JDK 8 Update 112 with the x86egl overlay bundle built from the OpenJFX 8 sources on October 27, 2016. The test machine is a Dell OptiPlex GX620 with 4 GB of RAM and 2 logical processors (one 3.0 GHz Intel Pentium 4 Processor 630 with hyper-threading enabled).

Development Kit or Runtime version:

$ ~/opt/jdk1.8.0_112/bin/java -version
java version "1.8.0_112"
Java(TM) SE Runtime Environment (build 1.8.0_112-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.112-b15, mixed mode)

★ Description:

The Linux input event type is defined in linux/input.h as an unsigned short, two bytes in size:

/*
 * The event structure itself
 */

struct input_event {
        struct timeval time;
        __u16 type;
        __u16 code;
        __s32 value;
};

Yet the first statement in the constructor for com.sun.glass.ui.monocle.LinuxEventBuffer reads four bytes for the event type by calling getInt as follows:

boolean isSync = event.getInt(eventStruct.getTypeIndex()) == 0
        && event.getInt(eventStruct.getValueIndex()) == 0;

The other occurrences in LinuxEventBuffer use the correct getShort method to get the event type.

★ Frequency:

☒ Always
☐ Often
☐ Occasionally
☐ Rarely

Regression:

Unknown.

Steps to Reproduce:

Run any JavaFX program with mouse or keyboard input.

Expected Result:

There are no external symptoms for the error.

Actual Result:

There are no external symptoms for the error.

Error Message(s)/Crash Logs:

None.

Source code for an executable test case:

You can use the program below to step through the code:

package org.status6.hello;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

public class HelloApp extends Application {

    private static final String TITLE = "Hello App";
    private static final String LABEL = "Say Hello";
    private static final String MESSAGE = "Hello World!";
    private static final int WIDTH = 800;
    private static final int HEIGHT = 600;

    @Override
    public void start(Stage stage) {
        Button button = new Button();
        button.setText(LABEL);
        button.setOnAction(e -> System.out.println(MESSAGE));

        StackPane root = new StackPane();
        root.getChildren().add(button);
        Scene scene = new Scene(root, WIDTH, HEIGHT);

        stage.setTitle(TITLE);
        stage.setScene(scene);
        stage.show();
    }

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

Click the program's button to enter the LinuxEventBuffer constructor.

Run the program with a command like the following:

$ sudo ~/opt/jdk1.8.0_112/bin/java \
  -Dglass.platform=Monocle -Dmonocle.platform=Linux -Dprism.order=sw \
  -jar ~/lib/hello.jar

Debug the program remotely in NetBeans with:

$ sudo ~/opt/jdk1.8.0_112/bin/java \
  -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y \
  -Dglass.platform=Monocle -Dmonocle.platform=Linux -Dprism.order=sw \
  -jar ~/lib/hello.jar

You must run the program as root so that the program has permission to access the Linux input and framebuffer devices.

Workaround:

None.

★ Severity:

☐ Can not make any progress until this bug is resolved.
☐ Difficult to make even minimal progress without resolving this bug.
☐ Some progress is possible without resolving this bug.
☒ No Impact.

User Information

★ Your Name: John Neffenger

★ Company: Status Six Communications

★ Email: john@status6.com