private static Reference<Map<Class, Map<Collection<Annotation>, Type>>> typeCacheReference;
static Type getType(jnr.ffi.Runtime runtime, Class javaType, Collection<Annotation> annotations) {
Map<Class, Map<Collection<Annotation>, Type>> cache = typeCacheReference != null ? typeCacheReference.get() : null;
Map<Collection<Annotation>, Type> aliasCache = cache != null ? cache.get(javaType) : null;
Type type = aliasCache != null ? aliasCache.get(annotations) : null;
return type != null ? type : lookupAndCacheType(runtime, javaType, annotations);
}