Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for superclass fields to @AutoLog #95

Open
Jelatinone opened this issue Jun 23, 2024 · 1 comment
Open

Add support for superclass fields to @AutoLog #95

Jelatinone opened this issue Jun 23, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@Jelatinone
Copy link

Jelatinone commented Jun 23, 2024

Consider any given class which does not have the @AutoLog annotation applied:

...
public abstract class SomeNotLoggedClass<T extends StructSerializable> {

  protected T[] someLoggedProperty; //Can't create generic array
  ...
}

Then consider another class, which extends the aforementioned SomeNotLoggedClass:

...
@AutoLog
public class LoggedSubClass extends SomeNotLoggedClass<Rotation2d> {
  
  protected double[] someAdditionalLoggedProperty = new double[0];
  ...
}

Current implementation of the AutoLogAnnotationProcessor would parse only the fields contained within SomeNotLoggedClass, but notably not SomeNotLoggedClassand it's field, someLoggedProperty. I would like to suggest changes to AutoLogAnnotationProcessor which would log the aforementioned, as well as only attempting to log field elements that have the access modifiers public or protected.

The latter of which would provide a route by which to prevent fields in a super class (or any class for that matter) from unecessarily logging a field. If done, it would remove the additional complexity that currently exists of having to manually implement LoggableInputs if you wish to have the super class field someLoggedProperty to be logged.

@Jelatinone Jelatinone changed the title Add Support for superclass fields to @AutoLog Add support for superclass fields to @AutoLog Jun 23, 2024
@jwbonner
Copy link
Member

I think there are a few pieces here which are missing right now, and they don't all depend on each other:

  1. Logging fields declared in superclasses
  2. Logging generic fields from superclasses
  3. Logging only public/protected fields

I think that all of those are doable, though dealing with superclasses in particular is a bit challenging for compile-type annotation processing. At runtime it's trivial to retrieve all of the fields of a class including its superclasses, but I believe doing it at compile time will require searching each superclass and explicitly filling in generics as necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants