You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In jruby/jruby#6714 we discovered that jnr-ffi is attempting to bind a getsockoptInt method to the same named-C function, which of course fails.
The problem here is due to JRuby's BasicSocket using an interface for jnr-ffi that has default methods (utility wrappers around the other methods) which are not intended to be bound to a native endpoint. The java.lang.Proxy logic in Java 8-15 provides no way to invoke the default method, so we proceed to attempt to bind it as a native call.
Unfortunately the fixes for this are pretty heinous. This SO post seems to indicate that there is no clean way to fix it until Java 16. The only option for us in Java 8 would be to rework how the interface proxy gets initialized, passing in a Lookup that can access and call the default method.
Default methods on interfaces fed to java.lang.Proxy cannot be
invoked without using method handles, which requires a Lookup with
private access (acquired within the interface class). This commit
adds a load path that propagates such a Lookup through to the
eventual Proxy instance, allowing it to skip binding default
methods to their (nonexistent) native function, instead calling
the provided default method body.
Fixesjnr#249.
headius
added a commit
to headius/jnr-ffi
that referenced
this issue
Jun 14, 2021
In jruby/jruby#6714 we discovered that jnr-ffi is attempting to bind a
getsockoptInt
method to the same named-C function, which of course fails.The problem here is due to JRuby's BasicSocket using an interface for jnr-ffi that has default methods (utility wrappers around the other methods) which are not intended to be bound to a native endpoint. The java.lang.Proxy logic in Java 8-15 provides no way to invoke the default method, so we proceed to attempt to bind it as a native call.
Unfortunately the fixes for this are pretty heinous. This SO post seems to indicate that there is no clean way to fix it until Java 16. The only option for us in Java 8 would be to rework how the interface proxy gets initialized, passing in a Lookup that can access and call the default method.
https://stackoverflow.com/questions/26206614/java8-dynamic-proxy-and-default-methods
For now we will remove the default methods in JRuby, but this needs a proper fix in jnr-ffi.
The text was updated successfully, but these errors were encountered: