Summary: | [1.5] GenericList.getLast() should flag error if not in try block/ | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Michael Schneider <michaelschneider> |
Component: | Core | Assignee: | JDT-Core-Inbox <jdt-core-inbox> |
Status: | RESOLVED INVALID | QA Contact: | |
Severity: | normal | ||
Priority: | P3 | ||
Version: | 3.0 | ||
Target Milestone: | 3.1 M1 | ||
Hardware: | PC | ||
OS: | Windows XP | ||
Whiteboard: |
Description
Michael Schneider
2004-07-13 00:41:53 EDT
LinkedList.getLast() doesn't declare any exception. 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; } ---- 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; } ------------------------------------------------- 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. |