Monday, December 13, 2010

JDT 3.7 M4 - New and Noteworthy

This time there are a bunch of interesting items in the quick assist (Ctrl+1) area

The Introduce new local with cast type quick assist is now not only available on the instanceof keyword, but also in the body of the conditional statement (before the first body statement).

The Join variable declaration quick assist is now also available for variables initialized to null.

The Exchange left and right operands for infix expression quick assist is now also available for the !=, <, <=, >, and >= operators.

The properties file editor now offers two new quick assists to escape or unescape backslashes.

The Escape backslashes quick assist is also offered automatically on paste if the pasted text contains backslashes that should be escaped.  The next step is to provide a similar feature in the Java Editor, see Bug 332205.

Couple of irritating bugs that got fixed
  • Bug 327079 [JUnit] Can't run single test with JUnit 4 launcher if there's a suite() method
  • Bug 329677 [type hierarchy] view must honor package name abbreviation setting

Sunday, October 31, 2010

e4 - Eclipse 4.x - Second Impression

I have been using the latest builds of Eclipse 4.x SDK for my daily work for the last 6 weeks. The overall stability has improved gradually, and the NPEs are quite rare now. Some of the bugs I filed were also fixed  quite quickly during M3 - Bug 325834 , Bug 327154. But there are still a few things which must work but don't.
  • Ability to customize a perspective (Bug 320478)
  • Ability to set or change key bindings (Bug 317299)
  • Plus I am a bit confused about the 'Editor Area' introduced in 4.1 M3. Does this mean I should not create multiple editor stacks? Should I create multiple editor stacks only in the editor area? Will this editor area continue to take extra space as it does in M3? In 3.x we had a editor only area, are we going back towards that? M4 is supposed to have a more polished implementation of the 'Editor area', I will wait for that.
I am also hoping that Editor tab rendering could be improved significantly in Eclipse 4.x (Bug 325422).

    Saturday, September 18, 2010

    e4 - Eclipse 4.0 : First Impression

    Looks a bit funny

    Off is On and On is Off - I saw that Build Automatically was Off so I switched it On, and then my code changes had no effect... few minutes later I realized that if something is turned Off in the UI, it may mean that it is actually turned On! e.g.Mark Occurrences, Build Automatically.  Or in the case of 'Edit > Smart Insert Mode' I cannot even toggle it.

    Layout and minimized Views - I like the overall layout and the fact that I can put views in the editor area. I also like the way when minimized views are selected they open in a pop-up sort of a way. Overall the UI/layout feels nice.

    Custom Key Bindings - mmh...

    Order of menu and toolbar items - The ordering of items in menus and toolbars can be a bit different from 3.x versions. e.g. navigate menu, run/debug toolbar
    I can use it for my daily work, except for some minor glitches and some funny behavior I have been able to use it for last few days. And I do like the layout, mixing of editors and views, and the overall feel of the UI to not go back to 3.x (at least for now).

    Monday, September 6, 2010

    New Command in JDT : Open from Clipboard

    This is what I used to end up doing very frequently
    - copy something like String#getBytes from a bug comment
    - press Ctrl+Shift+T in Eclipse
    - paste the copied text Open Type dialog
    - argh... no matches
    - delete the method name
    - open the type in an editor
    - press Ctrl+O
    - argh.. what was that method again?
    - go back to bugzilla and read/copy the method name
    - come back to Quick Outline and filter the method
    - and finally reach the method

    The new command opens a Java element or a Java stack trace from clipboard. If the clipboard content spans multiple lines then the it is pasted to the Java Stack Trace Console. If the clipboard content is a single line the command tries to open the matching Java element in an editor. Some examples
    • java.lang.String
    • String#getBytes
    • java.lang.String.getBytes(String, int[], int)
    • at java.lang.String.matches(
    • java.lang.String.valueOf(char) line: 1456  
    I use this command with a key binding of Ctrl+Shift+V. After doing a Ctrl+C the most natural thing to do is Ctrl+V so the key binding for this command should be similar. Plus Ctrl+Shift+V is also similar to Ctrl+Shift+T and Ctrl+Shift+R, making it a bit easier for me to remember it.

    This command (Bug 48880) is already in nightly builds and will be in the today's I-build.

    As a final note I should also mention 2 'nasty' Platform bugs that I faced while implementing this command
    • Bug 324160: [Commands] Platform should support to use the action IDs from the action set contribution in menuContribution
    • Bug 324161: menu contributions added using 'endof' should appear before contributions added using 'after'
    I say nasty because in its current form the whole menu contribution, command, actionSet, action story can be very confusing...

    Saturday, August 7, 2010

    JDT 3.7 M1 - New and Noteworthy

    Filter preferences on Java > Compiler > Errors/Warnings page

    We have just too many options on this preference page (as does PDE and API tooling on some of their preference pages) and finding the option you are looking for can be quite difficult (and frustrating) with all the twisties and so much of scrolling involved.

    You can now filter preferences on the Java > Compiler > Errors/Warnings page by preference label text or by preference value. A word in the filter string preceded by '~' is used to filter on preference values. Examples:
    • param
    • ~off
    • ~ignore
    • param ~enabled
    • ~ignore param

    Bug 321818 is the next item to do - allow to filter a section for a value e.g. 'code style ~error.

    New 'Open Hyperlink' command

    The new Open Hyperlink command opens one or more hyperlinks at the current caret location. The command has been added to the Navigate menu for the Java and properties file editors and can also be used in other text editors by assigning a key binding on the General > Keys preference page.

    The command opens the hyperlink directly if there's only one link available. Otherwise, it shows a chooser with all the available hyperlinks at that location. The links are the same as when you move the mouse with Ctrl pressed.
    So now you can assign a key to this command (say F6) and then use this command in Properties files to navigate to NLS key references, in Java editor to navigate to declaration or implementation for a method,and declaration for other Java elements, or for any other hyperlinks.

    In short you can possibly stop using Open Declaration (F3) and start using this new command - depending on whether or not you would like to always make a choice between navigating to declaration or navigating to implementation for method invocations :)

    Other New and Noteworthy items.

    Sunday, August 1, 2010

    CVS vs Git: Local disk usage

    I was a bit skeptical about the local disk usage with Git, as every Git clone is a full-fledged repository with complete history, and apparently Git stores entire snapshots and not the deltas.

    Everyone seemed to be claiming that Git is quite efficient in terms of storage space required, and I also found the following statistic on the web
    "The Mozilla CVS repository was 2.7GB, imported to Subversion it grew to 8.2GB. Under Git, it shrunk to 450MB. Given that a Mozilla checkout is around 350MB, its fairly nice to have the whole project history (from 1998) in only slightly more space."

    But I was still a bit skeptical... :)

    So I downloaded some of the JDT source from Eclipse Git repositories and compared the disk usage under Git with CVS. Here are the numbers. For these selected projects, Git on an average takes less than three times the space required by CVS. In my opinion this cost is nothing as compared to the benefits of having the entire history locally.

    Saturday, July 31, 2010

    Eclipse Helios

    Going through the Helios Reviews I see that a number of bloggers have said good things about the new features in JDT :)

    If you have not yet seen the new features of JDT then check out the 10 minute demo I recorded last month. This video shows what's new in JDT for Eclipse 3.6, the Helios release.What's shown in the video is just a part of all the new stuff within JDT. For more information see the 'What's New' document in the Java development user guide.

    My favorite features being
    • Java breakpoint detail - No more opening a new dialog for editing breakpoint properties, I just love this one.
    • Package name abbreviations - This is a simple but very useful improvement, makes the Package Explorer a lot less cluttered.

      • Remove nodes from Call Hierarchy - While this is useful now, it should become better once Bug 304135 (Allow to pin Call Hierarchy) gets fixed.

      • Fix multiple problems via problem hover - This saves a lot of effort.

      Work on Eclipse Indigo is already in full swing with M1 coming up next week. Some nice features have been implemented in M1, bugs - 78522 , 277862 , 315772 , 320876 , 310470.

      Thursday, July 1, 2010

      Too many options in Eclipse?

      At times I wonder if we have too many actions, key bindings, preferences etc in Eclipse. I mean a beginner would probably find  number of key bindings in the Ctrl+Shift+L pop-up overwhelming. This pop-up lists a number of 'Show View' key bindings, but I think listing only Quick Access (Ctrl+3) should suffice - at least for beginners.

      This raises another question - how many users of Eclipse are beginners, how many some what comfortable, how many expert. I would assume a significant number in each category. Maybe we should have beginner, intermediate, expert modes/perspectives. For example in the beginner mode we can hide (not disable) the actions and preferences which are typically used by power users.

      Sunday, June 20, 2010

      Mac : Windows :: iOS : Android ?

      In the late 70s and the early 80s Apple computers were the coolest devices around and everyone wanted to have one, and then Windows came along firstly with IBM PCs and then with IBM PC clones, i.e. Windows worked on hardware sold by most manufactures.

      Now in 2010, iPhone is the coolest device out there and everyone wants to have one, but Android has come along which works on hardware sold by a number of manufactures.

      Is history repeating itself?

      Saturday, June 19, 2010

      The Executive Dashboard 2010

      This is the Executive Dashboard as presented at IBM Rational Innovate 2010. This looks to be quite a bit more sophisticated than last year.

      Wednesday, June 2, 2010

      Printpoints : Debugging by writing to console

      There are two ways of debugging
      • Breakpoints - I typically use breakpoints when
        • I do not have much idea of the code and need to inspect variables and expressions at a number of places to gain an understanding of what is happening.
        • I am making some changes and want to see how these changes affect a particular variable/expression, also I am confident that one or two iterations of this change-test process will suffice
      • Printpoints - There are scenarios when the breakpoints fail or are inefficient, in these cases I just use System.out.println(). This is typically when
        • the breakpoint hits too often, for example keypress, focus, mouse events
        • I want to see the order of thread execution
        • I am making some changes and want to see how these changes affect a 'few' variables/expressions, also I am confident that it will take 'a number' of iterations of this change-test process to fix the bug. Printing everything to console in this case proves to be much more efficient than stepping through the code.
      Most developers (including me till recently) insert the print statements in their code and the problem with that is that you have to take them out later. I know you can sometimes leave them in the source as tracing statements, but most of the time they have to be taken out. But there is a solution...

      The conditional breakpoint editor in Eclipse can be 'tricked' to create what I like to call as Printpoint - and define as a 'point' in code where the debugger does not 'break' but only 'prints' to console. Essentially a Printpoint is a conditional breakpoint that never suspends execution but only prints to console. To set a printpoint, set a conditional breakpoint with Suspend when 'true' option and a condition which is always false. e.g.

      Code templates are available in the condition editor, so you can create a template under 'Java statements' context and use it here. Bug 315404 has been filed to have this available in JDT by default.

      Saturday, May 29, 2010

      ECJ - Eclipse Compiler for Java

      Eclipse provides and uses its own compiler that is not javac
      • The Eclipse compiler is used inside the IDE (Eclipse)
      • The Eclipse compiler can also be used as a pure batch compiler outside of Eclipse
      Finding the Batch compiler

      The batch compiler class is located in the JDT Core plug-in. The name of the class is org.eclipse.jdt.compiler.batch.BatchCompiler. It is packaged into plugins/org.eclipse.jdt.core_3.5.2.v_981_R35x.jar. Since 3.2, it is also available as a separate download. The name of the file is ecj.jar. Its corresponding source is also available. To get them, go to the download page, select a build and search for the section JDT Core Batch Compiler. This jar contains the batch compiler and the javac ant adapter.

      Running the batch compiler from command line

      Check compiler version
      $ java -jar ecj-3.5.2.jar -version
      $ java -jar org.eclipse.jdt.core_3.5.2.v_981_R35x.jar -version

      Eclipse Compiler for Java (TM) 0.981_R35x, 3.5.2 release, Copyright IBM Corp 2000, 2009. All rights reserved.

      Compile a source file
      $ java -jar ecj-3.5.2.jar
      $ java -jar org.eclipse.jdt.core_3.5.2.v_981_R35x.jar

      Running the batch compiler programmatically
      Use the static compile(String commandLine, PrintWriter outWriter, PrintWriter errWriter, CompilationProgress progress) method of the class BatchCompiler.

      org.eclipse.jdt.compiler.CompilationProgress progress = null; // instantiate your subclass
      "-classpath rt.jar",
      new PrintWriter(System.out),
      new PrintWriter(System.err),

      You can control how progress is reported, or how the batch compiler is canceled, by subclassing the class org.eclipse.jdt.compiler.CompilationProgress.

      Using the ant javac adapter

      The Eclipse compiler can be used inside an Ant buildfile using the javac adapter. In order to use the Eclipse compiler, you simply need to define the build.compiler property in your buildfile.

      property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"

      More Information
      Look in Eclipse SDK - Help : JDT Plug-in Developer Guide > Programmer's Guide > JDT Core > Compiling Java code

      So who all are using the Eclipse Java Compiler - besides developers using Eclipse for writing java code :) ? Apache Tomcat uses ECJ to compile JSPs, IntelliJ IDEA has support ECJ, as of GCJ 4.3, GCJ integrates with ECJ, Liferay Builds with ECJ, and there are many others.

      Sunday, May 9, 2010

      Why Open Source?

      Now that I work on Eclipse which is Open Source, I decided to give some serious thought to the question - why allow your software to be used for free?

      Before getting to software lets see if some other things have been allowed to be used for free in the past. The first example I can think of is Roads - governments construct roads and let people use them for free. The goal of the government is to make places - markets, malls, industries, schools etc - on the road to be more accessible. These places in turn generate money and the government earns its taxes from them which in turn are used to construct more roads.

      Now there are some 'Toll roads' as well where you pay for each usage of the road. People will pay for each usage of a road if firstly they have the money, and secondly they have no alternative free road to use.

      In both cases the roads do not serve any purpose other than make places accessible where the actual work gets done and people make money. True you can go for a nice relaxing drive but that is not the primary use of a road.

      In software world, an example of 'Toll Road' would be Microsoft Windows - people do not pay for Windows just to click around with a mouse; they probably need a word processor, a browser, a presentation maker etc to get some work done. Since historically there were not many choices in operating systems and Microsoft managed to market Windows well - people ended up paying for it.

      Now Eclipse began as an IBM project which was later made open source. The Eclipse foundation has a number of strategic members and I think all of them sell products built of top of Eclipse platform and make money. Eclipse being a free and open road means that the road is just awesome and a lot of people use it, making the final destinations (commercial products) that much more profitable.

      MySql also has a free version and an enterprise commercial version. Mozilla Foundation makes money from Search royalties and some donations. However if Netscape had defeated Microsoft in the browser wars over a decade ago then I do not think we would have been using Firefox for free. (Maybe all of us should thank Microsoft for this :p )

      I assume something similar happens in Apache, Linux worlds and other open source projects. If you are not able to make people pay for the road, you give it away for free, create a huge user base or community, invite contributions from this community and then reap benefits from making money at the malls, industries, schools down the road.

      Sunday, May 2, 2010

      3.6 M7 - New & Cool in JDT

      Till now Eclipse had a package name compression preference with which 'org.eclipse.ui.contentassist' could be compressed to 'o.e.u.contentassist'. From M7 onwards package names in Java views can be abbreviated with some custom rules as well.

      Rules for this example:

      These rules can be configured in Preferences > Java > Appearance > Abbreviate package names.

      I really like this feature. Thanks Guven Demir for contributing this(Bug 299514) !!

      Also, we have a new decorator (a big red '!') on Java projects and working sets that contain build path errors. We went through a number of options (Bug 215980)before settling on this one. Helps to spot those build path problems really easily!

      Saturday, April 24, 2010

      UI Patterns in Eclipse

      Slides for my talk at Eclipse Day India 2010

      Eclipse Day India 2010

      Yesterday I presented at the first Eclipse Day to be organized in India. It was a great event, credit goes to Ankur and Prakash for organizing it, and to all the presenters and attendees (some of them had come from other cities) for making it successful.

      The keynote was planned to be delivered by Daniel Megert, but the volcanic eruption in Iceland meant that he could not make it to Bangalore. However, Rajesh Thakkar, who stepped in at the last minute, delivered a nice keynote - Agility and Open Source. He is quite an inspirational speaker and I have heard him quite a few times inspiring people in the hallways of Rational Labs :). The keynote started off with a history of open source (not open source software), looks like open source has been around since at least 1857 when volunteers started work on the Oxford English Dictionary! I also liked his point on working at a 'sustainable pace', and not over committing. A lot of developers (me included) are guilty of saying 'no problem, it will be done' even when they no nothing about the problem at hand and then slogging days and nights trying to get it done.

      Among the other talks I liked
      - the OSGi tutorial by Prakash - modules in an application and rooms in a house analogy was nice!
      - P2 talk by Pradeep,
      - the one on RAP by Ankur ,
      - and lastly Chetan's talk on dependency injection. I thought Chetan explained the topic really well with simple examples.

      And oh yes, pizza and drinks with my team and Rajesh in the evening was fun. Guys we need to make this a tradition at every Eclipse event we organize!

      Friday, April 2, 2010

      Eclipse, NASA and the Mars rovers

      Dr Jeff Norris from NASA Jet Propulsion Laboratory gave an amazing keynote presentation at EclipseCon 2010. He showed how his team at NASA has been using Eclipse based clients to control Robots/Rovers. He also did some live demos - remotely controlled a giant ATHLETE rover, and controlled a robotic Socrates head. It was nice to see Eclipse being used for controlling those Mars rovers :).

      While I was really impressed by the live demos and the rovers I think the highlight of his talk was something else. The talk was built around the point that 'An individual alone cannot construct a skyscraper (a complex system), it takes a group of people specialized in different skills to do that'. This means that an individual's contribution, however small it may appear, is important to the group's success and we at Eclipse can take some credit (however small) for those Mars Rovers :).

      10 years ago I was writing essays as part of 'Red Rover goes to Mars' project, while my essays did not make the cut then, I now write software which is used for controlling those Mars Rovers! Pretty neat, I say :)

      Sunday, February 21, 2010

      Open windows explorer from command line

      $start . // opens the current directory
      $start C:\Downloads //opens the downloads directory

      instead of 'start' 'explorer' also works

      Wednesday, January 27, 2010

      Monday, January 25, 2010

      Scripted Data sets in BIRT

      Why/when do you need a Scripted data set in a BIRT report?
      Existing tables in your database will not provide data in the way you need them in a report. You might have to query more than one table to get all the data, or you may want to do some computation which requires going through one table data more than once.

      What scripting language can be used?
      Javascript is the primary language to be used in BIRT. BIRT also uses the Mozilla Rhino JavaScript engine which provides excellent integration with Java, hence you can use Java libraries as well but with a Javascript like syntax.

      How to do it?
      - Create a global variable: declare the variable in the initialize event of the report
      For example:
      globalVarMap = new java.util.HashMap();
      globalVarList = new java.util.ArrayList();

      - Populate this variable with required data: Typically you would read a simple dataset and dump all the data in this global map with the primary key (or maybe some other value) of the table being the key of the hashmap. The necessary code goes in 'onFetch' event (method) of the dataset, and a table column is referred to as 'row["CUSTOMER_ID"]'. The onFetch event is called once per each table record, hence you get access to table data one record at a time.
      For example:
      var list = globalVarMap.get(row["CUSTOMER_ID"]);;
      if(list == null) {
      list = new java.util.ArrayList();
      var data={};
      data.customer_name = row["CUSTOMER_NAME"];
      data.product_bought = row["PRODUCT_BOUGHT"];
      data.price = row["PRICE"];
      globalVarMap.put(row["CUSTOMER_ID"], list);

      Here the CUSTOMER_ID is not the primary key, and we are just sorting of various items bought by each customer.

      - Create a scripted data set: The final step is to create a scripted data set with the required columns and use global variables like the one above to populate this data set. Since you have the necessary data in a bunch of global variables, you can do pretty much what you want. The necessary code goes in 'fetch' event (method) of the dataset.
      if(customerCount < globalVarList.size()){
       var data = globalVarList.get(customerCount);
       row["CUSTOMER_ID"] = data.customer_id;
       row["CUSTOMER_NAME"] = data.customer_name;
       row["PRODUCT_ID"] =data.product_id;
       row["TOTAL_PURCHASE"] = data.total_purchase;
       row["QUARTER"] = data.quarter;
       row["COUNTRY"] =;
       return true;
      return false;

      Here, we have the necessary data in a global list variable and we just have to populate the scripted data set. In the fetch method we return true to indicate that there is more data coming, and false to indicate that we are done.

      Additional Info
      BIRT Java Reporting

      Wednesday, January 20, 2010

      Monitoring and Allocating Users Across Projects in Rational Team Concert

      Most views and reports in Rational Team Concert (RTC) are project centric. They give information about a particular project, its members and their utilization and various other facades. So far so good. But what if you wanted to maximize your resource (user) utilization across projects from within RTC. Who should the project manager pick up to assign to a new task?

      Few custom reports can be created to provide a resource centric view of RTC.

      Resource Assignment
      This report gives how various resources are assigned to various projects. Essentially this report gives the overall 'Load' (as defined in the User admin page of RTC) for all users across all projects.

      Resource Utilization
      This report gives you how the users are utilized across projects. It shows one value for a user by doing a weighted average, with the weights being the user assignment in percentage.

      Resource Utilization for a user for one project = Work Assigned (Hrs) in the project/ Total time (Hrs) available for the project

      Resource Utilization per User
      This will give a breakdown of resource utilization of a particular user.
      Task Card
      Users can use this Task card to see all their workitems across all projects.

      Discussion and Downloads
      The detailed discussion on these is captured in an RTC workitem on The report designs can also be downloaded from there.
      Create a report to see user utilization across all projects in the repository (100997)

      • These reports also deal with massive amounts of data and hence can be a bit slow.
      • They also span across multiple project areas which can have different timelines, hence the reports may or may not suit your needs. If the timelines are aligned, then these reports should work without problems.
      • These have been tested with RTC

      Thursday, January 14, 2010

      Asking questions the smart way

      The industry standard on this :

      While this is a fairly long piece the following steps should work in most cases
      -While asking your question provide enough information so that no one needs to come back to you for clarification or more information, as no one will.
      - And use general common sense ;-)

      Saturday, January 9, 2010

      Some Misc Eclipse Links

      Eclipse and Java for total beginners. These are some nice video tutorials.
      Eclipse Webinars and Podcasts