-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathInterfaceCannotBeImplemented.qhelp
More file actions
59 lines (45 loc) · 1.46 KB
/
InterfaceCannotBeImplemented.qhelp
File metadata and controls
59 lines (45 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<!DOCTYPE qhelp PUBLIC
"-//Semmle//qhelp//EN"
"qhelp.dtd">
<qhelp>
<overview>
<p>
An interface that contains methods whose return types clash with protected
methods on <code>java.lang.Object</code> can never be implemented, because
methods cannot be overloaded based simply on their return type.</p>
</overview>
<recommendation>
<p>
If the interface is useful, name methods so that they
do not clash with methods in <code>Object</code>. Otherwise you should delete the interface.
</p>
</recommendation>
<example>
<p>In the following example, the interface <code>I</code> is useless because the
<code>clone</code> method must return type <code>java.lang.Object</code>:</p>
<sample src="InterfaceCannotBeImplemented.java" />
<p>
Any attempt to implement the interface produces an error:
</p>
<pre>
InterfaceCannotBeImplemented.java:6: clone() in C cannot override
clone() in java.lang.Object; attempting to use incompatible return
type
found : int
required: java.lang.Object
public int clone() {
^
1 error
</pre>
</example>
<references>
<li>
Help - Eclipse Platform:
<a href="https://help.eclipse.org/2020-12/advanced/content.jsp?topic=/org.eclipse.jdt.doc.user/reference/preferences/java/compiler/ref-preferences-errors-warnings.htm">Java Compiler Errors/Warnings Preferences</a>.
</li>
<li>
Java Language Specification:
<a href="https://docs.oracle.com/javase/specs/jls/se11/html/jls-9.html#jls-9.2">9.2 Interface Members</a>.
</li>
</references>
</qhelp>