Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/jdk17u
Path: blob/master/test/jdk/javax/swing/JEditorPane/8080972/TestJEditor.java
58328 views
1
/*
2
* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
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.
22
*/
23
import java.io.IOException;
24
import java.io.InputStream;
25
import java.io.OutputStream;
26
import java.io.Reader;
27
import java.io.Writer;
28
import javax.swing.Action;
29
import javax.swing.JEditorPane;
30
import javax.swing.SwingUtilities;
31
import javax.swing.text.BadLocationException;
32
import javax.swing.text.Caret;
33
import javax.swing.text.Document;
34
import javax.swing.text.EditorKit;
35
import javax.swing.text.ViewFactory;
36
37
/*
38
* @test
39
* @bug 8080972 8169887
40
* @summary Audit Core Reflection in module java.desktop for places that will
41
* require changes to work with modules
42
* @author Alexander Scherbatiy
43
* @run main/othervm -Djava.security.manager=allow TestJEditor
44
*/
45
public class TestJEditor {
46
47
public static void main(String[] args) throws Exception {
48
49
SwingUtilities.invokeAndWait(TestJEditor::testJEditorPane);
50
System.setSecurityManager(new SecurityManager());
51
SwingUtilities.invokeAndWait(TestJEditor::testJEditorPane);
52
}
53
54
private static void testJEditorPane() {
55
56
try {
57
58
JEditorPane.registerEditorKitForContentType("text/html", UserEditorKit.class.getName());
59
EditorKit editorKit = JEditorPane.createEditorKitForContentType("text/html");
60
61
if (!(editorKit instanceof UserEditorKit)) {
62
throw new RuntimeException("Editor kit is not UserEditorKit!");
63
}
64
} catch (Exception e) {
65
throw new RuntimeException(e);
66
}
67
}
68
69
public static class UserEditorKit extends EditorKit {
70
71
@Override
72
public String getContentType() {
73
throw new UnsupportedOperationException("Not supported yet.");
74
}
75
76
@Override
77
public ViewFactory getViewFactory() {
78
throw new UnsupportedOperationException("Not supported yet.");
79
}
80
81
@Override
82
public Action[] getActions() {
83
throw new UnsupportedOperationException("Not supported yet.");
84
}
85
86
@Override
87
public Caret createCaret() {
88
throw new UnsupportedOperationException("Not supported yet.");
89
}
90
91
@Override
92
public Document createDefaultDocument() {
93
throw new UnsupportedOperationException("Not supported yet.");
94
}
95
96
@Override
97
public void read(InputStream in, Document doc, int pos) throws IOException, BadLocationException {
98
throw new UnsupportedOperationException("Not supported yet.");
99
}
100
101
@Override
102
public void write(OutputStream out, Document doc, int pos, int len) throws IOException, BadLocationException {
103
throw new UnsupportedOperationException("Not supported yet.");
104
}
105
106
@Override
107
public void read(Reader in, Document doc, int pos) throws IOException, BadLocationException {
108
throw new UnsupportedOperationException("Not supported yet.");
109
}
110
111
@Override
112
public void write(Writer out, Document doc, int pos, int len) throws IOException, BadLocationException {
113
throw new UnsupportedOperationException("Not supported yet.");
114
}
115
}
116
}
117
118