8051641: Africa/Casablanca transitions is incorrectly calculated starting from 2027
Reviewed-by: sherman
diff --git a/make/src/classes/build/tools/tzdb/ZoneRulesBuilder.java b/make/src/classes/build/tools/tzdb/ZoneRulesBuilder.java
index f4a437d..2b4f8ad 100644
--- a/make/src/classes/build/tools/tzdb/ZoneRulesBuilder.java
+++ b/make/src/classes/build/tools/tzdb/ZoneRulesBuilder.java
@@ -491,10 +491,10 @@
                 TZRule rule = new TZRule(year, month, dayOfMonthIndicator, dayOfWeek, time, timeEndOfDay, timeDefinition, savingAmountSecs);
                 if (lastRule) {
                     lastRuleList.add(rule);
-                    maxLastRuleStartYear = Math.max(startYear, maxLastRuleStartYear);
                 } else {
                     ruleList.add(rule);
                 }
+                maxLastRuleStartYear = Math.max(startYear, maxLastRuleStartYear);
                 year++;
             }
         }
diff --git a/test/ProblemList.txt b/test/ProblemList.txt
index 93fdaed..25ada7c 100644
--- a/test/ProblemList.txt
+++ b/test/ProblemList.txt
@@ -272,7 +272,4 @@
 # Filed 6772009
 java/util/concurrent/locks/ReentrantLock/CancelledLockLoops.java generic-all
 
-# 8051641
-sun/util/calendar/zi/TestZoneInfo310.java                        generic-all
-
 ############################################################################
diff --git a/test/sun/util/calendar/zi/Rule.java b/test/sun/util/calendar/zi/Rule.java
index ee4df5b..a30f2c0 100644
--- a/test/sun/util/calendar/zi/Rule.java
+++ b/test/sun/util/calendar/zi/Rule.java
@@ -126,6 +126,14 @@
             });
         rules.clear();
         for (int i = 0; i < n; i++) {
+            if (i != 0 && recs[i -1].getSave() == recs[i].getSave()) {
+                // we have two recs back to back with same saving for the same year.
+                if (recs[i].isLastRule()) {
+                    continue;
+                } else if (recs[i - 1].isLastRule()) {
+                    rules.remove(rules.size() - 1);
+                }
+            }
             rules.add(recs[i]);
         }
         return rules;