enjoy 3.3 release ^_^
This commit is contained in:
@@ -17,21 +17,21 @@
|
||||
package com.jfinal.template.expr.ast;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* FieldKit
|
||||
*/
|
||||
public class FieldKit {
|
||||
|
||||
private static final ConcurrentHashMap<String, Object> fieldCache = new ConcurrentHashMap<String, Object>();
|
||||
private static final HashMap<Long, Object> fieldCache = new HashMap<Long, Object>();
|
||||
|
||||
public static Field getField(String key, Class<?> targetClass, String fieldName) {
|
||||
public static Field getField(Long key, Class<?> targetClass, String fieldName) {
|
||||
Object field = fieldCache.get(key);
|
||||
if (field == null) {
|
||||
field = doGetField(targetClass, fieldName);
|
||||
if (field != null) {
|
||||
fieldCache.putIfAbsent(key, field);
|
||||
fieldCache.put(key, field);
|
||||
} else {
|
||||
// 对于不存在的 Field,只进行一次获取操作,主要为了支持 null safe,未来需要考虑内存泄漏风险
|
||||
fieldCache.put(key, Boolean.FALSE);
|
||||
@@ -49,14 +49,6 @@ public class FieldKit {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 Field 用于缓存的 key
|
||||
*/
|
||||
public static String getFieldKey(Class<?> targetClass, String getterName) {
|
||||
return new StringBuilder(64).append(targetClass.getName())
|
||||
.append('.').append(getterName).toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user