loadLibrary as of v4.4.0 currently looks like this:
{code}
public static T loadLibrary(String name, Class interfaceClass, Map<String, ?> options) {
if (!Library.class.isAssignableFrom(interfaceClass)) {
throw new IllegalArgumentException("Interface (" + interfaceClass.getSimpleName() + ")"
+ " of library=" + name + " does not extend " + Library.class.getSimpleName());
}
{code}
This allows code to compile but then throws an error at runtime, which is trappy. We hit this when we had a library defined as:
{code}
public interface Kernel32Custom extends WinNT
{code}
WinNT did extend Library in v4.0.0 but does not in v4.4.0.
Instead, the signature should just take <T extends Library>.
{code}
public static T loadLibrary(String name, Class interfaceClass, Map<String, ?> options) {
{code}
Then this change would have shown up as a compile-time error, making it possible to catch the issue much sooner.
loadLibraryas of v4.4.0 currently looks like this:{code}
public static T loadLibrary(String name, Class interfaceClass, Map<String, ?> options) {
if (!Library.class.isAssignableFrom(interfaceClass)) {
throw new IllegalArgumentException("Interface (" + interfaceClass.getSimpleName() + ")"
+ " of library=" + name + " does not extend " + Library.class.getSimpleName());
}
{code}
This allows code to compile but then throws an error at runtime, which is trappy. We hit this when we had a library defined as:
{code}
public interface Kernel32Custom extends WinNT
{code}
WinNTdid extendLibraryin v4.0.0 but does not in v4.4.0.Instead, the signature should just take
<T extends Library>.{code}
public static T loadLibrary(String name, Class interfaceClass, Map<String, ?> options) {
{code}
Then this change would have shown up as a compile-time error, making it possible to catch the issue much sooner.