jdk/src/share/classes/com/sun/naming/internal/FactoryEnumeration.java
changeset 22329 4cd45450d07c
parent 10324 e28265130e4f
child 22338 fda2b44112c7
equal deleted inserted replaced
22328:5a7d30033602 22329:4cd45450d07c
    54      *
    54      *
    55      * <p> Both Class objects and factories are wrapped in weak
    55      * <p> Both Class objects and factories are wrapped in weak
    56      * references so as not to prevent GC of the class loader.  Each
    56      * references so as not to prevent GC of the class loader.  Each
    57      * weak reference is tagged with the factory's class name so the
    57      * weak reference is tagged with the factory's class name so the
    58      * class can be reloaded if the reference is cleared.
    58      * class can be reloaded if the reference is cleared.
    59 
    59      *
    60      * @param factories A non-null list
    60      * @param factories A non-null list
    61      * @param loader    The class loader of the list's contents
    61      * @param loader    The class loader of the list's contents
       
    62      *
       
    63      * This internal method is used with Thread Context Class Loader (TCCL),
       
    64      * please don't expose this method as public.
    62      */
    65      */
    63     FactoryEnumeration(List<NamedWeakReference<Object>> factories,
    66     FactoryEnumeration(List<NamedWeakReference<Object>> factories,
    64                        ClassLoader loader) {
    67                        ClassLoader loader) {
    65         this.factories = factories;
    68         this.factories = factories;
    66         this.loader = loader;
    69         this.loader = loader;
    77 
    80 
    78             String className = ref.getName();
    81             String className = ref.getName();
    79 
    82 
    80             try {
    83             try {
    81                 if (answer == null) {   // reload class if weak ref cleared
    84                 if (answer == null) {   // reload class if weak ref cleared
    82                     answer = Class.forName(className, true, loader);
    85                     Class<?> cls = Class.forName(className, true, loader);
       
    86                     VersionHelper12.checkPackageAccess(cls);
       
    87                     answer = cls;
    83                 }
    88                 }
    84                 // Instantiate Class to get factory
    89                 // Instantiate Class to get factory
    85                 answer = ((Class) answer).newInstance();
    90                 answer = ((Class) answer).newInstance();
    86                 ref = new NamedWeakReference<>(answer, className);
    91                 ref = new NamedWeakReference<>(answer, className);
    87                 factories.set(posn-1, ref);  // replace Class object or null
    92                 factories.set(posn-1, ref);  // replace Class object or null