You want to find that constructor and set its availability to true.
But this is a dangerous operation that you should not attempt lightly. It's a dirty secret that private need not mean private, but I would still expect you to honor the wishes of the class designer and not circumvent.
Besides, you don't need to. If I understand your requirement, I've posted an example that will do what you want.
This works, because of this:
The protected modifier specifies that the member can only be accessed
within its own package (as with package-private) and, in addition, by
a subclass of its class in another package.
I think you've confused the meaning of the protected modifier.
Parent w/ protected ctor:
package foo;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* Parent with protected constructor
* User: MDUFFY
* Date: 3/27/14
* Time: 5:18 PM
* @link http://stackoverflow.com/questions/22698501/reflection-how-to-call-superclass-constructor-which-is-hidden/22698543?noredirect=1#comment34586243_22698543
*/
public class Foo {
private List<String> x;
protected Foo(List<String> y) {
this.x = ((y == null) ? new ArrayList<String>() : new ArrayList<String>(y));
}
public List<String> getX() {
return Collections.unmodifiableList(this.x);
}
@Override
public String toString() {
return "Foo{" +
"x=" + x +
'}';
}
}
Child extends Parent:
package bar;
import foo.Foo;
import java.util.Arrays;
import java.util.List;
/**
* Child of parent with protected ctor
* User: MDUFFY
* Date: 3/27/14
* Time: 5:22 PM
* @link http://stackoverflow.com/questions/22698501/reflection-how-to-call-superclass-constructor-which-is-hidden/22698543?noredirect=1#comment34586243_22698543
*/
public class Bar extends Foo {
public static void main(String[] args) {
Bar bar = new Bar(Arrays.asList(args));
System.out.println(bar);
}
public Bar(List<String> y) {
super(y);
}
}
This will compile and run.