Skip to content

Commit

Permalink
[Java] use java.lang.ClassValue to cache Lookup (#844)
Browse files Browse the repository at this point in the history
* use java.lang.ClassValue to cache lookup

* lint code

* lint code
  • Loading branch information
chaokunyang authored Aug 6, 2023
1 parent 35a2dc8 commit 6e53f9c
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,19 @@ public class _JDKAccess {
}
}

private static final ClassValue<Lookup> lookupCache =
new ClassValue<Lookup>() {
@Override
protected Lookup computeValue(Class type) {
return _Lookup._trustedLookup(type);
}
};

// CHECKSTYLE.OFF:MethodName

public static Lookup _trustedLookup(Class<?> objectClass) {
// CHECKSTYLE.ON:MethodName
return _Lookup._trustedLookup(objectClass);
return lookupCache.get(objectClass);
}

public static <T> T tryMakeFunction(
Expand Down

0 comments on commit 6e53f9c

Please sign in to comment.