JAVA 8 New FeaturesPresenters:
●Nguyen Van Tan
●Nguyen Van Ngoc
●Nguyen Van Vu
●Tran Duc Toan
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. P...
Main Presents
1.Nashorn Javascript Engine
2.Remove The Permanent generation
3.Array ParallelSort
4.Lambda expressions
5.Sm...
1.1 Nashorn Java Script Engine.
1.What’s Nashorn?
2.Why we need develop new Script Engine(Nashorn)?
3.How to use new Nasho...
1.2 What’s Nashorn?
- Nashorn is a JavaScript engine developed in the Java programming
language by Oracle. It is based on ...
1.3 Why need new Javascript Engine?
- The Peformance of Rhino Script Engine was slow.
- Rhino java script engine was too o...
1.4 How to use Nashorn Engine?
-Import javax.script.* package.
- create New Nashorn Script Engine by use ScriptEngineManag...
1.5 Example Nashorn.
Reference: http://download.java.
net/jdk8/docs/technotes/guides/scripting/prog_guide/javascript.html
2. Remove permanent
generation
“java.lang.OutOfMemoryError: PermGen space”
2.1 Java memory model
2.2 Heap vs Stack
2.3 What’s permanent used for ?
•- Originally there was no permanent generation. Objects
and classes were just stored toge...
2.4 Permanent generation stores what ?
•- Methods of a class (including the bytecodes)
•- Names of the classes
•- Object a...
3.5 Why have to remove permanent generation ?
•Why?
•Demo
to be continued...
3.6 References
•https://blogs.oracle.com/jonthecollector/entry/presenting_the_permanent_generation
•http://www.infoq.com/n...
3. Array.ParallelSort in JAVA 8
- Reintroduce Array.Sort
- Introduce Array.ParallelSort
- Demo
- Reference doc
3.1 About Array.Sort
Array.Sort is a API use MergeSort or TimSort
object or primitive arrays.
public static void sort(Obje...
3.2 Array.ParallelSort
Arrays#parallelSort uses Fork/Join framework (in Java 7)
to assign the sorting tasks to multiple th...
3.3 ParallelSort
And the above steps are repeated
recursively with each part until the size of
the part to sort is not les...
3.4 Compare result Demo
------------------------------------------------------------------
| Seq | Array size | Sort time ...
3.5 Reference.
● http://blog.sanaulla.info/2013/04/08/arrays-sort-versus-arrays-parallelsort/
Upcoming SlideShare
Loading in …5
×

Java 8 new features

826 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
826
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
15
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Java 8 new features

  1. 1. JAVA 8 New FeaturesPresenters: ●Nguyen Van Tan ●Nguyen Van Ngoc ●Nguyen Van Vu ●Tran Duc Toan
  2. 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. 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. 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. 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. 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. 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')"); }}
  8. 8. 1.5 Example Nashorn. Reference: http://download.java. net/jdk8/docs/technotes/guides/scripting/prog_guide/javascript.html
  9. 9. 2. Remove permanent generation “java.lang.OutOfMemoryError: PermGen space”
  10. 10. 2.1 Java memory model
  11. 11. 2.2 Heap vs Stack
  12. 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. 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. 14. 3.5 Why have to remove permanent generation ? •Why? •Demo to be continued...
  15. 15. 3.6 References •https://blogs.oracle.com/jonthecollector/entry/presenting_the_permanent_generation •http://www.infoq.com/news/2013/03/java-8-permgen-metaspace
  16. 16. 3. Array.ParallelSort in JAVA 8 - Reintroduce Array.Sort - Introduce Array.ParallelSort - Demo - Reference doc
  17. 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. 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. 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.
  20. 20. 3.4 Compare result Demo ------------------------------------------------------------------ | Seq | Array size | Sort time | VS | PSort time | ------------------------------------------------------------------ | 1 | 602 | 0.002 | < | 0.008 | ------------------------------------------------------------------ | 2 | 1400 | 0.006 | > | 0.004 | ------------------------------------------------------------------ | 3 | 2492 | 0.008 | > | 0.006 | ------------------------------------------------------------------ | 4 | 4984 | 0.012 | > | 0.008 |
  21. 21. 3.5 Reference. ● http://blog.sanaulla.info/2013/04/08/arrays-sort-versus-arrays-parallelsort/

×