Skip to content

Commit

Permalink
fix(java): References within InvocationHandler, Issue #1364 - checkst…
Browse files Browse the repository at this point in the history
…yle fixups
  • Loading branch information
cn-at-osmit committed Feb 8, 2024
1 parent bc5b56a commit 0a4f45a
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions java/fury-core/src/main/java/org/apache/fury/util/Platform.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,19 +144,19 @@ public static long objectFieldOffset(Field f) {
}

/**
* Gets the offset of the only field in the class matching the required type
* Gets the offset of the only field in the class matching the required type.
*
* @param clazz the class in which the field should be declared
* @param fieldType the required type of the field
* @return
* @return offset of the field
* @throws IllegalStateException if there are multiple fields of the required type
* @throws IllegalArgumentException if there are no fields of the required type
*/
public static long objectFieldOffset(Class<?> clazz, Class<?> fieldType) {
Field f = null;
for (Field fi : clazz.getDeclaredFields()) {
if (fieldType.equals(fi.getType())) {
if (f != null)
if (f != null) {
throw new IllegalStateException(
"Found multiple field s matching "
+ fieldType
Expand All @@ -166,13 +166,14 @@ public static long objectFieldOffset(Class<?> clazz, Class<?> fieldType) {
+ f
+ " and "
+ fi);

}
f = fi;
}
}
if (f == null)
if (f == null) {
throw new IllegalArgumentException(
"Found no field matching " + fieldType.getName() + " in " + clazz + "!");
}
return objectFieldOffset(f);
}

Expand Down

0 comments on commit 0a4f45a

Please sign in to comment.