-
Bug
-
Resolution: Unresolved
-
P4
-
7
Alex found below API document is ambiguous during a code review:
* The lead path is set to the last unique path.
Which has been added after the fixJDK-6210002 Undefined behavior of DefaultTreeSelectionModel.getSelectionPath() after setSelectionPaths.
Before the fix the javadoc was:
http://docs.oracle.com/javase/6/docs/api/javax/swing/tree/DefaultTreeSelectionModel.html#setSelectionPaths%28javax.swing.tree.TreePath[]%29
"The lead path is set to the last path in pPaths."
It was found that the setSelectionPaths method works differently for the duplicated paths.
For example:
----------------
model.setSelectionPaths(new TreePath[] {path1, path2, path1});
// lead path is path2 (last set path is path1)
----------------
It was decided not to change the setSelectionPaths method algorithm to not break the already written applications and just update the specification from "The lead path is set to the last path in pPaths." to "The lead path is set to the last unique path."
So "unique path" refers to paths in the current setSelectionPaths arguments.
This comment contradicts with the:
http://docs.oracle.com/javase/7/docs/api/javax/swing/tree/TreeSelectionModel.html
The lead TreePath is the last path that was added (or set).
and with:
http://docs.oracle.com/javase/7/docs/api/javax/swing/tree/DefaultTreeSelectionModel.html#leadPath
protected TreePath leadPath
Last path that was added.
* The lead path is set to the last unique path.
Which has been added after the fix
Before the fix the javadoc was:
http://docs.oracle.com/javase/6/docs/api/javax/swing/tree/DefaultTreeSelectionModel.html#setSelectionPaths%28javax.swing.tree.TreePath[]%29
"The lead path is set to the last path in pPaths."
It was found that the setSelectionPaths method works differently for the duplicated paths.
For example:
----------------
model.setSelectionPaths(new TreePath[] {path1, path2, path1});
// lead path is path2 (last set path is path1)
----------------
It was decided not to change the setSelectionPaths method algorithm to not break the already written applications and just update the specification from "The lead path is set to the last path in pPaths." to "The lead path is set to the last unique path."
So "unique path" refers to paths in the current setSelectionPaths arguments.
This comment contradicts with the:
http://docs.oracle.com/javase/7/docs/api/javax/swing/tree/TreeSelectionModel.html
The lead TreePath is the last path that was added (or set).
and with:
http://docs.oracle.com/javase/7/docs/api/javax/swing/tree/DefaultTreeSelectionModel.html#leadPath
protected TreePath leadPath
Last path that was added.
- relates to
-
JDK-6210002 Undefined behavior of DefaultTreeSelectionModel.getSelectionPath() after setSelectionPaths
-
- Closed
-