Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8066571

UnsupportedTemporalTypeException is thrown not only in the case of unsupported temporal

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b93

      Description

      The spec on the method Temporal plus(long amountToAdd, TemporalUnit unit) says:

      http://download.java.net/jdk9/docs/api/java/time/temporal/Temporal.html#plus-long-java.time.temporal.TemporalUnit-

      that UnsupportedTemporalTypeException is expected in the case if the unit is not supported

      The following test shows that exception can be thrown not only in the case mentioned above:

      public class Test {

          public static void main(String[] args) {
              Temporal temporal = JapaneseDate.now();
              if (IsoFields.WEEK_BASED_YEARS.isSupportedBy(temporal)) {
                  try {
                      temporal.minus(1, IsoFields.WEEK_BASED_YEARS);
                  } catch (UnsupportedTemporalTypeException ute) {
                      System.out.println("We don't expect UnsupportedTemporalTypeException since the temporal unit is supported by the temporal");
                  } catch (Exception ex) {
                      // other exceptions is OK
                  }
              }
          }
      }

      Tests belonging to the JCK9 suite (not yet integrated) will fail due to this issue:

       - api/java_time/temporal/TemporalUnit/index.html#IsSupported

        Attachments

        1. index_IsSupported.jtr
          12 kB
          Nadeesh Tv
        2. Test.java
          0.8 kB
          Olga Strizhenko

          Issue Links

            Activity

              People

              Assignee:
              ntv Nadeesh Tv
              Reporter:
              ostrizhe Olga Strizhenko (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: