author | mfang |
Wed, 17 Aug 2011 14:18:26 -0700 | |
changeset 10294 | 8fcdae2a7ec7 |
parent 5506 | 202f599c92aa |
child 12636 | 03f4fb9b26be |
permissions | -rw-r--r-- |
4204
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
1 |
/* |
5506 | 2 |
* Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. |
4204
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
4 |
* |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
8 |
* |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
13 |
* accompanied this code). |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
14 |
* |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
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. |
|
4204
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
22 |
*/ |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
23 |
|
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
24 |
/* |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
25 |
* @test |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
26 |
* @bug 6822057 |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
27 |
* |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
28 |
* @summary Test verifies that list of supported graphics configurations |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
29 |
* can not be changed via modification of elements of an array |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
30 |
* returned by getConfiguration() method. |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
31 |
* |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
32 |
* @run main CloneConfigsTest |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
33 |
* @run main/othervm -Dsun.java2d.opengl=True CloneConfigsTest |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
34 |
* @run main/othervm -Dsun.java2d.d3d=true CloneConfigsTest |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
35 |
* @run main/othervm -Dsun.java2d.noddraw=true CloneConfigsTest |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
36 |
*/ |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
37 |
|
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
38 |
import java.awt.GraphicsConfiguration; |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
39 |
import java.awt.GraphicsDevice; |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
40 |
import java.awt.GraphicsEnvironment; |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
41 |
import java.awt.Rectangle; |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
42 |
import java.awt.geom.AffineTransform; |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
43 |
import java.awt.image.BufferedImage; |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
44 |
import java.awt.image.ColorModel; |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
45 |
|
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
46 |
public class CloneConfigsTest { |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
47 |
|
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
48 |
public static void main(String[] args) { |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
49 |
GraphicsEnvironment env = |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
50 |
GraphicsEnvironment.getLocalGraphicsEnvironment(); |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
51 |
|
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
52 |
GraphicsDevice[] devices = env.getScreenDevices(); |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
53 |
|
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
54 |
GraphicsConfiguration c = new TestConfig(); |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
55 |
|
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
56 |
for (GraphicsDevice gd : devices) { |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
57 |
System.out.println("Device: " + gd); |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
58 |
|
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
59 |
GraphicsConfiguration[] configs = gd.getConfigurations(); |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
60 |
|
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
61 |
for (int i = 0; i < configs.length; i++) { |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
62 |
GraphicsConfiguration gc = configs[i]; |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
63 |
System.out.println("\tConfig: " + gc); |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
64 |
|
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
65 |
configs[i] = c; |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
66 |
} |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
67 |
|
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
68 |
// verify whether array of configs was modified |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
69 |
configs = gd.getConfigurations(); |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
70 |
for (GraphicsConfiguration gc : configs) { |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
71 |
if (gc == c) { |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
72 |
throw new RuntimeException("Test failed."); |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
73 |
} |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
74 |
} |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
75 |
System.out.println("Test passed."); |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
76 |
} |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
77 |
} |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
78 |
|
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
79 |
private static class TestConfig extends GraphicsConfiguration { |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
80 |
|
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
81 |
@Override |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
82 |
public GraphicsDevice getDevice() { |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
83 |
throw new UnsupportedOperationException("Not supported yet."); |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
84 |
} |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
85 |
|
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
86 |
@Override |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
87 |
public BufferedImage createCompatibleImage(int width, int height) { |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
88 |
throw new UnsupportedOperationException("Not supported yet."); |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
89 |
} |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
90 |
|
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
91 |
@Override |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
92 |
public ColorModel getColorModel() { |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
93 |
throw new UnsupportedOperationException("Not supported yet."); |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
94 |
} |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
95 |
|
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
96 |
@Override |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
97 |
public ColorModel getColorModel(int transparency) { |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
98 |
throw new UnsupportedOperationException("Not supported yet."); |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
99 |
} |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
100 |
|
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
101 |
@Override |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
102 |
public AffineTransform getDefaultTransform() { |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
103 |
throw new UnsupportedOperationException("Not supported yet."); |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
104 |
} |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
105 |
|
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
106 |
@Override |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
107 |
public AffineTransform getNormalizingTransform() { |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
108 |
throw new UnsupportedOperationException("Not supported yet."); |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
109 |
} |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
110 |
|
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
111 |
@Override |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
112 |
public Rectangle getBounds() { |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
113 |
throw new UnsupportedOperationException("Not supported yet."); |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
114 |
} |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
115 |
|
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
116 |
} |
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
117 |
|
d8eff41661bf
6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff
changeset
|
118 |
} |