-
Bug
-
Resolution: Fixed
-
P3
-
8
-
b19
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8048484 | 8u25 | Paul Govereau | P3 | Resolved | Fixed | b05 |
JDK-8046586 | 8u20 | Paul Govereau | P3 | Resolved | Fixed | b20 |
JDK-8052631 | emb-8u26 | Paul Govereau | P3 | Resolved | Fixed | b17 |
If an inner class is a member, then a receiver parameter works fine:
class Top {
class Inner {
Inner(Top Top.this) {}
}
}
but if the inner class is local:
class Top {
void m() {
class Inner {
Inner(Top Top.this) {}
}
}
}
then javac (JDK8 b116) gets confused - it thinks Inner is top level:
error: receiver parameter not applicable for constructor of top-level class
Inner(Top Top.this) {}
^
This is a bug. A local class is a perfectly good inner class - the ctor of Top$1Inner.class even takes a Top - so its constructor ought to permit a receiver parameter. This is even true when the local class is inside a default method of an interface - in that case, the type of the receiver parameter is the interface. (As of JLS8, it is legal to say InterfaceName.this inside a default method of an interface.)
class Top {
class Inner {
Inner(Top Top.this) {}
}
}
but if the inner class is local:
class Top {
void m() {
class Inner {
Inner(Top Top.this) {}
}
}
}
then javac (JDK8 b116) gets confused - it thinks Inner is top level:
error: receiver parameter not applicable for constructor of top-level class
Inner(Top Top.this) {}
^
This is a bug. A local class is a perfectly good inner class - the ctor of Top$1Inner.class even takes a Top - so its constructor ought to permit a receiver parameter. This is even true when the local class is inside a default method of an interface - in that case, the type of the receiver parameter is the interface. (As of JLS8, it is legal to say InterfaceName.this inside a default method of an interface.)
- backported by
-
JDK-8046586 Receiver parameter not supported on local class constructor
-
- Resolved
-
-
JDK-8048484 Receiver parameter not supported on local class constructor
-
- Resolved
-
-
JDK-8052631 Receiver parameter not supported on local class constructor
-
- Resolved
-
- relates to
-
JDK-8162500 Receiver annotations of inner classes of local classes not found at runtime
-
- In Progress
-
-
JDK-8162501 getAnnotatedReceiverType of a local class constructor returns null
-
- In Progress
-