You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2011/05/03 11:29:41 UTC

svn commit: r1098982 - in /commons/sandbox/runtime/trunk/src/main: java/org/apache/commons/runtime/ java/org/apache/commons/runtime/platform/windows/ native/os/win32/ test/org/apache/commons/runtime/

Author: mturk
Date: Tue May  3 09:29:41 2011
New Revision: 1098982

URL: http://svn.apache.org/viewvc?rev=1098982&view=rev
Log:
Split RegistryKey api to abstract and implementation

Added:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/RegistryKeyImpl.java   (with props)
Modified:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Limits.java
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Platform.java
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Vm.java
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/Registry.java
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/RegistryKey.java
    commons/sandbox/runtime/trunk/src/main/native/os/win32/registry.c
    commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestRegistry.java

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Limits.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Limits.java?rev=1098982&r1=1098981&r2=1098982&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Limits.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Limits.java Tue May  3 09:29:41 2011
@@ -38,6 +38,7 @@ public final class Limits
         SIZE_T_MAX  = Platform.SIZE_T_MAX;
         SHMMAX      = Platform.SHMMAX;
         SHMMIN      = Platform.SHMMIN;
+        NOFILE      = Platform.NOFILE;
     }
 
     /**
@@ -65,5 +66,11 @@ public final class Limits
      */
     public static final long    SHMMAX;
 
+    /**
+     * The maximum file descriptor number that can be opened by this process.
+     * Zero means unknown, so presumably unlimited.
+     */
+    public static final int     NOFILE;
+
 }
 

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Platform.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Platform.java?rev=1098982&r1=1098981&r2=1098982&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Platform.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Platform.java Tue May  3 09:29:41 2011
@@ -87,6 +87,7 @@ final class Platform
         SIZE_T_MAX                      =   s[10];
         SHMMIN                          =   s[11];
         SHMMAX                          =   s[12];
+        NOFILE                          =   (int)s[13];
     }
 
     /**
@@ -158,6 +159,11 @@ final class Platform
      */
     public static final long    SHMMAX;
 
-
+    /**
+     * The maximum file descriptor number that can be opened by this process.
+     * Zero means unknown, so presumably unlimited.
+     */
+    public static final int     NOFILE;
+    
 }
 

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Vm.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Vm.java?rev=1098982&r1=1098981&r2=1098982&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Vm.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Vm.java Tue May  3 09:29:41 2011
@@ -33,15 +33,15 @@ public final class Vm
     /**
      * Returns the process ID of the current VM.
      */
-    public static native int getPid();
+    public  static native int getPid();
 
     /**
      * Returns the process ID of the parent of the current VM.
      */
-    public static native int getParentPid();
+    public  static native int getParentPid();
 
-    public static final File exec;
-    public static native String exe0();
+    private static final File exec;
+    private static native String exe0();
 
     static {
         exec = new File(exe0());
@@ -50,7 +50,7 @@ public final class Vm
     /**
      * Returns full path to the current JVM executable.
      */
-    public static final File executable()
+    public  static final File executable()
     {
         return exec;
     }

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/Registry.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/Registry.java?rev=1098982&r1=1098981&r2=1098982&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/Registry.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/Registry.java Tue May  3 09:29:41 2011
@@ -44,9 +44,67 @@ public final class Registry
     private Registry()
     {
     }
+    /** Registry entries subordinate to this key define types (or classes)
+     * of documents and the properties associated with those types. Shell
+     * and COM applications use the information stored under this key.
+     * For more information, see {@code HKEY_CLASSES_ROOT} Key.
+     * <p>
+     * This key also provides backward compatibility with the Windows 3.1
+     * registration database by storing information for DDE and OLE support.
+     * File viewers and user interface extensions store their OLE class
+     * identifiers in {@code HKEY_CLASSES_ROOT}, and in-process servers are
+     * registered in this key.
+     * </p>
+     * This handle should not be used in a service or an application that
+     * impersonates different users.
+     */
+    public static final RegistryKey ClassesRoot     = new RegistryKeyImpl(0x80000000L, "HKEY_CLASSES_ROOT");
+
+    /** Registry entries subordinate to this key define the preferences of
+     * the current user. These preferences include the settings of
+     * environment variables, data about program groups, colors, printers,
+     * network connections, and application preferences. This key makes it
+     * easier to establish the current user's settings; the key maps to the
+     * current user's branch in {@code HKEY_USERS}.
+     */
+    public static final RegistryKey CurrentUser     = new RegistryKeyImpl(0x80000001L, "HKEY_CURRENT_USER");
+
+    /** Registry entries subordinate to this key define the physical state
+     * of the computer, including data about the bus type, system memory,
+     * and installed hardware and software. It contains subkeys that hold
+     * current configuration data, including Plug and Play information
+     * (the Enum branch, which includes a complete list of all hardware that
+     * has ever been on the system), network logon preferences, network
+     * security information, software-related information (such as server
+     * names and the location of the server), and other system information.
+     */
+    public static final RegistryKey LocalMachine    = new RegistryKeyImpl(0x80000002L, "HKEY_LOCAL_MACHINE");
 
+    /** Registry entries subordinate to this key define the default user
+     * configuration for new users on the local computer and the user
+     * configuration for the current user.
+     */
+    public static final RegistryKey Users           = new RegistryKeyImpl(0x80000003L, "HKEY_USERS");
+
+    /** Registry entries subordinate to this key allow you to access
+     * performance data. The data is not actually stored in the registry;
+     * the registry functions cause the system to collect the data from
+     * its source.
+     */
+    public static final RegistryKey PerformanceData = new RegistryKeyImpl(0x80000004L, "HKEY_PERFORMANCE_DATA");
+
+    /** Contains information about the current hardware profile of the
+     * local computer system.
+     * <p>
+     * The information under {@code HKEY_CURRENT_CONFIG}
+     * describes only the differences between the current hardware
+     * configuration and the standard configuration. Information about
+     * the standard hardware configuration is stored under the Software
+     * and System keys of {@code HKEY_LOCAL_MACHINE}.
+     * </p>
+     */
+    public static final RegistryKey CurrentConfig   = new RegistryKeyImpl(0x80000005L, "HKEY_CURRENT_CONFIG");
 
-    private static native int unlink0(long key, String name, boolean onlyIfEmpty);
     /**
      * Delete the Registry subkey
      * @param root Root key, one of HKEY_*
@@ -60,14 +118,7 @@ public final class Registry
     {
         if (name == null)
             throw new NullPointerException();
-        long hKey = root.handle();
-        if (hKey == 0L || hKey == -1L)
-            throw new InvalidHandleException();
-        int rc = unlink0(hKey, name, onlyIfEmpty);
-        if (rc == 0)
-            return true;
-        else
-            return false;
+        return root.delete(name, onlyIfEmpty);
     }
 
 }

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/RegistryKey.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/RegistryKey.java?rev=1098982&r1=1098981&r2=1098982&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/RegistryKey.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/RegistryKey.java Tue May  3 09:29:41 2011
@@ -38,114 +38,12 @@ import org.apache.commons.runtime.util.U
  * keys.
  * </p>
  */
-public final class RegistryKey implements Closeable, Flushable
+public abstract class RegistryKey implements Closeable, Flushable
 {
 
-    /** Registry entries subordinate to this key define types (or classes)
-     * of documents and the properties associated with those types. Shell
-     * and COM applications use the information stored under this key.
-     * For more information, see {@code HKEY_CLASSES_ROOT} Key.
-     * <p>
-     * This key also provides backward compatibility with the Windows 3.1
-     * registration database by storing information for DDE and OLE support.
-     * File viewers and user interface extensions store their OLE class
-     * identifiers in {@code HKEY_CLASSES_ROOT}, and in-process servers are
-     * registered in this key.
-     * </p>
-     * This handle should not be used in a service or an application that
-     * impersonates different users.
-     */
-    public static final RegistryKey ClassesRoot     = new RegistryKey(0x80000000L, "HKEY_CLASSES_ROOT");
-
-    /** Registry entries subordinate to this key define the preferences of
-     * the current user. These preferences include the settings of
-     * environment variables, data about program groups, colors, printers,
-     * network connections, and application preferences. This key makes it
-     * easier to establish the current user's settings; the key maps to the
-     * current user's branch in {@code HKEY_USERS}.
-     */
-    public static final RegistryKey CurrentUser     = new RegistryKey(0x80000001L, "HKEY_CURRENT_USER");
-
-    /** Registry entries subordinate to this key define the physical state
-     * of the computer, including data about the bus type, system memory,
-     * and installed hardware and software. It contains subkeys that hold
-     * current configuration data, including Plug and Play information
-     * (the Enum branch, which includes a complete list of all hardware that
-     * has ever been on the system), network logon preferences, network
-     * security information, software-related information (such as server
-     * names and the location of the server), and other system information.
-     */
-    public static final RegistryKey LocalMachine    = new RegistryKey(0x80000002L, "HKEY_LOCAL_MACHINE");
-
-    /** Registry entries subordinate to this key define the default user
-     * configuration for new users on the local computer and the user
-     * configuration for the current user.
-     */
-    public static final RegistryKey Users           = new RegistryKey(0x80000003L, "HKEY_USERS");
-
-    /** Registry entries subordinate to this key allow you to access
-     * performance data. The data is not actually stored in the registry;
-     * the registry functions cause the system to collect the data from
-     * its source.
-     */
-    public static final RegistryKey PerformanceData = new RegistryKey(0x80000004L, "HKEY_PERFORMANCE_DATA");
-
-    /** Contains information about the current hardware profile of the
-     * local computer system.
-     * <p>
-     * The information under {@code HKEY_CURRENT_CONFIG}
-     * describes only the differences between the current hardware
-     * configuration and the standard configuration. Information about
-     * the standard hardware configuration is stored under the Software
-     * and System keys of {@code HKEY_LOCAL_MACHINE}.
-     * </p>
-     */
-    public static final RegistryKey CurrentConfig   = new RegistryKey(0x80000005L, "HKEY_CURRENT_CONFIG");
-
-    private String name;
-    private long   hKey;
-
-    private RegistryKey(long v, String n)
-    {
-        hKey = v;
-        name = n;
-    }
-
-    public long handle()
-    {
-        return hKey;
-    }
-
-    public String toString()
-    {
-        if (name == null)
-            return "null";
-        else
-            return name;
-    }
-
-    private static native int close0(long key);
-    /**
-     * Called by the garbage collector when the object is destroyed.
-     * The class will free internal resources allocated by the Operating system.
-     * @see Object#finalize()
-     * @throws Throwable the {@code Exception} raised by this method.
-     */
-    @Override
-    protected final void finalize()
-        throws Throwable
+    protected RegistryKey()
     {
-        if (hKey != 0L) {
-            try {
-                close0(hKey);
-            } catch (Exception e) {
-                // Ignore
-            } finally {
-                hKey = 0L;
-            }
-        }
     }
-
     /**
      * Free the allocated resource by the Operating system.
      * <p>
@@ -156,23 +54,9 @@ public final class RegistryKey implement
      * @see java.io.Closeable#close()
      * @throws IOException if an I/O error occurs.
      */
-    public final void close()
-        throws IOException
-    {
-        int s = Status.ENOTIMPL;
-        try {
-            s = close0(hKey);
-        } catch (Exception e) {
-            // Ignore
-        } finally {
-            hKey = 0L;
-        }
-        if (s != 0) {
-            throw new IOException(Status.describe(s));
-        }
-    }
+    public abstract void close()
+        throws IOException;
 
-    private static native int flush0(long key);
     /**
      * Flushed the underlying object by writing any buffered data.
      * <p>
@@ -187,44 +71,11 @@ public final class RegistryKey implement
      * @throws SyncFailedException when the object cannot be flushed.
      * @throws IOException if an I/O error occurs.
      */
-    public final void flush()
-        throws SyncFailedException, IOException
-    {
-        if (hKey == 0L || hKey == -1L)
-            throw new InvalidHandleException();
-        else {
-            int s = flush0(hKey);
-            if (s != 0) {
-                throw new SyncFailedException(Status.describe(s));
-            }
-        }
-    }
+    public abstract void flush()
+        throws SyncFailedException, IOException;
 
-    private static native long open0(long key, String name, int sam)
-        throws IOException, SystemException;
-    private static native long create0(long key, String name, int sam)
-        throws IOException, SystemException;
-    private static native int  info0(long key, String name);
-    private static native String gets0(long key, String name);
-    private static native char[] gets1(long key, String name);
-    private static native byte[] gets2(long key, String name);
-    private static native int    gets3(long key, String name, int[]  pval);
-    private static native int    gets4(long key, String name, long[] pval);
-    private static native int    unlink0(long key, String name);
-
-    public RegistryKey open(String name, EnumSet<RegistryKeyAccessRights> mode)
-        throws NullPointerException, IOException, SystemException
-    {
-        if (name == null || mode == null)
-            throw new NullPointerException();
-        if (hKey == 0L || hKey == -1L)
-            throw new InvalidHandleException();
-        long sKey = open0(hKey, name, RegistryKeyAccessRights.bitmapOf(mode));
-        if (sKey == 0L || sKey == -1L)
-            return null;
-        else
-            return new RegistryKey(sKey, name);
-    }
+    public abstract RegistryKey open(String name, EnumSet<RegistryKeyAccessRights> mode)
+        throws NullPointerException, IOException, SystemException;
 
     public RegistryKey open(String name, RegistryKeyAccessRights... mode)
         throws NullPointerException, IOException, SystemException
@@ -238,19 +89,8 @@ public final class RegistryKey implement
         return open(name, RegistryKeyAccessRights.READ);
     }
 
-    public RegistryKey create(String name, EnumSet<RegistryKeyAccessRights> mode)
-        throws NullPointerException, IOException, SystemException
-    {
-        if (name == null || mode == null)
-            throw new NullPointerException();
-        if (hKey == 0L || hKey == -1L)
-            throw new InvalidHandleException();
-        long sKey = create0(hKey, name, RegistryKeyAccessRights.bitmapOf(mode));
-        if (sKey == 0L || sKey == -1L)
-            return null;
-        else
-            return new RegistryKey(sKey, name);
-    }
+    public abstract RegistryKey create(String name, EnumSet<RegistryKeyAccessRights> mode)
+        throws NullPointerException, IOException, SystemException;
 
     public RegistryKey create(String name, RegistryKeyAccessRights... mode)
         throws NullPointerException, IOException, SystemException
@@ -264,215 +104,67 @@ public final class RegistryKey implement
         return create(name, RegistryKeyAccessRights.ALL_ACCESS);
     }
 
-    public RegistryValueType getValueType(String valueName)
-        throws NullPointerException, IOException
-    {
-        if (valueName == null)
-            throw new NullPointerException();
-        if (hKey == 0L || hKey == -1L)
-            throw new InvalidHandleException();
-
-        int rc = info0(hKey, valueName);
-        if (rc == -1)
-            throw new IOException(Errno.msg());
-        return RegistryValueType.valueOf(rc);
-    }
+    public abstract RegistryValueType getValueType(String valueName)
+        throws NullPointerException, IOException;
 
-    public String getValue(String valueName)
-        throws NullPointerException, IOException
-    {
-        if (valueName == null)
-            throw new NullPointerException();
-        if (hKey == 0L || hKey == -1L)
-            throw new InvalidHandleException();
-
-        String rv = gets0(hKey, valueName);
-        if (rv == null)
-            throw new IOException(Errno.msg());
-        return rv;
-    }
+    public abstract String getValue(String valueName)
+        throws NullPointerException, IOException;
 
-    public String[] getStringArray(String valueName)
-        throws NullPointerException, IOException
-    {
-        if (valueName == null)
-            throw new NullPointerException();
-        if (hKey == 0L || hKey == -1L)
-            throw new InvalidHandleException();
-
-        char[] rv = gets1(hKey, valueName);
-        if (rv == null)
-            throw new IOException(Errno.msg());
-        return Utils.charBlockToStringArray(rv);
-    }
+    public abstract String[] getStringArray(String valueName)
+        throws NullPointerException, IOException;
 
-    public byte[] getByteArray(String valueName)
-        throws NullPointerException, IOException
-    {
-        if (valueName == null)
-            throw new NullPointerException();
-        if (hKey == 0L || hKey == -1L)
-            throw new InvalidHandleException();
-
-        byte[] rv = gets2(hKey, valueName);
-        if (rv == null)
-            throw new IOException(Errno.msg());
-        return rv;
-    }
+    public abstract byte[] getByteArray(String valueName)
+        throws NullPointerException, IOException;
 
-    public int getIntegerValue(String valueName)
-        throws NullPointerException, IOException
-    {
-        if (valueName == null)
-            throw new NullPointerException();
-        if (hKey == 0L || hKey == -1L)
-            throw new InvalidHandleException();
-        int[] rp = new int[1];
-        int rc = gets3(hKey, valueName, rp);
-        if (rc != 0)
-            throw new IOException(Status.describe(rc));
-        return rp[0];
-    }
-
-    public long getLongValue(String valueName)
-        throws NullPointerException, IOException
-    {
-        if (valueName == null)
-            throw new NullPointerException();
-        if (hKey == 0L || hKey == -1L)
-            throw new InvalidHandleException();
-        long[] rp = new long[1];
-        int rc = gets4(hKey, valueName, rp);
-        if (rc != 0)
-            throw new IOException(Status.describe(rc));
-        return rp[0];
-    }
+    public abstract int getIntegerValue(String valueName)
+        throws NullPointerException, IOException;
 
-    private static native String[] enum0(long key);
-    private static native String[] enum1(long key);
+    public abstract long getLongValue(String valueName)
+        throws NullPointerException, IOException;
 
     /**
      * Enumerate the Registry subkeys
      * @return Array of all subkey names
      */
-    public String[] getKeys()
-        throws NullPointerException, IOException
-    {
-        if (hKey == 0L || hKey == -1L)
-            throw new InvalidHandleException();
-        String[] s = enum0(hKey);
-
-        return s;
-    }
+    public abstract String[] getKeys()
+        throws NullPointerException, IOException;
 
     /**
      * Enumerate the Registry values
      * @return Array of all value names
      */
-    public String[] getValues()
-        throws NullPointerException, IOException
-    {
-        if (hKey == 0L || hKey == -1L)
-            throw new InvalidHandleException();
-        String[] s = enum1(hKey);
+    public abstract String[] getValues()
+        throws NullPointerException, IOException;
 
-        return s;
-    }
+    public abstract void setValue(String name, String value)
+        throws NullPointerException, IOException;
 
-    private static native int   setv0(long key, String name, String value);
-    private static native int   setv1(long key, String name, int value);
-    private static native int   setv2(long key, String name, long value);
-    private static native int   setv3(long key, String name, byte[] value);
-    private static native int   setv4(long key, String name, char[] value);
+    public abstract void setValue(String name, byte[] value)
+        throws NullPointerException, IOException;
 
-    public void setValue(String name, String value)
-        throws NullPointerException, IOException
-    {
-        if (name == null || value == null)
-            throw new NullPointerException();
-        if (hKey == 0L || hKey == -1L)
-            throw new InvalidHandleException();
-        if (hKey == 0L || hKey == -1L)
-            throw new InvalidHandleException();
-        int rc = setv0(hKey, name, value);
-        if (rc != 0)
-            throw new IOException(Status.describe(rc));
-    }
-
-    public void setValue(String name, byte[] value)
-        throws NullPointerException, IOException
-    {
-        if (name == null || value == null)
-            throw new NullPointerException();
-        if (hKey == 0L || hKey == -1L)
-            throw new InvalidHandleException();
-        if (hKey == 0L || hKey == -1L)
-            throw new InvalidHandleException();
-        int rc = setv3(hKey, name, value);
-        if (rc != 0)
-            throw new IOException(Status.describe(rc));
-    }
-
-    public void setValue(String name, List<String> value)
-        throws NullPointerException, IOException
-    {
-        if (name == null || value == null)
-            throw new NullPointerException();
-        if (hKey == 0L || hKey == -1L)
-            throw new InvalidHandleException();
-        if (hKey == 0L || hKey == -1L)
-            throw new InvalidHandleException();
-        char[] msz = Utils.stringArrayToCharBlock(value);
-        int rc = setv4(hKey, name, msz);
-        if (rc != 0)
-            throw new IOException(Status.describe(rc));
-    }
+    public abstract void setValue(String name, List<String> value)
+        throws NullPointerException, IOException;
 
-    public void setValue(String name, int value)
-        throws NullPointerException, IOException
-    {
-        if (name == null)
-            throw new NullPointerException();
-        if (hKey == 0L || hKey == -1L)
-            throw new InvalidHandleException();
-        if (hKey == 0L || hKey == -1L)
-            throw new InvalidHandleException();
-        int rc = setv1(hKey, name, value);
-        if (rc != 0)
-            throw new IOException(Status.describe(rc));
-    }
+    public abstract void setValue(String name, int value)
+        throws NullPointerException, IOException;
 
-    public void setValue(String name, long value)
-        throws NullPointerException, IOException
-    {
-        if (name == null)
-            throw new NullPointerException();
-        if (hKey == 0L || hKey == -1L)
-            throw new InvalidHandleException();
-        if (hKey == 0L || hKey == -1L)
-            throw new InvalidHandleException();
-        int rc = setv2(hKey, name, value);
-        if (rc != 0)
-            throw new IOException(Status.describe(rc));
-    }
+    public abstract void setValue(String name, long value)
+        throws NullPointerException, IOException;
 
     /**
      * Delete the Registry value
      * @param name The name of the value to delete
      * @return {@code true} if the function succeeds.
      */
-    public boolean deleteValue(String name)
-        throws NullPointerException, IOException
-    {
-        if (name == null)
-            throw new NullPointerException();
-        if (hKey == 0L || hKey == -1L)
-            throw new InvalidHandleException();
-        int rc = unlink0(hKey, name);
-        if (rc == 0)
-            return true;
-        else
-            return false;
-    }
+    public abstract boolean deleteValue(String name)
+        throws NullPointerException, IOException;
 
+    /**
+     * Delete the Registry key
+     * @param name The name of the key to delete
+     * @return {@code true} if the function succeeds.
+     */
+    public abstract boolean delete(String name, boolean onlyIfEmpty)
+        throws NullPointerException, IOException;
+        
 }

Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/RegistryKeyImpl.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/RegistryKeyImpl.java?rev=1098982&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/RegistryKeyImpl.java (added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/RegistryKeyImpl.java Tue May  3 09:29:41 2011
@@ -0,0 +1,429 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.runtime.platform.windows;
+
+import java.io.Closeable;
+import java.io.Flushable;
+import java.io.IOException;
+import java.io.SyncFailedException;
+import java.util.EnumSet;
+import java.util.List;
+import org.apache.commons.runtime.Errno;
+import org.apache.commons.runtime.Status;
+import org.apache.commons.runtime.SystemException;
+import org.apache.commons.runtime.util.Utils;
+
+/**
+ * Registry key implementation.
+ */
+final class RegistryKeyImpl extends RegistryKey
+{
+
+    private String name;
+    private long   hKey;
+
+    /**
+     * Create new RegistryKey.
+     *
+     * @exclude
+     */
+    public RegistryKeyImpl(long v, String n)
+    {
+        hKey = v;
+        name = n;
+    }
+
+    public long handle()
+    {
+        return hKey;
+    }
+
+    public String toString()
+    {
+        if (name == null)
+            return "null";
+        else
+            return name;
+    }
+
+    private static native int close0(long key);
+    /**
+     * Called by the garbage collector when the object is destroyed.
+     * The class will free internal resources allocated by the Operating system.
+     * @see Object#finalize()
+     * @throws Throwable the {@code Exception} raised by this method.
+     */
+    @Override
+    protected final void finalize()
+        throws Throwable
+    {
+        if (hKey != 0L) {
+            try {
+                close0(hKey);
+            } catch (Exception e) {
+                // Ignore
+            } finally {
+                hKey = 0L;
+            }
+        }
+    }
+
+    /**
+     * Free the allocated resource by the Operating system.
+     * <p>
+     * Note that {@code Object.finalize()} method will call
+     * this function. However if the native code can block for
+     * long time explicit {@code close()} should be called.
+     * </p>
+     * @see java.io.Closeable#close()
+     * @throws IOException if an I/O error occurs.
+     */
+    public final void close()
+        throws IOException
+    {
+        int s = Status.ENOTIMPL;
+        try {
+            s = close0(hKey);
+        } catch (Exception e) {
+            // Ignore
+        } finally {
+            hKey = 0L;
+        }
+        if (s != 0) {
+            throw new IOException(Status.describe(s));
+        }
+    }
+
+    private static native int flush0(long key);
+    /**
+     * Flushed the underlying object by writing any buffered data.
+     * <p>
+     * {@code fsync()} transfers  all  modified in-core data of the object
+     * referred to by {@code this} Descriptor to the disk device
+     * (or other permanent storage device)  where  that  object resides.
+     * The call blocks until the device reports that the transfer has
+     * completed.  It also flushes  metadata information associated with
+     * {@code this} Descriptor.
+     * </p>
+     *
+     * @throws SyncFailedException when the object cannot be flushed.
+     * @throws IOException if an I/O error occurs.
+     */
+    public final void flush()
+        throws SyncFailedException, IOException
+    {
+        if (hKey == 0L || hKey == -1L)
+            throw new InvalidHandleException();
+        else {
+            int s = flush0(hKey);
+            if (s != 0) {
+                throw new SyncFailedException(Status.describe(s));
+            }
+        }
+    }
+
+    private static native long open0(long key, String name, int sam)
+        throws IOException, SystemException;
+    private static native long create0(long key, String name, int sam)
+        throws IOException, SystemException;
+    private static native int  info0(long key, String name);
+    private static native String gets0(long key, String name);
+    private static native char[] gets1(long key, String name);
+    private static native byte[] gets2(long key, String name);
+    private static native int    gets3(long key, String name, int[]  pval);
+    private static native int    gets4(long key, String name, long[] pval);
+    private static native int    unlink0(long key, String name);
+    private static native int    unlink1(long key, String name, boolean onlyIfEmpty);
+
+    public RegistryKey open(String name, EnumSet<RegistryKeyAccessRights> mode)
+        throws NullPointerException, IOException, SystemException
+    {
+        if (name == null || mode == null)
+            throw new NullPointerException();
+        if (hKey == 0L || hKey == -1L)
+            throw new InvalidHandleException();
+        long sKey = open0(hKey, name, RegistryKeyAccessRights.bitmapOf(mode));
+        if (sKey == 0L || sKey == -1L)
+            return null;
+        else
+            return new RegistryKeyImpl(sKey, name);
+    }
+
+    public RegistryKey open(String name, RegistryKeyAccessRights... mode)
+        throws NullPointerException, IOException, SystemException
+    {
+        return open(name, RegistryKeyAccessRights.of(mode));
+    }
+
+    public RegistryKey open(String name)
+        throws NullPointerException, IOException, SystemException
+    {
+        return open(name, RegistryKeyAccessRights.READ);
+    }
+
+    public RegistryKey create(String name, EnumSet<RegistryKeyAccessRights> mode)
+        throws NullPointerException, IOException, SystemException
+    {
+        if (name == null || mode == null)
+            throw new NullPointerException();
+        if (hKey == 0L || hKey == -1L)
+            throw new InvalidHandleException();
+        long sKey = create0(hKey, name, RegistryKeyAccessRights.bitmapOf(mode));
+        if (sKey == 0L || sKey == -1L)
+            return null;
+        else
+            return new RegistryKeyImpl(sKey, name);
+    }
+
+    public RegistryKey create(String name, RegistryKeyAccessRights... mode)
+        throws NullPointerException, IOException, SystemException
+    {
+        return create(name, RegistryKeyAccessRights.of(mode));
+    }
+
+    public RegistryKey create(String name)
+        throws NullPointerException, IOException, SystemException
+    {
+        return create(name, RegistryKeyAccessRights.ALL_ACCESS);
+    }
+
+    public RegistryValueType getValueType(String valueName)
+        throws NullPointerException, IOException
+    {
+        if (valueName == null)
+            throw new NullPointerException();
+        if (hKey == 0L || hKey == -1L)
+            throw new InvalidHandleException();
+
+        int rc = info0(hKey, valueName);
+        if (rc == -1)
+            throw new IOException(Errno.msg());
+        return RegistryValueType.valueOf(rc);
+    }
+
+    public String getValue(String valueName)
+        throws NullPointerException, IOException
+    {
+        if (valueName == null)
+            throw new NullPointerException();
+        if (hKey == 0L || hKey == -1L)
+            throw new InvalidHandleException();
+
+        String rv = gets0(hKey, valueName);
+        if (rv == null)
+            throw new IOException(Errno.msg());
+        return rv;
+    }
+
+    public String[] getStringArray(String valueName)
+        throws NullPointerException, IOException
+    {
+        if (valueName == null)
+            throw new NullPointerException();
+        if (hKey == 0L || hKey == -1L)
+            throw new InvalidHandleException();
+
+        char[] rv = gets1(hKey, valueName);
+        if (rv == null)
+            throw new IOException(Errno.msg());
+        return Utils.charBlockToStringArray(rv);
+    }
+
+    public byte[] getByteArray(String valueName)
+        throws NullPointerException, IOException
+    {
+        if (valueName == null)
+            throw new NullPointerException();
+        if (hKey == 0L || hKey == -1L)
+            throw new InvalidHandleException();
+
+        byte[] rv = gets2(hKey, valueName);
+        if (rv == null)
+            throw new IOException(Errno.msg());
+        return rv;
+    }
+
+    public int getIntegerValue(String valueName)
+        throws NullPointerException, IOException
+    {
+        if (valueName == null)
+            throw new NullPointerException();
+        if (hKey == 0L || hKey == -1L)
+            throw new InvalidHandleException();
+        int[] rp = new int[1];
+        int rc = gets3(hKey, valueName, rp);
+        if (rc != 0)
+            throw new IOException(Status.describe(rc));
+        return rp[0];
+    }
+
+    public long getLongValue(String valueName)
+        throws NullPointerException, IOException
+    {
+        if (valueName == null)
+            throw new NullPointerException();
+        if (hKey == 0L || hKey == -1L)
+            throw new InvalidHandleException();
+        long[] rp = new long[1];
+        int rc = gets4(hKey, valueName, rp);
+        if (rc != 0)
+            throw new IOException(Status.describe(rc));
+        return rp[0];
+    }
+
+    private static native String[] enum0(long key);
+    private static native String[] enum1(long key);
+
+    /**
+     * Enumerate the Registry subkeys
+     * @return Array of all subkey names
+     */
+    public String[] getKeys()
+        throws NullPointerException, IOException
+    {
+        if (hKey == 0L || hKey == -1L)
+            throw new InvalidHandleException();
+        String[] s = enum0(hKey);
+
+        return s;
+    }
+
+    /**
+     * Enumerate the Registry values
+     * @return Array of all value names
+     */
+    public String[] getValues()
+        throws NullPointerException, IOException
+    {
+        if (hKey == 0L || hKey == -1L)
+            throw new InvalidHandleException();
+        String[] s = enum1(hKey);
+
+        return s;
+    }
+
+    private static native int   setv0(long key, String name, String value);
+    private static native int   setv1(long key, String name, int value);
+    private static native int   setv2(long key, String name, long value);
+    private static native int   setv3(long key, String name, byte[] value);
+    private static native int   setv4(long key, String name, char[] value);
+
+    public void setValue(String name, String value)
+        throws NullPointerException, IOException
+    {
+        if (name == null || value == null)
+            throw new NullPointerException();
+        if (hKey == 0L || hKey == -1L)
+            throw new InvalidHandleException();
+        if (hKey == 0L || hKey == -1L)
+            throw new InvalidHandleException();
+        int rc = setv0(hKey, name, value);
+        if (rc != 0)
+            throw new IOException(Status.describe(rc));
+    }
+
+    public void setValue(String name, byte[] value)
+        throws NullPointerException, IOException
+    {
+        if (name == null || value == null)
+            throw new NullPointerException();
+        if (hKey == 0L || hKey == -1L)
+            throw new InvalidHandleException();
+        if (hKey == 0L || hKey == -1L)
+            throw new InvalidHandleException();
+        int rc = setv3(hKey, name, value);
+        if (rc != 0)
+            throw new IOException(Status.describe(rc));
+    }
+
+    public void setValue(String name, List<String> value)
+        throws NullPointerException, IOException
+    {
+        if (name == null || value == null)
+            throw new NullPointerException();
+        if (hKey == 0L || hKey == -1L)
+            throw new InvalidHandleException();
+        if (hKey == 0L || hKey == -1L)
+            throw new InvalidHandleException();
+        char[] msz = Utils.stringArrayToCharBlock(value);
+        int rc = setv4(hKey, name, msz);
+        if (rc != 0)
+            throw new IOException(Status.describe(rc));
+    }
+
+    public void setValue(String name, int value)
+        throws NullPointerException, IOException
+    {
+        if (name == null)
+            throw new NullPointerException();
+        if (hKey == 0L || hKey == -1L)
+            throw new InvalidHandleException();
+        if (hKey == 0L || hKey == -1L)
+            throw new InvalidHandleException();
+        int rc = setv1(hKey, name, value);
+        if (rc != 0)
+            throw new IOException(Status.describe(rc));
+    }
+
+    public void setValue(String name, long value)
+        throws NullPointerException, IOException
+    {
+        if (name == null)
+            throw new NullPointerException();
+        if (hKey == 0L || hKey == -1L)
+            throw new InvalidHandleException();
+        if (hKey == 0L || hKey == -1L)
+            throw new InvalidHandleException();
+        int rc = setv2(hKey, name, value);
+        if (rc != 0)
+            throw new IOException(Status.describe(rc));
+    }
+
+    /**
+     * Delete the Registry value
+     * @param name The name of the value to delete
+     * @return {@code true} if the function succeeds.
+     */
+    public boolean deleteValue(String name)
+        throws NullPointerException, IOException
+    {
+        if (name == null)
+            throw new NullPointerException();
+        if (hKey == 0L || hKey == -1L)
+            throw new InvalidHandleException();
+        int rc = unlink0(hKey, name);
+        if (rc == 0)
+            return true;
+        else
+            return false;
+    }
+
+    public boolean delete(String name, boolean onlyIfEmpty)
+        throws NullPointerException, IOException
+    {
+        if (name == null)
+            throw new NullPointerException();
+        if (hKey == 0L || hKey == -1L)
+            throw new InvalidHandleException();
+        int rc = unlink1(hKey, name, onlyIfEmpty);
+        if (rc == 0)
+            return true;
+        else
+            return false;
+    }
+
+}

Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/RegistryKeyImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/registry.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/registry.c?rev=1098982&r1=1098981&r2=1098982&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/registry.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/registry.c Tue May  3 09:29:41 2011
@@ -54,7 +54,7 @@ static REGSAM regsam_translate(int nsam)
     return rsam;
 }
 
-ACR_WIN_EXPORT(jint, RegistryKey, close0)(JNI_STDARGS, jlong key)
+ACR_WIN_EXPORT(jint, RegistryKeyImpl, close0)(JNI_STDARGS, jlong key)
 {
     int rc    = ACR_EBADF;
     HKEY hkey = J2P(key, HKEY);
@@ -73,13 +73,13 @@ ACR_WIN_EXPORT(jint, RegistryKey, close0
     return rc;
 }
 
-ACR_WIN_EXPORT(jint, RegistryKey, flush0)(JNI_STDARGS, jlong key)
+ACR_WIN_EXPORT(jint, RegistryKeyImpl, flush0)(JNI_STDARGS, jlong key)
 {
     return (int)RegFlushKey(J2P(key, HKEY));
 }
 
-ACR_WIN_EXPORT(jlong, RegistryKey, open0)(JNI_STDARGS, jlong key,
-                                          jstring name, jint sam)
+ACR_WIN_EXPORT(jlong, RegistryKeyImpl, open0)(JNI_STDARGS, jlong key,
+                                              jstring name, jint sam)
 {
     int  rc     = ACR_EINVAL;
     HKEY skey   = 0;
@@ -101,8 +101,8 @@ ACR_WIN_EXPORT(jlong, RegistryKey, open0
     return P2J(skey);
 }
 
-ACR_WIN_EXPORT(jlong, RegistryKey, create0)(JNI_STDARGS, jlong key,
-                                            jstring name, jint sam)
+ACR_WIN_EXPORT(jlong, RegistryKeyImpl, create0)(JNI_STDARGS, jlong key,
+                                                jstring name, jint sam)
 {
     int  rc     = ACR_EINVAL;
     HKEY skey   = 0;
@@ -128,7 +128,7 @@ ACR_WIN_EXPORT(jlong, RegistryKey, creat
     return P2J(skey);
 }
 
-ACR_WIN_EXPORT(jint, RegistryKey, info0)(JNI_STDARGS, jlong key, jstring name)
+ACR_WIN_EXPORT(jint, RegistryKeyImpl, info0)(JNI_STDARGS, jlong key, jstring name)
 {
     int  v    = 0;
     int  rc   = ACR_EINVAL;
@@ -147,7 +147,7 @@ ACR_WIN_EXPORT(jint, RegistryKey, info0)
     }
 }
 
-ACR_WIN_EXPORT(jstring, RegistryKey, gets0)(JNI_STDARGS, jlong key, jstring name)
+ACR_WIN_EXPORT(jstring, RegistryKeyImpl, gets0)(JNI_STDARGS, jlong key, jstring name)
 {
     jstring r = 0;
     DWORD rt  = 0;
@@ -200,7 +200,7 @@ ACR_WIN_EXPORT(jstring, RegistryKey, get
     return r;
 }
 
-ACR_WIN_EXPORT(jcharArray, RegistryKey, gets1)(JNI_STDARGS, jlong key, jstring name)
+ACR_WIN_EXPORT(jcharArray, RegistryKeyImpl, gets1)(JNI_STDARGS, jlong key, jstring name)
 {
     jcharArray r = 0;
     DWORD rt  = 0;
@@ -239,7 +239,7 @@ ACR_WIN_EXPORT(jcharArray, RegistryKey, 
     return r;
 }
 
-ACR_WIN_EXPORT(jbyteArray, RegistryKey, gets2)(JNI_STDARGS, jlong key, jstring name)
+ACR_WIN_EXPORT(jbyteArray, RegistryKeyImpl, gets2)(JNI_STDARGS, jlong key, jstring name)
 {
     jbyteArray r = 0;
     DWORD rt  = 0;
@@ -278,7 +278,7 @@ ACR_WIN_EXPORT(jbyteArray, RegistryKey, 
     return r;
 }
 
-ACR_WIN_EXPORT(jint, RegistryKey, gets3)(JNI_STDARGS, jlong key, jstring name, jintArray pval)
+ACR_WIN_EXPORT(jint, RegistryKeyImpl, gets3)(JNI_STDARGS, jlong key, jstring name, jintArray pval)
 {
     DWORD rt  = 0;
     DWORD rs  = 0;
@@ -304,7 +304,7 @@ ACR_WIN_EXPORT(jint, RegistryKey, gets3)
     return rc;
 }
 
-ACR_WIN_EXPORT(jint, RegistryKey, gets4)(JNI_STDARGS, jlong key, jstring name, jlongArray pval)
+ACR_WIN_EXPORT(jint, RegistryKeyImpl, gets4)(JNI_STDARGS, jlong key, jstring name, jlongArray pval)
 {
     DWORD rt  = 0;
     DWORD rs  = 0;
@@ -337,7 +337,7 @@ ACR_WIN_EXPORT(jint, RegistryKey, gets4)
 
 #define MAX_VALUE_NAME 4096
 
-ACR_WIN_EXPORT(jobjectArray, RegistryKey, enum0)(JNI_STDARGS, jlong key)
+ACR_WIN_EXPORT(jobjectArray, RegistryKeyImpl, enum0)(JNI_STDARGS, jlong key)
 {
     HKEY hkey = J2P(key, HKEY);
     LONG rc;
@@ -407,7 +407,7 @@ ACR_WIN_EXPORT(jobjectArray, RegistryKey
     return v;
 }
 
-ACR_WIN_EXPORT(jobjectArray, RegistryKey, enum1)(JNI_STDARGS, jlong key)
+ACR_WIN_EXPORT(jobjectArray, RegistryKeyImpl, enum1)(JNI_STDARGS, jlong key)
 {
     HKEY hkey = J2P(key, HKEY);
     LONG rc;
@@ -478,7 +478,7 @@ ACR_WIN_EXPORT(jobjectArray, RegistryKey
     return v;
 }
 
-ACR_WIN_EXPORT(jint, RegistryKey, setv0)(JNI_STDARGS, jlong key,
+ACR_WIN_EXPORT(jint, RegistryKeyImpl, setv0)(JNI_STDARGS, jlong key,
                                          jstring name, jstring val)
 {
     jint rc   = ACR_EINVAL;
@@ -495,7 +495,7 @@ ACR_WIN_EXPORT(jint, RegistryKey, setv0)
     return rc;
 }
 
-ACR_WIN_EXPORT(jint, RegistryKey, setv1)(JNI_STDARGS, jlong key,
+ACR_WIN_EXPORT(jint, RegistryKeyImpl, setv1)(JNI_STDARGS, jlong key,
                                          jstring name, jint val)
 {
     jint rc   = ACR_EINVAL;
@@ -508,7 +508,7 @@ ACR_WIN_EXPORT(jint, RegistryKey, setv1)
     return rc;
 }
 
-ACR_WIN_EXPORT(jint, RegistryKey, setv2)(JNI_STDARGS, jlong key,
+ACR_WIN_EXPORT(jint, RegistryKeyImpl, setv2)(JNI_STDARGS, jlong key,
                                          jstring name, jlong val)
 {
     jint rc   = ACR_EINVAL;
@@ -521,7 +521,7 @@ ACR_WIN_EXPORT(jint, RegistryKey, setv2)
     return rc;
 }
 
-ACR_WIN_EXPORT(jint, RegistryKey, setv3)(JNI_STDARGS, jlong key,
+ACR_WIN_EXPORT(jint, RegistryKeyImpl, setv3)(JNI_STDARGS, jlong key,
                                          jstring name, jbyteArray val)
 {
     jint rc   = ACR_EINVAL;
@@ -538,7 +538,7 @@ ACR_WIN_EXPORT(jint, RegistryKey, setv3)
     return rc;
 }
 
-ACR_WIN_EXPORT(jint, RegistryKey, setv4)(JNI_STDARGS, jlong key,
+ACR_WIN_EXPORT(jint, RegistryKeyImpl, setv4)(JNI_STDARGS, jlong key,
                                          jstring name, jcharArray val)
 {
     jint rc   = ACR_EINVAL;
@@ -555,8 +555,8 @@ ACR_WIN_EXPORT(jint, RegistryKey, setv4)
     return rc;
 }
 
-ACR_WIN_EXPORT(jint, RegistryKey, unlink0)(JNI_STDARGS, jlong key,
-                                           jstring name)
+ACR_WIN_EXPORT(jint, RegistryKeyImpl, unlink0)(JNI_STDARGS, jlong key,
+                                               jstring name)
 {
     jint rc   = ACR_EINVAL;
     HKEY hkey = J2P(key, HKEY);
@@ -567,9 +567,8 @@ ACR_WIN_EXPORT(jint, RegistryKey, unlink
     return rc;
 }
 
-ACR_WIN_EXPORT(jint, Registry, unlink0)(JNI_STDARGS, jlong key,
-                                        jstring name,
-                                        jboolean empty)
+ACR_WIN_EXPORT(jint, RegistryKeyImpl, unlink1)(JNI_STDARGS, jlong key,
+                                               jstring name, jboolean empty)
 {
     jint rc   = ACR_EINVAL;
     HKEY hkey = J2P(key, HKEY);

Modified: commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestRegistry.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestRegistry.java?rev=1098982&r1=1098981&r2=1098982&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestRegistry.java (original)
+++ commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestRegistry.java Tue May  3 09:29:41 2011
@@ -28,7 +28,7 @@ public class TestRegistry extends Assert
     public void openExiting()
         throws Exception
     {
-        RegistryKey key = RegistryKey.LocalMachine.open("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion");
+        RegistryKey key = Registry.LocalMachine.open("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion");
         assertNotNull(key);
         String name = key.getValue("ProductName");
         assertNotNull(name);
@@ -39,7 +39,7 @@ public class TestRegistry extends Assert
     public void openMsz()
         throws Exception
     {
-        RegistryKey key = RegistryKey.LocalMachine.open("SYSTEM\\CurrentControlSet\\Control\\Session Manager");
+        RegistryKey key = Registry.LocalMachine.open("SYSTEM\\CurrentControlSet\\Control\\Session Manager");
         assertNotNull(key);
         String[] sa = key.getStringArray("ObjectDirectories");
         assertNotNull(sa);
@@ -52,7 +52,7 @@ public class TestRegistry extends Assert
     public void getInteger()
         throws Exception
     {
-        RegistryKey key = RegistryKey.LocalMachine.open("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion");
+        RegistryKey key = Registry.LocalMachine.open("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion");
         assertNotNull(key);
         int val = key.getIntegerValue("InstallDate");
         assertNotNull(val == 0);
@@ -62,7 +62,7 @@ public class TestRegistry extends Assert
     public void getIntegerFault()
         throws Exception
     {
-        RegistryKey key = RegistryKey.LocalMachine.open("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion");
+        RegistryKey key = Registry.LocalMachine.open("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion");
         assertNotNull(key);
         assertEquals(key.getValueType("InstallDate"), RegistryValueType.DWORD);
         String val = key.getValue("InstallDate");
@@ -72,7 +72,7 @@ public class TestRegistry extends Assert
     public void enumKeys()
         throws Exception
     {
-        RegistryKey key = RegistryKey.LocalMachine.open("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion");
+        RegistryKey key = Registry.LocalMachine.open("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion");
         assertNotNull(key);
         String[] keys = key.getKeys();
         assertTrue(keys.length > 10);
@@ -82,7 +82,7 @@ public class TestRegistry extends Assert
     public void enumValues()
         throws Exception
     {
-        RegistryKey key = RegistryKey.LocalMachine.open("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion");
+        RegistryKey key = Registry.LocalMachine.open("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion");
         assertNotNull(key);
         String[] vals = key.getValues();
         assertTrue(vals.length > 10);
@@ -92,11 +92,11 @@ public class TestRegistry extends Assert
     public void createValues()
         throws Exception
     {
-        RegistryKey key = RegistryKey.CurrentUser.create("SOFTWARE\\Apache Group\\CommonsTest\\Runtime");
+        RegistryKey key = Registry.CurrentUser.create("SOFTWARE\\Apache Group\\CommonsTest\\Runtime");
         assertNotNull(key);
         key.setValue("TestString", "Some Value");
         key.close();
-        Registry.delete(RegistryKey.CurrentUser, "SOFTWARE\\Apache Group\\CommonsTest", false);
+        Registry.CurrentUser.delete("SOFTWARE\\Apache Group\\CommonsTest", false);
     }
 
 }