implementing the TypeVariable interface

Discussion in 'Java' started by transkawa, Nov 17, 2009.

  1. transkawa

    transkawa Guest

    can anyone demonstrate to me how to implement the TypeVariable<D extends
    GenericDeclaration> interface of the java.lang.reflect package?
    would really be helpful for me to see an algorithm that implements
    getBounds() and getGenericDeclaration(). am in the clouds from reading the
    language spec.
    xnt
    david
    transkawa, Nov 17, 2009
    #1
    1. Advertising

  2. transkawa

    markspace Guest

    transkawa wrote:
    > can anyone demonstrate to me how to implement the TypeVariable<D extends
    > GenericDeclaration> interface of the java.lang.reflect package?
    > would really be helpful for me to see an algorithm that implements
    > getBounds() and getGenericDeclaration(). am in the clouds from reading the
    > language spec.



    I don't think one would implement a TypeVariable. One gets an
    implementation from an instance of java.lang.Class.

    <http://java.sun.com/docs/books/tutorial/reflect/>

    Short example:

    import static java.lang.System.out;

    .....

    /** method to list type parameters */
    void listTypes( Object o ) {
    Class c = o.getClass();
    TypeVariable[] tv = c.getTypeParameters();
    if (tv.length != 0) {
    out.format(" ");
    for (TypeVariable t : tv)
    out.format("%s ", t.getName());
    out.format("%n%n");
    } else {
    out.format(" -- No Type Parameters --%n%n");
    }
    }

    I didn't test that, but most of it I got from that link I gave you. It
    should work.
    markspace, Nov 17, 2009
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Gomathi

    Implementing Interface

    Gomathi, Nov 17, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    553
    S.M. Altaf [MVP]
    Nov 17, 2005
  2. Manavendra Gupta
    Replies:
    1
    Views:
    357
    Manavendra Gupta
    Mar 7, 2004
  3. Robert Maas, see http://tinyurl.com/uh3t

    Trouble implementing an interface, strange compiler error

    Robert Maas, see http://tinyurl.com/uh3t, May 15, 2005, in forum: Java
    Replies:
    4
    Views:
    508
    Ross Bamford
    May 15, 2005
  4. golem
    Replies:
    13
    Views:
    781
    Nigel Wade
    Feb 17, 2006
  5. kscho
    Replies:
    1
    Views:
    392
    Rob Williscroft
    Sep 16, 2003
Loading...

Share This Page