Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow old 'enum' package to compile and run #585

Merged
merged 3 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions framework/core/Project/Lang.pm
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,21 @@ sub _post_checkout {
Utils::convert_file_encoding($work_dir."/".$result->{src}."/org/apache/commons/lang3/text/translate/EntityArrays.java");
Utils::convert_file_encoding($work_dir."/".$result->{src}."/org/apache/commons/lang/Entities.java");

# remove old pre Java 1.5 code
print($work_dir."/".$result->{src}."/org/apache/commons/lang/enum\n");
rmtree($work_dir."/".$result->{src}."/org/apache/commons/lang/enum");
rmtree($work_dir."/".$result->{test}."/org/apache/commons/lang/enum");
# Some of the Lang tests were created pre Java 1.5 and contain an 'enum' package.
# The is now a reserved word in Java so we covert all references to 'oldenum'.
markro49 marked this conversation as resolved.
Show resolved Hide resolved
my $cmd = "grep -lR '\.enum;' $work_dir'/'$result->{src}'/org/apache/commons/lang/enum/'";
my $log = `$cmd`;
my $ret = $?;
if ($ret == 0 && length($log) > 0) {
Utils::exec_cmd("grep -lR '\.enum;' $work_dir'/'$result->{src}'/org/apache/commons/lang/enum/' | xargs sed -i'' 's/\.enum;/\.oldenum;/'", "Rename enum 1") or die;
}

$cmd = "grep -lR '\.enum;' $work_dir'/'$result->{test}'/org/apache/commons/lang/enum/'";
$log = `$cmd`;
$ret = $?;
if ($ret == 0 && length($log) > 0) {
Utils::exec_cmd("grep -lR '\.enum;' $work_dir'/'$result->{test}'/org/apache/commons/lang/enum/' | xargs sed -i'' 's/\.enum;/\.oldenum;/'", "Rename enum 2") or die;
}

# Fix compilation errors if necessary
my $compile_errors = "$PROJECTS_DIR/$self->{pid}/compile-errors/";
Expand Down
16 changes: 16 additions & 0 deletions framework/projects/Lang/compile-errors/test-65-65.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
index 38d578aba..a0ae9fc73 100644
--- a/src/java/org/apache/commons/lang/enum/ValuedEnum.java
+++ b/src/java/org/apache/commons/lang/enum/ValuedEnum.java
@@ -140,9 +140,9 @@ public abstract class ValuedEnum extends Enum {
}
List list = Enum.getEnumList(enumClass);
for (Iterator it = list.iterator(); it.hasNext();) {
- ValuedEnum enum = (ValuedEnum) it.next();
- if (enum.getValue() == value) {
- return.oldenum;
markro49 marked this conversation as resolved.
Show resolved Hide resolved
+ ValuedEnum enumer = (ValuedEnum) it.next();
+ if (enumer.getValue() == value) {
+ return enumer;
}
}
return null;