Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8255299: Drop explicit zeroing at instantiation of Atomic* objects
Reviewed-by: redestad, serb, prr
  • Loading branch information
stsypanov authored and dfuch committed Oct 28, 2020
1 parent 6b2d11b commit 3c4fc79
Show file tree
Hide file tree
Showing 17 changed files with 16 additions and 19 deletions.
Expand Up @@ -87,7 +87,7 @@
private static final String[] EMPTY_STRING_ARRAY = new String[0];

// Used to ensure that each spun class name is unique
private static final AtomicInteger counter = new AtomicInteger(0);
private static final AtomicInteger counter = new AtomicInteger();

// For dumping generated classes to disk, for debugging purposes
private static final ProxyClassesDumper dumper;
Expand Down
2 changes: 1 addition & 1 deletion src/java.base/share/classes/java/util/Timer.java
Expand Up @@ -120,7 +120,7 @@ protected void finalize() throws Throwable {
/**
* This ID is used to generate thread names.
*/
private static final AtomicInteger nextSerialNumber = new AtomicInteger(0);
private static final AtomicInteger nextSerialNumber = new AtomicInteger();
private static int serialNumber() {
return nextSerialNumber.getAndIncrement();
}
Expand Down
Expand Up @@ -68,7 +68,7 @@ abstract class AbstractShortCircuitTask<P_IN, P_OUT, R,
protected AbstractShortCircuitTask(PipelineHelper<P_OUT> helper,
Spliterator<P_IN> spliterator) {
super(helper, spliterator);
sharedResult = new AtomicReference<>(null);
sharedResult = new AtomicReference<>();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/java.base/share/classes/sun/net/ResourceManager.java
Expand Up @@ -62,7 +62,7 @@ public class ResourceManager {
}
} catch (NumberFormatException e) {}
maxSockets = defmax;
numSockets = new AtomicInteger(0);
numSockets = new AtomicInteger();
}

public static void beforeUdpCreate() throws SocketException {
Expand Down
2 changes: 1 addition & 1 deletion src/java.desktop/share/classes/java/awt/EventQueue.java
Expand Up @@ -95,7 +95,7 @@
* @since 1.1
*/
public class EventQueue {
private static final AtomicInteger threadInitNumber = new AtomicInteger(0);
private static final AtomicInteger threadInitNumber = new AtomicInteger();

private static final int LOW_PRIORITY = 0;
private static final int NORM_PRIORITY = 1;
Expand Down
2 changes: 1 addition & 1 deletion src/java.desktop/share/classes/javax/swing/TimerQueue.java
Expand Up @@ -248,7 +248,7 @@ static class DelayedTimer implements Delayed {
* Sequence number to break scheduling ties, and in turn to
* guarantee FIFO order among tied entries.
*/
private static final AtomicLong sequencer = new AtomicLong(0);
private static final AtomicLong sequencer = new AtomicLong();

/** Sequence number to break ties FIFO */
private final long sequenceNumber;
Expand Down
2 changes: 1 addition & 1 deletion src/java.desktop/share/classes/sun/awt/AppContext.java
Expand Up @@ -208,7 +208,7 @@ public boolean isDisposed() {
* number is 1. If so, it returns the sole AppContext without
* checking Thread.currentThread().
*/
private static final AtomicInteger numAppContexts = new AtomicInteger(0);
private static final AtomicInteger numAppContexts = new AtomicInteger();


/*
Expand Down
Expand Up @@ -72,7 +72,7 @@

public class LogRecord implements java.io.Serializable {
private static final AtomicLong globalSequenceNumber
= new AtomicLong(0);
= new AtomicLong();

/**
* Logging message level
Expand Down
Expand Up @@ -39,7 +39,7 @@ abstract class WindowUpdateSender {

final int limit;
final Http2Connection connection;
final AtomicInteger received = new AtomicInteger(0);
final AtomicInteger received = new AtomicInteger();

WindowUpdateSender(Http2Connection connection) {
this(connection, connection.clientSettings.getParameter(SettingsFrame.INITIAL_WINDOW_SIZE));
Expand Down
Expand Up @@ -375,7 +375,7 @@ void stop() {
scheduler.stop();
}

AtomicInteger count = new AtomicInteger(0);
AtomicInteger count = new AtomicInteger();

// minimum number of bytes required to call unwrap.
// Usually this is 0, unless there was a buffer underflow.
Expand Down
Expand Up @@ -74,7 +74,7 @@ public enum SchedulingAction { CONTINUE, RETURN, RESCHEDULE }
private final CompletableFuture<Void> cf;
private final SequentialScheduler pushScheduler;
private final AtomicReference<Throwable> errorRef = new AtomicReference<>();
final AtomicLong upstreamWindow = new AtomicLong(0);
final AtomicLong upstreamWindow = new AtomicLong();

/**
* Wraps the given downstream subscriber. For each call to {@link
Expand Down
2 changes: 1 addition & 1 deletion src/java.rmi/share/classes/java/rmi/server/ObjID.java
Expand Up @@ -84,7 +84,7 @@ public final class ObjID implements Serializable {
/** indicate compatibility with JDK 1.1.x version of class */
private static final long serialVersionUID = -6386392263968365220L;

private static final AtomicLong nextObjNum = new AtomicLong(0);
private static final AtomicLong nextObjNum = new AtomicLong();
private static final UID mySpace = new UID();
private static final SecureRandom secureRandom = new SecureRandom();

Expand Down
3 changes: 1 addition & 2 deletions src/java.rmi/share/classes/sun/rmi/runtime/RuntimeUtil.java
Expand Up @@ -30,7 +30,6 @@
import java.security.PrivilegedAction;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Level;

Expand Down Expand Up @@ -70,7 +69,7 @@ private RuntimeUtil() {
scheduler = new ScheduledThreadPoolExecutor(
schedulerThreads,
new ThreadFactory() {
private final AtomicInteger count = new AtomicInteger(0);
private final AtomicInteger count = new AtomicInteger();
public Thread newThread(Runnable runnable) {
try {
return AccessController.doPrivileged(
Expand Down
Expand Up @@ -128,8 +128,6 @@ public class UnicastServerRef extends UnicastRef
private static final Map<Class<?>,?> withoutSkeletons =
Collections.synchronizedMap(new WeakHashMap<Class<?>,Void>());

private final AtomicInteger methodCallIDCount = new AtomicInteger(0);

/**
* Create a new (empty) Unicast server remote reference.
* The filter is null to defer to the default ObjectInputStream filter, if any.
Expand Down
Expand Up @@ -115,7 +115,7 @@ public Thread newThread(Runnable runnable) {
});

/** total connections handled */
private static final AtomicInteger connectionCount = new AtomicInteger(0);
private static final AtomicInteger connectionCount = new AtomicInteger();

/** client host for the current thread's connection */
private static final ThreadLocal<ConnectionHandler>
Expand Down
Expand Up @@ -48,7 +48,7 @@
* an event stream.
*/
abstract class AbstractEventStream implements EventStream {
private final static AtomicLong counter = new AtomicLong(0);
private final static AtomicLong counter = new AtomicLong();

private final Object terminated = new Object();
private final Runnable flushOperation = () -> dispatcher().runFlushActions();
Expand Down
Expand Up @@ -32,7 +32,7 @@

public final class ThrowableTracer {

private static final AtomicLong numThrowables = new AtomicLong(0);
private static final AtomicLong numThrowables = new AtomicLong();

public static void traceError(Error e, String message) {
if (e instanceof OutOfMemoryError) {
Expand Down

1 comment on commit 3c4fc79

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented on 3c4fc79 Oct 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.