Name | Modified | Size | Downloads / Week |
---|---|---|---|
Parent folder | |||
README.txt | 2011-03-01 | 1.7 kB | |
dp4j-1.0-jar-with-dependencies.jar | 2011-03-01 | 381.9 kB | |
Totals: 2 Items | 383.6 kB | 0 |
Javadoc, sources, and other artifacts maybe downloaded from http://repo2.maven.org/maven2/com/dp4j/dp4j/1.0/ Follows a quick command-line test. You are expected to have the jdk installed, and javac in your path. $ vim Test.java (windows: notepad Test.java) class T { private static void p(int i, Double d, String... s){} } public class Test{ @com.dp4j.InjectReflection public void t() { T.p(1,new Double(2),"hello", "reflection"); } } $ ls Test.class T.class (windows: dir Test.class T.class) ls: Test.class: No such file or directory ls: T.class: No such file or directory $ javac -cp dp4j-1.0-jar-with-dependencies.jar Test.java $ ls Test.class T.class (windows: dir Test.class T.class) ls Test.class T.class To see the code generated for you: $ javac -Averbose=true -cp dp4j-1.0-jar-with-dependencies.jar Test.java ... @com.dp4j.InjectReflection() public void t() throws java.lang.ClassNotFoundException, java.lang.NoSuchFieldException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException, java.lang.IllegalArgumentException { final java.lang.reflect.Method pMethod = Class.forName("T").getDeclaredMethod("p", .java.lang.Integer.TYPE, .java.lang .class); pMethod.setAccessible(true); pMethod.invoke("", new .java.lang.Object[3][]{1, new Double(2), new .java.lang.String[2][]{"hello", "reflection"}}); } } $ javac -version javac 1.7.0-ea javac 1.6.0_23 javac 1.6.0_18 To use @Test annotation instead of @InjectReflection you must have junit/testNG.jar in the classpath. More tests can be downloaded from http://code.google.com/p/dp4j/source/browse/#hg%2Fsrc%2Ftest%2Fresources%2Fcom%2Fdp4j%2Fsamples