Google Summer of Code at Eclipse

I would like to introduce myself. I’m Hendrik and currently I’m participating at the Google Summer of Code this year with a coding project at

The Google Summer of Code is a program by Google to motivate students (like me) to start working on Open Source projects. The whole program is organized by Google itself but the mentoring is done by volunteers of the Open Source projects. In my case I’m mentored by Lars Vogel and Markus Kuppe from the vogella GmbH and I also get support from John Arthone. After the project the students should have learned how to work at Open Source projects and be motivated to stay as committers or contributors in the Open Source community. With the successful completion of the project the participants are rewarded with a nice “pay check” from Google.

If you’re interested in the GSoC, you find more information at there site here and for Eclipse specific topics at the Eclipse Wiki .

But now to my project.

My accepted proposal with the title Implementing generics in JFace viewers is based on a feature-request/bug opened by Lars Vogel.

The reason for this bug is, that currently the JFace Framework does not support the Java generics feature, so the developers has to use typcastings to access there data in the viewers like in the following example:

col.setLabelProvider(new ColumnLabelProvider() {
public String getText(Object element) {
Person p = (Person) element;
return p.getLastName();

While this works the casting has a big disadvantage. It does not ensure that your program is type safe, because the casting and the usage of the Object class allows the JVM only to determine the type of element object at runtime.

For example the the element object could be from the class Invoice which is not type compatible to the Person class. The program will compile, but the program will crash at runtime with a log like this:

Exception in thread "main" java.lang.ClassCastException: Invoice cannot be cast to Person

Hopefully the Exception will be raised at the testing phase, not in a sales presentation with an CEO attending.

Sure you can avoid this exception with an instanceOf like in the following example, but there is a good reason why a lot of programmers find this a little bit smelly.

combo.setLabelProvider(new LabelProvider() {
public String getText(Object element) {
if(element instanceof String){
String index = (String) element;
return index;
return "";

In this case the instanceof is even worse, because it will hide the potential problems. The change of the return “”; line to return null, will also get an exception and just wrote some boilerplatecode. With my project I want to fix this problem.

My task for the next three and a half months will be the implementation of the Java generics language feature for the JFace viewers.
This should help to avoid castings like in the first example. So the goal is to allow JFace users following coding.

col.setLabelProvider(new ColumnLabelProvider<Person>() {
public String getText(Person element) {
return element.getLastName();

To get started with the project I’ve committed a small change which will allow the usage of Java 1.5 within the org.eclipse.jface bundle. The change is based on the Bug #395213 and is committed to Gerrit

The next step will be the implementation of the generics feature for some smaller viewers like the ComboViewer and test them and the backwards compatibility. I also plan to look and document other things along the way if time permits.

If you’re interested in my project you find more information on my Google Summmer of Code proposal site here or on the Eclipse Wiki

This entry was posted in Eclipse, Hendrik Still, Java, Other and tagged . Bookmark the permalink.