SlideShare a Scribd company logo
Java
rudalson@gmail.com
Table Of Contents
1. Coding convention
2. JAVA 7
a. Project Coin
b. NIO
3. JAVA 8
4. Language type
5. JVM
Coding Convention
• Indentation
• Tab VS Space ?
• 2 VS 4 VS 8 ?
• Brace location
• Next VS Current ?
• 변수 명
• Eclipse formatter 부터
Java 7
• Project Coin
• JDK 7 In Action - Learn With Java Tutorials and Developer Guides
• Using New Core Platform Features In Real Code
The Six Coin Features and How They help
Consistency and clarity
– 1. Improved literals
– 2. Strings in switch
Easier to use generics
– 3. SafeVarargs (removing varargs warnings)
– 4. Diamond
More concise error handling
– 5. Multi-catch and precise rethrow
– 6. Try-with-resources
Integral Binary Literals
// An 8-bit 'byte' value:
byte aByte = (byte)0b00100001;
// A 16-bit 'short' value:
short aShort = (short)0b1010000101000101;
// Some 32-bit 'int' values:
int anInt1 = 0b10100001010001011010000101000101;
int anInt3 = 0B101; // The B can be upper or lower case.
// A 64-bit 'long' value. Note the "L" suffix:
long aLong =
0b1010000101000101101000010100010110100001010001011010000101000101L;
Underscores in Literals
long creditCardNumber = 1234_5678_9012_3456L;
long socialSecurityNumber = 999_99_9999L;
long hexWords = 0xCAFE_BABE;
long maxLong = 0x7fff_ffff_ffff_ffffL;
byte nybbles = 0b0010_0101;
long bytes = 0b11010010_01101001_10010100_10010010;
Strings in switch Statements
public String getTypeOfDayWithSwitchStatement(String dayOfWeekArg) {
String typeOfDay;
switch (dayOfWeekArg) {
case "Monday":
typeOfDay = "Start of work week";
break;
case "Tuesday":
case "Wednesday":
case "Thursday":
typeOfDay = "Midweek";
break;
case "Friday":
typeOfDay = "End of work week";
break;
case "Saturday":
case "Sunday":
typeOfDay = "Weekend";
break;
default:
throw new IllegalArgumentException("Invalid day of the week: " + dayOfWeekArg);
}
return typeOfDay;
}
Strings in switch Statements
What is there to discuss?
• What does switching on a null do? (NullPointerException)
• Can null be a case label? (No.)
• Case-insensitive comparisons? (No.)
• Implementation
• relies on a particular algorithm be used for String.hashCode
• on average faster than if-else chain with >3 cases
Safe Varargs
아 몰랑 ~
Diamond <>
Set<List<String>> setOfLists = new HashSet<List<String>>();
Set<List<String>> setOfLists = new HashSet<>();
Diamond Use
Assignment Statement
List<Map<String,Integer>> listOfMaps;
…
listOfMaps = new ArrayList<>();
Return Statement
public Set<Map<BigInteger,BigInteger>> compute() {
…
return new Set<>();
}
Multi-Catch and Precise Rethrow
Multi-catch:
ability to catch multiple exception types in a single catch clause
try {
...
} catch (FirstException | SecondException) { ... }
Precise rethrow:
change in can-throw analysis of a catch clause
private List<String> readFile(String fileName) {
List<String> lines = new ArrayList<String>();
BufferedReader reader = null;
try {
reader = new BufferedReader(new FileReader(fileName));
String line;
while ((line = reader.readLine()) != null) {
lines.add(line);
}
} catch (FileNotFoundException ex) {
ex.printStackTrace();
} catch (IOException ex) {
ex.printStackTrace();
} finally {
try {
if (reader != null) {
reader.close();
}
} catch (IOException e) {
// 이건..... 쫌...
}
}
return lines;
}
The try-with-resources Statement
The try-with-resources Statement
static String readFirstLineFromFile(String path) throws IOException {
try (BufferedReader br = new BufferedReader(new FileReader(path))) {
return br.readLine();
}
}
Prior to Java SE 7
static String readFirstLineFromFileWithFinallyBlock(String path) throws IOException {
BufferedReader br = new BufferedReader(new FileReader(path));
try {
return br.readLine();
} finally {
if (br != null) br.close();
}
}
NIO.2 File System API
Background and Motivation
The platform was long overdue something better than java.io.File
• Doesn’t work consistently across platforms
• Lack of useful exceptions when a file operation fails
• Missing basic operations, no file copy, move, ...
• Limited support for symbolic links
• Very limited support for file attributes
• No bulk access to file attributes
• Badly missing features that many applications require
• No way to plug-in other file system implementations
New File System API
• Path – used to locate a file in a file system
• Files – defines static methods to operate on files, directories and other types
of files
• FileSystem
• Provides a handle to a file system
• Factory for objects that access the file system
• FileSystems.getDefault returs a reference to the default FileSystem
• FileStore – the underlying storage/volume
public class Test {
public static void main(String[] args) {
FileSystem fileSystem = FileSystems.getDefault();
FileSystemProvider provider = fileSystem.provider();
System.out.println("Provider: " + provider.toString());
System.out.println("Open: " + fileSystem.isOpen());
System.out.println("Read Only: " + fileSystem.isReadOnly());
Iterable<Path> rootDirectories = fileSystem.getRootDirectories();
System.out.println();
System.out.println("Root Directories");
for (Path path : rootDirectories) {
System.out.println(path);
}
Iterable<FileStore> fileStores = fileSystem.getFileStores();
System.out.println();
System.out.println("File Stores");
for (FileStore fileStore : fileStores) {
System.out.println(fileStore.name());
}
}
}
Provider: sun.nio.fs.WindowsFileSystemProvider@1db9742
Open: true
Read Only: false
Root Directories
C:
D:
E:
F:
G:
H:
I:
File Stores
ssd1
ssd2
data
ssd3
Samsung1TB
public class FileSystemExampleV {
public static void main(String[] args) throws Exception {
FileSystem fileSystem = FileSystems.getDefault();
for (FileStore store : fileSystem.getFileStores()) {
System.out.println("드라이버명: " + store.name());
System.out.println("파일시스템: " + store.type());
System.out.println("전체 공간: " + store.getTotalSpace() + " 바이트");
System.out.println("사용 중인 공간: " + (store.getTotalSpace() - store.getUnallocatedSpace()) + " 바이트");
System.out.println("사용 가능한 공간: " + (store.getTotalSpace() - store.getUsableSpace()) + " 바이트");
System.out.println();
}
System.out.println("파일 구분자: " + fileSystem.getSeparator());
System.out.println();
for (Path path : fileSystem.getRootDirectories()) {
System.out.println(path.toString());
}
}
}
드라이버명:
파일시스템: NTFS
전체 공간: 127666221056 바이트
사용 중인 공간: 114883612672 바이트
사용 가능한 공간: 114883612672 바이트
드라이버명: ssd1
파일시스템: NTFS
전체 공간: 256058060800 바이트
사용 중인 공간: 193507590144 바이트
사용 가능한 공간: 193507590144 바이트
드라이버명: ssd2
파일시스템: NTFS
전체 공간: 256058060800 바이트
사용 중인 공간: 114384744448 바이트
사용 가능한 공간: 114384744448 바이트
드라이버명: data
파일시스템: NTFS
전체 공간: 2000396742656 바이트
사용 중인 공간: 953533616128 바이트
사용 가능한 공간: 953533616128 바이트
드라이버명: ssd3
파일시스템: NTFS
전체 공간: 500104687616 바이트
사용 중인 공간: 239441858560 바이트
사용 가능한 공간: 239441858560 바이트
드라이버명: Samsung1TB
파일시스템: NTFS
전체 공간: 1000194011136 바이트
사용 중인 공간: 841152049152 바이트
사용 가능한 공간: 841152049152 바이트
파일 구분자: 
C:
D:
E:
F:
G:
H:
I:
Java 8
• What’s New in JDK 8
• Lambda
• Default Methods
• Optional
• Type Annotation
• Nashorn
• Concurrency
• Stamped Lock
• Concurrent Addr
• Parallel Sorting
• 그리고 그 외?
• New Date API
• OS Process Control
JVM Language
• Java
• Scala
• Play, Akka
• Clojure
• Groovy
• Grails, Gradle
• JRuby
• Jython
• Kotlin
• Jetbrain
CLR
• C#
• Visual Basic
• F#
• Iron Python
• Iron Ruby
• Power Shell
• Java
• J#
그 외
• C/C++
• Java Script
• Go
• Haskell
• OCaml
• Erlang
• Swift
• Dart
• Type Script
앞으로...
• 함수 패러다임
• 메타 프로그래밍
• Concurrent 프로그래밍
Description of Java Conceptual Diagram
JVM
• 스택 기반의 가상 머신 (NOT Register 기반)
• Dalvik VM은???
• 심볼릭 레퍼런스(NOT Address 기반)
• 가비지 컬렉션
• 기본 자료형을 명확하게 정의해 플랫폼 독립성 보장
• 네트워크 바이트 순서
• Little endian vs Big endian
JVM 구조
Java Byte Code
public void add(java.lang.String);
Code:
0: aload_0
1: getfield #15; // Field admin:Lcom.mantech.mccs/user/UserAdmin;
4: aload_1
5: invokevirtual #23; // Method com/mantech/mccs/user/UserAdmin.addUser:(Ljava/lang/String;)Lcom/mantech.mccs/user/User;
8: pop
9: return
aload_0 = 0x2a
getfield = 0xb4
aload_1 = 0x2b
invokevirtual = 0xb6
2a b4 00 0f 2b b6 00 17 57 b1
Runtime Data Areas
Execution Engine
• Interpreter
• JIT(Just In Time)
• Oracle hotspot VM
• From JDK 1.3 ~
• Dalvik VM from Android 2.2 ~
• IBM AOT(Ahead-Of-Time)
• From JDK6
Garbage Collection
• “stop-the-world”
• Young Generation
• Eden
• Survivor(2개)
• Old Generation (JDK 7)
• Serial GC
• Parallel GC
• Parallel Old GC(Parallel Compacting GC)
• Concurrent Mark & Sweep GC
• G1(Garbage First) GC
And more...
BTrace
Multithread
Concurrent VS Paralle
Java Thread
• 스레드 상태
• NEW
• RUNNABLE
• BLOCKED
• WAITING
• TIMED_WAITING
• TERMINATED
Race condition
Monitor
• Muitual exclusion
• acquire
• release
• Synchronized
synchronized instance
synchronized void method() {
…
}
void method() {
synchronized (this) {
…
}
}
synchronized class
class Something {
static synchronized void method() {
…
}
}
class Something {
static void method() {
synchronized (Something.class) {
…
}
}
}
Synchronized?
public synchronized void setName(String name) {
this.name = name;
}
public synchronized void setAddress(String address) {
this.address = address;
}
쓰레드 협조
• wait
• notify/notifyAll
volatile?
“visibility를 확보기 위해 barrier reordering 을 한다.”
Reorder
class Something {
private int x = 0;
private int y = 0;
public void write() {
x = 100;
y = 50;
}
public void read() {
if (x < y) {
System.out.println("x < y");
}
}
}
public class Reorder {
public static void main(String[] args) {
final Something obj = new Something();
new Thread() { // Thread A
public void run() {
obj.write();
}
}.start();
new Thread() { // Thread B
public void run() {
obj.read();
}
}.start();
}
}
x < y가 출력될 수 있을까?
Visibility
volatile
java의 volatile은 2가지 기능
1. 변수의 동기화
2. long, double 을 atomic 단위 취급

More Related Content

What's hot

Grails/Groovyによる開発事例紹介
Grails/Groovyによる開発事例紹介Grails/Groovyによる開発事例紹介
Grails/Groovyによる開発事例紹介
Kiyotaka Oku
 
NIO and NIO2
NIO and NIO2NIO and NIO2
Hack ASP.NET website
Hack ASP.NET websiteHack ASP.NET website
Hack ASP.NET website
Positive Hack Days
 
Distributed systems at ok.ru #rigadevday
Distributed systems at ok.ru #rigadevdayDistributed systems at ok.ru #rigadevday
Distributed systems at ok.ru #rigadevday
odnoklassniki.ru
 
JAVA NIO
JAVA NIOJAVA NIO
JAVA NIO
오석 한
 
Java Programming - 08 java threading
Java Programming - 08 java threadingJava Programming - 08 java threading
Java Programming - 08 java threading
Danairat Thanabodithammachari
 
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
julien.ponge
 
Java 7 LavaJUG
Java 7 LavaJUGJava 7 LavaJUG
Java 7 LavaJUG
julien.ponge
 
Слава Бобик «NancyFx для самых маленьких»
Слава Бобик «NancyFx для самых маленьких»Слава Бобик «NancyFx для самых маленьких»
Слава Бобик «NancyFx для самых маленьких»
SpbDotNet Community
 
201913046 wahyu septiansyah network programing
201913046 wahyu septiansyah network programing201913046 wahyu septiansyah network programing
201913046 wahyu septiansyah network programing
wahyuseptiansyah
 
sizeof(Object): how much memory objects take on JVMs and when this may matter
sizeof(Object): how much memory objects take on JVMs and when this may mattersizeof(Object): how much memory objects take on JVMs and when this may matter
sizeof(Object): how much memory objects take on JVMs and when this may matter
Dawid Weiss
 
Testing with Node.js
Testing with Node.jsTesting with Node.js
Testing with Node.js
Jonathan Waller
 
Code red SUM
Code red SUMCode red SUM
Code red SUM
Shumail Haider
 
Server1
Server1Server1
Server1
FahriIrawan3
 
Jakarta Commons - Don't re-invent the wheel
Jakarta Commons - Don't re-invent the wheelJakarta Commons - Don't re-invent the wheel
Jakarta Commons - Don't re-invent the wheel
tcurdt
 
No dark magic - Byte code engineering in the real world
No dark magic - Byte code engineering in the real worldNo dark magic - Byte code engineering in the real world
No dark magic - Byte code engineering in the real world
tcurdt
 
Back to the future with Java 7 (Geekout June/2011)
Back to the future with Java 7 (Geekout June/2011)Back to the future with Java 7 (Geekout June/2011)
Back to the future with Java 7 (Geekout June/2011)
Martijn Verburg
 
Clojure Intro
Clojure IntroClojure Intro
Clojure Intro
thnetos
 
ROracle
ROracle ROracle
ROracle
Mohamed Magdy
 

What's hot (19)

Grails/Groovyによる開発事例紹介
Grails/Groovyによる開発事例紹介Grails/Groovyによる開発事例紹介
Grails/Groovyによる開発事例紹介
 
NIO and NIO2
NIO and NIO2NIO and NIO2
NIO and NIO2
 
Hack ASP.NET website
Hack ASP.NET websiteHack ASP.NET website
Hack ASP.NET website
 
Distributed systems at ok.ru #rigadevday
Distributed systems at ok.ru #rigadevdayDistributed systems at ok.ru #rigadevday
Distributed systems at ok.ru #rigadevday
 
JAVA NIO
JAVA NIOJAVA NIO
JAVA NIO
 
Java Programming - 08 java threading
Java Programming - 08 java threadingJava Programming - 08 java threading
Java Programming - 08 java threading
 
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
 
Java 7 LavaJUG
Java 7 LavaJUGJava 7 LavaJUG
Java 7 LavaJUG
 
Слава Бобик «NancyFx для самых маленьких»
Слава Бобик «NancyFx для самых маленьких»Слава Бобик «NancyFx для самых маленьких»
Слава Бобик «NancyFx для самых маленьких»
 
201913046 wahyu septiansyah network programing
201913046 wahyu septiansyah network programing201913046 wahyu septiansyah network programing
201913046 wahyu septiansyah network programing
 
sizeof(Object): how much memory objects take on JVMs and when this may matter
sizeof(Object): how much memory objects take on JVMs and when this may mattersizeof(Object): how much memory objects take on JVMs and when this may matter
sizeof(Object): how much memory objects take on JVMs and when this may matter
 
Testing with Node.js
Testing with Node.jsTesting with Node.js
Testing with Node.js
 
Code red SUM
Code red SUMCode red SUM
Code red SUM
 
Server1
Server1Server1
Server1
 
Jakarta Commons - Don't re-invent the wheel
Jakarta Commons - Don't re-invent the wheelJakarta Commons - Don't re-invent the wheel
Jakarta Commons - Don't re-invent the wheel
 
No dark magic - Byte code engineering in the real world
No dark magic - Byte code engineering in the real worldNo dark magic - Byte code engineering in the real world
No dark magic - Byte code engineering in the real world
 
Back to the future with Java 7 (Geekout June/2011)
Back to the future with Java 7 (Geekout June/2011)Back to the future with Java 7 (Geekout June/2011)
Back to the future with Java 7 (Geekout June/2011)
 
Clojure Intro
Clojure IntroClojure Intro
Clojure Intro
 
ROracle
ROracle ROracle
ROracle
 

Viewers also liked

Photoshop progress
Photoshop progressPhotoshop progress
Photoshop progress
Devon Walker
 
Iatrogenic opioid dependence_in_the_united_states_.18
Iatrogenic opioid dependence_in_the_united_states_.18Iatrogenic opioid dependence_in_the_united_states_.18
Iatrogenic opioid dependence_in_the_united_states_.18
Paul Coelho, MD
 
Yealink cp860 quick_start_guide_v80_10
Yealink cp860 quick_start_guide_v80_10Yealink cp860 quick_start_guide_v80_10
Yealink cp860 quick_start_guide_v80_10
Miluska Guerra Guerra
 
Comparación entre el mapa curricular del nuevo modelo educativo 2016 y el map...
Comparación entre el mapa curricular del nuevo modelo educativo 2016 y el map...Comparación entre el mapa curricular del nuevo modelo educativo 2016 y el map...
Comparación entre el mapa curricular del nuevo modelo educativo 2016 y el map...
Dolores Navarro Vieyra
 
Qualitative data analysis
Qualitative data analysisQualitative data analysis
Qualitative data analysis
Ramakanta Mohalik
 
Managerial accounting-v1.1
Managerial accounting-v1.1Managerial accounting-v1.1
Managerial accounting-v1.1
Bantwal Srinivas Pradeep
 
үйлдвэрийн нэмэгдэл зардлын бүртгэл
үйлдвэрийн нэмэгдэл зардлын бүртгэлүйлдвэрийн нэмэгдэл зардлын бүртгэл
үйлдвэрийн нэмэгдэл зардлын бүртгэл
Enebish Vandandulam
 
Sembrando ya! Marzo 2017
Sembrando ya! Marzo 2017Sembrando ya! Marzo 2017
Sembrando ya! Marzo 2017
ALCIDES TORRES PAREDES
 
La historia: inicio de nuestro viaje por el tiempo.
La historia: inicio de nuestro viaje por el tiempo.La historia: inicio de nuestro viaje por el tiempo.
La historia: inicio de nuestro viaje por el tiempo.
Gustavo Bolaños
 
Ejercicios pert cpm
Ejercicios pert cpmEjercicios pert cpm
Ejercicios pert cpm
Jorge Alonzo
 
20% i corte
20% i corte20% i corte
Processor
ProcessorProcessor
Processor
박 경민
 
Temas politico militares
Temas politico militaresTemas politico militares
Temas politico militares
Jeferson Colina Vivenes
 
Herramientas básicas de word
Herramientas básicas de wordHerramientas básicas de word
Herramientas básicas de word
PaBlo HernAndez
 
Trabajo de informatica
Trabajo de informaticaTrabajo de informatica
Trabajo de informatica
Franklin Castellanos
 
Barometric condensor
Barometric condensorBarometric condensor
Barometric condensor
Mustika T. A A
 
Jennifergallardo
JennifergallardoJennifergallardo
Jennifergallardo
Jennifer Gallardo
 
INTERFAZ word 2013
INTERFAZ word 2013INTERFAZ word 2013
INTERFAZ word 2013
tania taveras espinal
 
Secado porliofilizacion
Secado porliofilizacionSecado porliofilizacion
Secado porliofilizacion
Antonio Arizmendi
 
Dias positivas yeysa las tic
Dias positivas yeysa las ticDias positivas yeysa las tic
Dias positivas yeysa las tic
carmen rodriguez
 

Viewers also liked (20)

Photoshop progress
Photoshop progressPhotoshop progress
Photoshop progress
 
Iatrogenic opioid dependence_in_the_united_states_.18
Iatrogenic opioid dependence_in_the_united_states_.18Iatrogenic opioid dependence_in_the_united_states_.18
Iatrogenic opioid dependence_in_the_united_states_.18
 
Yealink cp860 quick_start_guide_v80_10
Yealink cp860 quick_start_guide_v80_10Yealink cp860 quick_start_guide_v80_10
Yealink cp860 quick_start_guide_v80_10
 
Comparación entre el mapa curricular del nuevo modelo educativo 2016 y el map...
Comparación entre el mapa curricular del nuevo modelo educativo 2016 y el map...Comparación entre el mapa curricular del nuevo modelo educativo 2016 y el map...
Comparación entre el mapa curricular del nuevo modelo educativo 2016 y el map...
 
Qualitative data analysis
Qualitative data analysisQualitative data analysis
Qualitative data analysis
 
Managerial accounting-v1.1
Managerial accounting-v1.1Managerial accounting-v1.1
Managerial accounting-v1.1
 
үйлдвэрийн нэмэгдэл зардлын бүртгэл
үйлдвэрийн нэмэгдэл зардлын бүртгэлүйлдвэрийн нэмэгдэл зардлын бүртгэл
үйлдвэрийн нэмэгдэл зардлын бүртгэл
 
Sembrando ya! Marzo 2017
Sembrando ya! Marzo 2017Sembrando ya! Marzo 2017
Sembrando ya! Marzo 2017
 
La historia: inicio de nuestro viaje por el tiempo.
La historia: inicio de nuestro viaje por el tiempo.La historia: inicio de nuestro viaje por el tiempo.
La historia: inicio de nuestro viaje por el tiempo.
 
Ejercicios pert cpm
Ejercicios pert cpmEjercicios pert cpm
Ejercicios pert cpm
 
20% i corte
20% i corte20% i corte
20% i corte
 
Processor
ProcessorProcessor
Processor
 
Temas politico militares
Temas politico militaresTemas politico militares
Temas politico militares
 
Herramientas básicas de word
Herramientas básicas de wordHerramientas básicas de word
Herramientas básicas de word
 
Trabajo de informatica
Trabajo de informaticaTrabajo de informatica
Trabajo de informatica
 
Barometric condensor
Barometric condensorBarometric condensor
Barometric condensor
 
Jennifergallardo
JennifergallardoJennifergallardo
Jennifergallardo
 
INTERFAZ word 2013
INTERFAZ word 2013INTERFAZ word 2013
INTERFAZ word 2013
 
Secado porliofilizacion
Secado porliofilizacionSecado porliofilizacion
Secado porliofilizacion
 
Dias positivas yeysa las tic
Dias positivas yeysa las ticDias positivas yeysa las tic
Dias positivas yeysa las tic
 

Similar to Java

55 new things in Java 7 - Devoxx France
55 new things in Java 7 - Devoxx France55 new things in Java 7 - Devoxx France
55 new things in Java 7 - Devoxx France
David Delabassee
 
Java 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from OredevJava 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from Oredev
Mattias Karlsson
 
Modern Java Development
Modern Java DevelopmentModern Java Development
Modern Java Development
Angel Conde Manjon
 
Solr @ Etsy - Apache Lucene Eurocon
Solr @ Etsy - Apache Lucene EuroconSolr @ Etsy - Apache Lucene Eurocon
Solr @ Etsy - Apache Lucene Eurocon
Giovanni Fernandez-Kincade
 
Java7 New Features and Code Examples
Java7 New Features and Code ExamplesJava7 New Features and Code Examples
Java7 New Features and Code Examples
Naresh Chintalcheru
 
A topology of memory leaks on the JVM
A topology of memory leaks on the JVMA topology of memory leaks on the JVM
A topology of memory leaks on the JVM
Rafael Winterhalter
 
What`s new in Java 7
What`s new in Java 7What`s new in Java 7
What`s new in Java 7
Georgian Micsa
 
New Features Of JDK 7
New Features Of JDK 7New Features Of JDK 7
New Features Of JDK 7
Deniz Oguz
 
Nantes Jug - Java 7
Nantes Jug - Java 7Nantes Jug - Java 7
Nantes Jug - Java 7
Sébastien Prunier
 
Clojure - A new Lisp
Clojure - A new LispClojure - A new Lisp
Clojure - A new Lisp
elliando dias
 
What is new in Java 8
What is new in Java 8What is new in Java 8
What is new in Java 8
Sandeep Kr. Singh
 
wtf is in Java/JDK/wtf7?
wtf is in Java/JDK/wtf7?wtf is in Java/JDK/wtf7?
wtf is in Java/JDK/wtf7?
Scott Leberknight
 
Silicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM MechanicsSilicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM Mechanics
Azul Systems, Inc.
 
Building and Scaling Node.js Applications
Building and Scaling Node.js ApplicationsBuilding and Scaling Node.js Applications
Building and Scaling Node.js Applications
Ohad Kravchick
 
Local data storage for mobile apps
Local data storage for mobile appsLocal data storage for mobile apps
Local data storage for mobile apps
Ivano Malavolta
 
Atlassian Groovy Plugins
Atlassian Groovy PluginsAtlassian Groovy Plugins
Atlassian Groovy Plugins
Paul King
 
Java
Java Java
From Java 6 to Java 7 reference
From Java 6 to Java 7 referenceFrom Java 6 to Java 7 reference
From Java 6 to Java 7 reference
Giacomo Veneri
 
Web program-peformance-optimization
Web program-peformance-optimizationWeb program-peformance-optimization
Web program-peformance-optimization
xiaojueqq12345
 
Anti patterns
Anti patternsAnti patterns
Anti patterns
Alex Tumanoff
 

Similar to Java (20)

55 new things in Java 7 - Devoxx France
55 new things in Java 7 - Devoxx France55 new things in Java 7 - Devoxx France
55 new things in Java 7 - Devoxx France
 
Java 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from OredevJava 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from Oredev
 
Modern Java Development
Modern Java DevelopmentModern Java Development
Modern Java Development
 
Solr @ Etsy - Apache Lucene Eurocon
Solr @ Etsy - Apache Lucene EuroconSolr @ Etsy - Apache Lucene Eurocon
Solr @ Etsy - Apache Lucene Eurocon
 
Java7 New Features and Code Examples
Java7 New Features and Code ExamplesJava7 New Features and Code Examples
Java7 New Features and Code Examples
 
A topology of memory leaks on the JVM
A topology of memory leaks on the JVMA topology of memory leaks on the JVM
A topology of memory leaks on the JVM
 
What`s new in Java 7
What`s new in Java 7What`s new in Java 7
What`s new in Java 7
 
New Features Of JDK 7
New Features Of JDK 7New Features Of JDK 7
New Features Of JDK 7
 
Nantes Jug - Java 7
Nantes Jug - Java 7Nantes Jug - Java 7
Nantes Jug - Java 7
 
Clojure - A new Lisp
Clojure - A new LispClojure - A new Lisp
Clojure - A new Lisp
 
What is new in Java 8
What is new in Java 8What is new in Java 8
What is new in Java 8
 
wtf is in Java/JDK/wtf7?
wtf is in Java/JDK/wtf7?wtf is in Java/JDK/wtf7?
wtf is in Java/JDK/wtf7?
 
Silicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM MechanicsSilicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM Mechanics
 
Building and Scaling Node.js Applications
Building and Scaling Node.js ApplicationsBuilding and Scaling Node.js Applications
Building and Scaling Node.js Applications
 
Local data storage for mobile apps
Local data storage for mobile appsLocal data storage for mobile apps
Local data storage for mobile apps
 
Atlassian Groovy Plugins
Atlassian Groovy PluginsAtlassian Groovy Plugins
Atlassian Groovy Plugins
 
Java
Java Java
Java
 
From Java 6 to Java 7 reference
From Java 6 to Java 7 referenceFrom Java 6 to Java 7 reference
From Java 6 to Java 7 reference
 
Web program-peformance-optimization
Web program-peformance-optimizationWeb program-peformance-optimization
Web program-peformance-optimization
 
Anti patterns
Anti patternsAnti patterns
Anti patterns
 

Recently uploaded

AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
Google
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
Sven Peters
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
TheSMSPoint
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
Shane Coughlan
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
Green Software Development
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j
 
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
Alina Yurenko
 
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdfRevolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
Undress Baby
 
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket ManagementUtilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
ICS
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
Drona Infotech
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
mz5nrf0n
 
How to write a program in any programming language
How to write a program in any programming languageHow to write a program in any programming language
How to write a program in any programming language
Rakesh Kumar R
 
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise EditionWhy Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Envertis Software Solutions
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j
 
DDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systemsDDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systems
Gerardo Pardo-Castellote
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
Hornet Dynamics
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
Neo4j
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Łukasz Chruściel
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
Ayan Halder
 

Recently uploaded (20)

AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
 
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
 
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdfRevolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
 
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket ManagementUtilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
 
How to write a program in any programming language
How to write a program in any programming languageHow to write a program in any programming language
How to write a program in any programming language
 
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise EditionWhy Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
 
DDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systemsDDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systems
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
 

Java

  • 2. Table Of Contents 1. Coding convention 2. JAVA 7 a. Project Coin b. NIO 3. JAVA 8 4. Language type 5. JVM
  • 3. Coding Convention • Indentation • Tab VS Space ? • 2 VS 4 VS 8 ? • Brace location • Next VS Current ? • 변수 명 • Eclipse formatter 부터
  • 4. Java 7 • Project Coin • JDK 7 In Action - Learn With Java Tutorials and Developer Guides • Using New Core Platform Features In Real Code
  • 5. The Six Coin Features and How They help Consistency and clarity – 1. Improved literals – 2. Strings in switch Easier to use generics – 3. SafeVarargs (removing varargs warnings) – 4. Diamond More concise error handling – 5. Multi-catch and precise rethrow – 6. Try-with-resources
  • 6. Integral Binary Literals // An 8-bit 'byte' value: byte aByte = (byte)0b00100001; // A 16-bit 'short' value: short aShort = (short)0b1010000101000101; // Some 32-bit 'int' values: int anInt1 = 0b10100001010001011010000101000101; int anInt3 = 0B101; // The B can be upper or lower case. // A 64-bit 'long' value. Note the "L" suffix: long aLong = 0b1010000101000101101000010100010110100001010001011010000101000101L;
  • 7. Underscores in Literals long creditCardNumber = 1234_5678_9012_3456L; long socialSecurityNumber = 999_99_9999L; long hexWords = 0xCAFE_BABE; long maxLong = 0x7fff_ffff_ffff_ffffL; byte nybbles = 0b0010_0101; long bytes = 0b11010010_01101001_10010100_10010010;
  • 8.
  • 9. Strings in switch Statements public String getTypeOfDayWithSwitchStatement(String dayOfWeekArg) { String typeOfDay; switch (dayOfWeekArg) { case "Monday": typeOfDay = "Start of work week"; break; case "Tuesday": case "Wednesday": case "Thursday": typeOfDay = "Midweek"; break; case "Friday": typeOfDay = "End of work week"; break; case "Saturday": case "Sunday": typeOfDay = "Weekend"; break; default: throw new IllegalArgumentException("Invalid day of the week: " + dayOfWeekArg); } return typeOfDay; }
  • 10. Strings in switch Statements What is there to discuss? • What does switching on a null do? (NullPointerException) • Can null be a case label? (No.) • Case-insensitive comparisons? (No.) • Implementation • relies on a particular algorithm be used for String.hashCode • on average faster than if-else chain with >3 cases
  • 12. Diamond <> Set<List<String>> setOfLists = new HashSet<List<String>>(); Set<List<String>> setOfLists = new HashSet<>();
  • 13. Diamond Use Assignment Statement List<Map<String,Integer>> listOfMaps; … listOfMaps = new ArrayList<>(); Return Statement public Set<Map<BigInteger,BigInteger>> compute() { … return new Set<>(); }
  • 14. Multi-Catch and Precise Rethrow Multi-catch: ability to catch multiple exception types in a single catch clause try { ... } catch (FirstException | SecondException) { ... } Precise rethrow: change in can-throw analysis of a catch clause
  • 15. private List<String> readFile(String fileName) { List<String> lines = new ArrayList<String>(); BufferedReader reader = null; try { reader = new BufferedReader(new FileReader(fileName)); String line; while ((line = reader.readLine()) != null) { lines.add(line); } } catch (FileNotFoundException ex) { ex.printStackTrace(); } catch (IOException ex) { ex.printStackTrace(); } finally { try { if (reader != null) { reader.close(); } } catch (IOException e) { // 이건..... 쫌... } } return lines; } The try-with-resources Statement
  • 16. The try-with-resources Statement static String readFirstLineFromFile(String path) throws IOException { try (BufferedReader br = new BufferedReader(new FileReader(path))) { return br.readLine(); } } Prior to Java SE 7 static String readFirstLineFromFileWithFinallyBlock(String path) throws IOException { BufferedReader br = new BufferedReader(new FileReader(path)); try { return br.readLine(); } finally { if (br != null) br.close(); } }
  • 17. NIO.2 File System API Background and Motivation The platform was long overdue something better than java.io.File • Doesn’t work consistently across platforms • Lack of useful exceptions when a file operation fails • Missing basic operations, no file copy, move, ... • Limited support for symbolic links • Very limited support for file attributes • No bulk access to file attributes • Badly missing features that many applications require • No way to plug-in other file system implementations
  • 18. New File System API • Path – used to locate a file in a file system • Files – defines static methods to operate on files, directories and other types of files • FileSystem • Provides a handle to a file system • Factory for objects that access the file system • FileSystems.getDefault returs a reference to the default FileSystem • FileStore – the underlying storage/volume
  • 19. public class Test { public static void main(String[] args) { FileSystem fileSystem = FileSystems.getDefault(); FileSystemProvider provider = fileSystem.provider(); System.out.println("Provider: " + provider.toString()); System.out.println("Open: " + fileSystem.isOpen()); System.out.println("Read Only: " + fileSystem.isReadOnly()); Iterable<Path> rootDirectories = fileSystem.getRootDirectories(); System.out.println(); System.out.println("Root Directories"); for (Path path : rootDirectories) { System.out.println(path); } Iterable<FileStore> fileStores = fileSystem.getFileStores(); System.out.println(); System.out.println("File Stores"); for (FileStore fileStore : fileStores) { System.out.println(fileStore.name()); } } } Provider: sun.nio.fs.WindowsFileSystemProvider@1db9742 Open: true Read Only: false Root Directories C: D: E: F: G: H: I: File Stores ssd1 ssd2 data ssd3 Samsung1TB
  • 20. public class FileSystemExampleV { public static void main(String[] args) throws Exception { FileSystem fileSystem = FileSystems.getDefault(); for (FileStore store : fileSystem.getFileStores()) { System.out.println("드라이버명: " + store.name()); System.out.println("파일시스템: " + store.type()); System.out.println("전체 공간: " + store.getTotalSpace() + " 바이트"); System.out.println("사용 중인 공간: " + (store.getTotalSpace() - store.getUnallocatedSpace()) + " 바이트"); System.out.println("사용 가능한 공간: " + (store.getTotalSpace() - store.getUsableSpace()) + " 바이트"); System.out.println(); } System.out.println("파일 구분자: " + fileSystem.getSeparator()); System.out.println(); for (Path path : fileSystem.getRootDirectories()) { System.out.println(path.toString()); } } } 드라이버명: 파일시스템: NTFS 전체 공간: 127666221056 바이트 사용 중인 공간: 114883612672 바이트 사용 가능한 공간: 114883612672 바이트 드라이버명: ssd1 파일시스템: NTFS 전체 공간: 256058060800 바이트 사용 중인 공간: 193507590144 바이트 사용 가능한 공간: 193507590144 바이트 드라이버명: ssd2 파일시스템: NTFS 전체 공간: 256058060800 바이트 사용 중인 공간: 114384744448 바이트 사용 가능한 공간: 114384744448 바이트 드라이버명: data 파일시스템: NTFS 전체 공간: 2000396742656 바이트 사용 중인 공간: 953533616128 바이트 사용 가능한 공간: 953533616128 바이트 드라이버명: ssd3 파일시스템: NTFS 전체 공간: 500104687616 바이트 사용 중인 공간: 239441858560 바이트 사용 가능한 공간: 239441858560 바이트 드라이버명: Samsung1TB 파일시스템: NTFS 전체 공간: 1000194011136 바이트 사용 중인 공간: 841152049152 바이트 사용 가능한 공간: 841152049152 바이트 파일 구분자: C: D: E: F: G: H: I:
  • 21. Java 8 • What’s New in JDK 8 • Lambda • Default Methods • Optional • Type Annotation • Nashorn • Concurrency • Stamped Lock • Concurrent Addr • Parallel Sorting • 그리고 그 외? • New Date API • OS Process Control
  • 22. JVM Language • Java • Scala • Play, Akka • Clojure • Groovy • Grails, Gradle • JRuby • Jython • Kotlin • Jetbrain
  • 23. CLR • C# • Visual Basic • F# • Iron Python • Iron Ruby • Power Shell • Java • J#
  • 24. 그 외 • C/C++ • Java Script • Go • Haskell • OCaml • Erlang • Swift • Dart • Type Script
  • 25. 앞으로... • 함수 패러다임 • 메타 프로그래밍 • Concurrent 프로그래밍
  • 26. Description of Java Conceptual Diagram
  • 27. JVM • 스택 기반의 가상 머신 (NOT Register 기반) • Dalvik VM은??? • 심볼릭 레퍼런스(NOT Address 기반) • 가비지 컬렉션 • 기본 자료형을 명확하게 정의해 플랫폼 독립성 보장 • 네트워크 바이트 순서 • Little endian vs Big endian
  • 29. Java Byte Code public void add(java.lang.String); Code: 0: aload_0 1: getfield #15; // Field admin:Lcom.mantech.mccs/user/UserAdmin; 4: aload_1 5: invokevirtual #23; // Method com/mantech/mccs/user/UserAdmin.addUser:(Ljava/lang/String;)Lcom/mantech.mccs/user/User; 8: pop 9: return aload_0 = 0x2a getfield = 0xb4 aload_1 = 0x2b invokevirtual = 0xb6 2a b4 00 0f 2b b6 00 17 57 b1
  • 31. Execution Engine • Interpreter • JIT(Just In Time) • Oracle hotspot VM • From JDK 1.3 ~ • Dalvik VM from Android 2.2 ~ • IBM AOT(Ahead-Of-Time) • From JDK6
  • 32. Garbage Collection • “stop-the-world” • Young Generation • Eden • Survivor(2개) • Old Generation (JDK 7) • Serial GC • Parallel GC • Parallel Old GC(Parallel Compacting GC) • Concurrent Mark & Sweep GC • G1(Garbage First) GC
  • 36. Java Thread • 스레드 상태 • NEW • RUNNABLE • BLOCKED • WAITING • TIMED_WAITING • TERMINATED
  • 38. Monitor • Muitual exclusion • acquire • release • Synchronized synchronized instance synchronized void method() { … } void method() { synchronized (this) { … } } synchronized class class Something { static synchronized void method() { … } } class Something { static void method() { synchronized (Something.class) { … } } }
  • 39. Synchronized? public synchronized void setName(String name) { this.name = name; } public synchronized void setAddress(String address) { this.address = address; }
  • 40. 쓰레드 협조 • wait • notify/notifyAll
  • 41. volatile? “visibility를 확보기 위해 barrier reordering 을 한다.”
  • 42. Reorder class Something { private int x = 0; private int y = 0; public void write() { x = 100; y = 50; } public void read() { if (x < y) { System.out.println("x < y"); } } } public class Reorder { public static void main(String[] args) { final Something obj = new Something(); new Thread() { // Thread A public void run() { obj.write(); } }.start(); new Thread() { // Thread B public void run() { obj.read(); } }.start(); } } x < y가 출력될 수 있을까?
  • 44. volatile java의 volatile은 2가지 기능 1. 변수의 동기화 2. long, double 을 atomic 단위 취급