JNA-JVM致命错误-XGetInputFocus-Ubuntu [英] JNA - JVM Fatal Error - XGetInputFocus - Ubuntu

查看:169
本文介绍了JNA-JVM致命错误-XGetInputFocus-Ubuntu的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

操作系统:Ubuntu 16.04
JNA:4.2.2
JDK:1.8.0u111

OS: Ubuntu 16.04
JNA: 4.2.2
JDK: 1.8.0u111

我正在尝试在Ubuntu上运行的JavaFX应用程序中使用JNA检索当前的焦点窗口.

I'm trying to retrieve the current focused window using JNA in a JavaFX application running on Ubuntu.

要实现我的目标,我正在使用X11 api,更确切地说是功能XGetInputFocus:

To achieve my goal, I'm using X11 api, more precisely the function XGetInputFocus in that way :

if (Platform.isLinux()) {

    System.err.println("Linux platform");

    final X11 x11 = X11.INSTANCE;
    final XLib xlib = XLib.INSTANCE;

    X11.Display display = x11.XOpenDisplay(null);

    //X11.Window window = new X11.Window();
    X11.WindowByReference winRef = new X11.WindowByReference();

    Pointer pointer = Pointer.NULL;

    xlib.XGetInputFocus(display, winRef, pointer);

    /*X11.XTextProperty name = new X11.XTextProperty();
    x11.XGetWMName(display, window, name);
    System.out.println(name.toString());*/
}

-

public interface XLib extends X11 {
    XLib INSTANCE = (XLib) Native.loadLibrary("X11", XLib.class);
    //void XGetInputFocus(X11.Display display, X11.Window focus_return, Pointer revert_to_return);
    void XGetInputFocus(X11.Display display, X11.WindowByReference focus_return, Pointer revert_to_return);
}

不幸的是,我遇到了以下异常,我尝试了X11.WindowByReferenceX11.Window具有参数,但是它什么都没有改变,异常是相同的.

Unfortunately, I got the following exception, I tried X11.WindowByReference and X11.Window has parameter, but it changes nothing, the exception is the same.

Linux platform
Looking in classpath from sun.misc.Launcher$AppClassLoader@73d16e93 for /com/sun/jna/linux-x86-64/libjnidispatch.so
Found library resource at jar:file:/home/puglic/eclipse/jna-4.2.2.jar!/com/sun/jna/linux-x86-64/libjnidispatch.so
Looking for library 'X11'
Adding paths from jna.library.path: null
Trying libX11.so
Found library 'X11' at libX11.so
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007f4063178e47, pid=21693, tid=0x00007f405423a700
#
# JRE version: Java(TM) SE Runtime Environment (8.0_111-b14) (build 1.8.0_111-b14)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.111-b14 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C  [libX11.so.6+0x22e47]  XGetInputFocus+0x57

此外,它还会生成一个名为hs_err_pid21693.log的巨大错误文件.在哪里可以找到这种线:

Also, It generates a huge error file named hs_err_pid21693.log. Where we can find this kind of line :

...
Internal exceptions (10 events):
Event: 0,223 Thread 0x00007f213000a000 Exception <a 'java/lang/NoSuchFieldError': method resolution failed> (0x00000000d7b0ded8) thrown at [/HUDSON3/workspace/8-2-build-linux-amd64/jdk8u111/7883/hotspot/src/share/vm/prims/methodHandles.cpp, line 1146]
Event: 0,262 Thread 0x00007f213000a000 Exception <a 'java/security/PrivilegedActionException'> (0x00000000d7b98008) thrown at [/HUDSON3/workspace/8-2-build-linux-amd64/jdk8u111/7883/hotspot/src/share/vm/prims/jvm.cpp, line 1386]
Event: 0,262 Thread 0x00007f213000a000 Exception <a 'java/security/PrivilegedActionException'> (0x00000000d7b98218) thrown at [/HUDSON3/workspace/8-2-build-linux-amd64/jdk8u111/7883/hotspot/src/share/vm/prims/jvm.cpp, line 1386]
Event: 0,263 Thread 0x00007f213000a000 Exception <a 'java/security/PrivilegedActionException'> (0x00000000d7b9a7e8) thrown at [/HUDSON3/workspace/8-2-build-linux-amd64/jdk8u111/7883/hotspot/src/share/vm/prims/jvm.cpp, line 1386]
Event: 0,263 Thread 0x00007f213000a000 Exception <a 'java/security/PrivilegedActionException'> (0x00000000d7b9a9f8) thrown at [/HUDSON3/workspace/8-2-build-linux-amd64/jdk8u111/7883/hotspot/src/share/vm/prims/jvm.cpp, line 1386]
Event: 0,263 Thread 0x00007f213000a000 Exception <a 'java/lang/NullPointerException'> (0x00000000d7b9afd0) thrown at [/HUDSON3/workspace/8-2-build-linux-amd64/jdk8u111/7883/hotspot/src/share/vm/interpreter/linkResolver.cpp, line 1178]
Event: 0,621 Thread 0x00007f21302c1800 Exception <a 'java/lang/NullPointerException'> (0x00000000d8349f68) thrown at [/HUDSON3/workspace/8-2-build-linux-amd64/jdk8u111/7883/hotspot/src/share/vm/interpreter/linkResolver.cpp, line 1178]
Event: 0,621 Thread 0x00007f21302c1800 Exception <a 'java/lang/NullPointerException'> (0x00000000d8349f68) thrown at [/HUDSON3/workspace/8-2-build-linux-amd64/jdk8u111/7883/hotspot/src/share/vm/prims/jvm.cpp, line 1390]
Event: 0,871 Thread 0x00007f21302c1800 Exception <a 'java/io/FileNotFoundException'> (0x00000000d87dc6d8) thrown at [/HUDSON3/workspace/8-2-build-linux-amd64/jdk8u111/7883/hotspot/src/share/vm/prims/jni.cpp, line 709]
Event: 1,041 Thread 0x00007f21302c1800 Implicit null exception at 0x00007f212120d176 to 0x00007f212120d531
...

推荐答案

我不认为XGetInputFocus允许您选择传入NULL作为最终参数.您需要传递一个有效内存位置的地址,该函数可以在其中写入其revert_to返回"值.

I don't think XGetInputFocus gives you the option of passing in NULL as the final argument. You need to pass in the address of a valid memory location where the function can write its revert_to "return" value.

您应该使用非null IntByReference对象而不是NULL.

You should use a non-null IntByReference object rather than NULL.

这篇关于JNA-JVM致命错误-XGetInputFocus-Ubuntu的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆