The Artima Developer Community
Sponsored Link

Weblogs Forum
JavaOne 2010: Upcoming Java Features

47 replies on 4 pages. Most recent reply: Oct 30, 2010 11:19 AM by Morgan Conrad

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 47 replies on 4 pages [ « | 1 2 3 4 | » ]
V.H.Indukumar

Posts: 28
Nickname: vhi
Registered: Apr, 2005

Re: JavaOne 2010: Upcoming Java Features Posted: Oct 5, 2010 3:40 PM
Reply to this message Reply
Advertisement
>> hover over "someCall", see that it returns an ExtremelyLongToTypeFoo

Eclipse has something similar (not the same) but even better. You can select a method "someCalls()" and execute "Extract to a local variable" refactoring. You don't even need to type the variable name :-)

Morgan Conrad

Posts: 307
Nickname: miata71
Registered: Mar, 2006

Re: JavaOne 2010: Upcoming Java Features Posted: Oct 5, 2010 5:56 PM
Reply to this message Reply
> Eclipse has something similar (not the same) but even
> better. You can select a method "someCalls()" and execute
> "Extract to a local variable" refactoring. You don't even
> need to type the variable name :-)

Hmm, close. I still need to select the expression (not just hover), remember the magic three key combo alt-shift-L, (I'm on Windows, YMMV) then stare at (or blissfully ignore) a dialog and hit Return. So it's not perfect but it's something to remember. Thanks!

Ian Robertson

Posts: 68
Nickname: ianr
Registered: Apr, 2007

Re: JavaOne 2010: Upcoming Java Features Posted: Oct 5, 2010 8:25 PM
Reply to this message Reply
> > Eclipse has something similar (not the same) but even
> > better. You can select a method "someCalls()" and
> execute
> > "Extract to a local variable" refactoring. You don't
> even
> > need to type the variable name :-)
>
> Hmm, close. I still need to select the expression (not
> just hover), remember the magic three key combo
> alt-shift-L, (I'm on Windows, YMMV) then stare at (or
> blissfully ignore) a dialog and hit Return. So it's not
> perfect but it's something to remember. Thanks!

Instead of Alt-shift-L, try control-2 L. It skips the dialog step and just guesses a good variable name, leaving that name selected so that you can change it.

Gregor Zeitlinger

Posts: 108
Nickname: gregor
Registered: Aug, 2005

Re: JavaOne 2010: Upcoming Java Features Posted: Oct 5, 2010 9:15 PM
Reply to this message Reply
> Not to make a big deal of it, but, from a "purist" point
> of view, one could argue that the Java way is superior.
> Why? Because "they say" that you should code to the
> interface, not the implementation.
I think this applies to method signatures, not to local variables.

Mark Thornton

Posts: 275
Nickname: mthornton
Registered: Oct, 2005

Re: JavaOne 2010: Upcoming Java Features Posted: Oct 6, 2010 12:34 AM
Reply to this message Reply
> > Not to make a big deal of it, but, from a "purist"
> point
> > of view, one could argue that the Java way is superior.
> > Why? Because "they say" that you should code to the
> > interface, not the implementation.
> I think this applies to method signatures, not to local
> variables.

No, it applies to local variables too.

Vincent O'Sullivan

Posts: 724
Nickname: vincent
Registered: Nov, 2002

Re: JavaOne 2010: Upcoming Java Features Posted: Oct 6, 2010 2:18 AM
Reply to this message Reply
> Again I hope avoiding a new keyword wasn't another reason:
> there are certainly ways round that.

I'm willing to bet that no new keywords will be added to Java (ever).

V.H.Indukumar

Posts: 28
Nickname: vhi
Registered: Apr, 2005

Re: JavaOne 2010: Upcoming Java Features Posted: Oct 6, 2010 2:40 AM
Reply to this message Reply
>> I'm willing to bet that no new keywords will be added to Java (ever).

I will not bet :-) I read somewhere (sorry no references) that they were toying with the idea of introducing context sensitive keywords. I think it could even be argued that it is better to introduce a new keyword than to extend the semantic meaning of existing keywords.

Gregor Zeitlinger

Posts: 108
Nickname: gregor
Registered: Aug, 2005

Re: JavaOne 2010: Upcoming Java Features Posted: Oct 6, 2010 12:00 PM
Reply to this message Reply
> I'm willing to bet that no new keywords will be added to
> Java (ever).
given the problems that the addition of "assert" and "enum" keywords have caused for many people, this is probably true.
This just makes it more likely that Java will be the next COBOL.

Morgan Conrad

Posts: 307
Nickname: miata71
Registered: Mar, 2006

Re: JavaOne 2010: Upcoming Java Features Posted: Oct 6, 2010 12:39 PM
Reply to this message Reply
Nobody seems to have commented much on four of the new features. I also talked briefly with Jim Holmlund at java One.

>Strings in Switch Statements

A slight improvement over a chain of if/else if (which I think it uses under the covers) but nothing I'm getting too excited about.

>Underscores in constants

In his examples, I found this new feature most useful for hex constants, where I'm always counting very carefully to make sure there are 8 characters.

>Multi-catch

Encourages cleaner code instead of the lazy "catch-all"

catch (Exception e) { ... }

I did mention to him that it might be nice to have the ability to catch all exceptions except a certain type, e.g. something like:

catch (!IOException e) { ... }

>Autoclose interface

This looked really useful - saves a lot of potentially buggy boilerplate code.

Max Lybbert

Posts: 314
Nickname: mlybbert
Registered: Apr, 2005

Re: JavaOne 2010: Upcoming Java Features Posted: Oct 6, 2010 3:03 PM
Reply to this message Reply
> Nobody seems to have commented much on four of the new features. ...

Strings in switch statements are nice. Do we get the ability to use additional classes in switch statements? I think I know the answer, but I can't figure out the rationale.

Underscores in constants are good.

Multi-catch I'm not comfortable with, but I'm not going to have to use it.

Autoclose is nice. Especially when the alternative (use finally) turns out to be hard to do correctly ("The automatic resource management statement obviates the need for manual resource termination, which has proven ugly and error prone. Even good programmers get it wrong most of the time. ... In fact, 2/3 of the uses of the close method in the JDK itself are wrong!" http://mail.openjdk.java.net/pipermail/coin-dev/2009-February/000011.html ).

John Wellbelove

Posts: 72
Nickname: garibaldi
Registered: Mar, 2008

Re: JavaOne 2010: Upcoming Java Features Posted: Oct 7, 2010 1:13 AM
Reply to this message Reply
I have to say upfront that I have not coded a line of Java in my life, but I do like to keep myself informed about other languages to see what concepts they may offer that may enhance my use of C++. (C++ is powerful enough to be able to often emulate paradigms from other languages)

> Strings in switch statements.
Something I think all C++ coders would love natively.
There are some emulations, but usually not very pretty.

> Underscores in constants.
Not sure I really see the point.

> Multi-catch.
Could reduce code size a little, and reduce repeated code errors.

> Autoclose.
I was quite amused at that one. Java gets a form of deterministic destructor! I'm used to that being the default for C++. It's what stops C++ applications from gobbling up humongous amounts of resources.

Mark Thornton

Posts: 275
Nickname: mthornton
Registered: Oct, 2005

Re: JavaOne 2010: Upcoming Java Features Posted: Oct 7, 2010 1:38 AM
Reply to this message Reply
> Nobody seems to have commented much on four of the new
> features. I also talked briefly with Jim Holmlund at java
> One.
>
> >Strings in Switch Statements
>
> A slight improvement over a chain of if/else if (which I
> think it uses under the covers) but nothing I'm getting
> too excited about.

I think the implementation was going to use a switch on the hashCode followed by a (very) short if chain in each case.

Mark Thornton

Posts: 275
Nickname: mthornton
Registered: Oct, 2005

Re: JavaOne 2010: Upcoming Java Features Posted: Oct 7, 2010 1:44 AM
Reply to this message Reply
> > Underscores in constants.
> Not sure I really see the point.
CxRoadConnection a = new CxRoadConnection(4000000026575345,0.536909818649292f, SiteAccessSet.ALL_ACCESS);

or
CxRoadConnection a = new CxRoadConnection(4000_0000_2657_5345L,0.5369_0981_8649_292f, SiteAccessSet.ALL_ACCESS);


It is hard to see whether the first case has the correct number of zeros.

Achilleas Margaritis

Posts: 674
Nickname: achilleas
Registered: Feb, 2005

Re: JavaOne 2010: Upcoming Java Features Posted: Oct 7, 2010 2:30 AM
Reply to this message Reply
> > > Underscores in constants.
> > Not sure I really see the point.
>
CxRoadConnection a = new
> CxRoadConnection(4000000026575345,0.536909818649292f,
> SiteAccessSet.ALL_ACCESS);

> or
>
CxRoadConnection a = new
> CxRoadConnection(4000_0000_2657_5345L,0.5369_0981_8649_292f
> , SiteAccessSet.ALL_ACCESS);

>
> It is hard to see whether the first case has the correct
> number of zeros.

can you just write

4 000 000 026 575 345L

and then delete the spaces? that's what I do.

Roland Pibinger

Posts: 93
Nickname: rp123
Registered: Jan, 2006

Autoclose interface Posted: Oct 7, 2010 10:09 AM
Reply to this message Reply
> If you implement the autoclose
> interface, you can put input and output streams in a single try block
> and, when the block ends, all of the streams are closed.

What does that mean exactly? Destructors and RAII in Java, finally? Too good to be true.

Flat View: This topic has 47 replies on 4 pages [ « | 1  2  3  4 | » ]
Topic: Practical Scala/Java interoperability by small examples Previous Topic   Next Topic Topic: Why To Go Into Bioinformatics

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use