src/share/jaxws_classes/com/sun/xml/internal/ws/spi/db/Utils.java

changeset 786
a14efa699f0f
parent 721
06807f9a6835
child 760
e530533619ec
equal deleted inserted replaced
785:e044bd1da6b8 786:a14efa699f0f
52 */ 52 */
53 static final Navigator<Type, Class, Field, Method> REFLECTION_NAVIGATOR; 53 static final Navigator<Type, Class, Field, Method> REFLECTION_NAVIGATOR;
54 54
55 static { // we statically initializing REFLECTION_NAVIGATOR property 55 static { // we statically initializing REFLECTION_NAVIGATOR property
56 try { 56 try {
57 Class refNav = Class.forName("com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator"); 57 final Class refNav = Class.forName("com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator");
58 //noinspection unchecked
59 final Method getInstance = refNav.getDeclaredMethod("getInstance");
60 58
61 // requires accessClassInPackage privilege 59 // requires accessClassInPackage privilege
62 AccessController.doPrivileged( 60 final Method getInstance = AccessController.doPrivileged(
63 new PrivilegedAction<Object>() { 61 new PrivilegedAction<Method>() {
64 @Override 62 @Override
65 public Object run() { 63 public Method run() {
66 getInstance.setAccessible(true); 64 try {
67 return null; 65 Method getInstance = refNav.getDeclaredMethod("getInstance");
66 getInstance.setAccessible(true);
67 return getInstance;
68 } catch (NoSuchMethodException e) {
69 throw new IllegalStateException("ReflectionNavigator.getInstance can't be found");
70 }
68 } 71 }
69 } 72 }
70 ); 73 );
71 74
72 //noinspection unchecked 75 //noinspection unchecked
73 REFLECTION_NAVIGATOR = (Navigator<Type, Class, Field, Method>) getInstance.invoke(null); 76 REFLECTION_NAVIGATOR = (Navigator<Type, Class, Field, Method>) getInstance.invoke(null);
74 } catch (ClassNotFoundException e) { 77 } catch (ClassNotFoundException e) {
75 e.printStackTrace();
76 throw new IllegalStateException("Can't find ReflectionNavigator class"); 78 throw new IllegalStateException("Can't find ReflectionNavigator class");
77 } catch (InvocationTargetException e) { 79 } catch (InvocationTargetException e) {
78 e.printStackTrace();
79 throw new IllegalStateException("ReflectionNavigator.getInstance throws the exception"); 80 throw new IllegalStateException("ReflectionNavigator.getInstance throws the exception");
80 } catch (NoSuchMethodException e) {
81 e.printStackTrace();
82 throw new IllegalStateException("ReflectionNavigator.getInstance can't be found");
83 } catch (IllegalAccessException e) { 81 } catch (IllegalAccessException e) {
84 e.printStackTrace();
85 throw new IllegalStateException("ReflectionNavigator.getInstance method is inaccessible"); 82 throw new IllegalStateException("ReflectionNavigator.getInstance method is inaccessible");
86 } catch (SecurityException e) { 83 } catch (SecurityException e) {
87 LOGGER.log(Level.FINE, "Unable to access ReflectionNavigator.getInstance", e); 84 LOGGER.log(Level.FINE, "Unable to access ReflectionNavigator.getInstance", e);
88 throw e; 85 throw e;
89 } 86 }

mercurial