diff options
Diffstat (limited to 'libjava/classpath/vm/reference/java')
22 files changed, 538 insertions, 540 deletions
diff --git a/libjava/classpath/vm/reference/java/io/VMFile.java b/libjava/classpath/vm/reference/java/io/VMFile.java index 9f584af..2af1e95 100644 --- a/libjava/classpath/vm/reference/java/io/VMFile.java +++ b/libjava/classpath/vm/reference/java/io/VMFile.java @@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -61,7 +61,7 @@ final class VMFile System.loadLibrary("javaio"); } } - + /* * This native method does the actual work of getting the last file * modification time. It also does the existence check to avoid the @@ -120,38 +120,38 @@ final class VMFile * Gets the total bytes of the filesystem named by path. */ public static native long getTotalSpace(String path); - + /** * Gets the total free bytes of the filesystem named by path. */ public static native long getFreeSpace(String path); - + /** * Gets the available bytes of the filesystem named by path. */ public static native long getUsableSpace(String path); - + /** * Set the read permission of the file. */ public static synchronized native boolean setReadable(String path, - boolean readable, - boolean ownerOnly); - + boolean readable, + boolean ownerOnly); + /** * Set the write permission of the file. */ public static synchronized native boolean setWritable(String path, boolean writable, boolean ownerOnly); - + /** * Set the execute permission of the file. */ public static synchronized native boolean setExecutable(String path, boolean executable, boolean ownerOnly); - + /* * This native method does the actual check of whether or not a file * is a plain file or not. It also handles the existence check to @@ -163,7 +163,7 @@ final class VMFile * This native method checks file permissions for writing */ static synchronized native boolean canWrite(String path); - + /** * This methods checks if a directory can be written to. */ @@ -178,7 +178,7 @@ final class VMFile * This native method checks file permissions for execution */ static synchronized native boolean canExecute(String path); - + /* * This method does the actual check of whether or not a file is a * directory or not. It also handle the existence check to eliminate @@ -193,7 +193,7 @@ final class VMFile { return canWriteDirectory(path.getAbsolutePath()); } - + /** * This method returns an array of filesystem roots. Some operating systems * have volume oriented filesystem. This method provides a mechanism for @@ -207,9 +207,9 @@ final class VMFile */ static File[] listRoots() { - File[] roots = new File[1]; - roots[0] = new File("/"); - return roots; + File[] roots = new File[1]; + roots[0] = new File("/"); + return roots; } /** @@ -225,8 +225,8 @@ final class VMFile */ static boolean isHidden(String path) { - // FIXME: this only works on UNIX - return getName(path).startsWith("."); + // FIXME: this only works on UNIX + return getName(path).startsWith("."); } /** @@ -238,14 +238,14 @@ final class VMFile */ static String getName(String path) { - int pos = PlatformHelper.lastIndexOfSeparator(path); - if (pos == -1) - return path; - - if (PlatformHelper.endWithSeparator(path)) - return ""; - - return path.substring(pos + File.separator.length()); + int pos = PlatformHelper.lastIndexOfSeparator(path); + if (pos == -1) + return path; + + if (PlatformHelper.endWithSeparator(path)) + return ""; + + return path.substring(pos + File.separator.length()); } /** @@ -260,7 +260,7 @@ final class VMFile */ static String getAbsolutePath(String path) { - if (File.separatorChar == '\\' + if (File.separatorChar == '\\' && path.length() > 0 && path.charAt (0) == '\\') { // On Windows, even if the path starts with a '\\' it is not @@ -274,8 +274,8 @@ final class VMFile || (path.charAt (0) >= 'A' && path.charAt (0) <= 'Z'))) { // On Windows, a process has a current working directory for - // each drive and a path like "G:foo\bar" would mean the - // absolute path "G:\wombat\foo\bar" if "\wombat" is the + // each drive and a path like "G:foo\bar" would mean the + // absolute path "G:\wombat\foo\bar" if "\wombat" is the // working directory on the G drive. String drvDir = null; try @@ -288,7 +288,7 @@ final class VMFile } // Note: this would return "C:\\." for the path "C:.", if "\" - // is the working folder on the C drive, but this is + // is the working folder on the C drive, but this is // consistent with what Sun's JRE 1.4.1.01 actually returns! if (path.length() > 2) return drvDir + '\\' + path.substring (2, path.length()); @@ -341,7 +341,7 @@ final class VMFile throws MalformedURLException { // On Win32, Sun's JDK returns URLs of the form "file:/c:/foo/bar.txt", - // while on UNIX, it returns URLs of the form "file:/foo/bar.txt". + // while on UNIX, it returns URLs of the form "file:/foo/bar.txt". if (File.separatorChar == '\\') return new URL ("file:/" + file.getAbsolutePath().replace ('\\', '/') + (file.isDirectory() ? "/" : "")); @@ -358,7 +358,7 @@ final class VMFile * "." and "..", and symbolic links. * <p> * Note that this method, unlike the other methods which return path - * names, can throw an IOException. This is because native method + * names, can throw an IOException. This is because native method * might be required in order to resolve the canonical path * * @exception IOException If an error occurs diff --git a/libjava/classpath/vm/reference/java/io/VMObjectInputStream.java b/libjava/classpath/vm/reference/java/io/VMObjectInputStream.java index be0f8eb..10e1f34 100644 --- a/libjava/classpath/vm/reference/java/io/VMObjectInputStream.java +++ b/libjava/classpath/vm/reference/java/io/VMObjectInputStream.java @@ -48,7 +48,7 @@ final class VMObjectInputStream { if (Configuration.INIT_LOAD_LIBRARY) { - System.loadLibrary("javaio"); + System.loadLibrary("javaio"); } } @@ -59,6 +59,6 @@ final class VMObjectInputStream * which is a super class of the given clazz. */ static native Object allocateObject(Class clazz, Class constr_clazz, - Constructor constructor) + Constructor constructor) throws InstantiationException; } diff --git a/libjava/classpath/vm/reference/java/io/VMObjectStreamClass.java b/libjava/classpath/vm/reference/java/io/VMObjectStreamClass.java index 77470fa..fbaf7d6 100644 --- a/libjava/classpath/vm/reference/java/io/VMObjectStreamClass.java +++ b/libjava/classpath/vm/reference/java/io/VMObjectStreamClass.java @@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -47,7 +47,7 @@ final class VMObjectStreamClass { if (Configuration.INIT_LOAD_LIBRARY) { - System.loadLibrary("javaio"); + System.loadLibrary("javaio"); } } @@ -92,7 +92,7 @@ final class VMObjectStreamClass */ static native void setLongNative(Field field, Object obj, long val) throws InternalError; - + /** * Sets the value of the specified field. This method handles "int". * Warning ! The types are not truely checked here and final values may be @@ -102,9 +102,9 @@ final class VMObjectStreamClass * @param obj Instance which will have its field set. * @param val Value to put in the field. */ - static native void setIntNative(Field field, Object obj, int val) + static native void setIntNative(Field field, Object obj, int val) throws InternalError; - + /** * Sets the value of the specified field. This method handles "short". * Warning ! The types are not truely checked here and final values may be @@ -114,7 +114,7 @@ final class VMObjectStreamClass * @param obj Instance which will have its field set. * @param val Value to put in the field. */ - static native void setShortNative(Field field, Object obj, short val) + static native void setShortNative(Field field, Object obj, short val) throws InternalError; /** @@ -126,7 +126,7 @@ final class VMObjectStreamClass * @param obj Instance which will have its field set. * @param val Value to put in the field. */ - static native void setCharNative(Field field, Object obj, char val) + static native void setCharNative(Field field, Object obj, char val) throws InternalError; /** @@ -138,7 +138,7 @@ final class VMObjectStreamClass * @param obj Instance which will have its field set. * @param val Value to put in the field. */ - static native void setByteNative(Field field, Object obj, byte val) + static native void setByteNative(Field field, Object obj, byte val) throws InternalError; /** @@ -150,7 +150,7 @@ final class VMObjectStreamClass * @param obj Instance which will have its field set. * @param val Value to put in the field. */ - static native void setBooleanNative(Field field, Object obj, boolean val) + static native void setBooleanNative(Field field, Object obj, boolean val) throws InternalError; /** @@ -162,8 +162,7 @@ final class VMObjectStreamClass * @param obj Instance which will have its field set. * @param val Value to put in the field. */ - static native void setObjectNative(Field field, Object obj, Object val) + static native void setObjectNative(Field field, Object obj, Object val) throws InternalError; - -} +} diff --git a/libjava/classpath/vm/reference/java/lang/VMClass.java b/libjava/classpath/vm/reference/java/lang/VMClass.java index 7e9620b..a0091c0 100644 --- a/libjava/classpath/vm/reference/java/lang/VMClass.java +++ b/libjava/classpath/vm/reference/java/lang/VMClass.java @@ -58,7 +58,7 @@ import java.lang.reflect.Modifier; * @author Tom Tromey (tromey@cygnus.com) * @author Andrew John Hughes (gnu_andrew@member.fsf.org) */ -final class VMClass +final class VMClass { // Only static methods. Cannot be instantiated. @@ -287,11 +287,11 @@ final class VMClass * <code>getName()</code> which follows the last ".". Anonymous * classes have no name, and so the result of calling this method is * "". The simple name of an array consists of the simple name of - * its component type, followed by "[]". Thus, an array with the + * its component type, followed by "[]". Thus, an array with the * component type of an anonymous class has a simple name of simply * "[]". * - * @param klass the class whose simple name should be returned. + * @param klass the class whose simple name should be returned. * @return the simple name for this class. */ static String getSimpleName(Class klass) @@ -300,7 +300,7 @@ final class VMClass return ""; if (isArray(klass)) { - return getComponentType(klass).getSimpleName() + "[]"; + return getComponentType(klass).getSimpleName() + "[]"; } String fullName = getName(klass); int pos = fullName.lastIndexOf("$"); @@ -308,9 +308,9 @@ final class VMClass pos = 0; else { - ++pos; - while (Character.isDigit(fullName.charAt(pos))) - ++pos; + ++pos; + while (Character.isDigit(fullName.charAt(pos))) + ++pos; } int packagePos = fullName.lastIndexOf(".", pos); if (packagePos == -1) @@ -346,7 +346,7 @@ final class VMClass * The canonical name for top-level classes, top-level interfaces and * primitive types is always the same as the fully-qualified name. * For array types, the canonical name is the canonical name of its - * component type with `[]' appended. + * component type with `[]' appended. * </p> * <p> * The canonical name of a member class always refers to the place where @@ -374,17 +374,17 @@ final class VMClass return null; if (isArray(klass)) { - String componentName = getComponentType(klass).getCanonicalName(); - if (componentName != null) - return componentName + "[]"; + String componentName = getComponentType(klass).getCanonicalName(); + if (componentName != null) + return componentName + "[]"; } if (isMemberClass(klass)) { - String memberName = getDeclaringClass(klass).getCanonicalName(); - if (memberName != null) - return memberName + "." + getSimpleName(klass); - else - return memberName; + String memberName = getDeclaringClass(klass).getCanonicalName(); + if (memberName != null) + return memberName + "." + getSimpleName(klass); + else + return memberName; } return getName(klass); } @@ -402,7 +402,7 @@ final class VMClass /** * Returns the constructor which immediately encloses the specified class. - * If the class is a top-level class, or a local or anonymous class + * If the class is a top-level class, or a local or anonymous class * immediately enclosed by a type definition, instance initializer * or static initializer, then <code>null</code> is returned. * @@ -416,7 +416,7 @@ final class VMClass /** * Returns the method which immediately encloses the specified class. If - * the class is a top-level class, or a local or anonymous class + * the class is a top-level class, or a local or anonymous class * immediately enclosed by a type definition, instance initializer * or static initializer, then <code>null</code> is returned. * @@ -460,7 +460,7 @@ final class VMClass /** * Returns true if the specified class represents an member class. * - * @param klass the klass to test. + * @param klass the klass to test. * @return true if the specified class represents an member class. * @since 1.5 */ diff --git a/libjava/classpath/vm/reference/java/lang/VMClassLoader.java b/libjava/classpath/vm/reference/java/lang/VMClassLoader.java index e56152d..c1d4625 100644 --- a/libjava/classpath/vm/reference/java/lang/VMClassLoader.java +++ b/libjava/classpath/vm/reference/java/lang/VMClassLoader.java @@ -77,7 +77,7 @@ final class VMClassLoader /** jars from property java.boot.class.path */ static final HashMap bootjars = new HashMap(); - + /** * Converts the array string of native package names to @@ -87,18 +87,18 @@ final class VMClassLoader static { String[] packages = getBootPackages(); - + if( packages != null) { - String specName = + String specName = SystemProperties.getProperty("java.specification.name"); String vendor = SystemProperties.getProperty("java.specification.vendor"); String version = SystemProperties.getProperty("java.specification.version"); - + Package p; - + for(int i = 0; i < packages.length; i++) { p = new Package(packages[i], @@ -116,7 +116,7 @@ final class VMClassLoader } } - + /** * Helper to define a class using a string of bytes. This assumes that * the security checks have already been performed, if necessary. @@ -186,23 +186,23 @@ final class VMClassLoader Vector v = new Vector(); while (st.hasMoreTokens()) { - File file = new File(st.nextToken()); - if (file.isDirectory()) - { - try - { + File file = new File(st.nextToken()); + if (file.isDirectory()) + { + try + { File f = new File(file, name); if (!f.exists()) continue; v.add(new URL("file://" + f.getAbsolutePath())); - } - catch (MalformedURLException e) - { - throw new Error(e); - } - } - else if (file.isFile()) - { - ZipFile zip; + } + catch (MalformedURLException e) + { + throw new Error(e); + } + } + else if (file.isFile()) + { + ZipFile zip; synchronized(bootjars) { zip = (ZipFile) bootjars.get(file.getName()); @@ -210,31 +210,31 @@ final class VMClassLoader if(zip == null) { try - { + { zip = new ZipFile(file); synchronized(bootjars) { bootjars.put(file.getName(), zip); } - } - catch (IOException e) - { - continue; - } + } + catch (IOException e) + { + continue; + } + } + String zname = name.startsWith("/") ? name.substring(1) : name; + if (zip.getEntry(zname) == null) + continue; + try + { + v.add(new URL("jar:file://" + + file.getAbsolutePath() + "!/" + zname)); } - String zname = name.startsWith("/") ? name.substring(1) : name; - if (zip.getEntry(zname) == null) - continue; - try - { - v.add(new URL("jar:file://" - + file.getAbsolutePath() + "!/" + zname)); - } - catch (MalformedURLException e) - { - throw new Error(e); - } - } + catch (MalformedURLException e) + { + throw new Error(e); + } + } } return v.elements(); } @@ -297,9 +297,9 @@ final class VMClassLoader } - + /** - * Helper to get all packages from the bootstrap class loader. + * Helper to get all packages from the bootstrap class loader. * * @return all named packages, if any exist */ @@ -410,7 +410,7 @@ final class VMClassLoader static final Class defineClassWithTransformers(ClassLoader loader, String name, byte[] data, int offset, int len, ProtectionDomain pd) { - + if (instrumenter != null) { byte[] modifiedData = new byte[len]; @@ -419,7 +419,7 @@ final class VMClassLoader modifiedData = ((InstrumentationImpl)instrumenter).callTransformers(loader, jvmName, null, pd, modifiedData); - + return defineClass(loader, name, modifiedData, 0, modifiedData.length, pd); } diff --git a/libjava/classpath/vm/reference/java/lang/VMDouble.java b/libjava/classpath/vm/reference/java/lang/VMDouble.java index 58b3b45..8e523cd 100644 --- a/libjava/classpath/vm/reference/java/lang/VMDouble.java +++ b/libjava/classpath/vm/reference/java/lang/VMDouble.java @@ -46,7 +46,7 @@ import gnu.classpath.Configuration; */ /** - * Code relocated from java.lang.Double by + * Code relocated from java.lang.Double by * @author Dave Grove (groved@us.ibm.com) */ final class VMDouble @@ -59,7 +59,7 @@ final class VMDouble { if (Configuration.INIT_LOAD_LIBRARY) { - System.loadLibrary("javalang"); + System.loadLibrary("javalang"); } initIDs(); diff --git a/libjava/classpath/vm/reference/java/lang/VMFloat.java b/libjava/classpath/vm/reference/java/lang/VMFloat.java index 26d89dc..ba523d6 100644 --- a/libjava/classpath/vm/reference/java/lang/VMFloat.java +++ b/libjava/classpath/vm/reference/java/lang/VMFloat.java @@ -46,7 +46,7 @@ import gnu.classpath.Configuration; */ /** - * Code relocated from java.lang.Float by + * Code relocated from java.lang.Float by * @author Dave Grove <groved@us.ibm.com> */ final class VMFloat diff --git a/libjava/classpath/vm/reference/java/lang/VMMath.java b/libjava/classpath/vm/reference/java/lang/VMMath.java index 4d37824..dc5fd42 100644 --- a/libjava/classpath/vm/reference/java/lang/VMMath.java +++ b/libjava/classpath/vm/reference/java/lang/VMMath.java @@ -47,7 +47,7 @@ class VMMath { if (Configuration.INIT_LOAD_LIBRARY) { - System.loadLibrary("javalang"); + System.loadLibrary("javalang"); } } @@ -330,7 +330,7 @@ class VMMath * the original value is returned. The returned result must be within 1 ulp * of the exact result. For a finite value, <code>x</code>, the cube root * of <code>-x</code> is equal to the negation of the cube root - * of <code>x</code>. + * of <code>x</code>. * </p> * <p> * For a square root, use <code>sqrt</code>. For other roots, use @@ -347,7 +347,7 @@ class VMMath /** * <p> * Returns the hyperbolic cosine of the given value. For a value, - * <code>x</code>, the hyperbolic cosine is <code>(e<sup>x</sup> + + * <code>x</code>, the hyperbolic cosine is <code>(e<sup>x</sup> + * e<sup>-x</sup>)/2</code> * with <code>e</code> being <a href="#E">Euler's number</a>. The returned * result must be within 2.5 ulps of the exact result. @@ -357,7 +357,7 @@ class VMMath * returned. For either infinity, positive infinity is returned. * The hyperbolic cosine of zero must be 1.0. * </p> - * + * * @param a the numeric argument * @return the hyperbolic cosine of <code>a</code>. * @since 1.5 @@ -372,12 +372,12 @@ class VMMath * 1 ulp of the exact result, and results must be semi-monotonic. For finite * inputs, the returned value must be greater than or equal to -1.0. Once * a result enters within half a ulp of this limit, the limit is returned. - * </p> + * </p> * <p> * For <code>NaN</code>, positive infinity and zero, the original value * is returned. Negative infinity returns a result of -1.0 (the limit). * </p> - * + * * @param a the numeric argument * @return <code>e<sup>a</sup> - 1</code> * @since 1.5 @@ -396,7 +396,7 @@ class VMMath * is positive infinity. Otherwise, if either argument is <code>NaN</code>, * then <code>NaN</code> is returned. * </p> - * + * * @param a the first parameter. * @param b the second parameter. * @return the hypotenuse matching the supplied parameters. @@ -449,7 +449,7 @@ class VMMath /** * <p> * Returns the hyperbolic sine of the given value. For a value, - * <code>x</code>, the hyperbolic sine is <code>(e<sup>x</sup> - + * <code>x</code>, the hyperbolic sine is <code>(e<sup>x</sup> - * e<sup>-x</sup>)/2</code> * with <code>e</code> being <a href="#E">Euler's number</a>. The returned * result must be within 2.5 ulps of the exact result. @@ -458,7 +458,7 @@ class VMMath * If the supplied value is <code>NaN</code>, an infinity or a zero, then the * original value is returned. * </p> - * + * * @param a the numeric argument * @return the hyperbolic sine of <code>a</code>. * @since 1.5 @@ -468,7 +468,7 @@ class VMMath /** * <p> * Returns the hyperbolic tangent of the given value. For a value, - * <code>x</code>, the hyperbolic tangent is <code>(e<sup>x</sup> - + * <code>x</code>, the hyperbolic tangent is <code>(e<sup>x</sup> - * e<sup>-x</sup>)/(e<sup>x</sup> + e<sup>-x</sup>)</code> * (i.e. <code>sinh(a)/cosh(a)</code>) * with <code>e</code> being <a href="#E">Euler's number</a>. The returned @@ -483,7 +483,7 @@ class VMMath * value is returned. Positive infinity returns +1.0 and negative infinity * returns -1.0. * </p> - * + * * @param a the numeric argument * @return the hyperbolic tangent of <code>a</code>. * @since 1.5 diff --git a/libjava/classpath/vm/reference/java/lang/VMObject.java b/libjava/classpath/vm/reference/java/lang/VMObject.java index 1d1ec40..279f250 100644 --- a/libjava/classpath/vm/reference/java/lang/VMObject.java +++ b/libjava/classpath/vm/reference/java/lang/VMObject.java @@ -54,7 +54,7 @@ final class VMObject * @return the class of the Object. */ static native Class getClass(Object obj); - + /** * The VM is expected to make a field-for-field shallow copy of the * argument. Thus, the copy has the same runtime type as the argument. diff --git a/libjava/classpath/vm/reference/java/lang/VMProcess.java b/libjava/classpath/vm/reference/java/lang/VMProcess.java index 076e599..c41d7cc0 100644 --- a/libjava/classpath/vm/reference/java/lang/VMProcess.java +++ b/libjava/classpath/vm/reference/java/lang/VMProcess.java @@ -85,17 +85,17 @@ final class VMProcess extends Process static int reapedExitValue; // Information about this process - int state; // current state of process - final String[] cmd; // copied from Runtime.exec() - final String[] env; // copied from Runtime.exec() - final File dir; // copied from Runtime.exec() - Throwable exception; // if process failed to start - long pid; // process id - OutputStream stdin; // process input stream - InputStream stdout; // process output stream - InputStream stderr; // process error stream - int exitValue; // process exit value - boolean redirect; // redirect stderr -> stdout + int state; // current state of process + final String[] cmd; // copied from Runtime.exec() + final String[] env; // copied from Runtime.exec() + final File dir; // copied from Runtime.exec() + Throwable exception; // if process failed to start + long pid; // process id + OutputStream stdin; // process input stream + InputStream stdout; // process output stream + InputStream stderr; // process error stream + int exitValue; // process exit value + boolean redirect; // redirect stderr -> stdout // // Dedicated thread that does all the fork()'ing and wait()'ing @@ -125,97 +125,97 @@ final class VMProcess extends Process { final LinkedList workList = VMProcess.workList; while (true) - { - - // Get the next process to spawn (if any) and spawn it. Spawn - // at most one at a time before checking for reapable children. - VMProcess process = null; - synchronized (workList) - { - if (!workList.isEmpty()) - process = (VMProcess)workList.removeFirst(); - } - - if (process != null) - spawn(process); - - - // Check for termination of active child processes - while (!activeMap.isEmpty() && VMProcess.nativeReap()) - { - long pid = VMProcess.reapedPid; - int exitValue = VMProcess.reapedExitValue; - process = (VMProcess)activeMap.remove(new Long(pid)); - if (process != null) - { - synchronized (process) - { - process.exitValue = exitValue; - process.state = TERMINATED; - process.notify(); - } - } - else - System.err.println("VMProcess WARNING reaped unknown process: " - + pid); - } - - - // If there are more new processes to create, go do that now. - // If there is nothing left to do, exit this thread. Otherwise, - // sleep a little while, and then check again for reapable children. - // We will get woken up immediately if there are new processes to - // spawn, but not if there are new children to reap. So we only - // sleep a short time, in effect polling while processes are active. - synchronized (workList) - { - if (!workList.isEmpty()) - continue; - if (activeMap.isEmpty()) - { - processThread = null; - break; - } - - try - { - workList.wait(MAX_REAP_DELAY); - } - catch (InterruptedException e) - { - /* ignore */ - } - } - } + { + + // Get the next process to spawn (if any) and spawn it. Spawn + // at most one at a time before checking for reapable children. + VMProcess process = null; + synchronized (workList) + { + if (!workList.isEmpty()) + process = (VMProcess)workList.removeFirst(); + } + + if (process != null) + spawn(process); + + + // Check for termination of active child processes + while (!activeMap.isEmpty() && VMProcess.nativeReap()) + { + long pid = VMProcess.reapedPid; + int exitValue = VMProcess.reapedExitValue; + process = (VMProcess)activeMap.remove(new Long(pid)); + if (process != null) + { + synchronized (process) + { + process.exitValue = exitValue; + process.state = TERMINATED; + process.notify(); + } + } + else + System.err.println("VMProcess WARNING reaped unknown process: " + + pid); + } + + + // If there are more new processes to create, go do that now. + // If there is nothing left to do, exit this thread. Otherwise, + // sleep a little while, and then check again for reapable children. + // We will get woken up immediately if there are new processes to + // spawn, but not if there are new children to reap. So we only + // sleep a short time, in effect polling while processes are active. + synchronized (workList) + { + if (!workList.isEmpty()) + continue; + if (activeMap.isEmpty()) + { + processThread = null; + break; + } + + try + { + workList.wait(MAX_REAP_DELAY); + } + catch (InterruptedException e) + { + /* ignore */ + } + } + } } // Spawn a process private void spawn(VMProcess process) { - + // Spawn the process and put it in our active map indexed by pid. // If the spawn operation fails, store the exception with the process. // In either case, wake up thread that created the process. synchronized (process) - { - try - { - process.nativeSpawn(process.cmd, process.env, process.dir, - process.redirect); - process.state = RUNNING; - activeMap.put(new Long(process.pid), process); - } + { + try + { + process.nativeSpawn(process.cmd, process.env, process.dir, + process.redirect); + process.state = RUNNING; + activeMap.put(new Long(process.pid), process); + } catch (ThreadDeath death) { throw death; } - catch (Throwable t) - { - process.state = TERMINATED; - process.exception = t; - } - process.notify(); - } + catch (Throwable t) + { + process.state = TERMINATED; + process.exception = t; + } + process.notify(); + } } } @@ -223,77 +223,77 @@ final class VMProcess extends Process private VMProcess(String[] cmd, String[] env, File dir, boolean redirect) throws IOException { - + // Initialize this process this.state = INITIAL; this.cmd = cmd; this.env = env; this.dir = dir; this.redirect = redirect; - + // Add process to the new process work list and wakeup processThread synchronized (workList) { - workList.add(this); - if (processThread == null) - { - processThread = new ProcessThread(); - processThread.setDaemon(true); - processThread.start(); - } - else - { - workList.notify(); - } + workList.add(this); + if (processThread == null) + { + processThread = new ProcessThread(); + processThread.setDaemon(true); + processThread.start(); + } + else + { + workList.notify(); + } } // Wait for processThread to spawn this process and update its state synchronized (this) { - while (state == INITIAL) - { - try - { - wait(); - } - catch (InterruptedException e) - { - /* ignore */ - } - } + while (state == INITIAL) + { + try + { + wait(); + } + catch (InterruptedException e) + { + /* ignore */ + } + } } // If spawning failed, rethrow the exception in this thread if (exception != null) { - exception.fillInStackTrace(); - if (exception instanceof IOException) - throw (IOException)exception; + exception.fillInStackTrace(); + if (exception instanceof IOException) + throw (IOException)exception; - if (exception instanceof Error) - throw (Error)exception; + if (exception instanceof Error) + throw (Error)exception; - if (exception instanceof RuntimeException) - throw (RuntimeException)exception; + if (exception instanceof RuntimeException) + throw (RuntimeException)exception; - throw new RuntimeException(exception); + throw new RuntimeException(exception); } } // Invoked by native code (from nativeSpawn()) to record process info. private void setProcessInfo(OutputStream stdin, - InputStream stdout, InputStream stderr, long pid) + InputStream stdout, InputStream stderr, long pid) { this.stdin = stdin; this.stdout = stdout; if (stderr == null) this.stderr = new InputStream() - { - public int read() throws IOException - { - return -1; - } - }; + { + public int read() throws IOException + { + return -1; + } + }; else this.stderr = stderr; this.pid = pid; @@ -308,7 +308,7 @@ final class VMProcess extends Process } static Process exec(List cmd, Map env, - File dir, boolean redirect) throws IOException + File dir, boolean redirect) throws IOException { String[] acmd = (String[]) cmd.toArray(new String[cmd.size()]); String[] aenv = new String[env.size()]; @@ -317,8 +317,8 @@ final class VMProcess extends Process Iterator iter = env.entrySet().iterator(); while (iter.hasNext()) { - Map.Entry entry = (Map.Entry) iter.next(); - aenv[i++] = entry.getKey() + "=" + entry.getValue(); + Map.Entry entry = (Map.Entry) iter.next(); + aenv[i++] = entry.getKey() + "=" + entry.getValue(); } return new VMProcess(acmd, aenv, dir, redirect); @@ -359,17 +359,17 @@ final class VMProcess extends Process return; nativeKill(pid); - + while (state != TERMINATED) { - try - { - wait(); - } - catch (InterruptedException e) - { - /* ignore */ - } + try + { + wait(); + } + catch (InterruptedException e) + { + /* ignore */ + } } } @@ -381,7 +381,7 @@ final class VMProcess extends Process * @throws IOException if the O/S process could not be created. */ native void nativeSpawn(String[] cmd, String[] env, File dir, - boolean redirect) + boolean redirect) throws IOException; /** diff --git a/libjava/classpath/vm/reference/java/lang/VMRuntime.java b/libjava/classpath/vm/reference/java/lang/VMRuntime.java index b685b35..0b58d5f 100644 --- a/libjava/classpath/vm/reference/java/lang/VMRuntime.java +++ b/libjava/classpath/vm/reference/java/lang/VMRuntime.java @@ -50,7 +50,7 @@ final class VMRuntime /** * No instance is ever created. */ - private VMRuntime() + private VMRuntime() { } @@ -177,7 +177,7 @@ final class VMRuntime * @throws NullPointerException if cmd or env have null elements */ static Process exec(String[] cmd, String[] env, File dir) - throws IOException { + throws IOException { return VMProcess.exec(cmd, env, dir); } diff --git a/libjava/classpath/vm/reference/java/lang/VMString.java b/libjava/classpath/vm/reference/java/lang/VMString.java index 7e65eed..e1fbf83 100644 --- a/libjava/classpath/vm/reference/java/lang/VMString.java +++ b/libjava/classpath/vm/reference/java/lang/VMString.java @@ -47,7 +47,7 @@ import java.util.WeakHashMap; */ /** - * Code relocated from java.lang.String by + * Code relocated from java.lang.String by * @author Dave Grove <groved@us.ibm.com> */ final class VMString diff --git a/libjava/classpath/vm/reference/java/lang/VMSystem.java b/libjava/classpath/vm/reference/java/lang/VMSystem.java index bf46b27..52a3c1c 100644 --- a/libjava/classpath/vm/reference/java/lang/VMSystem.java +++ b/libjava/classpath/vm/reference/java/lang/VMSystem.java @@ -163,7 +163,7 @@ final class VMSystem * </p> * * @return the time of a system timer in nanoseconds. - * @since 1.5 + * @since 1.5 */ public static native long nanoTime(); @@ -178,18 +178,18 @@ final class VMSystem /** * Helper method which creates the standard input stream. * VM implementors may choose to construct these streams differently. - * This method can also return null if the stream is created somewhere + * This method can also return null if the stream is created somewhere * else in the VM startup sequence. */ static InputStream makeStandardInputStream() { return new BufferedInputStream(new FileInputStream(FileDescriptor.in)); } - + /** * Helper method which creates the standard output stream. * VM implementors may choose to construct these streams differently. - * This method can also return null if the stream is created somewhere + * This method can also return null if the stream is created somewhere * else in the VM startup sequence. */ static PrintStream makeStandardOutputStream() @@ -200,14 +200,14 @@ final class VMSystem /** * Helper method which creates the standard error stream. * VM implementors may choose to construct these streams differently. - * This method can also return null if the stream is created somewhere + * This method can also return null if the stream is created somewhere * else in the VM startup sequence. */ static PrintStream makeStandardErrorStream() { return new PrintStream(new BufferedOutputStream(new FileOutputStream(FileDescriptor.err)), true); } - + /** * Gets the value of an environment variable. * Always returning null is a valid (but not very useful) implementation. diff --git a/libjava/classpath/vm/reference/java/lang/VMThread.java b/libjava/classpath/vm/reference/java/lang/VMThread.java index ff0ec68..1b461a6 100644 --- a/libjava/classpath/vm/reference/java/lang/VMThread.java +++ b/libjava/classpath/vm/reference/java/lang/VMThread.java @@ -62,7 +62,7 @@ package java.lang; * or to implement some optional (and sometimes deprecated) behaviour. Default * implementations are provided but it is highly recommended to optimize them * for a specific VM. - * + * * @author Jeroen Frijters (jeroen@frijters.net) * @author Dalibor Topic (robilad@kaffe.org) */ @@ -93,7 +93,7 @@ final class VMThread */ private VMThread(Thread thread) { - this.thread = thread; + this.thread = thread; } /** @@ -103,48 +103,48 @@ final class VMThread */ private void run() { - try - { - try - { - running = true; - synchronized(thread) - { - Throwable t = thread.stillborn; - if(t != null) - { - thread.stillborn = null; - throw t; - } - } - thread.run(); - } - catch(Throwable t) - { - try - { - Thread.UncaughtExceptionHandler handler; - handler = thread.getUncaughtExceptionHandler(); - handler.uncaughtException(thread, t); - } - catch(Throwable ignore) - { - } - } - } - finally - { - // Setting runnable to false is partial protection against stop - // being called while we're cleaning up. To be safe all code in - // VMThread be unstoppable. - running = false; - thread.die(); - synchronized(this) - { - // release the threads waiting to join us - notifyAll(); - } - } + try + { + try + { + running = true; + synchronized(thread) + { + Throwable t = thread.stillborn; + if(t != null) + { + thread.stillborn = null; + throw t; + } + } + thread.run(); + } + catch(Throwable t) + { + try + { + Thread.UncaughtExceptionHandler handler; + handler = thread.getUncaughtExceptionHandler(); + handler.uncaughtException(thread, t); + } + catch(Throwable ignore) + { + } + } + } + finally + { + // Setting runnable to false is partial protection against stop + // being called while we're cleaning up. To be safe all code in + // VMThread be unstoppable. + running = false; + thread.die(); + synchronized(this) + { + // release the threads waiting to join us + notifyAll(); + } + } } /** @@ -158,9 +158,9 @@ final class VMThread */ static void create(Thread thread, long stacksize) { - VMThread vmThread = new VMThread(thread); - vmThread.start(stacksize); - thread.vmThread = vmThread; + VMThread vmThread = new VMThread(thread); + vmThread.start(stacksize); + thread.vmThread = vmThread; } /** @@ -170,7 +170,7 @@ final class VMThread */ String getName() { - return thread.name; + return thread.name; } /** @@ -181,7 +181,7 @@ final class VMThread */ void setName(String name) { - thread.name = name; + thread.name = name; } /** @@ -192,8 +192,8 @@ final class VMThread */ void setPriority(int priority) { - thread.priority = priority; - nativeSetPriority(priority); + thread.priority = priority; + nativeSetPriority(priority); } /** @@ -243,32 +243,32 @@ final class VMThread */ synchronized void join(long ms, int ns) throws InterruptedException { - // Round up - ms += (ns != 0) ? 1 : 0; - - // Compute end time, but don't overflow - long now = System.currentTimeMillis(); - long end = now + ms; - if (end < now) - end = Long.MAX_VALUE; - - // A VM is allowed to return from wait() without notify() having been - // called, so we loop to handle possible spurious wakeups. - while(thread.vmThread != null) - { - // We use the VMThread object to wait on, because this is a private - // object, so client code cannot call notify on us. - wait(ms); - if(ms != 0) - { - now = System.currentTimeMillis(); - ms = end - now; - if(ms <= 0) - { - break; - } - } - } + // Round up + ms += (ns != 0) ? 1 : 0; + + // Compute end time, but don't overflow + long now = System.currentTimeMillis(); + long end = now + ms; + if (end < now) + end = Long.MAX_VALUE; + + // A VM is allowed to return from wait() without notify() having been + // called, so we loop to handle possible spurious wakeups. + while(thread.vmThread != null) + { + // We use the VMThread object to wait on, because this is a private + // object, so client code cannot call notify on us. + wait(ms); + if(ms != 0) + { + now = System.currentTimeMillis(); + ms = end - now; + if(ms <= 0) + { + break; + } + } + } } /** @@ -276,7 +276,7 @@ final class VMThread * If you stop a Thread that has not yet started, the stop is ignored * (contrary to what the JDK documentation says). * <b>WARNING</b>This bypasses Java security, and can throw a checked - * exception which the call stack is unprepared to handle. Do not abuse + * exception which the call stack is unprepared to handle. Do not abuse * this power. * * <p>This is inherently unsafe, as it can interrupt synchronized blocks and @@ -290,12 +290,12 @@ final class VMThread */ void stop(Throwable t) { - // Note: we assume that we own the lock on thread - // (i.e. that Thread.stop() is synchronized) - if(running) - nativeStop(t); - else - thread.stillborn = t; + // Note: we assume that we own the lock on thread + // (i.e. that Thread.stop() is synchronized) + if(running) + nativeStop(t); + else + thread.stillborn = t; } /** @@ -383,33 +383,33 @@ final class VMThread // It's unclear if this is a bug in the implementation or the spec. // See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6213203 if (ms == 0 && ns == 0) - { - if (Thread.interrupted()) - throw new InterruptedException(); - return; - } + { + if (Thread.interrupted()) + throw new InterruptedException(); + return; + } // Compute end time, but don't overflow long now = System.currentTimeMillis(); long end = now + ms; if (end < now) - end = Long.MAX_VALUE; + end = Long.MAX_VALUE; // A VM is allowed to return from wait() without notify() having been // called, so we loop to handle possible spurious wakeups. VMThread vt = Thread.currentThread().vmThread; synchronized (vt) - { - while (true) - { - vt.wait(ms, ns); - now = System.currentTimeMillis(); - if (now >= end) - break; - ms = end - now; - ns = 0; - } - } + { + while (true) + { + vt.wait(ms, ns); + now = System.currentTimeMillis(); + if (now >= end) + break; + ms = end - now; + ns = 0; + } + } } /** @@ -428,23 +428,23 @@ final class VMThread * @return true if the current thread is currently synchronized on obj * @throws NullPointerException if obj is null */ - static boolean holdsLock(Object obj) + static boolean holdsLock(Object obj) { /* Use obj.notify to check if the current thread holds * the monitor of the object. * If it doesn't, notify will throw an exception. */ - try - { - obj.notify(); - // okay, current thread holds lock - return true; - } + try + { + obj.notify(); + // okay, current thread holds lock + return true; + } catch (IllegalMonitorStateException e) - { - // it doesn't hold the lock - return false; - } + { + // it doesn't hold the lock + return false; + } } /** @@ -453,7 +453,7 @@ final class VMThread * "RUNNABLE", "TERMINATED", "TIMED_WAITING" or * "WAITING". * - * @return a string corresponding to one of the + * @return a string corresponding to one of the * thread enumeration states specified above. */ native String getState(); diff --git a/libjava/classpath/vm/reference/java/lang/reflect/VMConstructor.java b/libjava/classpath/vm/reference/java/lang/reflect/VMConstructor.java index dbed903..c6f3190 100644 --- a/libjava/classpath/vm/reference/java/lang/reflect/VMConstructor.java +++ b/libjava/classpath/vm/reference/java/lang/reflect/VMConstructor.java @@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -47,7 +47,7 @@ final class VMConstructor Class clazz; int slot; - /** + /** * This field allows us to refer back to the main constructor instance. * It is set by the constructor of Constructor. */ @@ -97,7 +97,7 @@ final class VMConstructor * is no Signature attribute, return null. */ native String getSignature(); - + /** * <p> * Return an array of arrays representing the annotations on each @@ -112,7 +112,7 @@ final class VMConstructor * The returned annotations are serialized. Changing the annotations has * no affect on the return value of future calls to this method. * </p> - * + * * @return an array of arrays which represents the annotations used on the * parameters of this constructor. The order of the array elements * matches the declaration order of the parameters. @@ -134,7 +134,7 @@ final class VMConstructor { if (!(o instanceof Constructor)) return false; - Constructor that = (Constructor)o; + Constructor that = (Constructor)o; if (clazz != that.getDeclaringClass()) return false; if (!Arrays.equals(getParameterTypes(), that.getParameterTypes())) diff --git a/libjava/classpath/vm/reference/java/lang/reflect/VMField.java b/libjava/classpath/vm/reference/java/lang/reflect/VMField.java index 53f3847..ee9239a 100644 --- a/libjava/classpath/vm/reference/java/lang/reflect/VMField.java +++ b/libjava/classpath/vm/reference/java/lang/reflect/VMField.java @@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -45,8 +45,8 @@ final class VMField Class clazz; String name; int slot; - - /** + + /** * This field allows us to refer back to the main constructor instance. * It is set by the constructor of Field. */ @@ -512,7 +512,7 @@ final class VMField { if (!(o instanceof Field)) return false; - Field that = (Field)o; + Field that = (Field)o; if (clazz != that.getDeclaringClass()) return false; if (!name.equals(that.getName())) diff --git a/libjava/classpath/vm/reference/java/lang/reflect/VMMethod.java b/libjava/classpath/vm/reference/java/lang/reflect/VMMethod.java index f8574cd..d8bb8b4 100644 --- a/libjava/classpath/vm/reference/java/lang/reflect/VMMethod.java +++ b/libjava/classpath/vm/reference/java/lang/reflect/VMMethod.java @@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -48,7 +48,7 @@ final class VMMethod String name; int slot; - /** + /** * This field allows us to refer back to the main constructor instance. * It is set by the constructor of Field. */ @@ -129,7 +129,7 @@ final class VMMethod * The returned annotations are serialized. Changing the annotations has * no affect on the return value of future calls to this method. * </p> - * + * * @return an array of arrays which represents the annotations used on the * parameters of this method. The order of the array elements * matches the declaration order of the parameters. @@ -206,4 +206,3 @@ final class VMMethod native Annotation[] getDeclaredAnnotations(); } - diff --git a/libjava/classpath/vm/reference/java/net/VMNetworkInterface.java b/libjava/classpath/vm/reference/java/net/VMNetworkInterface.java index 63a29b1..fca0c52 100644 --- a/libjava/classpath/vm/reference/java/net/VMNetworkInterface.java +++ b/libjava/classpath/vm/reference/java/net/VMNetworkInterface.java @@ -64,7 +64,7 @@ final class VMNetworkInterface this.name = name; addresses = new HashSet(); } - + /** * Creates a dummy instance which represents any network * interface. @@ -81,15 +81,15 @@ final class VMNetworkInterface // Cannot happen. } } - + static { if (Configuration.INIT_LOAD_LIBRARY) System.loadLibrary("javanet"); - + initIds(); } - + private static native void initIds(); /** @@ -100,7 +100,7 @@ final class VMNetworkInterface */ public static native VMNetworkInterface[] getVMInterfaces() throws SocketException; - + private void addAddress(ByteBuffer addr) throws SocketException, UnknownHostException { diff --git a/libjava/classpath/vm/reference/java/nio/channels/VMChannels.java b/libjava/classpath/vm/reference/java/nio/channels/VMChannels.java index c833b6e..05b1441 100644 --- a/libjava/classpath/vm/reference/java/nio/channels/VMChannels.java +++ b/libjava/classpath/vm/reference/java/nio/channels/VMChannels.java @@ -63,35 +63,35 @@ final class VMChannels { try { - Class[] argTypes = new Class[1]; - argTypes[0] = FileChannelImpl.class; - Constructor constructor = - streamClass.getDeclaredConstructor(argTypes); - constructor.setAccessible(true); - Object[] args = new Object[1]; - args[0] = ch; - return constructor.newInstance(args); + Class[] argTypes = new Class[1]; + argTypes[0] = FileChannelImpl.class; + Constructor constructor = + streamClass.getDeclaredConstructor(argTypes); + constructor.setAccessible(true); + Object[] args = new Object[1]; + args[0] = ch; + return constructor.newInstance(args); } catch (IllegalAccessException e) { - // Ignored. + // Ignored. } catch (InstantiationException e) { - // Ignored. + // Ignored. } catch (InvocationTargetException e) { - // Ignored. + // Ignored. } catch (NoSuchMethodException e) { - // Ignored. + // Ignored. } return null; } - + /** * Constructs a stream that reads bytes from the given channel. */ @@ -99,7 +99,7 @@ final class VMChannels { if (ch instanceof FileChannelImpl) return (FileInputStream) createStream(FileInputStream.class, ch); - + return new ChannelInputStream(ch); } @@ -110,7 +110,7 @@ final class VMChannels { if (ch instanceof FileChannelImpl) return (FileOutputStream) createStream(FileOutputStream.class, ch); - + return new ChannelOutputStream(ch); } } diff --git a/libjava/classpath/vm/reference/java/security/VMAccessController.java b/libjava/classpath/vm/reference/java/security/VMAccessController.java index da13c68..9299e6f 100644 --- a/libjava/classpath/vm/reference/java/security/VMAccessController.java +++ b/libjava/classpath/vm/reference/java/security/VMAccessController.java @@ -205,8 +205,8 @@ final class VMAccessController && method.equals ("doPrivileged")) { // If there was a call to doPrivileged with a supplied context, - // return that context. If using JAAS doAs*, it should be - // a context with a SubjectDomainCombiner + // return that context. If using JAAS doAs*, it should be + // a context with a SubjectDomainCombiner LinkedList l = (LinkedList) contexts.get(); if (l != null) context = (AccessControlContext) l.getFirst(); @@ -214,7 +214,7 @@ final class VMAccessController } // subject to getProtectionDomain RuntimePermission - ProtectionDomain domain = clazz.getProtectionDomain(); + ProtectionDomain domain = clazz.getProtectionDomain(); if (domain == null) continue; diff --git a/libjava/classpath/vm/reference/java/security/VMSecureRandom.java b/libjava/classpath/vm/reference/java/security/VMSecureRandom.java index 5eeb158..bea1549 100644 --- a/libjava/classpath/vm/reference/java/security/VMSecureRandom.java +++ b/libjava/classpath/vm/reference/java/security/VMSecureRandom.java @@ -126,4 +126,4 @@ final class VMSecureRandom running = false; } } -}
\ No newline at end of file +} diff --git a/libjava/classpath/vm/reference/java/util/VMTimeZone.java b/libjava/classpath/vm/reference/java/util/VMTimeZone.java index 992ecaf..11061aa 100644 --- a/libjava/classpath/vm/reference/java/util/VMTimeZone.java +++ b/libjava/classpath/vm/reference/java/util/VMTimeZone.java @@ -55,10 +55,10 @@ final class VMTimeZone { if (Configuration.INIT_LOAD_LIBRARY) { - System.loadLibrary("javautil"); + System.loadLibrary("javautil"); } } - + /** * This method returns a time zone id string which is in the form * (standard zone name) or (standard zone name)(GMT offset) or @@ -104,67 +104,67 @@ final class VMTimeZone // Try to parse /etc/timezone. if (zone == null) { - tzid = readTimeZoneFile("/etc/timezone"); - if (tzid != null && !tzid.equals("")) - zone = TimeZone.getDefaultTimeZone(tzid); + tzid = readTimeZoneFile("/etc/timezone"); + if (tzid != null && !tzid.equals("")) + zone = TimeZone.getDefaultTimeZone(tzid); } - + // Try to parse /etc/localtime if (zone == null) { - zone = ZoneInfo.readTZFile((String) null, "/etc/localtime"); - if (zone != null) - { - // Try to find a more suitable ID for the /etc/localtime - // timezone. - // Sometimes /etc/localtime is a symlink to some - // /usr/share/zoneinfo/ file. - String id = null; - try - { - id = new File("/etc/localtime").getCanonicalPath(); - if (id != null) - { - String zoneinfo_dir - = SystemProperties.getProperty("gnu.java.util.zoneinfo.dir"); - if (zoneinfo_dir != null) - zoneinfo_dir - = new File(zoneinfo_dir - + File.separatorChar).getCanonicalPath(); - if (zoneinfo_dir != null && id.startsWith(zoneinfo_dir)) - { - int pos = zoneinfo_dir.length(); - while (pos < id.length() - && id.charAt(pos) == File.separatorChar) - pos++; - if (pos < id.length()) - id = id.substring(pos); - else - id = null; - } - else - id = null; - } - } - catch (IOException ioe) - { - id = null; - } + zone = ZoneInfo.readTZFile((String) null, "/etc/localtime"); + if (zone != null) + { + // Try to find a more suitable ID for the /etc/localtime + // timezone. + // Sometimes /etc/localtime is a symlink to some + // /usr/share/zoneinfo/ file. + String id = null; + try + { + id = new File("/etc/localtime").getCanonicalPath(); + if (id != null) + { + String zoneinfo_dir + = SystemProperties.getProperty("gnu.java.util.zoneinfo.dir"); + if (zoneinfo_dir != null) + zoneinfo_dir + = new File(zoneinfo_dir + + File.separatorChar).getCanonicalPath(); + if (zoneinfo_dir != null && id.startsWith(zoneinfo_dir)) + { + int pos = zoneinfo_dir.length(); + while (pos < id.length() + && id.charAt(pos) == File.separatorChar) + pos++; + if (pos < id.length()) + id = id.substring(pos); + else + id = null; + } + else + id = null; + } + } + catch (IOException ioe) + { + id = null; + } - if (id == null) - id = readSysconfigClockFile("/etc/sysconfig/clock"); + if (id == null) + id = readSysconfigClockFile("/etc/sysconfig/clock"); - if (id != null) - zone.setID(id); - } + if (id != null) + zone.setID(id); + } } // Try some system specific way if (zone == null) { - tzid = getSystemTimeZoneId(); - if (tzid != null && !tzid.equals("")) - zone = TimeZone.getDefaultTimeZone(tzid); + tzid = getSystemTimeZoneId(); + if (tzid != null && !tzid.equals("")) + zone = TimeZone.getDefaultTimeZone(tzid); } return zone; @@ -192,42 +192,42 @@ final class VMTimeZone InputStreamReader isr = null; try { - FileInputStream fis = new FileInputStream(f); - BufferedInputStream bis = new BufferedInputStream(fis); - isr = new InputStreamReader(bis); - - StringBuffer sb = new StringBuffer(); - int i = isr.read(); - while (i != -1) - { - char c = (char) i; - if (Character.isLetter(c) || Character.isDigit(c) - || c == '/' || c == '-' || c == '_') - { - sb.append(c); - i = isr.read(); - } - else - break; - } - return sb.toString(); + FileInputStream fis = new FileInputStream(f); + BufferedInputStream bis = new BufferedInputStream(fis); + isr = new InputStreamReader(bis); + + StringBuffer sb = new StringBuffer(); + int i = isr.read(); + while (i != -1) + { + char c = (char) i; + if (Character.isLetter(c) || Character.isDigit(c) + || c == '/' || c == '-' || c == '_') + { + sb.append(c); + i = isr.read(); + } + else + break; + } + return sb.toString(); } catch (IOException ioe) { - // Parse error, not a proper tzfile. - return null; + // Parse error, not a proper tzfile. + return null; } finally { - try - { - if (isr != null) - isr.close(); - } - catch (IOException ioe) - { - // Error while close, nothing we can do. - } + try + { + if (isr != null) + isr.close(); + } + catch (IOException ioe) + { + // Error while close, nothing we can do. + } } } @@ -248,48 +248,48 @@ final class VMTimeZone BufferedReader br = null; try { - FileInputStream fis = new FileInputStream(file); - BufferedInputStream bis = new BufferedInputStream(fis); - br = new BufferedReader(new InputStreamReader(bis)); + FileInputStream fis = new FileInputStream(file); + BufferedInputStream bis = new BufferedInputStream(fis); + br = new BufferedReader(new InputStreamReader(bis)); - for (String line = br.readLine(); line != null; line = br.readLine()) - { - line = line.trim(); - if (line.length() < 8 || !line.startsWith("ZONE=")) - continue; - int posstart = 6; - int posend; - if (line.charAt(5) == '"') - posend = line.indexOf('"', 6); - else if (line.charAt(5) == '\'') - posend = line.indexOf('\'', 6); - else - { - posstart = 5; - posend = line.length(); - } - if (posend < 0) - return null; - return line.substring(posstart, posend); - } - return null; + for (String line = br.readLine(); line != null; line = br.readLine()) + { + line = line.trim(); + if (line.length() < 8 || !line.startsWith("ZONE=")) + continue; + int posstart = 6; + int posend; + if (line.charAt(5) == '"') + posend = line.indexOf('"', 6); + else if (line.charAt(5) == '\'') + posend = line.indexOf('\'', 6); + else + { + posstart = 5; + posend = line.length(); + } + if (posend < 0) + return null; + return line.substring(posstart, posend); + } + return null; } catch (IOException ioe) { - // Parse error, not a proper tzfile. - return null; + // Parse error, not a proper tzfile. + return null; } finally { - try - { - if (br != null) - br.close(); - } - catch (IOException ioe) - { - // Error while close, nothing we can do. - } + try + { + if (br != null) + br.close(); + } + catch (IOException ioe) + { + // Error while close, nothing we can do. + } } } |