Tuesday, June 19, 2012

Eclipse Demo Camp 2012 - Bangalore

It's demo camp time again! I will be speaking this Friday at the Eclipse Demo Camp Bangalore where I will demo some of the interesting new features in JDT for Juno and also show off a few tips and tricks. 


It should be fun discussing Eclipse over some Tapas and wine :-) Thanks Annamalai for organizing this!

Thursday, June 14, 2012

JDT Tip: Toggle between inserting and replacing content assist


When content assist is invoked on an existing identifier, it can either replace the identifier with the chosen completion or do an insert.

The default behavior is to insert. You can toggle this behavior while inside the content assist selection dialog by pressing and holding the Ctrl key while selecting the completion. The highlighted text is overwritten.

If you wish the completion to overwrite without pressing the Ctrl key then you can select 'Preferences > Java > Editor > Content Assist > Completion overwrites'.

Thursday, May 3, 2012

Subwords completion

Not so long ago I was fairly happy with JDT's content assist, and then I started using Subwords completion from Code Recommenders project and now it is fair to say that I cannot write code without it! :-)

The idea is simple enough - you should not have to type a name from the beginning to find a match in the content assist popup. It really helps when I do not know if I have to 'find' an element or 'get' an element.

The feature is sophisticated enough to understand a rough shorthand e.g. dclr for declaration.


It is also sophisticated enough to understand that a method or type name in Java is composed of several words e.g. 'ty + dclr' finds all 'type' + 'declarations'.

Wednesday, May 2, 2012

JDT 3.8/4.2 M7 - New and Noteworthy

As usual we devoted most of our time in M7 towards polish and performance, nevertheless we managed a few new and noteworthy items.

Firstly a word about bracket matching. So far, a matching bracket was found when the caret was placed immediately 'after' a bracket. This caused confusion because a user can also think in terms of placing the caret 'inside' or 'outside' a bracket pair, see bug 9503. We tweaked this during M6 so that the start bracket was highlighted when the caret is before (not after) the end bracket, i.e. bracket matching now worked when the caret was 'inside' a bracket pair. We realized that this was still not ideal, and also that the old behavior was broken which some of users were already accustomed to.

All this has been improved and now a matching bracket is found both when the caret is placed either immediately before or immediately after a bracket i.e. now bracket matching just works in all cases a user might expect it to work.
You can hover over a closing curly brace and see the source near the matching opening brace in a hover. This is helpful when you want to see the code near the start of a long code block. The hover also tells the number of lines in the code block.


The hover is also useful to temporarily 'highlight' a code block.

In M6 we had tweaked the warning on enum based switch statements, unfortunately the tweaks were not ideal and resulted in a bit of activity on bugzilla. This has been improved and new compiler options have been added to take care of all cases.

Those who are using null annotations will also discover that there are a few new quick fixes to help you a little bit.  One set of quick fixes help to quickly setup a project to use null annotations, i.e. appropriately add the annotations jar to the build path. The second set of quick fixes help you fix problems with respect to incorrect usage of null annotations, missing annotations etc. This second set is not yet perfect, see bug 337977

As always, feedback is greatly appreciated especially in the form of bug reports!

In other news, during this milestone I also earned commit rights on Platform/Text project :-)

Friday, April 20, 2012

Recovering from a hard disk failure


A few weeks back the hard disk of my laptop computer crashed, and as a hard disk had never crashed in my vicinity earlier I was a bit unsure about what to do. I could have used one of those data recovery services, however I decided to tackle the problem on my own because - no one cares for my data more than me and you cannot really trust a stranger with your data. I ended up spending a fair bit of time trying to recover my data. Here is a summary of what I did

1. Essentially my computer had stopped booting up. On powering it on, the Loading Windows screen would come and then a blue-screen-of-death. Now this could be because some OS files are corrupted, or there is a problem with master-boot-record, mother board issue or a gazillion other things. Hence, the first step is to verify that it is an hard disk issue. To do so get a bootable CD/DVD or a USB and boot using that, if the system boots then something is probably wrong with the hard disk. If you do not have a bootable CD/DVD/USB ready at hand, ask around, a bootable Linux disc is not too hard to find.

2. I could boot my system using a bootable USB drive. Once booted I tried to access the hard disk in question, however that did not work. The hard disk would not mount. I even tried using a bootable BartPE disk, and even that did not help. So something was seriously wrong with my hard disk.

3. Now I was certain that there is a serious failure and I would need some special tools to recover my data. At this point you have 2 choices in front of you
a) Boot your system using a bootable disk and use a specialized software installed on that bootable disk to recover your data
b) Take out your hard disk and connect it to another computer as a secondary drive.

Let me explain both choices and reasons behind why I went with option (b)
a) For this option, you can use BartPE to boot your computer. BartPE has a plugin for GetDataBack, however I found this option a bit cumbersome to use. There were a few steps to setup everything nicely so as to copy data on to an external drive. Hence, I thought of exploring option (b)
b) In this option, the major hurdle is to be able to connect your hard disk to another computer because you need some hardware which not everyone may not have lying around. Luckily for me a friend had replaced his CD/DVD drive with a secondary hard disk and he was kind enough to lend me the hard disk bay for a few days :-) I also had another laptop readily available, something that may not be true for everyone. Once I was able to connect my faulty hard drive to another computer as a secondary drive, I could use any number of data recovery tools like GetDataBack, Partition Table Doctor, or freeware such as PC Inspector File recovery. Some more tools can be found at alternativeto.net.

4. Now reading data from my faulty hard drive was a simple task, it was slow but simple enough. However, some sectors on the disk were clearly bad and there were quite a few I/O errors while recovering the data. Hence, I was a bit unsure about the quality of data I was getting back - maybe some files were forever lost, or maybe some files were corrupted - essentially I did not know if I could trust the data. Now I also had a few months old data backup on an external drive, hence I thought to start with that and compare with the recovered data and sort of merge the two :-) Again there are a few tools which can help with this, Microsoft SyncToy is fairly neat and is also free, Beyond Comapre is a bit better but is not free.

Now I could have avoided all this if I frequently did a data backup. In any case it was kind of interesting to do all this and I did learn a few things along the way. The most important lesson obviously being - take a data backup every week! :-)

Note: I should also mention that somewhere in between I also tried the freezing-the-hard-disk trick. I know it sounds a bit crazy, and it did not work for me, but for some folks it seems to help a bit.

Sunday, April 15, 2012

YourKit profiler APIs

YourKit provides APIs to start and stop measuring from within your application, e.g.
com.yourkit.api.Controller controller = new com.yourkit.api.Controller();
controller.startCPUProfiling (com.yourkit.api.ProfilingModes.CPU_TRACING , null);
controller.stopCPUProfiling();
controller.captureSnapshot (com.yourkit.api.ProfilingModes.SNAPSHOT_WITHOUT_HEAP);
To use these APIs include <Profiler Installation Directory>/lib/yjp-controller-api-redist.jar in the classpath. Read more about YourKit APIs here.

Wednesday, April 11, 2012

Permanently enable 'Open command window here' in Windows 7

By default you need to right-click a folder, while pressing the SHIFT key, in order to access 'Open command window here' context menu option. However, it can be enabled permanently with the help of following steps
  • Click Start, Run and type Regedit.exe
  • Navigate to the following location:
    • HKEY_CLASSES_ROOT\Directory\shell\cmd
  • In the right-pane, delete the REG_SZ value named Extended