mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-21 21:52:10 +02:00
Don't synchronize on Boolean/Integer object
This fixes numerous warnings like this: Boolean is a value-based type which is a discouraged argument for the synchronized statement and: Integer is a value-based type which is a discouraged argument for the synchronized statement
This commit is contained in:
parent
161b57f9ed
commit
3b3f29c93a
4 changed files with 8 additions and 15 deletions
|
@ -217,7 +217,7 @@ public class GDBRemoteTracepointsTest extends BaseParametrizedTestCase {
|
||||||
// *********************************************************************
|
// *********************************************************************
|
||||||
// Below are utility methods.
|
// Below are utility methods.
|
||||||
// *********************************************************************
|
// *********************************************************************
|
||||||
private static Boolean lock = true;
|
private static Object lock = new Object();
|
||||||
|
|
||||||
enum Events {
|
enum Events {
|
||||||
BP_ADDED, BP_UPDATED, BP_REMOVED, BP_HIT
|
BP_ADDED, BP_UPDATED, BP_REMOVED, BP_HIT
|
||||||
|
|
|
@ -109,7 +109,7 @@ public class MIBreakpointsTest extends BaseParametrizedTestCase {
|
||||||
protected IExpressions fExpressionService;
|
protected IExpressions fExpressionService;
|
||||||
protected IGDBControl fCommandControl;
|
protected IGDBControl fCommandControl;
|
||||||
// Event Management
|
// Event Management
|
||||||
protected static Boolean lock = true;
|
protected static Object lock = new Object();
|
||||||
|
|
||||||
protected enum Events {
|
protected enum Events {
|
||||||
BP_ADDED, BP_UPDATED, BP_REMOVED, BP_HIT, WP_HIT, WP_OOS
|
BP_ADDED, BP_UPDATED, BP_REMOVED, BP_HIT, WP_HIT, WP_OOS
|
||||||
|
|
|
@ -104,7 +104,7 @@ public class MICatchpointsTest extends BaseParametrizedTestCase {
|
||||||
private IExpressions fExpressionService;
|
private IExpressions fExpressionService;
|
||||||
|
|
||||||
// Event Management
|
// Event Management
|
||||||
private static Boolean fEventHandlerLock = true;
|
private static Object fEventHandlerLock = new Object();
|
||||||
|
|
||||||
private enum Events {
|
private enum Events {
|
||||||
BP_ADDED, BP_UPDATED, BP_REMOVED, BP_HIT
|
BP_ADDED, BP_UPDATED, BP_REMOVED, BP_HIT
|
||||||
|
|
|
@ -25,6 +25,7 @@ import static org.junit.Assert.assertEquals;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.ByteOrder;
|
import java.nio.ByteOrder;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.IAddress;
|
import org.eclipse.cdt.core.IAddress;
|
||||||
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
||||||
|
@ -86,7 +87,7 @@ public class MIMemoryTest extends BaseParametrizedTestCase {
|
||||||
// Keeps track of the MemoryChangedEvents
|
// Keeps track of the MemoryChangedEvents
|
||||||
private final int BLOCK_SIZE = 256;
|
private final int BLOCK_SIZE = 256;
|
||||||
private IAddress fBaseAddress;
|
private IAddress fBaseAddress;
|
||||||
private Integer fMemoryChangedEventCount = 0;
|
private AtomicInteger fMemoryChangedEventCount = new AtomicInteger(0);
|
||||||
private boolean[] fMemoryAddressesChanged = new boolean[BLOCK_SIZE];
|
private boolean[] fMemoryAddressesChanged = new boolean[BLOCK_SIZE];
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
|
@ -168,9 +169,7 @@ public class MIMemoryTest extends BaseParametrizedTestCase {
|
||||||
*/
|
*/
|
||||||
@DsfServiceEventHandler
|
@DsfServiceEventHandler
|
||||||
public void eventDispatched(IMemoryChangedEvent e) {
|
public void eventDispatched(IMemoryChangedEvent e) {
|
||||||
synchronized (fMemoryChangedEventCount) {
|
fMemoryChangedEventCount.incrementAndGet();
|
||||||
fMemoryChangedEventCount++;
|
|
||||||
}
|
|
||||||
IAddress[] addresses = e.getAddresses();
|
IAddress[] addresses = e.getAddresses();
|
||||||
for (int i = 0; i < addresses.length; i++) {
|
for (int i = 0; i < addresses.length; i++) {
|
||||||
int offset = Math.abs(addresses[i].distanceTo(fBaseAddress).intValue());
|
int offset = Math.abs(addresses[i].distanceTo(fBaseAddress).intValue());
|
||||||
|
@ -183,9 +182,7 @@ public class MIMemoryTest extends BaseParametrizedTestCase {
|
||||||
|
|
||||||
// Clears the counters
|
// Clears the counters
|
||||||
private void clearEventCounters() {
|
private void clearEventCounters() {
|
||||||
synchronized (fMemoryChangedEventCount) {
|
fMemoryChangedEventCount.set(0);
|
||||||
fMemoryChangedEventCount = 0;
|
|
||||||
}
|
|
||||||
synchronized (fMemoryAddressesChanged) {
|
synchronized (fMemoryAddressesChanged) {
|
||||||
for (int i = 0; i < BLOCK_SIZE; i++)
|
for (int i = 0; i < BLOCK_SIZE; i++)
|
||||||
fMemoryAddressesChanged[i] = false;
|
fMemoryAddressesChanged[i] = false;
|
||||||
|
@ -194,11 +191,7 @@ public class MIMemoryTest extends BaseParametrizedTestCase {
|
||||||
|
|
||||||
// Returns the total number of events received
|
// Returns the total number of events received
|
||||||
private int getEventCount() {
|
private int getEventCount() {
|
||||||
int count;
|
return fMemoryChangedEventCount.get();
|
||||||
synchronized (fMemoryChangedEventCount) {
|
|
||||||
count = fMemoryChangedEventCount;
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the number of distinct addresses reported
|
// Returns the number of distinct addresses reported
|
||||||
|
|
Loading…
Add table
Reference in a new issue