Skip to main content
simpatico's user avatar
simpatico's user avatar
simpatico's user avatar
simpatico
  • Member for 13 years, 3 months
  • Last seen more than 1 year ago
Stats
631
reputation
132k
reached
2
answers
10
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.

4
gold badges
9
silver badges
19
bronze badges
2
Score
4
Posts
33
Posts %
2
Score
2
Posts
17
Posts %
2
Score
2
Posts
17
Posts %
2
Score
2
Posts
17
Posts %
2
Score
2
Posts
17
Posts %
0
Score
3
Posts
25
Posts %
Top posts
View all questions and answers