Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #39629
| From | Eric Sosman <esosman@comcast-dot-net.invalid> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: getting generic type parameter in method |
| Date | 2020-10-21 08:43 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <rmpact$irl$1@dont-email.me> (permalink) |
| References | <7e2c11ae-85bd-42cd-a7a7-27313edb9178n@googlegroups.com> |
On 10/21/2020 7:38 AM, Philipp Kraus wrote:
> Hello,
>
> I'm implementing an interface of a library, which I can use for deserialization a byte array into my own datastructures. The method is:
>
> public <T> T fromData( @Nonnull final byte[] p_bytes, @Nonnull final Class<T> p_class, @Nonnull final Type p_type ) throws DataConverterException
> [...]
> I have taken a look into Google Guava and Apache Commons with the ReflectUtils / TypeUtils, but I don't know How I get get from my p_class Variable the details auf T during runtime.
I'm not up to speed on all the latest developments, but I think
you're out of luck at least through Java 15. JLS 4.7 describes which
types are "reifiable," and includes a discussion on why some types
(including most generic types) are not. Perhaps in some future Java
things will change, but I don't believe they've changed yet.
(However, "perhaps" I'm wrong. I'm at Java 11 these days, and
have not fully explored the more recent releases.)
--
esosman@comcast-dot-net.invalid
"Total honesty is what we as citizens deserve from our president."
-- Melania Trump
Ninety-one days to go.
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
getting generic type parameter in method Philipp Kraus <philipp.kraus.flashpixx@gmail.com> - 2020-10-21 04:38 -0700
Re: getting generic type parameter in method Eric Sosman <esosman@comcast-dot-net.invalid> - 2020-10-21 08:43 -0400
Re: getting generic type parameter in method Marcel Mueller <news.5.maazl@spamgourmet.org> - 2020-10-21 15:28 +0200
Re: getting generic type parameter in method Arne Vajhøj <arne@vajhoej.dk> - 2020-10-21 21:33 -0400
Re: getting generic type parameter in method Philipp Kraus <philipp.kraus.flashpixx@gmail.com> - 2020-10-22 04:16 -0700
Re: getting generic type parameter in method Philipp Kraus <philipp.kraus.flashpixx@gmail.com> - 2020-10-22 04:21 -0700
Re: getting generic type parameter in method "e.d.pro...@gmail.com" <e.d.programmer@gmail.com> - 2020-10-22 04:16 -0700
csiph-web