JDK-8148570 : TzdbZoneRulesCompiler.java throws Null Pointer Exception While Compiling and building TZDB data file
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.time
  • Affected Version: 9
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2016-01-29
  • Updated: 2016-06-13
  • Resolved: 2016-02-09
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9 b106Fixed
Related Reports
Relates :  
Relates :  
Description
While Compiling the tzdata2016a the below NPE is thrown:
java.lang.NullPointerException
                at build.tools.tzdb.ZoneRules.writeRule(ZoneRules.java:235)
                at build.tools.tzdb.ZoneRules.writeExternal(ZoneRules.java:186)
                at build.tools.tzdb.TzdbZoneRulesCompiler.outputFile(TzdbZoneRulesCompiler.java:266)
                at build.tools.tzdb.TzdbZoneRulesCompiler.compile(TzdbZoneRulesCompiler.java:217)
                at build.tools.tzdb.TzdbZoneRulesCompiler.main(TzdbZoneRulesCompiler.java:89)
 
It fails for the below Transition Rules:
TransitionRule[Gap +03:30 to +04:30, MARCH 21 at 00:00 WALL, standard offset +03:30]
TransitionRule[Overlap +04:30 to +03:30, SEPTEMBER 21 at 00:00 WALL, standard offset +03:30]
which corresponds to:
Rule       Iran        2036       max       -              Mar        21           0:00        1:00        D
Rule       Iran        2036       max       -              Sep        21           0:00        0              S

 
Obviously, ZoneRules.java:235 lacks null check for the DayOfWeek field of ZoneOffsetTransitionRule.
 
As per the ZoneOffsetTransitionRule constructor definition: 
"@param dayOfWeek  the required day-of-week, null if the month-day should not be changed"
 
All other parameters are "not null", so need for the null check while reading and writing those.
 
Solution: Before getting day-of-week value(an integer value from 1 to 7) from DayOfWeek field of  ZoneOffsetTransitionRule a null check is necessary in ZoneRules.java line no. 235