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

changeset 567
7d8cd27f1543
parent 450
b0c2840e2513
child 637
9c07ef4934dd
child 721
06807f9a6835
     1.1 --- a/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/Utils.java	Tue Apr 01 12:01:34 2014 -0700
     1.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/Utils.java	Tue Apr 15 16:26:48 2014 -0400
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -31,6 +31,8 @@
    1.11  import java.lang.reflect.InvocationTargetException;
    1.12  import java.lang.reflect.Method;
    1.13  import java.lang.reflect.Type;
    1.14 +import java.security.AccessController;
    1.15 +import java.security.PrivilegedAction;
    1.16  import java.util.logging.Level;
    1.17  import java.util.logging.Logger;
    1.18  
    1.19 @@ -38,22 +40,32 @@
    1.20   * Utils class.
    1.21   * Has *package private* access to avoid inappropriate usage.
    1.22   */
    1.23 -/* package */ final class Utils {
    1.24 +final class Utils {
    1.25  
    1.26      private static final Logger LOGGER = Logger.getLogger(Utils.class.getName());
    1.27  
    1.28      /**
    1.29       * static ReflectionNavigator field to avoid usage of reflection every time we use it.
    1.30       */
    1.31 -    /* package */ static final Navigator<Type, Class, Field, Method> REFLECTION_NAVIGATOR;
    1.32 +    static final Navigator<Type, Class, Field, Method> REFLECTION_NAVIGATOR;
    1.33  
    1.34      static { // we statically initializing REFLECTION_NAVIGATOR property
    1.35 -        Class refNav = null;
    1.36          try {
    1.37 -            refNav = Class.forName("com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator");
    1.38 +            Class refNav = Class.forName("com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator");
    1.39              //noinspection unchecked
    1.40 -            Method getInstance = refNav.getDeclaredMethod("getInstance");
    1.41 -            getInstance.setAccessible(true);
    1.42 +            final Method getInstance = refNav.getDeclaredMethod("getInstance");
    1.43 +
    1.44 +            // requires accessClassInPackage privilege
    1.45 +            AccessController.doPrivileged(
    1.46 +                    new PrivilegedAction<Object>() {
    1.47 +                        @Override
    1.48 +                        public Object run() {
    1.49 +                            getInstance.setAccessible(true);
    1.50 +                            return null;
    1.51 +                        }
    1.52 +                    }
    1.53 +            );
    1.54 +
    1.55              //noinspection unchecked
    1.56              REFLECTION_NAVIGATOR = (Navigator<Type, Class, Field, Method>) getInstance.invoke(null);
    1.57          } catch (ClassNotFoundException e) {

mercurial