@Override @SuppressWarnings("unchecked") public U getValue(T target) { if (getterIndex != NO_METHOD) { return (U) methodAccess.invoke(target, getterIndex); } else { return (U) fieldAccess.get(target, fieldIndex); } }
ReflectASMFieldAccessor(Class<T> ownerType, Field field, Class<U> fieldType) throws InaccessibleFieldException { methodAccess = MethodAccess.get(ownerType); Method getter = ReflectionUtil.findGetter(field); if (getter != null) { getterIndex = methodAccess.getIndex(getter.getName()); } Method setter = ReflectionUtil.findSetter(field); if (setter != null) { setterIndex = methodAccess.getIndex(setter.getName()); } if (getterIndex == NO_METHOD || setterIndex == NO_METHOD) { fieldAccess = FieldAccess.get(ownerType); try { fieldIndex = fieldAccess.getIndex(field.getName()); } catch (IllegalArgumentException e) { throw new InaccessibleFieldException("Failed to create accessor for field '" + field.getName() + "' of type '" + ownerType.getName() + "'", e); } } }
public Object get (Object instance, String fieldName) { return get(instance, getIndex(fieldName)); }
public Object getField (Object object) throws IllegalArgumentException, IllegalAccessException { if (accessIndex != -1) return ((FieldAccess)access).get(object, accessIndex); throw new KryoException("Unknown acess index"); }
public Object get (Object object, String fieldName) { return get(object, getIndex(fieldName)); } }
public Object getField (Object object) throws IllegalArgumentException, IllegalAccessException { if (accessIndex != -1) return ((FieldAccess)access).get(object, accessIndex); throw new KryoException("Unknown acess index"); }
public Object get (Object instance, String fieldName) { return get(instance, getIndex(fieldName)); }
public Object getField (Object object) throws IllegalArgumentException, IllegalAccessException { if (accessIndex != -1) return ((FieldAccess)access).get(object, accessIndex); throw new KryoException("Unknown acess index"); }
public Object get (Object instance, String fieldName) { return get(instance, getIndex(fieldName)); }
public Object getField (Object object) throws IllegalArgumentException, IllegalAccessException { if (accessIndex != -1) return ((FieldAccess)access).get(object, accessIndex); throw new KryoException("Unknown acess index"); }
public Object get (Object instance, String fieldName) { return get(instance, getIndex(fieldName)); }
public Object getFieldValue(FieldInfo fieldInfo, Object object) { Object fieldAccessor = fieldInfo.getter; try { if (fieldAccessor instanceof MethodAccess) { MethodAccess access = (MethodAccess) fieldAccessor; return access.invoke(object, fieldInfo.getterIndex); } else if (fieldAccessor instanceof FieldAccess) { FieldAccess access = (FieldAccess) fieldAccessor; return access.get(object, fieldInfo.getterIndex); } else if (fieldAccessor instanceof Method) { Method m = (Method) fieldAccessor; return m.invoke(object); } else { Field f = (Field) fieldAccessor; return f.get(object); } } catch (Exception e) { } throw new NoSuchFieldError(object.getClass() + "." + fieldInfo.getName()); }
public void copy (Object original, Object copy) { try { if (accessIndex != -1) { access.set(copy, accessIndex, kryo.copy(access.get(original, accessIndex))); } else throw new KryoException("Unknown acess index"); } catch (KryoException ex) { ex.addTrace(this + " (" + type.getName() + ")"); throw ex; } catch (RuntimeException runtimeEx) { KryoException ex = new KryoException(runtimeEx); ex.addTrace(this + " (" + type.getName() + ")"); throw ex; } } }
public void copy (Object original, Object copy) { try { if (accessIndex != -1) { access.set(copy, accessIndex, kryo.copy(access.get(original, accessIndex))); } else throw new KryoException("Unknown acess index"); } catch (KryoException ex) { ex.addTrace(this + " (" + type.getName() + ")"); throw ex; } catch (RuntimeException runtimeEx) { KryoException ex = new KryoException(runtimeEx); ex.addTrace(this + " (" + type.getName() + ")"); throw ex; } } }
public void copy (Object original, Object copy) { try { if (accessIndex != -1) { access.set(copy, accessIndex, kryo.copy(access.get(original, accessIndex))); } else throw new KryoException("Unknown acess index"); } catch (KryoException ex) { ex.addTrace(this + " (" + type.getName() + ")"); throw ex; } catch (RuntimeException runtimeEx) { KryoException ex = new KryoException(runtimeEx); ex.addTrace(this + " (" + type.getName() + ")"); throw ex; } } }
public void copy (Object original, Object copy) { try { if (accessIndex != -1) { access.set(copy, accessIndex, kryo.copy(access.get(original, accessIndex))); } else throw new KryoException("Unknown acess index"); } catch (KryoException ex) { ex.addTrace(this + " (" + type.getName() + ")"); throw ex; } catch (RuntimeException runtimeEx) { KryoException ex = new KryoException(runtimeEx); ex.addTrace(this + " (" + type.getName() + ")"); throw ex; } } }
public void copy (Object original, Object copy) { try { if (accessIndex != -1) { FieldAccess access = (FieldAccess)fieldSerializer.access; access.set(copy, accessIndex, kryo.copy(access.get(original, accessIndex))); } else setField(copy, kryo.copy(getField(original))); } catch (IllegalAccessException ex) { throw new KryoException("Error accessing field: " + this + " (" + type.getName() + ")", ex); } catch (KryoException ex) { ex.addTrace(this + " (" + type.getName() + ")"); throw ex; } catch (RuntimeException runtimeEx) { KryoException ex = new KryoException(runtimeEx); ex.addTrace(this + " (" + type.getName() + ")"); throw ex; } }
public void copy (Object original, Object copy) { try { if (accessIndex != -1) { FieldAccess access = (FieldAccess)fieldSerializer.access; access.set(copy, accessIndex, kryo.copy(access.get(original, accessIndex))); } else setField(copy, kryo.copy(getField(original))); } catch (IllegalAccessException ex) { throw new KryoException("Error accessing field: " + this + " (" + type.getName() + ")", ex); } catch (KryoException ex) { ex.addTrace(this + " (" + type.getName() + ")"); throw ex; } catch (RuntimeException runtimeEx) { KryoException ex = new KryoException(runtimeEx); ex.addTrace(this + " (" + type.getName() + ")"); throw ex; } }
public void copy (Object original, Object copy) { try { if (accessIndex != -1) { FieldAccess access = (FieldAccess)fieldSerializer.access; access.set(copy, accessIndex, kryo.copy(access.get(original, accessIndex))); } else setField(copy, kryo.copy(getField(original))); } catch (IllegalAccessException ex) { throw new KryoException("Error accessing field: " + this + " (" + type.getName() + ")", ex); } catch (KryoException ex) { ex.addTrace(this + " (" + type.getName() + ")"); throw ex; } catch (RuntimeException runtimeEx) { KryoException ex = new KryoException(runtimeEx); ex.addTrace(this + " (" + type.getName() + ")"); throw ex; } }
public void copy (Object original, Object copy) { try { if (accessIndex != -1) { FieldAccess access = (FieldAccess)fieldSerializer.access; access.set(copy, accessIndex, kryo.copy(access.get(original, accessIndex))); } else setField(copy, kryo.copy(getField(original))); } catch (IllegalAccessException ex) { throw new KryoException("Error accessing field: " + this + " (" + type.getName() + ")", ex); } catch (KryoException ex) { ex.addTrace(this + " (" + type.getName() + ")"); throw ex; } catch (RuntimeException runtimeEx) { KryoException ex = new KryoException(runtimeEx); ex.addTrace(this + " (" + type.getName() + ")"); throw ex; } }