{"id":1683,"date":"2009-06-12T23:16:00","date_gmt":"2009-06-12T23:16:00","guid":{"rendered":"http:\/\/www.leobard.net\/blog\/?p=1683"},"modified":"2019-10-20T20:16:15","modified_gmt":"2019-10-20T20:16:15","slug":"java-reflection-on-generics","status":"publish","type":"post","link":"https:\/\/www.leobard.net\/blog\/2009\/06\/12\/java-reflection-on-generics\/","title":{"rendered":"java reflection on generics"},"content":{"rendered":"<p>When you drill down far into Java reflection, you end up at the reflection class for generic types. This is, if you have <\/p>\n<pre><code>\nclass Blah {\n  T t;\n  public T get() { return t; }\n}\n... Blah stringBlah = new Blah();\n<\/code><\/pre>\n<p>Then you can get the configured return type &#8220;String&#8221; by reflecting on the method &#8220;get&#8221;. The return type of that method is String. BUT if you need the generic variable T of Blah, you end up calling Blah.class.getTypeParameters(). And here the fun starts in the doc of TypeVariable:<\/p>\n<p><cite>The type parameter D represents the type of generic declaration that declared the underlying type variable. <\/cite><\/p>\n<p>wtf? this is as complex as playing <a href=\"http:\/\/braid-game.com\/\">braid<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When you drill down far into Java reflection, you end up at the reflection class for generic types. This is, if you have class Blah { T t; public T get() { return t; } } &#8230; Blah stringBlah = new Blah(); Then you can get the configured return type &#8220;String&#8221; by reflecting on the &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.leobard.net\/blog\/2009\/06\/12\/java-reflection-on-generics\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;java reflection on generics&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_bluesky_dont_syndicate":"","_bluesky_syndication_accounts":"","_bluesky_syndication_text":"","activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":3,"activitypub_interaction_policy_quote":"anyone","activitypub_status":"","footnotes":""},"categories":[19],"tags":[],"class_list":["post-1683","post","type-post","status-publish","format-standard","hentry","category-computers"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>java reflection on generics - Leobard&#039;s blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.leobard.net\/blog\/2009\/06\/12\/java-reflection-on-generics\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"java reflection on generics - Leobard&#039;s blog\" \/>\n<meta property=\"og:description\" content=\"When you drill down far into Java reflection, you end up at the reflection class for generic types. This is, if you have class Blah { T t; public T get() { return t; } } ... Blah stringBlah = new Blah(); Then you can get the configured return type &#8220;String&#8221; by reflecting on the &hellip; Continue reading &quot;java reflection on generics&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.leobard.net\/blog\/2009\/06\/12\/java-reflection-on-generics\/\" \/>\n<meta property=\"og:site_name\" content=\"Leobard&#039;s blog\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/leobard\" \/>\n<meta property=\"article:published_time\" content=\"2009-06-12T23:16:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-10-20T20:16:15+00:00\" \/>\n<meta name=\"author\" content=\"leobard\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"leobard\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.leobard.net\\\/blog\\\/2009\\\/06\\\/12\\\/java-reflection-on-generics\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.leobard.net\\\/blog\\\/2009\\\/06\\\/12\\\/java-reflection-on-generics\\\/\"},\"author\":{\"name\":\"leobard\",\"@id\":\"https:\\\/\\\/www.leobard.net\\\/blog\\\/#\\\/schema\\\/person\\\/23f718c5d3bd8d343befaa1b11bdc609\"},\"headline\":\"java reflection on generics\",\"datePublished\":\"2009-06-12T23:16:00+00:00\",\"dateModified\":\"2019-10-20T20:16:15+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.leobard.net\\\/blog\\\/2009\\\/06\\\/12\\\/java-reflection-on-generics\\\/\"},\"wordCount\":101,\"commentCount\":0,\"articleSection\":[\"computers\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.leobard.net\\\/blog\\\/2009\\\/06\\\/12\\\/java-reflection-on-generics\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.leobard.net\\\/blog\\\/2009\\\/06\\\/12\\\/java-reflection-on-generics\\\/\",\"url\":\"https:\\\/\\\/www.leobard.net\\\/blog\\\/2009\\\/06\\\/12\\\/java-reflection-on-generics\\\/\",\"name\":\"java reflection on generics - Leobard&#039;s blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.leobard.net\\\/blog\\\/#website\"},\"datePublished\":\"2009-06-12T23:16:00+00:00\",\"dateModified\":\"2019-10-20T20:16:15+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.leobard.net\\\/blog\\\/#\\\/schema\\\/person\\\/23f718c5d3bd8d343befaa1b11bdc609\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.leobard.net\\\/blog\\\/2009\\\/06\\\/12\\\/java-reflection-on-generics\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.leobard.net\\\/blog\\\/2009\\\/06\\\/12\\\/java-reflection-on-generics\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.leobard.net\\\/blog\\\/2009\\\/06\\\/12\\\/java-reflection-on-generics\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.leobard.net\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"java reflection on generics\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.leobard.net\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.leobard.net\\\/blog\\\/\",\"name\":\"Leobard&#039;s blog\",\"description\":\"personal weblog of Leo Sauermann\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.leobard.net\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.leobard.net\\\/blog\\\/#\\\/schema\\\/person\\\/23f718c5d3bd8d343befaa1b11bdc609\",\"name\":\"leobard\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4f15ee76fffcb732371d121c4713809a3f075186c6223630d4fe6c82ae88166d?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4f15ee76fffcb732371d121c4713809a3f075186c6223630d4fe6c82ae88166d?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4f15ee76fffcb732371d121c4713809a3f075186c6223630d4fe6c82ae88166d?s=96&d=mm&r=g\",\"caption\":\"leobard\"},\"description\":\"https:\\\/\\\/www.leobard.net\\\/blog\\\/about-leo-sauermann\\\/\",\"sameAs\":[\"https:\\\/\\\/www.leobard.net\\\/\",\"https:\\\/\\\/www.facebook.com\\\/leobard\",\"https:\\\/\\\/www.instagram.com\\\/leobarder\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/leosauermann\\\/\"],\"url\":\"https:\\\/\\\/www.leobard.net\\\/blog\\\/author\\\/leobard\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"java reflection on generics - Leobard&#039;s blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.leobard.net\/blog\/2009\/06\/12\/java-reflection-on-generics\/","og_locale":"en_US","og_type":"article","og_title":"java reflection on generics - Leobard&#039;s blog","og_description":"When you drill down far into Java reflection, you end up at the reflection class for generic types. This is, if you have class Blah { T t; public T get() { return t; } } ... Blah stringBlah = new Blah(); Then you can get the configured return type &#8220;String&#8221; by reflecting on the &hellip; Continue reading \"java reflection on generics\"","og_url":"https:\/\/www.leobard.net\/blog\/2009\/06\/12\/java-reflection-on-generics\/","og_site_name":"Leobard&#039;s blog","article_author":"https:\/\/www.facebook.com\/leobard","article_published_time":"2009-06-12T23:16:00+00:00","article_modified_time":"2019-10-20T20:16:15+00:00","author":"leobard","twitter_card":"summary_large_image","twitter_misc":{"Written by":"leobard","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.leobard.net\/blog\/2009\/06\/12\/java-reflection-on-generics\/#article","isPartOf":{"@id":"https:\/\/www.leobard.net\/blog\/2009\/06\/12\/java-reflection-on-generics\/"},"author":{"name":"leobard","@id":"https:\/\/www.leobard.net\/blog\/#\/schema\/person\/23f718c5d3bd8d343befaa1b11bdc609"},"headline":"java reflection on generics","datePublished":"2009-06-12T23:16:00+00:00","dateModified":"2019-10-20T20:16:15+00:00","mainEntityOfPage":{"@id":"https:\/\/www.leobard.net\/blog\/2009\/06\/12\/java-reflection-on-generics\/"},"wordCount":101,"commentCount":0,"articleSection":["computers"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.leobard.net\/blog\/2009\/06\/12\/java-reflection-on-generics\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.leobard.net\/blog\/2009\/06\/12\/java-reflection-on-generics\/","url":"https:\/\/www.leobard.net\/blog\/2009\/06\/12\/java-reflection-on-generics\/","name":"java reflection on generics - Leobard&#039;s blog","isPartOf":{"@id":"https:\/\/www.leobard.net\/blog\/#website"},"datePublished":"2009-06-12T23:16:00+00:00","dateModified":"2019-10-20T20:16:15+00:00","author":{"@id":"https:\/\/www.leobard.net\/blog\/#\/schema\/person\/23f718c5d3bd8d343befaa1b11bdc609"},"breadcrumb":{"@id":"https:\/\/www.leobard.net\/blog\/2009\/06\/12\/java-reflection-on-generics\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.leobard.net\/blog\/2009\/06\/12\/java-reflection-on-generics\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.leobard.net\/blog\/2009\/06\/12\/java-reflection-on-generics\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.leobard.net\/blog\/"},{"@type":"ListItem","position":2,"name":"java reflection on generics"}]},{"@type":"WebSite","@id":"https:\/\/www.leobard.net\/blog\/#website","url":"https:\/\/www.leobard.net\/blog\/","name":"Leobard&#039;s blog","description":"personal weblog of Leo Sauermann","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.leobard.net\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.leobard.net\/blog\/#\/schema\/person\/23f718c5d3bd8d343befaa1b11bdc609","name":"leobard","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4f15ee76fffcb732371d121c4713809a3f075186c6223630d4fe6c82ae88166d?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4f15ee76fffcb732371d121c4713809a3f075186c6223630d4fe6c82ae88166d?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4f15ee76fffcb732371d121c4713809a3f075186c6223630d4fe6c82ae88166d?s=96&d=mm&r=g","caption":"leobard"},"description":"https:\/\/www.leobard.net\/blog\/about-leo-sauermann\/","sameAs":["https:\/\/www.leobard.net\/","https:\/\/www.facebook.com\/leobard","https:\/\/www.instagram.com\/leobarder\/","https:\/\/www.linkedin.com\/in\/leosauermann\/"],"url":"https:\/\/www.leobard.net\/blog\/author\/leobard\/"}]}},"_links":{"self":[{"href":"https:\/\/www.leobard.net\/blog\/wp-json\/wp\/v2\/posts\/1683","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.leobard.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.leobard.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.leobard.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.leobard.net\/blog\/wp-json\/wp\/v2\/comments?post=1683"}],"version-history":[{"count":1,"href":"https:\/\/www.leobard.net\/blog\/wp-json\/wp\/v2\/posts\/1683\/revisions"}],"predecessor-version":[{"id":2469,"href":"https:\/\/www.leobard.net\/blog\/wp-json\/wp\/v2\/posts\/1683\/revisions\/2469"}],"wp:attachment":[{"href":"https:\/\/www.leobard.net\/blog\/wp-json\/wp\/v2\/media?parent=1683"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.leobard.net\/blog\/wp-json\/wp\/v2\/categories?post=1683"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.leobard.net\/blog\/wp-json\/wp\/v2\/tags?post=1683"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}