harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ndbe...@apache.org
Subject svn commit: r446491 [3/24] - in /incubator/harmony/enhanced/classlib/trunk/modules: luni-kernel/.settings/ luni-kernel/META-INF/ luni-kernel/make/ luni-kernel/src/main/java/java/lang/ luni-kernel/src/main/java/java/lang/ref/ luni-kernel/src/main/java/j...
Date Fri, 15 Sep 2006 03:08:13 GMT
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni-kernel/src/main/java/java/lang/Runtime.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni-kernel/src/main/java/java/lang/Runtime.java?view=diff&rev=446491&r1=446490&r2=446491
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni-kernel/src/main/java/java/lang/Runtime.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni-kernel/src/main/java/java/lang/Runtime.java
Thu Sep 14 20:08:07 2006
@@ -1,306 +1,306 @@
-/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
- * 
- * Licensed 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 java.lang;
-
-import java.io.File;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-/**
- * This class, with the exception of the exec() APIs, must be implemented by the
- * VM vendor. The exec() APIs must first do any required security checks, and
- * then call org.apache.harmony.luni.internal.process.SystemProcess.create().
- * The Runtime interface.
- */
-public class Runtime {
-    /**
-     * Execute progAray[0] in a separate platform process The new process
-     * inherits the environment of the caller.
-     * 
-     * @param progArray the array containing the program to execute as well as
-     *        any arguments to the program.
-     * @throws java.io.IOException if the program cannot be executed
-     * @throws SecurityException if the current SecurityManager disallows
-     *         program execution
-     * @see SecurityManager#checkExec
-     */
-    public Process exec(String[] progArray) throws java.io.IOException {
-        return null;
-    }
-
-    /**
-     * Execute progArray[0] in a seperate platform process The new process uses
-     * the environment provided in envp
-     * 
-     * @param progArray the array containing the program to execute a well as
-     *        any arguments to the program.
-     * @param envp the array containing the environment to start the new process
-     *        in.
-     * @throws java.io.IOException if the program cannot be executed
-     * @throws SecurityException if the current SecurityManager disallows
-     *         program execution
-     * @see SecurityManager#checkExec
-     */
-    public Process exec(String[] progArray, String[] envp) throws java.io.IOException {
-        return null;
-    }
-
-    /**
-     * Execute progArray[0] in a seperate platform process. The new process uses
-     * the environment provided in envp
-     * 
-     * @param progArray the array containing the program to execute a well as
-     *        any arguments to the program.
-     * @param envp the array containing the environment to start the new process
-     *        in.
-     * @param directory the directory in which to execute progArray[0]. If null,
-     *        execute in same directory as parent process.
-     * @throws java.io.IOException if the program cannot be executed
-     * @throws SecurityException if the current SecurityManager disallows
-     *         program execution
-     * @see SecurityManager#checkExec
-     */
-    public Process exec(String[] progArray, String[] envp, File directory)
-            throws java.io.IOException {
-        return null;
-    }
-
-    /**
-     * Execute program in a seperate platform process The new process inherits
-     * the environment of the caller.
-     * 
-     * @param prog the name of the program to execute
-     * @throws java.io.IOException if the program cannot be executed
-     * @throws SecurityException if the current SecurityManager disallows
-     *         program execution
-     * @see SecurityManager#checkExec
-     */
-    public Process exec(String prog) throws java.io.IOException {
-        return null;
-    }
-
-    /**
-     * Execute prog in a seperate platform process The new process uses the
-     * environment provided in envp
-     * 
-     * @param prog the name of the program to execute
-     * @param envp the array containing the environment to start the new process
-     *        in.
-     * @throws java.io.IOException if the program cannot be executed
-     * @throws SecurityException if the current SecurityManager disallows
-     *         program execution
-     * @see SecurityManager#checkExec
-     */
-    public Process exec(String prog, String[] envp) throws java.io.IOException {
-        return null;
-    }
-
-    /**
-     * Execute prog in a seperate platform process The new process uses the
-     * environment provided in envp
-     * 
-     * @param prog the name of the program to execute
-     * @param envp the array containing the environment to start the new process
-     *        in.
-     * @param directory the initial directory for the subprocess, or null to use
-     *        the directory of the current process
-     * @throws java.io.IOException if the program cannot be executed
-     * @throws SecurityException if the current SecurityManager disallows
-     *         program execution
-     * @see SecurityManager#checkExec
-     */
-    public Process exec(String prog, String[] envp, File directory) throws java.io.IOException
{
-        return null;
-    }
-
-    /**
-     * Causes the virtual machine to stop running, and the program to exit. If
-     * runFinalizersOnExit(true) has been invoked, then all finalizers will be
-     * run first.
-     * 
-     * @param code the return code.
-     * @throws SecurityException if the running thread is not allowed to cause
-     *         the vm to exit.
-     * @see SecurityManager#checkExit
-     */
-    public void exit(int code) {
-        return;
-    }
-
-    /**
-     * Answers the amount of free memory resources which are available to the
-     * running program.
-     * 
-     */
-    public long freeMemory() {
-        return 0L;
-    }
-
-    /**
-     * Indicates to the virtual machine that it would be a good time to collect
-     * available memory. Note that, this is a hint only.
-     * 
-     */
-    public void gc() {
-        return;
-    }
-
-    /**
-     * Return the single Runtime instance
-     * 
-     */
-    public static Runtime getRuntime() {
-        return null;
-    }
-
-    /**
-     * Loads and links the library specified by the argument.
-     * 
-     * @param pathName the absolute (ie: platform dependent) path to the library
-     *        to load
-     * @throws UnsatisfiedLinkError if the library could not be loaded
-     * @throws SecurityException if the library was not allowed to be loaded
-     */
-    public void load(String pathName) {
-        return;
-    }
-
-    /**
-     * Loads and links the library specified by the argument.
-     * 
-     * @param libName the name of the library to load
-     * @throws UnsatisfiedLinkError if the library could not be loaded
-     * @throws SecurityException if the library was not allowed to be loaded
-     */
-    public void loadLibrary(String libName) {
-        return;
-    }
-
-    /**
-     * Provides a hint to the virtual machine that it would be useful to attempt
-     * to perform any outstanding object finalizations.
-     * 
-     */
-    public void runFinalization() {
-        return;
-    }
-
-    /**
-     * Ensure that, when the virtual machine is about to exit, all objects are
-     * finalized. Note that all finalization which occurs when the system is
-     * exiting is performed after all running threads have been terminated.
-     * 
-     * @param run true means finalize all on exit.
-     * @deprecated This method is unsafe.
-     */
-    @Deprecated
-    public static void runFinalizersOnExit(boolean run) {
-        return;
-    }
-
-    /**
-     * Answers the total amount of memory resources which is available to (or in
-     * use by) the running program.
-     * 
-     */
-    public long totalMemory() {
-        return 0L;
-    }
-
-    /**
-     * Turns the output of debug information for instructions on or off.
-     * 
-     * @param enable if true, turn trace on. false turns trace off.
-     */
-    public void traceInstructions(boolean enable) {
-        return;
-    }
-
-    /**
-     * Turns the output of debug information for methods on or off.
-     * 
-     * @param enable if true, turn trace on. false turns trace off.
-     */
-    public void traceMethodCalls(boolean enable) {
-        return;
-    }
-
-    /**
-     * @deprecated Use InputStreamReader
-     */
-    @Deprecated
-    public InputStream getLocalizedInputStream(InputStream stream) {
-        return null;
-    }
-
-    /**
-     * @deprecated Use OutputStreamWriter
-     */
-    @Deprecated
-    public OutputStream getLocalizedOutputStream(OutputStream stream) {
-        return null;
-    }
-
-    /**
-     * Registers a new virtual-machine shutdown hook.
-     * 
-     * @param hook the hook (a Thread) to register
-     */
-    public void addShutdownHook(Thread hook) {
-        return;
-    }
-
-    /**
-     * De-registers a previously-registered virtual-machine shutdown hook.
-     * 
-     * @param hook the hook (a Thread) to de-register
-     * @return true if the hook could be de-registered
-     */
-    public boolean removeShutdownHook(Thread hook) {
-        return false;
-    }
-
-    /**
-     * Causes the virtual machine to stop running, and the program to exit.
-     * Finalizers will not be run first. Shutdown hooks will not be run.
-     * 
-     * @param code
-     *            the return code.
-     * @throws SecurityException
-     *                if the running thread is not allowed to cause the vm to
-     *                exit.
-     * @see SecurityManager#checkExit
-     */
-    public void halt(int code) {
-        return;
-    }
-
-    /**
-     * Return the number of processors, always at least one.
-     */
-    public int availableProcessors() {
-        return 0;
-    }
-
-    /**
-     * Return the maximum memory that will be used by the virtual machine, or
-     * Long.MAX_VALUE.
-     */
-    public long maxMemory() {
-        return 0L;
-    }
-
-}
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed 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 java.lang;
+
+import java.io.File;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+/**
+ * This class, with the exception of the exec() APIs, must be implemented by the
+ * VM vendor. The exec() APIs must first do any required security checks, and
+ * then call org.apache.harmony.luni.internal.process.SystemProcess.create().
+ * The Runtime interface.
+ */
+public class Runtime {
+    /**
+     * Execute progAray[0] in a separate platform process The new process
+     * inherits the environment of the caller.
+     * 
+     * @param progArray the array containing the program to execute as well as
+     *        any arguments to the program.
+     * @throws java.io.IOException if the program cannot be executed
+     * @throws SecurityException if the current SecurityManager disallows
+     *         program execution
+     * @see SecurityManager#checkExec
+     */
+    public Process exec(String[] progArray) throws java.io.IOException {
+        return null;
+    }
+
+    /**
+     * Execute progArray[0] in a seperate platform process The new process uses
+     * the environment provided in envp
+     * 
+     * @param progArray the array containing the program to execute a well as
+     *        any arguments to the program.
+     * @param envp the array containing the environment to start the new process
+     *        in.
+     * @throws java.io.IOException if the program cannot be executed
+     * @throws SecurityException if the current SecurityManager disallows
+     *         program execution
+     * @see SecurityManager#checkExec
+     */
+    public Process exec(String[] progArray, String[] envp) throws java.io.IOException {
+        return null;
+    }
+
+    /**
+     * Execute progArray[0] in a seperate platform process. The new process uses
+     * the environment provided in envp
+     * 
+     * @param progArray the array containing the program to execute a well as
+     *        any arguments to the program.
+     * @param envp the array containing the environment to start the new process
+     *        in.
+     * @param directory the directory in which to execute progArray[0]. If null,
+     *        execute in same directory as parent process.
+     * @throws java.io.IOException if the program cannot be executed
+     * @throws SecurityException if the current SecurityManager disallows
+     *         program execution
+     * @see SecurityManager#checkExec
+     */
+    public Process exec(String[] progArray, String[] envp, File directory)
+            throws java.io.IOException {
+        return null;
+    }
+
+    /**
+     * Execute program in a seperate platform process The new process inherits
+     * the environment of the caller.
+     * 
+     * @param prog the name of the program to execute
+     * @throws java.io.IOException if the program cannot be executed
+     * @throws SecurityException if the current SecurityManager disallows
+     *         program execution
+     * @see SecurityManager#checkExec
+     */
+    public Process exec(String prog) throws java.io.IOException {
+        return null;
+    }
+
+    /**
+     * Execute prog in a seperate platform process The new process uses the
+     * environment provided in envp
+     * 
+     * @param prog the name of the program to execute
+     * @param envp the array containing the environment to start the new process
+     *        in.
+     * @throws java.io.IOException if the program cannot be executed
+     * @throws SecurityException if the current SecurityManager disallows
+     *         program execution
+     * @see SecurityManager#checkExec
+     */
+    public Process exec(String prog, String[] envp) throws java.io.IOException {
+        return null;
+    }
+
+    /**
+     * Execute prog in a seperate platform process The new process uses the
+     * environment provided in envp
+     * 
+     * @param prog the name of the program to execute
+     * @param envp the array containing the environment to start the new process
+     *        in.
+     * @param directory the initial directory for the subprocess, or null to use
+     *        the directory of the current process
+     * @throws java.io.IOException if the program cannot be executed
+     * @throws SecurityException if the current SecurityManager disallows
+     *         program execution
+     * @see SecurityManager#checkExec
+     */
+    public Process exec(String prog, String[] envp, File directory) throws java.io.IOException
{
+        return null;
+    }
+
+    /**
+     * Causes the virtual machine to stop running, and the program to exit. If
+     * runFinalizersOnExit(true) has been invoked, then all finalizers will be
+     * run first.
+     * 
+     * @param code the return code.
+     * @throws SecurityException if the running thread is not allowed to cause
+     *         the vm to exit.
+     * @see SecurityManager#checkExit
+     */
+    public void exit(int code) {
+        return;
+    }
+
+    /**
+     * Answers the amount of free memory resources which are available to the
+     * running program.
+     * 
+     */
+    public long freeMemory() {
+        return 0L;
+    }
+
+    /**
+     * Indicates to the virtual machine that it would be a good time to collect
+     * available memory. Note that, this is a hint only.
+     * 
+     */
+    public void gc() {
+        return;
+    }
+
+    /**
+     * Return the single Runtime instance
+     * 
+     */
+    public static Runtime getRuntime() {
+        return null;
+    }
+
+    /**
+     * Loads and links the library specified by the argument.
+     * 
+     * @param pathName the absolute (ie: platform dependent) path to the library
+     *        to load
+     * @throws UnsatisfiedLinkError if the library could not be loaded
+     * @throws SecurityException if the library was not allowed to be loaded
+     */
+    public void load(String pathName) {
+        return;
+    }
+
+    /**
+     * Loads and links the library specified by the argument.
+     * 
+     * @param libName the name of the library to load
+     * @throws UnsatisfiedLinkError if the library could not be loaded
+     * @throws SecurityException if the library was not allowed to be loaded
+     */
+    public void loadLibrary(String libName) {
+        return;
+    }
+
+    /**
+     * Provides a hint to the virtual machine that it would be useful to attempt
+     * to perform any outstanding object finalizations.
+     * 
+     */
+    public void runFinalization() {
+        return;
+    }
+
+    /**
+     * Ensure that, when the virtual machine is about to exit, all objects are
+     * finalized. Note that all finalization which occurs when the system is
+     * exiting is performed after all running threads have been terminated.
+     * 
+     * @param run true means finalize all on exit.
+     * @deprecated This method is unsafe.
+     */
+    @Deprecated
+    public static void runFinalizersOnExit(boolean run) {
+        return;
+    }
+
+    /**
+     * Answers the total amount of memory resources which is available to (or in
+     * use by) the running program.
+     * 
+     */
+    public long totalMemory() {
+        return 0L;
+    }
+
+    /**
+     * Turns the output of debug information for instructions on or off.
+     * 
+     * @param enable if true, turn trace on. false turns trace off.
+     */
+    public void traceInstructions(boolean enable) {
+        return;
+    }
+
+    /**
+     * Turns the output of debug information for methods on or off.
+     * 
+     * @param enable if true, turn trace on. false turns trace off.
+     */
+    public void traceMethodCalls(boolean enable) {
+        return;
+    }
+
+    /**
+     * @deprecated Use InputStreamReader
+     */
+    @Deprecated
+    public InputStream getLocalizedInputStream(InputStream stream) {
+        return null;
+    }
+
+    /**
+     * @deprecated Use OutputStreamWriter
+     */
+    @Deprecated
+    public OutputStream getLocalizedOutputStream(OutputStream stream) {
+        return null;
+    }
+
+    /**
+     * Registers a new virtual-machine shutdown hook.
+     * 
+     * @param hook the hook (a Thread) to register
+     */
+    public void addShutdownHook(Thread hook) {
+        return;
+    }
+
+    /**
+     * De-registers a previously-registered virtual-machine shutdown hook.
+     * 
+     * @param hook the hook (a Thread) to de-register
+     * @return true if the hook could be de-registered
+     */
+    public boolean removeShutdownHook(Thread hook) {
+        return false;
+    }
+
+    /**
+     * Causes the virtual machine to stop running, and the program to exit.
+     * Finalizers will not be run first. Shutdown hooks will not be run.
+     * 
+     * @param code
+     *            the return code.
+     * @throws SecurityException
+     *                if the running thread is not allowed to cause the vm to
+     *                exit.
+     * @see SecurityManager#checkExit
+     */
+    public void halt(int code) {
+        return;
+    }
+
+    /**
+     * Return the number of processors, always at least one.
+     */
+    public int availableProcessors() {
+        return 0;
+    }
+
+    /**
+     * Return the maximum memory that will be used by the virtual machine, or
+     * Long.MAX_VALUE.
+     */
+    public long maxMemory() {
+        return 0L;
+    }
+
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/luni-kernel/src/main/java/java/lang/Runtime.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni-kernel/src/main/java/java/lang/StackTraceElement.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni-kernel/src/main/java/java/lang/StackTraceElement.java?view=diff&rev=446491&r1=446490&r2=446491
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni-kernel/src/main/java/java/lang/StackTraceElement.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni-kernel/src/main/java/java/lang/StackTraceElement.java
Thu Sep 14 20:08:07 2006
@@ -1,235 +1,235 @@
-/* Copyright 2002, 2005 The Apache Software Foundation or its licensors, as applicable
- * 
- * Licensed 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.
- */
-
-/*[INCLUDE-IF mJava14]*/
-
-package java.lang;
-
-import java.io.Serializable;
-
-/**
- * An implementation of this class is provided, but the documented constructor
- * can be used by the VM specific implementation to create instances.
- * 
- * StackTraceElement represents a stack frame.
- * 
- * @see Throwable#getStackTrace()
- * @since 1.4
- */
-public final class StackTraceElement implements Serializable {
-
-    private static final long serialVersionUID = 6992337162326171013L;
-
-    String declaringClass;
-
-    String methodName;
-
-    String fileName;
-
-    int lineNumber;
-
-    /**
-     * <p>
-     * Constructs a <code>StackTraceElement</code> for an execution point.
-     * </p>
-     * 
-     * @param cls The fully qualified name of the class where execution is at.
-     * @param method The name of the method where execution is at.
-     * @param file The name of the file where execution is at or
-     *        <code>null</code>.
-     * @param line The line of the file where execution is at, a negative number
-     *        if unknown or <code>-2</code> if the execution is in a native
-     *        method.
-     * 
-     * @throws NullPointerException if <code>cls</code> or <code>method</code>
-     *         is <code>null</code>.
-     * 
-     * @since 1.5
-     */
-    public StackTraceElement(String cls, String method, String file, int line) {
-        super();
-        if (cls == null || method == null) {
-            throw new NullPointerException();
-        }
-        declaringClass = cls;
-        methodName = method;
-        fileName = file;
-        lineNumber = line;
-    }
-
-    /**
-     * <p>
-     * Private, nullary constructor for VM use only.
-     * </p>
-     */
-    private StackTraceElement() {
-        super();
-    }
-
-    /**
-     * Compare this object with the object passed in
-     * 
-     * @param obj Object to compare with
-     */
-    @Override
-    public boolean equals(Object obj) {
-        if (!(obj instanceof StackTraceElement)) {
-            return false;
-        }
-        StackTraceElement castObj = (StackTraceElement) obj;
-
-        /*
-         * Unknown methods are never equal to anything (not strictly to spec,
-         * but spec does not allow null method/class names)
-         */
-        if ((methodName == null) || (castObj.methodName == null)) {
-            return false;
-        }
-
-        if (!getMethodName().equals(castObj.getMethodName())) {
-            return false;
-        }
-        if (!getClassName().equals(castObj.getClassName())) {
-            return false;
-        }
-        String localFileName = getFileName();
-        if (localFileName == null) {
-            if (castObj.getFileName() != null) {
-                return false;
-            }
-        } else {
-            if (!localFileName.equals(castObj.getFileName())) {
-                return false;
-            }
-        }
-        if (getLineNumber() != castObj.getLineNumber()) {
-            return false;
-        }
-
-        return true;
-    }
-
-    /**
-     * Returns the full name (i.e. including the package) of the class where
-     * this stack trace element is executing.
-     * 
-     * @return the fully qualified type name of the class where this stack trace
-     *         element is executing.
-     */
-    public String getClassName() {
-        return (declaringClass == null) ? "<unknown class>" : declaringClass;
-    }
-
-    /**
-     * If available, returns the name of the file containing the Java code
-     * source which was compiled into the class where this stack trace element
-     * is executing.
-     * 
-     * @return if available, the name of the file containing the Java code
-     *         source for the stack trace element's executing class. If no such
-     *         detail is available, a <code>null</code> value is returned.
-     */
-    public String getFileName() {
-        return fileName;
-    }
-
-    /**
-     * If available, returns the line number in the source for the class where
-     * this stack trace element is executing.
-     * 
-     * @return if available, the line number in the source file for the class
-     *         where this stack trace element is executing. If no such detail is
-     *         available, a number less than <code>0</code>.
-     */
-    public int getLineNumber() {
-        return lineNumber;
-    }
-
-    /**
-     * Returns the name of the method where this stack trace element is
-     * executing.
-     * 
-     * @return the name of the method where this stack trace element is
-     *         executing.
-     */
-    public String getMethodName() {
-        return (methodName == null) ? "<unknown method>" : methodName;
-    }
-
-    /**
-     * Return this StackTraceElement objects hash code
-     * 
-     * @return This objects hash code
-     */
-    @Override
-    public int hashCode() {
-        /*
-         * Either both methodName and declaringClass are null, or neither are
-         * null.
-         */
-        if (methodName == null) {
-            // all unknown methods hash the same
-            return 0;
-        }
-        // declaringClass never null if methodName is non-null
-        return methodName.hashCode() ^ declaringClass.hashCode();
-    }
-
-    /**
-     * Returns <code>true</code> if the method name returned by
-     * {@link #getMethodName()} is implemented as a native method.
-     * 
-     * @return if the method in which this stack trace element is executing is a
-     *         native method
-     */
-    public boolean isNativeMethod() {
-        return lineNumber == -2;
-    }
-
-    /**
-     * Return a String representating this StackTraceElement object
-     * 
-     * @return String representing this object
-     */
-    @Override
-    public String toString() {
-        StringBuilder buf = new StringBuilder(80);
-
-        buf.append(getClassName());
-        buf.append('.');
-        buf.append(getMethodName());
-
-        if (isNativeMethod()) {
-            buf.append("(Native Method)");
-        } else {
-            String fName = getFileName();
-
-            if (fName == null) {
-                buf.append("(Unknown Source)");
-            } else {
-                int lineNum = getLineNumber();
-
-                buf.append('(');
-                buf.append(fName);
-                if (lineNum >= 0) {
-                    buf.append(':');
-                    buf.append(lineNum);
-                }
-                buf.append(')');
-            }
-        }
-        return buf.toString();
-    }
-}
+/* Copyright 2002, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed 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.
+ */
+
+/*[INCLUDE-IF mJava14]*/
+
+package java.lang;
+
+import java.io.Serializable;
+
+/**
+ * An implementation of this class is provided, but the documented constructor
+ * can be used by the VM specific implementation to create instances.
+ * 
+ * StackTraceElement represents a stack frame.
+ * 
+ * @see Throwable#getStackTrace()
+ * @since 1.4
+ */
+public final class StackTraceElement implements Serializable {
+
+    private static final long serialVersionUID = 6992337162326171013L;
+
+    String declaringClass;
+
+    String methodName;
+
+    String fileName;
+
+    int lineNumber;
+
+    /**
+     * <p>
+     * Constructs a <code>StackTraceElement</code> for an execution point.
+     * </p>
+     * 
+     * @param cls The fully qualified name of the class where execution is at.
+     * @param method The name of the method where execution is at.
+     * @param file The name of the file where execution is at or
+     *        <code>null</code>.
+     * @param line The line of the file where execution is at, a negative number
+     *        if unknown or <code>-2</code> if the execution is in a native
+     *        method.
+     * 
+     * @throws NullPointerException if <code>cls</code> or <code>method</code>
+     *         is <code>null</code>.
+     * 
+     * @since 1.5
+     */
+    public StackTraceElement(String cls, String method, String file, int line) {
+        super();
+        if (cls == null || method == null) {
+            throw new NullPointerException();
+        }
+        declaringClass = cls;
+        methodName = method;
+        fileName = file;
+        lineNumber = line;
+    }
+
+    /**
+     * <p>
+     * Private, nullary constructor for VM use only.
+     * </p>
+     */
+    private StackTraceElement() {
+        super();
+    }
+
+    /**
+     * Compare this object with the object passed in
+     * 
+     * @param obj Object to compare with
+     */
+    @Override
+    public boolean equals(Object obj) {
+        if (!(obj instanceof StackTraceElement)) {
+            return false;
+        }
+        StackTraceElement castObj = (StackTraceElement) obj;
+
+        /*
+         * Unknown methods are never equal to anything (not strictly to spec,
+         * but spec does not allow null method/class names)
+         */
+        if ((methodName == null) || (castObj.methodName == null)) {
+            return false;
+        }
+
+        if (!getMethodName().equals(castObj.getMethodName())) {
+            return false;
+        }
+        if (!getClassName().equals(castObj.getClassName())) {
+            return false;
+        }
+        String localFileName = getFileName();
+        if (localFileName == null) {
+            if (castObj.getFileName() != null) {
+                return false;
+            }
+        } else {
+            if (!localFileName.equals(castObj.getFileName())) {
+                return false;
+            }
+        }
+        if (getLineNumber() != castObj.getLineNumber()) {
+            return false;
+        }
+
+        return true;
+    }
+
+    /**
+     * Returns the full name (i.e. including the package) of the class where
+     * this stack trace element is executing.
+     * 
+     * @return the fully qualified type name of the class where this stack trace
+     *         element is executing.
+     */
+    public String getClassName() {
+        return (declaringClass == null) ? "<unknown class>" : declaringClass;
+    }
+
+    /**
+     * If available, returns the name of the file containing the Java code
+     * source which was compiled into the class where this stack trace element
+     * is executing.
+     * 
+     * @return if available, the name of the file containing the Java code
+     *         source for the stack trace element's executing class. If no such
+     *         detail is available, a <code>null</code> value is returned.
+     */
+    public String getFileName() {
+        return fileName;
+    }
+
+    /**
+     * If available, returns the line number in the source for the class where
+     * this stack trace element is executing.
+     * 
+     * @return if available, the line number in the source file for the class
+     *         where this stack trace element is executing. If no such detail is
+     *         available, a number less than <code>0</code>.
+     */
+    public int getLineNumber() {
+        return lineNumber;
+    }
+
+    /**
+     * Returns the name of the method where this stack trace element is
+     * executing.
+     * 
+     * @return the name of the method where this stack trace element is
+     *         executing.
+     */
+    public String getMethodName() {
+        return (methodName == null) ? "<unknown method>" : methodName;
+    }
+
+    /**
+     * Return this StackTraceElement objects hash code
+     * 
+     * @return This objects hash code
+     */
+    @Override
+    public int hashCode() {
+        /*
+         * Either both methodName and declaringClass are null, or neither are
+         * null.
+         */
+        if (methodName == null) {
+            // all unknown methods hash the same
+            return 0;
+        }
+        // declaringClass never null if methodName is non-null
+        return methodName.hashCode() ^ declaringClass.hashCode();
+    }
+
+    /**
+     * Returns <code>true</code> if the method name returned by
+     * {@link #getMethodName()} is implemented as a native method.
+     * 
+     * @return if the method in which this stack trace element is executing is a
+     *         native method
+     */
+    public boolean isNativeMethod() {
+        return lineNumber == -2;
+    }
+
+    /**
+     * Return a String representating this StackTraceElement object
+     * 
+     * @return String representing this object
+     */
+    @Override
+    public String toString() {
+        StringBuilder buf = new StringBuilder(80);
+
+        buf.append(getClassName());
+        buf.append('.');
+        buf.append(getMethodName());
+
+        if (isNativeMethod()) {
+            buf.append("(Native Method)");
+        } else {
+            String fName = getFileName();
+
+            if (fName == null) {
+                buf.append("(Unknown Source)");
+            } else {
+                int lineNum = getLineNumber();
+
+                buf.append('(');
+                buf.append(fName);
+                if (lineNum >= 0) {
+                    buf.append(':');
+                    buf.append(lineNum);
+                }
+                buf.append(')');
+            }
+        }
+        return buf.toString();
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/luni-kernel/src/main/java/java/lang/StackTraceElement.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message