Browse Source

DATACMNS-1451 - Consider more than 16 immutable Kotlin properties in generated PropertyAccessor.

We now consider more than 16 immutable and nullable Kotlin properties per bucket in generated PropertyAccessors.

Previously only the first 16 properties were considered due to truncation of the defaulting bitmap. We used SIPUSH to render the defaulting mask in bytecode which is intended for 16 bit integers (short). Migrating to LDC (runtime constants) preserves the actual constant value of 32 bits and so we're considering now full buckets.
pull/338/head
Mark Paluch 7 years ago committed by Oliver Drotbohm
parent
commit
aa39b9ba3a
  1. 4
      src/main/java/org/springframework/data/mapping/model/ClassGeneratingPropertyAccessorFactory.java
  2. 13
      src/test/java/org/springframework/data/mapping/model/PersistentPropertyAccessorTests.java

4
src/main/java/org/springframework/data/mapping/model/ClassGeneratingPropertyAccessorFactory.java

@ -1115,9 +1115,7 @@ public class ClassGeneratingPropertyAccessorFactory implements PersistentPropert @@ -1115,9 +1115,7 @@ public class ClassGeneratingPropertyAccessorFactory implements PersistentPropert
visitDefaultValue(parameterTypes[i], mv);
}
copyByProperty.getDefaultMask().forEach(i -> {
mv.visitIntInsn(Opcodes.SIPUSH, i);
});
copyByProperty.getDefaultMask().forEach(mv::visitLdcInsn);
mv.visitInsn(Opcodes.ACONST_NULL);

13
src/test/java/org/springframework/data/mapping/model/PersistentPropertyAccessorTests.java

@ -140,6 +140,19 @@ public class PersistentPropertyAccessorTests { @@ -140,6 +140,19 @@ public class PersistentPropertyAccessorTests {
assertThatThrownBy(() -> accessor.setProperty(property, 1)).isInstanceOf(UnsupportedOperationException.class);
}
@Test // DATACMNS-1451
public void shouldSet17thImmutableNullableKotlinProperty() {
With33Args bean = new With33Args();
PersistentPropertyAccessor accessor = propertyAccessorFunction.apply(bean);
SamplePersistentProperty property = getProperty(bean, "17");
accessor.setProperty(property, "foo");
With33Args updated = (With33Args) accessor.getBean();
assertThat(updated.get17()).isEqualTo("foo");
}
@Test // DATACMNS-1322
public void shouldWitherProperty() {

Loading…
Cancel
Save