Saturday, October 14, 2006

More on VIM

I was bored and just browsing through del.icio.us. And got a link saying that VIM is easy than you think. Got interested and Wanted to know what they are telling about vim. They said that VIM 7.0 supports tabs. Here is the link

Browsers, editors in linux and now???? vim.
Everybody is after tabs... :) For people like me, who don't like to see the desktop cluttered with windows, like in some operating systems, it will be gud to use.

And will those OS introduce tab based explorers for browsing the local file systems in future????

Wednesday, October 11, 2006

Power/Weakness (???) of Reflection in Java

Blogging after a loooooooooooooooooong time. :)

I got this question and answer from somebody else and thought of sharing:

public class test{
  private String id;
    public String getId() {
      return id;
    }
}


In this class, how to set value to id?

The answer is "Reflection"

Use the following code:

test obj = new test();
Field myfields[] = test.class.getDeclaredFields();
for (int i = 0; i < myfields.length; ++i) {
  if ("id".equals(myfields[i].getName())) {
    Field f = myfields[i];
    //This is important , otherwise u get a access denied exception
    f.setAccessible(true);
    f.set(obj,"I modified it");
  }
}


Seems like this is a security issue in Java. I read that if we used SecurityManager, this can be avoided. ( Have to learn about SecurityManager :) )