-
Notifications
You must be signed in to change notification settings - Fork 510
Description
Hello,
I am struggling with visual studio code and modules. I am working on project, which needs to use java.base/javax.smartcardio. But VS Code complains "ResponseAPDU cannot be resolved to a type".
The demo class to demonstrate the issue is:
import javax.smartcardio.ResponseAPDU;
public class SmartCardIoDemo {
public static void main(String[] args) throws Exception {
System.out.println("start");
ResponseAPDU rapdu = new ResponseAPDU(new byte[2]);
System.out.println("end");
}
}
It can be fixed it by adding module-info.java
module myModule {
requires java.smartcardio;
}
but this is not possible to do it in our codebase because we don't use java modules. If I run the build and test by maven, then it works fine (without any --add-exports etc).
I tried following change in settings.json but it didn't solve the issue:
{
"java.jdt.ls.vmargs":"--add-exports=java.base/javax.smartcardio=ALL-UNNAMED -XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx1G -Xms100m -Xlog:disable"
}
I am even bit confused which part (extension) complains about that import, because during opening of the project, I can click through reference of ResponseAPDU to see the decompiled code.

Sample app SmartCardio.zip
App can be executed by mvn clean package exec:java -Dexec.mainClass="com.mycompany.SmartCardIoDemo"
but if I click on run main method, I got this error in terminal:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
ResponseAPDU cannot be resolved to a type
ResponseAPDU cannot be resolved to a type
at com.mycompany.SmartCardIoDemo.main(SmartCardIoDemo.java:11)
Thx in advance for any advice.