Bug 89436 - [1.5][javadoc][annotations] Eclipse doesn't honour annotations.
Summary: [1.5][javadoc][annotations] Eclipse doesn't honour annotations.
Status: RESOLVED DUPLICATE of bug 83739
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-03-29 18:46 EST by R Lenard CLA
Modified: 2005-03-29 22:01 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description R Lenard CLA 2005-03-29 18:46:02 EST
This code is meant to not emit any warnings, but does.. Eclipse doesn't seem to 
be honouring the annotations.  Theoretically the @SuppressWarnings
({"unchecked"}) should tell Eclipse not to emit this.

"Type safety: The cast from T to Comparable<T> is actually checking against the 
erased type Comparable"

% cat Test.java
import java.util.Comparator;

/** */
public class Test
{
    /**
     * 
     * @param <T>
     * @param comparator
     * @param first
     * @param second
     * @return a value
     * @throws ClassCastException
     */
    @SuppressWarnings ({"unchecked"})
    public static <T> int compare(final Comparator<? super T> comparator, final 
T first, final T second)
        throws ClassCastException
    {
        // Same object (or both null) - quick exit.
        if (first == second)
        {
            return 0;
        }

        // If either is null, it is less than the other.
        if (first == null)
        {
            return -1;
        }
        else if (second == null)
        {
            return 1;
        }

        // Ensure that compare is consistent with equals
        if (first.equals(second))
        {
            return 0;
        }

        // If possible use {@link Comparator#compare}.
        if (comparator != null)
        {
            return comparator.compare(first, second);
        }

        // Fallback to the {@link Comparable#compareTo} implementation to 
determine.
        return ((Comparable<T>) first).compareTo(second);
    }
}
Comment 1 Olivier Thomann CLA 2005-03-29 22:01:31 EST

*** This bug has been marked as a duplicate of 83739 ***