Bug 45782 - [DCR] Compiler should take into account {@inheritDoc} tag
Summary: [DCR] Compiler should take into account {@inheritDoc} tag
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 3.0 M7   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 47397 49618 (view as bug list)
Depends on: 48385
Blocks:
  Show dependency tree
 
Reported: 2003-10-30 05:11 EST by Sebastian Davids CLA
Modified: 2004-04-16 13:06 EDT (History)
2 users (show)

See Also:


Attachments
screenshot of wrong erros being reported (223.65 KB, image/jpeg)
2004-04-16 12:39 EDT, Nikolay Metchev CLA
no flags Details
the settings used (72.82 KB, image/gif)
2004-04-16 12:39 EDT, Nikolay Metchev CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sebastian Davids CLA 2003-10-30 05:11:08 EST
I set "Problems in Javadoc tags" to warning and checked "Missing javadoc tags in
public types, methods, and fields".

/** {@inheritDoc} */
public synchronized boolean equals(Object obj) {
   return false;
}

The method above flags annotation warnings which it should not.

I want to have a "javadoc" -- so that tools can flag "missing javadoc" -- but I
do not want to copy the actual doc again.
Comment 1 Philipe Mulet CLA 2003-10-30 06:01:34 EST
Is the construct "/** {@inheritDoc} */" a standard javadoc feature ?
Comment 2 Sebastian Davids CLA 2003-10-30 06:57:45 EST
Since 1.4, yes:

http://java.sun.com/j2se/1.4.2/docs/tooldocs/javadoc/whatsnew-1.4.html#{@inheritDoc}

Actually it's quite sophisticated -- it will only copy the stuff you have not
"overwritten".


Comment 3 Sebastian Davids CLA 2003-10-30 06:59:05 EST
hmm there seems to be a bug in bugzilla itself =D

the trailing } should have been underlined also :/
Comment 4 Philipe Mulet CLA 2003-11-12 08:39:20 EST
Unsure this would be for 3.0. 
Comment 5 Frederic Fusier CLA 2003-12-01 04:53:48 EST
*** Bug 47397 has been marked as a duplicate of this bug. ***
Comment 6 Frederic Fusier CLA 2003-12-01 05:19:26 EST
Note that due to bug 47339 fix, you have now an equivalent of this tag using 
@see tag: see duplicate bug 47387.
Comment 7 Sebastian Davids CLA 2003-12-01 07:13:58 EST
@see <fully-javadoc-qualified methodname> is a coding/style convention

{@inheritDoc} is a Javadoc tag
Comment 8 Frederic Fusier CLA 2004-01-07 07:48:00 EST
*** Bug 49618 has been marked as a duplicate of this bug. ***
Comment 9 Frederic Fusier CLA 2004-01-13 05:18:37 EST
Fixed.

Due to bug 48385 fix, compiler is able to detect this inline tag in javadoc 
comment. When it happens, it flags Javadoc which does not report missing tags 
during resolve process.

Simply add condition (overriding && this.inherited) while computing 
reportMissing flag in jdt.internal.compiler.ast.Javadoc.resolve(MethodScope).

Note that this mean that tag is inefficient if it's written in a javadoc 
comment of a method which neither overrides superclass nor implements 
interfaces methods...

Test cases added in jdt.core.tests.compiler.regression.JavadocTestMixed.
Comment 10 David Audel CLA 2004-02-11 06:13:34 EST
Verified for 3.0M7
Comment 11 Nikolay Metchev CLA 2004-04-16 09:44:59 EDT
I am seeing this bug in eclipse M8
Comment 12 Frederic Fusier CLA 2004-04-16 12:26:26 EDT
Verified with build I200404131334 and M8 build: this bug is really fixed.

My test case is:
public class TestBug45782 implements Comparable {

	/**
	 * {@inheritDoc}
	 */
	public boolean equals(Object obj) {
		return super.equals(obj);
	}

	/**
	 * {@inheritDoc}
	 */
	public int compareTo(Object o) { return 0; }

	/**
	 * {@inheritDoc}
	 */
	public int foo(String str) { return 0; }
}
My project options are:
 - Process Javadoc comments: ON
 - Malformed Javadoc comments: Warning
   + Only consider member as visible as: Private
   + Report errors in tags: ON
 - Missing Javadoc tags: Warning
   + Only consider member as visible as: Private
   + Check overriding and implementing methods: ON
As expected:
 1) I have no warning on equals(Object) and compareTo(Object) methods
    as they respectively override and implement methods from hierarchy
 2) I have warnings on method foo(String) return type and parameter as this
    method neither overrides nor implements method from hierarchy.

Please provide a test case which shows your assumption, thx
Comment 13 Nikolay Metchev CLA 2004-04-16 12:39:28 EDT
Created attachment 9584 [details]
screenshot of wrong erros being reported

it would take too long to describe so I took a couple of screen shots
Comment 14 Nikolay Metchev CLA 2004-04-16 12:39:47 EDT
Created attachment 9585 [details]
the settings used
Comment 15 Frederic Fusier CLA 2004-04-16 12:59:45 EDT
Just put the code of the class in comment would have been enough and not take 
so long...

Warnings are:
1) on a constructor on which overriding has no sense in Java
2) on compareTo(Object) method which neither override nor implements method of 
hierarchy as your class A inherits from Object and does not implements any 
interface...

So there's no problem, compiler warns you accurately...
Comment 16 Sebastian Davids CLA 2004-04-16 13:06:27 EDT
To get rid of the bottom warning just add "implements Comparable" to your class
declaration.