src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/Utils.java

Fri, 14 Feb 2014 10:53:55 +0100

author
mkos
date
Fri, 14 Feb 2014 10:53:55 +0100
changeset 514
29a761eaff0d
parent 450
b0c2840e2513
child 567
7d8cd27f1543
permissions
-rw-r--r--

8025030: Enhance stream handling
Summary: Avoiding caching data initialized via TCCL in static context; fix also reviewed by Iaroslav Savytskyi, Alexander Fomin
Reviewed-by: ahgross, mgrebac, skoivu

mkos@450 1 /*
mkos@450 2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
mkos@450 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
mkos@450 4 *
mkos@450 5 * This code is free software; you can redistribute it and/or modify it
mkos@450 6 * under the terms of the GNU General Public License version 2 only, as
mkos@450 7 * published by the Free Software Foundation. Oracle designates this
mkos@450 8 * particular file as subject to the "Classpath" exception as provided
mkos@450 9 * by Oracle in the LICENSE file that accompanied this code.
mkos@450 10 *
mkos@450 11 * This code is distributed in the hope that it will be useful, but WITHOUT
mkos@450 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
mkos@450 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
mkos@450 14 * version 2 for more details (a copy is included in the LICENSE file that
mkos@450 15 * accompanied this code).
mkos@450 16 *
mkos@450 17 * You should have received a copy of the GNU General Public License version
mkos@450 18 * 2 along with this work; if not, write to the Free Software Foundation,
mkos@450 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
mkos@450 20 *
mkos@450 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
mkos@450 22 * or visit www.oracle.com if you need additional information or have any
mkos@450 23 * questions.
mkos@450 24 */
mkos@450 25
mkos@450 26 package com.sun.xml.internal.bind.v2.runtime;
mkos@450 27
mkos@450 28 import com.sun.xml.internal.bind.v2.model.nav.Navigator;
mkos@450 29
mkos@450 30 import java.lang.reflect.Field;
mkos@450 31 import java.lang.reflect.InvocationTargetException;
mkos@450 32 import java.lang.reflect.Method;
mkos@450 33 import java.lang.reflect.Type;
mkos@450 34 import java.util.logging.Level;
mkos@450 35 import java.util.logging.Logger;
mkos@450 36
mkos@450 37 /**
mkos@450 38 * Utils class.
mkos@450 39 * Has *package private* access to avoid inappropriate usage.
mkos@450 40 */
mkos@450 41 /* package */ final class Utils {
mkos@450 42
mkos@450 43 private static final Logger LOGGER = Logger.getLogger(Utils.class.getName());
mkos@450 44
mkos@450 45 /**
mkos@450 46 * static ReflectionNavigator field to avoid usage of reflection every time we use it.
mkos@450 47 */
mkos@450 48 /* package */ static final Navigator<Type, Class, Field, Method> REFLECTION_NAVIGATOR;
mkos@450 49
mkos@450 50 static { // we statically initializing REFLECTION_NAVIGATOR property
mkos@450 51 Class refNav = null;
mkos@450 52 try {
mkos@450 53 refNav = Class.forName("com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator");
mkos@450 54 //noinspection unchecked
mkos@450 55 Method getInstance = refNav.getDeclaredMethod("getInstance");
mkos@450 56 getInstance.setAccessible(true);
mkos@450 57 //noinspection unchecked
mkos@450 58 REFLECTION_NAVIGATOR = (Navigator<Type, Class, Field, Method>) getInstance.invoke(null);
mkos@450 59 } catch (ClassNotFoundException e) {
mkos@450 60 e.printStackTrace();
mkos@450 61 throw new IllegalStateException("Can't find ReflectionNavigator class");
mkos@450 62 } catch (InvocationTargetException e) {
mkos@450 63 e.printStackTrace();
mkos@450 64 throw new IllegalStateException("ReflectionNavigator.getInstance throws the exception");
mkos@450 65 } catch (NoSuchMethodException e) {
mkos@450 66 e.printStackTrace();
mkos@450 67 throw new IllegalStateException("ReflectionNavigator.getInstance can't be found");
mkos@450 68 } catch (IllegalAccessException e) {
mkos@450 69 e.printStackTrace();
mkos@450 70 throw new IllegalStateException("ReflectionNavigator.getInstance method is inaccessible");
mkos@450 71 } catch (SecurityException e) {
mkos@450 72 LOGGER.log(Level.FINE, "Unable to access ReflectionNavigator.getInstance", e);
mkos@450 73 throw e;
mkos@450 74 }
mkos@450 75 }
mkos@450 76
mkos@450 77 /**
mkos@450 78 * private constructor to avoid util class instantiating
mkos@450 79 */
mkos@450 80 private Utils() {
mkos@450 81 }
mkos@450 82 }

mercurial