Java Code Examples for sun.reflect.ConstructorAccessor

The following examples show how to use sun.reflect.ConstructorAccessor. These examples are extracted from open source projects. 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 Project: ModTheSpire   Source File: EnumBusterReflect.java    License: 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 2
Source Project: xmnlp   Source File: EnumBuster.java    License: 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 3
Source Project: jdk1.8-source-analysis   Source File: Constructor.java    License: 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 4
Source Project: jdk1.8-source-analysis   Source File: Constructor.java    License: 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 5
Source Project: dragonwell8_jdk   Source File: Constructor.java    License: 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 6
Source Project: dragonwell8_jdk   Source File: Constructor.java    License: 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 Project: TencentKona-8   Source File: Constructor.java    License: 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 8
Source Project: carbon-device-mgt   Source File: ChangeEnumValues.java    License: 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 9
Source Project: TencentKona-8   Source File: Constructor.java    License: 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 10
Source Project: jdk-1.7-annotated   Source File: Constructor.java    License: 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 11
Source Project: ModTheSpire   Source File: EnumBusterReflect.java    License: 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 12
Source Project: jdk8u60   Source File: Constructor.java    License: 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 Project: jdk8u60   Source File: Constructor.java    License: 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 14
Source Project: JDKSourceCode1.8   Source File: Constructor.java    License: 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 15
Source Project: JDKSourceCode1.8   Source File: Constructor.java    License: MIT License 5 votes vote down vote up
void setConstructorAccessor(ConstructorAccessor accessor) {
    constructorAccessor = accessor;
    // Propagate up
    if (root != null) {
        root.setConstructorAccessor(accessor);
    }
}
 
Example 16
Source Project: openjdk-jdk8u   Source File: Constructor.java    License: 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 17
Source Project: xmnlp   Source File: EnumBuster.java    License: 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 18
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
void setConstructorAccessor(ConstructorAccessor accessor) {
    constructorAccessor = accessor;
    // Propagate up
    if (root != null) {
        root.setConstructorAccessor(accessor);
    }
}
 
Example 20
Source Project: jdk8u-jdk   Source File: Constructor.java    License: 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 21
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 22
Source Project: Java8CN   Source File: Constructor.java    License: 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 23
Source Project: jdk-1.7-annotated   Source File: Constructor.java    License: 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 24
Source Project: Java8CN   Source File: Constructor.java    License: 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 25
Source Project: jdk8u-dev-jdk   Source File: Constructor.java    License: 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 26
Source Project: hottub   Source File: Constructor.java    License: 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 Project: openjdk-8-source   Source File: Constructor.java    License: 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 28
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 29
Source Project: jdk8u-dev-jdk   Source File: Constructor.java    License: 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 Project: openjdk-8   Source File: Constructor.java    License: 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;
}