background preloader

Java 8

Facebook Twitter

10 Things You Didn't Know About Java. So, you’ve been working with Java since the very beginning?

10 Things You Didn't Know About Java

Remember the days when it was called “Oak”, when OO was still a hot topic, when C++ folks thought that Java had no chance, when Applets were still a thing? I bet that you didn’t know at least half of the following things. Let’s start this week with some great surprises about the inner workings of Java. 1. There is no such thing as a checked exception That’s right! Today, everyone agrees that checked exceptions were a mistake. Do you want proof that the JVM doesn’t know such a thing? 01.public class Test { 04. public static void main(String[] args) { 05. doThrow(new SQLException()); 08. static void doThrow(Exception e) { 09. 12. 13. static <E extends Exception> 14. void doThrow0(Exception e) throws E { 15. throw (E) e; Not only does this compile, this also actually throws the SQLException, you don’t even need Lombok’s @SneakyThrows for that. More details about the above can be found in this article here, or here, on Stack Overflow. 2.

Collections Framework Enhancements in Java SE 8. Support for Lambda Expressions, Streams, and Aggregate Operations The Java Collections Framework has been updated to support lambda expressions, streams, and aggregate operations.

Collections Framework Enhancements in Java SE 8

For more information on these topics, see the following pages: Enhancements in Java SE 8New and Enhanced APIs That Take Advantage of Lambda Expressions and Streams in Java SE 8Lambda Expressions (The Java Tutorials) Aggregate Operations (The Java Tutorials) Collections (The Java Tutorials) Performance Improvement for HashMaps with Key Collisions As part of the work for JEP 180, there is a performance improvement for HashMap objects where there are lots of collisions in the keys. The alternative String hash function added in 7u6 has been removed from JDK 8, along with the jdk.map.althashing.threshold system property.

In rare situations, this change could introduce a change to the iteration order of HashMap and HashSet. The Dark Side of Java 8. The dark side of Java 8 So far, we’ve been showing the thrilling parts of this new major release.

The Dark Side of Java 8

But there are also caveats. Lots of them. Things that … are confusing… are "wrong"… are omitted (for now)… are omitted (for long) There are always two sides to Java major releases. Lambda expressions were introduced quite elegantly. Overloading gets even worse Overloading, generics, and varargs aren’t friends. Optional Will Remain an Option in Java. Optional: A new Option in Java So far, we’ve been pretty thrilled with all the additions to Java 8.

Optional Will Remain an Option in Java

All in all, this is a revolution more than anything before. But there are also one or two sore spots. One of them is how Java will never really get rid of Null: The billion dollar mistake. Java 8 Default Methods: What Can and Can Not Do? What default method is With the release of Java 8 you can modify interfaces adding new methods so that the interface remains compatible with the classes that implement the interface.

Java 8 Default Methods: What Can and Can Not Do?

This is very important in case you develop a library that is going to be used by several programmers from Kiev to New York. Until the dawn of Java 8 if you published an interface in a library you could not add a new method without risking that some application implementing in the interface will break with the new version of the interface. The Wait is Over: JDK 8 is Here! JDK 8: General Availability. Two years, seven months, and eigh­teen days after the re­lease of JDK 7, pro­duc­tion-ready builds of JDK 8 are now avail­able for down­load!

JDK 8: General Availability

Thanks! A major new re­lease of a soft­ware sys­tem as large as the JDK is the di­rect work of many hun­dreds of de­vel­op­ers, with in­di­rect con­tri­bu­tions from thou­sands more. By way of thanks I’d like to men­tion the major con­trib­u­tors here specif­i­cally: Brian Goetz picked up my ini­tial straw-man pro­posal to add lambda ex­pres­sions and de­fault meth­ods to Java, built it up into a bet­ter pro­posal, led Pro­ject Lambda in the Open­JDK Com­mu­nity, de­signed the re­lated streams API, and achieved con­sen­sus around all of this work in the JCP. Dan Smith and Mau­r­izio Cimadamore made major con­tri­bu­tions to the spec­i­fi­ca­tion and the im­ple­men­ta­tion.Stephen Cole­bourne‘s pop­u­lar Joda Time li­brary was the basis for his JSR 310 pro­posal to bring a new—and ac­tu­ally us­able—date and time API to Java.

Launch!