ArrayIndexOutOfBoundsException on getControllers()

ArrayIndexOutOfBoundsException inside CtrlEnv.getControllers()


      try
      {
         Controller[] con = ControllerEnvironment.getDefaultEnvironment().getControllers();

         for (int i = 0; i < con.length; i++)
         {
            System.out.println(con[i].getType().toString());
         }
      }
      catch (Exception exc)
      {
         exc.printStackTrace();
      }

http://home.hccnet.nl/s.balk/jinput_stack.png

I have the feeling it’s caught somewhere, because the Controller[] is filled with controllers after I press ‘continue’ (green arrow) in Eclipse.

The catch-block is never run. (no stacktrace printed)


Scanning jar: dxinput.jar

<snip>

Examining file : net/java/games/input/DirectInputEnvironmentPlugin.class
Found candidate class: net/java/games/input/DirectInputEnvironmentPlugin.class
Adding class to plugins:net.java.games.input.DirectInputEnvironmentPlugin

<snip>

Scanning jar: jutils.jar

<snip>

Examining file : net/java/games/util/plugins/Plugin.class
Found candidate class: net/java/games/util/plugins/Plugin.class

<note: nothing about 'adding' mentioned>

<snip>

<con[] printed after 'continue'>

mouse
buttons

Hi
So are you saying that no stacktrace appears on the console? the top of the debug window seems to be missing, and I’m guessing that shoes some more lines from the stack?. The console should contain some useful debug info, the bits you snipped, can you paste those too?

Cheers

Endolf

[quote]Hi
So are you saying that no stacktrace appears on the console?
[/quote]
Yes.

[quote]the top of the debug window seems to be missing, and I’m guessing that shoes some more lines from the stack?.
[/quote]
Ofcourse I would not do that, the line above it states:
“ArrayIndexOutOfBoundsException”

I updated the image to show it (check first post / refresh)

[quote]The console should contain some useful debug info, the bits you snipped, can you paste those too?
[/quote]
Sure, but AFAIK I did not snip any lines other than “Examining file: …” but I understand you cannot rely on that :slight_smile:

Here it is:


Scanning jar: dxinput.jar
Examining file : META-INF/
Examining file : META-INF/MANIFEST.MF
Examining file : net/
Examining file : net/java/
Examining file : net/java/games/
Examining file : net/java/games/input/
Examining file : net/java/games/input/DirectInputAxis.class
Examining file : net/java/games/input/DirectInputDevice.class
Examining file : net/java/games/input/DirectInputEnvironmentPlugin.class
Found candidate class: net/java/games/input/DirectInputEnvironmentPlugin.class
Adding class to plugins:net.java.games.input.DirectInputEnvironmentPlugin
Examining file : net/java/games/input/DirectInputKeyboard.class
Examining file : net/java/games/input/DirectInputMouse$BallAxis.class
Examining file : net/java/games/input/DirectInputMouse$BallImpl.class
Examining file : net/java/games/input/DirectInputMouse$ButtonImpl.class
Examining file : net/java/games/input/DirectInputMouse$ButtonsImpl.class
Examining file : net/java/games/input/DirectInputMouse.class
Examining file : net/java/games/input/DirectInputRumbler.class
Scanning jar: jinput.jar
Examining file : META-INF/
Examining file : META-INF/MANIFEST.MF
Examining file : net/
Examining file : net/java/
Examining file : net/java/games/
Examining file : net/java/games/input/
Examining file : net/java/games/input/test/
Examining file : net/java/games/input/AbstractAxis.class
Examining file : net/java/games/input/AbstractController.class
Examining file : net/java/games/input/Axis$Identifier.class
Examining file : net/java/games/input/Axis$POV.class
Examining file : net/java/games/input/Axis.class
Examining file : net/java/games/input/Controller$PortType.class
Examining file : net/java/games/input/Controller$Type.class
Examining file : net/java/games/input/Controller.class
Examining file : net/java/games/input/ControllerEnvironment.class
Examining file : net/java/games/input/ControllerEvent.class
Examining file : net/java/games/input/ControllerListener.class
Examining file : net/java/games/input/DefaultControllerEnvironment$1.class
Examining file : net/java/games/input/DefaultControllerEnvironment.class
Examining file : net/java/games/input/Keyboard$Key.class
Examining file : net/java/games/input/Keyboard$KeyID.class
Examining file : net/java/games/input/Keyboard.class
Examining file : net/java/games/input/Mouse$Ball.class
Examining file : net/java/games/input/Mouse$Button.class
Examining file : net/java/games/input/Mouse$ButtonID.class
Examining file : net/java/games/input/Mouse$Buttons.class
Examining file : net/java/games/input/Mouse.class
Examining file : net/java/games/input/PluginClassLoader$1.class
Examining file : net/java/games/input/PluginClassLoader$JarFileFilter.class
Examining file : net/java/games/input/PluginClassLoader.class
Examining file : net/java/games/input/Rumbler.class
Examining file : net/java/games/input/StandardKeyboard$KeyID.class
Examining file : net/java/games/input/StandardKeyboard.class
Examining file : net/java/games/input/test/AnalogAxisPanel.class
Examining file : net/java/games/input/test/AxisPanel.class
Examining file : net/java/games/input/test/ControllerReadTest$1.class
Examining file : net/java/games/input/test/ControllerReadTest.class
Examining file : net/java/games/input/test/ControllerTextTest.class
Examining file : net/java/games/input/test/ControllerWindow.class
Examining file : net/java/games/input/test/DigitalAxisPanel.class
Examining file : net/java/games/input/test/DigitalHatPanel.class
Examining file : net/java/games/input/test/RumbleTest.class
Examining file : net/java/games/input/Version.class
Scanning jar: jutils.jar
Examining file : META-INF/
Examining file : META-INF/MANIFEST.MF
Examining file : net/
Examining file : net/java/
Examining file : net/java/games/
Examining file : net/java/games/util/
Examining file : net/java/games/util/plugins/
Examining file : net/java/games/util/plugins/test/
Examining file : net/java/games/util/plugins/Plugin.class
Found candidate class: net/java/games/util/plugins/Plugin.class
Examining file : net/java/games/util/plugins/PluginLoader.class
Examining file : net/java/games/util/plugins/Plugins.class
Examining file : net/java/games/util/plugins/test/ClassRenderer.class
Examining file : net/java/games/util/plugins/test/ListUpdater.class
Examining file : net/java/games/util/plugins/test/PluginTest.class
Examining file : net/java/games/util/Version.class

after ‘continue’:


mouse
buttons

the last two lines are from my for-loop printing the types.

Running from the commandline gives the same output, not mentioning nor throwing an ArrayIndexOutOfBoundsException.

eclipse -> works, but requires to ‘continue’ after exception
commandline -> works.

Eclipse is tripping into debug mode the moment it sees a problem developing. There’s an option in the preferences to change this - “Pause execution on Exception” or something.

That doesn’t fix your problem, but it should explain the Eclipse/command line differences! ;D

Thanks, that ‘fixed’ it :slight_smile: