Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Edited by NavBot

...

Code Block
bgColor#FFcccc
class Modifiable {	
  private List&lt;Integer&gt;List<Integer> list = new ArrayList&lt;Integer&gt;ArrayList<Integer>();

  public void listIt() {
    addSomething(list);
    // ...
  }

  private void addSomething(Collection&lt;Integer&gt;Collection<Integer> collection) {
    collection.add(1); 
  }
}

...

Code Block
bgColor#ccccff
// ...
public void listIt() {
  addSomething(Collections.unmodifiableCollection(list));
  // ...
}

private void addSomething(Collection&lt;Integer&gt;Collection<Integer> collection) {
  collection.add(1); // throws java.lang.UnsupportedOperationException
} 

...

SEC00-J. Follow the principle of least privilege&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;      02. Platform Security (SEC)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;      SEC02-J. Do not expose standard APIs that may bypass Security Manager checks to untrusted code