-
Bug
-
Resolution: Fixed
-
P5
-
8
7.5.3 says "It is permissible for one single-static-import declaration to import several fields or types with the same name, or several methods with the same name and signature." and 7.5.4 says the same but with "static-import-on-demand" instead of "single-static-import".
Since a class can only declare one field of a given name, and that field hides any field of the same name in the superclass, it seems impossible that "several" such fields could exist. Similar reasoning applies to the member type and method declarations. However, the "permissible" scenario involves zero declarations in the class mentioned by 'import static', but declarations of the same name in multiple supertypes of that class. For example, a class may inherit a static field called 'f' from both its superclass and one of its superinterfaces. Even though 8.3/8.4.8/8.5 are reasonably clear that it's possible to inherit multiple fields/methods/types with the same name, it's not apparent in 7.5.3/7.5.4. A simple addendum to the paragraph should suffice: "This occurs when the named type inherits multiple fields, member types, or methods, all with the same name, from its own supertypes."
Since a class can only declare one field of a given name, and that field hides any field of the same name in the superclass, it seems impossible that "several" such fields could exist. Similar reasoning applies to the member type and method declarations. However, the "permissible" scenario involves zero declarations in the class mentioned by 'import static', but declarations of the same name in multiple supertypes of that class. For example, a class may inherit a static field called 'f' from both its superclass and one of its superinterfaces. Even though 8.3/8.4.8/8.5 are reasonably clear that it's possible to inherit multiple fields/methods/types with the same name, it's not apparent in 7.5.3/7.5.4. A simple addendum to the paragraph should suffice: "This occurs when the named type inherits multiple fields, member types, or methods, all with the same name, from its own supertypes."