fix close/finalize
This commit is contained in:
parent
8105d3c8f5
commit
9b111665f1
|
@ -43,7 +43,10 @@ public class RegistryKey extends Win32Bindings
|
|||
|
||||
public void close()
|
||||
{
|
||||
RegCloseKey(this.m_hkey);
|
||||
if (this.m_hkey != 0) {
|
||||
RegCloseKey(this.m_hkey);
|
||||
this.m_hkey = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public RegistryKey createSubKey(String subkey)
|
||||
|
@ -223,8 +226,7 @@ public class RegistryKey extends Win32Bindings
|
|||
|
||||
protected void finalize()
|
||||
{
|
||||
if(this.m_hkey != 0)
|
||||
this.close();
|
||||
close();
|
||||
}
|
||||
|
||||
private static final native int RegCloseKey(long hkey);
|
||||
|
|
|
@ -16,6 +16,7 @@ public class TestRegistryKey extends TestCase {
|
|||
RegistryKey.LocalMachine.openSubKey("SOFTWARE");
|
||||
String[] keys = software.getSubKeyNames();
|
||||
assertTrue(keys.length > 0);
|
||||
software.close();
|
||||
}
|
||||
|
||||
//dont want to be writing to the registry
|
||||
|
|
Loading…
Reference in New Issue