author | duke |
Wed, 05 Jul 2017 17:52:05 +0200 | |
changeset 10620 | 9df40a1578ef |
parent 5506 | 202f599c92aa |
child 39056 | d99e63b6d962 |
permissions | -rw-r--r-- |
1852
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
1 |
/* |
5506 | 2 |
* Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. |
1852
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
4 |
* |
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
8 |
* |
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
13 |
* accompanied this code). |
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
14 |
* |
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
18 |
* |
5506 | 19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
1852
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
22 |
*/ |
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
23 |
|
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
24 |
/* @test |
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
25 |
* @bug 6794836 |
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
26 |
* @summary BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE |
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
27 |
* @author Pavel Porvatov |
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
28 |
* @run main bug6794836 |
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
29 |
*/ |
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
30 |
|
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
31 |
import javax.swing.*; |
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
32 |
import javax.swing.plaf.basic.BasicSliderUI; |
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
33 |
import java.lang.reflect.Method; |
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
34 |
import java.util.Hashtable; |
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
35 |
|
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
36 |
public class bug6794836 { |
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
37 |
public static void main(String[] args) throws Exception { |
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
38 |
new bug6794836().run(); |
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
39 |
} |
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
40 |
|
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
41 |
public void run() throws Exception { |
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
42 |
JSlider slider = new JSlider(0, Integer.MAX_VALUE); |
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
43 |
|
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
44 |
slider.setPaintLabels(true); |
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
45 |
|
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
46 |
JLabel minLabel = new JLabel("Min"); |
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
47 |
JLabel maxLabel = new JLabel("Max"); |
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
48 |
|
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
49 |
Hashtable<Integer, JLabel> labelTable = new Hashtable<Integer, JLabel>(); |
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
50 |
|
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
51 |
labelTable.put(Integer.MIN_VALUE, minLabel); |
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
52 |
labelTable.put(Integer.MAX_VALUE, maxLabel); |
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
53 |
|
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
54 |
slider.setLabelTable(labelTable); |
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
55 |
|
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
56 |
BasicSliderUI ui = (BasicSliderUI) slider.getUI(); |
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
57 |
|
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
58 |
if (invokeMethod("getHighestValueLabel", ui) != maxLabel) { |
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
59 |
fail("invalid getHighestValueLabel result"); |
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
60 |
} |
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
61 |
|
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
62 |
if (invokeMethod("getLowestValueLabel", ui) != minLabel) { |
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
63 |
fail("invalid getLowestValueLabel result"); |
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
64 |
} |
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
65 |
|
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
66 |
System.out.println("The bug6794836 test passed"); |
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
67 |
} |
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
68 |
|
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
69 |
private static Object invokeMethod(String name, BasicSliderUI ui) throws Exception { |
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
70 |
Method method = BasicSliderUI.class.getDeclaredMethod(name, null); |
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
71 |
|
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
72 |
method.setAccessible(true); |
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
73 |
|
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
74 |
return method.invoke(ui, null); |
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
75 |
} |
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
76 |
|
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
77 |
private static void fail(String s) { |
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
78 |
throw new RuntimeException("Test failed: " + s); |
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
79 |
} |
958801d67667
6794836: BasicSliderUI throws NullPointerExc when JSlider maximum is Integer.MAX_VALUE
rupashka
parents:
diff
changeset
|
80 |
} |