mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2026-05-29 18:57:11 +08:00
AnnotationUtil新增两级缓存架构,提升高频注解解析性能(pr#1434@Gitee)
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
|
||||
# 🚀Changelog
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
# 5.8.45
|
||||
# 5.8.45(2026-03-19)
|
||||
### 🐣新特性
|
||||
* 【core 】 `AnnotationUtil`新增两级缓存架构,提升高频注解解析性能(pr#1434@Gitee)
|
||||
|
||||
### 🐞Bug修复
|
||||
|
||||
|
||||
@@ -9,10 +9,9 @@ import cn.hutool.core.exceptions.UtilException;
|
||||
import cn.hutool.core.lang.Opt;
|
||||
import cn.hutool.core.lang.func.Func1;
|
||||
import cn.hutool.core.lang.func.LambdaUtil;
|
||||
import cn.hutool.core.map.WeakConcurrentMap;
|
||||
import cn.hutool.core.map.reference.WeakKeyConcurrentMap;
|
||||
import cn.hutool.core.util.*;
|
||||
|
||||
|
||||
import java.lang.annotation.*;
|
||||
import java.lang.invoke.SerializedLambda;
|
||||
import java.lang.reflect.AnnotatedElement;
|
||||
@@ -58,14 +57,14 @@ public class AnnotationUtil {
|
||||
* 键:注解查询键(被注解元素 + 目标注解类型)<br>
|
||||
* 值:原生注解对象,或NULL_ANNOTATION_SENTINEL(表示不存在)
|
||||
*/
|
||||
private static final WeakConcurrentMap<AnnotationLookupKey, Annotation> L1_ANNOTATION_CACHE = new WeakConcurrentMap<>();
|
||||
private static final WeakKeyConcurrentMap<AnnotationLookupKey, Annotation> L1_ANNOTATION_CACHE = new WeakKeyConcurrentMap<>();
|
||||
|
||||
/**
|
||||
* L2 合成注解缓存(别名/聚合场景)<br>
|
||||
* 键:注解查询键(被注解元素 + 目标注解类型)<br>
|
||||
* 值:合成注解对象,或NULL_ANNOTATION_SENTINEL(表示不存在)
|
||||
*/
|
||||
private static final WeakConcurrentMap<AnnotationLookupKey, Annotation> L2_SYNTHESIZED_ANNOTATION_CACHE = new WeakConcurrentMap<>();
|
||||
private static final WeakKeyConcurrentMap<AnnotationLookupKey, Annotation> L2_SYNTHESIZED_ANNOTATION_CACHE = new WeakKeyConcurrentMap<>();
|
||||
|
||||
/**
|
||||
* 注解查询缓存键,唯一标识一次注解查询操作
|
||||
|
||||
Reference in New Issue
Block a user