/************************************************************************** * Copyright (c) 2007, 2010 by Chris Gray, /k/ Embedded Java Solutions. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of /k/ Embedded Java Solutions nor the names of other contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL /K/ * EMBEDDED SOLUTIONS OR OTHER CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * **************************************************************************/ package java.lang; import java.io.ByteArrayInputStream; import java.io.InputStream; import java.io.IOException; import java.util.Enumeration; import java.util.Vector; import java.util.Properties; /* ** Package-protected class used to implement the built-in system properties. ** In practice this is a singleton, but we don't enforce this; the single ** instance is generated by the static initialiser of java.lang.System and ** used to create the system properties. ** ** The 1.4.2 API states that the following should always be defined: ** java.version ** java.vendor ** java.vendor.url ** java.home ** java.vm.specification.version ** java.vm.specification.vendor ** java.vm.specification.name ** java.vm.version ** java.vm.vendor ** java.vm.name ** java.specification.version ** java.specification.vendor ** java.specification.name ** java.class.version ** java.class.path ** java.library.path + ** java.io.tmpdir + ** java.compiler + ** java.ext.dirs ** os.name ** os.arch ** os.version ** file.separator ** path.separator ** line.separator ** user.name ** user.home ** user.dir ** + = new in 1.4 ** ** We support all of these as best we can, except java.vm.specification.* ** and java.specification.* (for legal reasons). ** ** Sun JDK 1.4.2 seems also to define the following properties: ** java.runtime.name ** java.vm.name ** ** N.B. file.encoding should be one of the six mandatory encodings, ** in canonical form. */ class DefaultProperties extends Properties { DefaultProperties() { NativeProperties natives = new NativeProperties(); Enumeration nativeNames = natives.propertyNames(); while (nativeNames.hasMoreElements()) { String name = (String)nativeNames.nextElement(); String value = natives.getProperty(name); put(name, value); } try { super.load(new ByteArrayInputStream("java.vm.name=Mika\njava.vm.version=1.4.2\njava.vendor=/k/ Embedded Java Solutions\njava.vendor.url=http://www.k-embedded-java.com\njava.vm.vendor=/k/ Embedded Java Solutions\njava.vm.name=Mika\njava.class.version=48.0\njava.class.path=this will be set later\nfile.separator=/\nfile.encoding=8859_1\npath.separator=:\nline.separator=\\n\n".getBytes("ISO-8859-1"))); } catch (Throwable t) { t.printStackTrace(); } if (get("user.language") == null) { put("user.language","en"); } } public Object setProperty(String key, String value){ throw new UnknownError("Someone trying to change a default property?"); } public void load(InputStream in) throws IOException { throw new UnknownError("Someone trying to load the native properties?"); } public Enumeration propertyNames() { Vector v = new Vector(); Enumeration en; if (defaults != null) { en = defaults.keys(); while (en.hasMoreElements()) { v.add(en.nextElement()); } } en = keys(); while (en.hasMoreElements()) { v.add(en.nextElement()); } return v.elements(); } }