Skip to content

Commit

Permalink
Fix MissingOverride findings.
Browse files Browse the repository at this point in the history
It looks like some of these would have been handled by cl/232004516, which covered only mainline files.

Also, carry over a mainline-only `NullPointerTester` test from cl/412110543.

RELNOTES=n/a
PiperOrigin-RevId: 641983632
  • Loading branch information
cpovirk authored and Google Java Core Libraries committed Jun 10, 2024
1 parent 9ea6816 commit e0e44b5
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ public void testAwaitDone_FinalizationPredicate() {
map.put(new Object(), Boolean.TRUE);
GcFinalization.awaitDone(
new FinalizationPredicate() {
@Override
public boolean isDone() {
return map.isEmpty();
}
Expand All @@ -119,6 +120,7 @@ class Interruptenator extends Thread {
Interruptenator(final Thread interruptee, final AtomicBoolean shutdown) {
super(
new Runnable() {
@Override
public void run() {
while (!shutdown.get()) {
interruptee.interrupt();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class ToStringHelperBenchmark {

enum Dataset {
SMALL {
@Override
void addEntries(MoreObjects.ToStringHelper helper) {
helper
.add(SHORT_NAME, 10)
Expand All @@ -47,6 +48,7 @@ void addEntries(MoreObjects.ToStringHelper helper) {
}
},
CONDITIONAL {
@Override
void addEntries(MoreObjects.ToStringHelper helper) {
helper
.add(SHORT_NAME, "x")
Expand Down Expand Up @@ -82,6 +84,7 @@ void addEntries(MoreObjects.ToStringHelper helper) {
}
},
UNCONDITIONAL {
@Override
void addEntries(MoreObjects.ToStringHelper helper) {
helper
.add(SHORT_NAME, false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public void testFinalizeReferentCalled() {

GcFinalization.awaitDone(
new GcFinalization.FinalizationPredicate() {
@Override
public boolean isDone() {
return reference.finalizeReferentCalled;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@

import static org.junit.Assert.assertThrows;

import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.J2ktIncompatible;
import com.google.common.testing.NullPointerTester;
import java.util.Arrays;

/** Unit test for {@link AtomicDoubleArray}. */
Expand Down Expand Up @@ -50,6 +53,14 @@ static void assertBitEquals(double x, double y) {
assertEquals(Double.doubleToRawLongBits(x), Double.doubleToRawLongBits(y));
}

@J2ktIncompatible
@GwtIncompatible // NullPointerTester
public void testNulls() {
new NullPointerTester().testAllPublicStaticMethods(AtomicDoubleArray.class);
new NullPointerTester().testAllPublicConstructors(AtomicDoubleArray.class);
new NullPointerTester().testAllPublicInstanceMethods(new AtomicDoubleArray(1));
}

/** constructor creates array of given size with all elements zero */
public void testConstructor() {
AtomicDoubleArray aa = new AtomicDoubleArray(SIZE);
Expand Down Expand Up @@ -149,6 +160,7 @@ public void testCompareAndSetInMultipleThreads() throws InterruptedException {
Thread t =
newStartedThread(
new CheckedRunnable() {
@Override
public void realRun() {
while (!a.compareAndSet(0, 2.0, 3.0)) {
Thread.yield();
Expand All @@ -171,7 +183,8 @@ public void testWeakCompareAndSet() {
assertBitEquals(prev, aa.get(i));
assertFalse(aa.weakCompareAndSet(i, unused, x));
assertBitEquals(prev, aa.get(i));
while (!aa.weakCompareAndSet(i, prev, x)) {;
while (!aa.weakCompareAndSet(i, prev, x)) {
;
}
assertBitEquals(x, aa.get(i));
prev = x;
Expand Down Expand Up @@ -231,6 +244,7 @@ class Counter extends CheckedRunnable {
aa = a;
}

@Override
public void realRun() {
for (; ; ) {
boolean done = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ public void testCompareAndSetInMultipleThreads() throws Exception {
Thread t =
newStartedThread(
new CheckedRunnable() {
@Override
public void realRun() {
while (!at.compareAndSet(2.0, 3.0)) {
Thread.yield();
Expand All @@ -122,7 +123,8 @@ public void testWeakCompareAndSet() {
assertBitEquals(prev, at.get());
assertFalse(at.weakCompareAndSet(unused, x));
assertBitEquals(prev, at.get());
while (!at.weakCompareAndSet(prev, x)) {;
while (!at.weakCompareAndSet(prev, x)) {
;
}
assertBitEquals(x, at.get());
prev = x;
Expand Down
Loading

0 comments on commit e0e44b5

Please sign in to comment.