harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r986497 [4/4] - in /harmony/enhanced/java/branches/mrh: ./ classlib/ classlib/depends/build/platform/ classlib/depends/manifests/xalan-j_2.7.0/ classlib/depends/manifests/xerces_2.10.0/ classlib/make/ classlib/modules/archive/src/main/nativ...
Date Tue, 17 Aug 2010 21:36:14 GMT
Modified: harmony/enhanced/java/branches/mrh/classlib/modules/swing/src/test/api/java.injected/javax/swing/text/html/FormViewTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/swing/src/test/api/java.injected/javax/swing/text/html/FormViewTest.java?rev=986497&r1=986496&r2=986497&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/swing/src/test/api/java.injected/javax/swing/text/html/FormViewTest.java (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/swing/src/test/api/java.injected/javax/swing/text/html/FormViewTest.java Tue Aug 17 21:36:10 2010
@@ -62,6 +62,8 @@ public class FormViewTest extends SwingT
     private Element elem;
 
     private FormView formView;
+    
+    private boolean dataSubmitted = false;
 
     protected void setUp() throws Exception {
         super.setUp();
@@ -695,7 +697,7 @@ public class FormViewTest extends SwingT
             }
 
             protected void submitData(String data) {
-                super.submitData(data);
+                dataSubmitted = true;
             }
         };
         component = formView.createComponent();
@@ -706,7 +708,8 @@ public class FormViewTest extends SwingT
         };
         panel.add(component);
         ((JButton) component).doClick();
-        
+        assertTrue(dataSubmitted);
+        dataSubmitted = false;
         throw new UnsupportedOperationException("Not implemented");
     }
 

Copied: harmony/enhanced/java/branches/mrh/classlib/modules/xml/build.xml (from r986356, harmony/enhanced/java/trunk/classlib/modules/xml/build.xml)
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/xml/build.xml?p2=harmony/enhanced/java/branches/mrh/classlib/modules/xml/build.xml&p1=harmony/enhanced/java/trunk/classlib/modules/xml/build.xml&r1=986356&r2=986497&rev=986497&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/xml/build.xml (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/xml/build.xml Tue Aug 17 21:36:10 2010
@@ -21,10 +21,10 @@
 <project name="XML Build" default="build" basedir=".">
     <description>Build for XML component</description>
 
+    <property name="hy.component" value="classlib" />
     <property name="hy.module" value="xml" />
-    <property name="hy.hdk" location="${basedir}/../../deploy" />
-    <property name="depends.dir" location="${basedir}/../../depends" />
-    <import file="${hy.hdk}/build/ant/properties.xml" />
+    <property name="hy.target" location="${basedir}/../../target" />
+    <import file="${hy.target}/hdk/build/ant/properties.xml" />
     <import file="${hy.hdk}/build/ant/depends.xml" />
 
     <target name="build" depends="check-depends"/>

Propchange: harmony/enhanced/java/branches/mrh/common_resources/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Aug 17 21:36:10 2010
@@ -1,4 +1,4 @@
 /harmony/enhanced/java/branches/mrh/common_resources:935751
-/harmony/enhanced/java/trunk/common_resources:935751-964765,964786
+/harmony/enhanced/java/trunk/common_resources:935751-986356
 /harmony/enhanced/trunk/common_resources:476395-921782
 /incubator/harmony/enhanced/trunk/common_resources:292550-476394

Modified: harmony/enhanced/java/branches/mrh/common_resources/make/properties.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/common_resources/make/properties.xml?rev=986497&r1=986496&r2=986497&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/common_resources/make/properties.xml (original)
+++ harmony/enhanced/java/branches/mrh/common_resources/make/properties.xml Tue Aug 17 21:36:10 2010
@@ -224,6 +224,7 @@
         <propertyref name="svn.info" />
         <propertyref name="hy.no.thr" />
         <propertyref name="hy.zip.api" />
+        <propertyref name="hy.select" />
     </propertyset>
 
     <target name="echo" depends="-svn-info, test-jre-vm-info"

Propchange: harmony/enhanced/java/branches/mrh/drlvm/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Aug 17 21:36:10 2010
@@ -1,5 +1,5 @@
 /harmony/enhanced/java/branches/mrh/drlvm:935751
-/harmony/enhanced/java/trunk/drlvm:935751-964765,964786
+/harmony/enhanced/java/trunk/drlvm:935751-986356
 /harmony/enhanced/trunk/drlvm:476395-926313
 /harmony/enhanced/trunk/working_vm:476396-920147
 /incubator/harmony/enhanced/trunk/working_vm:423974-476394

Modified: harmony/enhanced/java/branches/mrh/drlvm/modules/vm/src/main/native/vmcore/shared/x86/lil/m2n.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/drlvm/modules/vm/src/main/native/vmcore/shared/x86/lil/m2n.cpp?rev=986497&r1=986496&r2=986497&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/drlvm/modules/vm/src/main/native/vmcore/shared/x86/lil/m2n.cpp (original)
+++ harmony/enhanced/java/branches/mrh/drlvm/modules/vm/src/main/native/vmcore/shared/x86/lil/m2n.cpp Tue Aug 17 21:36:10 2010
@@ -164,7 +164,7 @@ U_32* m2n_get_args(M2nFrame* m2nf)
 
 unsigned m2n_ts_to_register_size()
 {
-    return 22;
+    return 22 + 2;
 }
 
 char* m2n_gen_ts_to_register(char* buf, R_Opnd* reg)

Modified: harmony/enhanced/java/branches/mrh/drlvm/modules/vm/src/main/native/vmcore/shared/x86/thread/thread_helpers.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/drlvm/modules/vm/src/main/native/vmcore/shared/x86/thread/thread_helpers.cpp?rev=986497&r1=986496&r2=986497&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/drlvm/modules/vm/src/main/native/vmcore/shared/x86/thread/thread_helpers.cpp (original)
+++ harmony/enhanced/java/branches/mrh/drlvm/modules/vm/src/main/native/vmcore/shared/x86/thread/thread_helpers.cpp Tue Aug 17 21:36:10 2010
@@ -65,7 +65,9 @@ char* gen_hythread_self_helper(char *ss)
         ss = mov(ss,  eax_opnd,  M_Base_Opnd(eax_reg, offset));
 #   endif
 #else
+    ss = push(ss, ecx_opnd); // Preserve caller-saved ECX
     ss = call(ss, (char *)hythread_self);
+    ss = pop (ss, ecx_opnd);
 #endif
     return ss;
 }
@@ -204,7 +206,7 @@ char* gen_monitorenter_slow_path_helper(
   *  @param[in] ss buffer to put the assembly code to
   *  @param[in] input_param1 register should point to the lockword in object header.
   *  If input_param1 == ecx it reduce one register mov.
-  *  The code use and do not restore eax registers.
+  *  The code use and do not restore eax, ecx registers.
   *  @return 0 if success in eax register
   */
 char* gen_monitor_exit_helper(char *ss, const R_Opnd & input_param1) {
@@ -280,7 +282,7 @@ fast_tls_func* get_tls_helper(hythread_t
     unsigned key_offset =
         (unsigned) &(((HyThread_public *) (0))->thread_local_storage[key]);
 
-    const int stub_size = 126;
+    const int stub_size = 128;
     char *stub = (char *)malloc(stub_size);
     memset(stub, 0xcc /*int 3*/, stub_size);
 

Modified: harmony/enhanced/java/branches/mrh/drlvm/modules/vm/src/main/native/vmcore/shared/x86/util/jit_lock_rt_support.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/drlvm/modules/vm/src/main/native/vmcore/shared/x86/util/jit_lock_rt_support.cpp?rev=986497&r1=986496&r2=986497&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/drlvm/modules/vm/src/main/native/vmcore/shared/x86/util/jit_lock_rt_support.cpp (original)
+++ harmony/enhanced/java/branches/mrh/drlvm/modules/vm/src/main/native/vmcore/shared/x86/util/jit_lock_rt_support.cpp Tue Aug 17 21:36:10 2010
@@ -169,7 +169,7 @@ void * getaddress__vm_monitor_enter_nake
         return addr;
     }
 
-    const int stub_size = 226;
+    const int stub_size = 228;
     char *stub = (char *)malloc_fixed_code_for_jit(stub_size, DEFAULT_CODE_ALIGNMENT, CODE_BLOCK_HEAT_MAX/2, CAA_Allocate);
 #ifdef _DEBUG
     memset(stub, 0xcc /*int 3*/, stub_size);

Modified: harmony/enhanced/java/branches/mrh/drlvm/modules/vm/src/main/native/vmcore/shared/x86/util/jit_runtime_support.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/drlvm/modules/vm/src/main/native/vmcore/shared/x86/util/jit_runtime_support.cpp?rev=986497&r1=986496&r2=986497&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/drlvm/modules/vm/src/main/native/vmcore/shared/x86/util/jit_runtime_support.cpp (original)
+++ harmony/enhanced/java/branches/mrh/drlvm/modules/vm/src/main/native/vmcore/shared/x86/util/jit_runtime_support.cpp Tue Aug 17 21:36:10 2010
@@ -301,7 +301,7 @@ static void *getaddress__vm_initialize_c
 
 static void *generate_object_allocation_stub_with_thread_pointer(char *fast_obj_alloc_proc,
                                                                  char *slow_obj_alloc_proc,
-                                                                 char *stub_name)
+                                                                 const char *stub_name)
 {
     const int stub_size = 52+26;
     char *stub = (char *)malloc_fixed_code_for_jit(stub_size, DEFAULT_CODE_ALIGNMENT, CODE_BLOCK_HEAT_MAX/2, CAA_Allocate);
@@ -617,7 +617,7 @@ static void *getaddress__vm_aastore()
 
 
 
-static void * gen_new_vector_stub(char *stub_name, char *fast_new_vector_proc, char *slow_new_vector_proc)
+static void * gen_new_vector_stub(const char *stub_name, char *fast_new_vector_proc, char *slow_new_vector_proc)
 {
     const int stub_size = 52;
     char *stub = (char *)malloc_fixed_code_for_jit(stub_size, DEFAULT_CODE_ALIGNMENT, CODE_BLOCK_HEAT_MAX/2, CAA_Allocate);

Modified: harmony/enhanced/java/branches/mrh/drlvm/modules/vm/src/main/native/vmcore/unix/kernel_classes/Runtime.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/drlvm/modules/vm/src/main/native/vmcore/unix/kernel_classes/Runtime.cpp?rev=986497&r1=986496&r2=986497&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/drlvm/modules/vm/src/main/native/vmcore/unix/kernel_classes/Runtime.cpp (original)
+++ harmony/enhanced/java/branches/mrh/drlvm/modules/vm/src/main/native/vmcore/unix/kernel_classes/Runtime.cpp Tue Aug 17 21:36:10 2010
@@ -182,11 +182,37 @@ void JNICALL Java_java_lang_Runtime_0002
              }
              free(cmdDir);
          }
-         
+
+         char *newArgv[lenargv+2];
          if (lenEnvp == 0) {
              execvp(argv[0], argv);
+             if (errno == ENOEXEC) {
+               // give another try
+               for (i=0; i<lenargv; i++) {
+                 strCmd = (char *)malloc(1+strlen(argv[i])); // + NUL symbol
+                 *strCmd = '\0';
+                 strcat(strCmd, argv[i]);
+                 newArgv[i+1] = strCmd;
+               }
+               newArgv[0] = strdup("/bin/sh");
+               newArgv[lenargv+1] = (char *)0;
+               execvp(newArgv[0], newArgv);
+             }
          } else {
              execve(argv[0], argv, strEnvpBeginAA);
+             if (errno == ENOEXEC) {
+               // give another try
+               for (i=0; i<lenargv; i++) {
+                 strCmd = (char *)malloc(1+strlen(argv[i])); // + NUL symbol
+                 *strCmd = '\0';
+                 strcat(strCmd, argv[i]);
+                 newArgv[i+1] = strCmd;
+               }
+               newArgv[0] = strdup("/bin/sh");
+               newArgv[lenargv+1] = (char *)0;
+               execve(newArgv[0], newArgv, strEnvpBeginAA);
+             }
+
              if(strchr(argv[0], '/') == NULL) {
                  char* curDir = NULL;
                  char* cmdPath = NULL;
@@ -212,6 +238,11 @@ void JNICALL Java_java_lang_Runtime_0002
          }
          write(fildesInfo[1], &errno, sizeof(int));
          INFO("Process initiation failed: " << strerror(errno));
+         for (i=0; i<lenargv+1; i++) {
+           if (newArgv[i] != NULL) {
+             free(newArgv[i]);
+           }
+         }
          // kill self
          kill(getpid(), 9);
      }
@@ -221,8 +252,18 @@ void JNICALL Java_java_lang_Runtime_0002
      close(fildesI[0]);
      close(fildesE[1]);
      close(fildesInfo[1]);
-     free(cmdDir);
-     free(strCmd);
+
+     for (i=0; i<lenargv; i++) {
+       if (argv[i] != NULL) {
+         free(argv[i]);
+       }
+     }
+
+     for (i=0; i<lenEnvp; i++) {
+       if (strEnvpBeginAA[i] != NULL) {
+         free(strEnvpBeginAA[i]);
+       }
+     }
 
      // get execution status from child
      int errno_child;

Modified: harmony/enhanced/java/branches/mrh/drlvm/vm/vmcore/include/compile.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/drlvm/vm/vmcore/include/compile.h?rev=986497&r1=986496&r2=986497&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/drlvm/vm/vmcore/include/compile.h (original)
+++ harmony/enhanced/java/branches/mrh/drlvm/vm/vmcore/include/compile.h Tue Aug 17 21:36:10 2010
@@ -104,9 +104,9 @@ typedef void (Override_Generator)(Emitte
 typedef unsigned (Override_Size)(Method *);
 
 typedef struct Stub_Override_Entry {
-    char *class_name;
-    char *method_name;
-    char *descriptor;
+    const char *class_name;
+    const char *method_name;
+    const char *descriptor;
     Override_Generator *override_generator;
     Override_Size *override_size;
 } Stub_Override_Entry;

Modified: harmony/enhanced/java/branches/mrh/jdktools/modules/jdktools/build.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/jdktools/modules/jdktools/build.xml?rev=986497&r1=986496&r2=986497&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/jdktools/modules/jdktools/build.xml (original)
+++ harmony/enhanced/java/branches/mrh/jdktools/modules/jdktools/build.xml Tue Aug 17 21:36:10 2010
@@ -169,6 +169,11 @@
         <mkdir dir="${tests.hdk.dir}" />
 
         <copy file="make/run-test.xml" tofile="${tests.hdk.dir}/build.xml" />
+        
+        <copy todir= "${tests.hdk.dir}/resources">
+           <fileset dir = "src/test/resources" />
+        </copy>
+       
 
         <hy.jar.bin destfile="${tests.hdk.dir}/${hy.module}_tests.jar">
             <fileset dir="${hy.build.mod}/test/api" />

Modified: harmony/enhanced/java/branches/mrh/jdktools/modules/jdktools/src/main/java/org/apache/harmony/tools/jar/Main.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/jdktools/modules/jdktools/src/main/java/org/apache/harmony/tools/jar/Main.java?rev=986497&r1=986496&r2=986497&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/jdktools/modules/jdktools/src/main/java/org/apache/harmony/tools/jar/Main.java (original)
+++ harmony/enhanced/java/branches/mrh/jdktools/modules/jdktools/src/main/java/org/apache/harmony/tools/jar/Main.java Tue Aug 17 21:36:10 2010
@@ -128,7 +128,6 @@ public class Main {
             zos = new ZipOutputStream(new FileOutputStream(new File(args[1])));
         }
 
-        String workingDir = System.getProperty("user.dir");
         int firstFileIndex = 0;
         if (manifestFlag) {
             firstFileIndex = 3;
@@ -139,11 +138,11 @@ public class Main {
         // Assume that all the args following the manifest (if provided) are the name of files to add to the archive
         for (int i=firstFileIndex; i < args.length; i++) {
             // attempt to add the file to the output stream
-            File f = new File(workingDir + File.separator + args[i]);
+            File f = new File(args[i]);
             if (f.isDirectory()) {
-                processDir(f, zos, workingDir, verboseFlag);
+                processDir(f, zos, verboseFlag);
             } else {
-                processFile(f, zos, workingDir, verboseFlag);
+                processFile(f, zos, verboseFlag);
             }
         }
         
@@ -197,7 +196,6 @@ public class Main {
 
         // Read the zip entries - format and print their data
         ZipEntry ze;
-        String workingDir = System.getProperty("user.dir");
         
         while ((ze = zis.getNextEntry()) != null) {
             if (ze.isDirectory()) {
@@ -211,7 +209,7 @@ public class Main {
                 }
             } else {
                 // extract the file to the appropriate directory
-                File f = new File(workingDir + File.separator + ze.getName());
+                File f = new File(ze.getName());
                 f.createNewFile();
                 FileOutputStream fos = new FileOutputStream(f);
                 int i;
@@ -288,12 +286,12 @@ public class Main {
         System.out.println("Error: Jar indexing not yet implemented");
     }
     
-    private static void processDir(File dir, ZipOutputStream zos, String workingDir, boolean verboseFlag) throws IOException {	
+    private static void processDir(File dir, ZipOutputStream zos, boolean verboseFlag) throws IOException {
         // First add the dir to the ZipOutputStream
-        String relativePath = dir.getAbsolutePath().substring(workingDir.length() + 1);		
-        ZipEntry zEntry = new ZipEntry(relativePath);
+        String path = dir.getPath().replace('\\', '/') + "/";
+        ZipEntry zEntry = new ZipEntry(path);
         if (verboseFlag) {
-            System.out.println("adding: " + relativePath);
+            System.out.println("adding: " + path);
         }
         zos.putNextEntry(zEntry);
 
@@ -302,22 +300,22 @@ public class Main {
         for (int i=0; i < filesInDir.length; i++) {
             File curFile = filesInDir[i];
             if (curFile.isDirectory()) {
-                processDir(curFile, zos, workingDir, verboseFlag);
+                processDir(curFile, zos, verboseFlag);
             } else {
-                processFile(curFile, zos, workingDir, verboseFlag);
+                processFile(curFile, zos, verboseFlag);
             }
         }
 
         zos.closeEntry();
     }
 
-    private static void processFile(File file, ZipOutputStream zos, String workingDir, boolean verboseFlag) throws IOException {
-        String relativePath = file.getAbsolutePath().substring(workingDir.length() + 1);
+    private static void processFile(File file, ZipOutputStream zos, boolean verboseFlag) throws IOException {
+        String path = file.getPath().replace('\\', '/');
         if (verboseFlag) {
-            System.out.println("adding: " + relativePath);
+            System.out.println("adding: " + path);
         }
 
-        ZipEntry zEntry = new ZipEntry(relativePath);
+        ZipEntry zEntry = new ZipEntry(path);
         zos.putNextEntry(zEntry);
         // now write the data
         FileInputStream fis = new FileInputStream(file);

Modified: harmony/enhanced/java/branches/mrh/jdktools/modules/jdktools/src/main/java/org/apache/harmony/tools/javac/Main.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/jdktools/modules/jdktools/src/main/java/org/apache/harmony/tools/javac/Main.java?rev=986497&r1=986496&r2=986497&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/jdktools/modules/jdktools/src/main/java/org/apache/harmony/tools/javac/Main.java (original)
+++ harmony/enhanced/java/branches/mrh/jdktools/modules/jdktools/src/main/java/org/apache/harmony/tools/javac/Main.java Tue Aug 17 21:36:10 2010
@@ -103,7 +103,7 @@ public final class Main {
         sb.append(File.pathSeparator);
         sb.append(System.getProperty("sun.boot.class.path", ".")); //$NON-NLS-1$ //$NON-NLS-2$
         sb.append(File.pathSeparator);
-        sb.append("."); //$NON-NLS-1$
+        sb.append('.');
         result[args.length + 1] = sb.toString();
         result[args.length + 2] = "-1.5"; //$NON-NLS-1$
         return result;

Modified: harmony/enhanced/java/branches/mrh/jdktools/modules/jdktools/src/main/java/org/apache/harmony/tools/jdb/Main.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/jdktools/modules/jdktools/src/main/java/org/apache/harmony/tools/jdb/Main.java?rev=986497&r1=986496&r2=986497&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/jdktools/modules/jdktools/src/main/java/org/apache/harmony/tools/jdb/Main.java (original)
+++ harmony/enhanced/java/branches/mrh/jdktools/modules/jdktools/src/main/java/org/apache/harmony/tools/jdb/Main.java Tue Aug 17 21:36:10 2010
@@ -17,7 +17,6 @@
 
 package org.apache.harmony.tools.jdb;
 
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -30,38 +29,45 @@ import org.eclipse.jdi.Bootstrap;
 import org.eclipse.jdi.internal.VirtualMachineManagerImpl;
 import org.eclipse.jdi.internal.connect.SocketAttachingConnectorImpl;
 
-import com.sun.jdi.LocalVariable;
 import com.sun.jdi.Location;
+import com.sun.jdi.Method;
 import com.sun.jdi.ReferenceType;
-import com.sun.jdi.StackFrame;
-import com.sun.jdi.StringReference;
 import com.sun.jdi.ThreadReference;
-import com.sun.jdi.Value;
 import com.sun.jdi.VirtualMachine;
 import com.sun.jdi.VirtualMachineManager;
 import com.sun.jdi.connect.Connector;
-import com.sun.jdi.connect.IllegalConnectorArgumentsException;
 import com.sun.jdi.event.BreakpointEvent;
 import com.sun.jdi.event.ClassPrepareEvent;
 import com.sun.jdi.event.Event;
 import com.sun.jdi.event.EventIterator;
 import com.sun.jdi.event.EventQueue;
 import com.sun.jdi.event.EventSet;
-import com.sun.jdi.event.ExceptionEvent;
-import com.sun.jdi.event.LocatableEvent;
+import com.sun.jdi.event.MethodExitEvent;
+import com.sun.jdi.event.StepEvent;
+import com.sun.jdi.event.ThreadStartEvent;
 import com.sun.jdi.event.VMDisconnectEvent;
 import com.sun.jdi.event.VMStartEvent;
 import com.sun.jdi.request.BreakpointRequest;
 import com.sun.jdi.request.ClassPrepareRequest;
 import com.sun.jdi.request.EventRequest;
 import com.sun.jdi.request.EventRequestManager;
-import com.sun.jdi.request.ExceptionRequest;
+import com.sun.jdi.request.MethodExitRequest;
+import com.sun.jdi.request.StepRequest;
+import com.sun.jdi.request.ThreadStartRequest;
 
+/**
+ * The java implementation of Harmony JDB command line tool.
+ */
 public class Main {
 
+    /**
+     * The JDB command enumeration.
+     */
     static enum Command {
         
+        // complete
         CONNECTORS("connectors", "connectors", "") {
+            @Override
             @SuppressWarnings("unchecked")
             final String run(String[] args) {
                 List<Connector> connectors = 
@@ -103,159 +109,318 @@ public class Main {
             }
         },
         
+        // seems complete
         RUN("run", "run [class [args]]", "") {
+            @Override
             final String run(String[] args) {
                 if (jdb.status == Status.CONNECTED) {
-                    jdb.targetVM.resume();
+                    jdb.debuggee.resume();
+                    jdb.status = Status.STARTED;
                 }
-                return "";
+                return EMPTY_MSG;
             }
         },
         
         THREADS("threads", "threads [threadgroup]", "") {
+            @Override
             final String run(String[] args) {
-                StringBuilder sb = new StringBuilder("** command list **\n");
+                if (jdb.status != Status.STARTED) {
+                    return String.format(NOT_VALID_UNTIL_STARTED, "threads");
+                }
+                StringBuilder sb = new StringBuilder("** thread list **\n");
+                // TODO print the thread list
                 return sb.toString();
             }
         },
         
         THREAD("thread", "thread <thread id>", "") {
             final String run(String[] args) {
-                return "";
+                if (jdb.status != Status.STARTED) {
+                    return String.format(NOT_VALID_UNTIL_STARTED, "thread");
+                }
+                // TODO command logic
+                return EMPTY_MSG;
             }
         },
         
         SUSPEND("suspend", "suspend [thread id(s)]", "") {
             final String run(String[] args) {
-                return "";
+                if (jdb.status != Status.STARTED) {
+                    return String.format(NOT_VALID_UNTIL_STARTED, "suspend");
+                }
+                // TODO command logic
+                return EMPTY_MSG;
             }
         },
         
         RESUME("resume", "resume [thread id(s)]", "") {
             final String run(String[] args) {
-                return "";
+                if (jdb.status != Status.STARTED) {
+                    return String.format(NOT_VALID_UNTIL_STARTED, "resume");
+                }
+                // TODO command logic
+                return EMPTY_MSG;
             }
         },
         
         WHERE("where", "where [<thread id> | all]", "") {
             final String run(String[] args) {
-                return "";
+                if (jdb.status != Status.STARTED) {
+                    return String.format(NOT_VALID_UNTIL_STARTED, "where");
+                }
+                // TODO command logic
+                return EMPTY_MSG;
             }
         },
         
         WHEREI("wherei", "wherei [<thread id> | all]", "") {
             final String run(String[] args) {
-                return "";
+                if (jdb.status != Status.STARTED) {
+                    return String.format(NOT_VALID_UNTIL_STARTED, "wherei");
+                }
+                // TODO command logic
+                return EMPTY_MSG;
             }
         },
         
         UP("up", "up [n frames]", "") {
             final String run(String[] args) {
-                return "";
+                if (jdb.status != Status.STARTED) {
+                    return String.format(NOT_VALID_UNTIL_STARTED, "up");
+                }
+                // TODO command logic
+                return EMPTY_MSG;
             }
         },
         
         DOWN("down", "down [n frames]", "") {
             final String run(String[] args) {
-                return "";
+                if (jdb.status != Status.STARTED) {
+                    return String.format(NOT_VALID_UNTIL_STARTED, "down");
+                }
+                // TODO command logic
+                return EMPTY_MSG;
             }
         },
         
         KILL("kill", "kill <thread id> <expr>", "") {
             final String run(String[] args) {
-                return "";
+                if (jdb.status != Status.STARTED) {
+                    return String.format(NOT_VALID_UNTIL_STARTED, "kill");
+                }
+                // TODO command logic
+                return EMPTY_MSG;
             }
         },
         
         INTERRUPT("interrupt", "interrupt <thread id>", "") {
             final String run(String[] args) {
-                return "";
+                if (jdb.status != Status.STARTED) {
+                    return String.format(NOT_VALID_UNTIL_STARTED, "interrupt");
+                }
+                // TODO command logic
+                return EMPTY_MSG;
             }
         },
         
         PRINT("print", "print <expr>", "") {
             final String run(String[] args) {
-                return "";
+                if (jdb.status != Status.STARTED) {
+                    return String.format(NOT_VALID_UNTIL_STARTED, "print");
+                }
+                // TODO command logic
+                return EMPTY_MSG;
             }
         },
         
         DUMP("dump", "dump <expr>", "") {
             final String run(String[] args) {
-                return "";
+                if (jdb.status != Status.STARTED) {
+                    return String.format(NOT_VALID_UNTIL_STARTED, "dump");
+                }
+                // TODO command logic
+                return EMPTY_MSG;
             }
         },
         
         EVAL("eval", "eval <expr>", "") {
             final String run(String[] args) {
-                return "";
+                if (jdb.status != Status.STARTED) {
+                    return String.format(NOT_VALID_UNTIL_STARTED, "eval");
+                }
+                // TODO command logic
+                return EMPTY_MSG;
             }
         },
         
         SET("set", "set <lvalue> = <expr>", "") {
             final String run(String[] args) {
-                return "";
+                if (jdb.status != Status.STARTED) {
+                    return String.format(NOT_VALID_UNTIL_STARTED, "set");
+                }
+                // TODO command logic
+                return EMPTY_MSG;
             }
         },
         
         LOCALS("locals", "locals", "") {
             final String run(String[] args) {
-                return "";
+                if (jdb.status != Status.STARTED) {
+                    return String.format(NOT_VALID_UNTIL_STARTED, "locals");
+                }
+                // TODO command logic
+                return EMPTY_MSG;
             }
         },
         
         CLASSES("classes", "classes", "") {
             final String run(String[] args) {
-                return "";
+                if (jdb.status != Status.STARTED) {
+                    return String.format(NOT_VALID_UNTIL_STARTED, "classes");
+                }
+                // TODO command logic
+                return EMPTY_MSG;
             }
         },
         
         CLASS("class", "class <class id>", "") {
             final String run(String[] args) {
-                return "";
+                if (jdb.status != Status.STARTED) {
+                    return String.format(NOT_VALID_UNTIL_STARTED, "class");
+                }
+                return EMPTY_MSG;
             }
         },
         
         METHODS("methods", "methods <class id>", "") {
             final String run(String[] args) {
-                return "";
+                if (jdb.status != Status.STARTED) {
+                    return String.format(NOT_VALID_UNTIL_STARTED, "methods");
+                }
+                return EMPTY_MSG;
             }
         },
         
         FIELDS("fields", "fields <class id>", "") {
             final String run(String[] args) {
-                return "";
+                if (jdb.status != Status.STARTED) {
+                    return String.format(NOT_VALID_UNTIL_STARTED, "fields");
+                }
+                return EMPTY_MSG;
             }
         },
         
         THREADGROUPS("threadgroups", "threadgroups", "") {
             final String run(String[] args) {
-                return "";
+                if (jdb.status != Status.STARTED) {
+                    return String.format(NOT_VALID_UNTIL_STARTED, "threadgroups");
+                }
+                return EMPTY_MSG;
             }
         },
         
         THREADGROUP("threadgroup", "threadgroup <name>", "") {
             final String run(String[] args) {
-                return "";
+                if (jdb.status != Status.STARTED) {
+                    return String.format(NOT_VALID_UNTIL_STARTED, "threadgroup");
+                }
+                // TODO command logic
+                return EMPTY_MSG;
             }
         },
         
-        STOP_IN("stop", "stop in <class id>.<method>[(argument_type,...)]", "") {
+        // TODO complete, not working well though
+        STOP_IN("stop", "stop in <class id>.<method>[(argument_type,...)]", 
+                "") {
+            @Override
             final boolean match(String[] args) {
                 return super.match(args) && args[1].equals("in");
             }
+            @Override
+            @SuppressWarnings("unchecked")
             final String run(String[] args) {
-                return "";
+                String[] params;
+                try {
+                    params = parseClassMethod(args[2]);
+                } catch (Exception e) {
+                    return usage;
+                }
+                List<ReferenceType> classes = 
+                    jdb.debuggee.classesByName(params[0]);
+                // class not loaded yet
+                if (classes.isEmpty()) {
+                    if (!jdb.deferringMethodBreakpoint.containsKey(params[0])) {
+                        jdb.deferringMethodBreakpoint.put(
+                                params[0], new ArrayList<String>());
+                    }
+                    // method string: "method|argument_type,..."
+                    jdb.deferringMethodBreakpoint.get(
+                            params[0]).add(params[1] + "|" + params[2]);
+                    return String.format(
+                            "Deferring breakpoint %s\n" +
+                            "it will be set after the class is loaded.", 
+                            args[2]);
+                } else {
+                    // Generate the target argument type string list
+                    String[] argTypeNames = params[2].split(",");
+                    // Get all methods of the class
+                    ReferenceType clazz = classes.get(0);
+                    List<Method> methodList = clazz.methodsByName(params[1]);
+                    Method matchedMethod = null;
+                    /*
+                     * As the jdb command argument doesn't supply the result 
+                     * value type, it's impossible to generate a jni signature 
+                     * for the specified method. I just have to search...
+                     */
+                    for (Method m : methodList) {
+                        List<String> types = m.argumentTypeNames();
+                        if (types.size() != argTypeNames.length) {
+                            continue;
+                        } else {
+                            boolean matched = true;
+                            for (int i = 0; i < argTypeNames.length; i++) {
+                                if (!types.get(i).equals(argTypeNames[i])) {
+                                    matched = false;
+                                    break;
+                                }
+                            }
+                            if (matched) {
+                                matchedMethod = m;
+                                break;
+                            }
+                        }
+                    }
+                    if (null != matchedMethod) {
+                        Location loc = matchedMethod.location();
+                        if (null != loc) {
+                            BreakpointRequest breakpointRequest = 
+                                jdb.eventRequestManager.
+                                createBreakpointRequest(loc);
+                            breakpointRequest.setSuspendPolicy(
+                                    EventRequest.SUSPEND_ALL);
+                            breakpointRequest.enable();
+                            jdb.breakpointRegisterMap.put(
+                                    loc.toString(), breakpointRequest);
+                            return String.format("Breakpoint set: " + loc);
+                        }
+                    }
+                }
+                return EMPTY_MSG;
             }
         },
         
+        // TODO complete, working well, need more check
         STOP_AT("stop", "stop at <class id>:<line>", "") {
+            @Override
             final boolean match(String[] args) {
                 return super.match(args) && args[1].equals("at");
             }
+            @Override
+            @SuppressWarnings("unchecked")
             final String run(String[] args) throws Exception {
                 String[] params = args[2].split(":");
                 List<ReferenceType> classes = 
-                    jdb.targetVM.classesByName(params[0]);
+                    jdb.debuggee.classesByName(params[0]);
                 if (classes.isEmpty()) {
                     if (!jdb.deferringLineBreakpoint.containsKey(params[0])) {
                         jdb.deferringLineBreakpoint.put(
@@ -270,68 +435,209 @@ public class Main {
                 } else {
                     List<Location> locations = classes.get(0).
                             locationsOfLine(Integer.parseInt(params[1]));
-                    if (locations.isEmpty()) {
-                        Location location = locations.get(0);
-                        BreakpointRequest breakpointRequest = jdb.eventRequestManager
-                            .createBreakpointRequest(location);
-                        breakpointRequest.setSuspendPolicy(EventRequest.SUSPEND_ALL);
+                    if (!locations.isEmpty()) {
+                        Location loc = locations.get(0);
+                        BreakpointRequest breakpointRequest = 
+                            jdb.eventRequestManager.
+                            createBreakpointRequest(loc);
+                        breakpointRequest.setSuspendPolicy(
+                                EventRequest.SUSPEND_ALL);
                         breakpointRequest.enable();
-                        return String.format("Breakpoint set: " + location);
+                        jdb.breakpointRegisterMap.put(
+                                loc.toString(), breakpointRequest);
+                        return String.format("Breakpoint set: " + loc);
                     } else {
-                        return "";
+                        return EMPTY_MSG;
                     }
                 }
             }
         },
         
+        // TODO complete, not working well though
         CLEAR_METHOD("clear", "clear <class id>.<method>[(argument_type,...)]", "") {
             final boolean match(String[] args) {
-                return false;
+                return args.length >= 2 
+                && args[0].equals(prefix) 
+                && args[1].indexOf(':') == -1
+                && args[1].indexOf('.') != -1;
             }
+            @SuppressWarnings("unchecked")
             final String run(String[] args) {
-                return "";
+                String[] params;
+                boolean isFound = false;
+                try {
+                    params = parseClassMethod(args[1]);
+                } catch (Exception e) {
+                    return usage;
+                }
+                String methodStr = params[1] + "|" + params[2];
+                List<String> methodStrList = 
+                    jdb.deferringMethodBreakpoint.get(params[0]);
+                for (String str : methodStrList) {
+                    if (str.equals(methodStr)) {
+                        methodStrList.remove(str);
+                        isFound = true;
+                        break;
+                    }
+                }
+                if (!isFound) {
+                    List<ReferenceType> classes = 
+                        jdb.debuggee.classesByName(params[0]);
+                    if (!classes.isEmpty()) {
+                        // Generate the target argument type string list
+                        String[] argTypeNames = params[2].split(",");
+                        // Get all methods of the class
+                        ReferenceType clazz = classes.get(0);
+                        List<Method> methodList = clazz.methodsByName(params[1]);
+                        Method matchedMethod = null;
+                        /*
+                         * As the jdb command argument doesn't supply the result 
+                         * value type, it's impossible to generate a jni signature 
+                         * for the specified method. I just have to search...
+                         */
+                        for (Method m : methodList) {
+                            List<String> types = m.argumentTypeNames();
+                            if (types.size() != argTypeNames.length) {
+                                continue;
+                            } else {
+                                boolean matched = true;
+                                for (int i = 0; i < argTypeNames.length; i++) {
+                                    if (!types.get(i).equals(argTypeNames[i])) {
+                                        matched = false;
+                                        break;
+                                    }
+                                }
+                                if (matched) {
+                                    matchedMethod = m;
+                                    break;
+                                }
+                            }
+                        }
+                        if (null != matchedMethod) {
+                            Location loc = matchedMethod.location();
+                            if (null != loc) {
+                                String key = loc.toString();
+                                jdb.breakpointRegisterMap.get(key).disable();
+                                jdb.breakpointRegisterMap.remove(key);
+                                isFound = true;
+                            }
+                        }
+                    }
+                }
+                if (isFound) {
+                    return String.format("Breakpoint cleared: " + args[1]);
+                } else {
+                    return String.format(
+                            "Not found: breakpoint %s", args[1]);
+                }
             }
         },
         
+        // TODO complete, not working well though
         CLEAR_LINE("clear", "clear <class id>:<line>", "") {
             final boolean match(String[] args) {
-                return false;
+                return args.length >= 2 
+                    && args[0].equals(prefix) 
+                    && args[1].indexOf(':') != -1;
             }
-            final String run(String[] args) {
-                return "";
+            @SuppressWarnings("unchecked")
+            final String run(String[] args) throws Exception {
+                String[] params = args[1].split(":");
+                int line = Integer.parseInt(params[1]);
+                boolean isFound = false;
+                List<Integer> lineList = 
+                    jdb.deferringLineBreakpoint.get(params[0]);
+                for (Integer i : lineList) {
+                    if (i.intValue() == line) {
+                        lineList.remove(i);
+                        isFound = true;
+                        break;
+                    }
+                }
+                if (!isFound) {
+                    List<ReferenceType> classes = 
+                        jdb.debuggee.classesByName(params[0]);
+                    if (!classes.isEmpty()) {
+                        List<Location> locations = classes.get(0).
+                                locationsOfLine(line);
+                        if (!locations.isEmpty()) {
+                            Location loc = locations.get(0);
+                            String key = loc.toString();
+                            jdb.breakpointRegisterMap.get(key).disable();
+                            jdb.breakpointRegisterMap.remove(key);
+                            isFound = true;
+                        }
+                    }
+                }
+                if (isFound) {
+                    return String.format("Breakpoint cleared: " + args[1]);
+                } else {
+                    return String.format(
+                            "Not found: breakpoint %s", args[1]);
+                }
             }
         },
         
         CLEAR("clear", "clear", "") {
             final boolean match(String[] args) {
-                return false;
+                return args.length == 1 && args[0].equals(prefix);
             }
+            @SuppressWarnings("unchecked")
             final String run(String[] args) {
-                return "";
+                /*
+                 * TODO have not include deferred breakpoints yet
+                 */
+                List<BreakpointRequest> list = 
+                    jdb.eventRequestManager.breakpointRequests();
+                if (list.size() == 0) {
+                    return "No breakpoints set.";
+                } else {
+                    StringBuilder sb = new StringBuilder();
+                    for (BreakpointRequest request : list) {
+                        sb.append(request.location() + "\n");
+                    }
+                    return sb.toString();
+                }
             }
         },
         
         CATCH("catch", "catch [uncaught|caught|all]", "") {
             final String run(String[] args) {
-                return "";
+                if (jdb.status != Status.STARTED) {
+                    return String.format(NOT_VALID_UNTIL_STARTED, "catch");
+                }
+                // TODO command logic
+                return EMPTY_MSG;
             }
         },
         
         IGNORE("ignore", "ignore [uncaught|caught|all]", "") {
             final String run(String[] args) {
-                return "";
+                if (jdb.status != Status.STARTED) {
+                    return String.format(NOT_VALID_UNTIL_STARTED, "ignore");
+                }
+                // TODO command logic
+                return EMPTY_MSG;
             }
         },
         
         WATCH("watch", "watch [access|all] <class id>.<field name>", "") {
             final String run(String[] args) {
-                return "";
+                if (jdb.status != Status.STARTED) {
+                    return String.format(NOT_VALID_UNTIL_STARTED, "watch");
+                }
+                // TODO command logic
+                return EMPTY_MSG;
             }
         },
         
         UNWATCH("unwatch", "unwatch [access|all] <class id>.<field name>", "") {
             final String run(String[] args) {
-                return "";
+                if (jdb.status != Status.STARTED) {
+                    return String.format(NOT_VALID_UNTIL_STARTED, "unwatch");
+                }
+                // TODO command logic
+                return EMPTY_MSG;
             }
         },
         
@@ -345,7 +651,11 @@ public class Main {
                 }
             }
             final String run(String[] args) {
-                return "";
+                if (jdb.status != Status.STARTED) {
+                    return String.format(NOT_VALID_UNTIL_STARTED, "trace");
+                }
+                // TODO command logic
+                return EMPTY_MSG;
             }
         },
         
@@ -354,16 +664,25 @@ public class Main {
                 return false;
             }
             final String run(String[] args) {
-                return "";
+                if (jdb.status != Status.STARTED) {
+                    return String.format(NOT_VALID_UNTIL_STARTED, "trace");
+                }
+                // TODO command logic
+                return EMPTY_MSG;
             }
         },
         
         UNTRACE("untrace", "untrace [methods]", "") {
             final String run(String[] args) {
-                return "";
+                if (jdb.status != Status.STARTED) {
+                    return String.format(NOT_VALID_UNTIL_STARTED, "untrace");
+                }
+                // TODO command logic
+                return EMPTY_MSG;
             }
         },
         
+        // TODO complete, not working well though
         STEP("step", "step", "") {
             final boolean match(String[] args) {
                 if (args[0].equals(prefix) && 
@@ -374,10 +693,20 @@ public class Main {
                 }
             }
             final String run(String[] args) {
-                return "";
+                if (jdb.status != Status.STARTED) {
+                    return String.format(NOT_VALID_UNTIL_STARTED, "step");
+                }
+                StepRequest request = 
+                    jdb.eventRequestManager.createStepRequest(jdb.thread, 
+                            StepRequest.STEP_LINE, 
+                            StepRequest.STEP_INTO);
+                request.addCountFilter(1);// next step only
+                request.enable();
+                return "Step one line.";
             }
         },
         
+        // TODO complete, not working well though
         STEP_UP("step", "step up", "") {
             final boolean match(String[] args) {
                 if (args[0].equals(prefix) && 
@@ -388,28 +717,67 @@ public class Main {
                 }
             }
             final String run(String[] args) {
-                return "";
+                if (jdb.status != Status.STARTED) {
+                    return String.format(NOT_VALID_UNTIL_STARTED, "step up");
+                }
+                MethodExitRequest request = 
+                    jdb.eventRequestManager.createMethodExitRequest();
+                request.addThreadFilter(jdb.thread);
+                request.addCountFilter(1);
+                request.enable();
+                return "Step up to the caller.";
             }
         },
         
+        // TODO complete, not working well though
         STEPI("stepi", "stepi", "") {
             final String run(String[] args) {
-                return "";
+                if (jdb.status != Status.STARTED) {
+                    return String.format(NOT_VALID_UNTIL_STARTED, "stepi");
+                }
+                StepRequest request = 
+                    jdb.eventRequestManager.createStepRequest(jdb.thread, 
+                            StepRequest.STEP_MIN, 
+                            StepRequest.STEP_INTO);
+                request.addCountFilter(1);// next step only
+                request.enable();
+                return "Step one instruction.";
             }
         },
         
+        // TODO complete, not working well though
         NEXT("next", "next", "") {
             final String run(String[] args) {
-                return "";
+                if (jdb.status != Status.STARTED) {
+                    return String.format(NOT_VALID_UNTIL_STARTED, "next");
+                }
+                StepRequest request = 
+                    jdb.eventRequestManager.createStepRequest(jdb.thread, 
+                            StepRequest.STEP_LINE, 
+                            StepRequest.STEP_OVER);
+                request.addCountFilter(1);// next step only
+                request.enable();
+                return "Step one line (over calls)";
             }
         },
         
+        // TODO, complete, working well, need more check
         CONT("cont", "cont", "") {
+            final String run(String[] args) {
+                if (jdb.status != Status.STARTED) {
+                    return String.format(NOT_VALID_UNTIL_STARTED, "cont");
+                }
+                return EMPTY_MSG;
+            }
         },
         
         LIST("list", "list [line number|method]", "") {
             final String run(String[] args) {
-                return "";
+                if (jdb.status != Status.STARTED) {
+                    return String.format(NOT_VALID_UNTIL_STARTED, "list");
+                }
+                // TODO command logic
+                return EMPTY_MSG;
             }
         },
         
@@ -422,99 +790,145 @@ public class Main {
                 }
             }
             final String run(String[] args) {
-                return "";
+                // TODO command logic
+                return EMPTY_MSG;
             }
         },
         
         EXCLUDE("exclude", "exclude [<class pattern>, ... | \"none\"]", "") {
             final String run(String[] args) {
-                return "";
+                // TODO command logic
+                return EMPTY_MSG;
             }
         },
         
         CLASSPATH("classpath", "classpath", "") {
             final String run(String[] args) {
-                return "";
+                // TODO command logic
+                return EMPTY_MSG;
             }
         },
         
-        MONITOR_CMD("monitoer", "monitor <command>", "") {
+        MONITOR_CMD("monitor", "monitor <command>", "") {
             final boolean match(String[] args) {
                 return false;
             }
             final String run(String[] args) {
-                return "";
+                if (jdb.status != Status.STARTED) {
+                    return String.format(NOT_VALID_UNTIL_STARTED, "monitor");
+                }
+                // TODO command logic
+                return EMPTY_MSG;
             }
         },
         
-        MONITOR("monitoer", "monitor", "") {
+        MONITOR("monitor", "monitor", "") {
             final boolean match(String[] args) {
                 return false;
             }
             final String run(String[] args) {
-                return "";
+                if (jdb.status != Status.STARTED) {
+                    return String.format(NOT_VALID_UNTIL_STARTED, "monitor");
+                }
+                // TODO command logic
+                return EMPTY_MSG;
             }
         },
         
         UNMONITOR("unmonitor", "unmonitor <monitor#>", "") {
             final String run(String[] args) {
-                return "";
+                if (jdb.status != Status.STARTED) {
+                    return String.format(NOT_VALID_UNTIL_STARTED, "unmonitor");
+                }
+                // TODO command logic
+                return EMPTY_MSG;
             }
         },
         
         READ("read", "read <filename>", "") {
             final String run(String[] args) {
-                return "";
+                if (jdb.status != Status.STARTED) {
+                    return String.format(NOT_VALID_UNTIL_STARTED, "read");
+                }
+                // TODO command logic
+                return EMPTY_MSG;
             }
         },
         
         LOCK("lock", "lock <expr>", "") {
             final String run(String[] args) {
-                return "";
+                if (jdb.status != Status.STARTED) {
+                    return String.format(NOT_VALID_UNTIL_STARTED, "lock");
+                }
+                // TODO command logic
+                return EMPTY_MSG;
             }
         },
         
         THREADLOCKS("threadlocks", "threadlocks [thread id]", "") {
             final String run(String[] args) {
-                return "";
+                if (jdb.status != Status.STARTED) {
+                    return String.format(NOT_VALID_UNTIL_STARTED, "threadlocks");
+                }
+                // TODO command logic
+                return EMPTY_MSG;
             }
         },
         
         POP("pop", "pop", "") {
             final String run(String[] args) {
-                return "";
+                if (jdb.status != Status.STARTED) {
+                    return String.format(NOT_VALID_UNTIL_STARTED, "pop");
+                }
+                // TODO command logic
+                return EMPTY_MSG;
             }
         },
         
         REENTER("reenter", "reenter", "") {
             final String run(String[] args) {
-                return "";
+                if (jdb.status != Status.STARTED) {
+                    return String.format(NOT_VALID_UNTIL_STARTED, "reenter");
+                }
+                // TODO command logic
+                return EMPTY_MSG;
             }
         },
         
         REDEFINE("redefine", "redefine <class id> <class file name>", "") {
             final String run(String[] args) {
-                return "";
+                if (jdb.status != Status.STARTED) {
+                    return String.format(NOT_VALID_UNTIL_STARTED, "redefine");
+                }
+                // TODO command logic
+                return EMPTY_MSG;
             }
         },
         
         DISABLEGC("disablegc", "disablegc <expr>", "") {
             final String run(String[] args) {
-                return "";
+                if (jdb.status != Status.STARTED) {
+                    return String.format(NOT_VALID_UNTIL_STARTED, "disablegc");
+                }
+                // TODO command logic
+                return EMPTY_MSG;
             }
         },
         
         ENABLEGC("enablegc", "enablegc <expr>", "") {
             final String run(String[] args) {
-                return "";
+                if (jdb.status != Status.STARTED) {
+                    return String.format(NOT_VALID_UNTIL_STARTED, "enablegc");
+                }
+                // TODO command logic
+                return EMPTY_MSG;
             }
         },
         
         REPEAT("!!", "!!", "") {
-            Command lastCmd = null;
-            String[] lastArgs = null;
             final String run(String[] args) {
-                return "";
+                // TODO command logic
+                return EMPTY_MSG;
             }
         },
         
@@ -528,13 +942,14 @@ public class Main {
             }
             final String run(String[] args) {
                 StringBuilder sb = new StringBuilder("** command list **\n");
+                // TODO build the info string
                 return sb.toString();
             }
         },
         
         VERSION("version", "version", "") {
             final String run(String[] args) {
-                return "";
+                return VERSION_STR;
             }
         },
         
@@ -546,20 +961,28 @@ public class Main {
                     return false;
                 }
             }
+            final String run(String[] args) {
+                return EMPTY_MSG;
+            }
         },
         
+        // Returned by the search method when no real command is matched
         NONCMD("", "" ,"") {
             final String run(String[] args) {
                 return String.format("Unsupported command: '%s'.", args[0]);
             }
         };
         
+        // Expected command prefix
         final String usage;
         
+        // Command format and options
         final String comment;
         
+        // Help information of the command
         final String prefix;
         
+        // Iterate the command list and match the args against them
         static final Command search(final String[] args) {
             for (Command cmd : Command.values()) {
                 if (cmd != NONCMD && cmd.match(args)) {
@@ -569,12 +992,48 @@ public class Main {
             return NONCMD;
         }
         
+        // parse the "<class id>.<method>[(argument_type,...)]" string
+        static final String[] parseClassMethod(String str) {
+            String[] params = new String[3];
+            int argumentStart = str.indexOf('(');
+            if (argumentStart == -1) {
+                // class id
+                params[0] = str.substring(
+                        0, str.lastIndexOf('.'));
+                // method name
+                params[1] = str.substring(
+                        str.lastIndexOf('.') + 1);
+                // empty argument type list
+                params[2] = "";
+            } else {
+                String classMethod = str.substring(argumentStart);
+                // class id
+                params[0] = classMethod.substring(
+                        0, classMethod.lastIndexOf('.'));
+                // method name
+                params[1] = classMethod.substring(
+                        classMethod.lastIndexOf('.') + 1);
+                // argument type list
+                params[2] = str.substring(
+                        argumentStart + 1, str.length() - 1);
+            }
+            return params;
+        }
+        
+        /*
+         * Generally, a command matching only needs to compare its prefix, 
+         * override it in enum instance if necessary.
+         */
         boolean match(String[] args) {
             return args[0].equals(prefix);
         }
         
+        /*
+         * The default command running output is do nothing and return an empty 
+         * string, override it in enum instance if necessary.
+         */
         String run(String[] args) throws Exception {
-            return "";
+            return EMPTY_MSG;
         }
         
         Command(String prefix, String usage, String comment) {
@@ -585,19 +1044,42 @@ public class Main {
         
     }
     
+    // TODO not decided how many statuses needed yet
     static enum Status {
-        UNDEFINED, NO_VM_CONNECTED, CONNECTED
+        UNDEFINED, NO_VM_CONNECTED, CONNECTED, STARTED
     }
     
+    // The default prompt
     private static final String PROMPT = "> ";
     
-    private static Main jdb = new Main();
+    /*
+     * The empty message indicates there's no information coming out with 
+     * the command result
+     */
+    private static final String EMPTY_MSG = "";
+    
+    // The jdb version information
+    private static final String VERSION_STR = 
+        "This is jdb version 1.6 <Apache Harmony 6>";
+    
+    /*
+     * The string indicates that a command is not valid until the VM is started 
+     * with the 'run' command.
+     */
+    private static final String NOT_VALID_UNTIL_STARTED = 
+        "Command '%s' is not valid until " +
+        "the VM is started with the 'run' command";
+    
+    // The singleton instance of jdb
+    private static final Main jdb = new Main();
     
     private boolean isExit = false;
     
+    // The debuggee status
     private Status status = Status.UNDEFINED;
     
-    private VirtualMachineManager virturalMachineManager = Bootstrap.virtualMachineManager();
+    private VirtualMachineManager virturalMachineManager = 
+        Bootstrap.virtualMachineManager();
     
     private EventRequestManager eventRequestManager = null;
     
@@ -605,11 +1087,13 @@ public class Main {
     
     private EventSet eventSet = null;
     
-    private VirtualMachine targetVM = null;
+    private VirtualMachine debuggee = null;
     
-    private Process VMProcess = null;
+    //private Process VMProcess = null;
+    // Current thread
+    private ThreadReference thread = null;
     
-    private String mainClass = null;
+    //private String mainClass = null;
     
     private HashMap<String, List<Integer>> deferringLineBreakpoint = 
                 new HashMap<String, List<Integer>>();
@@ -617,6 +1101,16 @@ public class Main {
     private HashMap<String, List<String>> deferringMethodBreakpoint = 
                 new HashMap<String, List<String>>();
     
+    /* 
+     * A map that stores references to all breakpoints(not include the deferred 
+     * ones). The key of the map is a string indicate the location of the 
+     * breakpoint. The map is used by those commands that will clear some 
+     * breakpoint in certain location.
+     */
+    private HashMap<String, BreakpointRequest> breakpointRegisterMap = 
+                new HashMap<String, BreakpointRequest>();
+    
+    // TODO currentPrompt is prompt that indicate current context(fixed for now)
     private String currentPrompt = PROMPT;
     
     private Main() {}
@@ -626,36 +1120,50 @@ public class Main {
      *  and corresponding parameter, then launch jdb and get ready to process 
      *  commands.
      */
+    @SuppressWarnings("unchecked")
     private void init(String[] args) throws Exception {
+        /*
+         * TODO As currently jdb just supports "jdb -attach [port]" command, 
+         * more work to do to parse the jdb launching command option
+         */
         if (args.length >= 2 && args[0].equals("-attach")) {
-            SocketAttachingConnectorImpl sac = new SocketAttachingConnectorImpl(
-                    (VirtualMachineManagerImpl) Bootstrap.virtualMachineManager());
-
+            SocketAttachingConnectorImpl sac = 
+                new SocketAttachingConnectorImpl(
+                        (VirtualMachineManagerImpl) Bootstrap.
+                        virtualMachineManager());
             Map argMap = sac.defaultArguments();
             Connector.Argument value;
             value = (Connector.Argument) argMap.get("hostname");
             value.setValue("localhost");
             value = (Connector.Argument) argMap.get("port");
             value.setValue(args[1]);
-            targetVM = sac.attach(argMap);
-            VMProcess = targetVM.process();
+            debuggee = sac.attach(argMap);
+            //VMProcess = debuggee.process();
         } else {
             System.out.println("Wrong command option. " +
                     "The jdb currently only support jdb -attach [port].");
             System.exit(0);
         }
         
-        eventRequestManager = targetVM.eventRequestManager();
+        eventRequestManager = debuggee.eventRequestManager();
         
+        // Enable class prepare request for all classes
         ClassPrepareRequest classPrepareRequest 
             = eventRequestManager.createClassPrepareRequest();
         classPrepareRequest.addClassFilter("*");
         classPrepareRequest.setSuspendPolicy(EventRequest.SUSPEND_ALL);
         classPrepareRequest.enable();
+        
+        // Enable thread start request for all threads
+        ThreadStartRequest threadStartRequest 
+            = eventRequestManager.createThreadStartRequest();
+        threadStartRequest.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
+        threadStartRequest.enable();
     }
     
+    // Start the loop
     private void start() throws Exception {
-        eventQueue = targetVM.eventQueue();
+        eventQueue = debuggee.eventQueue();
         while (true) {
             if (isExit == true) {
                 break;
@@ -672,51 +1180,137 @@ public class Main {
         }
     }
     
+    @SuppressWarnings("unchecked")
     private void execute(Event event) throws Exception {
+        /*
+         * The variable indicates whether go to command looping after handling 
+         * the current event
+         */
         boolean keepRunning = true;
         if (event instanceof VMStartEvent) {
-            //eventRequestManager = targetVM.eventRequestManager();
-            //ExceptionRequest excReq = 
-                //eventRequestManager.createExceptionRequest(null, false, true);
-            //excReq.setSuspendPolicy(EventRequest.SUSPEND_ALL);
-            //excReq.enable();
-            //System.out.println("Set uncaught java.lang.Throwable");
-            //System.out.println("Set deferred uncaught java.lang.Throwable");
             status = Status.CONNECTED;
             System.out.println("Initializing jdb ...");
             System.out.println(
                     "VM Started: No frames on the current call stack");
-            //currentPrompt = ((VMStartEvent)event).thread().name();
+            // stop after the vm starts
             keepRunning = false;
         }
+        if (event instanceof ThreadStartEvent) {
+            thread = ((ThreadStartEvent) event).thread();
+        }
+        if (event instanceof MethodExitEvent) {
+            // run command step up -> stop
+            keepRunning = false;
+        }
+        if (event instanceof StepEvent) {
+            // run commands step, stepi, or next -> stop
+            keepRunning = false;
+        }
+        /*
+         * after a class is loaded, check whether there are deferred 
+         * breakpoints(both line and method) related to the class; if yes, 
+         * set these breakpoints. The jdb won't stop running.
+         */
         if (event instanceof ClassPrepareEvent) {
-            String className = ((ClassPrepareEvent) event).referenceType().name();
+            // get the class name
+            String className = ((ClassPrepareEvent) 
+                    event).referenceType().name();
+            // set the possible deferred line breakpoints
             List<Integer> lineList = deferringLineBreakpoint.get(className);
             if (lineList != null) {
-                ReferenceType classType = ((ClassPrepareEvent) event).referenceType();
+                ReferenceType classType = ((ClassPrepareEvent) 
+                        event).referenceType();
                 for (Integer line : lineList) {
                     List<Location> locations = classType.locationsOfLine(line);
                     if (!locations.isEmpty()) {
-                        Location location = locations.get(0);
-                        BreakpointRequest breakpointRequest = jdb.eventRequestManager
-                                .createBreakpointRequest(location);
-                        breakpointRequest.setSuspendPolicy(EventRequest.SUSPEND_ALL);
+                        Location loc = locations.get(0);
+                        BreakpointRequest breakpointRequest = 
+                            jdb.eventRequestManager.
+                            createBreakpointRequest(loc);
+                        breakpointRequest.setSuspendPolicy(
+                                EventRequest.SUSPEND_ALL);
                         breakpointRequest.enable();
-                        System.out.println(String.format("Breakpoint set: " + location));
+                        jdb.breakpointRegisterMap.put(
+                                loc.toString(), breakpointRequest);
+                        System.out.println(
+                                String.format("Breakpoint set: " + loc));
+                    }
+                }
+            }
+            // set the possible deferred method breakpoints
+            List<String> methodStrList = deferringMethodBreakpoint.get(className);
+            if (methodStrList != null) {
+                ReferenceType classType = ((ClassPrepareEvent) 
+                        event).referenceType();
+                for (String methodStr : methodStrList) {
+                    String[] params = methodStr.split("|");
+                    // Generate the target argument type string list
+                    String[] argTypeNames;
+                    if (params.length > 1) {
+                        argTypeNames = params[1].split(",");
+                    } else {
+                        argTypeNames = new String[0];
+                    }
+                    // Get all methods of the class
+                    List<Method> methodList = classType.methodsByName(params[0]);
+                    Method matchedMethod = null;
+                    /*
+                     * As the jdb command argument doesn't supply the result 
+                     * value type, it's impossible to generate a jni signature 
+                     * for the specified method. I just have to search...
+                     */
+                    for (Method m : methodList) {
+                        List<String> types = m.argumentTypeNames();
+                        if (types.size() != argTypeNames.length) {
+                            continue;
+                        } else {
+                            boolean matched = true;
+                            for (int i = 0; i < argTypeNames.length; i++) {
+                                if (!types.get(i).equals(argTypeNames[i])) {
+                                    matched = false;
+                                    break;
+                                }
+                            }
+                            if (matched) {
+                                matchedMethod = m;
+                                break;
+                            }
+                        }
+                    }
+                    if (null != matchedMethod) {
+                        Location loc = matchedMethod.location();
+                        if (null != loc) {
+                            BreakpointRequest breakpointRequest = 
+                                jdb.eventRequestManager.
+                                createBreakpointRequest(loc);
+                            breakpointRequest.setSuspendPolicy(
+                                    EventRequest.SUSPEND_ALL);
+                            breakpointRequest.enable();
+                            jdb.breakpointRegisterMap.put(
+                                    loc.toString(), breakpointRequest);
+                            System.out.println(
+                                    String.format("Breakpoint set: " + loc));
+                        }
                     }
                 }
             }
         }
         if (event instanceof BreakpointEvent) {
+            // reach breakpoint and stop
             System.out.println("Reach breakpoint at " + 
                     ((BreakpointEvent) event).location());
             keepRunning = false;
         }
         if (event instanceof VMDisconnectEvent) {
+            // The jdb will end when disconnected from target vm
             System.out.println("Application ends.");
             isExit = true;
         }
         
+        /*
+         * If the event requires the jdb to stop running, the jdb turn to the user 
+         * interaction mode before resuming.
+         */
         if (!keepRunning) {
             Scanner cmdScanner = new Scanner(System.in);
             while (true) {
@@ -729,16 +1323,18 @@ public class Main {
                         isExit = true;
                         break;
                     }
-                    if (cmd == Command.CONT) {
-                        break;
-                    }
                     String result = cmd.run(args);
-                    if (cmd == Command.RUN) {
-                        break;
-                    }
-                    if (!result.equals("")) {
+                    if (!result.equals(EMPTY_MSG)) {
                         System.out.println(result);
                     }
+                    // If the command is one of those execution control
+                    if (cmd == Command.STEP 
+                            || cmd == Command.STEP_UP 
+                            || cmd == Command.STEPI
+                            || cmd == Command.RUN
+                            || cmd == Command.CONT) {
+                        break;
+                    }
                 }
             }
         }
@@ -748,7 +1344,7 @@ public class Main {
         jdb.init(args);
         jdb.start();
         if (jdb.status == Status.CONNECTED) {
-            jdb.targetVM.dispose();
+            jdb.debuggee.dispose();
         }
     }
 

Modified: harmony/enhanced/java/branches/mrh/jdktools/modules/jdktools/src/test/java/org/apache/harmony/tests/tools/javac/MainTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/jdktools/modules/jdktools/src/test/java/org/apache/harmony/tests/tools/javac/MainTest.java?rev=986497&r1=986496&r2=986497&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/jdktools/modules/jdktools/src/test/java/org/apache/harmony/tests/tools/javac/MainTest.java (original)
+++ harmony/enhanced/java/branches/mrh/jdktools/modules/jdktools/src/test/java/org/apache/harmony/tests/tools/javac/MainTest.java Tue Aug 17 21:36:10 2010
@@ -17,22 +17,82 @@
 
 package org.apache.harmony.tests.tools.javac;
 
-import junit.framework.TestCase;
+import java.io.File;
 import java.io.PrintWriter;
 import java.io.StringWriter;
 
-import com.sun.tools.javac.Main;
+import junit.framework.TestCase;
 
-public class MainTest extends TestCase {
+import com.sun.tools.javac.Main;
 
-    public void test_main() throws Exception {
-        StringWriter out = new StringWriter();
-        String testStr = "no_this_test.java";
-        Main.compile(new String[]{testStr}, new PrintWriter(out));
-        assertTrue("The output should have " + testStr, out.toString().contains(testStr));
+public class MainTest extends TestCase {	
+	
+	private static final String RESOURCES = "resources/";
+	
+	/**
+	 * Method that takes in a non-existent file and checks the output for the appropriate Error message
+	 * 
+	 */
+    public void test_nonExists()  {
+        final StringWriter out = new StringWriter();
+        final String testStr = "no_this_test.java";
+        final int rc = Main.compile(new String[]{testStr}, new PrintWriter(out));        
+        assertTrue("The output should have " + testStr, out.toString().contains("missing") && rc == 1);
     }
-
-	public void test_nothing() {
-		// bogus test
-	}
+    
+    /**
+     * Method that takes a valid (A pgm without any errors) file and tests for the proper return code
+     */
+    public void test_exists()
+    {
+    	final StringWriter out = new StringWriter();
+    	final StringWriter err = new StringWriter();
+        	
+    	final String srcFile =  RESOURCES + "Simple.java";
+    	final File f = new File(srcFile);
+    	final String testStr =  f.getAbsolutePath();
+        	
+        final int rc = Main.compile(new String[]{testStr}, new PrintWriter(out), new PrintWriter(err));        
+        assertTrue("The program " + testStr + " should cleanly compile", err.toString().trim().equals("") && rc == 0 );
+    }
+	
+    /**
+     * Method that takes a valid (A program without any errors) file but with unresolved dependencies and tests for the proper return code     
+     */
+    public void test_existsWithUnresolvedDep()
+    {
+    	final StringWriter out = new StringWriter();
+    	final StringWriter err = new StringWriter();
+        
+    	final String srcFile =  RESOURCES + "Sample.java";
+    	final File f = new File(srcFile);
+    	final String testStr =  f.getAbsolutePath();
+    	
+    	final int rc = Main.compile(new String[]{testStr}, new PrintWriter(out), new PrintWriter(err));       
+        assertTrue("The program " + testStr + " shouldn't compile due to unresolved dependencies", err.toString().contains("ERROR") && (rc == 1) );
+    }
+    
+    /**
+     * Method that takes a valid (A program without any errors) file  with Resolved dependencies and tests for the proper return code    
+     */
+    public void test_existsWithResolvedDep()
+    {
+    	final StringWriter out = new StringWriter();
+    	final StringWriter err = new StringWriter();
+    	
+    	final String srcFile =  RESOURCES + "Sample.java";
+    	final File f = new File(srcFile);
+    	final String testStr =  f.getAbsolutePath();
+        
+        final String option1 =  "-classpath" ;
+        
+        final String jarFile =  RESOURCES + "Dependency.jar";
+    	final File f1 = new File(jarFile);
+    	final String option2 =  f1.getAbsolutePath();
+    	
+        final int rc = Main.compile(new String[]{testStr, option1, option2}, new PrintWriter(out), new PrintWriter(err));        
+        assertTrue("The program " + testStr + " should compile as dependency " +  option2 + " is resolved", ! err.toString().contains("ERROR") && (rc == 0) );
+    }  
+	
+	
 }

Modified: harmony/enhanced/java/branches/mrh/jdktools/modules/samsa/build.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/jdktools/modules/samsa/build.xml?rev=986497&r1=986496&r2=986497&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/jdktools/modules/samsa/build.xml (original)
+++ harmony/enhanced/java/branches/mrh/jdktools/modules/samsa/build.xml Tue Aug 17 21:36:10 2010
@@ -73,9 +73,6 @@
         <copy file="${hy.samsa.exe}" tofile="${hy.jdk}/bin/pack200${exe.suffix}" />
         <chmod file="${hy.jdk}/bin/pack200${exe.suffix}" perm="ugo+x" />
 
-        <copy file="${hy.samsa.exe}" tofile="${hy.jdk}/bin/policytool${exe.suffix}" />
-        <chmod file="${hy.jdk}/bin/policytool${exe.suffix}" perm="ugo+x" />
-
         <copy file="${hy.samsa.exe}" tofile="${hy.jdk}/bin/jar${exe.suffix}" />
         <chmod file="${hy.jdk}/bin/jar${exe.suffix}" perm="ugo+x" />
 
@@ -117,6 +114,10 @@
               tofile="${hy.jre}/bin/policytool${exe.suffix}" />
         <chmod file="${hy.jre}/bin/policytool${exe.suffix}" perm="ugo+x" />
 
+        <copy file="${hy.samsa.exe}"
+              tofile="${hy.jdk}/bin/policytool${exe.suffix}" />
+        <chmod file="${hy.jdk}/bin/policytool${exe.suffix}" perm="ugo+x" />
+
     </target>
 
     <!-- copy windows javaw executable -->

Modified: harmony/enhanced/java/branches/mrh/jdktools/modules/samsa/src/main/native/samsa/samsa.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/jdktools/modules/samsa/src/main/native/samsa/samsa.c?rev=986497&r1=986496&r2=986497&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/jdktools/modules/samsa/src/main/native/samsa/samsa.c (original)
+++ harmony/enhanced/java/branches/mrh/jdktools/modules/samsa/src/main/native/samsa/samsa.c Tue Aug 17 21:36:10 2010
@@ -15,10 +15,6 @@
  *  limitations under the License.
  */
 
-#if defined(FREEBSD)
-#include <sys/param.h>
-#endif
-
 #include <stdlib.h>
 #include <stdio.h>
 #include <errno.h>
@@ -83,6 +79,13 @@
 #define EXE_SUFFIX          ""
 #endif
 
+#if defined(ZOS)
+/* zOS does not define PATH_MAX, so just set it to be _POSIX_PATH_MAX */
+#if !defined(PATH_MAX)
+#define PATH_MAX _POSIX_PATH_MAX
+#endif
+#endif
+
 typedef struct ToolData {
     int numJars; 
     char **jarList;
@@ -94,6 +97,9 @@ char     *getRoot(const char*);
 TOOLDATA *getToolData(const char *, const char *, int toolType);
 int getToolType(const char*, const char*);
 char* jarFile(const char*, const char*);
+#if !defined(LINUX) && !defined(FREEBSD) && !defined(WIN32)
+char* findInPath(const char* basename);
+#endif
 
 /**
  *  main
@@ -459,19 +465,48 @@ char *getExeDir(const char* argv0) {
 
     char *last = NULL;
     
-#if defined(WIN32)
+#if defined(LINUX)
+    char buffer[PATH_MAX + 1];
+    
+    int size = readlink ("/proc/self/exe", buffer, sizeof(buffer)-2);
+    
+    buffer[size+1] = '\0';
+#elif defined(FREEBSD)
+    Dl_info info;
+    char buffer[PATH_MAX + 1];
+    if (dladdr( (const void*)&main, &info) == 0) {
+        return NULL;
+    }
+    strncpy(buffer, info.dli_fname, PATH_MAX);
+    buffer[PATH_MAX] = '\0';
+
+#elif defined(WIN32)
     char buffer[512];
     DWORD dwRet = GetModuleFileName(NULL, buffer, 512);
         
     // FIXME - handle this right - it could be that 512 isn't enough
 #else
-    char buffer[PATH_MAX + 1];
-
-    char *rc = realpath(argv0, buffer);
+    char buffer[PATH_MAX+1];
+    char *rc;
+    const char *exename;
+    rc = strchr(argv0, '/');
+    if (rc) {
+        /* is an absolute or relative path so just use that */
+        exename = argv0;
+    } else {
+        /* search in path */
+       exename = findInPath(argv0);
+       if (!exename) {
+           return NULL;
+       }
+    }
+    rc = realpath(exename, buffer);
+    if (exename != argv0) {
+        free((void*)exename);
+    }
     if (!rc) {
-      return NULL;
+        return NULL;
     }
-    buffer[PATH_MAX] = '\0';
 #endif
 
     last = strrchr(buffer, PATH_SEPARATOR_CHAR);
@@ -677,3 +712,52 @@ char* jarFile(const char* path, const ch
     strcat(jarPath, jarName);
     return jarPath;
 }
+
+#if !defined(LINUX) && !defined(FREEBSD) && !defined(WIN32)
+char* findInPath(const char* basename)
+{
+  char filename[PATH_MAX+1];
+  char *path;
+  char *path_to_free;
+  char *path_end;
+
+  path = getenv("PATH");
+  if (!path) {
+    return NULL;
+  }
+  path_to_free = path = strdup(path);
+  if (!path) {
+    return NULL;
+  }
+  path_end = path + strlen(path);
+  while (path < path_end) {
+    int rc;
+    char *path_next;
+    char *sep = strchr(path, ':');
+    if (sep) {
+      *sep = '\0';
+      path_next = sep + 1;
+    } else {
+      path_next = path_end;
+    }
+    if (PATH_MAX < strlen(path) + strlen(basename) + 1) {
+      path = path_next;
+      continue;
+    }
+    strcpy(filename, path);
+    filename[strlen(path)] = '/';
+    filename[strlen(path)+1] = '\0';
+    strcat(filename, basename);
+    rc = access(filename, X_OK);
+    if (rc == 0) {
+      char *ret = strdup(filename);
+      free((void*)path_to_free);
+      return ret;
+    }
+    path = path_next;
+  }
+
+  free((void*)path_to_free);
+  return NULL;
+}
+#endif

Modified: harmony/enhanced/java/branches/mrh/jdktools/modules/samsa/src/main/native/samsa/unix/makefile
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/jdktools/modules/samsa/src/main/native/samsa/unix/makefile?rev=986497&r1=986496&r2=986497&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/jdktools/modules/samsa/src/main/native/samsa/unix/makefile (original)
+++ harmony/enhanced/java/branches/mrh/jdktools/modules/samsa/src/main/native/samsa/unix/makefile Tue Aug 17 21:36:10 2010
@@ -24,7 +24,11 @@ BUILDFILES = samsa.o
 
 EXENAME = $(LIBPATH)samsa
 
+ifeq ($(HY_OS),zos)
+MDLLIBFILES = $(LIBPATH)libhya2e.x
+else
 MDLLIBFILES = 
+endif
 
 include $(HY_HDK)/build/make/rules.mk
 



Mime
View raw message