- 
    Bug 
- 
    Resolution: Duplicate
- 
     P2 P2
- 
    6, 7
- 
        generic
- 
        generic
                    Method: javax.swing.text.NavigationFilter.getNextVisualPositionFrom(..) doesn't throw declared BadLocationException when unexisting location is passed in.
Specification for BadLocationException states:
"This exception is to report bad locations within a document model (that is, attempts to reference a location that doesn't exist)."
The following code snippet expects BadLocationException for all valid SwingConstants, but it's not always being thrown.
-----
import javax.swing.*;
import javax.swing.text.NavigationFilter;
import javax.swing.text.Position;
import javax.swing.text.BadLocationException;
public class NF0006Snippet {
public static void main(String[] args) throws BadLocationException, InterruptedException {
JFormattedTextField jtf = new JFormattedTextField();
NavigationFilter nf = new NavigationFilter();
jtf.setText("A text message");
JFrame jFrame = new JFrame();
jFrame.getContentPane().add(jtf);
jFrame.pack();
jFrame.setVisible(true);
Position.Bias[] biasRet = {Position.Bias.Forward};
        
for (int swingConstant : new int[]{
SwingConstants.EAST,
SwingConstants.WEST,
// the following constants still will lead to "BadLocationException: Length must be positive"
// SwingConstants.SOUTH,
// SwingConstants.NORTH,
}) {
for (int position : new int[] {-100, Integer.MIN_VALUE} ) {
nf.getNextVisualPositionFrom(jtf, position, Position.Bias.Backward, swingConstant, biasRet);
nf.getNextVisualPositionFrom(jtf, position, Position.Bias.Forward, swingConstant, biasRet);
}
}
jFrame.dispose();
}
}
-----
JCK-runtime-7 b03
JDK 7 b30
Platform: Windows, Solaris
The following JCK test fails due to this problem:
api/javax_swing/text/NavigationFilter/index.html#Methods[NavigationFilter0006]
http://moonblade.russia.sun.com/set/java/jck/qa-results/jck/7/ea/b03/results/qac/m002_b30_failed_c1/solaris-amd64-080723150835/execdata/jtwork/report/filtered/newFailedTestCases.html
            
Specification for BadLocationException states:
"This exception is to report bad locations within a document model (that is, attempts to reference a location that doesn't exist)."
The following code snippet expects BadLocationException for all valid SwingConstants, but it's not always being thrown.
-----
import javax.swing.*;
import javax.swing.text.NavigationFilter;
import javax.swing.text.Position;
import javax.swing.text.BadLocationException;
public class NF0006Snippet {
public static void main(String[] args) throws BadLocationException, InterruptedException {
JFormattedTextField jtf = new JFormattedTextField();
NavigationFilter nf = new NavigationFilter();
jtf.setText("A text message");
JFrame jFrame = new JFrame();
jFrame.getContentPane().add(jtf);
jFrame.pack();
jFrame.setVisible(true);
Position.Bias[] biasRet = {Position.Bias.Forward};
for (int swingConstant : new int[]{
SwingConstants.EAST,
SwingConstants.WEST,
// the following constants still will lead to "BadLocationException: Length must be positive"
// SwingConstants.SOUTH,
// SwingConstants.NORTH,
}) {
for (int position : new int[] {-100, Integer.MIN_VALUE} ) {
nf.getNextVisualPositionFrom(jtf, position, Position.Bias.Backward, swingConstant, biasRet);
nf.getNextVisualPositionFrom(jtf, position, Position.Bias.Forward, swingConstant, biasRet);
}
}
jFrame.dispose();
}
}
-----
JCK-runtime-7 b03
JDK 7 b30
Platform: Windows, Solaris
The following JCK test fails due to this problem:
api/javax_swing/text/NavigationFilter/index.html#Methods[NavigationFilter0006]
http://moonblade.russia.sun.com/set/java/jck/qa-results/jck/7/ea/b03/results/qac/m002_b30_failed_c1/solaris-amd64-080723150835/execdata/jtwork/report/filtered/newFailedTestCases.html
- duplicates
- 
                    JDK-7016396 (spec) JCK test mentioned in 6735293 is still failing -           
- Closed
 
-         
- relates to
- 
                    JDK-6771184 Some methods in text package don't throw BadLocationException when expected -           
- Closed
 
-