You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by ia...@apache.org on 2004/09/02 22:33:26 UTC
cvs commit: ws-axis/java/src/org/apache/axis/components/compiler Javac.java
ias 2004/09/02 13:33:26
Modified: java/src/org/apache/axis/components/compiler Javac.java
Log:
Patch for annotations of J2SE 5 thanks to Jonathan Colwell.
Revision Changes Path
1.11 +44 -12 ws-axis/java/src/org/apache/axis/components/compiler/Javac.java
Index: Javac.java
===================================================================
RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/components/compiler/Javac.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- Javac.java 13 Jul 2004 18:40:40 -0000 1.10
+++ Javac.java 2 Sep 2004 20:33:26 -0000 1.11
@@ -27,6 +27,8 @@
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.ArrayList;
@@ -52,7 +54,7 @@
LogFactory.getLog(Javac.class.getName());
public static final String CLASSIC_CLASS = "sun.tools.javac.Main";
- public static final String MODERN_CLASS = "com.sun.tools.javac.Main";
+ public static final String MODERN_CLASS = "com.sun.tools.javac.main.Main";
private boolean modern = false;
@@ -106,20 +108,50 @@
try {
// Create an instance of the compiler, redirecting output to err
- Class c = ClassUtils.forName("sun.tools.javac.Main", true, getClassLoader());
-
- Constructor cons =
- c.getConstructor(new Class[] { OutputStream.class,
- String.class });
- Object compiler = cons.newInstance(new Object[] { err,
- "javac" });
+ Class c = ClassUtils.forName(modern ? MODERN_CLASS : CLASSIC_CLASS,
+ true,
+ getClassLoader());
+
+ Constructor cons;
+ Object compiler;
+ if (modern) {
+ PrintWriter pw = new PrintWriter(new OutputStreamWriter(err));
+ cons =
+ c.getConstructor(new Class[] { String.class,
+ PrintWriter.class});
+
+ compiler = cons.newInstance(new Object[] { "javac", pw });
+ }
+ else {
+ cons =
+ c.getConstructor(new Class[] { OutputStream.class,
+ String.class });
+ compiler = cons.newInstance(new Object[] { err, "javac" });
+
+ }
+
// Call the compile() method
Method compile = c.getMethod("compile",
new Class [] { String[].class });
- Boolean ok =
- (Boolean) compile.invoke(compiler,
- new Object[] {toStringArray(fillArguments(new ArrayList()))});
- result = ok.booleanValue();
+
+ if (modern) {
+ int compilationResult =
+ ((Integer)compile.invoke(compiler, new Object[]
+ {
+ toStringArray(fillArguments
+ (new ArrayList()))})).intValue();
+
+ result = (compilationResult == 0);
+ log.debug("Compilation Returned: "
+ + Integer.toString(compilationResult));
+ }
+ else {
+ Boolean ok =
+ (Boolean)compile.invoke(compiler, new Object[]
+ {toStringArray(fillArguments(new ArrayList()))});
+
+ result = ok.booleanValue();
+ }
} catch (Exception cnfe){
log.error(Messages.getMessage("noCompiler00"), cnfe);
throw new RuntimeException(Messages.getMessage("noCompiler00"));