sun.reflect.FieldAccessor Java Examples

The following examples show how to use sun.reflect.FieldAccessor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Field.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private FieldAccessor acquireFieldAccessor(boolean overrideFinalCheck) {
    // First check to see if one has been created yet, and take it
    // if so
    FieldAccessor tmp = null;
    if (root != null) tmp = root.getFieldAccessor(overrideFinalCheck);
    if (tmp != null) {
        if (overrideFinalCheck)
            overrideFieldAccessor = tmp;
        else
            fieldAccessor = tmp;
    } else {
        // Otherwise fabricate one and propagate it up to the root
        tmp = reflectionFactory.newFieldAccessor(this, overrideFinalCheck);
        setFieldAccessor(tmp, overrideFinalCheck);
    }

    return tmp;
}
 
Example #2
Source File: Field.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
private FieldAccessor acquireFieldAccessor(boolean overrideFinalCheck) {
    // First check to see if one has been created yet, and take it
    // if so
    FieldAccessor tmp = null;
    if (root != null) tmp = root.getFieldAccessor(overrideFinalCheck);
    if (tmp != null) {
        if (overrideFinalCheck)
            overrideFieldAccessor = tmp;
        else
            fieldAccessor = tmp;
    } else {
        // Otherwise fabricate one and propagate it up to the root
        tmp = reflectionFactory.newFieldAccessor(this, overrideFinalCheck);
        setFieldAccessor(tmp, overrideFinalCheck);
    }

    return tmp;
}
 
Example #3
Source File: Field.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
private FieldAccessor acquireFieldAccessor(boolean overrideFinalCheck) {
    // First check to see if one has been created yet, and take it
    // if so
    FieldAccessor tmp = null;
    if (root != null) tmp = root.getFieldAccessor(overrideFinalCheck);
    if (tmp != null) {
        if (overrideFinalCheck)
            overrideFieldAccessor = tmp;
        else
            fieldAccessor = tmp;
    } else {
        // Otherwise fabricate one and propagate it up to the root
        tmp = reflectionFactory.newFieldAccessor(this, overrideFinalCheck);
        setFieldAccessor(tmp, overrideFinalCheck);
    }

    return tmp;
}
 
Example #4
Source File: Field.java    From jdk-1.7-annotated with Apache License 2.0 6 votes vote down vote up
private FieldAccessor acquireFieldAccessor(boolean overrideFinalCheck) {
    // First check to see if one has been created yet, and take it
    // if so
    FieldAccessor tmp = null;
    if (root != null) tmp = root.getFieldAccessor(overrideFinalCheck);
    if (tmp != null) {
        if (overrideFinalCheck)
            overrideFieldAccessor = tmp;
        else
            fieldAccessor = tmp;
    } else {
        // Otherwise fabricate one and propagate it up to the root
        tmp = reflectionFactory.newFieldAccessor(this, overrideFinalCheck);
        setFieldAccessor(tmp, overrideFinalCheck);
    }

    return tmp;
}
 
Example #5
Source File: Field.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private FieldAccessor acquireFieldAccessor(boolean overrideFinalCheck) {
    // First check to see if one has been created yet, and take it
    // if so
    FieldAccessor tmp = null;
    if (root != null) tmp = root.getFieldAccessor(overrideFinalCheck);
    if (tmp != null) {
        if (overrideFinalCheck)
            overrideFieldAccessor = tmp;
        else
            fieldAccessor = tmp;
    } else {
        // Otherwise fabricate one and propagate it up to the root
        tmp = reflectionFactory.newFieldAccessor(this, overrideFinalCheck);
        setFieldAccessor(tmp, overrideFinalCheck);
    }

    return tmp;
}
 
Example #6
Source File: Field.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
private FieldAccessor acquireFieldAccessor(boolean overrideFinalCheck) {
    // First check to see if one has been created yet, and take it
    // if so
    FieldAccessor tmp = null;
    if (root != null) tmp = root.getFieldAccessor(overrideFinalCheck);
    if (tmp != null) {
        if (overrideFinalCheck)
            overrideFieldAccessor = tmp;
        else
            fieldAccessor = tmp;
    } else {
        // Otherwise fabricate one and propagate it up to the root
        tmp = reflectionFactory.newFieldAccessor(this, overrideFinalCheck);
        setFieldAccessor(tmp, overrideFinalCheck);
    }

    return tmp;
}
 
Example #7
Source File: ReflectionUtils.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
public static void setFailsafeFieldValue(Field field, Object target, Object value)
        throws NoSuchFieldException, IllegalAccessException {

    // let's make the field accessible
    field.setAccessible(true);

    // next we change the modifier in the Field instance to
    // not be final anymore, thus tricking reflection into
    // letting us modify the static final field
    Field modifiersField = Field.class.getDeclaredField("modifiers");
    modifiersField.setAccessible(true);
    int modifiers = modifiersField.getInt(field);

    // blank out the final bit in the modifiers int
    modifiers &= ~Modifier.FINAL;
    modifiersField.setInt(field, modifiers);

    try {
        FieldAccessor fa = ReflectionFactory.getReflectionFactory().newFieldAccessor(field, false);
        fa.set(target, value);
    } catch (NoSuchMethodError error) {
        field.set(target, value);
    }
}
 
Example #8
Source File: Field.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private FieldAccessor acquireFieldAccessor(boolean overrideFinalCheck) {
    // First check to see if one has been created yet, and take it
    // if so
    FieldAccessor tmp = null;
    if (root != null) tmp = root.getFieldAccessor(overrideFinalCheck);
    if (tmp != null) {
        if (overrideFinalCheck)
            overrideFieldAccessor = tmp;
        else
            fieldAccessor = tmp;
    } else {
        // Otherwise fabricate one and propagate it up to the root
        tmp = reflectionFactory.newFieldAccessor(this, overrideFinalCheck);
        setFieldAccessor(tmp, overrideFinalCheck);
    }

    return tmp;
}
 
Example #9
Source File: Field.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
private FieldAccessor acquireFieldAccessor(boolean overrideFinalCheck) {
    // First check to see if one has been created yet, and take it
    // if so
    FieldAccessor tmp = null;
    if (root != null) tmp = root.getFieldAccessor(overrideFinalCheck);
    if (tmp != null) {
        if (overrideFinalCheck)
            overrideFieldAccessor = tmp;
        else
            fieldAccessor = tmp;
    } else {
        // Otherwise fabricate one and propagate it up to the root
        tmp = reflectionFactory.newFieldAccessor(this, overrideFinalCheck);
        setFieldAccessor(tmp, overrideFinalCheck);
    }

    return tmp;
}
 
Example #10
Source File: Field.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private FieldAccessor acquireFieldAccessor(boolean overrideFinalCheck) {
    // First check to see if one has been created yet, and take it
    // if so
    FieldAccessor tmp = null;
    if (root != null) tmp = root.getFieldAccessor(overrideFinalCheck);
    if (tmp != null) {
        if (overrideFinalCheck)
            overrideFieldAccessor = tmp;
        else
            fieldAccessor = tmp;
    } else {
        // Otherwise fabricate one and propagate it up to the root
        tmp = reflectionFactory.newFieldAccessor(this, overrideFinalCheck);
        setFieldAccessor(tmp, overrideFinalCheck);
    }

    return tmp;
}
 
Example #11
Source File: Field.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private FieldAccessor acquireFieldAccessor(boolean overrideFinalCheck) {
    // First check to see if one has been created yet, and take it
    // if so
    FieldAccessor tmp = null;
    if (root != null) tmp = root.getFieldAccessor(overrideFinalCheck);
    if (tmp != null) {
        if (overrideFinalCheck)
            overrideFieldAccessor = tmp;
        else
            fieldAccessor = tmp;
    } else {
        // Otherwise fabricate one and propagate it up to the root
        tmp = reflectionFactory.newFieldAccessor(this, overrideFinalCheck);
        setFieldAccessor(tmp, overrideFinalCheck);
    }

    return tmp;
}
 
Example #12
Source File: Field.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
private FieldAccessor acquireFieldAccessor(boolean overrideFinalCheck) {
    // First check to see if one has been created yet, and take it
    // if so
    FieldAccessor tmp = null;
    if (root != null) tmp = root.getFieldAccessor(overrideFinalCheck);
    if (tmp != null) {
        if (overrideFinalCheck)
            overrideFieldAccessor = tmp;
        else
            fieldAccessor = tmp;
    } else {
        // Otherwise fabricate one and propagate it up to the root
        tmp = reflectionFactory.newFieldAccessor(this, overrideFinalCheck);
        setFieldAccessor(tmp, overrideFinalCheck);
    }

    return tmp;
}
 
Example #13
Source File: Field.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private FieldAccessor acquireFieldAccessor(boolean overrideFinalCheck) {
    // First check to see if one has been created yet, and take it
    // if so
    FieldAccessor tmp = null;
    if (root != null) tmp = root.getFieldAccessor(overrideFinalCheck);
    if (tmp != null) {
        if (overrideFinalCheck)
            overrideFieldAccessor = tmp;
        else
            fieldAccessor = tmp;
    } else {
        // Otherwise fabricate one and propagate it up to the root
        tmp = reflectionFactory.newFieldAccessor(this, overrideFinalCheck);
        setFieldAccessor(tmp, overrideFinalCheck);
    }

    return tmp;
}
 
Example #14
Source File: Field.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private FieldAccessor acquireFieldAccessor(boolean overrideFinalCheck) {
    // First check to see if one has been created yet, and take it
    // if so
    FieldAccessor tmp = null;
    if (root != null) tmp = root.getFieldAccessor(overrideFinalCheck);
    if (tmp != null) {
        if (overrideFinalCheck)
            overrideFieldAccessor = tmp;
        else
            fieldAccessor = tmp;
    } else {
        // Otherwise fabricate one and propagate it up to the root
        tmp = reflectionFactory.newFieldAccessor(this, overrideFinalCheck);
        setFieldAccessor(tmp, overrideFinalCheck);
    }

    return tmp;
}
 
Example #15
Source File: Field.java    From Java8CN with Apache License 2.0 6 votes vote down vote up
private FieldAccessor acquireFieldAccessor(boolean overrideFinalCheck) {
    // First check to see if one has been created yet, and take it
    // if so
    FieldAccessor tmp = null;
    if (root != null) tmp = root.getFieldAccessor(overrideFinalCheck);
    if (tmp != null) {
        if (overrideFinalCheck)
            overrideFieldAccessor = tmp;
        else
            fieldAccessor = tmp;
    } else {
        // Otherwise fabricate one and propagate it up to the root
        tmp = reflectionFactory.newFieldAccessor(this, overrideFinalCheck);
        setFieldAccessor(tmp, overrideFinalCheck);
    }

    return tmp;
}
 
Example #16
Source File: Field.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private FieldAccessor acquireFieldAccessor(boolean overrideFinalCheck) {
    // First check to see if one has been created yet, and take it
    // if so
    FieldAccessor tmp = null;
    if (root != null) tmp = root.getFieldAccessor(overrideFinalCheck);
    if (tmp != null) {
        if (overrideFinalCheck)
            overrideFieldAccessor = tmp;
        else
            fieldAccessor = tmp;
    } else {
        // Otherwise fabricate one and propagate it up to the root
        tmp = reflectionFactory.newFieldAccessor(this, overrideFinalCheck);
        setFieldAccessor(tmp, overrideFinalCheck);
    }

    return tmp;
}
 
Example #17
Source File: Field.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private FieldAccessor acquireFieldAccessor(boolean overrideFinalCheck) {
    // First check to see if one has been created yet, and take it
    // if so
    FieldAccessor tmp = null;
    if (root != null) tmp = root.getFieldAccessor(overrideFinalCheck);
    if (tmp != null) {
        if (overrideFinalCheck)
            overrideFieldAccessor = tmp;
        else
            fieldAccessor = tmp;
    } else {
        // Otherwise fabricate one and propagate it up to the root
        tmp = reflectionFactory.newFieldAccessor(this, overrideFinalCheck);
        setFieldAccessor(tmp, overrideFinalCheck);
    }

    return tmp;
}
 
Example #18
Source File: Field.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
private FieldAccessor getFieldAccessor(Object obj)
    throws IllegalAccessException
{
    boolean ov = override;
    FieldAccessor a = (ov) ? overrideFieldAccessor : fieldAccessor;
    return (a != null) ? a : acquireFieldAccessor(ov);
}
 
Example #19
Source File: Field.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private FieldAccessor getFieldAccessor(Object obj)
    throws IllegalAccessException
{
    boolean ov = override;
    FieldAccessor a = (ov) ? overrideFieldAccessor : fieldAccessor;
    return (a != null) ? a : acquireFieldAccessor(ov);
}
 
Example #20
Source File: Field.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private void setFieldAccessor(FieldAccessor accessor, boolean overrideFinalCheck) {
    if (overrideFinalCheck)
        overrideFieldAccessor = accessor;
    else
        fieldAccessor = accessor;
    // Propagate up
    if (root != null) {
        root.setFieldAccessor(accessor, overrideFinalCheck);
    }
}
 
Example #21
Source File: Field.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private FieldAccessor getFieldAccessor(Object obj)
    throws IllegalAccessException
{
    boolean ov = override;
    FieldAccessor a = (ov) ? overrideFieldAccessor : fieldAccessor;
    return (a != null) ? a : acquireFieldAccessor(ov);
}
 
Example #22
Source File: Field.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private void setFieldAccessor(FieldAccessor accessor, boolean overrideFinalCheck) {
    if (overrideFinalCheck)
        overrideFieldAccessor = accessor;
    else
        fieldAccessor = accessor;
    // Propagate up
    if (root != null) {
        root.setFieldAccessor(accessor, overrideFinalCheck);
    }
}
 
Example #23
Source File: DynamicEnumType.java    From Carbon with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static void setField(Field field, Object target, Object value) throws NoSuchFieldException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
	field.setAccessible(true);
	Field modifiersField = Field.class.getDeclaredField("modifiers");
	modifiersField.setAccessible(true);
	modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);

	FieldAccessor fieldAccessor = ReflectionFactory.getReflectionFactory().newFieldAccessor(field, true);
	fieldAccessor.set(target, value);
}
 
Example #24
Source File: Field.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private FieldAccessor getFieldAccessor(Object obj)
    throws IllegalAccessException
{
    boolean ov = override;
    FieldAccessor a = (ov) ? overrideFieldAccessor : fieldAccessor;
    return (a != null) ? a : acquireFieldAccessor(ov);
}
 
Example #25
Source File: Field.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private void setFieldAccessor(FieldAccessor accessor, boolean overrideFinalCheck) {
    if (overrideFinalCheck)
        overrideFieldAccessor = accessor;
    else
        fieldAccessor = accessor;
    // Propagate up
    if (root != null) {
        root.setFieldAccessor(accessor, overrideFinalCheck);
    }
}
 
Example #26
Source File: Injector.java    From Carbon with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static void setStaticFinalField(Field field, Object newValue) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
    field.setAccessible(true);
    Field fieldModifiers = Field.class.getDeclaredField("modifiers");
    fieldModifiers.setAccessible(true);
    fieldModifiers.setInt(field, field.getModifiers() & ~Modifier.FINAL);
 FieldAccessor fieldAccessor = ReflectionFactory.getReflectionFactory().newFieldAccessor(field, true);
 fieldAccessor.set(null, newValue);
}
 
Example #27
Source File: Field.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
private FieldAccessor getFieldAccessor(Object obj)
    throws IllegalAccessException
{
    boolean ov = override;
    FieldAccessor a = (ov) ? overrideFieldAccessor : fieldAccessor;
    return (a != null) ? a : acquireFieldAccessor(ov);
}
 
Example #28
Source File: Field.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private FieldAccessor getFieldAccessor(Object obj)
    throws IllegalAccessException
{
    boolean ov = override;
    FieldAccessor a = (ov) ? overrideFieldAccessor : fieldAccessor;
    return (a != null) ? a : acquireFieldAccessor(ov);
}
 
Example #29
Source File: Field.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private void setFieldAccessor(FieldAccessor accessor, boolean overrideFinalCheck) {
    if (overrideFinalCheck)
        overrideFieldAccessor = accessor;
    else
        fieldAccessor = accessor;
    // Propagate up
    if (root != null) {
        root.setFieldAccessor(accessor, overrideFinalCheck);
    }
}
 
Example #30
Source File: Field.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
private void setFieldAccessor(FieldAccessor accessor, boolean overrideFinalCheck) {
    if (overrideFinalCheck)
        overrideFieldAccessor = accessor;
    else
        fieldAccessor = accessor;
    // Propagate up
    if (root != null) {
        root.setFieldAccessor(accessor, overrideFinalCheck);
    }
}