MCPcopy Index your code
hub / github.com/java-native-access/jna / updateStructureByReference

Method updateStructureByReference

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

Only keep the original structure if its native address is unchanged. Otherwise replace it with a new object. @param type Structure subclass @param s Original Structure object @param address the native struct @return Updated Structure.ByReference object

(Class<T> type, T s, Pointer address)

Source from the content-addressed store, hash-verified

693 * @return Updated <code>Structure.ByReference</code> object
694 */
695 static <T extends Structure> T updateStructureByReference(Class<T> type, T s, Pointer address) {
696 if (address == null) {
697 s = null;
698 }
699 else {
700 if (s == null || !address.equals(s.getPointer())) {
701 Structure s1 = reading().get(address);
702 if (s1 != null && type.equals(s1.getClass())) {
703 s = (T) s1;
704 s.autoRead();
705 }
706 else {
707 s = newInstance(type, address);
708 s.conditionalAutoRead();
709 }
710 }
711 else {
712 s.autoRead();
713 }
714 }
715 return s;
716 }
717
718 /** Read the given field and return its value. The Java field will be
719 * updated from the contents of native memory.

Callers 3

getValueMethod · 0.95
readArrayMethod · 0.95
invokeMethod · 0.95

Calls 7

readingMethod · 0.95
newInstanceMethod · 0.95
autoReadMethod · 0.80
conditionalAutoReadMethod · 0.80
getPointerMethod · 0.65
equalsMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected