<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: reflection code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Tue, 19 Aug 2008 20:11:11 GMT</pubDate>
    <description>DZone Snippets: reflection code</description>
    <item>
      <title>2 + 2 = 5</title>
      <link>http://snippets.dzone.com/posts/show/3670</link>
      <description>Here is some very exciting Java code for printing 5.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;import java.security.*;&lt;br /&gt;import java.lang.reflect.*;&lt;br /&gt;import java.util.*;&lt;br /&gt;&lt;br /&gt;public class Test&lt;br /&gt;{&lt;br /&gt;    public static void main(String[] args) throws Exception&lt;br /&gt;    {   &lt;br /&gt;        AccessController.doPrivileged( new PrivilegedAction&lt;Object&gt;(){ public Object run(){try {&lt;br /&gt;        Field field = Class.forName("java.lang.Integer$IntegerCache").getDeclaredFields()[0];&lt;br /&gt;        field.setAccessible(true);&lt;br /&gt;&lt;br /&gt;        Integer[] cache = (Integer[])field.get(null);&lt;br /&gt;            &lt;br /&gt;        cache[130] = 3;  &lt;br /&gt;            &lt;br /&gt;        Integer foo = 2;&lt;br /&gt; &lt;br /&gt;        System.out.println(foo + 2); &lt;br /&gt;            &lt;br /&gt;        return null;} catch(Exception e) { throw new RuntimeException(e); } } }); &lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 14 Mar 2007 22:01:11 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3670</guid>
      <author>DRMacIver (David R. MacIver)</author>
    </item>
  </channel>
</rss>
