GSSCredential
Mark Rotteveel
mark at lawinegevaar.nl
Wed Jun 5 17:09:46 UTC 2019
On 5-6-2019 18:51, Douglas Surber wrote:
> I understand the intent of modules. Let's go back to Java 8. Both java.sql.ConnectionBuilder and java.security.jgss.GSSCredential are part of Java SE. Before modules we would have thought nothing of adding this method to the JDBC standard (at least in regard to dependency on GSSCredential). Is the new module system so restrictive that it effectively disallows adding this method? I don't believe that is the case.
>
> module java.sql {
> . . .
> requires static java.security.jgss;
> . . .
> }
>
> The above tells the JVM that java.security.jgss must be available to compile java.sql. This is interesting only when compiling Java SE which is not a typical user task. It does not require that java.security.jgss be available to compile or run code that requires java.sql. If a user wanted to call the method they would have to add
>
> requires java.security.jgss;
>
> to their own module-info.java.
>
> I do not consider this a reason not to include this method in JDBC.
As I said, I haven't done much with modules yet, so I'm not sure what
happens if you load the `ConnectionBuilder` interface which declares a
method with `GSSCredential`, or use an implementation that overrides
this method to be able to (not) support it.
I would expect that if you declare a method taking a certain type, that
you will need a requires dependency on the module and not a requires
static, because the type will need to be loaded for the method signature
(or otherwise when reflection occurs on methods, eg in proxies).
As far as I'm aware, requires static is only useful for things like
annotations (which are allowed to be absent from the classpath) and
annotation processors (which only need to be present during
compilation), or for optional dependencies that are used inside an
implementation (but not exposed in its API) where the implementation
will guard against absence of that optional dependency.
Mark
--
Mark Rotteveel
More information about the jdbc-spec-discuss
mailing list