You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I take a look at the ClassRealm code, I can see that there is only one place where the strategy is set.
public ClassRealm(ClassWorld world, String id, ClassLoader baseClassLoader) {
super(new URL[0], baseClassLoader);
this.world = world;
this.id = id;
foreignImports = new TreeSet<>();
strategy = StrategyFactory.getStrategy(this);
lockMap = isParallelCapable ? new ConcurrentHashMap<>() : null;
if (isParallelCapable) {
// We must call super.getClassLoadingLock at least once
// to avoid NPE in super.loadClass.
super.getClassLoadingLock(getClass().getName());
}
}
This place uses the StrategyFactory.getStrategy(this) method, which is a static call. The StrategyFactory does not provide any mechanism to change the behavior, like ServiceLoader or a ThreadLocal.
So how can one set a strategy without using reflection to set the private field?
If noone can ever set a strategy, what is the purpose of the subclasses like OsgiBundleStrategy.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
When I take a look at the ClassRealm code, I can see that there is only one place where the strategy is set.
This place uses the
StrategyFactory.getStrategy(this)
method, which is a static call. TheStrategyFactory
does not provide any mechanism to change the behavior, likeServiceLoader
or aThreadLocal
.So how can one set a strategy without using reflection to set the private field?
If noone can ever set a strategy, what is the purpose of the subclasses like
OsgiBundleStrategy
.Beta Was this translation helpful? Give feedback.
All reactions