105 import jdk.internal.dynalink.support.CompositeGuardingDynamicLinker; |
105 import jdk.internal.dynalink.support.CompositeGuardingDynamicLinker; |
106 import jdk.internal.dynalink.support.CompositeTypeBasedGuardingDynamicLinker; |
106 import jdk.internal.dynalink.support.CompositeTypeBasedGuardingDynamicLinker; |
107 import jdk.internal.dynalink.support.TypeUtilities; |
107 import jdk.internal.dynalink.support.TypeUtilities; |
108 |
108 |
109 /** |
109 /** |
110 * A factory class for creating {@link DynamicLinker}s. The usual dynamic linker is a linker composed of all |
110 * A factory class for creating {@link DynamicLinker} objects. The usual dynamic |
111 * {@link GuardingDynamicLinker}s known and pre-created by the caller as well as any |
111 * linker is a linker composed of all {@link GuardingDynamicLinker} objects |
112 * guarding linkers automatically discovered as declared in |
112 * known and pre-created by the caller as well as any guarding linkers |
113 * {@code /META-INF/services/jdk.internal.dynalink.linker.GuardingDynamicLinker} resources in the classpath (see |
113 * automatically discovered as declared in |
114 * {@link ServiceLoader} for the description of this mechanism), and the standard fallback {@link BeansLinker}. |
114 * {@code /META-INF/services/jdk.internal.dynalink.linker.GuardingDynamicLinker} |
|
115 * resources in the classpath (see {@link ServiceLoader} for the description of |
|
116 * this mechanism), and the standard fallback {@link BeansLinker}. |
115 * See {@link DynamicLinker} documentation for tips on how to use this class. |
117 * See {@link DynamicLinker} documentation for tips on how to use this class. |
116 */ |
118 */ |
117 public final class DynamicLinkerFactory { |
119 public final class DynamicLinkerFactory { |
118 /** |
120 /** |
119 * Default value for {@link #setUnstableRelinkThreshold(int) unstable relink threshold}. |
121 * Default value for {@link #setUnstableRelinkThreshold(int) unstable relink |
|
122 * threshold}. |
120 */ |
123 */ |
121 public static final int DEFAULT_UNSTABLE_RELINK_THRESHOLD = 8; |
124 public static final int DEFAULT_UNSTABLE_RELINK_THRESHOLD = 8; |
122 |
125 |
123 private boolean classLoaderExplicitlySet = false; |
126 private boolean classLoaderExplicitlySet = false; |
124 private ClassLoader classLoader; |
127 private ClassLoader classLoader; |
130 private GuardedInvocationFilter prelinkFilter; |
133 private GuardedInvocationFilter prelinkFilter; |
131 private MethodTypeConversionStrategy autoConversionStrategy; |
134 private MethodTypeConversionStrategy autoConversionStrategy; |
132 private MethodHandleTransformer internalObjectsFilter; |
135 private MethodHandleTransformer internalObjectsFilter; |
133 |
136 |
134 /** |
137 /** |
135 * Sets the class loader for automatic discovery of available linkers. If not set explicitly, then the thread |
138 * Creates a new dynamic linker factory with default configuration. Upon |
136 * context class loader at the time of {@link #createLinker()} invocation will be used. |
139 * creation, the factory can be configured using various {@code setXxx()} |
137 * |
140 * methods and used to create one or more dynamic linkers according to its |
138 * @param classLoader the class loader used for the autodiscovery of available linkers. |
141 * current configuration using {@link #createLinker()}. |
|
142 */ |
|
143 public DynamicLinkerFactory() { |
|
144 } |
|
145 |
|
146 /** |
|
147 * Sets the class loader for automatic discovery of available linkers. If |
|
148 * not set explicitly, then the thread context class loader of the thread |
|
149 * invoking {@link #createLinker()} invocation will be used. |
|
150 * |
|
151 * @param classLoader the class loader used for the automatic discovery of |
|
152 * available linkers. |
139 */ |
153 */ |
140 public void setClassLoader(final ClassLoader classLoader) { |
154 public void setClassLoader(final ClassLoader classLoader) { |
141 this.classLoader = classLoader; |
155 this.classLoader = classLoader; |
142 classLoaderExplicitlySet = true; |
156 classLoaderExplicitlySet = true; |
143 } |
157 } |