1. JAVA 8 New FeaturesPresenters:
●Nguyen Van Tan
●Nguyen Van Ngoc
●Nguyen Van Vu
●Tran Duc Toan
2. Members
1. Nguyễn Văn Tân
2. Tran Duc Toan
3. Nguyễn Văn Ngọc
4. Nguyễn Ngọc trần anh
5. Nguyễn Văn Vụ
6. Đỗ Xuân Đức
7. Phạm Trí Thái
8. Bùi Quý Dương
9. Trần Ngọc Thắng
3. Main Presents
1.Nashorn Javascript Engine
2.Remove The Permanent generation
3.Array ParallelSort
4.Lambda expressions
5.Small VM
6.Bulk Data Operations for Collections
7.Define a standard API for Base64 encoding and decoding
8.New Date & Time API
9.Provide stronger Password-Based-Encryption (PBE) algorithm
implementations in the SunJCE provider
4. 1.1 Nashorn Java Script Engine.
1.What’s Nashorn?
2.Why we need develop new Script Engine(Nashorn)?
3.How to use new Nashorn Engine?
4.Example.
5. 1.2 What’s Nashorn?
- Nashorn is a JavaScript engine developed in the Java programming
language by Oracle. It is based on the Da Vinci Machine (JSR 292) and will be
released with Java 8, which has been rescheduled for a 2014 release date
- Nashorn (the German word for rhinoceros) -> Rhino is an Javascript Engine
was build by Netscape in 1997.
- Nashorn execute base on InvokeDynamic byte code was introduce in java7.
6. 1.3 Why need new Javascript Engine?
- The Peformance of Rhino Script Engine was slow.
- Rhino java script engine was too old (build in 1997)
- Need a brigde between java and javascripts to help using
java and javascript more easy than.
7. 1.4 How to use Nashorn Engine?
-Import javax.script.* package.
- create New Nashorn Script Engine by use ScriptEngineManager Class.
- execute a javascript code by script engine
VD:
import javax.script.*;
public class EvalScript {
public static void main(String[] args) throws Exception {
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByName("nashorn");
// evaluate JavaScript code
engine.eval("print('Hello, World')");
}}
12. 2.3 What’s permanent used for ?
•- Originally there was no permanent generation. Objects
and classes were just stored together
•- Classes were mostly static, custom class loaders were
not widely used and so it was observed that not much class
unloading occurred
• - As a performance optimization the permanent generation
was created and classes were put into it
- The performance improvement was significant back
then
13. 2.4 Permanent generation stores what ?
•- Methods of a class (including the bytecodes)
•- Names of the classes
•- Object arrays and type arrays associated with a class (e.g., an object array
containing references to methods)
•- Internal objects created by the JVM (java/lang/Object or java/lang/exception
for instance)
•- Information used for optimization by the compilers (JITs)
14. 3.5 Why have to remove permanent generation ?
•Why?
•Demo
to be continued...
17. 3.1 About Array.Sort
Array.Sort is a API use MergeSort or TimSort
object or primitive arrays.
public static void sort(Object[] a) {
if (LegacyMergeSort.userRequested)
legacyMergeSort(a);
else ComparableTimSort.sort(a);
}
18. 3.2 Array.ParallelSort
Arrays#parallelSort uses Fork/Join framework (in Java 7)
to assign the sorting tasks to multiple threads available in
the thread pool.
The implementation in JDK 8 uses this approach:
- Divide the array into 4 parts.
- Sort the first two parts and then merge them.
- Sort the next two parts and then merge them.
19. 3.3 ParallelSort
And the above steps are repeated
recursively with each part until the size of
the part to sort is not lesser than the
threshold value calculated above.