< prev index next >
src/java.base/share/classes/java/lang/reflect/Field.java
Print this page
*** 401,411 ****
public Object get(Object obj)
throws IllegalArgumentException, IllegalAccessException
{
if (!override) {
Class<?> caller = Reflection.getCallerClass();
! checkAccess(caller, clazz, obj, modifiers);
}
return getFieldAccessor(obj).get(obj);
}
/**
--- 401,411 ----
public Object get(Object obj)
throws IllegalArgumentException, IllegalAccessException
{
if (!override) {
Class<?> caller = Reflection.getCallerClass();
! checkAccess(caller, obj);
}
return getFieldAccessor(obj).get(obj);
}
/**
*** 435,445 ****
public boolean getBoolean(Object obj)
throws IllegalArgumentException, IllegalAccessException
{
if (!override) {
Class<?> caller = Reflection.getCallerClass();
! checkAccess(caller, clazz, obj, modifiers);
}
return getFieldAccessor(obj).getBoolean(obj);
}
/**
--- 435,445 ----
public boolean getBoolean(Object obj)
throws IllegalArgumentException, IllegalAccessException
{
if (!override) {
Class<?> caller = Reflection.getCallerClass();
! checkAccess(caller, obj);
}
return getFieldAccessor(obj).getBoolean(obj);
}
/**
*** 469,479 ****
public byte getByte(Object obj)
throws IllegalArgumentException, IllegalAccessException
{
if (!override) {
Class<?> caller = Reflection.getCallerClass();
! checkAccess(caller, clazz, obj, modifiers);
}
return getFieldAccessor(obj).getByte(obj);
}
/**
--- 469,479 ----
public byte getByte(Object obj)
throws IllegalArgumentException, IllegalAccessException
{
if (!override) {
Class<?> caller = Reflection.getCallerClass();
! checkAccess(caller, obj);
}
return getFieldAccessor(obj).getByte(obj);
}
/**
*** 505,515 ****
public char getChar(Object obj)
throws IllegalArgumentException, IllegalAccessException
{
if (!override) {
Class<?> caller = Reflection.getCallerClass();
! checkAccess(caller, clazz, obj, modifiers);
}
return getFieldAccessor(obj).getChar(obj);
}
/**
--- 505,515 ----
public char getChar(Object obj)
throws IllegalArgumentException, IllegalAccessException
{
if (!override) {
Class<?> caller = Reflection.getCallerClass();
! checkAccess(caller, obj);
}
return getFieldAccessor(obj).getChar(obj);
}
/**
*** 541,551 ****
public short getShort(Object obj)
throws IllegalArgumentException, IllegalAccessException
{
if (!override) {
Class<?> caller = Reflection.getCallerClass();
! checkAccess(caller, clazz, obj, modifiers);
}
return getFieldAccessor(obj).getShort(obj);
}
/**
--- 541,551 ----
public short getShort(Object obj)
throws IllegalArgumentException, IllegalAccessException
{
if (!override) {
Class<?> caller = Reflection.getCallerClass();
! checkAccess(caller, obj);
}
return getFieldAccessor(obj).getShort(obj);
}
/**
*** 577,587 ****
public int getInt(Object obj)
throws IllegalArgumentException, IllegalAccessException
{
if (!override) {
Class<?> caller = Reflection.getCallerClass();
! checkAccess(caller, clazz, obj, modifiers);
}
return getFieldAccessor(obj).getInt(obj);
}
/**
--- 577,587 ----
public int getInt(Object obj)
throws IllegalArgumentException, IllegalAccessException
{
if (!override) {
Class<?> caller = Reflection.getCallerClass();
! checkAccess(caller, obj);
}
return getFieldAccessor(obj).getInt(obj);
}
/**
*** 613,623 ****
public long getLong(Object obj)
throws IllegalArgumentException, IllegalAccessException
{
if (!override) {
Class<?> caller = Reflection.getCallerClass();
! checkAccess(caller, clazz, obj, modifiers);
}
return getFieldAccessor(obj).getLong(obj);
}
/**
--- 613,623 ----
public long getLong(Object obj)
throws IllegalArgumentException, IllegalAccessException
{
if (!override) {
Class<?> caller = Reflection.getCallerClass();
! checkAccess(caller, obj);
}
return getFieldAccessor(obj).getLong(obj);
}
/**
*** 649,659 ****
public float getFloat(Object obj)
throws IllegalArgumentException, IllegalAccessException
{
if (!override) {
Class<?> caller = Reflection.getCallerClass();
! checkAccess(caller, clazz, obj, modifiers);
}
return getFieldAccessor(obj).getFloat(obj);
}
/**
--- 649,659 ----
public float getFloat(Object obj)
throws IllegalArgumentException, IllegalAccessException
{
if (!override) {
Class<?> caller = Reflection.getCallerClass();
! checkAccess(caller, obj);
}
return getFieldAccessor(obj).getFloat(obj);
}
/**
*** 685,695 ****
public double getDouble(Object obj)
throws IllegalArgumentException, IllegalAccessException
{
if (!override) {
Class<?> caller = Reflection.getCallerClass();
! checkAccess(caller, clazz, obj, modifiers);
}
return getFieldAccessor(obj).getDouble(obj);
}
/**
--- 685,695 ----
public double getDouble(Object obj)
throws IllegalArgumentException, IllegalAccessException
{
if (!override) {
Class<?> caller = Reflection.getCallerClass();
! checkAccess(caller, obj);
}
return getFieldAccessor(obj).getDouble(obj);
}
/**
*** 763,773 ****
public void set(Object obj, Object value)
throws IllegalArgumentException, IllegalAccessException
{
if (!override) {
Class<?> caller = Reflection.getCallerClass();
! checkAccess(caller, clazz, obj, modifiers);
}
getFieldAccessor(obj).set(obj, value);
}
/**
--- 763,773 ----
public void set(Object obj, Object value)
throws IllegalArgumentException, IllegalAccessException
{
if (!override) {
Class<?> caller = Reflection.getCallerClass();
! checkAccess(caller, obj);
}
getFieldAccessor(obj).set(obj, value);
}
/**
*** 799,809 ****
public void setBoolean(Object obj, boolean z)
throws IllegalArgumentException, IllegalAccessException
{
if (!override) {
Class<?> caller = Reflection.getCallerClass();
! checkAccess(caller, clazz, obj, modifiers);
}
getFieldAccessor(obj).setBoolean(obj, z);
}
/**
--- 799,809 ----
public void setBoolean(Object obj, boolean z)
throws IllegalArgumentException, IllegalAccessException
{
if (!override) {
Class<?> caller = Reflection.getCallerClass();
! checkAccess(caller, obj);
}
getFieldAccessor(obj).setBoolean(obj, z);
}
/**
*** 835,845 ****
public void setByte(Object obj, byte b)
throws IllegalArgumentException, IllegalAccessException
{
if (!override) {
Class<?> caller = Reflection.getCallerClass();
! checkAccess(caller, clazz, obj, modifiers);
}
getFieldAccessor(obj).setByte(obj, b);
}
/**
--- 835,845 ----
public void setByte(Object obj, byte b)
throws IllegalArgumentException, IllegalAccessException
{
if (!override) {
Class<?> caller = Reflection.getCallerClass();
! checkAccess(caller, obj);
}
getFieldAccessor(obj).setByte(obj, b);
}
/**
*** 871,881 ****
public void setChar(Object obj, char c)
throws IllegalArgumentException, IllegalAccessException
{
if (!override) {
Class<?> caller = Reflection.getCallerClass();
! checkAccess(caller, clazz, obj, modifiers);
}
getFieldAccessor(obj).setChar(obj, c);
}
/**
--- 871,881 ----
public void setChar(Object obj, char c)
throws IllegalArgumentException, IllegalAccessException
{
if (!override) {
Class<?> caller = Reflection.getCallerClass();
! checkAccess(caller, obj);
}
getFieldAccessor(obj).setChar(obj, c);
}
/**
*** 907,917 ****
public void setShort(Object obj, short s)
throws IllegalArgumentException, IllegalAccessException
{
if (!override) {
Class<?> caller = Reflection.getCallerClass();
! checkAccess(caller, clazz, obj, modifiers);
}
getFieldAccessor(obj).setShort(obj, s);
}
/**
--- 907,917 ----
public void setShort(Object obj, short s)
throws IllegalArgumentException, IllegalAccessException
{
if (!override) {
Class<?> caller = Reflection.getCallerClass();
! checkAccess(caller, obj);
}
getFieldAccessor(obj).setShort(obj, s);
}
/**
*** 943,953 ****
public void setInt(Object obj, int i)
throws IllegalArgumentException, IllegalAccessException
{
if (!override) {
Class<?> caller = Reflection.getCallerClass();
! checkAccess(caller, clazz, obj, modifiers);
}
getFieldAccessor(obj).setInt(obj, i);
}
/**
--- 943,953 ----
public void setInt(Object obj, int i)
throws IllegalArgumentException, IllegalAccessException
{
if (!override) {
Class<?> caller = Reflection.getCallerClass();
! checkAccess(caller, obj);
}
getFieldAccessor(obj).setInt(obj, i);
}
/**
*** 979,989 ****
public void setLong(Object obj, long l)
throws IllegalArgumentException, IllegalAccessException
{
if (!override) {
Class<?> caller = Reflection.getCallerClass();
! checkAccess(caller, clazz, obj, modifiers);
}
getFieldAccessor(obj).setLong(obj, l);
}
/**
--- 979,989 ----
public void setLong(Object obj, long l)
throws IllegalArgumentException, IllegalAccessException
{
if (!override) {
Class<?> caller = Reflection.getCallerClass();
! checkAccess(caller, obj);
}
getFieldAccessor(obj).setLong(obj, l);
}
/**
*** 1015,1025 ****
public void setFloat(Object obj, float f)
throws IllegalArgumentException, IllegalAccessException
{
if (!override) {
Class<?> caller = Reflection.getCallerClass();
! checkAccess(caller, clazz, obj, modifiers);
}
getFieldAccessor(obj).setFloat(obj, f);
}
/**
--- 1015,1025 ----
public void setFloat(Object obj, float f)
throws IllegalArgumentException, IllegalAccessException
{
if (!override) {
Class<?> caller = Reflection.getCallerClass();
! checkAccess(caller, obj);
}
getFieldAccessor(obj).setFloat(obj, f);
}
/**
*** 1051,1065 ****
public void setDouble(Object obj, double d)
throws IllegalArgumentException, IllegalAccessException
{
if (!override) {
Class<?> caller = Reflection.getCallerClass();
! checkAccess(caller, clazz, obj, modifiers);
}
getFieldAccessor(obj).setDouble(obj, d);
}
// security check is done before calling this method
private FieldAccessor getFieldAccessor(Object obj)
throws IllegalAccessException
{
boolean ov = override;
--- 1051,1074 ----
public void setDouble(Object obj, double d)
throws IllegalArgumentException, IllegalAccessException
{
if (!override) {
Class<?> caller = Reflection.getCallerClass();
! checkAccess(caller, obj);
}
getFieldAccessor(obj).setDouble(obj, d);
}
+ // check access to field
+ private void checkAccess(Class<?> caller, Object obj)
+ throws IllegalAccessException
+ {
+ checkAccess(caller, clazz,
+ Modifier.isStatic(modifiers) ? null : obj.getClass(),
+ modifiers);
+ }
+
// security check is done before calling this method
private FieldAccessor getFieldAccessor(Object obj)
throws IllegalAccessException
{
boolean ov = override;
< prev index next >