228 reputation
49
bio website dp4j.com
location Bolzano, Italy
age
visits member for 3 years, 1 month
seen Dec 24 '11 at 23:43

Author of dp4j.jar, which lets you test access private methods in Java without writing any reflection API code. The necessary reflection code is injected by dp4j at compile-time. So you only write:

@Test
public void aTest(){
  PrivateConstructor pc = new PrivateConstructor("Hello!");

Instead of:

import java.lang.reflect.*;

@Test
public void aTest() throws IllegalAccessException, NoSuchMethodException
, InvocationTargetException, InstantiationException {
    Constructor pcInit = PrivateConstructor.class.getDeclaredConstructor(String.class);
    pcInit.setAccessible(true);
    PrivateConstructor pc = (PrivateConstructor) pcInit.newInstance("Hello!");

Check it out at www.dp4j.com


Apr
5
awarded  Popular Question
Jun
18
awarded  Notable Question
Jun
5
awarded  Notable Question
May
28
awarded  Notable Question
Oct
24
awarded  Popular Question
Aug
24
awarded  Popular Question
Apr
19
awarded  Popular Question
Mar
4
awarded  Yearling
Mar
22
awarded  Commentator
Mar
21
awarded  Supporter
Mar
19
awarded  Editor
Mar
19
awarded  Student
Mar
4
awarded  Scholar