O'Reilly logo

Java™ Coding Guidelines: 75 Recommendations for Reliable and Secure Programs by David Svoboda, Dean F. Sutherland, Robert C. Seacord, Dhruv Mohindra, Fred Long

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 5. Programmer Misconceptions

The guidelines in this chapter address areas where developers often make unwarranted assumptions about Java language and library behaviors, or where ambiguities can easily be introduced. Failure to follow these guidelines can result in programs that produce counterintuitive results.

This chapter contains guidelines that address

1. Misconceptions about Java APIs and language features

2. Assumptions and ambiguity-laced programs

3. Situations in which the programmer wanted to do one thing but ended up doing another

66. Do not assume that declaring a reference volatile guarantees safe publication of the members of the referenced object

According to the Java Language Specification (JLS), §8.3.1.4, “volatile Fields” ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required