I've followed the steps in this tutorial exactly to set up JInput 2.0.7, but I keep getting the following error:
我完全按照本教程中的步骤来设置JInput 2.0.7,但是我一直收到以下错误:
Loading: net.java.games.input.OSXEnvironmentPlugin
java.lang.ClassCastException: java.lang.String cannot be cast to [Ljava.lang.Object;
at net.java.games.input.OSXHIDDevice.addElements(OSXHIDDevice.java:163)
at net.java.games.input.OSXHIDDevice.addElements(OSXHIDDevice.java:172)
at net.java.games.input.OSXHIDDevice.getElements(OSXHIDDevice.java:178)
at net.java.games.input.OSXEnvironmentPlugin.createControllersFromDevice(OSXEnvironmentPlugin.java:226)
at net.java.games.input.OSXEnvironmentPlugin.enumerateControllers(OSXEnvironmentPlugin.java:262)
at net.java.games.input.OSXEnvironmentPlugin.<init>(OSXEnvironmentPlugin.java:136)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at java.lang.Class.newInstance(Class.java:442)
at net.java.games.input.DefaultControllerEnvironment.getControllers(DefaultControllerEnvironment.java:157)
at net.java.games.input.test.ControllerReadTest.<init>(ControllerReadTest.java:253)
at net.java.games.input.test.ControllerReadTest.main(ControllerReadTest.java:302)
It seems to be an error with the class itself, but I haven't seen this error anywhere else, and the article was published just last year as well. Is this a problem with JInput, or did I do something wront?
它本身似乎是一个错误,但我没有在其他任何地方看到过这个错误,这篇文章也是去年发布的。这是JInput的问题,还是我做了什么?
1 个解决方案
#1
0
at net.java.games.input.OSXHIDDevice.addElements(OSXHIDDevice.java:163)
this is were the error occurs. this seems to be an internal JInput error. You'd have to modify the source code of JInput to fix that.
这是发生错误。这似乎是一个内部JInput错误。您必须修改JInput的源代码才能解决这个问题。
Looked into the source code. This is the method that throws the exception.
查看源代码。这是抛出异常的方法。
private final void addElements(List elements, Map properties) {
Object[] elements_properties = (Object[])properties.get(kIOHIDElementKey);
if (elements_properties == null)
return;
for (int i = 0; i < elements_properties.length; i++) {
Map element_properties = (Map)elements_properties[i];
OSXHIDElement element = createElementFromElementProperties(element_properties);
if (element != null) {
elements.add(element);
}
addElements(elements, element_properties);
}
}
In this line the properties.get(kIOHIDElementKey) returns a String. The String cannot be casted to an Object[]:
在这一行中,properties.get(kIOHIDElementKey)返回一个String。 String无法转换为Object []:
Object[] elements_properties = (Object[])properties.get(kIOHIDElementKey);
#1
0
at net.java.games.input.OSXHIDDevice.addElements(OSXHIDDevice.java:163)
this is were the error occurs. this seems to be an internal JInput error. You'd have to modify the source code of JInput to fix that.
这是发生错误。这似乎是一个内部JInput错误。您必须修改JInput的源代码才能解决这个问题。
Looked into the source code. This is the method that throws the exception.
查看源代码。这是抛出异常的方法。
private final void addElements(List elements, Map properties) {
Object[] elements_properties = (Object[])properties.get(kIOHIDElementKey);
if (elements_properties == null)
return;
for (int i = 0; i < elements_properties.length; i++) {
Map element_properties = (Map)elements_properties[i];
OSXHIDElement element = createElementFromElementProperties(element_properties);
if (element != null) {
elements.add(element);
}
addElements(elements, element_properties);
}
}
In this line the properties.get(kIOHIDElementKey) returns a String. The String cannot be casted to an Object[]:
在这一行中,properties.get(kIOHIDElementKey)返回一个String。 String无法转换为Object []:
Object[] elements_properties = (Object[])properties.get(kIOHIDElementKey);