sun.reflect.ConstructorAccessor Java Examples

The following examples show how to use sun.reflect.ConstructorAccessor. 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: EnumBuster.java    From xmnlp with Apache License 2.0 6 votes vote down vote up
private ConstructorAccessor findConstructorAccessor(
        Class[] additionalParameterTypes,
        Class<E> clazz) throws NoSuchMethodException {
    Class[] parameterTypes =
            new Class[additionalParameterTypes.length + 2];
    parameterTypes[0] = String.class;
    parameterTypes[1] = int.class;
    System.arraycopy(
            additionalParameterTypes, 0,
            parameterTypes, 2,
            additionalParameterTypes.length);
    Constructor<E> cstr = clazz.getDeclaredConstructor(
            parameterTypes
    );
    return reflection.newConstructorAccessor(cstr);
}
 
Example #2
Source File: EnumBusterReflect.java    From ModTheSpire with MIT License 6 votes vote down vote up
private ConstructorAccessor findConstructorAccessor(
    Class[] additionalParameterTypes,
    Class<?> clazz) throws NoSuchMethodException {
    Class[] parameterTypes =
        new Class[additionalParameterTypes.length + 2];
    parameterTypes[0] = String.class;
    parameterTypes[1] = int.class;
    System.arraycopy(
        additionalParameterTypes, 0,
        parameterTypes, 2,
        additionalParameterTypes.length);
    Constructor<?> cstr = clazz.getDeclaredConstructor(
        parameterTypes
    );
    return reflection.newConstructorAccessor(cstr);
}
 
Example #3
Source File: Constructor.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
void setConstructorAccessor(ConstructorAccessor accessor) {
    constructorAccessor = accessor;
    // Propagate up
    if (root != null) {
        root.setConstructorAccessor(accessor);
    }
}
 
Example #4
Source File: Constructor.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
void setConstructorAccessor(ConstructorAccessor accessor) {
    constructorAccessor = accessor;
    // Propagate up
    if (root != null) {
        root.setConstructorAccessor(accessor);
    }
}
 
Example #5
Source File: EnumBusterReflect.java    From ModTheSpire with MIT License 5 votes vote down vote up
private Enum<?> constructEnum(Class<?> clazz,
                        ConstructorAccessor ca,
                        String value, int ordinal,
                        Object[] additional)
    throws Exception {
    Object[] parms = new Object[additional.length + 2];
    parms[0] = value;
    parms[1] = ordinal;
    System.arraycopy(
        additional, 0, parms, 2, additional.length);
    return (Enum<?>)clazz.cast(ca.newInstance(parms));
}
 
Example #6
Source File: Constructor.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
void setConstructorAccessor(ConstructorAccessor accessor) {
    constructorAccessor = accessor;
    // Propagate up
    if (root != null) {
        root.setConstructorAccessor(accessor);
    }
}
 
Example #7
Source File: ChangeEnumValues.java    From carbon-device-mgt with Apache License 2.0 5 votes vote down vote up
private static ConstructorAccessor getConstructorAccessor(Class<?> enumClass, Class<?>[] additionalParameterTypes)
        throws NoSuchMethodException {
    Class<?>[] parameterTypes = new Class[additionalParameterTypes.length + 2];
    parameterTypes[0] = String.class;
    parameterTypes[1] = int.class;
    System.arraycopy(additionalParameterTypes, 0, parameterTypes, 2, additionalParameterTypes.length);
    return reflectionFactory.newConstructorAccessor(enumClass.getDeclaredConstructor(parameterTypes));
}
 
Example #8
Source File: Constructor.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
void setConstructorAccessor(ConstructorAccessor accessor) {
    constructorAccessor = accessor;
    // Propagate up
    if (root != null) {
        root.setConstructorAccessor(accessor);
    }
}
 
Example #9
Source File: Constructor.java    From jdk-1.7-annotated with Apache License 2.0 5 votes vote down vote up
void setConstructorAccessor(ConstructorAccessor accessor) {
    constructorAccessor = accessor;
    // Propagate up
    if (root != null) {
        root.setConstructorAccessor(accessor);
    }
}
 
Example #10
Source File: Constructor.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
private ConstructorAccessor acquireConstructorAccessor() {
    // First check to see if one has been created yet, and take it
    // if so.
    ConstructorAccessor tmp = null;
    if (root != null) tmp = root.getConstructorAccessor();
    if (tmp != null) {
        constructorAccessor = tmp;
    } else {
        // Otherwise fabricate one and propagate it up to the root
        tmp = reflectionFactory.newConstructorAccessor(this);
        setConstructorAccessor(tmp);
    }

    return tmp;
}
 
Example #11
Source File: Constructor.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
void setConstructorAccessor(ConstructorAccessor accessor) {
    constructorAccessor = accessor;
    // Propagate up
    if (root != null) {
        root.setConstructorAccessor(accessor);
    }
}
 
Example #12
Source File: Constructor.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private ConstructorAccessor acquireConstructorAccessor() {
    // First check to see if one has been created yet, and take it
    // if so.
    ConstructorAccessor tmp = null;
    if (root != null) tmp = root.getConstructorAccessor();
    if (tmp != null) {
        constructorAccessor = tmp;
    } else {
        // Otherwise fabricate one and propagate it up to the root
        tmp = reflectionFactory.newConstructorAccessor(this);
        setConstructorAccessor(tmp);
    }

    return tmp;
}
 
Example #13
Source File: EnumBuster.java    From xmnlp with Apache License 2.0 5 votes vote down vote up
private E constructEnum(Class<E> clazz,
                        ConstructorAccessor ca,
                        String value, int ordinal,
                        Object[] additional)
        throws Exception {
    Object[] parms = new Object[additional.length + 2];
    parms[0] = value;
    parms[1] = ordinal;
    System.arraycopy(
            additional, 0, parms, 2, additional.length);
    return clazz.cast(ca.newInstance(parms));
}
 
Example #14
Source File: Constructor.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private ConstructorAccessor acquireConstructorAccessor() {
    // First check to see if one has been created yet, and take it
    // if so.
    ConstructorAccessor tmp = null;
    if (root != null) tmp = root.getConstructorAccessor();
    if (tmp != null) {
        constructorAccessor = tmp;
    } else {
        // Otherwise fabricate one and propagate it up to the root
        tmp = reflectionFactory.newConstructorAccessor(this);
        setConstructorAccessor(tmp);
    }

    return tmp;
}
 
Example #15
Source File: Constructor.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
void setConstructorAccessor(ConstructorAccessor accessor) {
    constructorAccessor = accessor;
    // Propagate up
    if (root != null) {
        root.setConstructorAccessor(accessor);
    }
}
 
Example #16
Source File: Constructor.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
private ConstructorAccessor acquireConstructorAccessor() {
    // First check to see if one has been created yet, and take it
    // if so.
    ConstructorAccessor tmp = null;
    if (root != null) tmp = root.getConstructorAccessor();
    if (tmp != null) {
        constructorAccessor = tmp;
    } else {
        // Otherwise fabricate one and propagate it up to the root
        tmp = reflectionFactory.newConstructorAccessor(this);
        setConstructorAccessor(tmp);
    }

    return tmp;
}
 
Example #17
Source File: DynamicEnumType.java    From Carbon-2 with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static Object makeEnum(Class<?> enumClass, String name, int ordinal, Class<?>[] paramTypes, Object[] paramValues) throws Exception {
    ArrayList<Class<?>> allParamTypes = new ArrayList<Class<?>>();
    allParamTypes.add(String.class);
    allParamTypes.add(Integer.TYPE);
    allParamTypes.addAll(Arrays.asList(paramTypes));

    ArrayList<Object> allParamValues = new ArrayList<Object>();
    allParamValues.add(name);
    allParamValues.add(Integer.valueOf(ordinal));
    allParamValues.addAll(Arrays.asList(paramValues));

    Constructor<?> enumConstructor = enumClass.getDeclaredConstructor((Class[]) allParamTypes.toArray(new Class[0]));
    ConstructorAccessor constructorAccessor = ReflectionFactory.getReflectionFactory().newConstructorAccessor(enumConstructor);
    return constructorAccessor.newInstance(allParamValues.toArray(new Object[0]));
}
 
Example #18
Source File: Constructor.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
private ConstructorAccessor acquireConstructorAccessor() {
    // First check to see if one has been created yet, and take it
    // if so.
    ConstructorAccessor tmp = null;
    if (root != null) tmp = root.getConstructorAccessor();
    if (tmp != null) {
        constructorAccessor = tmp;
    } else {
        // Otherwise fabricate one and propagate it up to the root
        tmp = reflectionFactory.newConstructorAccessor(this);
        setConstructorAccessor(tmp);
    }

    return tmp;
}
 
Example #19
Source File: Constructor.java    From jdk-1.7-annotated with Apache License 2.0 5 votes vote down vote up
private ConstructorAccessor acquireConstructorAccessor() {
    // First check to see if one has been created yet, and take it
    // if so.
    ConstructorAccessor tmp = null;
    if (root != null) tmp = root.getConstructorAccessor();
    if (tmp != null) {
        constructorAccessor = tmp;
    } else {
        // Otherwise fabricate one and propagate it up to the root
        tmp = reflectionFactory.newConstructorAccessor(this);
        setConstructorAccessor(tmp);
    }

    return tmp;
}
 
Example #20
Source File: Constructor.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
void setConstructorAccessor(ConstructorAccessor accessor) {
    constructorAccessor = accessor;
    // Propagate up
    if (root != null) {
        root.setConstructorAccessor(accessor);
    }
}
 
Example #21
Source File: Constructor.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
void setConstructorAccessor(ConstructorAccessor accessor) {
    constructorAccessor = accessor;
    // Propagate up
    if (root != null) {
        root.setConstructorAccessor(accessor);
    }
}
 
Example #22
Source File: Constructor.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private ConstructorAccessor acquireConstructorAccessor() {
    // First check to see if one has been created yet, and take it
    // if so.
    ConstructorAccessor tmp = null;
    if (root != null) tmp = root.getConstructorAccessor();
    if (tmp != null) {
        constructorAccessor = tmp;
    } else {
        // Otherwise fabricate one and propagate it up to the root
        tmp = reflectionFactory.newConstructorAccessor(this);
        setConstructorAccessor(tmp);
    }

    return tmp;
}
 
Example #23
Source File: Constructor.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private ConstructorAccessor acquireConstructorAccessor() {
    // First check to see if one has been created yet, and take it
    // if so.
    ConstructorAccessor tmp = null;
    if (root != null) tmp = root.getConstructorAccessor();
    if (tmp != null) {
        constructorAccessor = tmp;
    } else {
        // Otherwise fabricate one and propagate it up to the root
        tmp = reflectionFactory.newConstructorAccessor(this);
        setConstructorAccessor(tmp);
    }

    return tmp;
}
 
Example #24
Source File: ReflectionUtils.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
private static ConstructorAccessor getConstructorAccessor(Class<?> enumClass,
                                                          Class<?>[] additionalParameterTypes) throws NoSuchMethodException {
    Class<?>[] parameterTypes = new Class[additionalParameterTypes.length + 2];
    parameterTypes[0] = String.class;
    parameterTypes[1] = int.class;
    System.arraycopy(additionalParameterTypes, 0,
            parameterTypes, 2, additionalParameterTypes.length);
    return ReflectionFactory.getReflectionFactory().newConstructorAccessor(enumClass.getDeclaredConstructor(parameterTypes));
}
 
Example #25
Source File: Constructor.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
private ConstructorAccessor acquireConstructorAccessor() {
    // First check to see if one has been created yet, and take it
    // if so.
    ConstructorAccessor tmp = null;
    if (root != null) tmp = root.getConstructorAccessor();
    if (tmp != null) {
        constructorAccessor = tmp;
    } else {
        // Otherwise fabricate one and propagate it up to the root
        tmp = reflectionFactory.newConstructorAccessor(this);
        setConstructorAccessor(tmp);
    }

    return tmp;
}
 
Example #26
Source File: Constructor.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private ConstructorAccessor acquireConstructorAccessor() {
    // First check to see if one has been created yet, and take it
    // if so.
    ConstructorAccessor tmp = null;
    if (root != null) tmp = root.getConstructorAccessor();
    if (tmp != null) {
        constructorAccessor = tmp;
    } else {
        // Otherwise fabricate one and propagate it up to the root
        tmp = reflectionFactory.newConstructorAccessor(this);
        setConstructorAccessor(tmp);
    }

    return tmp;
}
 
Example #27
Source File: Constructor.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
void setConstructorAccessor(ConstructorAccessor accessor) {
    constructorAccessor = accessor;
    // Propagate up
    if (root != null) {
        root.setConstructorAccessor(accessor);
    }
}
 
Example #28
Source File: EnumBuster.java    From xmnlp with Apache License 2.0 5 votes vote down vote up
/**
 * Make a new enum instance with the given value, ordinal and
 * additional parameters.  The additionalTypes is used to match
 * the constructor accurately.
 */
public E make(String value, int ordinal,
              Class[] additionalTypes, Object[] additional) {
    try {
        undoStack.push(new Memento());
        ConstructorAccessor ca = findConstructorAccessor(
                additionalTypes, clazz);
        return constructEnum(clazz, ca, value,
                ordinal, additional);
    } catch (Exception e) {
        throw new IllegalArgumentException(
                "Could not create enum", e);
    }
}
 
Example #29
Source File: Constructor.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private ConstructorAccessor acquireConstructorAccessor() {
    // First check to see if one has been created yet, and take it
    // if so.
    ConstructorAccessor tmp = null;
    if (root != null) tmp = root.getConstructorAccessor();
    if (tmp != null) {
        constructorAccessor = tmp;
    } else {
        // Otherwise fabricate one and propagate it up to the root
        tmp = reflectionFactory.newConstructorAccessor(this);
        setConstructorAccessor(tmp);
    }

    return tmp;
}
 
Example #30
Source File: Constructor.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
void setConstructorAccessor(ConstructorAccessor accessor) {
    constructorAccessor = accessor;
    // Propagate up
    if (root != null) {
        root.setConstructorAccessor(accessor);
    }
}