diff --git a/dbus-java-core/src/main/java/org/freedesktop/dbus/messages/ExportedObject.java b/dbus-java-core/src/main/java/org/freedesktop/dbus/messages/ExportedObject.java index b4a0fdc0..5b07496b 100644 --- a/dbus-java-core/src/main/java/org/freedesktop/dbus/messages/ExportedObject.java +++ b/dbus-java-core/src/main/java/org/freedesktop/dbus/messages/ExportedObject.java @@ -278,6 +278,9 @@ private void createReturnArguments(Method _meth, StringBuilder _sb) throws DBusE argTypes = Arrays.stream(clz.getDeclaredFields()) .filter(f -> f.isAnnotationPresent(Position.class)) .filter(Objects::nonNull) + .map(f -> Map.entry(f.getAnnotation(Position.class).value(), f)) + .sorted(Comparator.comparingInt(k -> k.getKey())) + .map(f -> f.getValue()) .map(Field::getType) .map(Type.class::cast) .toList();