Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

In this noncompliant code example, multiple threads can invoke the setValues() method to set the a and b fields. Because this class fails to test for integer overflow, users of the Adder class must ensure that the arguments to the setValues() method can be added without overflow. (For more information, see rule NUM00 NUM16-J. Detect or prevent integer overflow.)

Code Block
bgColor#FFcccc
final class Adder {
  private int a;
  private int b;

  public int getSum() {
    return a + b;
  }

  public void setValues(int a, int b) {
    this.a = a;
    this.b = b;
  }
}

...

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="bce8131a75f67870-23bb1e41-49dc4b2e-9b75a7bb-4d3dc438397b968dfc6d0dc4"><ac:plain-text-body><![CDATA[

[[API 2006

AA. Bibliography#API 06]]

Class AtomicInteger

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="2b2e318dc23b3804-f7ae54c9-49644f6f-b293b168-2d7c4552853a5b138a57ac59"><ac:plain-text-body><![CDATA[

[[Bloch 2008

AA. Bibliography#Bloch 08]]

Item 66: Synchronize access to shared mutable data

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="d22ce3cc9e664b85-b29fe472-41c247cf-8a37b314-c704e3681baeb7513390aea8"><ac:plain-text-body><![CDATA[

[[Goetz 2006

AA. Bibliography#Goetz 06]]

2.3. "Locking"

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="905ac392a597400b-4c661b9b-46894d98-8ee28b59-3ddf7668387e0876746ffb00"><ac:plain-text-body><![CDATA[

[[JLS 2005

AA. Bibliography#JLS 05]]

[Chapter 17 Threads and Locks

http://java.sun.com/docs/books/jls/third_edition/html/memory.html], ]]></ac:plain-text-body></ac:structured-macro>

 

Section 17.4.5 Happens-Before Order

 

Section 17.4.3 Programs and Program Order

 

Section 17.4.8 Executions and Causality Requirements

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="3e7d74ff6275d966-a7192bb4-41314f35-b60fbbb2-9c1e50c4052bc23bf5c88b30"><ac:plain-text-body><![CDATA[

[[Lea 2000

AA. Bibliography#Lea 00]]

Section 2.2.7 The Java Memory Model

]]></ac:plain-text-body></ac:structured-macro>

 

Section 2.1.1.1 Objects and Locks

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="59c8efec334b1732-84d4bb4a-45234b83-ac8cab20-67bfb5d264eeed858794dab5"><ac:plain-text-body><![CDATA[

[[Tutorials 2008

AA. Bibliography#Tutorials 08]]

[Java Concurrency Tutorial

http://java.sun.com/docs/books/tutorial/essential/concurrency/index.html]

]]></ac:plain-text-body></ac:structured-macro>

...