11 Replies
⌛
This post has been reserved for your question.
Hey @daysling! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
Not possible.
You need to pass a class by an argument.
Java has no way to infer that.
Reminder that generics don't exist at runtime. Declared types that do things like
class StringList extends List<String>
can be analyzed at runtime to detect they're a List of Strings.
But nothing else stays.EXCEPT
with some smart compiler magic, you can actually get the "generic" type of a method
Not sure what you mean
it's very hacky but it does work

I see. Hadn't seen this hack before
it is extraordinarily hacky but it's something
i wish with all my heart that generics will become actually good at some point
It is another thing that stays, as indeed the compiler magic creates an array of the expected return type.
But it is not something I'd tell someone they may do
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.