public Object getKryo() { Object value = this.kryo.get(); if (value == null) { try { value = this.kryoConstructor.newInstance(); this.kryo.set(value); } catch (Exception exception) { throw ValidationException.reflectiveExceptionWhileCreatingClassInstance("com.esotericsoftware.kryo.Kryo", exception); } } return value; }
public KryoSerializer() { try { Class kryoClass = Class.forName("com.esotericsoftware.kryo.Kryo"); this.kryoConstructor = kryoClass.getConstructor(); Class inputClass = Class.forName("com.esotericsoftware.kryo.io.Input"); this.inputConstructor = inputClass.getConstructor(InputStream.class); Class outputClass = Class.forName("com.esotericsoftware.kryo.io.Output"); this.outputConstructor = outputClass.getConstructor(OutputStream.class); this.writeMethod = kryoClass.getMethod("writeClassAndObject", outputClass, Object.class); this.readMethod = kryoClass.getMethod("readClassAndObject", inputClass); this.inputCloseMethod = inputClass.getMethod("close"); this.outputCloseMethod = outputClass.getMethod("close"); this.kryo = new ThreadLocal(); } catch (Exception exception) { throw ValidationException.reflectiveExceptionWhileCreatingClassInstance("com.esotericsoftware.kryo.Kryo", exception); } }
/** * INTERNAL: * Return a new instance of the class provided. */ public Object getClassInstance(Class cls) { if (cls != null){ try { if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){ return AccessController.doPrivileged(new PrivilegedNewInstanceFromClass(cls)); } else { return org.eclipse.persistence.internal.security.PrivilegedAccessHelper.newInstanceFromClass(cls); } } catch (Exception e) { throw ValidationException.reflectiveExceptionWhileCreatingClassInstance(cls.getName(), e); } } return null; }
/** * INTERNAL: * Return a new instance of the class provided. */ public Object getClassInstance(Class cls) { if (cls != null){ try { if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){ return AccessController.doPrivileged(new PrivilegedNewInstanceFromClass(cls)); } else { return org.eclipse.persistence.internal.security.PrivilegedAccessHelper.newInstanceFromClass(cls); } } catch (Exception e) { throw ValidationException.reflectiveExceptionWhileCreatingClassInstance(cls.getName(), e); } } return null; }
throw ValidationException.reflectiveExceptionWhileCreatingClassInstance(classExtractorName, ex); } catch (InstantiationException e) { throw ValidationException.reflectiveExceptionWhileCreatingClassInstance(classExtractorName, e);
throw ValidationException.reflectiveExceptionWhileCreatingClassInstance(classExtractorName, ex); } catch (InstantiationException e) { throw ValidationException.reflectiveExceptionWhileCreatingClassInstance(classExtractorName, e);
/** * INTERNAL: * Convert all the class-name-based settings to actual class-based * settings. This method is used when converting a project that has been built * with class names to a project with classes. */ public void convertClassNamesToClasses(ClassLoader classLoader) { if (getPartitioningClasName() == null) { setPartitioningClasName(""); } try { if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()) { Class partitioningClass = AccessController.doPrivileged(new PrivilegedClassForName(getPartitioningClasName(), true, classLoader)); this.policy = (PartitioningPolicy)AccessController.doPrivileged(new PrivilegedNewInstanceFromClass(partitioningClass)); } else { Class partitioningClass = PrivilegedAccessHelper.getClassForName(getPartitioningClasName(), true, classLoader); this.policy = (PartitioningPolicy)PrivilegedAccessHelper.newInstanceFromClass(partitioningClass); } } catch (PrivilegedActionException exception) { throw ValidationException.classNotFoundWhileConvertingClassNames(getPartitioningClasName(), exception.getException()); } catch (ClassNotFoundException exception) { throw ValidationException.classNotFoundWhileConvertingClassNames(getPartitioningClasName(), exception); } catch (IllegalAccessException exception) { throw ValidationException.reflectiveExceptionWhileCreatingClassInstance(getPartitioningClasName(), exception); } catch (InstantiationException exception) { throw ValidationException.reflectiveExceptionWhileCreatingClassInstance(getPartitioningClasName(), exception); } }
/** * INTERNAL: * Convert all the class-name-based settings to actual class-based * settings. This method is used when converting a project that has been built * with class names to a project with classes. */ public void convertClassNamesToClasses(ClassLoader classLoader) { if (getPartitioningClasName() == null) { setPartitioningClasName(""); } try { if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()) { Class partitioningClass = AccessController.doPrivileged(new PrivilegedClassForName(getPartitioningClasName(), true, classLoader)); this.policy = (PartitioningPolicy)AccessController.doPrivileged(new PrivilegedNewInstanceFromClass(partitioningClass)); } else { Class partitioningClass = PrivilegedAccessHelper.getClassForName(getPartitioningClasName(), true, classLoader); this.policy = (PartitioningPolicy)PrivilegedAccessHelper.newInstanceFromClass(partitioningClass); } } catch (PrivilegedActionException exception) { throw ValidationException.classNotFoundWhileConvertingClassNames(getPartitioningClasName(), exception.getException()); } catch (ClassNotFoundException exception) { throw ValidationException.classNotFoundWhileConvertingClassNames(getPartitioningClasName(), exception); } catch (IllegalAccessException exception) { throw ValidationException.reflectiveExceptionWhileCreatingClassInstance(getPartitioningClasName(), exception); } catch (InstantiationException exception) { throw ValidationException.reflectiveExceptionWhileCreatingClassInstance(getPartitioningClasName(), exception); } }
newCopyPolicy = (CopyPolicy)AccessController.doPrivileged(new PrivilegedNewInstanceFromClass(copyPolicyClass)); } catch (PrivilegedActionException exception) { throw ValidationException.reflectiveExceptionWhileCreatingClassInstance(getCopyPolicyClassName(), exception.getException()); throw ValidationException.classNotFoundWhileConvertingClassNames(getCopyPolicyClassName(), exc); } catch (IllegalAccessException ex){ throw ValidationException.reflectiveExceptionWhileCreatingClassInstance(getCopyPolicyClassName(), ex); } catch (InstantiationException e){ throw ValidationException.reflectiveExceptionWhileCreatingClassInstance(getCopyPolicyClassName(), e); newSerializedObjectPolicy = (SerializedObjectPolicy)AccessController.doPrivileged(new PrivilegedNewInstanceFromClass(serializedObjectPolicyClass)); } catch (PrivilegedActionException exception) { throw ValidationException.reflectiveExceptionWhileCreatingClassInstance(serializedObjectPolicyClassName, exception.getException()); throw ValidationException.classNotFoundWhileConvertingClassNames(serializedObjectPolicyClassName, exc); } catch (IllegalAccessException ex){ throw ValidationException.reflectiveExceptionWhileCreatingClassInstance(serializedObjectPolicyClassName, ex); } catch (InstantiationException e){ throw ValidationException.reflectiveExceptionWhileCreatingClassInstance(serializedObjectPolicyClassName, e);
newCopyPolicy = (CopyPolicy)AccessController.doPrivileged(new PrivilegedNewInstanceFromClass(copyPolicyClass)); } catch (PrivilegedActionException exception) { throw ValidationException.reflectiveExceptionWhileCreatingClassInstance(getCopyPolicyClassName(), exception.getException()); throw ValidationException.classNotFoundWhileConvertingClassNames(getCopyPolicyClassName(), exc); } catch (IllegalAccessException ex){ throw ValidationException.reflectiveExceptionWhileCreatingClassInstance(getCopyPolicyClassName(), ex); } catch (InstantiationException e){ throw ValidationException.reflectiveExceptionWhileCreatingClassInstance(getCopyPolicyClassName(), e); newSerializedObjectPolicy = (SerializedObjectPolicy)AccessController.doPrivileged(new PrivilegedNewInstanceFromClass(serializedObjectPolicyClass)); } catch (PrivilegedActionException exception) { throw ValidationException.reflectiveExceptionWhileCreatingClassInstance(serializedObjectPolicyClassName, exception.getException()); throw ValidationException.classNotFoundWhileConvertingClassNames(serializedObjectPolicyClassName, exc); } catch (IllegalAccessException ex){ throw ValidationException.reflectiveExceptionWhileCreatingClassInstance(serializedObjectPolicyClassName, ex); } catch (InstantiationException e){ throw ValidationException.reflectiveExceptionWhileCreatingClassInstance(serializedObjectPolicyClassName, e);
throw ValidationException.classNotFoundWhileConvertingClassNames(getCopyPolicyClassName(), exc); } catch (IllegalAccessException ex){ throw ValidationException.reflectiveExceptionWhileCreatingClassInstance(getCopyPolicyClassName(), ex); } catch (InstantiationException e){ throw ValidationException.reflectiveExceptionWhileCreatingClassInstance(getCopyPolicyClassName(), e);