オブジェクトのセキュリティリリース

公開されたオブジェクト:

輸入com.example.annoations.NotThreadSafe。
輸入lombok.extern.slf4j.Slf4j。
輸入java.util.Arrays。

@ SLF4J 
@NotThreadSafe 
パブリッククラスUnsafePublish { 
    プライベート文字列[]の状態= { "A"、 "B"、 "C"}。
    パブリック文字列[] GETSTATESは(){ 
        状態を返します。
    } 

    パブリック静的無効メイン(文字列[] args){ 
        UnsafePublish unsafePublish =新しいUnsafePublish()。
        log.info( "{}"、Arrays.toString(unsafePublish.getStates()))。

        unsafePublish.getStates()[0] = "D"。
        log.info( "{}"、Arrays.toString(unsafePublish.getStates()))。
    } 
}

  

輸入com.example.annoations.NotRecommend。
輸入com.example.annoations.NotThreadSafe。
輸入lombok.extern.slf4j.Slf4j。

@ SLF4J 
@NotThreadSafe 
@NotRecommend 
パブリッククラスエスケープ{ 
      公共のint thisCanBeEscape = 0; 
      公共のエスケープ(){ 
       新しいInnerClass(); 
      } 
      プライベートクラスInnerClass { 
          パブリックInnerClass(){ 
              log.info( "{}"、Escape.this.thisCanBeEscape)。
        } 
    } 

    パブリック静的無効メイン(文字列[] args){ 
        新しいエスケープ()。
    } 
}

  

おすすめ

転載: www.cnblogs.com/sunliyuan/p/11234636.html