<dd id="sga4y"><optgroup id="sga4y"></optgroup></dd>
<nav id="sga4y"><code id="sga4y"></code></nav>
  • <optgroup id="sga4y"></optgroup>

    Immutable Classes: Public Mutable Fields

    ABSTRACT

    被注釋為不可變,但是字段 public 和可變。

    EXPLANATION

    此類帶有來自 JCIP 注釋包的“不可變”注釋。可變類型的公共字段允許類的外部代碼修改該類的內容和違反其不可變性。

    例 1:不可變最終類的下列代碼錯誤地將集聲明為 publicfinal


    @Immutable
    public final class ThreeStooges {
    public final Set stooges = new HashSet();
    ...
    }

    REFERENCES

    [1] Standards Mapping - Common Weakness Enumeration - (CWE) CWE ID 471

    [2] B. Goetz Java Concurrency in Practice.Chapter 3:Sharing Objects Guidelines

    [3] Package net.jcip.annotations Specification


    Copyright 2013 Fortify Software - All rights reserved.
    (Generated from version 2013.1.1.0008 of the Fortify Secure Coding Rulepacks)
    desc.structural.java.immutable_public_mutable_fields

    97av