Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-5081782

type arguments to non-generic methods

XMLWordPrintable

    • 5.0
    • 5.0
    • b03
    • generic, x86
    • generic, linux, windows_7
    • Verified

      Giving Type argument to a method which does not take one compiles

      Tried with Beta3 buiold 59 on solaris

      Test Case:-
      /**Not a valid program, since one cannot pass a type argument to a method
        *that does not take one
        */
        
      class A {
        
         public <T> void callA() {
             System.out.println("Called callA method in class A");
         }

      }

      class B<T> {
         public <T> void callB() {
            System.out.println("Called callB method in class B");
         }
      }


      public class Test17 {
        
        public void check1() {
            A a_ref = new A();
            a_ref.<String>callA();
        }
        
        public void check2() {
             B<String> b_ref = new B<String>();
             b_ref.<String>callB();
        }
        
        public static void main(String args[]) {
            Test17 test17_ref = new Test17();
            test17_ref.check1();
            test17_ref.check2();
        }

      }

            ahe Peter Ahe
            jsinghsunw Jit Singh (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: