Return-Path:
Delivered-To: apmail-jakarta-ant-dev-archive@jakarta.apache.org
Received: (qmail 61299 invoked by uid 500); 24 Apr 2001 08:42:07 -0000
Mailing-List: contact ant-dev-help@jakarta.apache.org; run by ezmlm
Precedence: bulk
Reply-To: ant-dev@jakarta.apache.org
list-help:
list-unsubscribe:
list-post:
Delivered-To: mailing list ant-dev@jakarta.apache.org
Received: (qmail 60920 invoked by uid 500); 24 Apr 2001 08:42:05 -0000
Delivered-To: apmail-jakarta-ant-cvs@apache.org
Date: 24 Apr 2001 08:42:03 -0000
Message-ID: <20010424084203.60631.qmail@apache.org>
From: bodewig@apache.org
To: jakarta-ant-cvs@apache.org
Subject: cvs commit: jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs
ExecuteWatchdogTest.java
bodewig 01/04/24 01:42:03
Modified: . bootstrap.bat bootstrap.sh
src/main/org/apache/tools/ant/taskdefs Recorder.java
RecorderEntry.java
src/main/org/apache/tools/ant/taskdefs/optional Pvcs.java
src/main/org/apache/tools/ant/taskdefs/optional/ejb
BorlandGenerateClient.java
src/main/org/apache/tools/ant/taskdefs/rmic
DefaultRmicAdapter.java
src/main/org/apache/tools/zip ZipEntry.java
ZipOutputStream.java
src/testcases/org/apache/tools/ant/taskdefs
ExecuteWatchdogTest.java
Log:
More JDK 1.1 issues. Culprits have been , and the new
zip package.
Revision Changes Path
1.35 +1 -1 jakarta-ant/bootstrap.bat
Index: bootstrap.bat
===================================================================
RCS file: /home/cvs/jakarta-ant/bootstrap.bat,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- bootstrap.bat 2001/03/07 18:53:13 1.34
+++ bootstrap.bat 2001/04/24 08:41:46 1.35
@@ -48,7 +48,7 @@
echo.
echo ... Compiling Ant Classes
-%JAVAC% -d %CLASSDIR% %TOOLS%\tar\*.java %TOOLS%\ant\*.java %TOOLS%\ant\types\*.java %TOOLS%\ant\taskdefs\*.java %TOOLS%\ant\util\*.java %TOOLS%\ant\util\regexp\RegexpMatcher.java %TOOLS%\ant\util\regexp\RegexpMatcherFactory.java
+%JAVAC% -d %CLASSDIR% %TOOLS%\tar\*.java %TOOLS%\zip\*.java %TOOLS%\ant\*.java %TOOLS%\ant\types\*.java %TOOLS%\ant\taskdefs\*.java %TOOLS%\ant\util\*.java %TOOLS%\ant\util\regexp\RegexpMatcher.java %TOOLS%\ant\util\regexp\RegexpMatcherFactory.java
echo.
echo ... Copying Required Files
1.48 +1 -1 jakarta-ant/bootstrap.sh
Index: bootstrap.sh
===================================================================
RCS file: /home/cvs/jakarta-ant/bootstrap.sh,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -r1.47 -r1.48
--- bootstrap.sh 2001/03/16 09:22:36 1.47
+++ bootstrap.sh 2001/04/24 08:41:47 1.48
@@ -74,7 +74,7 @@
echo ... Compiling Ant Classes
-${JAVAC} -d ${CLASSDIR} ${TOOLS}/tar/*.java \
+${JAVAC} -d ${CLASSDIR} ${TOOLS}/tar/*.java ${TOOLS}/zip/*.java \
${TOOLS}/ant/util/regexp/RegexpMatcher.java \
${TOOLS}/ant/util/regexp/RegexpMatcherFactory.java \
${TOOLS}/ant/util/*.java ${TOOLS}/ant/types/*.java \
1.2 +1 -1 jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Recorder.java
Index: Recorder.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Recorder.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Recorder.java 2001/04/04 12:03:46 1.1
+++ Recorder.java 2001/04/24 08:41:50 1.2
@@ -93,7 +93,7 @@
/** What level to log? -1 means not initialized yet. */
private int loglevel = -1;
/** The list of recorder entries. */
- private static HashMap recorderEntries = new HashMap();
+ private static Hashtable recorderEntries = new Hashtable();
//////////////////////////////////////////////////////////////////////
// CONSTRUCTORS / INITIALIZERS
1.2 +1 -1 jakarta-ant/src/main/org/apache/tools/ant/taskdefs/RecorderEntry.java
Index: RecorderEntry.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/RecorderEntry.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- RecorderEntry.java 2001/04/04 12:03:46 1.1
+++ RecorderEntry.java 2001/04/24 08:41:51 1.2
@@ -203,7 +203,7 @@
}
public void setEmacsMode(boolean emacsMode) {
- throw new java.lang.UnsupportedOperationException("Method setEmacsMode() not yet implemented.");
+ throw new java.lang.RuntimeException("Method setEmacsMode() not yet implemented.");
}
public void setErrorPrintStream(PrintStream err) {
1.2 +7 -2 jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/Pvcs.java
Index: Pvcs.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/Pvcs.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Pvcs.java 2001/02/23 05:13:34 1.1
+++ Pvcs.java 2001/04/24 08:41:53 1.2
@@ -59,6 +59,7 @@
import java.io.*;
import java.text.*;
+import java.util.Random;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.Execute;
@@ -150,9 +151,9 @@
if(getPvcsproject()!=null)
commandLine.createArgument().setValue(getPvcsproject());
- File tmp;
+ File tmp = null;
try {
- tmp = File.createTempFile("pvcs_ant_",".log");
+ tmp = new File("pvcs_ant_"+(new Random(System.currentTimeMillis())).nextLong()+".log");
result = runCmd(commandLine, new PumpStreamHandler(new FileOutputStream(tmp), new LogOutputStream(this,Project.MSG_WARN)));
if ( result != 0 && !ignorerc) {
String msg = "Failed executing: " + commandLine.toString();
@@ -196,6 +197,10 @@
} catch(ParseException e) {
String msg = "Failed executing: " + commandLine.toString();
throw new BuildException(e.getMessage(),location);
+ } finally {
+ if (tmp != null) {
+ tmp.delete();
+ }
}
}
1.3 +0 -1 jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ejb/BorlandGenerateClient.java
Index: BorlandGenerateClient.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ejb/BorlandGenerateClient.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- BorlandGenerateClient.java 2001/04/19 14:02:16 1.2
+++ BorlandGenerateClient.java 2001/04/24 08:41:55 1.3
@@ -58,7 +58,6 @@
import java.io.*;
import java.net.*;
import java.util.*;
-import java.util.jar.*;
import javax.xml.parsers.*;
import org.apache.tools.ant.*;
1.3 +1 -1 jakarta-ant/src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java
Index: DefaultRmicAdapter.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DefaultRmicAdapter.java 2001/03/19 11:22:50 1.2
+++ DefaultRmicAdapter.java 2001/04/24 08:41:56 1.3
@@ -260,7 +260,7 @@
niceSourceList.append(" to be compiled:");
for (int i=0; i < compileList.size(); i++) {
- String arg = (String)compileList.get(i);
+ String arg = (String)compileList.elementAt(i);
cmd.createArgument().setValue(arg);
niceSourceList.append(" " + arg);
}
1.2 +134 -4 jakarta-ant/src/main/org/apache/tools/zip/ZipEntry.java
Index: ZipEntry.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/zip/ZipEntry.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ZipEntry.java 2001/04/23 16:12:21 1.1
+++ ZipEntry.java 2001/04/24 08:41:58 1.2
@@ -54,6 +54,8 @@
package org.apache.tools.zip;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import java.util.Vector;
import java.util.zip.ZipException;
@@ -62,7 +64,7 @@
* access to the internal and external file attributes.
*
* @author Stefan Bodewig
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
public class ZipEntry extends java.util.zip.ZipEntry {
@@ -85,7 +87,29 @@
* @since 1.1
*/
public ZipEntry(java.util.zip.ZipEntry entry) throws ZipException {
- super(entry);
+ /*
+ * REVISIT: call super(entry) instead of this stuff in Ant2,
+ * "copy constructor" has not been available in JDK 1.1
+ */
+ super(entry.getName());
+
+ setComment(entry.getComment());
+ setMethod(entry.getMethod());
+ setTime(entry.getTime());
+
+ long size = entry.getSize();
+ if (size > 0) {
+ setSize(size);
+ }
+ long cSize = entry.getCompressedSize();
+ if (cSize > 0) {
+ setComprSize(cSize);
+ }
+ long crc = entry.getCrc();
+ if (crc > 0) {
+ setCrc(crc);
+ }
+
byte[] extra = entry.getExtra();
if (extra != null) {
setExtraFields(ExtraFieldUtils.parse(extra));
@@ -100,8 +124,8 @@
*
* @since 1.1
*/
- public ZipEntry(ZipEntry entry) {
- super(entry);
+ public ZipEntry(ZipEntry entry) throws ZipException {
+ this((java.util.zip.ZipEntry) entry);
setInternalAttributes(entry.getInternalAttributes());
setExternalAttributes(entry.getExternalAttributes());
setExtraFields(entry.getExtraFields());
@@ -269,4 +293,110 @@
public byte[] getCentralDirectoryExtra() {
return ExtraFieldUtils.mergeCentralDirectoryData(getExtraFields());
}
+
+ /**
+ * Helper for JDK 1.1 <-> 1.2 incompatibility.
+ *
+ * @since 1.2
+ */
+ private Long compressedSize = null;
+
+ /**
+ * Make this class work in JDK 1.1 like a 1.2 class.
+ *
+ * This either stores the size for later usage or invokes
+ * setCompressedSize via reflection.
+ *
+ * @since 1.2
+ */
+ public void setComprSize(long size) {
+ if (haveSetCompressedSize()) {
+ performSetCompressedSize(this, size);
+ } else {
+ compressedSize = new Long(size);
+ }
+ }
+
+ /**
+ * Override to make this class work in JDK 1.1 like a 1.2 class.
+ *
+ * @since 1.2
+ */
+ public long getCompressedSize() {
+ if (compressedSize != null) {
+ // has been set explicitly and we are running in a 1.1 VM
+ return compressedSize.longValue();
+ }
+ return super.getCompressedSize();
+ }
+
+ /**
+ * Helper for JDK 1.1
+ *
+ * @since 1.2
+ */
+ private static Method setCompressedSizeMethod = null;
+ /**
+ * Helper for JDK 1.1
+ *
+ * @since 1.2
+ */
+ private static Object lockReflection = new Object();
+ /**
+ * Helper for JDK 1.1
+ *
+ * @since 1.2
+ */
+ private static boolean triedToGetMethod = false;
+
+ /**
+ * Are we running JDK 1.2 or higher?
+ *
+ * @since 1.2
+ */
+ private static boolean haveSetCompressedSize() {
+ checkSCS();
+ return setCompressedSizeMethod != null;
+ }
+
+ /**
+ * Invoke setCompressedSize via reflection.
+ *
+ * @since 1.2
+ */
+ private static void performSetCompressedSize(ZipEntry ze, long size) {
+ Long[] s = {new Long(size)};
+ try {
+ setCompressedSizeMethod.invoke(ze, s);
+ } catch (InvocationTargetException ite) {
+ Throwable nested = ite.getTargetException();
+ throw new RuntimeException("Exception setting the compressed size "
+ + "of " + ze + ": "
+ + nested.getMessage());
+ } catch (Throwable other) {
+ throw new RuntimeException("Exception setting the compressed size "
+ + "of " + ze + ": "
+ + other.getMessage());
+ }
+ }
+
+ /**
+ * Try to get a handle to the setCompressedSize method.
+ *
+ * @since 1.2
+ */
+ private static void checkSCS() {
+ if (!triedToGetMethod) {
+ synchronized (lockReflection) {
+ triedToGetMethod = true;
+ try {
+ setCompressedSizeMethod =
+ java.util.zip.ZipEntry.class.getMethod("setCompressedSize",
+ new Class[] {Long.TYPE});
+ } catch (NoSuchMethodException nse) {
+ }
+ }
+ }
+ }
+
}
1.2 +3 -3 jakarta-ant/src/main/org/apache/tools/zip/ZipOutputStream.java
Index: ZipOutputStream.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/zip/ZipOutputStream.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ZipOutputStream.java 2001/04/23 16:12:22 1.1
+++ ZipOutputStream.java 2001/04/24 08:41:59 1.2
@@ -78,7 +78,7 @@
* will be called.
*
* @author Stefan Bodewig
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
public class ZipOutputStream extends DeflaterOutputStream {
@@ -240,7 +240,7 @@
}
entry.setSize(def.getTotalIn());
- entry.setCompressedSize(def.getTotalOut());
+ entry.setComprSize(def.getTotalOut());
entry.setCrc(realCrc);
def.reset();
@@ -295,7 +295,7 @@
if (entry.getCrc() == -1) {
throw new ZipException("crc checksum is required for STORED method");
}
- entry.setCompressedSize(entry.getSize());
+ entry.setComprSize(entry.getSize());
} else {
def.setLevel(level);
}
1.4 +11 -0 jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/ExecuteWatchdogTest.java
Index: ExecuteWatchdogTest.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/ExecuteWatchdogTest.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ExecuteWatchdogTest.java 2001/02/19 10:09:36 1.3
+++ ExecuteWatchdogTest.java 2001/04/24 08:42:01 1.4
@@ -54,6 +54,8 @@
package org.apache.tools.ant.taskdefs;
+import org.apache.tools.ant.Project;
+
import java.net.*;
import junit.framework.*;
import java.io.*;
@@ -89,6 +91,15 @@
System.err.println("WARNING: 'build.tests' property is not available !");
classpath = System.getProperty("java.class.path");
}
+
+ // JDK 1.1 needs classes.zip in -classpath argument
+ if (Project.getJavaVersion() == Project.JAVA_1_1) {
+ classpath += File.pathSeparator
+ + System.getProperty("java.home")
+ + File.separator + "lib"
+ + File.separator + "classes.zip";
+ }
+
return classpath;
}