1 . Lambda expressions
Lambda expressions are a new and important feature included in Java SE 8. They provide a clear and simple way to represent one method interface using an expression. Lambda expressions also enhance the Collection libraries making it easier to iterate, filter, and extract data from a Collection.
public static void main(String[] args) { System.out.println("=== RunnableTest ==="); // Anonymous Runnable Runnable r1 = new Runnable(){ @Override public void run(){ System.out.println("Hello world one!"); } }; // Lambda Runnable Runnable r2 = () -> System.out.println("Hello world two!"); // Run r1.run(); r2.run();}
2. Removal of Permanent Generation/Method Area
In Java The permanent generation (or permgen) is used for class definitions and associated metadata. Permanent generation is not part of the heap.
The JDK 8 HotSpot JVM is now using native memory for the representation of class metadata called Metaspace; if you have been using Oracle JRockit you will find some of these concepts borrowed from Oracle JVM implementation.
One of the immediate advantages of the Meta Space is that you will forget about the java.lang.OutOfMemoryError: PermGen space problems which is a frequent issue if you try to deploy several times an application on a Container and the Container is unable to free up the space used by previous deployments. Keep in mind however that this new feature won't eliminate out of the box class and classloader memory leaks. You will need however to monitor these problems using a different approach and using different tools.
When running JDK 1.8, allocations for the class metadata will be done out of native memory and the objects used to describe class metadata have been removed.
3. Default Method” or (Defender methods)
Java 8 introduces “Default Method” or (Defender methods) new feature, which allows developer to add new methods to the interfaces without breaking the existing implementation of these interface. It provides flexibility to allow interface define implementation which will use as default in the situation where a concrete class fails to provide an implementation for that method.
public interface A {
default void foo(){
System.out.println("Calling A.foo()");
}
}
public class ClassAB implements A {
}
There is one common question that people ask about default methods when they hear about the new feature for the first time:
What if the class implements two interfaces and both those interfaces define a default method with the same signature?
Example to illustrate this situation:
public interface A {
default void foo(){
System.out.println("Calling A.foo()");
}
}
public interface B {
default void foo(){
System.out.println("Calling B.foo()");
}
}
public class ClassAB implements A, B {
}
This code fails to compile with the following result:
java: class Clazz inherits unrelated defaults for foo() from types A and B
To fix that, in Clazz, we have to resolve it manually by overriding the conflicting method:
public class Clazz implements A, B {
public void foo(){}
}
But what if we would like to call the default implementation of method foo() from interface A instead of implementing our own.
It is possible to refer to A#foo() as follows:
public class Clazz implements A, B {
public void foo(){
A.super.foo();
}
}
4 .Enhancement in Security
a) 64-bit PKCS11 for Windows
b) Stronger algorithms for password-based encryption
c) Client-side TLS 1.2 enabled by default
5. Enhancement in JavaFX
JavaFX is used to design fancy GUI similar to swing
6. New Tools
a) The
java command launches JavaFX applications.
b) The
jdeps command-line tool is provided for analyzing class files.- Unicode Enhancements, including support for Unicode 6.2.0
- Adoption of Unicode CLDR Data and the java.locale.providers System Property
- New Calendar and Locale APIs
- Ability to Install a Custom Resource Bundle as an Extension
8. Date-Time Package - a new set of packages that provide a comprehensive date-time model.
Support of nano seconds in Date API
9. JDBC(Type -1 Driver is removed )
- The JDBC-ODBC Bridge has been removed.
- JDBC 4.2 introduces new features.
10. Enhancement inside Concurrency package(java.util.concurrent package)
No comments:
Post a Comment