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

Method validateFields

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

ensure all fields are of valid type.

()

Source from the content-addressed store, hash-verified

1303
1304 /** ensure all fields are of valid type. */
1305 private void validateFields() {
1306 // Try to read the value under the read lock
1307 cacheStructureLock.readLock().lock();
1308 try {
1309 if (validationMap.containsKey(getClass())) {
1310 return; // Return because this Structure has already been validated
1311 }
1312 } finally {
1313 cacheStructureLock.readLock().unlock();
1314 }
1315
1316 // If not found, perform validation and update the cache under the write lock
1317 cacheStructureLock.writeLock().lock();
1318 try {
1319 // Double-check if another thread has computed the value before we do (see JavaDoc)
1320 validationMap.computeIfAbsent(getClass(), (cls) -> {
1321 for (Field f : getFieldList()) {
1322 validateField(f.getName(), f.getType());
1323 }
1324 return true;
1325 });
1326 } finally {
1327 cacheStructureLock.writeLock().unlock();
1328 }
1329 }
1330
1331 /** Calculates the size, alignment, and field layout of this structure.
1332 Also initializes any null-valued Structure or NativeMapped

Callers 1

StructureMethod · 0.95

Calls 6

getFieldListMethod · 0.95
validateFieldMethod · 0.95
lockMethod · 0.80
unlockMethod · 0.80
getNameMethod · 0.65
getTypeMethod · 0.45

Tested by

no test coverage detected