<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: A general-purpose utility to retrieve Java generic type values</title>
	<atom:link href="http://blog.xebia.com/2009/03/12/a-general-purpose-utility-to-retrieve-java-generic-type-values/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.xebia.com/2009/03/12/a-general-purpose-utility-to-retrieve-java-generic-type-values/</link>
	<description>Software development done right!</description>
	<lastBuildDate>Wed, 08 Feb 2012 14:41:38 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Myšlenky dne otce Fura &#187; Blog Archive &#187; Oříšek v reflexní analýze generik</title>
		<link>http://blog.xebia.com/2009/03/12/a-general-purpose-utility-to-retrieve-java-generic-type-values/#comment-94311</link>
		<dc:creator>Myšlenky dne otce Fura &#187; Blog Archive &#187; Oříšek v reflexní analýze generik</dc:creator>
		<pubDate>Fri, 19 Mar 2010 07:14:48 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=907#comment-94311</guid>
		<description>[...] Velmi pěkně popsané pozadí analýzy generik pomocí reflexe [...]</description>
		<content:encoded><![CDATA[<p>[...] Velmi pěkně popsané pozadí analýzy generik pomocí reflexe [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew Phillips</title>
		<link>http://blog.xebia.com/2009/03/12/a-general-purpose-utility-to-retrieve-java-generic-type-values/#comment-91914</link>
		<dc:creator>Andrew Phillips</dc:creator>
		<pubDate>Sun, 21 Jun 2009 20:02:42 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=907#comment-91914</guid>
		<description>PS: The code for this project is now available at &lt;a href=&quot;http://code.google.com/p/aphillips/&quot; target=&quot;_new&quot; rel=&quot;nofollow&quot;&gt;Google Code&lt;/a&gt; (in the &lt;a href=&quot;https://code.google.com/p/aphillips/source/browse/#svn/commons-lang/trunk&quot; target=&quot;_new&quot; rel=&quot;nofollow&quot;&gt;commons-lang&lt;/a&gt; project).</description>
		<content:encoded><![CDATA[<p>PS: The code for this project is now available at <a href="http://code.google.com/p/aphillips/" target="_new" rel="nofollow">Google Code</a> (in the <a href="https://code.google.com/p/aphillips/source/browse/#svn/commons-lang/trunk" target="_new" rel="nofollow">commons-lang</a> project).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Neal Gafter</title>
		<link>http://blog.xebia.com/2009/03/12/a-general-purpose-utility-to-retrieve-java-generic-type-values/#comment-91462</link>
		<dc:creator>Neal Gafter</dc:creator>
		<pubDate>Thu, 02 Apr 2009 16:04:10 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=907#comment-91462</guid>
		<description>Erik: I&#039;m not aware of any compatibility issues that are obstacles to adding closures to Java.  Are you?</description>
		<content:encoded><![CDATA[<p>Erik: I&#8217;m not aware of any compatibility issues that are obstacles to adding closures to Java.  Are you?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Erik Jan</title>
		<link>http://blog.xebia.com/2009/03/12/a-general-purpose-utility-to-retrieve-java-generic-type-values/#comment-91450</link>
		<dc:creator>Erik Jan</dc:creator>
		<pubDate>Sun, 29 Mar 2009 13:33:33 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=907#comment-91450</guid>
		<description>Ok that&#039;s right, I guess that is the only way they could have implemented generics, as Sun always wants to be backwards compatibility. They face the same problems with closures. If only they put in right from the beginning</description>
		<content:encoded><![CDATA[<p>Ok that&#8217;s right, I guess that is the only way they could have implemented generics, as Sun always wants to be backwards compatibility. They face the same problems with closures. If only they put in right from the beginning</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew Phillips</title>
		<link>http://blog.xebia.com/2009/03/12/a-general-purpose-utility-to-retrieve-java-generic-type-values/#comment-91410</link>
		<dc:creator>Andrew Phillips</dc:creator>
		<pubDate>Mon, 23 Mar 2009 11:06:14 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=907#comment-91410</guid>
		<description>@erikjan: I assume you meant

&lt;pre lang=&quot;java&quot;&gt;
List&lt;Integer&gt; list;
&lt;/pre&gt;

and adjusted your the comment accordingly - I think the angle brackets were stripped out as &quot;invalid HTML&quot; ;-).

Indeed, running the code prints

Type: interface java.util.List
GenericType: java.util.List&lt;java.lang.Integer&gt;
class java.lang.Integer

as you mention. This also works using &lt;tt&gt;Class c = Foo.class&lt;/tt&gt;.

Thanks for that, very useful. But it &lt;em&gt;does&lt;/em&gt; require you to have access to the &lt;strong&gt;field declaration&lt;/strong&gt; of &lt;tt&gt;list&lt;/tt&gt;, i.e. compile-time information.

What I meant - and could have expressed more clearly - when I wrote &quot;there is no way to get the Agent from&quot; is that you cannot access the type information &lt;u&gt;if given only the &lt;tt&gt;list&lt;/tt&gt; object&lt;/u&gt;.</description>
		<content:encoded><![CDATA[<p>@erikjan: I assume you meant</p>
<pre lang="java">
List&lt;Integer&gt; list;
</pre>
<p>and adjusted your the comment accordingly &#8211; I think the angle brackets were stripped out as &#8220;invalid HTML&#8221; <img src='http://blog.xebia.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> .</p>
<p>Indeed, running the code prints</p>
<p>Type: interface java.util.List<br />
GenericType: java.util.List<java .lang.Integer><br />
class java.lang.Integer</p>
<p>as you mention. This also works using <tt>Class c = Foo.class</tt>.</p>
<p>Thanks for that, very useful. But it <em>does</em> require you to have access to the <strong>field declaration</strong> of <tt>list</tt>, i.e. compile-time information.</p>
<p>What I meant &#8211; and could have expressed more clearly &#8211; when I wrote &#8220;there is no way to get the Agent from&#8221; is that you cannot access the type information <u>if given only the <tt>list</tt> object</u>.</java></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: erikjan</title>
		<link>http://blog.xebia.com/2009/03/12/a-general-purpose-utility-to-retrieve-java-generic-type-values/#comment-91402</link>
		<dc:creator>erikjan</dc:creator>
		<pubDate>Sun, 22 Mar 2009 16:09:34 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=907#comment-91402</guid>
		<description>I think there is a way to get the type of List list;

Execute this code and see that it will print Intger in the end.

&lt;pre lang=&quot;java&quot;&gt;
public class FieldSpy {
  public List&lt;Integer&gt; list;

  public static void main(String... args) {
    try {
      Class c = Class.forName(&quot;FieldSpy&quot;);
      Field f = c.getField(&quot;list&quot;);
      System.out.format(&quot;Type: %s%n&quot;, f.getType());
      System.out.format(&quot;GenericType: %s%n&quot;, f.getGenericType());

      Type type = f.getGenericType();
      if (type instanceof ParameterizedType) {
          System.out.println(((ParameterizedType)type).getActualTypeArguments()[0]);
      }
    } catch (ClassNotFoundException x) {
      x.printStackTrace();
    } catch (NoSuchFieldException x) {
      x.printStackTrace();
    }
  }
}
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>I think there is a way to get the type of List list;</p>
<p>Execute this code and see that it will print Intger in the end.</p>
<pre lang="java">
public class FieldSpy {
  public List&lt;Integer&gt; list;

  public static void main(String... args) {
    try {
      Class c = Class.forName("FieldSpy");
      Field f = c.getField("list");
      System.out.format("Type: %s%n", f.getType());
      System.out.format("GenericType: %s%n", f.getGenericType());

      Type type = f.getGenericType();
      if (type instanceof ParameterizedType) {
          System.out.println(((ParameterizedType)type).getActualTypeArguments()[0]);
      }
    } catch (ClassNotFoundException x) {
      x.printStackTrace();
    } catch (NoSuchFieldException x) {
      x.printStackTrace();
    }
  }
}
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan Howard</title>
		<link>http://blog.xebia.com/2009/03/12/a-general-purpose-utility-to-retrieve-java-generic-type-values/#comment-90658</link>
		<dc:creator>Dan Howard</dc:creator>
		<pubDate>Fri, 13 Mar 2009 21:04:55 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=907#comment-90658</guid>
		<description>Tres cool.</description>
		<content:encoded><![CDATA[<p>Tres cool.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew Phillips</title>
		<link>http://blog.xebia.com/2009/03/12/a-general-purpose-utility-to-retrieve-java-generic-type-values/#comment-90643</link>
		<dc:creator>Andrew Phillips</dc:creator>
		<pubDate>Fri, 13 Mar 2009 18:41:47 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=907#comment-90643</guid>
		<description>@florin: Eek, yes, thanks for that. I&#039;ve added a link to SetUtils.java on the &lt;a href=&quot;http://www.qrmedia.com/demo/classutils/&quot; rel=&quot;nofollow&quot;&gt;source page&lt;/a&gt;- it&#039;s nothing magical, simply a convenience method like Arrays.asList for Sets...</description>
		<content:encoded><![CDATA[<p>@florin: Eek, yes, thanks for that. I&#8217;ve added a link to SetUtils.java on the <a href="http://www.qrmedia.com/demo/classutils/" rel="nofollow">source page</a>- it&#8217;s nothing magical, simply a convenience method like Arrays.asList for Sets&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: florin</title>
		<link>http://blog.xebia.com/2009/03/12/a-general-purpose-utility-to-retrieve-java-generic-type-values/#comment-90636</link>
		<dc:creator>florin</dc:creator>
		<pubDate>Fri, 13 Mar 2009 17:30:29 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=907#comment-90636</guid>
		<description>Looks great. 

Where is the SetUtils.java that is imported?</description>
		<content:encoded><![CDATA[<p>Looks great. </p>
<p>Where is the SetUtils.java that is imported?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
<!-- This Quick Cache file was built for (  blog.xebia.com/2009/03/12/a-general-purpose-utility-to-retrieve-java-generic-type-values/feed/ ) in 0.54732 seconds, on Feb 9th, 2012 at 9:42 pm UTC. -->
<!-- This Quick Cache file will automatically expire ( and be re-built automatically ) on Feb 9th, 2012 at 10:42 pm UTC -->
