<pre id="vvttv"><mark id="vvttv"><progress id="vvttv"></progress></mark></pre>
    <pre id="vvttv"></pre>

      <p id="vvttv"></p>

          <p id="vvttv"></p>

                <p id="vvttv"></p>

                <pre id="vvttv"><cite id="vvttv"><progress id="vvttv"></progress></cite></pre>

                  <output id="vvttv"><dfn id="vvttv"><th id="vvttv"></th></dfn></output>

                    <p id="vvttv"></p>

                    Object Model Violation: Erroneous clone() Method

                    ABSTRACT

                    方法 clone() 應調用 super.clone() 獲取新的對象。

                    EXPLANATION

                    在所有實現 clone() 的方法中,應通過調用 super.clone() 來獲取新對象。如果類沒有遵守該約定,那么子類的 clone() 方法將會返回一個錯誤的對象類型。

                    例 1:以下兩個類顯示了由于沒有調用 super.clone() 而產生的 bug。由于 Kibitzer 實現 clone() 的方法的緣故,FancyKibitzer 的克隆方法將會返回類型為 Kibitzer 而非 FancyKibitzer 的對象。


                    public class Kibitzer implements Cloneable {
                    public Object clone() throws CloneNotSupportedException {
                    Object returnMe = new Kibitzer();
                    ...
                    }
                    }

                    public class FancyKibitzer extends Kibitzer
                    implements Cloneable {
                    public Object clone() throws CloneNotSupportedException {
                    Object returnMe = super.clone();
                    ...
                    }
                    }

                    REFERENCES

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


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

                      <pre id="vvttv"><mark id="vvttv"><progress id="vvttv"></progress></mark></pre>
                      <pre id="vvttv"></pre>

                        <p id="vvttv"></p>

                            <p id="vvttv"></p>

                                  <p id="vvttv"></p>

                                  <pre id="vvttv"><cite id="vvttv"><progress id="vvttv"></progress></cite></pre>

                                    <output id="vvttv"><dfn id="vvttv"><th id="vvttv"></th></dfn></output>

                                      <p id="vvttv"></p>

                                      这里只有精品视频