On 12/07/2013 02:57 AM, Alan Bateman wrote:
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
Hi Alan,

What is a JNI global? What I use here is a static global variable. I have uploaded this file to http://cr.openjdk.java.net/~dxu/8025437/DefaultProxySelector1.c. You can search for "no_proxy". I have declared this variable as "static jobject' at the beginning, and initialized it in function initJavaClass().

The error message can be found at http://prt-web.us.oracle.com//archive/2013/12/2013-12-07-173617.dan.jdk8Repo4/logs/linux_x64-product-c2-jdk_net.log.FAILED.log

Thanks!

-Dan


Reply via email to