S
- The type of the key that is used for identifying stored classes per class loader. Such keys must not strongly reference any
types or class loaders without potentially corrupting the garbage eligibility of stored classes. As the storage is segmented
by class loader, it is normally sufficient to store types by their name.public static class TypeCache.WithInlineExpunction<S> extends TypeCache<S>
TypeCache
where obsolete references are cleared upon any call.TypeCache
TypeCache.LookupKey, TypeCache.SimpleKey, TypeCache.Sort, TypeCache.StorageKey, TypeCache.WithInlineExpunction<S>
Constructor and Description |
---|
WithInlineExpunction()
Creates a new type cache with inlined expunction and strong references to the stored types.
|
WithInlineExpunction(TypeCache.Sort sort)
Creates a new type cache with inlined expunction.
|
Modifier and Type | Method and Description |
---|---|
Class<?> |
find(ClassLoader classLoader,
S key)
Finds a stored type or returns
null if no type was stored. |
Class<?> |
findOrInsert(ClassLoader classLoader,
S key,
Callable<Class<?>> builder)
Finds an existing type or inserts a new one if the previous type was not found.
|
Class<?> |
findOrInsert(ClassLoader classLoader,
S key,
Callable<Class<?>> builder,
Object monitor)
Finds an existing type or inserts a new one if the previous type was not found.
|
Class<?> |
insert(ClassLoader classLoader,
S key,
Class<?> type)
Inserts a new type into the cache.
|
clear, expungeStaleEntries
poll, remove, remove
public WithInlineExpunction()
public WithInlineExpunction(TypeCache.Sort sort)
sort
- The reference type to use for stored types.public Class<?> find(@MaybeNull ClassLoader classLoader, S key)
null
if no type was stored.public Class<?> insert(@MaybeNull ClassLoader classLoader, S key, Class<?> type)
insert
in class TypeCache<S>
classLoader
- The class loader for which this type is stored or null
for the bootstrap loader.key
- The key for the type in question.type
- The type to insert of no previous type was stored in the cache.public Class<?> findOrInsert(@MaybeNull ClassLoader classLoader, S key, Callable<Class<?>> builder)
findOrInsert
in class TypeCache<S>
classLoader
- The class loader for which this type is stored or null
for the bootstrap loader.key
- The key for the type in question.builder
- A lazy creator for the type to insert of no previous type was stored in the cache.public Class<?> findOrInsert(@MaybeNull ClassLoader classLoader, S key, Callable<Class<?>> builder, Object monitor)
findOrInsert
in class TypeCache<S>
classLoader
- The class loader for which this type is stored or null
for the bootstrap loader.key
- The key for the type in question.builder
- A lazy creator for the type to insert of no previous type was stored in the cache.monitor
- A monitor to lock before creating the lazy type.Copyright © 2014–2024. All rights reserved.