Java Annotations Processor (jar) for testing private methods and implemeting Design Patterns.
Java Shell
Clone or download
Latest commit f38bd9c Aug 11, 2018
Permalink
Failed to load latest commit information.
dp4j-tests
graphics
src
tools
.hgignore
Compile-Time Checked Reflection API.pdf
README.md
commands
nbactions-release-profile.xml
nbactions.xml
pom.xml

README.md

Dp4j is a Java Annotations Processor for testing private methods and implementing Design Patterns. You can see it in action with this testscript (for details, see wiki):

wget https://github.com/gk2go/dp4j/releases/download/dp4j-1.2/TESTDRIVE ; chmod +x TESTDRIVE ; ./TESTDRIVE

Testing Private Methods in Java

In a nutshell, when you add dp4j.jar to your project's CLASSPATH, Dp4j's Annotations Processor will analyze your @Test annotated methods and find out if you are trying to access private methods. It will then replace invalid code with equivalent Reflection API code that will work. The reflection code is injected directly in the AST of your code every time you compile it, and not in the source file so that you can freely edit your code. To see the generated reflection code, add the compiler parameter -Averbose=true as shown here:

javac -cp dp4j-1.0-jar-with-dependencies.jar -Averbose=true REPLACE-WITH-YOUR-JAVA-CLASS.java

Publications

Implementing patterns with annotations

Compile-time checked Reflection API

P.S. Contributions welcome!