Musings on JDK development

  • Java
    January 10, 2012

Project Coin Fixes in 7u2

Last month, JDK 7u2 was released.
The release has a few correctness fixes for the Project Coin features, two diamond fixes courtesy Maurizio and one fix to strings in switch:

  • Diamond inference with nested classes had an improper interaction. For example, in code like

    class X {
    class Y {
    Y(T a, Z b) {...}
    public static void main(String... args) {
    X<String>.Y<String> x1 = new X<String>().new Y<String>("",""); //ok
    X<String>.Y<String> x2 = new X<String>().new Y<>("",""); // Failed!

    diamond was not allowed at the second constructor call, but such code is accepted as of 7u2. (7046778)

  • The compiler erroneously allowed constructs like

    Foo<String>[] fooArr = new Foo<>[]{...};

    Such code is now properly rejected.

  • If extra parenthesis were used around the case label of a string switch statement, as in

    switch (s) {
    case ("a"):

    javac would throw a NullPointerException when compiling the code.
    Previously, the workaround was to remove the unneeded "(" and ")", but javac has been corrected to accept this valid syntax.
    (We received multiple reports of this bug, so parenthesis around case labels is much more common style than I would have expected!)

If you're using the Project Coin language features, I recommend upgrading to 7u2 to get these fixes and to minimize source compatibility concerns going forward.

Join the discussion

Comments ( 2 )
  • F&#305;rat Monday, January 16, 2012


    i saw your jdk8 unsigned integer improvements from a tweet.

    Is there any plan for new unsigned types. UByte, UShort, etc.?

  • Joe Darcy Friday, January 20, 2012


    Please see my subsequent blog entry on unsigned support:


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.