3 Replies Latest reply on Nov 27, 2008 10:51 AM by thomas_behr

    How can I get the type variable of my class?

    843810
      Hello :)
      I have a problem with javadoc.

      I have a class:
      public class Tup<E> 
      {
           public void add(E e) 
           {
           }
      }
      When I use a custom doclet I have a variable classDoc of the interface ClassDoc. The classDoc represents my class Tup.
      When I call classDoc.typeParameters() this method always returns an empty array.

      How can I get the type variable of my class?
        • 1. Re: How can I get the type variable of my class?
          thomas_behr
          Did you specify the language version in your doclet class, i.e. does your doclet class contain the following method?
          public static LanguageVersion languageVersion()  {
            return LanguageVersion.JAVA_1_5;
          }
          Only then is information about Java 1.5 language level features (such as generic type parameters) generated. (The reason for this is to ensure that pre-1.5 doclets still work.)
          • 2. Re: How can I get the type variable of my class?
            843810
            Hi Thomas,
            1) My mistake - abobe i've wanted to post type.asTypeVariable() not type.typeParameters() .
            2) I specified the language version in my doclet class after your post. But still type.asTypeVariable() is null for my class with generic type parameters.
            I use jdk1.6.0_10 on windows xp.

            I have no idea why it doesn't work. :(
            • 3. Re: How can I get the type variable of my class?
              thomas_behr
              prokazaa wrote:
              1) My mistake - abobe i've wanted to post type.asTypeVariable() not type.typeParameters() .
              2) I specified the language version in my doclet class after your post. But still type.asTypeVariable() is null for my class with generic type parameters.
              I use jdk1.6.0_10 on windows xp.
              Sorry, but that doesn't make sense to me. Can you explain what you are trying to do and post a small code snippet that shows how you are trying to do that? With your original example method typeParameters() of the ClassDoc for Tup should return a one-element array containing a TypeVariable for the type parameter E.