Upgrade to Pro — share decks privately, control downloads, hide ads and more …

オープントーン内部勉強会/ot-study-20151117

 オープントーン内部勉強会/ot-study-20151117

Avatar for Tetsuo Aoyagi

Tetsuo Aoyagi

November 15, 2015

Other Decks in Technology

Transcript

  1. ྺ࢙ͷ͓͞Β͍ JDK 1.1 J2SE 1.2 J2SE 1.3 J2SE 1.4 J2SE

    5.0 Java SE 6.0 Java SE 7.0 Java SE 8.0 1995 2000 2005 2010 2015 Java SE 9.0 • generics • annotation • autoboxing • for-each • enum • static import • Մม௕Ҿ਺ • Swing • Collection API • try-with-resources • multi-catch • strings in switch • NIO2 • ࿨ྐྵ • Properties#loa d(Reader) • Stream API • Time API • lambda • default method JDK 1.0 1996.01 1997.02 1998.12 2000.05 2002.02 2004.09 2006.12 2011.07 2014.03 2016.09 • Applet • ֮͑ͯͳ͍.. • Logging API • NIO • regexp • exception chaining • assert
  2. ྺ࢙ͷ͓͞Β͍ JDK 1.1 J2SE 1.2 J2SE 1.3 J2SE 1.4 J2SE

    5.0 Java SE 6.0 Java SE 7.0 Java SE 8.0 1995 2000 2005 2010 2015 Java SE 9.0 JDK 1.0 1996.01 1997.02 1998.12 2000.05 2002.02 2004.09 2006.12 2011.07 2014.03 2016.09 Struts Seasar2 Spring Framework Struts2 Tomcat3 Tomcat8 OpenTone J2EE EJB JUnit Eclipse JBuilder Visual Age Scala Groovy Maven2 Maven1 Maven3 Ant Gradle Jenkins Hudson POJO JSF2 Hibernate iBatis JSF1 SAStruts JRuby Wicket JPA CDI Jakarta Project ivy Grails Clojure PoEAA CoC Rails DDD TDD BDD Android Refactoring IntelliJ Play Framework Backlog Redmine
  3. 0 5 10 15 20 JDK1.1 J2SE1.2 J2SE1.3 J2SE1.4 J2SE5.0

    Java SE6 Java SE7 Java SE8 1 4.1 4.6 9.5 14.4 15.8 16.5 17.7 1 3.9 4.4 9.3 13.6 14.8 15.7 16.9 1 2.5 2.9 7.3 12.6 14.2 14.4 14.4 1 3.3 3.8 8.7 12.9 14.2 14.9 15.8 loc package type method APIͷن໛ਪҠ
  4. Service Provider Interface app.jar sample.Driver foo-driver.jar FooDriver sample.Driver sample.Driver META-INF/services

    bar-driver.jar BarDriver sample.Driver sample.Driver META-INF/services <<use>> <<use>> ྫɿσόΠεʹԠͨ͡υϥΠό੾ସ Interface͸ΞϓϦଆ Ͱఆٛ ࣮૷Ϋϥε͸ ֤jarͰఆٛ
  5. Pluggable Annotation Processing API (JSR269) • ίϯύΠϧ࣌ʹɺιʔείʔυʹهड़͞ΕͨΞ ϊςʔγϣϯΛॲཧ͢Δ࢓૊Έ • ੒Ռ෺ͷੜ੒

    • ιʔείʔυͷݕূ • ͍Ζ͍ΖͳOSSͰ΋࠾༻ • Lombok • Doma • Android Annotations
  6. try-with-resources OutputStream o = null; try { o = Files.newOutputStream(path);

    // ͍Ζ͍Ζͳॲཧ.. } catch (IOException e) { handleException(e); } finally { if (o != null) { try { o.close(); } catch (IOException e) { handleException(e); } } } try (OutputStream o = Files.newOutputStream(path)) { // ͍Ζ͍Ζͳॲཧ.. } catch (IOException e) { handleException(e); }
  7. throw͞ΕΔͷ͸Ͳͬͪʁ A. HogeResourceReadException B. HogeResourceCloseException public void readHoge() throws Exception

    { try (HogeResourceReader r = HogeResourceReader.open()) { List<HogeResource> resources = r.read(); } catch (HogeResourceReadException e) { throw e; } catch (HogeResourceCloseException e) { throw e; } }
  8. throw͞ΕΔͷ͸Ͳͬͪʁ A. HogeResourceReadException B. HogeResourceCloseException usage.java.lang.HogeResourceReadException at usage.java.lang.HogeResourceReader.read(HogeResourceReader.java:16) at usage.java.lang.TryWithResourcesTest.testTryWithResources1(TryWithResourcesTest.java:14)

    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:78) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:212) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:68) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140) Suppressed: usage.java.lang.HogeResourceCloseException at usage.java.lang.HogeResourceReader.close(HogeResourceReader.java:23) at usage.java.lang.TryWithResourcesTest.testTryWithResources1(TryWithResourcesTest.java:15) ... 26 more • ͨͩ͠ɺB΋ؚ·Εͯ·͢
  9. ͦͷଞ Miscellaneous // ϓϦϛςΟϒϥούʔ // ࿦ཧԋࢉࢠ boolean x, y; Boolean.compare(x,

    y); // x == y Boolean.logicalAnd(x, y); // x && y Boolean.logicalOr(x, y); // x || y Boolean.logicalXor(x, y); // x ^ y // ූ߸ͳ͠੔਺΁ͷม׵ byte b = -1; Byte.toUnsignedInt(b); // 255 int i = -1; Integer.toUnsignedLong(b); // 4294967295 (0xffffffffL)
  10. ͦͷଞ Miscellaneous // ࠃࡍԽυϝΠϯ import java.net.IDN; IDN.toASCII(“͜Ή.com”); // “xn—28jwe.com” //

    จࣈΤϯίʔσΟϯά import java.nio.charset.StandardCharsets; String message = ..; message.getBytes(StandardCharsets.UTF_8);
  11. ͦͷଞ Miscellaneous // ཁૉͷ܁Γฦ͠ॲཧ List<Foo> list = getFooListFromSomewhere(); list.forEach(e ->

    { // ͍Ζ͍Ζͳॲཧ }); // จࣈྻ൑ఆɾૢ࡞ String s = “”; s.isEmpty(); // true String.join(“-“, “a”, “b”, “”, “c”, null, “d”); // “a-b--c-null-d” // System.getProperty(“line.separator”) ͱಉ͡ System.lineSeparator();
  12. ͦͷଞ Miscellaneous // ฒ΂ସ͑ͦͷ1 import static java.util.Comparator.*; List<Integer> list =

    Arrays.asList(3, 1, 5, 7, 4); // 1, 3, 4, 5, 7 list.sort(naturalOrder()); // 7, 5, 4, 3, 1 list.sort(reverseOrder());
  13. ͦͷଞ Miscellaneous // ฒ΂ସ͑ͦͷ2 List<Employee> list = new ArrayList<Employee>() {

    { // empNo, name, age add(new Employee(“00001”, “Taro Yamada”, 29)); add(new Employee(“00305”, null, 32)); .. } }; // 1. nameͷঢॱ(null͸ઌ಄΁), 2. empNoͷ߱ॱ(null͸຤ඌ΁) list.sort(comparing(Employee::getName, nullsFirst(naturalOrder())) .thenComparing(Employee::getEmpNo, nullsLast(reverseOrder())));
  14. ͦͷଞ Miscellaneous // java.util.Objects Objects.equals(null, null); // true Objects.equals(null, “test”);

    // false; Objects.isNull(o); // nullͳΒtrue Objects.nonNull(o); // null͡Όͳ͚Ε͹true Objects.requireNonNull(o); // null͡Όͳ͚Ε͹o͕ฦ͞ΕΔ Objects.requireNonNull(null); // NullPointerException͕throw͞ΕΔ Objects.requireNonNull(o, “஋͕ઃఆ͞Ε͍ͯ·ͤΜ”); // nullͩͬͨΒϝοηʔδऔಘϝιου(͘͢͝ॏ͍ॲཧ)Ͱੜ੒ͨ͠ // ϝοηʔδΛઃఆͨ͠NullPointerException͕throw͞ΕΔ Objects.requireNonNull(o, this::createMessageUsingTooHeavyProcess);