/** * @return Instance. * @throws BinaryObjectException In case of error. */ private Object newInstance() throws BinaryObjectException { try { return ctor != null ? ctor.newInstance() : GridUnsafe.allocateInstance(cls); } catch (InstantiationException | InvocationTargetException | IllegalAccessException e) { throw new BinaryObjectException("Failed to instantiate instance: " + cls, e); } }
/** * @param cls Class to create. * @return Instance of class. * @throws Exception If failed. */ protected <T> T allocateInstance(Class<T> cls) throws Exception { return (T)GridUnsafe.allocateInstance(cls); }
/** * @param cls Class to create. * @return Instance of class. */ @Nullable protected <T> T allocateInstance0(Class<T> cls) { try { return (T)GridUnsafe.allocateInstance(cls); } catch (InstantiationException e) { e.printStackTrace(); return null; } }
/** {@inheritDoc} */ @Override public Object apply(List<?> arg) throws IgniteCheckedException { try { return GridUnsafe.allocateInstance(cls); } catch (InstantiationException e) { if (S.INCLUDE_SENSITIVE) throw new IgniteCheckedException("Failed to instantiate " + (key ? "key" : "value") + " [type=" + typeName + ']', e); else throw new IgniteCheckedException("Failed to instantiate " + (key ? "key" : "value") + '.', e); } } };
/** * Reads {@link LinkedHashSet}. * * @param mapFieldOff Map field offset. * @return Set. * @throws ClassNotFoundException If class not found. * @throws IOException In case of error. */ LinkedHashSet<?> readLinkedHashSet(long mapFieldOff) throws ClassNotFoundException, IOException { try { LinkedHashSet<Object> set = (LinkedHashSet<Object>)GridUnsafe.allocateInstance(LinkedHashSet.class); handles.assign(set); setObject(set, mapFieldOff, readLinkedHashMap(true)); return set; } catch (InstantiationException e) { throw new IOException(e); } }
/** * Reads {@link HashSet}. * * @param mapFieldOff Map field offset. * @return Set. * @throws ClassNotFoundException If class not found. * @throws IOException In case of error. */ HashSet<?> readHashSet(long mapFieldOff) throws ClassNotFoundException, IOException { try { HashSet<Object> set = (HashSet<Object>)GridUnsafe.allocateInstance(HashSet.class); handles.assign(set); setObject(set, mapFieldOff, readHashMap(true)); return set; } catch (InstantiationException e) { throw new IOException(e); } }
obj = GridUnsafe.allocateInstance(cls);
/** * @return Instance. * @throws BinaryObjectException In case of error. */ private Object newInstance() throws BinaryObjectException { try { return ctor != null ? ctor.newInstance() : GridUnsafe.allocateInstance(cls); } catch (InstantiationException | InvocationTargetException | IllegalAccessException e) { throw new BinaryObjectException("Failed to instantiate instance: " + cls, e); } }
/** {@inheritDoc} */ @Override public Object apply(List<?> arg) throws IgniteCheckedException { try { return GridUnsafe.allocateInstance(cls); } catch (InstantiationException e) { if (S.INCLUDE_SENSITIVE) throw new IgniteCheckedException("Failed to instantiate " + (key ? "key" : "value") + " [type=" + typeName + ']', e); else throw new IgniteCheckedException("Failed to instantiate " + (key ? "key" : "value") + '.', e); } } };
/** * Reads {@link LinkedHashSet}. * * @param mapFieldOff Map field offset. * @return Set. * @throws ClassNotFoundException If class not found. * @throws IOException In case of error. */ @SuppressWarnings("unchecked") LinkedHashSet<?> readLinkedHashSet(long mapFieldOff) throws ClassNotFoundException, IOException { try { LinkedHashSet<Object> set = (LinkedHashSet<Object>)GridUnsafe.allocateInstance(LinkedHashSet.class); handles.assign(set); setObject(set, mapFieldOff, readLinkedHashMap(true)); return set; } catch (InstantiationException e) { throw new IOException(e); } }
/** * Reads {@link HashSet}. * * @param mapFieldOff Map field offset. * @return Set. * @throws ClassNotFoundException If class not found. * @throws IOException In case of error. */ @SuppressWarnings("unchecked") HashSet<?> readHashSet(long mapFieldOff) throws ClassNotFoundException, IOException { try { HashSet<Object> set = (HashSet<Object>)GridUnsafe.allocateInstance(HashSet.class); handles.assign(set); setObject(set, mapFieldOff, readHashMap(true)); return set; } catch (InstantiationException e) { throw new IOException(e); } }
obj = GridUnsafe.allocateInstance(cls);