simpatico's user avatar
simpatico's user avatar
simpatico's user avatar
simpatico
  • Member for 13 years, 8 months
  • Last seen more than a month ago
Stats
10,799
reputation
4.1m
reached
62
answers
158
questions
Loading…
About

Author of [dp4j.jar][1], 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.

21
gold badges
81
silver badges
127
bronze badges
82
Score
92
Posts
42
Posts %
14
Score
17
Posts
8
Posts %
8
Score
19
Posts
9
Posts %
2
Score
23
Posts
10
Posts %
2
Score
12
Posts
5
Posts %
2
Score
11
Posts
5
Posts %