#vulnerable code 
                             @SuppressWarnings("unchecked")
	@Override
	protected void init() {
		super.init();
		
		int arrayHeaderSize = JvmUtil.getArrayHeaderSize();
		arrayIndexScale = JvmUtil.arrayIndexScale(elementType);
		arrayIndexStartAddress = allocationStartAddress + JvmUtil.arrayBaseOffset(elementType);
		objStartAddress = allocationStartAddress + JvmUtil.sizeOfArray(elementType, length);
		
		// Allocated objects must start aligned as address size from start address of allocated address
		long diffBetweenArrayAndObjectStartAddresses = objStartAddress - allocationStartAddress;
		long addressMod = diffBetweenArrayAndObjectStartAddresses % JvmUtil.getAddressSize();
		if (addressMod != 0) {
			objStartAddress += (JvmUtil.getAddressSize() - addressMod);
		}

		// Copy sample array header to object pool array header
		for (int i = 0; i < arrayHeaderSize; i++) {
			directMemoryService.putByte(allocationStartAddress + i, directMemoryService.getByte(sampleArray, i));
		}
		
		// Set length of array object pool array
		JvmUtil.setArrayLength(allocationStartAddress, elementType, length);

		if (initializeElements) {
			// All index is object pool array header point to allocated objects 
			for (long l = 0; l < length; l++) {
				directMemoryService.putLong(arrayIndexStartAddress + (l * arrayIndexScale), 
						JvmUtil.toJvmAddress((objStartAddress + (l * objectSize))));
			}
	
			long sourceAddress = sampleObjectAddress + 4;
			long copySize = objectSize - 4;
			// Copy sample object to allocated memory region for each object
			for (long l = 0; l < length; l++) {
				long targetAddress = objStartAddress + (l * objectSize);
				directMemoryService.putInt(targetAddress, 0);
				directMemoryService.copyMemory(sourceAddress, targetAddress + 4, copySize);
			}
		}
		else {
			// All index is object pool array header point to allocated objects 
			for (long l = 0; l < length; l++) {
				directMemoryService.putLong(arrayIndexStartAddress + (l * arrayIndexScale), 0);
			}
		}
		
		this.objectArray = (A) directMemoryService.getObject(allocationStartAddress);
		
		switch (JvmUtil.getAddressSize()) {
	        case JvmUtil.SIZE_32_BIT:
	        	jvmAwareArrayElementAddressFinder = new Address32BitJvmAwareArrayElementAddressFinder();
	            break;
	        case JvmUtil.SIZE_64_BIT:
	        	int referenceSize = JvmUtil.getReferenceSize();
	        	switch (referenceSize) {
	             	case JvmUtil.ADDRESSING_4_BYTE:   
	             		jvmAwareArrayElementAddressFinder = new Address64BitWithCompressedOopsJvmAwareArrayElementAddressFinder();
	             		break;
	             	case JvmUtil.ADDRESSING_8_BYTE:
	             		jvmAwareArrayElementAddressFinder = new Address64BitWithCompressedOopsJvmAwareArrayElementAddressFinder();
	             		break;
	             	default:    
	                    throw new AssertionError("Unsupported reference size: " + referenceSize);
	        	}
	        	break;    
	        default:
	            throw new AssertionError("Unsupported address size: " + JvmUtil.getAddressSize());
		} 
	} 
                            #location 45 
                            #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code
                             @SuppressWarnings("unchecked")
	@Override
	protected void init() {
		super.init();
		
		if (initializeElements) {
			// All index is object pool array header point to allocated objects 
			for (long l = 0; l < length; l++) {
				directMemoryService.putLong(arrayIndexStartAddress + (l * arrayIndexScale), 
						JvmUtil.toJvmAddress((objStartAddress + (l * objectSize))));
			}
	
			long sourceAddress = sampleObjectAddress + 4;
			long copySize = objectSize - 4;
			// Copy sample object to allocated memory region for each object
			for (long l = 0; l < length; l++) {
				long targetAddress = objStartAddress + (l * objectSize);
				directMemoryService.putInt(targetAddress, 0);
				directMemoryService.copyMemory(sourceAddress, targetAddress + 4, copySize);
			}
		}
		else {
			// All index is object pool array header point to allocated objects 
			for (long l = 0; l < length; l++) {
				directMemoryService.putLong(arrayIndexStartAddress + (l * arrayIndexScale), 0);
			}
		}
		
		this.objectArray = (A) directMemoryService.getObject(arrayStartAddress);
	}