public PropagationContext adaptModificationMaskForObjectType(ObjectType type, InternalWorkingMemory workingMemory) {
if (originalMask == Long.MAX_VALUE || originalMask <= 0 || !(type instanceof ClassObjectType)) {
return this;
}
ClassObjectType classObjectType = (ClassObjectType)type;
Long cachedMask = classObjectType.getTransformedMask(modifiedClass, originalMask);
if (cachedMask != null) {
return this;
}
modificationMask = originalMask;
long typeBit = modificationMask & Long.MIN_VALUE;
modificationMask &= Long.MAX_VALUE;
Class<?> classType = classObjectType.getClassType();
String pkgName = classType.getPackage().getName();
if (classType == modifiedClass || "java.lang".equals(pkgName) || !(classType.isInterface() || modifiedClass.isInterface())) {
modificationMask |= typeBit;
return this;
}
modificationMask = 0L;
List<String> typeClassProps = getSettableProperties(workingMemory, classType, pkgName);
List<String> modifiedClassProps = getSettableProperties( workingMemory, modifiedClass );
for (int i = 0; i < modifiedClassProps.size(); i++) {
if (BitMaskUtil.isPositionSet(originalMask, i)) {
int posInType = typeClassProps.indexOf(modifiedClassProps.get(i));
if (posInType >= 0) {
modificationMask = BitMaskUtil.set(modificationMask, posInType);
}
}
}
modificationMask |= typeBit;
classObjectType.storeTransformedMask(modifiedClass, originalMask, modificationMask);
return this;
}