I am currently running into an issue where a usage of java.sql.Time in an
Agent prevents the agent from starting correctly when running on JDK 9.
Here is the example I am testing with:

https://github.com/AdoptOpenJDK/jdk9-jigsaw/tree/
master/session-1-jigsaw-intro/01_Greetings

I modified the run.sh to look like the following:

java -javaagent:/path/to/my/agent.jar \
     --module-path mods \
     --module com.greetings/com.greetings.Main

However, the JVM fails to start up due to simply trying to parse some JSON:

java.lang.NoClassDefFoundError: java/sql/Time
at com.google.gson.Gson.<init>(Gson.java:232)
at com.google.gson.GsonBuilder.create(GsonBuilder.java:545)
...


The usage of "java.sql.Time" in Gson is preventing the application from
starting because it does not use "requires java.sql" and the agent is
unable to specify this required dependency.


I can work around the issue by using "--add-modules=java.sql" but this is
pretty clunky to require users to have to specify yet another command line
option. I could remove the Gson dependency to work around the issue but I
have a feeling that a similar issue would likely crop up in the future.


Are there any documented ways of either:

1. Allowing an agent to specify dependencies that it needs while still
maintaining backward compatibility with at least Java 8

2. Giving an agent access to any required modules/packages in a
programmatic way, considering that an agent is part of the unnamed module
and may require access to JDK modules



Any help or direction here would be greatly appreciated. Thank you!

Reply via email to