jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/nav/ReflectionNavigator.java
equal
deleted
inserted
replaced
42 |
42 |
43 /** |
43 /** |
44 * {@link Navigator} implementation for {@code java.lang.reflect}. |
44 * {@link Navigator} implementation for {@code java.lang.reflect}. |
45 * |
45 * |
46 */ |
46 */ |
47 public final class ReflectionNavigator implements Navigator<Type, Class, Field, Method> { |
47 /*package*/final class ReflectionNavigator implements Navigator<Type, Class, Field, Method> { |
48 |
48 |
49 /** |
49 // ---------- Singleton ----------------- |
50 * Singleton. |
50 private static final ReflectionNavigator INSTANCE = new ReflectionNavigator(); |
51 * |
51 |
52 * Use {@link Navigator#REFLECTION} |
52 /*package*/static ReflectionNavigator getInstance() { |
53 */ |
53 return INSTANCE; |
54 ReflectionNavigator() { |
54 } |
55 } |
55 |
|
56 private ReflectionNavigator() { |
|
57 } |
|
58 // --------------------------------------- |
56 |
59 |
57 public Class getSuperClass(Class clazz) { |
60 public Class getSuperClass(Class clazz) { |
58 if (clazz == Object.class) { |
61 if (clazz == Object.class) { |
59 return null; |
62 return null; |
60 } |
63 } |
62 if (sc == null) { |
65 if (sc == null) { |
63 sc = Object.class; // error recovery |
66 sc = Object.class; // error recovery |
64 } |
67 } |
65 return sc; |
68 return sc; |
66 } |
69 } |
|
70 |
67 private static final TypeVisitor<Type, Class> baseClassFinder = new TypeVisitor<Type, Class>() { |
71 private static final TypeVisitor<Type, Class> baseClassFinder = new TypeVisitor<Type, Class>() { |
68 |
72 |
69 public Type onClass(Class c, Class sup) { |
73 public Type onClass(Class c, Class sup) { |
70 // t is a raw type |
74 // t is a raw type |
71 if (sup == c) { |
75 if (sup == c) { |
494 public boolean hasDefaultConstructor(Class c) { |
498 public boolean hasDefaultConstructor(Class c) { |
495 try { |
499 try { |
496 c.getDeclaredConstructor(); |
500 c.getDeclaredConstructor(); |
497 return true; |
501 return true; |
498 } catch (NoSuchMethodException e) { |
502 } catch (NoSuchMethodException e) { |
499 return false; |
503 return false; // todo: do this WITHOUT exception throw |
500 } |
504 } |
501 } |
505 } |
502 |
506 |
503 public boolean isStaticField(Field field) { |
507 public boolean isStaticField(Field field) { |
504 return Modifier.isStatic(field.getModifiers()); |
508 return Modifier.isStatic(field.getModifiers()); |
542 } else { |
546 } else { |
543 return name.substring(0, idx); |
547 return name.substring(0, idx); |
544 } |
548 } |
545 } |
549 } |
546 |
550 |
547 public Class findClass(String className, Class referencePoint) { |
551 @Override |
|
552 public Class loadObjectFactory(Class referencePoint, String pkg) { |
|
553 ClassLoader cl= SecureLoader.getClassClassLoader(referencePoint); |
|
554 if (cl == null) |
|
555 cl = SecureLoader.getSystemClassLoader(); |
|
556 |
548 try { |
557 try { |
549 ClassLoader cl = SecureLoader.getClassClassLoader(referencePoint); |
558 return cl.loadClass(pkg + ".ObjectFactory"); |
550 if (cl == null) { |
|
551 cl = SecureLoader.getSystemClassLoader(); |
|
552 } |
|
553 return cl.loadClass(className); |
|
554 } catch (ClassNotFoundException e) { |
559 } catch (ClassNotFoundException e) { |
555 return null; |
560 return null; |
556 } |
561 } |
557 } |
562 } |
558 |
563 |