licel / jcardsim

https://jcardsim.org
223 stars 123 forks source link

Running jcardsim with eclipse: java.lang.IllegalArgumentException: wrong number of arguments #143

Closed iSecurus closed 5 years ago

iSecurus commented 5 years ago

Hey, when I try to include jcardsim into my project for debug reasons, i got the following error:

Exception in thread "main" java.lang.RuntimeException: Internal reflection error at com.licel.jcardsim.base.SimulatorRuntime.(SimulatorRuntime.java:95) at com.licel.jcardsim.base.SimulatorRuntime.(SimulatorRuntime.java:75) at com.licel.jcardsim.smartcardio.CardSimulator.(CardSimulator.java:44) at test.DebugMain.main(DebugMain.java:18) Caused by: java.lang.IllegalArgumentException: wrong number of arguments 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 com.licel.jcardsim.base.SimulatorRuntime.(SimulatorRuntime.java:85) ... 3 more

My setup is:

// 1. Create simulator CardSimulator simulator = new CardSimulator();

// 2. Install applet AID appletAID = AIDUtil.create("F000000001"); simulator.installApplet(appletAID, HelloWorldApplet.class);

// 3. Select applet simulator.selectApplet(appletAID);

// 4. Send APDU CommandAPDU commandAPDU = new CommandAPDU(0x00, 0x01, 0x00, 0x00); ResponseAPDU response = simulator.transmitCommand(commandAPDU);

// 5. Check response status word assertEquals(0x9000, response.getSW());

With this setup i have tried differnt jcardsim versions (2.2.2, 3.0.4, 3.0.5) combined with different java versions (1.5, 1.6, 1.8) and java card versions (2.2.2, 3.0.2, 3.0.5) and created two debug configurations within eclipse:

My reserach resulted in the knowledge, that jcardsim should use the implemented APDUProxy.class, which needs an argument when calling the constructor. But when running it with Eclipse, it will load the normal APDU.class and fails with "IllegalArgumentException". But I have no idea how to fix this. Also it is curious, that everything works fine, when using the cmdline to run jcardsim.

Is there something missing in the configuration or do I miss something else? How can I configure jcardsim to run in the eclipse debugger finally?

iSecurus commented 5 years ago

The problems were caused by the api_classic.jar in the classpath and later on by the missing -noverify-flag. After removing the user classpath completely from the Debug-Configuration, re-adding the jar file for jcardsim and the -noverify option to the VM arguments everything works fine!