What is the issue with a general-purpose RecordComponentFactory that uses canonical constructor to initialize components?
Class<?> recordClass = ...;
RecordComponent[] components = recordClass.getRecordComponents();
Class<?>[] parameterTypes = new Class<?>[components.length];
for (int i = 0; i < components.length; i++) {
parameterTypes[i] = components[i].getType();
}
Constructor<?> constructor = recordClass.getDeclaredConstructor(parameterTypes);
constructor.newInstance(args)