SlideShare a Scribd company logo
1 of 74
Download to read offline
김대우
젬플레이 이사
http://lekdw.blogspot.kr/
정도현(정개발)
나는 프로그래머다 MC
일본 Mamezou소속 컨설턴트
http://Iamprogrammer.io
http://moreagile.net
James Gosling
Patrick Naughton
https://en.wikipedia.org/wiki/Java_(programming_language)
https://en.wikipedia.org/wiki/Java_(programming_language)
J2SE 5.0
Java SE 7
Java SE 8
https://en.wikipedia.org/wiki/Java_version_history
연도별 언어 인기도
http://www.tiobe.com/index.p
hp/content/paperinfo/tpci/ind
ex.html
http://benchmarksgame.alioth.debian.org/u64/which-programs-are-fastest.html
http://www3.ntu.edu.sg/home/ehchua/programming/java/j5b_io.html
http://www.evanjones.ca/software/java-bytebuffers.html
http://netty.io/wiki/using-as-a-generic-library.html
http://terracotta.org/products/bigmemory
모바일 게임 서버와 같이 Life Cycle이 짧은 데이터(객체)를 주로 처리하
는 경우, 별다른 튜닝없이 -server, -d64, -Xms, -Xmx 옵션으로 충분.
http://www.drdobbs.com/jvm/the-comparative-productivity-of-programm/240005881
Language Hours Per Function Point
ASP* 06.1
Visual Basic 08.5
Java 10.6
SQL 10.8
C++ 12.4
C 13.0
C# 15.5
PL/1 14.2
COBOL 16.8
ABAP 19.9
Checkstyle
Error Prone
FindBugs
PMD
SonarQube
http://readwrite.com/2011/01/24/the-java-ecosystem-infographic
JUnit
SLF4J API Module
Scala Library
Logback Classic Module
Guava: Google Core Libraries for Java
Mockito
Google APIs Client Library for Java
Apache Log4j
Commons IO
SLF4J LOG4J-12 Binding
osgi.core
JavaServlet(TM) Specification
TestNG
ScalaTest
Commons Lang
Joda-Time
Spring Context
Mockito
H2 Database Engine
Java Servlet API
http://www.77dev.com/2014/05/java-trends-top-100-mostly-used.html
JCL 1.1.1 implemented over SLF4J
jackson-databind
SLF4J Simple Binding
Apache CommonsCodec
Apache HttpClient
Apache Commons Lang
Commons Logging
Spring Core
osgi.cmpn
Google Guice - Core Library
SpringTestContext Framework
Jetty :: Server Core
Maven Plugin API
FindBugs-jsr305
BeanValidation API
Spring Beans
Groovy
Jackson-core
EasyMock
Spock Framework - Core Module
Java8
http://www.slideshare.net/shintanimoto/from-old-java-to-modern-java
private List m_list=null;
private int process_file(String str_file_name){
String str_line;
List list_lines=new ArrayList();
int i_result=read_file(str_file_name,list_lines);
if(i_result==0){
List list_record=new ArrayList();
for(int i=0;i<list_lines.size();i++){
str_line=(String)list_lines.get(i);
Record record=new Record();
i_result=parse_line(str_line,record);
if(i_result!=0){
return i_result;
}
list_recordord.add(record);
}
m_list=list_record;
return 0;
}else{
return i_result;
}
}
http://www.slideshare.net/shintanimoto/from-old-java-to-modern-java
C-ish java
private List resultList;
private List processFile(String fileName)throws
SystemException {
List lines = readFile(fileName);
List recordList = new ArrayList();
for (int i = 0; i < lines.size(); i++) {
String line = (String) lines.get(i);
Record record = parseLine(line);
recordList.add(record);
}
return recordList;
}
http://www.slideshare.net/shintanimoto/from-old-java-to-modern-java
Java 1.4
private List<Record> processFile(String fileName)throws SystemException {
List<String> lines = readFile(fileName);
List<Record> recordList = new ArrayList();
for (String line : lines) {
Record record = parseLine(line);
recordList.add(record);
}
return recordList;
}
Java 1.7 generic + foreach
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) {
throw new SystemException(FILE_NOT_FOUND, ex);
} catch (IOException ex) {
throw new SystemException(FILE_READ_ERROR, ex);
}
finally {
try {
if (reader != null) {
reader.close();
}
} catch (IOException ex) {
// 이건 무시?
}
}
return lines;
}
private List<String> readFile(String fileName) {
List<String> lines = new ArrayList<>();
try (FileReader in = new FileReader(fileName);
BufferedReader reader = new BufferedReader(in)) {
String line;
while ((line = reader.readLine()) != null) {
lines.add(line);
}
} catch (FileNotFoundException ex) {
throw new SystemException(FILE_NOT_FOUND, ex);
} catch (IOException ex) {
throw new SystemException(FILE_READ_ERROR, ex);
}
return lines;
}
Java 7
private List<String> readFile(String fileName) {
try {
return Files.readAllLines(Paths.get(fileName), Charset.defaultCharset());
} catch (IOException ex) {
throw new SystemException(FILE_READ_ERROR, ex);
}
}
Java 7
https://ko.wikipedia.org/wiki/함수형_프로그래
밍
public static <E extends Comparable<? super E>>
List<E> quickSort(List<E> arr) {
if (!arr.isEmpty()) {
E pivot = arr.get(0); //This pivot can change
to get faster results
List<E> less = new LinkedList<E>();
List<E> pivotList = new LinkedList<E>();
List<E> more = new LinkedList<E>();
for (E i: arr) {
if (i.compareTo(pivot) < 0)
less.add(i);
else if (i.compareTo(pivot) > 0)
more.add(i);
else
pivotList.add(i);
}
less = quickSort(less);
more = quickSort(more);
less.addAll(pivotList);
less.addAll(more);
return less;
}
return arr;
}
http://rosettacode.org/wiki/Sorting_algorithms/Quicksort#Java
Java 7
public static <T> List<T> Quicksort(List<T> v, BiFunction<T, T,
Integer> comparer) {
if (v.size() < 2)
return v;
T pivot = v.get(v.size() / 2);
List<T> l = new LinkedList<T>(Quicksort(v.stream()
.filter(x -> comparer.apply(x, pivot) < 0)
.collect(Collectors.toList()), comparer));
l.addAll( v.stream().filter(x -> comparer
.apply(x, pivot) == 0).collect(Collectors.toList()) );
l.addAll( Quicksort(v.stream()
.filter(x -> comparer.apply(x, pivot) > 0)
.collect(Collectors.toList()), comparer) );
return l;
}
Java 8
qsort [] = []
qsort (x:xs) = qsort (filter (< x) xs) ++ [x] ++ qsort (filter (>= x) xs)
https://en.wikibooks.org/wiki/Algorithm_Implementation/Sorting/Quicksort#Haskell
Haskell
package org.ingini.spark.java8;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.TreeMap;
import static java.util.function.Function.identity;
import static java.util.stream.Collectors.counting;
import static java.util.stream.Collectors.groupingBy;
public class WordsCounterJava {
public static final String REGEX = "s+";
public TreeMap<String, Long> count(String source) throws IOException {
return Files.lines(Paths.get(source))
.map(line -> line.split(REGEX))
.flatMap(Arrays::stream)
.collect(groupingBy(identity(), TreeMap::new, counting()));
}
}
-Djava.util.concurrent.ForkJoinPool.common.parallelism=1
SELECT * FROM BOOK
WHERE BOOK.PUBLISHED_IN = 2011
ORDER BY BOOK.TITLE
jOOQ
create.selectFrom(BOOK)
.where(BOOK.PUBLISHED_IN.eq(2011))
.orderBy(BOOK.TITLE)
http://www.jooq.org/
http://java2practice.com/2014/03/16/java-8-functional-interface-example/
Thread t =new Thread(new Runnable(){
public void run(){
System.out.println("Runnable implemented by using Lambda Expression");
}
});
Thread t = new Thread(()->{
System.out.println("Runnable implemented by using Lambda Expression");
});
Java 7
Java 8
interface DefaultInterfaceTest{
void show();
default void display(){
System.out.println("Default method from interface can have body..!");
}
}
public class DefaultInterfaceTestImpl implements DefaultInterfaceTest{
public void show(){
System.out.println("show method");
}
//we dont need to provide any implementation to default method.
public static void main(String[] args){
DefaultInterfaceTest obj = new DefaultInterfaceTestImpl();
obj.show();//out puts: show method
obj.display();//outputs : Default method from interface can have body..!
}
}
Default Method
•Function <T, R> - T를 입력으로 R을 출력으로 반환
•Predicate <T> - T를 입력으로 boolean을 출력으로 반환
•Consumer <T> - T를 입력으로 아무것도 반환하지 않는다
•Supplier <T> - 입력을 취하지 않고 T를 반환
•BinaryOperator <T> - 2 개의 T를 입력으로 하나의 T를 출력으로
반환
http://www.ibm.com/developerworks/library/j-jvmc2/index.html
Runnable task = () -> {
String threadName = Thread.currentThread().getName();
System.out.println("Hello " + threadName);
};
task.run();
Thread thread = new Thread(task);
thread.start();
ExecutorService executor = Executors.newSingleThreadExecutor();
executor.submit(() -> {
String threadName = Thread.currentThread().getName();
System.out.println("Hello " + threadName);
});
try {
//attempt to shutdown executor
executor.shutdown();
executor.awaitTermination(5, TimeUnit.SECONDS);
}
catch (InterruptedException e) {
System.err.println("tasks interrupted");
}
finally {
if (!executor.isTerminated()) {
executor.shutdownNow();
}
System.out.println("shutdown finished");
}
Executors
http://winterbe.com/posts/2015/04/07/java8-concurrency-tutorial-thread-executor-examples/
http://ariya.ofilabs.com/2014/03/nashorn-the-new-rhino-on-the-block.html
interface CustomerRepository extends Repository<Customer, Long> {
@Query("select c from Customer c")
Stream<Customer> streamAllCustomers();
}
try (Stream<Customer> customers = repository.streamAllCustomers()) {
// use the stream here
}
Support for JDK 8' Stream in repository methods
interface CustomerRepository extends Repository<Customer, Long> {
@Async
CompletableFuture<List<Customer>> readAllBy();
}
CompletableFuture<List<Customer>> future =
repository.readAllBy().thenApply(this::doSomethingWithCustomers);
while (!future.isDone()) {
log.info("Waiting for the CompletableFuture to finish...");
TimeUnit.MILLISECONDS.sleep(500);
}
List<Customer> processedCustomers = future.get();
http://doc.akka.io/docs/akka/2.3.0-RC1/java/lambda-actors.html
import akka.actor.AbstractActor;
import akka.event.Logging;
import akka.event.LoggingAdapter;
import akka.japi.pf.ReceiveBuilder;
import scala.PartialFunction;
import scala.runtime.BoxedUnit;
public class MyActor extends AbstractActor {
private final LoggingAdapter log = Logging.getLogger(context().system(), this);
@Override
public PartialFunction<Object, BoxedUnit> receive() {
return ReceiveBuilder.
match(String.class, s -> s.equals("test"), s -> log.info("received test")).
matchAny(o -> log.info("received unknown message")).build();
}
}
https://blogs.oracle.com/javatraining/entry/announcing_jdk_8_mooc_lambdas
모던자바의 역습
모던자바의 역습
모던자바의 역습
모던자바의 역습
모던자바의 역습
모던자바의 역습
모던자바의 역습
모던자바의 역습
모던자바의 역습
모던자바의 역습
모던자바의 역습
모던자바의 역습

More Related Content

What's hot

Code generation for alternative languages
Code generation for alternative languagesCode generation for alternative languages
Code generation for alternative languagesRafael Winterhalter
 
Functional Thinking - Programming with Lambdas in Java 8
Functional Thinking - Programming with Lambdas in Java 8Functional Thinking - Programming with Lambdas in Java 8
Functional Thinking - Programming with Lambdas in Java 8Ganesh Samarthyam
 
Advanced Debugging Using Java Bytecodes
Advanced Debugging Using Java BytecodesAdvanced Debugging Using Java Bytecodes
Advanced Debugging Using Java BytecodesGanesh Samarthyam
 
Modern Programming in Java 8 - Lambdas, Streams and Date Time API
Modern Programming in Java 8 - Lambdas, Streams and Date Time APIModern Programming in Java 8 - Lambdas, Streams and Date Time API
Modern Programming in Java 8 - Lambdas, Streams and Date Time APIGanesh Samarthyam
 
New Features in JDK 8
New Features in JDK 8New Features in JDK 8
New Features in JDK 8Martin Toshev
 
Advance Java Programs skeleton
Advance Java Programs skeletonAdvance Java Programs skeleton
Advance Java Programs skeletonIram Ramrajkar
 
Java 8 presentation
Java 8 presentationJava 8 presentation
Java 8 presentationVan Huong
 
Basic Javascript
Basic JavascriptBasic Javascript
Basic JavascriptBunlong Van
 
Oredev 2015 - Taming Java Agents
Oredev 2015 - Taming Java AgentsOredev 2015 - Taming Java Agents
Oredev 2015 - Taming Java AgentsAnton Arhipov
 
Getting started with Java 9 modules
Getting started with Java 9 modulesGetting started with Java 9 modules
Getting started with Java 9 modulesRafael Winterhalter
 
Voxxed Days Vilnius 2015 - Having fun with Javassist
Voxxed Days Vilnius 2015 - Having fun with JavassistVoxxed Days Vilnius 2015 - Having fun with Javassist
Voxxed Days Vilnius 2015 - Having fun with JavassistAnton Arhipov
 

What's hot (20)

Java 8 Feature Preview
Java 8 Feature PreviewJava 8 Feature Preview
Java 8 Feature Preview
 
Code generation for alternative languages
Code generation for alternative languagesCode generation for alternative languages
Code generation for alternative languages
 
Java Concurrency by Example
Java Concurrency by ExampleJava Concurrency by Example
Java Concurrency by Example
 
Functional Thinking - Programming with Lambdas in Java 8
Functional Thinking - Programming with Lambdas in Java 8Functional Thinking - Programming with Lambdas in Java 8
Functional Thinking - Programming with Lambdas in Java 8
 
Java 8 features
Java 8 featuresJava 8 features
Java 8 features
 
Java 8: the good parts!
Java 8: the good parts!Java 8: the good parts!
Java 8: the good parts!
 
Sailing with Java 8 Streams
Sailing with Java 8 StreamsSailing with Java 8 Streams
Sailing with Java 8 Streams
 
Advanced Debugging Using Java Bytecodes
Advanced Debugging Using Java BytecodesAdvanced Debugging Using Java Bytecodes
Advanced Debugging Using Java Bytecodes
 
Modern Programming in Java 8 - Lambdas, Streams and Date Time API
Modern Programming in Java 8 - Lambdas, Streams and Date Time APIModern Programming in Java 8 - Lambdas, Streams and Date Time API
Modern Programming in Java 8 - Lambdas, Streams and Date Time API
 
New Features in JDK 8
New Features in JDK 8New Features in JDK 8
New Features in JDK 8
 
Advance Java Programs skeleton
Advance Java Programs skeletonAdvance Java Programs skeleton
Advance Java Programs skeleton
 
Java 5 and 6 New Features
Java 5 and 6 New FeaturesJava 5 and 6 New Features
Java 5 and 6 New Features
 
Java 8 presentation
Java 8 presentationJava 8 presentation
Java 8 presentation
 
Basic Javascript
Basic JavascriptBasic Javascript
Basic Javascript
 
Oredev 2015 - Taming Java Agents
Oredev 2015 - Taming Java AgentsOredev 2015 - Taming Java Agents
Oredev 2015 - Taming Java Agents
 
Java SE 8 best practices
Java SE 8 best practicesJava SE 8 best practices
Java SE 8 best practices
 
Java8 features
Java8 featuresJava8 features
Java8 features
 
Getting started with Java 9 modules
Getting started with Java 9 modulesGetting started with Java 9 modules
Getting started with Java 9 modules
 
Voxxed Days Vilnius 2015 - Having fun with Javassist
Voxxed Days Vilnius 2015 - Having fun with JavassistVoxxed Days Vilnius 2015 - Having fun with Javassist
Voxxed Days Vilnius 2015 - Having fun with Javassist
 
Smart Migration to JDK 8
Smart Migration to JDK 8Smart Migration to JDK 8
Smart Migration to JDK 8
 

Viewers also liked

Java9 특징 훑어보기
Java9 특징 훑어보기Java9 특징 훑어보기
Java9 특징 훑어보기duriepark 유현석
 
자바9 특징 (Java9 Features)
자바9 특징 (Java9 Features)자바9 특징 (Java9 Features)
자바9 특징 (Java9 Features)Chang-Hwan Han
 
java 8 람다식 소개와 의미 고찰
java 8 람다식 소개와 의미 고찰java 8 람다식 소개와 의미 고찰
java 8 람다식 소개와 의미 고찰Sungchul Park
 
발렌타인 웨비너 7회 - React를 이용한 웹 앱 개발 살펴보기
발렌타인 웨비너 7회 - React를 이용한 웹 앱 개발 살펴보기발렌타인 웨비너 7회 - React를 이용한 웹 앱 개발 살펴보기
발렌타인 웨비너 7회 - React를 이용한 웹 앱 개발 살펴보기DoHyun Jung
 
우리가 모르는 노드로 할 수 있는 몇가지
우리가 모르는 노드로 할 수 있는 몇가지우리가 모르는 노드로 할 수 있는 몇가지
우리가 모르는 노드로 할 수 있는 몇가지Rhio Kim
 
SOSCON2015 SI이노베이션
SOSCON2015 SI이노베이션SOSCON2015 SI이노베이션
SOSCON2015 SI이노베이션DoHyun Jung
 
JavaScript Debugging (수업자료)
JavaScript Debugging (수업자료)JavaScript Debugging (수업자료)
JavaScript Debugging (수업자료)지수 윤
 
현재 자바스크립트 표준은 어디쯤
현재 자바스크립트 표준은 어디쯤 현재 자바스크립트 표준은 어디쯤
현재 자바스크립트 표준은 어디쯤 Dai-Hyun Lim
 
자바8 나머지 공개
자바8 나머지 공개자바8 나머지 공개
자바8 나머지 공개Sungchul Park
 
Electron 개발하기
Electron 개발하기Electron 개발하기
Electron 개발하기성일 한
 
9주 dom & event advanced 실습
9주  dom & event advanced 실습9주  dom & event advanced 실습
9주 dom & event advanced 실습지수 윤
 
VAADIN으로 스크립트 없는 자바 웹 애플리케이션 만들기
VAADIN으로 스크립트 없는 자바 웹 애플리케이션 만들기 VAADIN으로 스크립트 없는 자바 웹 애플리케이션 만들기
VAADIN으로 스크립트 없는 자바 웹 애플리케이션 만들기 Jae-il Lee
 
At Your Service: Using Jenkins in Operations
At Your Service: Using Jenkins in OperationsAt Your Service: Using Jenkins in Operations
At Your Service: Using Jenkins in OperationsMandi Walls
 
차세대 웹 플랫폼과 HTML5 기술 동향
차세대 웹 플랫폼과 HTML5 기술 동향차세대 웹 플랫폼과 HTML5 기술 동향
차세대 웹 플랫폼과 HTML5 기술 동향Jonathan Jeon
 
Javascript Test Double Sinon.js
Javascript Test Double Sinon.jsJavascript Test Double Sinon.js
Javascript Test Double Sinon.js우영 주
 
Akka라이브러리를 이용해 구현하는 결함 내성 (발렌타인 발표자료)
Akka라이브러리를 이용해 구현하는 결함 내성 (발렌타인 발표자료)Akka라이브러리를 이용해 구현하는 결함 내성 (발렌타인 발표자료)
Akka라이브러리를 이용해 구현하는 결함 내성 (발렌타인 발표자료)DoHyun Jung
 
Spring 4.x Web Application 살펴보기
Spring 4.x Web Application  살펴보기Spring 4.x Web Application  살펴보기
Spring 4.x Web Application 살펴보기Ji Heon Kim
 
비전공자의 자바스크립트 도전기
비전공자의 자바스크립트 도전기비전공자의 자바스크립트 도전기
비전공자의 자바스크립트 도전기jeong seok yang
 

Viewers also liked (20)

Java9 특징 훑어보기
Java9 특징 훑어보기Java9 특징 훑어보기
Java9 특징 훑어보기
 
자바9 특징 (Java9 Features)
자바9 특징 (Java9 Features)자바9 특징 (Java9 Features)
자바9 특징 (Java9 Features)
 
java 8 람다식 소개와 의미 고찰
java 8 람다식 소개와 의미 고찰java 8 람다식 소개와 의미 고찰
java 8 람다식 소개와 의미 고찰
 
발렌타인 웨비너 7회 - React를 이용한 웹 앱 개발 살펴보기
발렌타인 웨비너 7회 - React를 이용한 웹 앱 개발 살펴보기발렌타인 웨비너 7회 - React를 이용한 웹 앱 개발 살펴보기
발렌타인 웨비너 7회 - React를 이용한 웹 앱 개발 살펴보기
 
우리가 모르는 노드로 할 수 있는 몇가지
우리가 모르는 노드로 할 수 있는 몇가지우리가 모르는 노드로 할 수 있는 몇가지
우리가 모르는 노드로 할 수 있는 몇가지
 
SOSCON2015 SI이노베이션
SOSCON2015 SI이노베이션SOSCON2015 SI이노베이션
SOSCON2015 SI이노베이션
 
JavaScript Debugging (수업자료)
JavaScript Debugging (수업자료)JavaScript Debugging (수업자료)
JavaScript Debugging (수업자료)
 
현재 자바스크립트 표준은 어디쯤
현재 자바스크립트 표준은 어디쯤 현재 자바스크립트 표준은 어디쯤
현재 자바스크립트 표준은 어디쯤
 
자바8 나머지 공개
자바8 나머지 공개자바8 나머지 공개
자바8 나머지 공개
 
Electron 개발하기
Electron 개발하기Electron 개발하기
Electron 개발하기
 
9주 dom & event advanced 실습
9주  dom & event advanced 실습9주  dom & event advanced 실습
9주 dom & event advanced 실습
 
VAADIN으로 스크립트 없는 자바 웹 애플리케이션 만들기
VAADIN으로 스크립트 없는 자바 웹 애플리케이션 만들기 VAADIN으로 스크립트 없는 자바 웹 애플리케이션 만들기
VAADIN으로 스크립트 없는 자바 웹 애플리케이션 만들기
 
At Your Service: Using Jenkins in Operations
At Your Service: Using Jenkins in OperationsAt Your Service: Using Jenkins in Operations
At Your Service: Using Jenkins in Operations
 
차세대 웹 플랫폼과 HTML5 기술 동향
차세대 웹 플랫폼과 HTML5 기술 동향차세대 웹 플랫폼과 HTML5 기술 동향
차세대 웹 플랫폼과 HTML5 기술 동향
 
Javascript Test Double Sinon.js
Javascript Test Double Sinon.jsJavascript Test Double Sinon.js
Javascript Test Double Sinon.js
 
Akka라이브러리를 이용해 구현하는 결함 내성 (발렌타인 발표자료)
Akka라이브러리를 이용해 구현하는 결함 내성 (발렌타인 발표자료)Akka라이브러리를 이용해 구현하는 결함 내성 (발렌타인 발표자료)
Akka라이브러리를 이용해 구현하는 결함 내성 (발렌타인 발표자료)
 
DDD 준비 서문래
DDD 준비 서문래DDD 준비 서문래
DDD 준비 서문래
 
Spring 4.x Web Application 살펴보기
Spring 4.x Web Application  살펴보기Spring 4.x Web Application  살펴보기
Spring 4.x Web Application 살펴보기
 
비전공자의 자바스크립트 도전기
비전공자의 자바스크립트 도전기비전공자의 자바스크립트 도전기
비전공자의 자바스크립트 도전기
 
RESTful Java
RESTful JavaRESTful Java
RESTful Java
 

Similar to 모던자바의 역습

201913046 wahyu septiansyah network programing
201913046 wahyu septiansyah network programing201913046 wahyu septiansyah network programing
201913046 wahyu septiansyah network programingwahyuseptiansyah
 
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 JVMRafael Winterhalter
 
DevNexus 2020: Discover Modern Java
DevNexus 2020: Discover Modern JavaDevNexus 2020: Discover Modern Java
DevNexus 2020: Discover Modern JavaHenri Tremblay
 
JavaOne 2016 - Learn Lambda and functional programming
JavaOne 2016 - Learn Lambda and functional programmingJavaOne 2016 - Learn Lambda and functional programming
JavaOne 2016 - Learn Lambda and functional programmingHenri Tremblay
 
Xopus Application Framework
Xopus Application FrameworkXopus Application Framework
Xopus Application FrameworkJady Yang
 
Atlassian Groovy Plugins
Atlassian Groovy PluginsAtlassian Groovy Plugins
Atlassian Groovy PluginsPaul King
 
Java and SPARQL
Java and SPARQLJava and SPARQL
Java and SPARQLRaji Ghawi
 
Jersey framework
Jersey frameworkJersey framework
Jersey frameworkknight1128
 
Fighting Fear-Driven-Development With PHPUnit
Fighting Fear-Driven-Development With PHPUnitFighting Fear-Driven-Development With PHPUnit
Fighting Fear-Driven-Development With PHPUnitJames Fuller
 
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 OredevMattias Karlsson
 

Similar to 모던자바의 역습 (20)

201913046 wahyu septiansyah network programing
201913046 wahyu septiansyah network programing201913046 wahyu septiansyah network programing
201913046 wahyu septiansyah network programing
 
Java 7 & 8 New Features
Java 7 & 8 New FeaturesJava 7 & 8 New Features
Java 7 & 8 New Features
 
Server1
Server1Server1
Server1
 
3 j unit
3 j unit3 j unit
3 j unit
 
Modern Java Development
Modern Java DevelopmentModern Java Development
Modern Java Development
 
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
 
DevNexus 2020: Discover Modern Java
DevNexus 2020: Discover Modern JavaDevNexus 2020: Discover Modern Java
DevNexus 2020: Discover Modern Java
 
JavaOne 2016 - Learn Lambda and functional programming
JavaOne 2016 - Learn Lambda and functional programmingJavaOne 2016 - Learn Lambda and functional programming
JavaOne 2016 - Learn Lambda and functional programming
 
Xopus Application Framework
Xopus Application FrameworkXopus Application Framework
Xopus Application Framework
 
JUnit 5
JUnit 5JUnit 5
JUnit 5
 
Pimp My Java LavaJUG
Pimp My Java LavaJUGPimp My Java LavaJUG
Pimp My Java LavaJUG
 
Slides
SlidesSlides
Slides
 
Java API, Exceptions and IO
Java API, Exceptions and IOJava API, Exceptions and IO
Java API, Exceptions and IO
 
Atlassian Groovy Plugins
Atlassian Groovy PluginsAtlassian Groovy Plugins
Atlassian Groovy Plugins
 
Java and SPARQL
Java and SPARQLJava and SPARQL
Java and SPARQL
 
Jersey framework
Jersey frameworkJersey framework
Jersey framework
 
Fighting Fear-Driven-Development With PHPUnit
Fighting Fear-Driven-Development With PHPUnitFighting Fear-Driven-Development With PHPUnit
Fighting Fear-Driven-Development With PHPUnit
 
My java file
My java fileMy java file
My java file
 
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
 
Nantes Jug - Java 7
Nantes Jug - Java 7Nantes Jug - Java 7
Nantes Jug - Java 7
 

Recently uploaded

VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics
 
ETE PPT.pdf LMMKLMKLMLKMLLMJKBHJBHBNUIHBU
ETE PPT.pdf LMMKLMKLMLKMLLMJKBHJBHBNUIHBUETE PPT.pdf LMMKLMKLMLKMLLMJKBHJBHBNUIHBU
ETE PPT.pdf LMMKLMKLMLKMLLMJKBHJBHBNUIHBUsamruddhijedgule2004
 
Advantages of Cargo Cloud Solutions.pptx
Advantages of Cargo Cloud Solutions.pptxAdvantages of Cargo Cloud Solutions.pptx
Advantages of Cargo Cloud Solutions.pptxRTS corp
 
What is Mendix and the concept of low-code development.docx
What is Mendix and the concept of low-code development.docxWhat is Mendix and the concept of low-code development.docx
What is Mendix and the concept of low-code development.docxTechnogeeks
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldRoberto Pérez Alcolea
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...Bert Jan Schrijver
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesVictoriaMetrics
 
What are the core components of Azure Data Engineer courses.docx
What are the core components of Azure Data Engineer courses.docxWhat are the core components of Azure Data Engineer courses.docx
What are the core components of Azure Data Engineer courses.docxkzayra69
 
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdfAndrey Devyatkin
 
OpenMetadata Community Meeting - 4th April, 2024
OpenMetadata Community Meeting - 4th April, 2024OpenMetadata Community Meeting - 4th April, 2024
OpenMetadata Community Meeting - 4th April, 2024OpenMetadata
 
Explore the Three Main Types of Logistics - Inbound Logistics, Outbound Logis...
Explore the Three Main Types of Logistics - Inbound Logistics, Outbound Logis...Explore the Three Main Types of Logistics - Inbound Logistics, Outbound Logis...
Explore the Three Main Types of Logistics - Inbound Logistics, Outbound Logis...Piyovi
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorTier1 app
 
eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolsosttopstonverter
 
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdfPros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdfkalichargn70th171
 
The State of the Green IT at the beginning of 2024
The State of the Green IT at the beginning of 2024The State of the Green IT at the beginning of 2024
The State of the Green IT at the beginning of 2024Artur Skowroński
 
Santander Stream Processing with Apache Flink
Santander Stream Processing with Apache FlinkSantander Stream Processing with Apache Flink
Santander Stream Processing with Apache Flinkconfluent
 
Introduction to Firebase Workshop Slides
Introduction to Firebase Workshop SlidesIntroduction to Firebase Workshop Slides
Introduction to Firebase Workshop Slidesvaideheekore1
 
AmsterdamJUG April 2024 - Going serverless with Quarkus GraalVM native images...
AmsterdamJUG April 2024 - Going serverless with Quarkus GraalVM native images...AmsterdamJUG April 2024 - Going serverless with Quarkus GraalVM native images...
AmsterdamJUG April 2024 - Going serverless with Quarkus GraalVM native images...Bert Jan Schrijver
 
logical backup of Oracle Datapump-detailed.pptx
logical backup of Oracle Datapump-detailed.pptxlogical backup of Oracle Datapump-detailed.pptx
logical backup of Oracle Datapump-detailed.pptxRemote DBA Services
 
SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?Alexandre Beguel
 

Recently uploaded (20)

VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
 
ETE PPT.pdf LMMKLMKLMLKMLLMJKBHJBHBNUIHBU
ETE PPT.pdf LMMKLMKLMLKMLLMJKBHJBHBNUIHBUETE PPT.pdf LMMKLMKLMLKMLLMJKBHJBHBNUIHBU
ETE PPT.pdf LMMKLMKLMLKMLLMJKBHJBHBNUIHBU
 
Advantages of Cargo Cloud Solutions.pptx
Advantages of Cargo Cloud Solutions.pptxAdvantages of Cargo Cloud Solutions.pptx
Advantages of Cargo Cloud Solutions.pptx
 
What is Mendix and the concept of low-code development.docx
What is Mendix and the concept of low-code development.docxWhat is Mendix and the concept of low-code development.docx
What is Mendix and the concept of low-code development.docx
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository world
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 Updates
 
What are the core components of Azure Data Engineer courses.docx
What are the core components of Azure Data Engineer courses.docxWhat are the core components of Azure Data Engineer courses.docx
What are the core components of Azure Data Engineer courses.docx
 
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
 
OpenMetadata Community Meeting - 4th April, 2024
OpenMetadata Community Meeting - 4th April, 2024OpenMetadata Community Meeting - 4th April, 2024
OpenMetadata Community Meeting - 4th April, 2024
 
Explore the Three Main Types of Logistics - Inbound Logistics, Outbound Logis...
Explore the Three Main Types of Logistics - Inbound Logistics, Outbound Logis...Explore the Three Main Types of Logistics - Inbound Logistics, Outbound Logis...
Explore the Three Main Types of Logistics - Inbound Logistics, Outbound Logis...
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryError
 
eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration tools
 
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdfPros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
 
The State of the Green IT at the beginning of 2024
The State of the Green IT at the beginning of 2024The State of the Green IT at the beginning of 2024
The State of the Green IT at the beginning of 2024
 
Santander Stream Processing with Apache Flink
Santander Stream Processing with Apache FlinkSantander Stream Processing with Apache Flink
Santander Stream Processing with Apache Flink
 
Introduction to Firebase Workshop Slides
Introduction to Firebase Workshop SlidesIntroduction to Firebase Workshop Slides
Introduction to Firebase Workshop Slides
 
AmsterdamJUG April 2024 - Going serverless with Quarkus GraalVM native images...
AmsterdamJUG April 2024 - Going serverless with Quarkus GraalVM native images...AmsterdamJUG April 2024 - Going serverless with Quarkus GraalVM native images...
AmsterdamJUG April 2024 - Going serverless with Quarkus GraalVM native images...
 
logical backup of Oracle Datapump-detailed.pptx
logical backup of Oracle Datapump-detailed.pptxlogical backup of Oracle Datapump-detailed.pptx
logical backup of Oracle Datapump-detailed.pptx
 
SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?
 

모던자바의 역습

  • 1.
  • 2. 김대우 젬플레이 이사 http://lekdw.blogspot.kr/ 정도현(정개발) 나는 프로그래머다 MC 일본 Mamezou소속 컨설턴트 http://Iamprogrammer.io http://moreagile.net
  • 3.
  • 6. J2SE 5.0 Java SE 7 Java SE 8 https://en.wikipedia.org/wiki/Java_version_history
  • 7.
  • 8.
  • 9.
  • 10.
  • 12.
  • 18. 모바일 게임 서버와 같이 Life Cycle이 짧은 데이터(객체)를 주로 처리하 는 경우, 별다른 튜닝없이 -server, -d64, -Xms, -Xmx 옵션으로 충분.
  • 19.
  • 20.
  • 21.
  • 22. http://www.drdobbs.com/jvm/the-comparative-productivity-of-programm/240005881 Language Hours Per Function Point ASP* 06.1 Visual Basic 08.5 Java 10.6 SQL 10.8 C++ 12.4 C 13.0 C# 15.5 PL/1 14.2 COBOL 16.8 ABAP 19.9
  • 23.
  • 25.
  • 26.
  • 28. JUnit SLF4J API Module Scala Library Logback Classic Module Guava: Google Core Libraries for Java Mockito Google APIs Client Library for Java Apache Log4j Commons IO SLF4J LOG4J-12 Binding osgi.core JavaServlet(TM) Specification TestNG ScalaTest Commons Lang Joda-Time Spring Context Mockito H2 Database Engine Java Servlet API http://www.77dev.com/2014/05/java-trends-top-100-mostly-used.html
  • 29. JCL 1.1.1 implemented over SLF4J jackson-databind SLF4J Simple Binding Apache CommonsCodec Apache HttpClient Apache Commons Lang Commons Logging Spring Core osgi.cmpn Google Guice - Core Library SpringTestContext Framework Jetty :: Server Core Maven Plugin API FindBugs-jsr305 BeanValidation API Spring Beans Groovy Jackson-core EasyMock Spock Framework - Core Module
  • 30.
  • 31. Java8
  • 32.
  • 34. private List m_list=null; private int process_file(String str_file_name){ String str_line; List list_lines=new ArrayList(); int i_result=read_file(str_file_name,list_lines); if(i_result==0){ List list_record=new ArrayList(); for(int i=0;i<list_lines.size();i++){ str_line=(String)list_lines.get(i); Record record=new Record(); i_result=parse_line(str_line,record); if(i_result!=0){ return i_result; } list_recordord.add(record); } m_list=list_record; return 0; }else{ return i_result; } } http://www.slideshare.net/shintanimoto/from-old-java-to-modern-java C-ish java
  • 35. private List resultList; private List processFile(String fileName)throws SystemException { List lines = readFile(fileName); List recordList = new ArrayList(); for (int i = 0; i < lines.size(); i++) { String line = (String) lines.get(i); Record record = parseLine(line); recordList.add(record); } return recordList; } http://www.slideshare.net/shintanimoto/from-old-java-to-modern-java Java 1.4
  • 36. private List<Record> processFile(String fileName)throws SystemException { List<String> lines = readFile(fileName); List<Record> recordList = new ArrayList(); for (String line : lines) { Record record = parseLine(line); recordList.add(record); } return recordList; } Java 1.7 generic + foreach
  • 37.
  • 38. 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) { throw new SystemException(FILE_NOT_FOUND, ex); } catch (IOException ex) { throw new SystemException(FILE_READ_ERROR, ex); } finally { try { if (reader != null) { reader.close(); } } catch (IOException ex) { // 이건 무시? } } return lines; }
  • 39. private List<String> readFile(String fileName) { List<String> lines = new ArrayList<>(); try (FileReader in = new FileReader(fileName); BufferedReader reader = new BufferedReader(in)) { String line; while ((line = reader.readLine()) != null) { lines.add(line); } } catch (FileNotFoundException ex) { throw new SystemException(FILE_NOT_FOUND, ex); } catch (IOException ex) { throw new SystemException(FILE_READ_ERROR, ex); } return lines; } Java 7
  • 40. private List<String> readFile(String fileName) { try { return Files.readAllLines(Paths.get(fileName), Charset.defaultCharset()); } catch (IOException ex) { throw new SystemException(FILE_READ_ERROR, ex); } } Java 7
  • 42.
  • 43. public static <E extends Comparable<? super E>> List<E> quickSort(List<E> arr) { if (!arr.isEmpty()) { E pivot = arr.get(0); //This pivot can change to get faster results List<E> less = new LinkedList<E>(); List<E> pivotList = new LinkedList<E>(); List<E> more = new LinkedList<E>(); for (E i: arr) { if (i.compareTo(pivot) < 0) less.add(i); else if (i.compareTo(pivot) > 0) more.add(i); else pivotList.add(i); } less = quickSort(less); more = quickSort(more); less.addAll(pivotList); less.addAll(more); return less; } return arr; } http://rosettacode.org/wiki/Sorting_algorithms/Quicksort#Java Java 7
  • 44. public static <T> List<T> Quicksort(List<T> v, BiFunction<T, T, Integer> comparer) { if (v.size() < 2) return v; T pivot = v.get(v.size() / 2); List<T> l = new LinkedList<T>(Quicksort(v.stream() .filter(x -> comparer.apply(x, pivot) < 0) .collect(Collectors.toList()), comparer)); l.addAll( v.stream().filter(x -> comparer .apply(x, pivot) == 0).collect(Collectors.toList()) ); l.addAll( Quicksort(v.stream() .filter(x -> comparer.apply(x, pivot) > 0) .collect(Collectors.toList()), comparer) ); return l; } Java 8
  • 45. qsort [] = [] qsort (x:xs) = qsort (filter (< x) xs) ++ [x] ++ qsort (filter (>= x) xs) https://en.wikibooks.org/wiki/Algorithm_Implementation/Sorting/Quicksort#Haskell Haskell
  • 46.
  • 47. package org.ingini.spark.java8; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.Arrays; import java.util.TreeMap; import static java.util.function.Function.identity; import static java.util.stream.Collectors.counting; import static java.util.stream.Collectors.groupingBy; public class WordsCounterJava { public static final String REGEX = "s+"; public TreeMap<String, Long> count(String source) throws IOException { return Files.lines(Paths.get(source)) .map(line -> line.split(REGEX)) .flatMap(Arrays::stream) .collect(groupingBy(identity(), TreeMap::new, counting())); } }
  • 49. SELECT * FROM BOOK WHERE BOOK.PUBLISHED_IN = 2011 ORDER BY BOOK.TITLE jOOQ create.selectFrom(BOOK) .where(BOOK.PUBLISHED_IN.eq(2011)) .orderBy(BOOK.TITLE) http://www.jooq.org/
  • 50.
  • 51. http://java2practice.com/2014/03/16/java-8-functional-interface-example/ Thread t =new Thread(new Runnable(){ public void run(){ System.out.println("Runnable implemented by using Lambda Expression"); } }); Thread t = new Thread(()->{ System.out.println("Runnable implemented by using Lambda Expression"); }); Java 7 Java 8
  • 52. interface DefaultInterfaceTest{ void show(); default void display(){ System.out.println("Default method from interface can have body..!"); } } public class DefaultInterfaceTestImpl implements DefaultInterfaceTest{ public void show(){ System.out.println("show method"); } //we dont need to provide any implementation to default method. public static void main(String[] args){ DefaultInterfaceTest obj = new DefaultInterfaceTestImpl(); obj.show();//out puts: show method obj.display();//outputs : Default method from interface can have body..! } } Default Method
  • 53.
  • 54. •Function <T, R> - T를 입력으로 R을 출력으로 반환 •Predicate <T> - T를 입력으로 boolean을 출력으로 반환 •Consumer <T> - T를 입력으로 아무것도 반환하지 않는다 •Supplier <T> - 입력을 취하지 않고 T를 반환 •BinaryOperator <T> - 2 개의 T를 입력으로 하나의 T를 출력으로 반환
  • 56. Runnable task = () -> { String threadName = Thread.currentThread().getName(); System.out.println("Hello " + threadName); }; task.run(); Thread thread = new Thread(task); thread.start();
  • 57. ExecutorService executor = Executors.newSingleThreadExecutor(); executor.submit(() -> { String threadName = Thread.currentThread().getName(); System.out.println("Hello " + threadName); }); try { //attempt to shutdown executor executor.shutdown(); executor.awaitTermination(5, TimeUnit.SECONDS); } catch (InterruptedException e) { System.err.println("tasks interrupted"); } finally { if (!executor.isTerminated()) { executor.shutdownNow(); } System.out.println("shutdown finished"); } Executors http://winterbe.com/posts/2015/04/07/java8-concurrency-tutorial-thread-executor-examples/
  • 59. interface CustomerRepository extends Repository<Customer, Long> { @Query("select c from Customer c") Stream<Customer> streamAllCustomers(); } try (Stream<Customer> customers = repository.streamAllCustomers()) { // use the stream here } Support for JDK 8' Stream in repository methods
  • 60. interface CustomerRepository extends Repository<Customer, Long> { @Async CompletableFuture<List<Customer>> readAllBy(); } CompletableFuture<List<Customer>> future = repository.readAllBy().thenApply(this::doSomethingWithCustomers); while (!future.isDone()) { log.info("Waiting for the CompletableFuture to finish..."); TimeUnit.MILLISECONDS.sleep(500); } List<Customer> processedCustomers = future.get();
  • 61. http://doc.akka.io/docs/akka/2.3.0-RC1/java/lambda-actors.html import akka.actor.AbstractActor; import akka.event.Logging; import akka.event.LoggingAdapter; import akka.japi.pf.ReceiveBuilder; import scala.PartialFunction; import scala.runtime.BoxedUnit; public class MyActor extends AbstractActor { private final LoggingAdapter log = Logging.getLogger(context().system(), this); @Override public PartialFunction<Object, BoxedUnit> receive() { return ReceiveBuilder. match(String.class, s -> s.equals("test"), s -> log.info("received test")). matchAny(o -> log.info("received unknown message")).build(); } }