Skip to content

Commit

Permalink
Bring back 24 Collections bugs previously deprecated, patching compil…
Browse files Browse the repository at this point in the history
…ation errors.
  • Loading branch information
rjust committed Sep 6, 2024
1 parent 4e65fb9 commit 63d725a
Show file tree
Hide file tree
Showing 10 changed files with 1,133 additions and 37 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ jobs:
working-directory: "./framework/test"

# Verify a few select bugs to detect serious breakages early.
- run: carton exec ./test_verify_bugs.sh -p Collections -b 10 -A
name: "test_verify_bugs.sh -p Collections -b 10 -A"
working-directory: "./framework/test"
- run: carton exec ./test_verify_bugs.sh -p Lang -b 24 -A
name: "test_verify_bugs.sh -p Lang -b 24 -A"
working-directory: "./framework/test"
Expand Down
30 changes: 17 additions & 13 deletions framework/core/Project/Collections.pm
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,24 @@ sub determine_layout {
#
sub _post_checkout {
my ($self, $rev_id, $work_dir) = @_;
my $vid = $self->{_vcs}->lookup_vid($rev_id);

# Fix compilation errors if necessary.
# Run this as the first step to ensure that patches are applicable to
# unmodified source files.
my $compile_errors = "$PROJECTS_DIR/$self->{pid}/compile-errors/";
opendir(DIR, $compile_errors) or die "Could not find compile-errors directory.";
my @entries = readdir(DIR);
closedir(DIR);
foreach my $file (@entries) {
if ($file =~ /-(\d+)-(\d+).diff/) {
if ($vid >= $1 && $vid <= $2) {
$self->apply_patch($work_dir, "$compile_errors/$file")
or die("Couldn't apply patch ($file): $!");
}
}
}

my $project_dir = "$PROJECTS_DIR/$self->{pid}";
# Check whether ant build file exists
unless (-e "$work_dir/build.xml") {
my $build_files_dir = "$PROJECTS_DIR/$PID/build_files/$rev_id";
Expand All @@ -93,18 +109,6 @@ sub _post_checkout {
}
}

if (-e "$work_dir/build.xml"){
rename("$work_dir/build.xml", "$work_dir/build.xml".'.bak');
open(IN, '<'."$work_dir/build.xml".'.bak') or die $!;
open(OUT, '>'."$work_dir/build.xml") or die $!;
while(<IN>) {
$_ =~ s/\<javac srcdir=\"\$\{source\.home\}\" destdir=\"\$\{build\.home\}\/classes\" debug=\"\$\{compile\.debug\}\" deprecation\=\"\$\{compile\.deprecation\}\" target=\"\$\{compile\.target\}\" source=\"\$\{compile\.source\}\" excludes=\"\$\{compile\.excludes\}\" optimize=\"\$\{compile\.optimize\}\" includeantruntime=\"false\" encoding=\"\$\{compile\.encoding\}\"\>/\<javac fork=\"true\" srcdir=\"\$\{source\.home\}\" destdir=\"\$\{build\.home\}\/classes\" debug=\"\$\{compile\.debug\}\" deprecation\=\"\$\{compile\.deprecation\}\" target=\"1\.7\" source=\"1\.7\" excludes=\"\$\{compile\.excludes\}\" optimize=\"\$\{compile\.optimize\}\" includeantruntime=\"false\" encoding=\"\$\{compile\.encoding\}\"\>/g;
print OUT $_;
}
close(IN);
close(OUT);
}

# Convert the file encoding of a problematic file
my $result = determine_layout($self, $rev_id);
if(-e $work_dir."/".$result->{src}."/org/apache/commons/collections/functors/ComparatorPredicate.java"){
Expand Down
24 changes: 24 additions & 0 deletions framework/projects/Collections/active-bugs.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
bug.id,revision.id.buggy,revision.id.fixed,report.id,report.url
1,b1cd358495cae3df8e0e32147ef433cce83390c8,f8aa3e033c1fde4a434864f666315b433498d32c,COLLECTIONS-217,https://issues.apache.org/jira/browse/COLLECTIONS-217,2.0.0,JVM8.Does.Not.Compile
2,f8aa3e033c1fde4a434864f666315b433498d32c,3f09772b742d7886c5a18427c9838fb267cc335b,COLLECTIONS-214,https://issues.apache.org/jira/browse/COLLECTIONS-214,2.0.0,JVM8.Does.Not.Compile
3,3f09772b742d7886c5a18427c9838fb267cc335b,66c4b99ddc7daea806c1318a40736d0f5c8fa7bd,COLLECTIONS-219,https://issues.apache.org/jira/browse/COLLECTIONS-219,2.0.0,JVM8.Does.Not.Compile
4,139636b502dd144b7f6070a8f30b46913ef6965a,5e313d14b2a10ce0aea529ac4db50e183f0b1e49,COLLECTIONS-228,https://issues.apache.org/jira/browse/COLLECTIONS-228,2.0.0,JVM8.Does.Not.Compile
5,d0128142ff08d9a9dc5c1ca483594abb21f90353,f43e0a53c1f4d3335e720131973dfc8e1103f5f9,COLLECTIONS-249,https://issues.apache.org/jira/browse/COLLECTIONS-249,2.0.0,JVM8.Does.Not.Compile
6,95a3fecee0f7a87624e490f0026b391188f9aceb,1d5610521f5846c1d6f7d0a65f93c384dbf33e8d,COLLECTIONS-261,https://issues.apache.org/jira/browse/COLLECTIONS-261,2.0.0,JVM8.Does.Not.Compile
7,142a6dd5eedf83e9bd5f077d64977969cc4be40c,01086ef5b312d7aa5ad231277950618cb93664ee,COLLECTIONS-278,https://issues.apache.org/jira/browse/COLLECTIONS-278,2.0.0,JVM8.Does.Not.Compile
8,b147d16e647c9fa54b4ad14a76fd532906cec558,7cf943172b154019d7c6a66f4290272b2144e29a,COLLECTIONS-220,https://issues.apache.org/jira/browse/COLLECTIONS-220,2.0.0,JVM8.Does.Not.Compile
9,7cf943172b154019d7c6a66f4290272b2144e29a,8a5d3acab88bb2ef7416f3141d63f10b79d318cf,COLLECTIONS-271,https://issues.apache.org/jira/browse/COLLECTIONS-271,2.0.0,JVM8.Does.Not.Compile
10,c1351569a7184caee4ed7eacdf948f6a79db160f,e6d4f465446e5645f1a68f3d90964a6ade82f59e,COLLECTIONS-240,https://issues.apache.org/jira/browse/COLLECTIONS-240,2.0.0,JVM8.Does.Not.Compile
11,7873bd62ee22efd0c32cddd94e388a80faab81b2,d887c5913fddcecad8483ec9a0cbf407ed08c157,COLLECTIONS-266,https://issues.apache.org/jira/browse/COLLECTIONS-266,2.0.0,JVM8.Does.Not.Compile
12,441ed780ad999caf09ef5522983764977c8be45d,79ff10494b90ba99c339aadb87f6281c97aea966,COLLECTIONS-271,https://issues.apache.org/jira/browse/COLLECTIONS-271,2.0.0,JVM8.Does.Not.Compile
13,79ff10494b90ba99c339aadb87f6281c97aea966,f3eaf2ceae5d49c329ce8675d06b3003eb1ba389,COLLECTIONS-299,https://issues.apache.org/jira/browse/COLLECTIONS-299,2.0.0,JVM8.Does.Not.Compile
14,f3eaf2ceae5d49c329ce8675d06b3003eb1ba389,0725e476d4cc66e6331bdceb4e29a54a9ce7f462,COLLECTIONS-294,https://issues.apache.org/jira/browse/COLLECTIONS-294,2.0.0,JVM8.Does.Not.Compile
15,0725e476d4cc66e6331bdceb4e29a54a9ce7f462,0122245f02ba7b22dd40f38c98aa2f08984707bd,COLLECTIONS-304,https://issues.apache.org/jira/browse/COLLECTIONS-304,2.0.0,JVM8.Does.Not.Compile
16,0122245f02ba7b22dd40f38c98aa2f08984707bd,3290bbc85420176f53bad1968611bf53798b2770,COLLECTIONS-307,https://issues.apache.org/jira/browse/COLLECTIONS-307,2.0.0,JVM8.Does.Not.Compile
17,bb72bc51ce46c102124d09ac862860f44d169cb4,459f14b33c02509a4b9cc5360f3ff2f4edba9284,COLLECTIONS-239,https://issues.apache.org/jira/browse/COLLECTIONS-239,2.0.0,JVM8.Does.Not.Compile
18,38bb9b4ac534abc95a83c75faf5e87cfe25319d4,b10fa43d3e29af6c6e79577c305fad99df01dff0,COLLECTIONS-426,https://issues.apache.org/jira/browse/COLLECTIONS-426,2.0.0,JVM8.Does.Not.Compile
19,89d8791f05f0d28199820e87c683696f96d42f40,bb9952dbedc77f25fffda32d96e6494e2246bab3,COLLECTIONS-444,https://issues.apache.org/jira/browse/COLLECTIONS-444,2.0.0,JVM8.Does.Not.Compile
20,89ebfe8f921be807d40b3cecc504b05d56c0d898,b88692f83a938e31fd5f703c99db2a5720cd9f3e,COLLECTIONS-447,https://issues.apache.org/jira/browse/COLLECTIONS-447,2.0.0,JVM8.Does.Not.Compile
21,4b9c68b55a6f82942d32c5149fa0363b8b6b39fc,803a9c6c17efbc98bc9513e6bf7e6900d4dbae2c,COLLECTIONS-310,https://issues.apache.org/jira/browse/COLLECTIONS-310,2.0.0,JVM8.Does.Not.Compile
22,62e69cf4f2fcb3ad8bdc44f75f8a9e3e20ca7337,7df57879c92a467cd71860e6cfe14a04a49fd031,COLLECTIONS-474,https://issues.apache.org/jira/browse/COLLECTIONS-474,2.0.0,JVM8.Does.Not.Compile
23,15ee56bd0f91ef807a3e729ab3410a834ef3fcef,72784c46f6a7d7644398db5c7ac8bd3822c523d4,COLLECTIONS-495,https://issues.apache.org/jira/browse/COLLECTIONS-495,2.0.0,JVM8.Does.Not.Compile
24,72784c46f6a7d7644398db5c7ac8bd3822c523d4,539be680cd2b1a8f6833b28ee0cca22a88161466,COLLECTIONS-496,https://issues.apache.org/jira/browse/COLLECTIONS-496,2.0.0,JVM8.Does.Not.Compile
25,7c99c6234c7b403449420b2688fff3d516662591,73d69dfe8677210e44049bc1a2a7d1ff85bc1ca7,COLLECTIONS-566,https://issues.apache.org/jira/browse/COLLECTIONS-566
26,3a9c4718ee0fd2eeef8b3ce151ee829fadbef5ae,f8bd75d37ca12c5d49c1b628c33c0b45e2d082eb,COLLECTIONS-576,https://issues.apache.org/jira/browse/COLLECTIONS-576
27,7a72b1983c03f7b33e397cdfc5e8f0636bcd924e,3eee44cf63b1ebb0da6925e98b3dcc6ef1e4d610,COLLECTIONS-580,https://issues.apache.org/jira/browse/COLLECTIONS-580
Expand Down
187 changes: 187 additions & 0 deletions framework/projects/Collections/compile-errors/compile-1-16.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
diff --git a/src/java/org/apache/commons/collections/MultiHashMap.java b/src/java/org/apache/commons/collections/MultiHashMap.java
index e23bfa5a..d2597f51 100644
--- a/src/java/org/apache/commons/collections/MultiHashMap.java
+++ b/src/java/org/apache/commons/collections/MultiHashMap.java
@@ -330,7 +330,7 @@ public class MultiHashMap extends HashMap implements MultiMap {
* @param item the value to remove
* @return the value removed (which was passed in), null if nothing removed
*/
- public Object remove(Object key, Object item) {
+ public Object removeMapping(Object key, Object item) {
Collection valuesForKey = getCollection(key);
if (valuesForKey == null) {
return null;
diff --git a/src/java/org/apache/commons/collections/MultiMap.java b/src/java/org/apache/commons/collections/MultiMap.java
index 21701663..4b0fee67 100644
--- a/src/java/org/apache/commons/collections/MultiMap.java
+++ b/src/java/org/apache/commons/collections/MultiMap.java
@@ -65,7 +65,7 @@ public interface MultiMap extends Map {
* @throws ClassCastException if the key or value is of an invalid type
* @throws NullPointerException if the key or value is null and null is invalid
*/
- public Object remove(Object key, Object item);
+ public Object removeMapping(Object key, Object item);

//-----------------------------------------------------------------------
/**
diff --git a/src/java/org/apache/commons/collections/map/MultiKeyMap.java b/src/java/org/apache/commons/collections/map/MultiKeyMap.java
index 8df5efb5..526b89ca 100644
--- a/src/java/org/apache/commons/collections/map/MultiKeyMap.java
+++ b/src/java/org/apache/commons/collections/map/MultiKeyMap.java
@@ -196,7 +196,7 @@ public class MultiKeyMap
* @param key2 the second key
* @return the value mapped to the removed key, null if key not in map
*/
- public Object remove(Object key1, Object key2) {
+ public Object removeMultiKey(Object key1, Object key2) {
int hashCode = hash(key1, key2);
int index = map.hashIndex(hashCode, map.data.length);
AbstractHashedMap.HashEntry entry = map.data[index];
@@ -326,7 +326,7 @@ public class MultiKeyMap
* @param key3 the third key
* @return the value mapped to the removed key, null if key not in map
*/
- public Object remove(Object key1, Object key2, Object key3) {
+ public Object removeMultiKey(Object key1, Object key2, Object key3) {
int hashCode = hash(key1, key2, key3);
int index = map.hashIndex(hashCode, map.data.length);
AbstractHashedMap.HashEntry entry = map.data[index];
@@ -466,7 +466,7 @@ public class MultiKeyMap
* @param key4 the fourth key
* @return the value mapped to the removed key, null if key not in map
*/
- public Object remove(Object key1, Object key2, Object key3, Object key4) {
+ public Object removeMultiKey(Object key1, Object key2, Object key3, Object key4) {
int hashCode = hash(key1, key2, key3, key4);
int index = map.hashIndex(hashCode, map.data.length);
AbstractHashedMap.HashEntry entry = map.data[index];
@@ -616,7 +616,7 @@ public class MultiKeyMap
* @param key5 the fifth key
* @return the value mapped to the removed key, null if key not in map
*/
- public Object remove(Object key1, Object key2, Object key3, Object key4, Object key5) {
+ public Object removeMultiKey(Object key1, Object key2, Object key3, Object key4, Object key5) {
int hashCode = hash(key1, key2, key3, key4, key5);
int index = map.hashIndex(hashCode, map.data.length);
AbstractHashedMap.HashEntry entry = map.data[index];
diff --git a/src/java/org/apache/commons/collections/map/MultiValueMap.java b/src/java/org/apache/commons/collections/map/MultiValueMap.java
index 81e86be9..04a1395f 100644
--- a/src/java/org/apache/commons/collections/map/MultiValueMap.java
+++ b/src/java/org/apache/commons/collections/map/MultiValueMap.java
@@ -152,7 +152,7 @@ public class MultiValueMap extends AbstractMapDecorator implements MultiMap {
* @param value the value to remove
* @return the value removed (which was passed in), null if nothing removed
*/
- public Object remove(Object key, Object value) {
+ public Object removeMapping(Object key, Object value) {
Collection valuesForKey = getCollection(key);
if (valuesForKey == null) {
return null;
diff --git a/src/test/org/apache/commons/collections/TestMultiHashMap.java b/src/test/org/apache/commons/collections/TestMultiHashMap.java
index 4b6fa261..09a0ff5f 100644
--- a/src/test/org/apache/commons/collections/TestMultiHashMap.java
+++ b/src/test/org/apache/commons/collections/TestMultiHashMap.java
@@ -216,7 +216,7 @@ public class TestMultiHashMap extends AbstractTestMap {
MultiHashMap one = new MultiHashMap();
Integer value = new Integer(1);
one.put("One", value);
- one.remove("One", value);
+ one.removeMapping("One", value);

MultiHashMap two = new MultiHashMap();
assertEquals(two, one);
@@ -268,7 +268,7 @@ public class TestMultiHashMap extends AbstractTestMap {
assertEquals(4, map.totalSize());
map.remove("A");
assertEquals(3, map.totalSize());
- map.remove("B", "BC");
+ map.removeMapping("B", "BC");
assertEquals(2, map.totalSize());
}

@@ -291,7 +291,7 @@ public class TestMultiHashMap extends AbstractTestMap {
map.remove("A");
assertEquals(0, map.size("A"));
assertEquals(3, map.size("B"));
- map.remove("B", "BC");
+ map.removeMapping("B", "BC");
assertEquals(0, map.size("A"));
assertEquals(2, map.size("B"));
}
@@ -463,11 +463,11 @@ public class TestMultiHashMap extends AbstractTestMap {
map.put("A", "AA");
map.put("A", "AB");
map.put("A", "AC");
- assertEquals(null, map.remove("C", "CA"));
- assertEquals(null, map.remove("A", "AD"));
- assertEquals("AC", map.remove("A", "AC"));
- assertEquals("AB", map.remove("A", "AB"));
- assertEquals("AA", map.remove("A", "AA"));
+ assertEquals(null, map.removeMapping("C", "CA"));
+ assertEquals(null, map.removeMapping("A", "AD"));
+ assertEquals("AC", map.removeMapping("A", "AC"));
+ assertEquals("AB", map.removeMapping("A", "AB"));
+ assertEquals("AA", map.removeMapping("A", "AA"));
assertEquals(new MultiHashMap(), map);
}

diff --git a/src/test/org/apache/commons/collections/collection/AbstractTestCollection.java b/src/test/org/apache/commons/collections/collection/AbstractTestCollection.java
index 859aeccb..caafd8cf 100644
--- a/src/test/org/apache/commons/collections/collection/AbstractTestCollection.java
+++ b/src/test/org/apache/commons/collections/collection/AbstractTestCollection.java
@@ -1115,7 +1115,7 @@ public abstract class AbstractTestCollection extends AbstractTestObject {
verify();

try {
- array = collection.toArray(null);
+ array = collection.toArray((Object[])null);
fail("toArray(null) should raise NPE");
} catch (NullPointerException e) {
// expected
diff --git a/src/test/org/apache/commons/collections/map/TestMultiKeyMap.java b/src/test/org/apache/commons/collections/map/TestMultiKeyMap.java
index 7cd7e780..09aa810d 100644
--- a/src/test/org/apache/commons/collections/map/TestMultiKeyMap.java
+++ b/src/test/org/apache/commons/collections/map/TestMultiKeyMap.java
@@ -314,34 +314,34 @@ public class TestMultiKeyMap extends AbstractTestIterableMap {
switch (key.size()) {
case 2:
assertEquals(true, multimap.containsKey(key.getKey(0), key.getKey(1)));
- assertEquals(value, multimap.remove(key.getKey(0), key.getKey(1)));
+ assertEquals(value, multimap.removeMultiKey(key.getKey(0), key.getKey(1)));
assertEquals(false, multimap.containsKey(key.getKey(0), key.getKey(1)));
assertEquals(size - 1, multimap.size());
- assertEquals(null, multimap.remove(key.getKey(0), key.getKey(1)));
+ assertEquals(null, multimap.removeMultiKey(key.getKey(0), key.getKey(1)));
assertEquals(false, multimap.containsKey(key.getKey(0), key.getKey(1)));
break;
case 3:
assertEquals(true, multimap.containsKey(key.getKey(0), key.getKey(1), key.getKey(2)));
- assertEquals(value, multimap.remove(key.getKey(0), key.getKey(1), key.getKey(2)));
+ assertEquals(value, multimap.removeMultiKey(key.getKey(0), key.getKey(1), key.getKey(2)));
assertEquals(false, multimap.containsKey(key.getKey(0), key.getKey(1), key.getKey(2)));
assertEquals(size - 1, multimap.size());
- assertEquals(null, multimap.remove(key.getKey(0), key.getKey(1), key.getKey(2)));
+ assertEquals(null, multimap.removeMultiKey(key.getKey(0), key.getKey(1), key.getKey(2)));
assertEquals(false, multimap.containsKey(key.getKey(0), key.getKey(1), key.getKey(2)));
break;
case 4:
assertEquals(true, multimap.containsKey(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3)));
- assertEquals(value, multimap.remove(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3)));
+ assertEquals(value, multimap.removeMultiKey(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3)));
assertEquals(false, multimap.containsKey(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3)));
assertEquals(size - 1, multimap.size());
- assertEquals(null, multimap.remove(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3)));
+ assertEquals(null, multimap.removeMultiKey(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3)));
assertEquals(false, multimap.containsKey(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3)));
break;
case 5:
assertEquals(true, multimap.containsKey(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3), key.getKey(4)));
- assertEquals(value, multimap.remove(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3), key.getKey(4)));
+ assertEquals(value, multimap.removeMultiKey(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3), key.getKey(4)));
assertEquals(false, multimap.containsKey(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3), key.getKey(4)));
assertEquals(size - 1, multimap.size());
- assertEquals(null, multimap.remove(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3), key.getKey(4)));
+ assertEquals(null, multimap.removeMultiKey(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3), key.getKey(4)));
assertEquals(false, multimap.containsKey(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3), key.getKey(4)));
break;
default:
Loading

0 comments on commit 63d725a

Please sign in to comment.