GSSCredential
Mark Rotteveel
mark at lawinegevaar.nl
Sat Jun 8 08:00:12 UTC 2019
On 7-6-2019 17:57, Douglas Surber wrote:
> And here is the result with requires java.security.jgss instead of requires static.
>
>> dhcp-10-159-154-205:~ douglas.surber$ tmp/bin/java --list-modules
>> bar.sql
>> baz
>> com.bar
>> java.base at 11.0.1
>> java.logging at 11.0.1
>> java.naming at 11.0.1
>> java.security.jgss at 11.0.1
>> java.security.sasl at 11.0.1
>> dhcp-10-159-154-205:~ douglas.surber$
I did some experiments, including generating a Proxy and using (direct)
reflection. When using the full runtime this will not yield a problem,
but in a fully modularized Java (built with jlink) generating a Proxy
will yield a `NoClassDefFoundError` like shown below (and similar for
calling `getDeclaredMethods` on the class implementing the interface or
on the interface).
Given using proxies and reflection is very common in JDBC drivers and
related tools and libraries (especially with `DataSource` related
things), declaring as `requires static` is not an acceptable solution.
Declaring with `requires` will be the minimum necessary to ensure proper
functionality and the least amount of surprise. Probably `requires
transitive` is better as JDBC drivers will need to actually implement
this method as well. Otherwise, the driver will need to use `requires
static`, `requires` or `requires transitive` themselves; although I have
actually not seen modularized JDBC drivers yet so maybe that is of
lesser importance.
That just leaves the question if this is an acceptable widening of the
dependencies of JDBC (for reference, the java.security.jgss.jmod is 623
kilobytes on my Java 11.0.3 compared to java.sql.jmod of 82 kilobytes).
I don't have a real objection to this, but on the other hand I don't see
the need for this method that can't be solved through vendor specific
means, or have been solved through vendor-specific means for a long time
already, so I wonder if this new method will see any real use.
Exception on creating proxy:
Exception in thread "main" java.lang.NoClassDefFoundError:
org/ietf/jgss/GSSCredential
at java.base/java.lang.Class.getDeclaredMethods0(Native Method)
at
java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3166)
at
java.base/java.lang.Class.privateGetPublicMethods(Class.java:3191)
at java.base/java.lang.Class.getMethods(Class.java:1904)
at
java.base/java.lang.reflect.Proxy$ProxyBuilder.referencedTypes(Proxy.java:712)
at
java.base/java.lang.reflect.Proxy$ProxyBuilder.<init>(Proxy.java:624)
at
java.base/java.lang.reflect.Proxy$ProxyBuilder.<init>(Proxy.java:635)
at
java.base/java.lang.reflect.Proxy.lambda$getProxyConstructor$0(Proxy.java:415)
at
java.base/jdk.internal.loader.AbstractClassLoaderValue$Memoizer.get(AbstractClassLoaderValue.java:329)
at
java.base/jdk.internal.loader.AbstractClassLoaderValue.computeIfAbsent(AbstractClassLoaderValue.java:205)
at
java.base/java.lang.reflect.Proxy.getProxyConstructor(Proxy.java:413)
at
java.base/java.lang.reflect.Proxy.newProxyInstance(Proxy.java:1006)
at test.user/test.user.Main.main(Main.java:18)
Caused by: java.lang.ClassNotFoundException: org.ietf.jgss.GSSCredential
at
java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
at
java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 13 more
--
Mark Rotteveel
More information about the jdbc-spec-discuss
mailing list