changeset 60402:b0a24ee540a3

8233048: WeekFields.ISO is not a singleton Reviewed-by: joehw, rriggs, scolebourne
author naoto
date Fri, 31 Jul 2020 09:09:53 -0700
parents 35ddb4acb1e8
children 059df93c90a4
files src/java.base/share/classes/java/time/temporal/WeekFields.java test/jdk/java/time/test/java/time/temporal/TestIsoWeekFields.java
diffstat 2 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/java/time/temporal/WeekFields.java	Fri Jul 31 12:05:55 2020 -0400
+++ b/src/java.base/share/classes/java/time/temporal/WeekFields.java	Fri Jul 31 09:09:53 2020 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -210,7 +210,7 @@
      * Note also that the first few days of a calendar year may be in the
      * week-based-year corresponding to the previous calendar year.
      */
-    public static final WeekFields ISO = new WeekFields(DayOfWeek.MONDAY, 4);
+    public static final WeekFields ISO = WeekFields.of(DayOfWeek.MONDAY, 4);
 
     /**
      * The common definition of a week that starts on Sunday and the first week
--- a/test/jdk/java/time/test/java/time/temporal/TestIsoWeekFields.java	Fri Jul 31 12:05:55 2020 -0400
+++ b/test/jdk/java/time/test/java/time/temporal/TestIsoWeekFields.java	Fri Jul 31 09:09:53 2020 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,9 @@
 
 import static java.time.temporal.ChronoField.DAY_OF_WEEK;
 import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
 
+import java.time.DayOfWeek;
 import java.time.LocalDate;
 import java.time.LocalTime;
 import java.time.MonthDay;
@@ -281,6 +283,11 @@
         }
     }
 
+    @Test
+    public void test_ISOSingleton() {
+        assertTrue(WeekFields.ISO == WeekFields.of(DayOfWeek.MONDAY, 4));
+    }
+
     private int wbyLen(int wby) {
         return (wby == 2004 || wby == 2009 || wby == 2015 || wby == 2020 ? 53 : 52);
     }