src.samples.java.ex.MUC_Sample Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fb-contrib Show documentation
Show all versions of fb-contrib Show documentation
An auxiliary findbugs.sourceforge.net plugin for java bug detectors that fall outside the narrow scope of detectors to be packaged with the product itself.
package ex;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class MUC_Sample {
public void testMUC() {
List l = getImmutableList();
l.add("Uhoh");
}
public void testPossiblyMUC() {
Set s = getPossiblyImmutableSet(Math.random() > 0.5);
s.add("Yowsers");
}
public void testMUCChained() {
List l = getImmutableListChained();
l.add("Uhoh");
}
public List getImmutableList() {
return Arrays.asList("foo");
}
public Set getPossiblyImmutableSet(boolean b) {
if (b)
return Collections.unmodifiableSet(new HashSet());
return new HashSet();
}
public List getImmutableListChained() {
return getImmutableList();
}
}