Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!nx02.iad01.newshosting.com!newshosting.com!69.16.185.16.MISMATCH!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!postnews.google.com!a12g2000yqi.googlegroups.com!not-for-mail From: Robert Klemme Newsgroups: comp.lang.java.programmer Subject: Re: Define Type at runtime Date: Thu, 8 Sep 2011 08:12:15 -0700 (PDT) Organization: http://groups.google.com Lines: 36 Message-ID: <3d05f689-fd75-4ccd-8fd4-8e41b12f736a@a12g2000yqi.googlegroups.com> References: <4e678737$1@news.x-privat.org> <4e678ab5$0$13073$426a74cc@news.free.fr> <4e678d02$2@news.x-privat.org> NNTP-Posting-Host: 193.0.246.21 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1315494735 14463 127.0.0.1 (8 Sep 2011 15:12:15 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 8 Sep 2011 15:12:15 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: a12g2000yqi.googlegroups.com; posting-host=193.0.246.21; posting-account=MGO7qgoAAABvyo26eHVDO00044spH-ws User-Agent: G2/1.0 X-HTTP-Via: 1.1 webwasher (Webwasher 6.8.7.9396) X-Google-Web-Client: true X-Google-Header-Order: ASELNKCHRUV X-HTTP-UserAgent: Mozilla/5.0 (Windows NT 5.1; rv:6.0) Gecko/20100101 Firefox/6.0,gzip(gfe) Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:7702 On 7 Sep., 17:25, John wrote: > Il 07/09/2011 17:20, Mayeul ha scritto: > > > > > > > > > > > On 07/09/2011 17:01, John wrote: > >> If I have a method: > >> public void someMethod(Object o){ > >> ... > >> Entity entity; > >> .... > >> } > > >> How could I define at runtime the type T if I have an Object? > > > You can't. Generics are a compile-time-only tool. They are erased at > > runtime. > > > You need to organize your program so that type-safety is checked > > entirely at compile-time. Or, if impractical, to just renounce > > type-safety and work with something like Entity instead. > > Ok, solved. > Thank you Just curious, how did you solve it? Cheers robert