Proposed refactoring: introduce JLS7 language features to core libs

Stuart Marks stuart.marks at
Wed May 2 21:57:29 UTC 2012

On 5/1/12 11:23 AM, Stefan Reich wrote:
> Hi Stuart,
> thank you for your reply. I sent a patch to the adopt-openjdk group that uses multi-catch for catch clauses with duplicate code blocks in the same try statement (message and patch attached). That patch covers all code in src/shared/classes. Martijn will help coordinating the effort with all individual component owners, since I don't know anyone over at the OpenJDK team.

OK great, glad to hear you're coordinating this with Martijn and the Adopt 
OpenJDK gang.

> The string switch conversion is relatively straight forward, too. The more complicated case that you mention:
> String s;
> if("literal1".equals(s)) {
> } else if("literal2".equals(s)) {
> } else {
> // s is null or some other value
> }
> is very rare in the OpenJDK code base. I saw only a handful of occurrences out of 95 files affected by this refactoring (in src/share/classes). If there is interest, I'd review the changes and create a patch, but I wanted to see how things are going with my first submission before investing more time.

I'm surprised there are that many occurrences in the JDK. It's good to know 
that the null issue comes up only rarely. In any case, it might make sense to 
see how the multi-catch changes go before inundating the group with too many 

> How far are you with type inference? Are you going to write a NetBeans plugin?

By "type inference" I assume you mean "type inference for generic instance 
creation" -- which we usually refer to as diamond -- and not type inference in 

There is already a NetBeans facility to do this kind of refactoring. It wasn't 
available when I was doing coinification work in 2010 and 2011. It was 
introduced in NetBeans 7.1 I believe. It's available under the Refactoring > 
Inspect and Transform dialog. Look for "Can Use Diamond" in the "JDK 1.5 and 
Later" category.

I'm not actively working on coinification, so if you (or somebody else in Adopt 
OpenJDK) wants to pursue diamond conversion, by all means go ahead.


More information about the core-libs-dev mailing list