public void registerStaticFields ( final Class < ? > ... classes ) { for ( final Class < ? > c : classes ) { final List < Field > fields = allFields ( c ) ; for ( final Field field : fields ) { final int mods = field . getModifiers ( ) ; if ( Modifier . isStatic ( mods ) && ! field . getType ( ) . isPrimitive ( ) ) { // System.out.println(c + " . " + field.getName()); registerConstant ( c , field . getName ( ) ) ; } } } }
registers all static fields of these classes . Those static fields won t be cloned when an instance of the class is cloned . This is useful i . e . when a static field object is added into maps or sets . At that point there is no way for the cloner to know that it was static except if it is registered .