Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
tweimer committed Jul 17, 2021
1 parent 0ac1457 commit 84859d5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/main/java/com/rits/cloning/Cloner.java
Original file line number Diff line number Diff line change
Expand Up @@ -578,15 +578,17 @@ private class CloneObjectCloner implements IDeepCloner {
do {
Field[] fs = sc.getDeclaredFields();
for (final Field f : fs) {
if (!f.isAccessible()) {
f.setAccessible(true);
}
int modifiers = f.getModifiers();
if (!Modifier.isStatic(modifiers)) {
if (!(nullTransient && Modifier.isTransient(modifiers)) && !isFieldNullInsteadBecauseOfAnnotation(f)) {
l.add(f);
boolean shouldClone = (cloneSynthetics || !f.isSynthetic()) && (cloneAnonymousParent || !isAnonymousParent(f));
shouldCloneList.add(shouldClone);
if (shouldClone) {
if (!f.isAccessible()) {
f.setAccessible(true);
}
}
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/test/java/com/rits/tests/cloning/TestCloner.java
Original file line number Diff line number Diff line change
Expand Up @@ -908,5 +908,11 @@ public void testLinkedHashSetWithMitableValue() {
assertEquals("Cloned value not equal to original object", dc, dc2);

}

public void testStaticTransientMembers() {
class StaticTransient extends ArrayList<String> {};

cloner.deepClone(new StaticTransient());
}
}

0 comments on commit 84859d5

Please sign in to comment.