-
Bug
-
Resolution: Not an Issue
-
P4
-
23
-
generic
-
generic
This class should compile but does not:
public class Test2 {
class Inner {
Inner() {
this(Test2::run);
}
Inner(Runnable r) {
}
}
public void run() {
}
}
$ javac -version
javac 22
$ javac -Xdiags:verbose Test2.java
Test2.java:4: error: no suitable constructor found for Inner(Test2::run)
this(Test2::run);
^
constructor Test2.Inner.Test2.Inner() is not applicable
(actual and formal argument lists differ in length)
constructor Test2.Inner.Test2.Inner(Runnable) is not applicable
(argument mismatch; invalid method reference
unexpected instance method run() found in unbound lookup)
1 error
Note also that the error message says "Test2.Inner.Test2.Inner" where it should say "Test2.Inner", but that may just be a side effect of the actual bug (i.e., there shouldn't be any error message).
Verified in JDK 8, 11, 17, 22, and 24-head.
This may have the same root cause asJDK-8333766.
public class Test2 {
class Inner {
Inner() {
this(Test2::run);
}
Inner(Runnable r) {
}
}
public void run() {
}
}
$ javac -version
javac 22
$ javac -Xdiags:verbose Test2.java
Test2.java:4: error: no suitable constructor found for Inner(Test2::run)
this(Test2::run);
^
constructor Test2.Inner.Test2.Inner() is not applicable
(actual and formal argument lists differ in length)
constructor Test2.Inner.Test2.Inner(Runnable) is not applicable
(argument mismatch; invalid method reference
unexpected instance method run() found in unbound lookup)
1 error
Note also that the error message says "Test2.Inner.Test2.Inner" where it should say "Test2.Inner", but that may just be a side effect of the actual bug (i.e., there shouldn't be any error message).
Verified in JDK 8, 11, 17, 22, and 24-head.
This may have the same root cause as
- relates to
-
JDK-8333766 Stack overflow with anonymous class in super() parameter
-
- Resolved
-