On 07/12/2013 01:22, Dan Xu wrote:
Hi All,
When working on src/solaris/native/sun/net/spi/DefaultProxySelector.c,
previously I tried to cached a jobject (The cached java object is
java.net.Proxy.NO_PROXY, which is a special type of Proxy.) as a
global static variable, no_proxy, in this c file. Its value is
initialized in the init() native function call. In the following proxy
query by calling native function, getSystemProxy(), I will just return
this no_proxy object if no proxy is found.
But strangely, in the case that I return this no_proxy object back to
java side, the program may throw an ClassCastException saying that the
object that is passed to java side is a java.io.FileDescriptor instead
of a java.net.Proxy. The problem only happened in jprt in test,
java/net/ProxySelector/MultiThreadedSystemProxies.java. If I test it
in my local linux, it seems always passed.
In addition, instead of caching this special proxy object, I modified
my change to create no_proxy jobject every time I need by using the
same code that I previously used to create no_proxy in the init()
function. And the change can pass the jprt test without any issue.
Does anyone know why the cached proxy object changed to a
FileDescriptor? Thanks!
-Dan
Just so I understand, did you use a JNI global when caching the reference?
-Alan