author | malenkov |
Wed, 03 Sep 2008 21:00:04 +0400 | |
changeset 1308 | db0929bb4cd4 |
child 5506 | 202f599c92aa |
permissions | -rw-r--r-- |
1308
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
1 |
/* |
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
2 |
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. |
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
4 |
* |
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
8 |
* |
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
13 |
* accompanied this code). |
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
14 |
* |
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
18 |
* |
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
19 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
20 |
* CA 95054 USA or visit www.sun.com if you need additional information or |
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
21 |
* have any questions. |
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
22 |
*/ |
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
23 |
|
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
24 |
/* |
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
25 |
* @test |
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
26 |
* @bug 6397609 |
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
27 |
* @summary Tests autocleaning |
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
28 |
* @author Sergey Malenkov |
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
29 |
*/ |
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
30 |
|
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
31 |
import java.beans.PropertyEditorManager; |
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
32 |
|
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
33 |
public class Test6397609 { |
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
34 |
public static void main(String[] args) throws Exception { |
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
35 |
MemoryClassLoader loader = new MemoryClassLoader(); |
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
36 |
PropertyEditorManager.registerEditor( |
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
37 |
Object.class, |
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
38 |
loader.compile("Editor", |
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
39 |
"public class Editor extends java.beans.PropertyEditorSupport {}")); |
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
40 |
|
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
41 |
if (!isEditorExist(Object.class)) { |
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
42 |
throw new Error("the editor is lost"); |
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
43 |
} |
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
44 |
loader = null; // clean the reference |
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
45 |
if (isEditorExist(Object.class)) { |
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
46 |
throw new Error("unexpected editor is found"); |
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
47 |
} |
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
48 |
} |
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
49 |
|
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
50 |
private static boolean isEditorExist(Class type) { |
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
51 |
for (int i = 0; i < 10; i++) { |
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
52 |
System.gc(); // clean all weak references |
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
53 |
if (null == PropertyEditorManager.findEditor(type)) { |
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
54 |
return false; |
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
55 |
} |
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
56 |
} |
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
57 |
return true; |
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
58 |
} |
db0929bb4cd4
6397609: DOC: De-register API required for PropertyEditorManager and/or doc change
malenkov
parents:
diff
changeset
|
59 |
} |