src/share/jaxws_classes/com/sun/tools/internal/xjc/model/nav/Utils.java

changeset 721
06807f9a6835
parent 567
7d8cd27f1543
child 760
e530533619ec
     1.1 --- a/src/share/jaxws_classes/com/sun/tools/internal/xjc/model/nav/Utils.java	Mon Oct 27 12:57:38 2014 -0700
     1.2 +++ b/src/share/jaxws_classes/com/sun/tools/internal/xjc/model/nav/Utils.java	Fri Oct 24 15:02:28 2014 +0200
     1.3 @@ -38,6 +38,9 @@
     1.4  
     1.5  /**
     1.6   * Utils class.
     1.7 + *
     1.8 + * WARNING: If you are doing any changes don't forget to change other Utils classes in different packages.
     1.9 + *
    1.10   * Has *package private* access to avoid inappropriate usage.
    1.11   */
    1.12  final class Utils {
    1.13 @@ -51,17 +54,20 @@
    1.14  
    1.15      static { // we statically initializing REFLECTION_NAVIGATOR property
    1.16          try {
    1.17 -            Class refNav = Class.forName("com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator");
    1.18 -            //noinspection unchecked
    1.19 -            final Method getInstance = refNav.getDeclaredMethod("getInstance");
    1.20 +            final Class refNav = Class.forName("com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator");
    1.21  
    1.22              // requires accessClassInPackage privilege
    1.23 -            AccessController.doPrivileged(
    1.24 -                    new PrivilegedAction<Object>() {
    1.25 +            final Method getInstance = AccessController.doPrivileged(
    1.26 +                    new PrivilegedAction<Method>() {
    1.27                          @Override
    1.28 -                        public Object run() {
    1.29 -                            getInstance.setAccessible(true);
    1.30 -                            return null;
    1.31 +                        public Method run() {
    1.32 +                            try {
    1.33 +                                Method getInstance = refNav.getDeclaredMethod("getInstance");
    1.34 +                                getInstance.setAccessible(true);
    1.35 +                                return getInstance;
    1.36 +                            } catch (NoSuchMethodException e) {
    1.37 +                                throw new IllegalStateException("ReflectionNavigator.getInstance can't be found");
    1.38 +                            }
    1.39                          }
    1.40                      }
    1.41              );
    1.42 @@ -69,16 +75,10 @@
    1.43              //noinspection unchecked
    1.44              REFLECTION_NAVIGATOR = (Navigator<Type, Class, Field, Method>) getInstance.invoke(null);
    1.45          } catch (ClassNotFoundException e) {
    1.46 -            e.printStackTrace();
    1.47              throw new IllegalStateException("Can't find ReflectionNavigator class");
    1.48          } catch (InvocationTargetException e) {
    1.49 -            e.printStackTrace();
    1.50              throw new IllegalStateException("ReflectionNavigator.getInstance throws the exception");
    1.51 -        } catch (NoSuchMethodException e) {
    1.52 -            e.printStackTrace();
    1.53 -            throw new IllegalStateException("ReflectionNavigator.getInstance can't be found");
    1.54          } catch (IllegalAccessException e) {
    1.55 -            e.printStackTrace();
    1.56              throw new IllegalStateException("ReflectionNavigator.getInstance method is inaccessible");
    1.57          } catch (SecurityException e) {
    1.58              LOGGER.log(Level.FINE, "Unable to access ReflectionNavigator.getInstance", e);

mercurial