1 /*
2 * Copyright (c) 2001, 2017, 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. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 // NewInstance.java - create a new instance of a class by name.
27 // http://www.saxproject.org
28 // Written by Edwin Goei, edwingo@apache.org
29 // and by David Brownell, dbrownell@users.sourceforge.net
30 // NO WARRANTY! This class is in the Public Domain.
31 // $Id: NewInstance.java,v 1.2 2005/06/10 03:50:50 jeffsuttor Exp $
32
33 package org.xml.sax.helpers;
34
35 import java.lang.reflect.InvocationTargetException;
36 import java.util.Objects;
37
38 /**
39 * Create a new instance of a class by name.
40 *
41 * <blockquote>
42 * <em>This module, both source code and documentation, is in the
43 * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
44 * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
45 * for further information.
46 * </blockquote>
47 *
48 * <p>This class contains a static method for creating an instance of a
49 * class from an explicit class name. It tries to use the thread's context
50 * ClassLoader if possible and falls back to using
51 * Class.forName(String).</p>
52 *
53 * <p>This code is designed to compile and run on JDK version 1.1 and later
54 * including versions of Java 2.</p>
55 *
56 * @author Edwin Goei, David Brownell
57 * @version 2.0.1 (sax2r2)
58 */
59 class NewInstance {
60 private static final String DEFAULT_PACKAGE = "com.sun.org.apache.xerces.internal";
61 private static final String DEFAULT_CLASS = "com.sun.org.apache.xerces.internal.parsers.SAXParser";
62 /**
63 * Creates a new instance of the specified class name
64 *
65 * Package private so this code is not exposed at the API level.
66 */
|
1 /*
2 * Copyright (c) 2001, 2019, 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. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package org.xml.sax.helpers;
27
28 import java.lang.reflect.InvocationTargetException;
29 import java.util.Objects;
30
31 /**
32 * Create a new instance of a class by name.
33 *
34 *
35 * <p>This class contains a static method for creating an instance of a
36 * class from an explicit class name. It tries to use the thread's context
37 * ClassLoader if possible and falls back to using
38 * Class.forName(String).</p>
39 *
40 * <p>This code is designed to compile and run on JDK version 1.1 and later
41 * including versions of Java 2.</p>
42 *
43 * @author Edwin Goei, David Brownell
44 * @version 2.0.1 (sax2r2)
45 */
46 class NewInstance {
47 private static final String DEFAULT_PACKAGE = "com.sun.org.apache.xerces.internal";
48 private static final String DEFAULT_CLASS = "com.sun.org.apache.xerces.internal.parsers.SAXParser";
49 /**
50 * Creates a new instance of the specified class name
51 *
52 * Package private so this code is not exposed at the API level.
53 */
|