diff --git a/jdk/src/java.logging/share/classes/java/util/logging/LogRecord.java b/jdk/src/java.logging/share/classes/java/util/logging/LogRecord.java index 7cf7aee1eec..4a75c82bcee 100644 --- a/jdk/src/java.logging/share/classes/java/util/logging/LogRecord.java +++ b/jdk/src/java.logging/share/classes/java/util/logging/LogRecord.java @@ -468,12 +468,11 @@ public class LogRecord implements java.io.Serializable { * @implSpec This is equivalent to calling * {@link #getInstant() getInstant().toEpochMilli()}. * - * @deprecated To get the full nanosecond resolution event time, + * @apiNote To get the full nanosecond resolution event time, * use {@link #getInstant()}. * * @see #getInstant() */ - @Deprecated public long getMillis() { return instant.toEpochMilli(); } @@ -487,8 +486,10 @@ public class LogRecord implements java.io.Serializable { * {@link #setInstant(java.time.Instant) * setInstant(Instant.ofEpochMilli(millis))}. * - * @deprecated To set event time with nanosecond resolution, - * use {@link #setInstant(java.time.Instant)}. + * @deprecated LogRecord maintains timestamps with nanosecond resolution, + * using {@link Instant} values. For this reason, + * {@link #setInstant(java.time.Instant) setInstant()} + * should be used in preference to {@code setMillis()}. * * @see #setInstant(java.time.Instant) */ @@ -510,14 +511,23 @@ public class LogRecord implements java.io.Serializable { /** * Sets the instant that the event occurred. + *
+ * If the given {@code instant} represents a point on the time-line too
+ * far in the future or past to fit in a {@code long} milliseconds and
+ * nanoseconds adjustment, then an {@code ArithmeticException} will be
+ * thrown.
*
* @param instant the instant that the event occurred.
*
* @throws NullPointerException if {@code instant} is null.
+ * @throws ArithmeticException if numeric overflow would occur while
+ * calling {@link Instant#toEpochMilli() instant.toEpochMilli()}.
+ *
* @since 1.9
*/
public void setInstant(Instant instant) {
- this.instant = Objects.requireNonNull(instant);
+ instant.toEpochMilli();
+ this.instant = instant;
}
/**
diff --git a/jdk/test/TEST.groups b/jdk/test/TEST.groups
index fcb5f56d081..0600a4c8345 100644
--- a/jdk/test/TEST.groups
+++ b/jdk/test/TEST.groups
@@ -30,6 +30,7 @@ tier1 = \
-java/lang/ProcessHandle/TreeTest.java \
-java/util/zip/TestLocalTime.java \
:jdk_util \
+ -java/util/WeakHashMap/GCDuringIteration.java \
-java/util/concurrent/Phaser/Basic.java \
sun/nio/cs/ISO8859x.java \
java/nio/Buffer \
@@ -40,6 +41,7 @@ tier2 = \
java/lang/ProcessHandle/TreeTest.java \
java/util/zip/TestLocalTime.java \
java/util/concurrent/Phaser/Basic.java \
+ java/util/WeakHashMap/GCDuringIteration.java \
:jdk_io \
:jdk_nio \
-sun/nio/cs/ISO8859x.java \
diff --git a/jdk/test/java/util/WeakHashMap/GCDuringIteration.java b/jdk/test/java/util/WeakHashMap/GCDuringIteration.java
index 1492e637980..663947f78b2 100644
--- a/jdk/test/java/util/WeakHashMap/GCDuringIteration.java
+++ b/jdk/test/java/util/WeakHashMap/GCDuringIteration.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2015, 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
@@ -24,13 +24,17 @@
/*
* @test
* @bug 6499848
+ * @library /lib/testlibrary/
+ * @build jdk.testlibrary.RandomFactory
+ * @run main GCDuringIteration
* @summary Check that iterators work properly in the presence of
* concurrent finalization and removal of elements.
- * @key randomness
+ * @key randomness intermittent
*/
import java.util.*;
import java.util.concurrent.CountDownLatch;
+import jdk.testlibrary.RandomFactory;
public class GCDuringIteration {
private static void waitForFinalizersToRun() {
@@ -65,8 +69,9 @@ public class GCDuringIteration {
equal(map.values().iterator().next(), v);
}
+ static final Random rnd = RandomFactory.getRandom();
+
void checkIterator(final Iterator