MCPcopy Create free account
hub / github.com/java-native-access/jna / getFieldList

Method getFieldList

src/com/sun/jna/Structure.java:1021–1059  ·  view source on GitHub ↗

Look up all fields in this class and superclasses. @return ordered list of public java.lang.reflect.Field available on this Structure class.

()

Source from the content-addressed store, hash-verified

1019 * this {@link Structure} class.
1020 */
1021 protected List<Field> getFieldList() {
1022 Class<?> clazz = getClass();
1023 // Try to read the value under the read lock
1024 cacheStructureLock.readLock().lock();
1025 try {
1026 List<Field> fields = fieldList.get(clazz);
1027 if (fields != null) {
1028 return fields; // Return the cached result if found
1029 }
1030 } finally {
1031 cacheStructureLock.readLock().unlock();
1032 }
1033
1034 // If not found, compute the value under the write lock
1035 cacheStructureLock.writeLock().lock();
1036 try {
1037 // Double-check if another thread has computed the value before we do
1038 return fieldList.computeIfAbsent(clazz, (c) -> {
1039 List<Field> flist = new ArrayList<>();
1040 List<Field> classFields = new ArrayList<>();
1041 for (Class<?> cls = clazz;
1042 !cls.equals(Structure.class);
1043 cls = cls.getSuperclass()) {
1044 for (Field field : cls.getDeclaredFields()) {
1045 int modifiers = field.getModifiers();
1046 if (Modifier.isStatic(modifiers) || !Modifier.isPublic(modifiers)) {
1047 continue;
1048 }
1049 classFields.add(field);
1050 }
1051 flist.addAll(0, classFields);
1052 classFields.clear();
1053 }
1054 return flist;
1055 });
1056 } finally {
1057 cacheStructureLock.writeLock().unlock();
1058 }
1059 }
1060
1061 /** Cache field order per-class.
1062 * @return (cached) ordered list of fields

Callers 5

getFieldsMethod · 0.95
validateFieldsMethod · 0.95
initializeFieldsMethod · 0.95
getFieldOrderMethod · 0.45

Calls 8

lockMethod · 0.80
unlockMethod · 0.80
getModifiersMethod · 0.80
isStaticMethod · 0.80
getMethod · 0.45
equalsMethod · 0.45
addMethod · 0.45
clearMethod · 0.45

Tested by 1