1,a) 1,b) 1,c) Java 214 Java Java Java 1 13 3 Stream Optional 18% Stream 5% Stream JDK6/7 Java Stream Optional 1. [1], [2], [3] [4] 2 1 a) h-tanaka@ist.osaka-u.ac.jp b) shinsuke@ist.osaka-u.ac.jp c) kusumoto@ist.osaka-u.ac.jp [5] Java Java Java 214 Java 8 / Java 8 Stream Optional 3 3 Research Question RQ c 218 Information Processing Society of Japan 184
RQ1: RQ2: / RQ3: 2. 2.1 Java 8 2.1.1 [6] List < Integer > list =...; list. foreach (s -> System.out.println(s)); -> 3 Collection list 2.1.2 Stream Stream Stream List < Integer > list =...; list.stream().filter(i -> i > ).foreach(i -> System.out.println(i)); Stream 1 Stream 1 Stream Collection stream() Stream API Stream Stream filter() Stream 2.1.3 Optional Optional null null Optional List < Integer > list =...; int val = Optional.ofNullable(list.get(3)).orElseGet(); list 3 null null val Optional null Optional 2.2 Java [7], [8] Java [9] Stream Stream Stream [1] Stream Stream foreach 1 [5] Java Java Java 3. Research Questions Java 3 Research Question RQ1: 2 Java c 218 Information Processing Society of Japan 185
Java RQ Java 8 4 Java RQ2: / Java Java RQ3: Java 4. 4.1 RQ 1 1. 1 2. 3. 4. 5. RQ1 6. issue RQ2 7. 8. RQ3 3. 使用密度 *2 を算出 4. 値の遷移をグラフ化 5. に注目し採用 / 不採用を判断 *1 関数型イディオム *2 FI の使用回数 / 非 FI の使用回数 1. Star 順検索で上位 1 個の Java プロジェクトを抽出 6. の時期に注目しコミットメッセージや issue を調査 RQ1 RQ2 RQ3 1 2. 全リビジョンから FI *1 を検出 7. 最新リビジョンの FI を抽出 8. 実際の開発現場での FI の使い方を調査 FI を使用しているコード断片最新リビジョン使用密度が大きく変化する時期 213 9 18 218 4 1 Java 4.3 3 Stream, Optional 1 D idiom 4.4 RQ1 RQ1 D idiom D idiom 4.2 GitHub 1 Java Java 8 1 Stream Optional for, while null c 218 Information Processing Society of Japan 186
4.5 RQ2 RQ1 D idiom 3%, Stream Optional 1% issue 87 Stream 53 Optional 69 GitHub issue Scope = (" java 8" OR " java8 ") Fi = (" lambda " OR " stream " OR " optional ") Action = (" use " OR " accept " OR " remove " OR " replace " OR " reason ") Query = ( Scope OR Fi) AND Action GitHub Java 1 4.6 RQ3 RQ3 AST AST IDE Eclipse JDT Java Development Tools JDT AST Statement Stream API AST Stream API Stream 1 Stream ラムダ式 Stream Optional 5% 6% 18% 82% 95% 94% 採用不採用 2 1 / stream() of() Stream stream() of() Optional Java Optional 5. 5.1 RQ1 RQ1: D idiom 1 / 2 D idiom 1% 1 Stream Optional 2 18% Stream 5% 3 1 D idiom 3 D idiom 3 3 D idiom 5 D idiom 2 D idiom c 218 Information Processing Society of Japan 187
1 1 1 ラムダ式 Stream Optional Vert. Pocket. Proxyee. zipkin spark D idiom 213/3 218/4 T 3 Java-ds. selenium Spring. RxJava fastjson guava 213/3 218/4 T D idiom ( D idiom 5 ) RxJava Java-ds. selenium guava 213/3 218/4 T Vert. Java 8 Pocket. Proxyee. Stream D idiom Java-ds. 15% Java-ds. D idiom Optional RxJava 215 Optional Optional D idiom 1% Stream Optional for,while null Java 8 D idiom 5.2 RQ2 RQ2: / RQ2 2 guava Stream Stream Guava realm-java realm-java RxJava2 Java realm-java selenium Stream spark selenium jar jar retrofit Optional retrofit Optional Optional RQ3 3 GraalVM Stream Stream GraalVM Stream guava guava Hystrix lottie-android, RxJava JDK6 JDK7 selenium Optional Optional Optional null c 218 Information Processing Society of Japan 188
事例数 事例数 事例数 5 25 13 ~ 1 2 3 4 5 6 7 8 9 1 24 27 29 ステートメント数 4 Lambda 5 1 2 3 4 5 6 7 メソッド数 Stream map 6 collect filter foreach toarray empty findfirst メソッド名 concat flatmap ~ builder allmatch Stream API generate peek Optional selenium Optional 5.3 RQ3 RQ3: 4 4 1 2 2 *1 https://groups.google.com/forum/#!topic/guava- 29 1 Stream 5 Stream announce/o954pqvaxly/discussion *2 https://github.com/realm/realm-java/commit/9ac68 *3 https://github.com/square/retrofit/commit/e985d *4 https://github.com/google/guava/issues/167 *5 https://github.com/seleniumhq/selenium/issues/4867 *6 https://github.com/seleniumhq/selenium/commit/4c38c *7 https://github.com/oracle/graal/commit/bca7c *8 https://github.com/google/guava/issues/167 *9 https://github.com/netflix/hystrix/commit/e12e *1 https://github.com/airbnb/lottie-android/commit/fa239 *11 https://github.com/reactivex/rxjava/commit/a1 *12 https://github.com/seleniumhq/selenium/commit/4c38c 2 guava Stream 216/11/5 Stream guava * 1 realm-java 217/9/12 RxJava2 * 2 retrofit Optional 217/3/12 Optional * 3 selenium 214/11/1 jar * 4 selenium Stream 217/12/3 * 5 spark 214/4/7 * 6 3 GraalVM Stream 214/9/9 * 7 guava 214/11/1 * 8 Hystrix Stream, Optional 216/8/19 JDK6/7 * 9 lottie-android 217/4/8 * 1 RxJava Stream, Optional 216/2/4 JDK6 * 11 selenium Optional 217/3/3 Optional * 12 c 218 Information Processing Society of Japan 189
事例数 3 1 orelse() Optional orelse() Optional 6. orelse filter equals ofnullable stream ispresent get of empty メソッド名 7 Optional, stream() of() Stream 218 1 26 7 1 Stream API 6 Stream API Stream map() 129 collect() 18 peek() 1 allmatch() 1 peek() Stream allmatch() Stream true false allmatch() Stream true Optional 7 Optional 7 Optional empty() 29 1 equals() 2 Optional Optional Optional 6.1 RQ1 2 18% Stream Optional 1 6% RQ1 Java 6.2 RQ2 5.2 3 1 selenium spark selenium jar 2 guava Stream Java Stream [9] guava 3 realm-java retrofit 3 1 JDK 6 JDK 7 2 Java [7] c 218 Information Processing Society of Japan 19
3 guava RQ2 JDK 7 6.3 RQ3 4 1 [11] 2 7 get() ispresent() [12], [13] RQ3 Stream 7. Java 3 RQ B 16H298 18H3222 [1] Favre, J. M.: Languages evolve too! Changing the software time scale, Proceedings of the 8th International Workshop on Principles of Software Evolution, pp. 33 42 (25). [2] Landin, P. J.: The Next 7 Programming Languages, Communications of the Association for Computing Machinery, Vol. 9, No. 3, pp. 157 166 (1966). [3] Spinellis, D., Louridas, P. and Kechagia, M.: The Evolution of C Programming Practices: A Study of the Unix Operating System 1973 215, Proceedings of the 38th International Conference on Software Engineering, pp. 748 759 (216). [4] Simmonds, D. M.: The Programming Paradigm Evolution, Computer, Vol. 45, No. 6, pp. 93 95 (212). [5] Saumont, P.: What s Wrong in Java 8, Part V: Tuples - DZone Performance, https://dzone.com/article/ whats-wrong-java-8-part-v. [6] Warburton, R.: Java 8 Lambda Functional Programming for the Masses, O Reilly Media (214). [7] Fischer, R.: Java Closures and Lambda, chapter 7, Apress. (215). [8] Weiss, T.: The Dark Side Of Lambda Expressions in Java 8 OverOps Blog, https: //blog.takipi.com/the-dark-side-of-lambdaexpressions-in-java-8/. [9] Zhitnitsky, A.: The 6 biggest problems of Java 8 - JAXenter, https://jaxenter.com/java-8-problems- 112279.html. [1] Cheon, Y. and Torre, A.: Impacts of Java Language Features on the Memory Performances of Android Apps, Technical report, University of Texas at El Paso (217). [11] Subramaniam, V.: Java 8 idioms: Why the perfect lambda expression is just one line, https://www.ibm.com/developerworks/library/jjava8idioms6/index.html. [12] Winnicki, M.: Optional ispresent() Is Bad for You - DZone Java, https://dzone.com/articles/ optional-ispresent-is-bad-for-you. [13] Gioiosa, M. P.: Java 8 Optional - Replace Your Get() Calls - DZone Java, https://dzone.com/articles/ java-8-optional-replace-your-get-calls. c 218 Information Processing Society of Japan 191