Revision: 5358
          http://jnode.svn.sourceforge.net/jnode/?rev=5358&view=rev
Author:   crawley
Date:     2009-04-29 15:31:45 +0000 (Wed, 29 Apr 2009)

Log Message:
-----------
Vector requests for system properties through 'native' methods implemented
on the JNode side. 

Modified Paths:
--------------
    classlib6/core/src/classpath/gnu/gnu/classpath/SystemProperties.java

Modified: classlib6/core/src/classpath/gnu/gnu/classpath/SystemProperties.java
===================================================================
--- classlib6/core/src/classpath/gnu/gnu/classpath/SystemProperties.java        
2009-04-29 15:11:27 UTC (rev 5357)
+++ classlib6/core/src/classpath/gnu/gnu/classpath/SystemProperties.java        
2009-04-29 15:31:45 UTC (rev 5358)
@@ -47,17 +47,13 @@
  * This class is separated out from java.lang.System to simplify bootstrap
  * dependencies and to allow trusted code a simple and efficient mechanism
  * to access the system properties.
+ * <p>
+ * In JNode, we further indirect through 2 'native' methods that are 
implemented
+ * in JNode specific Java code.
  */
 public class SystemProperties
 {
     /**
-     * Stores the current system properties. This can be modified by
-     * {...@link #setProperties(Properties)}, but will never be null, because
-     * setProperties(null) sucks in the default properties.
-     */
-    private static Properties properties;
-
-    /**
      * The default properties. Once the default is stabilized,
      * it should not be modified;
      * instead it is cloned when calling <code>setProperties(null)</code>.
@@ -120,29 +116,35 @@
 
         VMSystemProperties.postInit(defaultProperties);
 
-        // Note that we use clone here and not new.  Some programs assume
-        // that the system properties do not have a parent.
-    properties = (Properties) defaultProperties.clone();
+        try {
+               // Note that we use clone here and not new.  Some programs 
assume
+               // that the system properties do not have a parent.
+               doSetProperties((Properties) defaultProperties.clone());
+        } catch (UnsatisfiedLinkError ex) {
+               // This happens if we are running in JNode bootimage builder
+               // because the JNode implementation of the native method 
+               // doSetProperties is not available.
+        }
     }
 
     public static String getProperty(String name)
     {
-        return properties.getProperty(name);
+        return doGetProperties().getProperty(name);
     }
 
     public static String getProperty(String name, String defaultValue)
     {
-        return properties.getProperty(name, defaultValue);
+        return doGetProperties().getProperty(name, defaultValue);
     }
 
     public static String setProperty(String name, String value)
     {
-    return (String) properties.setProperty(name, value);
+    return (String) doGetProperties().setProperty(name, value);
     }
 
     public static Properties getProperties()
     {
-        return properties;
+        return doGetProperties();
     }
 
     public static void setProperties(Properties properties)
@@ -154,7 +156,7 @@
             properties = (Properties)defaultProperties.clone();
           }
 
-        SystemProperties.properties = properties;
+        doSetProperties(properties);
     }
 
   /**
@@ -167,7 +169,12 @@
    */
   public static String remove(String name)
   {
-    return (String) properties.remove(name);
+    return (String) doGetProperties().remove(name);
   }
+  
+  private static native Properties doGetProperties();
+  
+  private static native void doSetProperties(Properties props);
+  
 
 }


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Register Now & Save for Velocity, the Web Performance & Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance & Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
_______________________________________________
Jnode-svn-commits mailing list
Jnode-svn-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jnode-svn-commits

Reply via email to