Bug 69895 - [1.5] GenericList.getLast() should flag error if not in try block/
Summary: [1.5] GenericList.getLast() should flag error if not in try block/
Status: RESOLVED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M1   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-07-13 00:41 EDT by Michael Schneider CLA
Modified: 2004-10-27 06:54 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Schneider CLA 2004-07-13 00:41:53 EDT
I am using a generic linked list


GenericList.getLast();

should be an error if not in try block, or in function that
with a throw statement.

1) No Error
2) No Quick Fix

Thanks
Mike
Comment 1 Philipe Mulet CLA 2004-07-14 06:17:44 EDT
LinkedList.getLast() doesn't declare any exception.
Comment 2 Michael Schneider CLA 2004-07-14 09:03:51 EDT
Here is the code for getLast from Java 1.5 beta 2.

Thanks
Mike


    /**
     * Returns the last element in this list.
     *
     * @return the last element in this list.
     * @throws    NoSuchElementException if this list is empty.
     */
    public E getLast()  {
	if (size==0)
	    throw new NoSuchElementException();

	return header.previous.element;
    }
Comment 3 Michael Schneider CLA 2004-07-14 09:09:17 EDT
---- FYI ---- here is the code from java 1.4


    /**
     * Returns the last element in this list.
     *
     * @return the last element in this list.
     * @throws    NoSuchElementException if this list is empty.
     */
    public Object getLast()  {
	if (size==0)
	    throw new NoSuchElementException();

	return header.previous.element;
    }

-------------------------------------------------
Comment 4 Philipe Mulet CLA 2004-07-14 09:49:32 EDT
This is what I said earlier, it does not declare any exception; thus can only 
throw unchecked exception which a compiler is not reporting. 
This is described in language specs.