ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Takashi Okamoto <toran...@kun.ne.jp>
Subject Re: [PATCH] Rmic.java for Kaffe
Date Fri, 09 Mar 2001 01:45:51 GMT
Hi, Ant!!


me > Please refer following patch and fix it (but I didn't test it). 

I tested to compile log4j (it's included rmic task). I found that I
take a mistake following line:

+	      compile.invoke(compiler, (Object[]) cmd.getArguments() );

It should be

+	      compile.invoke(compiler, (new Object[] {cmd.getArguments()} ));


Now attached patch works fine with both SUN's rmic and Kaffe's rmic to
compile log4j.
Please fix it.

Caution:
We must specify output directry path by CLASSPATH when use Kaffe's rmic.
For example, when  output directory is classes, we have to set
classpath:

# export CLASSPATH=${CLASSPATH}:classes

regards.
-----------------
Takashi Okamoto

--- src/main/org/apache/tools/ant/taskdefs/Rmic.java.orig	Thu Mar  8 09:26:48 2001
+++ src/main/org/apache/tools/ant/taskdefs/Rmic.java	Thu Mar  8 09:29:05 2001
@@ -63,6 +63,8 @@
 import org.apache.tools.ant.types.Reference;
 import org.apache.tools.ant.util.*;
 
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
 import java.io.*;
 import java.util.StringTokenizer;
 import java.util.Vector;
@@ -249,7 +251,6 @@
         // need to provide an input stream that we read in from!
 
         OutputStream logstr = new LogOutputStream(this, Project.MSG_WARN);
-        sun.rmi.rmic.Main compiler = new sun.rmi.rmic.Main(logstr, "rmic");
         Commandline cmd = new Commandline();
         
         cmd.createArgument().setValue("-d");
@@ -292,7 +293,33 @@
                 cmd.createArgument().setValue((String) compileList.elementAt(j));
             }
             log("Compilation args: " + cmd.toString(), Project.MSG_VERBOSE);
-            compiler.compile(cmd.getArguments());
+
+	    Object compiler = null;
+	    Method compile = null;
+	    Class c = null;
+	    Constructor cons  = null;
+	    try {
+	      // SUN's rmic 
+	      c = Class.forName("sun.rmi.rmic.Main");
+	      cons = c.getConstructor(new Class[] 
+		{ OutputStream.class, String.class });
+	      compiler = cons.newInstance(new Object[] { logstr, "rmic" });
+	      compile = c.getMethod("compile", new Class [] 
+		{ String[].class });
+	      compile.invoke(compiler, (new Object[] {cmd.getArguments()} ));
+	    } catch (Exception es) {
+	      try {
+		// Kaffe's rmic
+		c = Class.forName("kaffe.rmi.rmic.RMIC");
+		cons = c.getConstructor(new Class[] { String[].class });
+		compiler = cons.newInstance(new Object[] { cmd.getArguments() });
+		compile = c.getMethod("run", null);
+		compile.invoke(compiler, null);
+	      } catch (Exception ek) {
+		ek.printStackTrace();
+		System.exit(1);
+	      }
+	    }
         }
 
         // Move the generated source file to the base directory


---------------------------------------------------------------------
To unsubscribe, e-mail: ant-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: ant-dev-help@jakarta.apache.org


Mime
View raw message