On Sat, 9 Apr 2022 15:00:46 GMT, Weijun Wang <wei...@openjdk.org> wrote:
>>> You might try it on other objects: >> >> Nice idea to test object collection. I added two test cases. >> >>> The `NativeGSSContext` code still needs to be fixed. >> >> Could you have more details? I did not catch the comment about >> NativeGSSContext. > >> Could you have more details? I did not catch the comment about >> NativeGSSContext. > > When `NativeGSSContext(GSSNameElement peer, GSSCredElement myCred, int time, > GSSLibStub stub)` is called, `pContext` is 0 and you haven't registered the > cleaner. Later, when `initSecContext()` is called, it calls into > `cStub.initContext()` and this native method will set `pContext` if a context > is established. Since you haven't registered the cleaner in the ctor, this > native context will not be released at the end. > > So one solution is to add a `setNativeContext(long pContext)` method and when > this method is called you register the cleaner. Now, inside the native > method, instead of setting the `pContext` field directly you can call this > setter method. Or, move `cStub` and `pContext` into a new static inner class > and let `disposerFor` work on it. @wangweij In the following constructor, I'm not sure if the assert right. NativeGSSContext(long pCtxt, GSSLibStub stub) throws GSSException { assert(pContext != 0); ... Should it be `assert(pCtxt != 0);`? ------------- PR: https://git.openjdk.java.net/jdk/pull/8136