Skip to content

Epilogue creates duplicate NT entries in kotlin. #7886

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

Open
falOn-Dev opened this issue Mar 29, 2025 · 3 comments
Open

Epilogue creates duplicate NT entries in kotlin. #7886

falOn-Dev opened this issue Mar 29, 2025 · 3 comments
Labels
type: bug Something isn't working.

Comments

@falOn-Dev
Copy link
Contributor

Describe the bug
When epilogue is used with kotlin, it generates two NT entries for every field. One is called field and one is called getField. For some reason even when kotlin gets compiled to bytecode with simple getters (just a function with return this.whatever) it still gets logged. I've been told that's not supposed to happen. For fields with no custom getter you can annotate @JvmField to fix this issue, but you can't utilize a custom getter, and epilogue, without duplicates.

To Reproduce

  1. Set up a kotlin FRC project
  2. Register epilogue with Kapt (to allow java annotation processors to process kotlin code)
  3. Log some stuff

Expected behavior
I expected epilogue to not generate duplicate entries in NT when logging.

Desktop (please complete the following information):

  • OS: Arch Linux
  • Project Information: WPILib 2025.3.2, WPILib's 2025 JDK

Additional context
I understand if this issue gets closed nearly instantly, as kotlin is not officially supported. However I would really like to explore the use of epilogue in kotlin, and fixing this would be huge.

@falOn-Dev falOn-Dev added the type: bug Something isn't working. label Mar 29, 2025
@falOn-Dev
Copy link
Contributor Author

I think the easiest way to solve this would be: If a class has @Metadata (automatically part of all kotlin class files, unique to kotlin unless manually added to a java filed) then ignore fields, log the getter methods, and drop the get prefix

@falOn-Dev
Copy link
Contributor Author

In general there seems to be tons of issues with detecting and logging things in kotlin. Tagging with @JvmSynthetic causes the duplicates to no longer appear, but it also makes some (but for some reason not all?) of the logged variables no longer update. Also, variables from an abstract parent class only get logged if they're overriden, even when both classes are tagged @Logged (might be intentional?)

@falOn-Dev
Copy link
Contributor Author

falOn-Dev commented Mar 29, 2025

The only way to avoid logging twice, and use custom getters (from what I've found), is to annotate with NotLogged for every field

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working.
Projects
None yet
Development

No branches or pull requests

1 participant