/** * Resolve the class. * * @param ctx Binary context. * @param typeId Type ID. * @param clsName Class name. * @param ldr Class loaded. * @return Resovled class. */ public static Class resolveClass(BinaryContext ctx, int typeId, @Nullable String clsName, @Nullable ClassLoader ldr, boolean deserialize) { Class cls; if (typeId != GridBinaryMarshaller.UNREGISTERED_TYPE_ID) cls = ctx.descriptorForTypeId(true, typeId, ldr, deserialize).describedClass(); else { try { cls = U.forName(clsName, ldr); } catch (ClassNotFoundException e) { throw new BinaryInvalidTypeException("Failed to load the class: " + clsName, e); } // forces registering of class by type id, at least locally ctx.descriptorForClass(cls, true, false); } return cls; }
return desc; throw new BinaryInvalidTypeException(e);
/** * @param in Binary input stream. * @param ctx Binary context. * @param ldr Class loader. * @param typeId Type id. * @return Class object specified at the input stream. * @throws BinaryObjectException If failed. */ public static Class doReadClass(BinaryInputStream in, BinaryContext ctx, ClassLoader ldr, int typeId) throws BinaryObjectException { Class cls; if (typeId != GridBinaryMarshaller.UNREGISTERED_TYPE_ID) cls = ctx.descriptorForTypeId(true, typeId, ldr, true).describedClass(); else { String clsName = doReadClassName(in); try { cls = U.forName(clsName, ldr); } catch (ClassNotFoundException e) { throw new BinaryInvalidTypeException("Failed to load the class: " + clsName, e); } // forces registering of class by type id, at least locally ctx.descriptorForClass(cls, true, false); } return cls; }
/** * @param reader BinaryBuilderReader. */ public BinaryBuilderEnum(BinaryBuilderReader reader) { int typeId = reader.readInt(); if (typeId == GridBinaryMarshaller.UNREGISTERED_TYPE_ID) { clsName = reader.readString(); Class cls; try { cls = U.forName(reader.readString(), reader.binaryContext().configuration().getClassLoader()); } catch (ClassNotFoundException e) { throw new BinaryInvalidTypeException("Failed to load the class: " + clsName, e); } this.typeId = reader.binaryContext().descriptorForClass(cls, false, false).typeId(); } else { this.typeId = typeId; this.clsName = null; } ordinal = reader.readInt(); }
/** * @param reader Reader. */ protected BinaryObjectArrayLazyValue(BinaryBuilderReader reader) { super(reader, reader.position() - 1); int typeId = reader.readInt(); if (typeId == GridBinaryMarshaller.UNREGISTERED_TYPE_ID) { clsName = reader.readString(); Class cls; try { cls = U.forName(reader.readString(), reader.binaryContext().configuration().getClassLoader()); } catch (ClassNotFoundException e) { throw new BinaryInvalidTypeException("Failed to load the class: " + clsName, e); } compTypeId = reader.binaryContext().descriptorForClass(cls, true, false).typeId(); } else { compTypeId = typeId; clsName = null; } int size = reader.readInt(); lazyValsArr = new Object[size]; for (int i = 0; i < size; i++) lazyValsArr[i] = reader.parseValue(); }
/** * @param reader Reader. */ protected BinaryEnumArrayLazyValue(BinaryBuilderReader reader) { super(reader, reader.position() - 1); int typeId = reader.readInt(); if (typeId == GridBinaryMarshaller.UNREGISTERED_TYPE_ID) { clsName = reader.readString(); Class cls; try { cls = U.forName(reader.readString(), reader.binaryContext().configuration().getClassLoader()); } catch (ClassNotFoundException e) { throw new BinaryInvalidTypeException("Failed to load the class: " + clsName, e); } compTypeId = reader.binaryContext().descriptorForClass(cls, true, false).typeId(); } else { compTypeId = typeId; clsName = null; } int size = reader.readInt(); for (int i = 0; i < size; i++) reader.skipValue(); len = reader.position() - valOff; }
throw new BinaryInvalidTypeException("Failed to load the class: " + clsNameToWrite, e);
throw new BinaryInvalidTypeException("Unknown type ID: " + typeId);
/** * Resolve the class. * * @param ctx Binary context. * @param typeId Type ID. * @param clsName Class name. * @param ldr Class loaded. * @return Resovled class. */ public static Class resolveClass(BinaryContext ctx, int typeId, @Nullable String clsName, @Nullable ClassLoader ldr, boolean deserialize) { Class cls; if (typeId != GridBinaryMarshaller.UNREGISTERED_TYPE_ID) cls = ctx.descriptorForTypeId(true, typeId, ldr, deserialize).describedClass(); else { try { cls = U.forName(clsName, ldr); } catch (ClassNotFoundException e) { throw new BinaryInvalidTypeException("Failed to load the class: " + clsName, e); } // forces registering of class by type id, at least locally ctx.descriptorForClass(cls, true, false); } return cls; }
return desc; throw new BinaryInvalidTypeException(e);
/** * @param in Binary input stream. * @param ctx Binary context. * @param ldr Class loader. * @param typeId Type id. * @return Class object specified at the input stream. * @throws BinaryObjectException If failed. */ public static Class doReadClass(BinaryInputStream in, BinaryContext ctx, ClassLoader ldr, int typeId) throws BinaryObjectException { Class cls; if (typeId != GridBinaryMarshaller.UNREGISTERED_TYPE_ID) cls = ctx.descriptorForTypeId(true, typeId, ldr, true).describedClass(); else { String clsName = doReadClassName(in); try { cls = U.forName(clsName, ldr); } catch (ClassNotFoundException e) { throw new BinaryInvalidTypeException("Failed to load the class: " + clsName, e); } // forces registering of class by type id, at least locally ctx.descriptorForClass(cls, true, false); } return cls; }
/** * @param reader BinaryBuilderReader. */ public BinaryBuilderEnum(BinaryBuilderReader reader) { int typeId = reader.readInt(); if (typeId == GridBinaryMarshaller.UNREGISTERED_TYPE_ID) { clsName = reader.readString(); Class cls; try { cls = U.forName(reader.readString(), reader.binaryContext().configuration().getClassLoader()); } catch (ClassNotFoundException e) { throw new BinaryInvalidTypeException("Failed to load the class: " + clsName, e); } this.typeId = reader.binaryContext().descriptorForClass(cls, false, false).typeId(); } else { this.typeId = typeId; this.clsName = null; } ordinal = reader.readInt(); }
/** * @param reader Reader. */ protected BinaryObjectArrayLazyValue(BinaryBuilderReader reader) { super(reader, reader.position() - 1); int typeId = reader.readInt(); if (typeId == GridBinaryMarshaller.UNREGISTERED_TYPE_ID) { clsName = reader.readString(); Class cls; try { cls = U.forName(reader.readString(), reader.binaryContext().configuration().getClassLoader()); } catch (ClassNotFoundException e) { throw new BinaryInvalidTypeException("Failed to load the class: " + clsName, e); } compTypeId = reader.binaryContext().descriptorForClass(cls, true, false).typeId(); } else { compTypeId = typeId; clsName = null; } int size = reader.readInt(); lazyValsArr = new Object[size]; for (int i = 0; i < size; i++) lazyValsArr[i] = reader.parseValue(); }
/** * @param reader Reader. */ protected BinaryEnumArrayLazyValue(BinaryBuilderReader reader) { super(reader, reader.position() - 1); int typeId = reader.readInt(); if (typeId == GridBinaryMarshaller.UNREGISTERED_TYPE_ID) { clsName = reader.readString(); Class cls; try { cls = U.forName(reader.readString(), reader.binaryContext().configuration().getClassLoader()); } catch (ClassNotFoundException e) { throw new BinaryInvalidTypeException("Failed to load the class: " + clsName, e); } compTypeId = reader.binaryContext().descriptorForClass(cls, true, false).typeId(); } else { compTypeId = typeId; clsName = null; } int size = reader.readInt(); for (int i = 0; i < size; i++) reader.skipValue(); len = reader.position() - valOff; }
throw new BinaryInvalidTypeException("Failed to load the class: " + clsNameToWrite, e);
throw new BinaryInvalidTypeException("Unknown type ID: " + typeId);