사용자 도구

사이트 도구


java:9

차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

양쪽 이전 판 이전 판
다음 판
이전 판
java:9 [2021/02/20 22:53]
kwon37xi [Properties UTF-8]
java:9 [2023/09/18 03:06] (현재)
kwon37xi [String Concat 개선]
줄 1: 줄 1:
 ====== Java 9 ====== ====== Java 9 ======
 +  * [[java:9:module|Java 9 Module]]
   * [[http://www.javacodegeeks.com/2015/06/5-features-in-java-9-that-will-change-how-you-develop-software-and-2-that-wont.html|5 Features in Java 9 that WILL Change How You Develop Software (and 2 That Won’t) | Java Code Geeks]]   * [[http://www.javacodegeeks.com/2015/06/5-features-in-java-9-that-will-change-how-you-develop-software-and-2-that-wont.html|5 Features in Java 9 that WILL Change How You Develop Software (and 2 That Won’t) | Java Code Geeks]]
   * [[https://www.sitepoint.com/ultimate-guide-to-java-9/|Ultimate Guide To Java 9]]   * [[https://www.sitepoint.com/ultimate-guide-to-java-9/|Ultimate Guide To Java 9]]
 +
 +===== Collection Factory Methods =====
 +  * ''Set.of'', ''List.of'', ''Map.of''
 +  * 완전한 immutable 컬렉션을 만들어준다.
 +  * ''null'' 값을 넣을 수 없게 방어해준다.
 +  * ''Set'',''Map'' 은 중복값을 넣는 경우에도 오류를 발생시켜 방어해준다.
 +  * 컬렉션 크기가 명확하게 정해지기 때문에 공간 최적화가 된다.
 +  * ''Collections.unmodifiableXxx''
 +    * 원본 컬렉션에 추가, 삭제 등이 일어나면 ''unmodifiable'' 컬렉션에 이 값이 반영된다. 즉, 완벽한 immutable 이 아니다.
 +    * null 값을 넣을 수 있다.
 +
 +===== G1 GC =====
 +  * [[java:g1gc|Java G1 GC]]가 기본 Garbage Collector 가 된다.
 +
 +===== Compact Strings =====
 +  * 원래 ''String''은 ''char []''로 표현되고 ''char''는 UTF-16 으로 2byte 를 차지했다. 
 +  * Java 9 에서는 ''byte[]'' 로 저장하여 1byte 단위로 공간을 차지하게 최적화 하였다.
 +  * ''Latin-1'' 문자로 이루어진 경우에는 ''coder'' 라는 ''String'' 의 내부 변수를 ''LATIN1''으로 설정하여 1 바이트 단위로 읽고
 +  * ''UTF-16''일 경우에는 ''coder'' 값을 ''UTF_16'' 으로 설정하고 2 바이트 단위로 읽는다. 
 +  * ''StringBuilder''와 ''StringBuffer''에도 최적화가 반영되어있다.
 +  * Memory 사용량이 줄고 줄고 그로인해 GC도 적어지고 성능이 좋아졌다.
 +
 +===== String Concat 개선 =====
 +  * Java 8 에서는 문자열 연속 연결시에 자동으로 ''StringBuilder''로 만들어주었었으나 이 경우 ''StringBuilder''의 기본 버퍼 크기를 사용하면서 버퍼 크기 부족시 성능저하가 있을 수 있음.
 +  * Java 9 는 문자열 연속 ''+'' 연산시 ''invokeDynamic''으로 ''StringBuilder''를 동적으로 최적화 해서 호출한다.
 +  * 따라서 연속적인 문자열 ''+'' 연결은 그냥 ''+''를 사용하는게 훨씬 빠르다. 물론 Java 9 이상을 target 으로 컴파일해야 한다.
 +
 +> "+ is no longer compiled to StringBuilder." In their "Lessons from Today" slide, they state, "Use + instead of StringBuilder where possible" and "recompile classes for Java 9+."
 +
 +  * [[http://marxsoftware.blogspot.com/2019/01/jep-280-indify-string-concatenations.html|Inspired by Actual Events: JDK 9/JEP 280: String Concatenations Will Never Be the Same]]
 +  * [[https://www.javaspecialists.eu/talks/pdfs/2018%20Voxxed%20in%20Thessaloniki,%20Greece%20-%20%22Enough%20java.lang.String%20to%20Hang%20Ourselves%20...%22%20by%20Heinz%20Kabutz.pdf|2018 Voxxed in Thessaloniki, Greece - "Enough java.lang.String to Hang Ourselves ..." by Heinz Kabutz]]
 +
 +  * [[https://dzone.com/articles/concatenating-strings-in-java-9|Concatenating Strings in Java 9 - DZone Java]]
  
 ===== 참고 ===== ===== 참고 =====
줄 60: 줄 94:
   * [[https://www.tutorialspoint.com/java9/java9_completablefuture_api_improvements.htm|CompletableFuture API Improvements - Tutorialspoint]]   * [[https://www.tutorialspoint.com/java9/java9_completablefuture_api_improvements.htm|CompletableFuture API Improvements - Tutorialspoint]]
  
-===== String Concat ===== 
-> Java 에서 문자열을 연결할 때는 StringBuilder 를 사용해야 한다 -> JDK 9 부터는 그냥 + 연산으로 연결하는게 제일 빠르다. 
-> "+ is no longer compiled to StringBuilder." In their "Lessons from Today" slide, they state, "Use + instead of StringBuilder where possible" and "recompile classes for Java 9+." 
- 
-  * [[http://marxsoftware.blogspot.com/2019/01/jep-280-indify-string-concatenations.html|Inspired by Actual Events: JDK 9/JEP 280: String Concatenations Will Never Be the Same]] 
-  * [[https://www.javaspecialists.eu/talks/pdfs/2018%20Voxxed%20in%20Thessaloniki,%20Greece%20-%20%22Enough%20java.lang.String%20to%20Hang%20Ourselves%20...%22%20by%20Heinz%20Kabutz.pdf|]] 
- 
-  * [[https://dzone.com/articles/concatenating-strings-in-java-9|Concatenating Strings in Java 9 - DZone Java]] 
  
 ===== Resourcebundle UTF-8 ===== ===== Resourcebundle UTF-8 =====
java/9.1613829221.txt.gz · 마지막으로 수정됨: 2021/02/20 22:53 저자 kwon37xi