edu.illinois.keshmesh.detector.tests/src/edu/illinois/keshmesh/detector/tests/vna00j/VNA00JTests.java
public static class VNA00JTest05 extends VNA00JTest {

		@Before
		public void setup() throws Exception {
			setupProjectAndAnalyze("05", "A.java");
String getExpectedUnprotectedInstructionsThatMayAccessUnsafelySharedFields()
edu.illinois.keshmesh.detector.tests/src/edu/illinois/keshmesh/detector/tests/vna00j/VNA00JTests.java
return "[<Application,Lp/A>]";
String getExpectedThreadSafeClasses()
edu.illinois.keshmesh.detector.tests/src/edu/illinois/keshmesh/detector/tests/vna00j/VNA00JTests.java
return "[<Application,Lp/A>]";
String getExpectedThreadSafeClasses()
InstructionInfo instructionInfo  IClassHierarchy classHierarchy
edu.illinois.keshmesh.detector/src/edu/illinois/keshmesh/detector/util/AnalysisUtils.java
if (canBeUnsafelyShared(argumentValueNumber, instructionInfo.getCGNode(), classHierarchy)) {
				return true;
boolean canAnyArgumentBeUnsafelyShared(InstructionInfo instructionInfo, IClassHierarchy classHierarchy)
int valueNumber  CGNode enclosingCGNode  IClassHierarchy classHierarchy
edu.illinois.keshmesh.detector/src/edu/illinois/keshmesh/detector/util/AnalysisUtils.java
DefUse defUse = enclosingCGNode.getDU();
		SSAInstruction defInstruction = defUse.getDef(valueNumber);
		//		if (defInstruction instanceof SSAGetInstruction && !isFinalOrVolatile((SSAFieldAccessInstruction) defInstruction, classHierarchy)) {
		//			return true;
		//
boolean canBeUnsafelyShared(int valueNumber, CGNode enclosingCGNode, IClassHierarchy classHierarchy)
int valueNumber  CGNode enclosingCGNode  IClassHierarchy classHierarchy  boolean isFirstCall
edu.illinois.keshmesh.detector/src/edu/illinois/keshmesh/detector/util/AnalysisUtils.java
int numberOfParametersOfCaller = enclosingCGNode.getMethod().getNumberOfParameters();
		DefUse defUse = enclosingCGNode.getDU();
		if (valueNumber <= numberOfParametersOfCaller) {
			// valueNumber represents a parameter of the enclosing method.
			if (isFirstCall) {
				return true;
boolean isDirectlyOrIndirectlyLocal(int valueNumber, CGNode enclosingCGNode, IClassHierarchy classHierarchy, boolean isFirstCall)
SSAFieldAccessInstruction fieldAccessInstruction  IClassHierarchy classHierarchy
edu.illinois.keshmesh.detector/src/edu/illinois/keshmesh/detector/util/AnalysisUtils.java
IField accessedField = classHierarchy.resolveField(fieldAccessInstruction.getDeclaredField());
		//FIXME: We do not know why it could be null here, e.g. the field sun.security.util.SecurityConstants.GET_CLASSLOADER_PERMISSION 
		//can not be resolved because its class can not be looked up.
		if (accessedField != null) {
			return accessedField.isFinal() || accessedField.isVolatile();
boolean isFinalOrVolatile(SSAFieldAccessInstruction fieldAccessInstruction, IClassHierarchy classHierarchy)
edu.illinois.keshmesh.detector/src/edu/illinois/keshmesh/detector/VNA00JBugDetector.java
Map<CGNode, Collection<InstructionInfo>> intermediateMapOfUnsafeInstructions = null;
			intermediateMapOfUnsafeInstructions = new HashMap<CGNode, Collection<InstructionInfo>>();
			Collection<InstructionInfo> unsafeInstructionsThatAccessUnprotectedFields = new HashSet<InstructionInfo>();
			if (canContainUnsafeAccesses(cgNode.getMethod())) {
				Collection<InstructionInfo> instructionsThatAccessUnprotectedFields = getInstructionsThatAccessUnprotectedFields(cgNode);
				for (InstructionInfo instructionThatAccessesUnprotectedFields : instructionsThatAccessUnprotectedFields) {
					if (!AnalysisUtils.isProtectedByAnySynchronizedBlock(synchronizedBlocks, instructionThatAccessesUnprotectedFields)) {
						unsafeInstructionsThatAccessUnprotectedFields.add(instructionThatAccessesUnprotectedFields);
				for (InstructionInfo instructionThatAccessesUnprotectedFields : instructionsThatAccessUnprotectedFields) {
					Logger.log("MODIFY: " + instructionThatAccessesUnprotectedFields);
				for (InstructionInfo unsafeInstruction : unsafeInstructionsThatAccessUnprotectedFields) {
					bitVector.set(globalValues.add(unsafeInstruction));
					Logger.log("UNSAFE INSTRUCTION: " + unsafeInstruction);
			if (!Modes.isInProductionMode() && intermediateMapOfUnsafeInstructions != null) {
				intermediateMapOfUnsafeInstructions.put(cgNode, unsafeInstructionsThatAccessUnprotectedFields);
			intermediateResults.setUnsafeInstructionsThatAccessUnprotectedFields(intermediateMapOfUnsafeInstructions);
	private boolean canContainUnsafeAccesses(IMethod method) {
	private Collection<InstructionInfo> getInstructionsThatAccessUnprotectedFields(CGNode cgNode) {
		Collection<InstructionInfo> instructionsThatAccessUnprotectedFields = new HashSet<InstructionInfo>();
		IR ir = cgNode.getIR();
		if (ir == null) {
			return instructionsThatAccessUnprotectedFields;
void populateMapOfunsafeInstructionsThatAccessUnprotectedFields()
edu.illinois.keshmesh.detector/src/edu/illinois/keshmesh/detector/VNA00JBugDetector.java
return doesAccessUnprotectedField(defUse, instructionInfo.getInstruction());
		return instructionsThatAccessUnprotectedFields;
	 * @param defUse
	 * @param ssaInstruction
	private boolean doesAccessUnprotectedField(final DefUse defUse, SSAInstruction ssaInstruction) {
			SSAInstruction defInstruction = defUse.getDef(ssaInstruction.getUse(i));
			if (defInstruction instanceof SSAGetInstruction && !isProtected((SSAFieldAccessInstruction) defInstruction)) {
	/**
	 * 
	 * @param fieldAccessInstruction
	 * @return true if the changes to the given field are visible to other
	 *         threads.
	 */
	private boolean isProtected(SSAFieldAccessInstruction fieldAccessInstruction) {
		return isFinal(fieldAccessInstruction) || isVolatile(fieldAccessInstruction);
new InstructionFilter()
SSAFieldAccessInstruction fieldAccessInstruction
edu.illinois.keshmesh.detector/src/edu/illinois/keshmesh/detector/VNA00JBugDetector.java
IField accessedField = basicAnalysisData.classHierarchy.resolveField(fieldAccessInstruction.getDeclaredField());
		return accessedField.isFinal();
boolean isFinal(SSAFieldAccessInstruction fieldAccessInstruction)
SSAFieldAccessInstruction fieldAccessInstruction
edu.illinois.keshmesh.detector/src/edu/illinois/keshmesh/detector/VNA00JBugDetector.java
IField accessedField = basicAnalysisData.classHierarchy.resolveField(fieldAccessInstruction.getDeclaredField());
		return accessedField.isVolatile();
boolean isVolatile(SSAFieldAccessInstruction fieldAccessInstruction)