Java Coding Guidelines: 75 Recommendations for Reliable and Secure Programs (SEI Series in Software Engineering)

By Fred Long, Dhruv Mohindra, Robert C. Seacord, Dean F. Sutherland, David Svoboda

“A must-read for all Java builders. . . . each developer has a accountability to writer code that's freed from major safety vulnerabilities. This e-book offers sensible counsel to aid Java builders enforce wanted performance with defense, reliability, and maintainability targets in mind.”

–Mary Ann Davidson, leader safeguard Officer, Oracle Corporation 


Organizations around the globe depend on Java code to accomplish mission-critical initiatives, and for this reason that code has to be trustworthy, strong, quick, maintainable, and safe. Java™ Coding Guidelines brings jointly specialist directions, ideas, and code examples that will help you meet those calls for.


Written by means of a similar staff that introduced you The CERT® Oracle ® safe Coding general for Java™, this advisor extends that past work’s specialist safeguard suggestion to handle many extra caliber attributes.


You’ll locate seventy five guidance, every one provided always and intuitively. for every guide, conformance standards are designated; for many, noncompliant code examples and compliant ideas also are provided. The authors clarify whilst to use every one guide and supply references to much more certain info.


Reflecting pioneering study on Java protection, Java™ Coding Guidelines deals up to date options for safeguarding opposed to either planned assaults and different unforeseen occasions. You’ll locate most sensible practices for making improvements to code reliability and readability, and a whole bankruptcy exposing universal misunderstandings that bring about suboptimal code.


With a Foreword through James A. Gosling, Father of the Java Programming Language

Show description

Preview of Java Coding Guidelines: 75 Recommendations for Reliable and Secure Programs (SEI Series in Software Engineering) PDF

Similar Java books

Mastering Lambdas: Java Programming in a Multicore World (Oracle Press)

The Definitive consultant to Lambda Expressions learning Lambdas: Java Programming in a Multicore international describes how the lambda-related beneficial properties of Java SE eight will let Java to satisfy the demanding situations of next-generation parallel architectures. The ebook explains find out how to write lambdas, and the way to exploit them in streams and in assortment processing, supplying code examples all through.

Mastering JavaFX 8 Controls (Oracle Press)

Layout and set up High-Performance JavaFX Controls convey state of the art purposes with visually beautiful UIs. studying JavaFX eight Controls presents transparent directions, particular examples, and ready-to-use code samples. how to paintings with the most recent JavaFX APIs, configure UI elements, instantly generate FXML, construct state-of-the-art controls, and successfully practice CSS styling.

Data Abstraction and Problem Solving with Java: Walls and Mirrors (3rd Edition)

The 3rd variation of information Abstraction and challenge fixing with Java: partitions and Mirrors employs the analogies of partitions (data abstraction) and Mirrors (recursion) to educate Java programming layout strategies, in a fashion that starting scholars locate available. The booklet has a student-friendly pedagogical procedure that conscientiously debts for the strengths and weaknesses of the Java language.

Java Software Solutions: Foundations of Program Design (7th Edition)

Java software program options teaches a starting place of programming ideas to foster well-designed object-oriented software program. Heralded for its integration of small and big reasonable examples, this around the world best-selling textual content emphasizes development sturdy problem-solving and layout talents to jot down top of the range courses.

Additional info for Java Coding Guidelines: 75 Recommendations for Reliable and Secure Programs (SEI Series in Software Engineering)

Show sample text content

10, “Capture Conversion,” and §15. 12. 2. 7, “Inferring style Arguments according to real Arguments” of the JLS for additional info [JLS 2013]. The complexity of the principles that make certain the outcome kind of a conditional expression can lead to accidental style conversions. for that reason, the second one and 3rd operands of every conditional expression must have exact varieties. this advice additionally applies to boxed primitives. Noncompliant Code instance during this noncompliant code instance, the programmer expects that either print statements will print the worth of alpha as a char: click on the following to view code photograph * * * public category Expr { public static void main(String[] args) { char alpha = 'A'; int i = zero; // different code. worth of i could switch boolean trueExp = actual; // Expression that evaluates to real procedure. out. print(trueExp ? alpha : 0); // Prints A process. out. print(trueExp ? alpha : i); // Prints sixty five } } * * * the 1st print assertion prints A as the compiler applies rule eight from the outcome kind decision desk to figure out that the second one and 3rd operands of the conditional expression are, or are switched over to, variety char. notwithstanding, the second one print assertion prints 65—the price of alpha as an int. the 1st matching rule from the desk is rule 10. accordingly, the compiler promotes the price of alpha to variety int. Compliant resolution This compliant resolution makes use of exact varieties for the second one and 3rd operands of every conditional expression; the specific casts specify the sort anticipated via the programmer: click on the following to view code photograph * * * public classification Expr { public static void main(String[] args) { char alpha = 'A'; int i = zero; boolean trueExp = real; // Expression that evaluates to actual process. out. print(trueExp ? alpha : 0); // Prints A // planned narrowing solid of i; attainable truncation okay process. out. print(trueExp ? alpha : ((char) i)); // Prints A } } * * * while the worth of i within the moment conditional expression falls open air the variety that may be represented as a char, the specific forged will truncate its price. This utilization complies with exception NUM12-EX0 of NUM12-J, “Ensure conversions of numeric varieties to narrower kinds don't lead to misplaced or misinterpreted information” within the CERT® Oracle® safe Coding general for Java™ [Long 2012]. Noncompliant Code instance This noncompliant code instance prints a hundred because the measurement of the HashSet instead of the anticipated end result (some price among zero and 50): click on the following to view code picture * * * public category ShortSet { public static void main(String[] args) { HashSet s = new HashSet(); for (short i = zero; i < a hundred; i++) { s. add(i); // forged of i-1 is secure, // simply because price is usually representable brief workingVal = (short) (i-1); // ... different code may possibly replace workingVal s. remove(((i % 2) == 1) ? i-1 : workingVal); } procedure. out. println(s. size()); } } * * * the combo of values of varieties brief and int within the moment argument of the conditional expression (the operation i-1) factors the outcome to be an int, as laid out in the integer advertising ideas.

Download PDF sample

Rated 4.69 of 5 – based on 47 votes