/** * Ensure that previously-serialized instances don't fail due to the member name change. */ @SuppressWarnings("unchecked") private void readObject(ObjectInputStream is) throws ClassNotFoundException, IOException { GetField fields = is.readFields(); if (fields.defaulted("first")) { // This is a pre-V3.3 this.first = (F) fields.get("fFirst", null); this.second = (S) fields.get("fSecond", null); } else { this.first = (F) fields.get("first", null); this.second = (S) fields.get("second", null); } }
/** * readObject is called to restore the state of the URL from the * stream. It reads the components of the URL and finds the local * stream handler. */ private synchronized void readObject(java.io.ObjectInputStream s) throws IOException, ClassNotFoundException { GetField gf = s.readFields(); String protocol = (String)gf.get("protocol", null); if (getURLStreamHandler(protocol) == null) { throw new IOException("unknown protocol: " + protocol); } String host = (String)gf.get("host", null); int port = gf.get("port", -1); String authority = (String)gf.get("authority", null); String file = (String)gf.get("file", null); String ref = (String)gf.get("ref", null); int hashCode = gf.get("hashCode", -1); if (authority == null && ((host != null && host.length() > 0) || port != -1)) { if (host == null) host = ""; authority = (port == -1) ? host : host + ":" + port; } tempState = new UrlDeserializedState(protocol, host, port, authority, file, ref, hashCode); }
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { GetField fields = stream.readFields(); fromVariable = (String) fields.get("fromVariable", null); // the fields of BaseCommonReturnValue were originally in this class. // if deserializing an old object, we need to manually copy the values into the parent class. ObjectStreamClass streamClass = fields.getObjectStreamClass(); if (streamClass.getField("toVariable") != null) { this.toVariable = (String) fields.get("toVariable", null); } if (streamClass.getField("calculation") != null) { this.calculation = (CalculationEnum) fields.get("calculation", null); } if (streamClass.getField("incrementerFactoryClassName") != null) { this.incrementerFactoryClassName = (String) fields.get("incrementerFactoryClassName", null); } }
@SuppressWarnings("unchecked") private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException { setThreadJasperReportsContext(); GetField fields = in.readFields(); cachedRenderers = (Map<String, Renderable>) fields.get("cachedRenderers", null); cachedTemplates = (Map<String, JRTemplateElement>) fields.get("cachedTemplates", null); readOnly = fields.get("readOnly", false); // use configured default if serialized by old version pageElementSize = fields.get("pageElementSize", JRPropertiesUtil.getInstance(jasperReportsContext).getIntegerProperty( JRVirtualPrintPage.PROPERTY_VIRTUAL_PAGE_ELEMENT_SIZE, 0)); setThreadVirtualizer(); initLock(); }
@SuppressWarnings("deprecation") private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { GetField fields = in.readFields(); this.PSEUDO_SERIAL_VERSION_UID = fields.get("PSEUDO_SERIAL_VERSION_UID", 0); if (PSEUDO_SERIAL_VERSION_UID < JRConstants.PSEUDO_SERIAL_VERSION_UID_3_7_2) { byte evaluationTime = fields.get("evaluationTime", (byte) 0); this.evaluationTimeValue = EvaluationTimeEnum.getByValue(evaluationTime); } else { this.evaluationTimeValue = (EvaluationTimeEnum) fields.get("evaluationTimeValue", null); } this.evaluationGroup = (String) fields.get("evaluationGroup", null); this.codeExpression = (JRExpression) fields.get("codeExpression", null); if (PSEUDO_SERIAL_VERSION_UID < JRConstants.PSEUDO_SERIAL_VERSION_UID_6_0_2 && this instanceof Barcode4jComponent) { //up to 6.0.0 this class had several fields that were moved to Barcode4jComponent in 6.0.2. //copying the values to the Barcode4jComponent fields. Barcode4jComponent barcode4jComponent = (Barcode4jComponent) this; barcode4jComponent.copyBarcodeComponentFields(fields); } }
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { GetField fields = stream.readFields(); eventCount = readIntField(fields, "eventCount", 0); sessionCount = readIntField(fields, "sessionCount", 0); subsessionCount = readIntField(fields, "subsessionCount", -1); sessionLength = readLongField(fields, "sessionLength", -1l); timeSpent = readLongField(fields, "timeSpent", -1l); lastActivity = readLongField(fields, "lastActivity", -1l); lastInterval = readLongField(fields, "lastInterval", -1l); // new fields uuid = readStringField(fields, "uuid", null); enabled = readBooleanField(fields, "enabled", true); askingAttribution = readBooleanField(fields, "askingAttribution", false); // create UUID for migrating devices if (uuid == null) { uuid = Util.createUuid(); } }
/** * Subclasses should call this method within their * readObject(ObjectInputStream) invocations * * @param stream * @throws IOException * @throws ClassNotFoundException */ protected void doReadObject(final ObjectInputStream stream) throws IOException, ClassNotFoundException { final GetField readFields = stream.readFields(); for (final String fieldName : getFieldNamesInAdditionToId()) { final Object value = readFields.get(fieldName, null); setField(fieldName, value); } // fix issue of deserializing _rowNumber in it's previous int form final long rowNumber; final ObjectStreamField legacyRowNumberField = readFields.getObjectStreamClass().getField(getFieldNameForOldId()); if (legacyRowNumberField != null) { rowNumber = readFields.get(getFieldNameForOldId(), -1); } else { rowNumber = readFields.get(getFieldNameForNewId(), -1L); } setField(getFieldNameForNewId(), rowNumber); }
public void readObject(ObjectInputStream stream, Adaptor adaptor) throws IOException, ClassNotFoundException { try { GetField getField = stream.readFields(); Field[] fields; fields = _clazz.getDeclaredFields(); deserializeFields(fields, getField); fields = ReflectionUtils.getFields(_clazz, Moved.class); deserializeFields(fields, getField); if (adaptor != null) { adaptor.deserialize(getField, _serializable); } } catch (IOException e) { logger.error("Could not deserialize object!", e); throw e; } }
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { ReadObjectBuilder.create(this, SimpleSynonymCatalog.class).readObject(stream, new Adaptor() { @Override public void deserialize(GetField getField, Serializable serializable) throws IOException { // Get the old List<Synonym> field '_synonyms'. Object synonyms = getField.get("_synonyms", null); if (synonyms instanceof List) { try { Field field = SimpleSynonymCatalog.class.getDeclaredField("_synonymMap"); field.setAccessible(true); field.set(SimpleSynonymCatalog.this, new HashMap<String, String>()); } catch (Exception e) { throw new IllegalStateException(e); } @SuppressWarnings("unchecked") List<Synonym> synonymsList = (List<Synonym>) synonyms; for (Synonym synonym : synonymsList) { addSynonym(synonym); } } } }); }
/** * Method invoked by the Java serialization framework while deserializing * Row instances. Since previous versions of MetaModel did not use a * DataSetHeader, but had a reference to a List<SelectItem>, this * deserialization is particularly tricky. We check if the items variable is * there, and if it is, we convert it to a header instead. * * @param stream * @throws Exception */ private void readObject(ObjectInputStream stream) throws Exception { GetField fields = stream.readFields(); try { // backwards compatible deserialization, convert items to header Object items = fields.get("_items", null); @SuppressWarnings("unchecked") List<SelectItem> itemsList = (List<SelectItem>) items; SimpleDataSetHeader header = new SimpleDataSetHeader(itemsList); Field field = getClass().getDeclaredField("_header"); field.setAccessible(true); field.set(this, header); } catch (IllegalArgumentException e) { // no backwards compatible deserialization needed. setWhileDeserializing(fields, "_header"); } setWhileDeserializing(fields, "_values"); setWhileDeserializing(fields, "_styles"); }
@SuppressWarnings({ "unchecked", "deprecation" }) private void readObject(ObjectInputStream is) throws ClassNotFoundException, IOException { GetField fields = is.readFields(); if (fields.defaulted("versionsByLabel")) { // This is a V2.2 class // The old 'rootVersion' maps to the current 'rootVersion' this.versionsByLabel = (HashMap<String, Version>) fields.get("versions", new HashMap<String, Version>()); // The old 'versionHistory' maps to the current 'versionHistory' this.versionHistory = (HashMap<String, String>) fields.get("versionHistory", new HashMap<String, String>()); // Need this comparator as versionsByLabel is not a LinkedHashMap in this version this.versionComparatorDesc = new VersionLabelComparator(); } else if (fields.defaulted("versionComparatorDesc")) { // This is a V3.1.0 class // The old 'rootVersion' maps to the current 'rootVersion' this.versionsByLabel = (HashMap<String, Version>) fields.get("versionsByLabel", new HashMap<String, Version>()); // The old 'versionHistory' maps to the current 'versionHistory' this.versionHistory = (HashMap<String, String>) fields.get("versionHistory", new HashMap<String, String>()); // Need this comparator as versionsByLabel is not a LinkedHashMap in this version this.versionComparatorDesc = new VersionLabelComparator(); } else { // This is a V4.1.3 (and 4.0.2 HF) class // The old 'rootVersion' maps to the current 'rootVersion' this.versionsByLabel = (Map<String, Version>) fields.get("versionsByLabel", new LinkedHashMap<String, Version>()); // The old 'versionHistory' maps to the current 'versionHistory' this.versionHistory = (HashMap<String, String>) fields.get("versionHistory", new HashMap<String, String>()); this.versionComparatorDesc = (Comparator<Version>) fields.get("versionComparatorDesc", null); } }
private void readObject (ObjectInputStream s) throws IOException, ClassNotFoundException { if (getClass().getClassLoader() != null) { throw new SecurityException ("invalid address type"); } GetField gf = s.readFields(); String host = (String)gf.get("hostName", null); int address= gf.get("address", 0); int family= gf.get("family", 0); InetAddressHolder h = new InetAddressHolder(host, address, family); UNSAFE.putObject(this, FIELDS_OFFSET, h); }
private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException { ObjectInputStream.GetField fields = s.readFields(); @SuppressWarnings("unchecked") Hashtable<String,PermissionCollection> permTable = (Hashtable<String,PermissionCollection>) (fields.get("perms", null)); if (permTable != null) { perms = new ConcurrentHashMap<>(permTable); } else { perms = new ConcurrentHashMap<>(); } }
protected final void copyBarcodeComponentFields(GetField fields) throws IOException { int orientation = fields.get("orientation", 0); this.orientationValue = OrientationEnum.getByValue(orientation); this.patternExpression = (JRExpression) fields.get("patternExpression", null); this.moduleWidth = (Double) fields.get("moduleWidth", null); String textPosition = (String) fields.get("textPosition", null); this.textPositionValue = TextPositionEnum.getByName(textPosition); this.quietZone = (Double) fields.get("quietZone", null); this.verticalQuietZone = (Double) fields.get("verticalQuietZone", null); }
@SuppressWarnings("unchecked") // we have to trust that keys are Ks and values are Vs private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { GetField fields = stream.readFields(); comparator = (Comparator<? super K>) fields.get("comparator", null); if (comparator == null) { comparator = (Comparator<? super K>) NATURAL_ORDER; } int size = stream.readInt(); for (int i = 0; i < size; i++) { putInternal((K) stream.readObject(), (V) stream.readObject()); } }
private String readStringField(GetField fields, String name, String defaultValue) { try { return (String) fields.get(name, defaultValue); } catch (Exception e) { logger.debug(readErrorMessage, name, e.getMessage()); return defaultValue; } }
private boolean readBooleanField(GetField fields, String name, boolean defaultValue) { try { return fields.get(name, defaultValue); } catch (Exception e) { logger.debug(readErrorMessage, name, e.getMessage()); return defaultValue; } }
private int readIntField(GetField fields, String name, int defaultValue) { try { return fields.get(name, defaultValue); } catch (Exception e) { logger.debug(readErrorMessage, name, e.getMessage()); return defaultValue; } }
private long readLongField(GetField fields, String name, long defaultValue) { try { return fields.get(name, defaultValue); } catch (Exception e) { logger.debug(readErrorMessage, name, e.getMessage()); return defaultValue; } }