231 reputation
411
bio website dp4j.com
location Bolzano, Italy
age
visits member for 3 years, 9 months
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


Dec
24
comment How to create a sudo user that cannot delete me?
that's a shame. I expected the OS to have such capability.
Aug
26
comment How do I delete all lines with “.png” in a file?
no inline option? I'd like to get rid of ".png" and ".jpg" for that matter. Also case-insenstive?
Jun
3
comment How to copy all html files from a directory tree to a single directory?
setopt globstar doesn't work on bash 4.2 both on mac and linux.
Jun
2
comment How to copy all html files from a directory tree to a single directory?
-J is not in gnu xargs (4.4.2)
May
10
comment How to copy all html files from a directory tree to a single directory?
on the mac I don't have -t but $ find MR -name "*.html" -exec cp ~/debug {} \; prints: "cp: /Users/simpatico/debug is a directory (not copied)." for each html file
May
10
comment How to copy all html files from a directory tree to a single directory?
@lain - did you notice my mac limited cp w/o -t? I actually intend not to copy the structure, so cmd would be ideal if it worked, but writing the cmd w/o -t doesn't do the trick (I still get the usage printed).
Mar
22
comment How can I keep processes running on a remote server even after turning off the terminal machine?
@Faheem: I still don't get it to work. I connect to the remote server through ssh and when I connect back to it from my home through vpn screen ls prints what I pasted in the 1st comment
Mar
19
comment How can I find and replace with a new line?
@lain: this doens't work with \n . Did you try it? the \ disappears while the n is appended. a, b --> an b
Mar
19
comment How can I find and replace with a new line?
@Mrozek: how do I use tr with the input and output file?
Mar
19
comment How can I keep processes running on a remote server even after turning off the terminal machine?
I execute $ screen -ls on my terminal. Before $ screen -d == $ screen ls, since I had multiple screens. N offense, is there how I could execute the command with some log to prove/track things?
Mar
19
comment How can I keep processes running on a remote server even after turning off the terminal machine?
$ screen -ls No Sockets found in /var/folders/Am/AmQYwuIoFSO0BNhXmOGzQU+++TI/-Tmp-/.screen. But I had detached sessions before turning off my machine, how do I attach to them again now?
Mar
19
comment How can I find and replace with a new line?
this replaced it with space and not new lines. Output: a b c
Mar
6
comment Why $JAVA_HOME does not persist on a mac?
my shell is Terminal.app. But why cannot it just work from the Property Editor List like other variables?
Mar
1
comment Why curl -O -C on mac fails to download
It doesn't fail. $ curl --fail -O repo2.maven.org/maven2/com/dp4j/dp4j/1.1/… % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 341k 100 341k 0 0 576k 0 --:--:-- --:--:-- --:--:-- 739k
Mar
1
comment Why curl -O -C on mac fails to download
i did all that..it's full of byte code (I already had the problem you guys refer to =) )
Mar
1
comment Why curl -O -C on mac fails to download
tried that..It's not the issue (it works on linux). The jar is indeed downloaded, but corrupt.