Code example for Constructor

Methods: getParameterTypes

0
    } 
 
    public void test_getParameterTypes() throws Exception { 
        Class[] expectedParameters = new Class[] { Object.class };
        Constructor<?> constructor = ConstructorTestHelper.class.getConstructor(expectedParameters);
        Class[] parameters = constructor.getParameterTypes();
        assertEquals(1, parameters.length);
        assertEquals(expectedParameters[0], parameters[0]);
        // Check that corrupting our array doesn't affect other callers. 
        parameters[0] = String.class;
        parameters = constructor.getParameterTypes();
        assertEquals(1, parameters.length);
        assertEquals(expectedParameters[0], parameters[0]);
    } 
 
    static class ConstructorTestHelper { 
        public ConstructorTestHelper() throws IndexOutOfBoundsException { } 
        public ConstructorTestHelper(Object o) { }
    } 
}