1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
#!@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, 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA
my $destpath=@COLLECTIONS_PREFIX@;
my $classpath=pop;
my @javalangclasses=qw(UnsupportedOperationException
Comparable
Iterable);
my @javautilclasses=qw(AbstractCollection
AbstractList
AbstractMap
AbstractSequentialList
AbstractSet
ArrayList
Arrays
List
Collection
Collections
Comparator
ConcurrentModificationException
HashMap
HashSet
Hashtable
Iterator
LinkedList
ListIterator
Map
NoSuchElementException
Random
RandomAccess
Set
SortedMap
SortedSet
TreeMap
TreeSet
Vector);
my @externalclasses=qw(AbstractQueue
ArrayDeque
Deque
NavigableMap
NavigableSet
Queue);
my $destPkg = $destpath;
$destPkg =~ s!/!.!g;
my %imports = ( "Collections" => [ "Enumeration" ],
"Hashtable" => [ "Dictionary", "Enumeration" ],
"Vector" => [ "Enumeration" ]);
sub mymkdir ($)
{
my ($dir) = @_;
if ($dir =~ /^(.*)\/\w+$/)
{
$parentdir = "$1";
if (! (-d $parentdir))
{
mymkdir ($parentdir);
}
}
print "$dir";
mkdir ($dir, 0777);
}
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)) {
mymkdir ($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;
}
for $clazz (@externalclasses) {
$_ =~ s/java.util.$clazz/$clazz/g;
}
$_ =~ s/abstract (interface)/$1/g;
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);
}
for $file (@externalclasses) {
my $infile = "$classpath/external/jsr166/java/util/$file.java";
my $outfile = "$destpath/$file.java";
print "$outfile\n";
convert ($file, $infile, $outfile);
}
|