DominatorsAnalysis dominators = classContext.getNonExceptionDominatorsAnalysis(method); PatternElementMatch createBegin = match.getFirstLabeledMatch("createObject"); PatternElementMatch store = match.getFirstLabeledMatch("end"); BitSet storeDominators = dominators.getStartFact(store.getBasicBlock()); if (!storeDominators.get(createBegin.getBasicBlock().getId())) return;
if (CHECK_PROPER_OBJECT_CREATION) {    DominatorsAnalysis dominators = classContext.getNonExceptionDominatorsAnalysis(method); PatternElementMatch createBegin = match.getFirstLabeledMatch("createObject"); PatternElementMatch store = match.getFirstLabeledMatch("end"); BitSet storeDominators = dominators.getStartFact(store.getBasicBlock()); if (!storeDominators.get(createBegin.getBasicBlock().getId())) return; }
	public void reportMatch(ClassContext classContext, Method method, ByteCodePatternMatch match)		throws CFGBuilderException, DataflowAnalysisException {		JavaClass javaClass = classContext.getJavaClass();		MethodGen methodGen = classContext.getMethodGen(method);		try {			// Get the variable referenced in the pattern instance.			BindingSet bindingSet = match.getBindingSet();			Binding binding = bindingSet.lookup("f");			// Look up the field as an XField.			// If it is volatile, then the instance is not a bug.			FieldVariable field = (FieldVariable) binding.getVariable();			XField xfield =				Hierarchy.findXField(field.getClassName(), field.getFieldName(), field.getFieldSig());			if (xfield == null || (xfield.getAccessFlags() & Constants.ACC_VOLATILE) != 0)				return;			// XXX: for now, ignore lazy initialization of instance fields			if (!xfield.isStatic())				return;			// Examine the lock sets for all matched instructions.			// If the intersection is nonempty, then there was at			// least one lock held for the entire sequence.			LockDataflow lockDataflow = classContext.getLockDataflow(method);			LockSet lockSet = null;			boolean sawNEW = false, sawINVOKE = false;			for (Iterator<PatternElementMatch> i = match.patternElementMatchIterator(); i.hasNext(); ) {				PatternElementMatch element = i.next();				InstructionHandle handle = element.getMatchedInstructionInstructionHandle();				Location location = new Location(handle, element.getBasicBlock());				// Keep track of whether we saw any instructions				// that might actually have created a new object.				Instruction ins = handle.getInstruction();				if (ins instanceof NEW)					sawNEW = true;				else if (ins instanceof InvokeInstruction)					sawINVOKE = true;				// Compute lock set intersection for all matched instructions.				LockSet insLockSet = lockDataflow.getFactAtLocation(location);				if (lockSet == null) {					lockSet = new LockSet();					lockSet.copyFrom(insLockSet);				} else					lockSet.intersectWith(insLockSet);			}			if (!lockSet.isEmpty())				return;			// If the instruction sequence did not contain a NEW instruction			// or any Invoke instructions, then a new object was not created.			if (!(sawNEW || sawINVOKE))				return;			// The first instruction in the "create object" sequence			// must dominate the Store of the created object (disregarding			// exception edges).			DominatorsAnalysis dominators = classContext.getNonExceptionDominatorsAnalysis(method);			PatternElementMatch createBegin = match.getFirstLabeledMatch("createObject");			PatternElementMatch store = match.getFirstLabeledMatch("end");			BitSet storeDominators = dominators.getStartFact(store.getBasicBlock());			if (!storeDominators.get(createBegin.getBasicBlock().getId()))				return;			// Compute the priority:			//  - ignore lazy initialization of instance fields			//  - when it's done in a public method, emit a high priority warning			//  - protected or default access method, emit a medium priority warning			//  - otherwise, low priority			int priority = LOW_PRIORITY;			boolean isDefaultAccess =				(method.getAccessFlags() & (Constants.ACC_PUBLIC|Constants.ACC_PRIVATE|Constants.ACC_PROTECTED)) == 0;			if (method.isPublic())				priority = HIGH_PRIORITY;			else if (method.isProtected() || isDefaultAccess)				priority = NORMAL_PRIORITY;			// Report the bug.			InstructionHandle start = match.getLabeledInstruction("start");			InstructionHandle end   = match.getLabeledInstruction("end");			String sourceFile = javaClass.getSourceFileName();			bugReporter.reportBug(new BugInstance("LI_LAZY_INIT_STATIC", priority)				.addClassAndMethod(methodGen, sourceFile)				.addField(xfield).describe("FIELD_ON")				.addSourceLine(methodGen, sourceFile, start, end));		} catch (ClassNotFoundException e) {			bugReporter.reportMissingClass(e);			return;		}	}