#vulnerable code 
                             @SuppressWarnings("unchecked")
	@Override
	protected void init() {
		super.init();
		
		this.currentIndex = 0;
		
		int arrayHeaderSize = JvmUtil.getArrayHeaderSize();
		int arrayIndexScale = JvmUtil.arrayIndexScale(elementType);
		long arrayIndexStartAddress = allocationStartAddress + JvmUtil.arrayBaseOffset(elementType);
		objStartAddress = allocationStartAddress + JvmUtil.sizeOfArray(elementType, objectCount);
		
		// 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, objectCount);
		
		// All index is object pool array header point to allocated objects 
		for (long l = 0; l < objectCount; l++) {
			directMemoryService.putLong(arrayIndexStartAddress + (l * arrayIndexScale), 
					JvmUtil.toJvmAddress((objStartAddress + (l * objectSize))));
		}

		long sourceAddress = offHeapSampleObjectAddress + 4;
		long copySize = objectSize - 4;
		// Copy sample object to allocated memory region for each object
		for (long l = 0; l < objectCount; l++) {
			long targetAddress = objStartAddress + (l * objectSize);
			directMemoryService.putInt(targetAddress, 0);
			directMemoryService.copyMemory(sourceAddress, targetAddress + 4, copySize);
		}

		this.objectArray = (T[]) directMemoryService.getObject(allocationStartAddress);
	} 
                            #location 17 
                            #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code
                             @SuppressWarnings("unchecked")
	@Override
	protected void init() {
		super.init();
		
		this.currentIndex = 0;
		
		int arrayHeaderSize = JvmUtil.getArrayHeaderSize();
		int arrayIndexScale = JvmUtil.arrayIndexScale(elementType);
		long arrayIndexStartAddress = allocationStartAddress + JvmUtil.arrayBaseOffset(elementType);
		
		objectsStartAddress = allocationStartAddress + JvmUtil.sizeOfArray(elementType, objectCount);
		// Allocated objects must start aligned as address size from start address of allocated address
		long diffBetweenArrayAndObjectStartAddresses = objectsStartAddress - allocationStartAddress;
		long addressMod = diffBetweenArrayAndObjectStartAddresses % JvmUtil.getAddressSize();
		if (addressMod != 0) {
			objectsStartAddress += (JvmUtil.getAddressSize() - addressMod);
		}
		objectsEndAddress = objectsStartAddress + (objectCount * objectSize);
		
		// 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, objectCount);
		
		// All index is object pool array header point to allocated objects 
		for (long l = 0; l < objectCount; l++) {
			directMemoryService.putLong(
					arrayIndexStartAddress + (l * arrayIndexScale), 
					JvmUtil.toJvmAddress((objectsStartAddress + (l * objectSize))));
		}

		long sourceAddress = offHeapSampleObjectAddress + 4;
		long copySize = objectSize - 4;
		// Copy sample object to allocated memory region for each object
		for (long l = 0; l < objectCount; l++) {
			long targetAddress = objectsStartAddress + (l * objectSize);
			directMemoryService.putInt(targetAddress, 0);
			directMemoryService.copyMemory(sourceAddress, targetAddress + 4, copySize);
		}

		this.objectArray = (T[]) directMemoryService.getObject(allocationStartAddress);
	}