summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Jones <cbj@gnu.org>2000-12-17 07:54:39 +0000
committerBrian Jones <cbj@gnu.org>2000-12-17 07:54:39 +0000
commit4a3f6eef3ced7ee5eaaa2ecf60f21294d4752f7e (patch)
treedbae859c575be23701cade8e524f363eade64dc2
parent36b4f8e9aa8257ba9ec0e205f0a132247ac02159 (diff)
downloadclasspath-4a3f6eef3ced7ee5eaaa2ecf60f21294d4752f7e.tar.gz
* java/util/ArrayList.java: Changes made to let a given Perl script
produce the correct collections api in a different package for Java 1.1. writeObject(): renamed variable to oFields readObject(): renamed variable to iFields * configure.in: create lib/mkcollections.pl * lib/Makefile.am: distribute mkcollections.pl.in * lib/mkcollections.pl.in: creates copies of collections classes in a new user defined package name space for use in Java 1.1 projects, contributed by Jochen Hoenicke <Jochen.Hoenicke@Informatik.Uni-Oldenburg.de>.
-rw-r--r--ChangeLog13
-rw-r--r--configure.in4
-rw-r--r--java/util/ArrayList.java10
-rw-r--r--lib/.cvsignore1
-rw-r--r--lib/Makefile.am2
-rwxr-xr-xlib/mkcollections.pl.in169
6 files changed, 192 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 1f44b90a2..fedee8dcb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2000-12-17 Brian Jones <cbj@gnu.org>
+ * java/util/ArrayList.java: Changes made to let a given Perl script
+ produce the correct collections api in a different package for
+ Java 1.1.
+ writeObject(): renamed variable to oFields
+ readObject(): renamed variable to iFields
+ * configure.in: create lib/mkcollections.pl
+ * lib/Makefile.am: distribute mkcollections.pl.in
+ * lib/mkcollections.pl.in: creates copies of collections classes
+ in a new user defined package name space for use in Java 1.1
+ projects, contributed by Jochen Hoenicke
+ <Jochen.Hoenicke@Informatik.Uni-Oldenburg.de>.
+
2000-12-14 Tom Tromey <tromey@redhat.com>
* java/lang/RuntimePermission.java: Class now final.
diff --git a/configure.in b/configure.in
index 16bd3b811..ca10717b7 100644
--- a/configure.in
+++ b/configure.in
@@ -369,8 +369,10 @@ vm/reference/java/lang/Makefile
vm/reference/java/lang/reflect/Makefile
lib/Makefile
lib/gen-classlist.sh
-lib/mkdep.pl,
+lib/mkdep.pl
+lib/mkcollections.pl,
[ chmod 755 lib/mkdep.pl
+ chmod 755 lib/mkcollections.pl
chmod 755 lib/gen-classlist.sh
])
diff --git a/java/util/ArrayList.java b/java/util/ArrayList.java
index 52c869355..113078a91 100644
--- a/java/util/ArrayList.java
+++ b/java/util/ArrayList.java
@@ -43,7 +43,7 @@ import java.io.ObjectStreamField;
* to or removing from the end of a list, checking the size, &c.
*
* @author Jon A. Zeppieri
- * @version $Id: ArrayList.java,v 1.11 2000-11-27 08:28:47 bryce Exp $
+ * @version $Id: ArrayList.java,v 1.12 2000-12-17 07:54:39 cbj Exp $
* @see java.util.AbstractList
* @see java.util.List
*/
@@ -398,8 +398,8 @@ public class ArrayList extends AbstractList
{
int i;
- ObjectOutputStream.PutField fields = out.putFields();
- fields.put("size", size);
+ ObjectOutputStream.PutField oFields = out.putFields();
+ oFields.put("size", size);
out.writeFields();
// FIXME: Do we really want to serialize unused list entries??
@@ -414,8 +414,8 @@ public class ArrayList extends AbstractList
int i;
int capacity;
- ObjectInputStream.GetField fields = in.readFields();
- size = fields.get("size", 0);
+ ObjectInputStream.GetField iFields = in.readFields();
+ size = iFields.get("size", 0);
capacity = in.readInt();
data = new Object[capacity];
diff --git a/lib/.cvsignore b/lib/.cvsignore
index 6f5181b49..3420f39bd 100644
--- a/lib/.cvsignore
+++ b/lib/.cvsignore
@@ -14,3 +14,4 @@ classes.dep
makefile.dep
java.dep
compile-classes
+mkcollections.pl
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 715541eb9..a7fbb1922 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -259,7 +259,7 @@ $(JAVA_DEPEND): classes
##endif
-EXTRA_DIST = glibj.zip standard.omit
+EXTRA_DIST = glibj.zip standard.omit mkcollections.pl.in
## not sure if we want to let the user easily get rid of glibj.zip
## CLEANFILES = glibj.zip
DISTCLEANFILES = $(CLASSES) $(CP_HEADERS)
diff --git a/lib/mkcollections.pl.in b/lib/mkcollections.pl.in
new file mode 100755
index 000000000..5e0125bb5
--- /dev/null
+++ b/lib/mkcollections.pl.in
@@ -0,0 +1,169 @@
+#!@PERL@
+#
+# mkcollections.pl - small perl script to convert GNU Classpath's
+# Collection classes into its own package for java 1.1
+#
+# USAGE: mkcollections.pl <Destination-Path>
+#
+# Copyright (C) 2000 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; see the file COPYING. If not, write to
+# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+
+my $destpath=pop || "gnu/java/util/collections";
+my $classpath="..";
+my @javalangclasses=qw(UnsupportedOperationException
+ Comparable);
+my @javautilclasses=qw(AbstractCollection
+ AbstractList
+ AbstractMap
+ AbstractSequentialList
+ AbstractSet
+ ArrayList
+ Arrays
+ BasicMapEntry
+ Bucket
+ List
+ Collection
+ Collections
+ Comparator
+ ConcurrentModificationException
+ HashMap
+ HashSet
+ Hashtable
+ Iterator
+ LinkedList
+ ListIterator
+ Map
+ NoSuchElementException
+ Random
+ Set
+ SortedMap
+ SortedSet
+ TreeMap
+ TreeSet
+ Vector);
+
+my $destPkg = $destpath;
+$destPkg =~ s!/!.!g;
+
+my %imports = ( "Collections" => [ "Enumeration" ],
+ "Hashtable" => [ "Dictionary", "Enumeration" ],
+ "Vector" => [ "Enumeration" ]);
+
+
+sub mymkdir ($) {
+ my ($dir) = @_;
+ $dir =~ /^(.*)\/\w+$/ and
+ $dir = "$1";
+ if (! (-d "$dir")) {
+ my $ret = mkdir ("$dir");
+ if (!($ret)) { mymkdir ("$dir"); mkdir ("$dir"); }
+ }
+}
+
+sub convert($$$) {
+ my ($file, $infile, $outfile) = @_;
+
+ open (INPUT, "<$infile") || die "Could not open ", $infile, " for reading\n";
+
+ my $dir = "$outfile";
+ $dir =~ /^(.*)\/\S+\.java$/ and
+ $dir = "$1";
+ if (! (-d "$dir")) {
+ my $ret = mkdir("$dir");
+ if (!($ret)) { mymkdir ("$dir"); mkdir ("$dir"); }
+ }
+
+ open (OUTPUT, ">$outfile") || die "Could not open ", $outfile, " for writing\n";
+ print OUTPUT <<'EOF';
+/* This file was converted from the GNU Classpath Project by a
+ * perl script, written by Jochen Hoenicke <jochen\@gnu.org>.
+ */
+EOF
+ while (<INPUT>) {
+ $_ = "package $destPkg;\n" if ($_ =~ /^package java.(lang|util);$/);
+
+ next if $_ =~ /^import java.io.Object.*putStream.*Field;$/;
+ next if $_ =~ /^import java.io.ObjectStreamField;$/;
+
+ for $clazz (@javalangclasses) {
+ $_ =~ s/java.lang.$clazz/$clazz/g;
+ }
+ for $clazz (@javautilclasses) {
+ $_ =~ s/java.util.$clazz/$clazz/g;
+ }
+
+ $_ =~ s/abstract (interface)/$1/g;
+
+ if ($file eq "ArrayList") {
+ # ArrayList makes heavy use of PutField/GetField.
+ # change it.
+ $_ =~ s/_iSize/size/g;
+ $_ =~ s/_arData/data/g;
+ }
+ if ($file eq "TreeMap") {
+ $_ =~ s/_oComparator/comparator/g;
+ $_ =~ s/(RBNode _oRoot|int _iSize|int _iModCount)/transient $1/;
+ }
+ if ($file eq "Vector") {
+ $_ =~ s/(\s+)return (\w+)\.delete\((.*), x\)\./$1$2.setLength($3);\n${1}return $2./g;
+ }
+
+ if ($file eq "ArrayList"
+ || $file eq "TreeMap"
+ || $file eq "Hashtable") {
+ if ($_ =~ /serialPersistentFields/) {
+ $_ = <INPUT> while !($_ =~ /\}/);
+ next;
+ }
+
+ $_ =~ /^(\s+)(.*\W)?(\w+).readFields/ and
+ $_ = "$1$3.defaultReadObject();\n";
+ $_ =~ /^(\s+)(.*\W)?(\w+).writeFields/ and
+ $_ = "$1$3.defaultWriteObject();\n";
+
+ if ($_ =~ /[io]Fields/) {
+ $_ = <INPUT> while !($_ =~ /;/);
+ next;
+ }
+ }
+
+ print OUTPUT $_;
+ if ($_ =~ /^package $destPkg;$/
+ && exists $imports{$file}) {
+ for $imp (@{$imports{$file}}) {
+ print OUTPUT "import java.util.$imp;\n";
+ }
+ }
+ }
+ close (OUTPUT);
+ close (INPUT);
+}
+
+my $file;
+
+for $file (@javalangclasses) {
+ my $infile = "$classpath/java/lang/$file.java";
+ my $outfile = "$destpath/$file.java";
+ print "$outfile\n";
+ convert ($file, $infile, $outfile);
+}
+
+for $file (@javautilclasses) {
+ my $infile = "$classpath/java/util/$file.java";
+ my $outfile = "$destpath/$file.java";
+ print "$outfile\n";
+ convert ($file, $infile, $outfile);
+}