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
publicclassTest {
interfaceFoo {
}
classBarimplementsFoo {
}
publicstaticvoidmain(String[] args) {
ClassLoaderclassLoader = ClassLoader.getSystemClassLoader();
TypePoolsystemTypePool = TypePool.Default.of(classLoader);
TypePoollazyResolution = newTypePool.Default.WithLazyResolution(
TypePool.CacheProvider.NoOp.INSTANCE,
ClassFileLocator.ForClassLoader.of(classLoader),
TypePool.Default.ReaderMode.FAST,
systemTypePool
);
TypePoollazyFacade = newTypePool.LazyFacade(lazyResolution);
// the bar holds the typePool: lazyResolution.TypeDescriptionbar = lazyFacade.describe(Bar.class.getName()).resolve();
// the foo is resolved by `systemTypePool.describe().resolve()` instead of `lazyFacade.describe().resolve()`TypeList.Genericinterfaces = bar.getInterfaces();
for (TypeDescription.Genericitem : interfaces) {
item.asErasure();
}
}
}
In the above code, when using the standard API to resolve the interface list information of bar, the initial LazyFacade is not attempted. In some scenarios, this is unexpected for me, causing certain logic that could have been skipped based on name checks to ultimately be interrupted by a NoSuchTypeException.
Specifically, some runtime types are modified by certain javaagents and implement specific interfaces within the agent. These types then cannot be resolved in my own agent, causing exceptions during type hierarchy traversal when using ElementMatchers.hasSuperType.
It's also worth mentioning that when there are unknown types in the interface implementation list, the iterator traversal form will encounter exceptions. For instance, if we assume that bar.getInterfaces() contains types not visible to the current TypePool, the following code will throw an exception (NoSuchTypeException). However, if traversed by index as shown below, no exception will occur:
for (TypeDescription.Genericitem : interfaces) {
// Potentially throws NoSuchTypeException
}
versus:
for (inti = 0; i < interfaces.size(); i++) {
// working wellTypeDescription.Genericitem = interfaces.get(i);
}
The text was updated successfully, but these errors were encountered:
Not sure I follow and I cannot reproduce the behaviour bellow. Can you create a reproducer project that demonstrates this? It is fully possible that I overlooked a lazy resolution somewhere. If you mix a lazy pool and an eager pool, as it seems to be the case however, there are no guarantees given.
In the process of reproducing the issue, I observed further and found that it might be related to type caching operations.
During the WithLazyResolution.doResolve call, if it encounters an invisible type, it ultimately registers an Illegal object with the CacheProvider. This causes types that are invisible to WithLazyResolution to only provide the target type's name information during the first call to TypePool.describe. Subsequent calls will fail to successfully return a LazyResolution object because they cache the Illegal object, preventing the retrieval of the type's name information in later processes.
In the above code, when using the standard API to resolve the interface list information of
bar
, the initialLazyFacade
is not attempted. In some scenarios, this is unexpected for me, causing certain logic that could have been skipped based on name checks to ultimately be interrupted by aNoSuchTypeException
.Specifically, some runtime types are modified by certain javaagents and implement specific interfaces within the agent. These types then cannot be resolved in my own agent, causing exceptions during type hierarchy traversal when using
ElementMatchers.hasSuperType
.It's also worth mentioning that when there are unknown types in the interface implementation list, the iterator traversal form will encounter exceptions. For instance, if we assume that
bar.getInterfaces()
contains types not visible to the current TypePool, the following code will throw an exception (NoSuchTypeException
). However, if traversed by index as shown below, no exception will occur:versus:
The text was updated successfully, but these errors were encountered: