On Fri, 8 Apr 2022 13:50:25 GMT, Weijun Wang <wei...@openjdk.org> wrote:
>> Xue-Lei Andrew Fan has updated the pull request incrementally with one >> additional commit since the last revision: >> >> Update copyright year > > @bchristi-git showed me this test. You might try it on other objects: > > import org.ietf.jgss.GSSManager; > import org.ietf.jgss.GSSName; > > import java.util.WeakHashMap; > > public class A1 { > private static WeakHashMap whm = new WeakHashMap(); > public static void main(String[] args) throws Exception { > System.setProperty("sun.security.nativegss.debug", "true"); > System.setProperty("sun.security.jgss.native", "true"); > GSSName e = GSSManager.getInstance().createName("u1", > GSSName.NT_USER_NAME); > whm.put(e, null); > e = null; > for (int i = 0; i < 10; i++) { > System.gc(); > Thread.sleep(100); > } > if (whm.size() > 0) { > throw new RuntimeException("GSSName still reachable"); > } > } > } > > The test ensures the objects are GCed and there's no memory leak. You need to > inspect the debug output to make sure native resources are released. The > `NativeGSSContext` code still needs to be fixed. Thanks, @wangweij . Wherever practical, it would be good to include tests to confirm correct conversions from finalizer to Cleaner -- bugs can be subtle, and hard to spot. ------------- PR: https://git.openjdk.java.net/jdk/pull/8136