0 Replies Latest reply on Feb 22, 2011 8:06 AM by dhoule

    Reflection and Class literal

    dhoule

      I'm trying to do some reflection in coldfusion, basically to dump the DNS cache InetAddress is currently holding in the JRE at the moment.  I found a site that offers a Java language example for dumping InetAddress cache and I'm trying to convert it to CF tags. I'm having trouble with this line...

       

      Class<InetAddress> klass = InetAddress.class;

       

      I've tried...

       

      <cfset klass = createObject("java", "java.net.InetAddress")>
      <cfset klass = createObject("java", "java.net.InetAddress").class>
      <cfset klass = createObject("java", "java.net.InetAddress").getClass()>
      <cfset klass = createObject("java", "java.net.InetAddress").class.getClass()>

       

      but they all return the same error...

       

      "The system has attempted to use an undefined value, which usually indicates a programming error, either in your code or some system code. Null Pointers are another name for undefined values."

       

      What works without error is...

       

      <cfset klass = createObject("java", "java.net.InetAddress").getLocalHost.getClass()>

       

      but the object it returns does not have a declaredField of "addressCache", it only has "INADDRSZ" "serialVersionUID" and "loopback" (I think because I'm not creating an instance of the base class for reflection, it's an instance of an instance.  Not sure.

       

      <cfset klass = createObject("java", "java.net.InetAddress")>

       

      also works but it has no declaredFields at all.

       

      Is there a way in CF7 to reproduce this line of Java...

       

      Class<InetAddress> klass = InetAddress.class;

       

      using CF tag(s) so that I can pull back the correct object for reflection purposes?

       

      Yes, I realize I could compile the pure Java language example, put it on the CF server and call it from CF, but for several reasons that's a pain, long story.  So... I'm hoping to do it in CF tags if at all possible.

       

      Thanks!