SlideShare a Scribd company logo
Java
TmaxSoft R&D Center
1
113년	 10월	 10일	 목
성장과 교육
2
213년	 10월	 10일	 목
2. 노력이 왜곡되
지 않도록
코칭과 feedback!
1. 스스로 노력
2만 번!
3
313년	 10월	 10일	 목
강의는 코칭의 한 수단일뿐
3. 성취욕 & 동기
부여
4
413년	 10월	 10일	 목
4. team spirit
함께 성장
5
513년	 10월	 10일	 목
교육이 핵심이
아니다!
교육은 거저 거들 뿐
6
613년	 10월	 10일	 목
자바 교육 계획
1일 : Language, String,
ClassLoader, Proxy
2일 : GC, Collections
3일 : Thread, Java Memory
Model
4일 : AQS, ForkJoin,
Concurrent Utils
5일 : IO, Generics, Annotation,
RMI
6일 : Unsafe, Lambda (Java 8)
7
713년	 10월	 10일	 목
History of Java
http://www.java.com/en/javahistory/timeline.jsp
1991 : Green Project Begins (Consumer Electronic Market)
1995 : Java Technology announced
1996 : JDK 1.0 released
1997 : JDK 1.1 released
1999 : Java 2 (JDK 1.2) released
2004 : J2SE 5 released
2006 : Open Source Java announced. Java SE 6 Released
2009 : Oracle acquires Sun Microsystems
2011 : Java SE 7 Released
2014 : Java SE 8 will be released
8
813년	 10월	 10일	 목
Getting Started
JDK (Java Development Kit)
Java Document
API Document
Java Language Specification, Java VM Specification
http://docs.oracle.com/javase/specs/
Source code : OpenJDK project page
http://openjdk.java.net
9
913년	 10월	 10일	 목
Compiled & Interpreted
.java .class Virtual Machinejavac java
.class
source file bytecode
10
1013년	 10월	 10일	 목
Java Types : Class,
Interface, Primitive
Types : Class, Interface, Functional Interface (JDK 8)
Parameterized Types : Generics (JDK 5)
enum type : compiled to a child class of
java.lang.Enum
Primitive : non-object type. for performance
byte, char, short, int, long, float, double
boolean
11
1113년	 10월	 10일	 목
Enum type
not a real Java type
Joshua Bloch’s typesafe enum pattern implementation by Java
compiler
Non-VM type. It’s compiled as a a final child class of
java.lang.Enum class.
static values() method
static valueOf(String) method
protected constructor (String name, int ordinal)
Can be safely used in switch clause as if it’s a cardinal type
12
1213년	 10월	 10일	 목
Data Conversion
Widening conversion (implicit)
byte < short < int < long < float < double
char < int
Narrowing conversion (explicit cast required)
Boxing/unboxing conversion (JDK 5)
Numeric promotion
unary op : byte, short, char -> int
binary op : double <- float <- long <- int <- byte, short, char
3 + 3.0f => 6.0f (int to float promotion occurs)
(byte) 3 + (short) 4 => (int) 7 (binary op cannot produce byte, short, char)
13
1313년	 10월	 10일	 목
Operator
==, !=, !, &, ^, |, &&, ||, ? :
<, <=, >, >=, +, -, *, /, %, ++, --, <<, >>, >>>, ~, |
unsigned right shift operator (>>>)
Java의 Numeric type은 모두 signed. right shift 시에 부호 비트를 shift할지 여부.
>>의 경우에는 상위 비트에 채워지는 값이 부호 비트 값, >>>의 경우에는 부호 비트의 값에
상관없이 0이 채워진다.
0B1111_1111_1111_1111_1111_1111_1111_1101 ((int) -3)
0B1111_1111_1111_1111_1111_1111_1111_1110 (-3 >> 1 = -2)
0B0111_1111_1111_1111_1111_1111_1111_1110 (-3 >>> 1 = 2147483646)
NOTE: 0b(이진수)와 숫자 사이의 가시성을 위한 ‘_’는 JDK 7부터의 기능
14
1413년	 10월	 10일	 목
java.lang.Object
Everything except some primitive types are objects
public Class<?> getClass();
public int hashCode();
protected Object clone() throws CloneNotSupportedException;
public String toString();
public final void notifyAll();
public final void wait(long timeout) throws InterruptedException;
public final void wait() throws InterruptedException;
public final void wait(long timeout, int nanos) throws InterruptedException;
protected void finalize() throws Throwable;
15
1513년	 10월	 10일	 목
java.lang.String
Immutable (StringBuffer/StringBuilder 참고)
+ operator
compiled to StringBuilder.append() after String conversion using Object.toString()
Compile time String constant reduction : “abc” + “def” -> “abcdef”
Performance problems
Too many concatenation
Concatenation always requires reallocation
Too many objects problem
String constant pool in JVM (Moved from Perm Area to Heap since JDK 7 Hotspot JVM)
intern() method : equals() and ==
16
1613년	 10월	 10일	 목
Flow Control
If, while, do - while statement
Continue and break
Exception Handling
try - catch
17
1713년	 10월	 10일	 목
Label (continue, break)
outer :
while (true) {
inner :
while (true) {
cotinue outer;
}
}
18
1813년	 10월	 10일	 목
For Each (JDK 5)
Syntatic sugar for easy collection iteration
즉, JVM은 이러한 syntax를 전혀 모름
List<String> list = Arrays.asList("a", "b", "c");
for (String s : list) {
System.out.println(s);
}
19
1913년	 10월	 10일	 목
Switch /w Strings (JDK 7)
JVM generates more efficient code for switching
depending on Strings
first switch using hashCode
then goto the case statement and call equals
20
2013년	 10월	 10일	 목
Multiple Catch (JDK 7)
try {
doSomething();
} catch (IOException e) {
e.printStackTrace();
} catch
(PrivilegedActionException e) {
e.printStackTrace();
}
21
try {
doSomething();
} catch (IOException |
PrivilegedActionException e)
{
e.printStackTrace();
}
2113년	 10월	 10일	 목
Try with Resources (JDK 7)
java.lang.AutoCloseable
java.lang.Throwable.addSuppressed(Th
rowable)
java.lang.Throwable.getSuppressed()
Syntactic Sugar
try (BufferedReader br = new
BufferedReader(new FileReader(path))) {
return br.readLine();
}
22
BufferedReader br = null;
try {
br = new BufferedReader(new
FileReader(path));
return br.readLine();
} finally {
if (br != null) {
br.close();
}
}
2213년	 10월	 10일	 목
Object Oriented Features
package, class, interface, inner class
Access modifiers
Class access modifiers, Member access modifiers
Inheritance : Single inheritance, Multiple inheritance using interface
Polymorphism
Method overriding/Field hiding
Method overloading
Parameterized types (Generics)
23
2313년	 10월	 10일	 목
Access Modifiers
public : class, method, field
private : method, field, inner class only
protected : method, field, inner class only
package private : class, method, field
Less restricted More restricted
public < protected < default (package private) < private
24
2413년	 10월	 10일	 목
Inner Class
static inner class
instance inner class
anonymous inner class
automatic name binding
compiler generates boilerplate codes
25
2513년	 10월	 10일	 목
this and super
Self or parent referencing in inheritance
Constructor
compiler generates super call if none exist
Static field/method (class field/method)
Instance field/method
final/abstract modifier
26
2613년	 10월	 10일	 목
ClassLoader
java.lang.ClassLoader
defineClass, findClass, loadClass
parent ClassLoader
Bootstrap class loader
System.getProperty(“sun.boot.class.path”), -Xbootclasspath: option
Application class loader
parent loader is Extension class loader : jre/lib/ext loading, -classpath option
Custom class loader
Parent first (default)/child first policy
27
2713년	 10월	 10일	 목
loadClass
loadClass can be done in parallel (JDK 7)
protected static boolean registerAsParallelCapable();
JDK 7 removed synchronized modifier
see the source code
1.call findLoadedClasses()
2.call parent.loadClass() or findBootstrapClassOrNull()
3.still not found then call findClass()
28
2813년	 10월	 10일	 목
class bytecode format
ClassFile {
u4 magic;
u2 minor_version;
u2 major_version;
u2 constant_pool_count;
cp_info
constant_pool[constant_pool_count-1];
u2 access_flags;
u2 this_class;
u2 super_class;
29
u2 interfaces_count;
u2 interfaces[interfaces_count];
u2 fields_count;
field_info fields[fields_count];
u2 methods_count;
method_info
methods[methods_count];
u2 attributes_count;
attribute_info attributes[attributes_count];
}
2913년	 10월	 10일	 목
Dynamic Proxy (JDK 1.3)
Creating Proxy Class
static Class<?> getProxyClass(ClassLoader loader, Class<?>... interfaces)
see sun.misc.ProxyGenerator.generateClassFile()
Instantiating Proxy Object
static Object newProxyInstance(ClassLoader loader, Class<?>[]
interfaces, InvocationHandler h)
Implementing InvocationHandler
Override toString/equals
Object invoke(Object proxy, Method method, Object[] args) throws
Throwable
30
3013년	 10월	 10일	 목
Hotspot JVM bootstrap
openjdk7/hotspot/src/share/tools/launcher/java.c#JavaMain
openjdk7/hotspot/src/share/vm/runtime/thread.cpp::create_vm
initialize java.lang.System
SystemDictionary::compute_java_system_loader
GC : ConcurrentMarkThread::makeSurrogateLockerThread
compiler: CompileBroker::compilation_init
create compiler threads
jclass mainClass = LoadClass(env, mainClassName);
(*env)->CallStaticVoidMethod(env, mainClass, mainID, mainArgs);
31
3113년	 10월	 10일	 목
다음 시간 예정
JVM의 동작을 Hello, World로..
classloader의 역할도 확실하게 JVM 안에서
지난 강의 reminder부터 (강의 내용에서 한발 나간 다른 측면
을 가볍게 소개)
inner class
class loader / proxy
syntactic sugar들에 대한 정리
32
3213년	 10월	 10일	 목

More Related Content

PPTX
Jdk(java) 7 - 5. invoke-dynamic
PDF
Java 8 고급 (5/6)
PDF
Why what how kotlin
KEY
Java start01 in 2hours
PDF
Java 8 고급 (3/6)
PDF
일단 시작하는 코틀린
PDF
Java 8 고급 (2/6)
PPTX
Kotlin with fp
Jdk(java) 7 - 5. invoke-dynamic
Java 8 고급 (5/6)
Why what how kotlin
Java start01 in 2hours
Java 8 고급 (3/6)
일단 시작하는 코틀린
Java 8 고급 (2/6)
Kotlin with fp

What's hot (14)

PDF
Realm은 어떻게 효율적인 데이터베이스를 만들었나?
PDF
Java in 2 hours
PDF
스위프트, 코틀린과 모던언어의 특징 (Swift, Kotlin and Modern Languages)
PPTX
[새차원, 코틀린(Kotlin) 강좌] 5. Control Flow
PDF
자바에서 null을 안전하게 다루는 방법
PDF
비전공자의 자바스크립트 도전기
PDF
JDK 변천사
PDF
Java jungsuk3 ch14_lambda_stream
PPTX
C++ inherit virtual
PPTX
[하코사 세미나] 비전공자의 자바스크립트 도전기
PDF
Swift3 typecasting nested_type
PDF
Scalability
PPTX
Jupyter notebok tensorboard 실행하기_20160706
PDF
java 8 람다식 소개와 의미 고찰
Realm은 어떻게 효율적인 데이터베이스를 만들었나?
Java in 2 hours
스위프트, 코틀린과 모던언어의 특징 (Swift, Kotlin and Modern Languages)
[새차원, 코틀린(Kotlin) 강좌] 5. Control Flow
자바에서 null을 안전하게 다루는 방법
비전공자의 자바스크립트 도전기
JDK 변천사
Java jungsuk3 ch14_lambda_stream
C++ inherit virtual
[하코사 세미나] 비전공자의 자바스크립트 도전기
Swift3 typecasting nested_type
Scalability
Jupyter notebok tensorboard 실행하기_20160706
java 8 람다식 소개와 의미 고찰
Ad

Similar to Java 8 고급 (1/6) (20)

PPTX
공유 Jdk 7-2-project coin
PDF
Java programming pdf
PPT
자바야 놀자 PPT
PDF
Java tutorial
PPTX
Programming java day2
PDF
Java_02 변수자료형
PDF
Java 변수자료형
PDF
Java 강의자료 ed11
PPTX
이것이 자바다 Chap.11 기본 API 클래스(java)(KOR)
PPTX
객체지향 프로그래밍 기본
PPTX
java_2장.pptx
PPTX
[자바카페] 자바 객체지향 프로그래밍 (2017)
PDF
Java(2/4)
PPTX
[HaU] 신입 기술 면접 준비 java
PDF
Java advancd ed10
PDF
Java the good parts
PPTX
Java Class File Format
PDF
Java(1/4)
PDF
Yapp a.a study 2 reflection+annotation
PPTX
Java, android 스터티3
공유 Jdk 7-2-project coin
Java programming pdf
자바야 놀자 PPT
Java tutorial
Programming java day2
Java_02 변수자료형
Java 변수자료형
Java 강의자료 ed11
이것이 자바다 Chap.11 기본 API 클래스(java)(KOR)
객체지향 프로그래밍 기본
java_2장.pptx
[자바카페] 자바 객체지향 프로그래밍 (2017)
Java(2/4)
[HaU] 신입 기술 면접 준비 java
Java advancd ed10
Java the good parts
Java Class File Format
Java(1/4)
Yapp a.a study 2 reflection+annotation
Java, android 스터티3
Ad

More from Kyung Koo Yoon (10)

PDF
Kubernetes
PDF
Java 8 고급 (6/6)
PDF
Java 8 고급 (4/6)
PDF
Spring Framework - Inversion of Control Container
PDF
Smart software engineer
PPT
Lecture on Java Concurrency Day 3 on Feb 11, 2009.
PPT
Lecture on Java Concurrency Day 2 on Feb 4, 2009.
PPT
Lecture on Java Concurrency Day 4 on Feb 18, 2009.
PPT
Lecture on Java Concurrency Day 1 on Jan 21, 2009.
PPTX
창의와 열정, 소프트웨어 엔지니어
Kubernetes
Java 8 고급 (6/6)
Java 8 고급 (4/6)
Spring Framework - Inversion of Control Container
Smart software engineer
Lecture on Java Concurrency Day 3 on Feb 11, 2009.
Lecture on Java Concurrency Day 2 on Feb 4, 2009.
Lecture on Java Concurrency Day 4 on Feb 18, 2009.
Lecture on Java Concurrency Day 1 on Jan 21, 2009.
창의와 열정, 소프트웨어 엔지니어

Java 8 고급 (1/6)

  • 3. 2. 노력이 왜곡되 지 않도록 코칭과 feedback! 1. 스스로 노력 2만 번! 3 313년 10월 10일 목
  • 4. 강의는 코칭의 한 수단일뿐 3. 성취욕 & 동기 부여 4 413년 10월 10일 목
  • 5. 4. team spirit 함께 성장 5 513년 10월 10일 목
  • 6. 교육이 핵심이 아니다! 교육은 거저 거들 뿐 6 613년 10월 10일 목
  • 7. 자바 교육 계획 1일 : Language, String, ClassLoader, Proxy 2일 : GC, Collections 3일 : Thread, Java Memory Model 4일 : AQS, ForkJoin, Concurrent Utils 5일 : IO, Generics, Annotation, RMI 6일 : Unsafe, Lambda (Java 8) 7 713년 10월 10일 목
  • 8. History of Java http://www.java.com/en/javahistory/timeline.jsp 1991 : Green Project Begins (Consumer Electronic Market) 1995 : Java Technology announced 1996 : JDK 1.0 released 1997 : JDK 1.1 released 1999 : Java 2 (JDK 1.2) released 2004 : J2SE 5 released 2006 : Open Source Java announced. Java SE 6 Released 2009 : Oracle acquires Sun Microsystems 2011 : Java SE 7 Released 2014 : Java SE 8 will be released 8 813년 10월 10일 목
  • 9. Getting Started JDK (Java Development Kit) Java Document API Document Java Language Specification, Java VM Specification http://docs.oracle.com/javase/specs/ Source code : OpenJDK project page http://openjdk.java.net 9 913년 10월 10일 목
  • 10. Compiled & Interpreted .java .class Virtual Machinejavac java .class source file bytecode 10 1013년 10월 10일 목
  • 11. Java Types : Class, Interface, Primitive Types : Class, Interface, Functional Interface (JDK 8) Parameterized Types : Generics (JDK 5) enum type : compiled to a child class of java.lang.Enum Primitive : non-object type. for performance byte, char, short, int, long, float, double boolean 11 1113년 10월 10일 목
  • 12. Enum type not a real Java type Joshua Bloch’s typesafe enum pattern implementation by Java compiler Non-VM type. It’s compiled as a a final child class of java.lang.Enum class. static values() method static valueOf(String) method protected constructor (String name, int ordinal) Can be safely used in switch clause as if it’s a cardinal type 12 1213년 10월 10일 목
  • 13. Data Conversion Widening conversion (implicit) byte < short < int < long < float < double char < int Narrowing conversion (explicit cast required) Boxing/unboxing conversion (JDK 5) Numeric promotion unary op : byte, short, char -> int binary op : double <- float <- long <- int <- byte, short, char 3 + 3.0f => 6.0f (int to float promotion occurs) (byte) 3 + (short) 4 => (int) 7 (binary op cannot produce byte, short, char) 13 1313년 10월 10일 목
  • 14. Operator ==, !=, !, &, ^, |, &&, ||, ? : <, <=, >, >=, +, -, *, /, %, ++, --, <<, >>, >>>, ~, | unsigned right shift operator (>>>) Java의 Numeric type은 모두 signed. right shift 시에 부호 비트를 shift할지 여부. >>의 경우에는 상위 비트에 채워지는 값이 부호 비트 값, >>>의 경우에는 부호 비트의 값에 상관없이 0이 채워진다. 0B1111_1111_1111_1111_1111_1111_1111_1101 ((int) -3) 0B1111_1111_1111_1111_1111_1111_1111_1110 (-3 >> 1 = -2) 0B0111_1111_1111_1111_1111_1111_1111_1110 (-3 >>> 1 = 2147483646) NOTE: 0b(이진수)와 숫자 사이의 가시성을 위한 ‘_’는 JDK 7부터의 기능 14 1413년 10월 10일 목
  • 15. java.lang.Object Everything except some primitive types are objects public Class<?> getClass(); public int hashCode(); protected Object clone() throws CloneNotSupportedException; public String toString(); public final void notifyAll(); public final void wait(long timeout) throws InterruptedException; public final void wait() throws InterruptedException; public final void wait(long timeout, int nanos) throws InterruptedException; protected void finalize() throws Throwable; 15 1513년 10월 10일 목
  • 16. java.lang.String Immutable (StringBuffer/StringBuilder 참고) + operator compiled to StringBuilder.append() after String conversion using Object.toString() Compile time String constant reduction : “abc” + “def” -> “abcdef” Performance problems Too many concatenation Concatenation always requires reallocation Too many objects problem String constant pool in JVM (Moved from Perm Area to Heap since JDK 7 Hotspot JVM) intern() method : equals() and == 16 1613년 10월 10일 목
  • 17. Flow Control If, while, do - while statement Continue and break Exception Handling try - catch 17 1713년 10월 10일 목
  • 18. Label (continue, break) outer : while (true) { inner : while (true) { cotinue outer; } } 18 1813년 10월 10일 목
  • 19. For Each (JDK 5) Syntatic sugar for easy collection iteration 즉, JVM은 이러한 syntax를 전혀 모름 List<String> list = Arrays.asList("a", "b", "c"); for (String s : list) { System.out.println(s); } 19 1913년 10월 10일 목
  • 20. Switch /w Strings (JDK 7) JVM generates more efficient code for switching depending on Strings first switch using hashCode then goto the case statement and call equals 20 2013년 10월 10일 목
  • 21. Multiple Catch (JDK 7) try { doSomething(); } catch (IOException e) { e.printStackTrace(); } catch (PrivilegedActionException e) { e.printStackTrace(); } 21 try { doSomething(); } catch (IOException | PrivilegedActionException e) { e.printStackTrace(); } 2113년 10월 10일 목
  • 22. Try with Resources (JDK 7) java.lang.AutoCloseable java.lang.Throwable.addSuppressed(Th rowable) java.lang.Throwable.getSuppressed() Syntactic Sugar try (BufferedReader br = new BufferedReader(new FileReader(path))) { return br.readLine(); } 22 BufferedReader br = null; try { br = new BufferedReader(new FileReader(path)); return br.readLine(); } finally { if (br != null) { br.close(); } } 2213년 10월 10일 목
  • 23. Object Oriented Features package, class, interface, inner class Access modifiers Class access modifiers, Member access modifiers Inheritance : Single inheritance, Multiple inheritance using interface Polymorphism Method overriding/Field hiding Method overloading Parameterized types (Generics) 23 2313년 10월 10일 목
  • 24. Access Modifiers public : class, method, field private : method, field, inner class only protected : method, field, inner class only package private : class, method, field Less restricted More restricted public < protected < default (package private) < private 24 2413년 10월 10일 목
  • 25. Inner Class static inner class instance inner class anonymous inner class automatic name binding compiler generates boilerplate codes 25 2513년 10월 10일 목
  • 26. this and super Self or parent referencing in inheritance Constructor compiler generates super call if none exist Static field/method (class field/method) Instance field/method final/abstract modifier 26 2613년 10월 10일 목
  • 27. ClassLoader java.lang.ClassLoader defineClass, findClass, loadClass parent ClassLoader Bootstrap class loader System.getProperty(“sun.boot.class.path”), -Xbootclasspath: option Application class loader parent loader is Extension class loader : jre/lib/ext loading, -classpath option Custom class loader Parent first (default)/child first policy 27 2713년 10월 10일 목
  • 28. loadClass loadClass can be done in parallel (JDK 7) protected static boolean registerAsParallelCapable(); JDK 7 removed synchronized modifier see the source code 1.call findLoadedClasses() 2.call parent.loadClass() or findBootstrapClassOrNull() 3.still not found then call findClass() 28 2813년 10월 10일 목
  • 29. class bytecode format ClassFile { u4 magic; u2 minor_version; u2 major_version; u2 constant_pool_count; cp_info constant_pool[constant_pool_count-1]; u2 access_flags; u2 this_class; u2 super_class; 29 u2 interfaces_count; u2 interfaces[interfaces_count]; u2 fields_count; field_info fields[fields_count]; u2 methods_count; method_info methods[methods_count]; u2 attributes_count; attribute_info attributes[attributes_count]; } 2913년 10월 10일 목
  • 30. Dynamic Proxy (JDK 1.3) Creating Proxy Class static Class<?> getProxyClass(ClassLoader loader, Class<?>... interfaces) see sun.misc.ProxyGenerator.generateClassFile() Instantiating Proxy Object static Object newProxyInstance(ClassLoader loader, Class<?>[] interfaces, InvocationHandler h) Implementing InvocationHandler Override toString/equals Object invoke(Object proxy, Method method, Object[] args) throws Throwable 30 3013년 10월 10일 목
  • 31. Hotspot JVM bootstrap openjdk7/hotspot/src/share/tools/launcher/java.c#JavaMain openjdk7/hotspot/src/share/vm/runtime/thread.cpp::create_vm initialize java.lang.System SystemDictionary::compute_java_system_loader GC : ConcurrentMarkThread::makeSurrogateLockerThread compiler: CompileBroker::compilation_init create compiler threads jclass mainClass = LoadClass(env, mainClassName); (*env)->CallStaticVoidMethod(env, mainClass, mainID, mainArgs); 31 3113년 10월 10일 목
  • 32. 다음 시간 예정 JVM의 동작을 Hello, World로.. classloader의 역할도 확실하게 JVM 안에서 지난 강의 reminder부터 (강의 내용에서 한발 나간 다른 측면 을 가볍게 소개) inner class class loader / proxy syntactic sugar들에 대한 정리 32 3213년 10월 10일 목