...
Code Block | ||
---|---|---|
| ||
class Modifiable { private List<Integer>List<Integer> list = new ArrayList<Integer>ArrayList<Integer>(); public void listIt() { addSomething(list); // ... } private void addSomething(Collection<Integer>Collection<Integer> collection) { collection.add(1); } } |
...
Code Block | ||
---|---|---|
| ||
// ... public void listIt() { addSomething(Collections.unmodifiableCollection(list)); // ... } private void addSomething(Collection<Integer>Collection<Integer> collection) { collection.add(1); // throws java.lang.UnsupportedOperationException } |
...
SEC00-J. Follow the principle of least privilege 02. Platform Security (SEC) SEC02-J. Do not expose standard APIs that may bypass Security Manager checks to untrusted code