dnault / therapi-runtime-javadoc

Read Javadoc comments at run time.
Apache License 2.0
117 stars 19 forks source link

Enhanced support for record classes #60

Open dnault opened 2 years ago

dnault commented 2 years ago

Implement the features suggested by @xeals in #52:

dnault commented 2 years ago

@xeals Do you have any more hints about how to identify the canonical constructor? I couldn't sniff out the flags you mentioned.

xeals commented 2 years ago

I'd not recorded the info when I was playing around (of course), but I rediscovered what I was talking about.

Unfortunately this was found through a debugger and I didn't realise it exposes javac internals, which in JDK16+ are a little harder to access than they used to be (doable, just requiring opt-in flags).

With that in mind:

It doesn't look like any of this is transferred to a properly public API, so deciding to opt into those private APIs might be a bigger decision than just adding support. Looking at it again I would be hesitant.

dnault commented 2 years ago

Thanks for digging into this again, Alex. I agree we should stick to the public API.

I wonder if we could infer the signature of the canonical constructor by paying attention to the ElementKind.RECORD_COMPONENT elements. Kind of like https://stackoverflow.com/a/67126110/611819 . For example, if we see an int and a String, then we know the the canonical constructor has a signature of (int, String).