Details
-
Enhancement
-
Resolution: Fixed
-
P4
-
17
Description
JVMS 4.2.2 has an old note which suggests that an interface can have an <init> method:
-----
Note that a field name or interface method name may be `<init>` or `<clinit>`, but no method invocation instruction may reference `<clinit>` and only the invokespecial instruction (§invokespecial) may reference `<init>`.
-----
This note has been out of date since JVMS9, which prohibited `<init>` methods in interfaces (see 2.9.1 and 4.6). In addition, the note is trying to make the point that field names are less constrained than method names, but the point is neither necessary nor well made. (A field name like `<hello>` would make it more clearly, because `<hello>` is forbidden as a method name in both classes and interfaces.) Finally, there is no point in highlighting that an interface method name may be <clinit>, because it's true for a method in a class as well. The most useful thing to say is simply:
-----
Note that no method invocation instruction may reference `<clinit>`, and only the invokespecial instruction (§invokespecial) may reference `<init>`.
-----
-----
Note that a field name or interface method name may be `<init>` or `<clinit>`, but no method invocation instruction may reference `<clinit>` and only the invokespecial instruction (§invokespecial) may reference `<init>`.
-----
This note has been out of date since JVMS9, which prohibited `<init>` methods in interfaces (see 2.9.1 and 4.6). In addition, the note is trying to make the point that field names are less constrained than method names, but the point is neither necessary nor well made. (A field name like `<hello>` would make it more clearly, because `<hello>` is forbidden as a method name in both classes and interfaces.) Finally, there is no point in highlighting that an interface method name may be <clinit>, because it's true for a method in a class as well. The most useful thing to say is simply:
-----
Note that no method invocation instruction may reference `<clinit>`, and only the invokespecial instruction (§invokespecial) may reference `<init>`.
-----
Attachments
Issue Links
- relates to
-
JDK-8122940 2.9: Clarify instance initialization methods
-
- Closed
-