/** * Assigns a {@link ConcurrentMap} instance to the given field. * Used on deserialization only. */ static <T extends MetadataStandard> void setMapForField(final Class<T> classe, final T instance, final String name) throws InvalidClassException { try { AccessController.doPrivileged(new FinalFieldSetter<>(classe, name)).set(instance, new ConcurrentHashMap<>()); } catch (ReflectiveOperationException e) { throw FinalFieldSetter.readFailure(e); } }
/** * Returns a clone of this unit format. The new unit format will be initialized to the same * {@linkplain #getLocale() locale} and {@linkplain #label(Unit, String) labels} than this format. * * @return a clone of this unit format. */ @Override public UnitFormat clone() { final UnitFormat f = (UnitFormat) super.clone(); try { AccessController.doPrivileged(new FinalFieldSetter<>(UnitFormat.class, "unitToLabel", "labelToUnit")) .set(f, clone(unitToLabel), clone(labelToUnit)); } catch (ReflectiveOperationException e) { throw FinalFieldSetter.cloneFailure(e); } return f; }
/** * Returns a clone of this range format. * * @return a clone of this range format. */ @Override public RangeFormat clone() { final RangeFormat f = (RangeFormat) super.clone(); try { AccessController.doPrivileged(new FinalFieldSetter<>(RangeFormat.class, "elementFormat", "unitFormat")) .set(f, elementFormat.clone(), unitFormat.clone()); } catch (ReflectiveOperationException e) { throw FinalFieldSetter.cloneFailure(e); } return f; } }
/** * Invoked on deserialization for restoring the {@link #parameters} array. * * @param in the input stream from which to deserialize a group of tensor parameters. * @throws IOException if an I/O error occurred while reading or if the stream contains invalid data. * @throws ClassNotFoundException if the class serialized on the stream is not on the classpath. */ private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); try { AccessController.doPrivileged(new FinalFieldSetter<>(TensorParameters.class, "parameters")).set(this, createCache()); } catch (ReflectiveOperationException e) { throw FinalFieldSetter.readFailure(e); } } }