-
Bug
-
Resolution: Fixed
-
P5
-
5.0, 6, 7
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();
}
}
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();
}
}
- duplicates
-
JDK-6776599 Accept explicit type arguments on call of nongeneric method
-
- Closed
-
-
JDK-7034522 No error if non-generic method is applied to type arguments
-
- Closed
-
- relates to
-
JDK-6559158 Qualified static method reference reported as ambiguous by javac
-
- Closed
-
-
JDK-6794932 JDK 7 javac accepts "new <String>ArrayList()" with only warning
-
- Closed
-