SlideShare a Scribd company logo
1 of 71
Download to read offline
JJUG CCC 2009 Fall




                 NTT


                        2009/10/08
2009   10   10
Slide# 2       JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
•
                 •   NTT
                 •   JGGUG
                 •           “Gr                      ”
                 •   “Grails                      ”
                 •   JavaWorld
                 •   Twitter: uehaj



  Slide# 3                 JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
• Groovy
            • Groovy
            • Groovy
            •                    Groovy
                 •                      Groovy
                 •                  Groovy
                     •                                     Groovy
            •
  Slide# 4               JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
Slide# 5       JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
Slide# 6       JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
• Java                                      (Stand by me)




  Slide# 6       JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
• Java                                               (Stand by me)

                 •   JavaVM




  Slide# 6                JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
• Java                                                 (Stand by me)

                 •   JavaVM
                 •   Java              (                      )




  Slide# 6                  JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
• Java                                                   (Stand by me)

                 •   JavaVM
                 •   Java                (                      )

                 •            Java
                     •   annotation/enum/generics/vararg/static import/




  Slide# 6                    JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
• Java                                                   (Stand by me)

                 •   JavaVM
                 •   Java                (                      )

                 •            Java
                     •   annotation/enum/generics/vararg/static import/

                 •                                  JSP


  Slide# 6                    JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
• Java                                                       (Stand by me)

                 •   JavaVM
                 •   Java                (                          )

                 •            Java
                     •   annotation/enum/generics/vararg/static import/

                 •                                  JSP
                                                 :(Java         )
  Slide# 6                    JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
• Scala       JRuby
                 •                  Scala               Ruby
                 •
                                                  Java API
             •
            • Groovy
             • Java
             •                                            Java
             • Maven                                    Java
  Slide# 7            JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
•         Java API                                GDK
                     Java


            •
                 •                      ,                 /            ,etc
            •
            •                                                  (DSL)
  Slide# 8              JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
import java.io.*;                                               String line;
       import java.net.*;                                              while ((line = bis.readLine()) != null)
                                                                         System.out.println(line);
       public class SocketAccess {                                     }
                                                                      }
        public static void main(String[] args) {                      catch (IOException e) {
         Socket soc = null;                                             e.printStackTrace();
         InputStream ins = null;                                        try {
         OutputStream outs = null;                                        if (soc != null) soc.close();
         try {                                                          }
           soc = new Socket("www.java-users.jp", 80);                   catch(IOException ex) {}
           ins = soc.getInputStream();                                }
           outs = soc.getOutputStream();                          }
           outs.write("GET / HTTP/1.0nn".getBytes());       }
           BufferedReader bis = new
       BufferedReader(new InputStreamReader(ins));

  Slide# 9                  JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
import java.io.*;                                               String line;
       import java.net.*;                                              while ((line = bis.readLine()) != null)
                                                                         System.out.println(line);
       public class SocketAccess {                                     }
                                                                      }
        public static void main(String[] args) {                      catch (IOException e) {
         Socket soc = null;                                             e.printStackTrace();
         InputStream ins = null;                                        try {
         OutputStream outs = null;                                        if (soc != null) soc.close();
         try {                                                          }
           soc = new Socket("www.java-users.jp", 80);                   catch(IOException ex) {}
           ins = soc.getInputStream();                                }
           outs = soc.getOutputStream();                          }
           outs.write("GET / HTTP/1.0nn".getBytes());       }
           BufferedReader bis = new
       BufferedReader(new InputStreamReader(ins));

  Slide# 10                 JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
import java.io.*;                                               String line;
       import java.net.*;                                              while ((line = bis.readLine()) != null)
                                                                         System.out.println(line);
       public class SocketAccess {                                     }
                                                                      }
        public static void main(String[] args) {                      catch (IOException e) {
         Socket soc = null;                                             e.printStackTrace();
         InputStream ins = null;                                        try {
         OutputStream outs = null;                                        if (soc != null) soc.close();
         try {                                                          }
           soc = new Socket("www.java-users.jp", 80);                   catch(IOException ex) {}
           ins = soc.getInputStream();                                }
           outs = soc.getOutputStream();                          }
           outs.write("GET / HTTP/1.0nn".getBytes());       }
           BufferedReader bis = new
       BufferedReader(new InputStreamReader(ins));

  Slide# 10                 JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
new Socket("www.java-users.jp", 80).withStreams { ins, outs ->
         outs.write("GET / HTTP/1.0nn".bytes)
         ins.eachLine {
           println it
         }
       }




  Slide# 11          JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
new Socket("www.java-users.jp", 80).withStreams { ins, outs ->
         outs.write("GET / HTTP/1.0nn".bytes)
         ins.eachLine {
           println it
         }
       }




  Slide# 11          JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
new Socket("www.java-users.jp", 80).withStreams { ins, outs ->
         outs.write("GET / HTTP/1.0nn".bytes)
         ins.eachLine {
           println it
         }
       }




  Slide# 11          JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
new Socket("www.java-users.jp", 80).withStreams { ins, outs ->
         outs.write("GET / HTTP/1.0nn".bytes)
         ins.eachLine {
           println it
         }
       }




  Slide# 11          JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
println new URL("http://www.java-users.jp").text




  Slide# 12               JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
println new URL("http://www.java-users.jp").text




                 Java         Groovy



                                                            Java 7


  Slide# 12               JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
•
                 •
                 •                                          (what)
                     SN
                 •
                     1
            •

  Slide# 13               JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
•
                 •
                            (Algol, Common Lisp, Ada, C++…)


                     (Polyglot Programing)

            • Groovy
                     Java



  Slide# 14           JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
Slide# 15      JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
2003             2004                     2005
                     8         3                     2
                             ▲                     ▲
                           1.0b4                 1.0b10
                           JSR                  JSR EA



                   2006              2007                    2008         2009
                   7       2         4            12         2      12      8
                     ▲        ▲ ▲      ▲    ▲                       ▲       ▲
                 1.0 JSR-6 1.0 1.1b2 1.5.0 1.5.4                    1.5.7   1.6.4
                       Grails   Grails                              1.6-rc1 1.7-b1
                        0.3     0.5.6
  Slide# 16               JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
• 2004
                                                       ?
                 •   SyntaxError Stacktrace!
            •

                 •                                         Grails
                 •   JRuby

  Slide# 17              JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
Slide# 18      JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
•
                 (1.6     )
            • Grape(1.6 )
            • AST     (1.6 )
            • Power Assert(1.7                            )

  Slide# 19             JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
Slide# 20      JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
'ls'.metaClass.exec = { new File(".").eachFile{println it} }
       'pwd'.metaClass.exec = { println new File(".").absolutePath }
       'env'.metaClass.exec = {
         System.getenv().each{k,v->println "$k=$v" }
       }

       System.in.eachLine {
         it.intern().exec()
       }




  Slide# 21          JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
transform




  Slide# 22        JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
transformation




            • Groovy
                 (AST                                           )
                 •   Groovy


                 •           AST                                    AST



                     aka
  Slide# 23                   JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
(Antlr)                                     (Antlr)   (ASM)




       a=a+a                                                                   0xCAFEBABE
                                                                                  ........



       Groovy                                                                   Java




  Slide# 24                JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
(Antlr)                                     (Antlr)                       (ASM)




                                                                           =

       a=a+a               a     =       a      +       1              a           +               0xCAFEBABE
                                                                                                      ........
                                                                               a       1

       Groovy                                                                                       Java
                                                                           AST




  Slide# 24                JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
(Antlr)                                     (Antlr)                        (ASM)




                                                                            =

       a=a+a               a     =       a      +       1              a            +               0xCAFEBABE
                                                                                                       ........
                                                                                a       1

       Groovy                                                                                        Java
                                                                            AST


                                                                           AST


  Slide# 24                JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
(Antlr)                                     (Antlr)                        (ASM)




                                                                            =

       a=a+a               a     =       a      +       1              a            +               0xCAFEBABE
                                                                                                       ........
                                                                                a       1

       Groovy                                                                                        Java
                                                                            AST


                                                                           AST
                                                                            AST


  Slide# 24                JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
(Antlr)                                     (Antlr)                        (ASM)




                                                                            =

       a=a+a               a     =       a      +       1              a            +               0xCAFEBABE
                                                                                                       ........
                                                                                a       1

       Groovy                                                                                        Java
                                                                            AST


                                                                           AST
                                                                            AST
                                                                             AST


  Slide# 24                JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
(Antlr)                                     (Antlr)                        (ASM)




                                                                            =

       a=a+a               a     =       a      +       1              a            +               0xCAFEBABE
                                                                                                       ........
                                                                                a       1

       Groovy                                                                                        Java
                                                                            AST


                                                                           AST
                                                                            AST
                                                                             AST


  Slide# 24                JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
•                   AST
                 •
                                                       AST
            •        AST
                 •

  Slide# 25          JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
•

                 •    groovyc                       AST
                 •   groovy


       •
                     Groovy


  Slide# 26                   JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
transform




  Slide# 27        JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
JAR
       Grape(@Grab)
                                        (Apache Ivy            )

                                        Assert
            Power Assert

                                        AST               Groovy
                 ASTBuilder
                                                                   AST

  Slide# 28             JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
@Grab('org.mortbay.jetty:jetty-embedded:6.1.0')
            import org.mortbay.jetty.Server
            import org.mortbay.jetty.servlet.*
            import groovy.servlet.*

            def server = new Server(8080)
            def context = new Context(server, "/", Context.SESSIONS)
            context.resourceBase = "."
            context.addServlet(TemplateServlet, "*.gsp")
            server.start()

        •                 jetty      Jar
        •                         Maven                     Jar   ‾/.groovy/
                 grapes



  Slide# 29               JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
a = 4
        assert 1+Math.max(3,a)*5==3
        ==>
        EXCEPTION:
        Assertion failed:

        assert 1+Math.max(3,a)*5==3
                |     |     | | |
                21    4     4 | false
                              25


        • assert            FAIL
  Slide# 30        JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
@Bindable /            Swing
                 @Vetoable              (java.beans. PropertyChangeSupport             )
                 @Singleton
                 @Immutable
                 @Delegate
                   @Lazy
                 @Category
                   @Mixin                                   mixin
                  @Newify               Python/Ruby             new(   : Integer(5),
                                        Integer.new(5))
            @PackageScope               package
  Slide# 31               JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
•
       @Singleton
       class Foo {
          def hello() { println "hello" }
       }
       Foo.instance.hello()  //
       a = new Foo()  // new
       ==>
       EXCEPTION:
       java.lang.RuntimeException: Can't instantiate
       singleton Foo. Use Foo.instance
       
 at Foo.<init>(Script1.groovy)
       
 at Script1.run(Script1.groovy:6)
  Slide# 32         JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
•
       @Immutable
       final class Foo {
         String x, y
       }
       a  = new Foo(x:"a",y:"b")
       a.x = "hoge"  //
       ==>
       EXCEPTION:
       groovy.lang.ReadOnlyPropertyException: Cannot set
       readonly property: x for class: Foo
       
 at Foo.setProperty(Script1.groovy)
       
 at Script1.run(Script1.groovy:6)

  Slide# 33         JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
•         /Proxy
       import java.util.concurrent.locks.*
       class LockableMap {
         @Delegate private Map map = [:]
         @Delegate private Lock lock = new ReentrantLock ()
       }
       res = new LockableMap()
       res.lock() // Lock
       try {
         res.a = 0 // Map
       } finally {
         res.unlock ()
       }
       assert res instanceof Map
       assert res instanceof Lock

  Slide# 34         JJUG CCC 2009 Fall / 2009.10.08
                   http://www.infoq.com/jp/articles/groovy-1-6
2009   10   10
•
       class LazyTest {
         @Lazy List s1 ={println "s1 initializing"; [1,2,3] }();
         List  s2 = {println "s2 initializing"; [4,5,6] }();
       }
       x = new LazyTest()
       // s2 initializing
       println x.s1       // s1
       // s1 initializing
       // [1, 2, 3]
       println x.s2
       // [4, 5, 6]
       println x.s1
       // [1, 2, 3]

  Slide# 35        JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
• use
             @Category(String)
             class TrMethod {
               String tr(from,to) {
                 def result = this
                 from.eachWithIndex{it,idx->
                   result = result.replaceAll(it, to.getAt(idx))
                 }
                 result
               }
             }
             use (TrMethod) {
               assert 'abcdef  123'.tr('abc      ','XYZ      ')
               

  == 'XYZdef   123'
             }
  Slide# 36           JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
•
            class Dumpable {                              x = new MyClass()
              void dump() {                               x.dump()
                this.metaClass.methods.each{              ==>
                  println it.name }                       toString
                this.metaClass.properties.each {          dump
                  println it.name }                       get__timeStamp__239_ne
              }                                           28920761
            }                                             set__timeStamp__239_ne
                                                          28920761
            @Mixin(Dumpable)                              equals
            class MyClass {                               getClass
              int field                                     :
              void foo() {}                               bar
              int bar(String i) {}                        foo
            }                                             field


  Slide# 37             JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
• Python/Ruby                                new
             class Test {
         @Newify(String) // Python
         static test() {
           def s0 = new String("hoge") // Groovy/Java
           def s1 = String("hoge")  // Python
           def s2 = String.new("hoge")  // Ruby
         }
       }




  Slide# 38           JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
transform




  Slide# 39        JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
•    AST
            •
                                                     (   AST
                                                     )
            •
                                   Groovy
  Slide# 40        JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
•      AST
            •
            •                                              AST


                 • META-INF/services/
                  org.codehaus.groovy.transform.AST
                  Transformation
            •    Groovy                                    (JAR   )

  Slide# 41              JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
•
                 ASTTransformation
            •
                 •   void visit(ASTNode[] nodes,
                                SourceUnit source)
             • SourceUnit                   getSourceUnit()

            • visit() AST
                     Visitor
  Slide# 42              JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
•           _FILE_, _LINE_,
                 _CLASS_, _METHOD_

                     AST
                 • log("$_FILE_:$_LINE_:
                  $_CLASS_:$_METHOD_
", ..)

  Slide# 43           JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
package org.jggug.transform
       import    org.codehaus.groovy.transform.GroovyASTTransformationClass;
       import    java.lang.annotation.Retention;
       import    java.lang.annotation.RetentionPolicy;
       import    java.lang.annotation.Target;
       import    java.lang.annotation.ElementType;



       @Retention(RetentionPolicy.SOURCE)
       @Target([ElementType.TYPE])
       @GroovyASTTransformationClass("org.jggug.transform.U
       seSourceInfoSymbolASTTransformation")
       public @interface UseSourceInfoSymbol {
       }

                                                                    AST

  Slide# 44                   JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
package org.jggug.transform
                                                                       void visitConstructorOrMethod(MethodNode
  import    org.codehaus.groovy.ast.*;                               node, boolean isConstructor) {
  import    org.codehaus.groovy.ast.expr.*;
  import    org.codehaus.groovy.ast.stmt.Statement;                      visitingMethod = node.name
  import    org.codehaus.groovy.control.CompilePhase;
  import    org.codehaus.groovy.control.SourceUnit;                      super.visitConstructorOrMethod(node,
  import    org.codehaus.groovy.transform.ASTTransformation;
  import    org.codehaus.groovy.transform.GroovyASTTransformation;   isConstructor)
                                                                       }
  @GroovyASTTransformation(phase =                                   (              )
  CompilePhase.CANONICALIZATION)
  public class
  UseSourceInfoSymbolASTTransformation extends
  ClassCodeExpressionTransformer implements
  ASTTransformation {
    private SourceUnit sourceUnit;
    SourceUnit getSourceUnit() {
      return sourceUnit;
    }
    String visitingMethod = null
    String visitingClass = null

    void visit(ASTNode[] nodes, SourceUnit
  source) {
      sourceUnit = source;
      def parent = nodes[1]
      visitingClass = parent.name
      super.visitClass(parent)
    }
  Slide# 45                        JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
  Expression transform(Expression exp) {
     if (exp == null) return null;
     switch (exp.class) {
     case VariableExpression.class:
       switch (exp.name) {
         case '_FILE_': return new ConstantExpression(sourceUnit.name)
         case '_LINE_': return new ConstantExpression(exp.lineNumber)
         case '_COLUMN_': return new ConstantExpression(exp.columnNumber)
         case '_CLASS_': return new ConstantExpression(visitingClass)
         case '_METHOD_': return new ConstantExpression(visitingMethod)
         default: return exp
       }
     case MethodCallExpression.class:
       def args = transform(exp.arguments);
       def method = transform(exp.method);
       def object = transform(exp.objectExpression);
       return new MethodCallExpression(object, method, args);
     case ClosureExpression.class:
       Statement code = exp.code;
       if (code == null) return exp
       return code.visit(this)
     case ConstructorCallExpression.class:
       return exp.transformExpression(this)
     default:
       return exp.transformExpression(this)
     }
   }
 }
 Slide# 46         JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
import org.jggug.transform.UseSourceInfoSymbol

       @UseSourceInfoSymbol
       class Test {
         def foo(hoge, fuga) {
           println _FILE_+':'+_LINE_
           println _FILE_+':'+_LINE_
           println _FILE_+':'+_LINE_
           println _FILE_+':'+_LINE_                  ==>
           println _FILE_+':'+_LINE_                  /tmp/test02.groovy:6
           println _CLASS_+':'+_METHOD_               /tmp/test02.groovy:7
         }                                            /tmp/test02.groovy:8
       }                                              /tmp/test02.groovy:9
                                                      /tmp/test02.groovy:10
       test = new Test()                              sample.Test:foo
       test.foo(1,2)


  Slide# 47         JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
• $b
                                                            (Java 7                  )
       @UseBinaryLit
          eral       println $b01_001_0001
                                ==> 145


       @WithTimeout @WithTimeout(3) def work()
                                { ....... }


                                @Define(symbol="that", value="delegate")
                 @Define         @Define(symbol="   ", value="it")
                                @Define(symbol="               ", value="this")
  Slide# 48                     @Define(symbol="
                          JJUG CCC 2009 Fall / 2009.10.08      ", value="println")
2009   10   10
• groovyConsole                         AST




  Slide# 49       JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
• ASTBuilder
                 • buildFromSpec … AST                   DSL
                 • buildFromString …
                      AST
                 • buildFromCode …                       (
                                  )                AST

  Slide# 50           JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
•
                 •
                     •
                 •
        • Scala                                            @Scalify


  Slide# 51              JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
Slide# 52      JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
• Groovy           Java
       •
       •                                               :
             • DSL

             •
       •
  Slide# 53          JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
• http://www.jggug.org/




  Slide# 54            JJUG CCC 2009 Fall / 2009.10.08

2009   10   10
•    http://groovy.codehaus.org/Compile-time+Metaprogramming+-+AST
                 +Transformations
                 Compile-time Metaprogramming - AST Transformations
            •    http://groovy.codehaus.org/AST+Macros+and+Annotations
                 AST Macros and Annotations
            •    http://groovy.codehaus.org/Building+AST+Guide
                 Building AST in Groovy 1.6 and Prior
            •    http://kartik-shah.blogspot.com/2009/03/groovy-16-ast-
                 transformation-example_5323.html
                 Groovy 1.6 AST Transformation Example
            •    http://www.infoq.com/jp/articles/groovy-1-6
                 Groovy 1.6                  - Groovy
            •    http://www.slideshare.net/paulk_asert/groovy-testing-
                 aug2009-1945995
                 Groovy Testing Sep2009
            •    http://dl.getdropbox.com/u/132573/groovy_scala/index.html
                 Groovy Scala:          JVM
            •

  Slide# 55                 JJUG CCC 2009 Fall / 2009.10.08

2009   10   10

More Related Content

What's hot

What's hot (19)

Gradle - time for another build
Gradle - time for another buildGradle - time for another build
Gradle - time for another build
 
Groovy Ecosystem - JFokus 2011 - Guillaume Laforge
Groovy Ecosystem - JFokus 2011 - Guillaume LaforgeGroovy Ecosystem - JFokus 2011 - Guillaume Laforge
Groovy Ecosystem - JFokus 2011 - Guillaume Laforge
 
Visage Android Hands-on Lab (OSCON)
Visage Android Hands-on Lab (OSCON)Visage Android Hands-on Lab (OSCON)
Visage Android Hands-on Lab (OSCON)
 
An introduction to maven gradle and sbt
An introduction to maven gradle and sbtAn introduction to maven gradle and sbt
An introduction to maven gradle and sbt
 
XML-Free Programming
XML-Free ProgrammingXML-Free Programming
XML-Free Programming
 
Intro To OSGi
Intro To OSGiIntro To OSGi
Intro To OSGi
 
Highlights from Java 10, 11 and 12 and Future of Java at JUG Koblenz
Highlights from Java 10, 11 and 12 and Future of Java at JUG KoblenzHighlights from Java 10, 11 and 12 and Future of Java at JUG Koblenz
Highlights from Java 10, 11 and 12 and Future of Java at JUG Koblenz
 
Maven
MavenMaven
Maven
 
Python + GDB = Javaデバッガ
Python + GDB = JavaデバッガPython + GDB = Javaデバッガ
Python + GDB = Javaデバッガ
 
5 Thing You're Not Doing, 4 Things You Should Stop Doing & 3 Things You Shoul...
5 Thing You're Not Doing, 4 Things You Should Stop Doing & 3 Things You Shoul...5 Thing You're Not Doing, 4 Things You Should Stop Doing & 3 Things You Shoul...
5 Thing You're Not Doing, 4 Things You Should Stop Doing & 3 Things You Shoul...
 
Maven basic concept
Maven basic conceptMaven basic concept
Maven basic concept
 
Simple Build Tool
Simple Build ToolSimple Build Tool
Simple Build Tool
 
Hands on the Gradle
Hands on the GradleHands on the Gradle
Hands on the Gradle
 
Intro to OSGi
Intro to OSGiIntro to OSGi
Intro to OSGi
 
Continous delivery with sbt
Continous delivery with sbtContinous delivery with sbt
Continous delivery with sbt
 
Spring & Hibernate
Spring & HibernateSpring & Hibernate
Spring & Hibernate
 
Spring Framework Petclinic sample application
Spring Framework Petclinic sample applicationSpring Framework Petclinic sample application
Spring Framework Petclinic sample application
 
SBT Crash Course
SBT Crash CourseSBT Crash Course
SBT Crash Course
 
OSGi Blueprint Services
OSGi Blueprint ServicesOSGi Blueprint Services
OSGi Blueprint Services
 

Viewers also liked

function list
function listfunction list
function list
kyon mm
 
レガシーコード改善はじめました 横浜道場
レガシーコード改善はじめました 横浜道場レガシーコード改善はじめました 横浜道場
レガシーコード改善はじめました 横浜道場
Hiroyuki Ohnaka
 
Grails/Groovyによる開発事例紹介
Grails/Groovyによる開発事例紹介Grails/Groovyによる開発事例紹介
Grails/Groovyによる開発事例紹介
Kiyotaka Oku
 
Jenkinsプラグインの作り方
Jenkinsプラグインの作り方Jenkinsプラグインの作り方
Jenkinsプラグインの作り方
Kiyotaka Oku
 
Jenkinsプラグイン開発
Jenkinsプラグイン開発Jenkinsプラグイン開発
Jenkinsプラグイン開発
Takahisa Wada
 
Jenkinsを用いたAndroidアプリビルド作業効率化
Jenkinsを用いたAndroidアプリビルド作業効率化Jenkinsを用いたAndroidアプリビルド作業効率化
Jenkinsを用いたAndroidアプリビルド作業効率化
Kenichi Kambara
 

Viewers also liked (20)

Groovier testing with Spock
Groovier testing with SpockGroovier testing with Spock
Groovier testing with Spock
 
Spock Framework
Spock FrameworkSpock Framework
Spock Framework
 
Androidリリース作業の効率化(2)
Androidリリース作業の効率化(2)Androidリリース作業の効率化(2)
Androidリリース作業の効率化(2)
 
function list
function listfunction list
function list
 
レガシーコード改善はじめました 横浜道場
レガシーコード改善はじめました 横浜道場レガシーコード改善はじめました 横浜道場
レガシーコード改善はじめました 横浜道場
 
Testing Web Applications with GEB
Testing Web Applications with GEBTesting Web Applications with GEB
Testing Web Applications with GEB
 
Groovy and Grails in Action - Devoxx 2008 - University - Guillaume Laforge
Groovy and Grails in Action - Devoxx 2008 - University - Guillaume LaforgeGroovy and Grails in Action - Devoxx 2008 - University - Guillaume Laforge
Groovy and Grails in Action - Devoxx 2008 - University - Guillaume Laforge
 
Gradle a new Generation Build Tool
Gradle a new Generation Build ToolGradle a new Generation Build Tool
Gradle a new Generation Build Tool
 
How about Gradle?
How about Gradle?How about Gradle?
How about Gradle?
 
Jenkins導入ライブ
Jenkins導入ライブJenkins導入ライブ
Jenkins導入ライブ
 
Grails/Groovyによる開発事例紹介
Grails/Groovyによる開発事例紹介Grails/Groovyによる開発事例紹介
Grails/Groovyによる開発事例紹介
 
Jenkinsプラグインの作り方
Jenkinsプラグインの作り方Jenkinsプラグインの作り方
Jenkinsプラグインの作り方
 
Jenkinsプラグイン開発
Jenkinsプラグイン開発Jenkinsプラグイン開発
Jenkinsプラグイン開発
 
Spock: A Highly Logical Way To Test
Spock: A Highly Logical Way To TestSpock: A Highly Logical Way To Test
Spock: A Highly Logical Way To Test
 
Jenkinsを用いたAndroidアプリビルド作業効率化
Jenkinsを用いたAndroidアプリビルド作業効率化Jenkinsを用いたAndroidアプリビルド作業効率化
Jenkinsを用いたAndroidアプリビルド作業効率化
 
GradleによるG*なビルドシステムの構築
GradleによるG*なビルドシステムの構築GradleによるG*なビルドシステムの構築
GradleによるG*なビルドシステムの構築
 
Groovy Testing Aug2009
Groovy Testing Aug2009Groovy Testing Aug2009
Groovy Testing Aug2009
 
うさぎ組 in G* WorkShop -うさみみの日常-
うさぎ組 in G* WorkShop -うさみみの日常-うさぎ組 in G* WorkShop -うさみみの日常-
うさぎ組 in G* WorkShop -うさみみの日常-
 
Spockを使おう!
Spockを使おう!Spockを使おう!
Spockを使おう!
 
The outlineoftestprocess
The outlineoftestprocessThe outlineoftestprocess
The outlineoftestprocess
 

Similar to Groovy, Transforming Language

クラウド・アプリケーション・アーキテクチャ
クラウド・アプリケーション・アーキテクチャクラウド・アプリケーション・アーキテクチャ
クラウド・アプリケーション・アーキテクチャ
Tomoharu ASAMI
 
Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...
Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...
Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...
Paul King
 
Java review00
Java review00Java review00
Java review00
saryu2011
 
Introduction to the Java bytecode - So@t - 20130924
Introduction to the Java bytecode - So@t - 20130924Introduction to the Java bytecode - So@t - 20130924
Introduction to the Java bytecode - So@t - 20130924
yohanbeschi
 

Similar to Groovy, Transforming Language (20)

クラウド・アプリケーション・アーキテクチャ
クラウド・アプリケーション・アーキテクチャクラウド・アプリケーション・アーキテクチャ
クラウド・アプリケーション・アーキテクチャ
 
DevNexus 2020: Discover Modern Java
DevNexus 2020: Discover Modern JavaDevNexus 2020: Discover Modern Java
DevNexus 2020: Discover Modern Java
 
「プログラミングGroovy」Groovyってなんだろ?編
「プログラミングGroovy」Groovyってなんだろ?編「プログラミングGroovy」Groovyってなんだろ?編
「プログラミングGroovy」Groovyってなんだろ?編
 
Java/Spring과 Node.js의 공존 시즌2
Java/Spring과 Node.js의 공존 시즌2Java/Spring과 Node.js의 공존 시즌2
Java/Spring과 Node.js의 공존 시즌2
 
Afstuderen bij Sogeti Java
Afstuderen bij Sogeti JavaAfstuderen bij Sogeti Java
Afstuderen bij Sogeti Java
 
JavaOne 2011 - JVM Bytecode for Dummies
JavaOne 2011 - JVM Bytecode for DummiesJavaOne 2011 - JVM Bytecode for Dummies
JavaOne 2011 - JVM Bytecode for Dummies
 
Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...
Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...
Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...
 
BeJUG JavaFx In Practice
BeJUG JavaFx In PracticeBeJUG JavaFx In Practice
BeJUG JavaFx In Practice
 
近未来的並列 LL
近未来的並列 LL近未来的並列 LL
近未来的並列 LL
 
Java review00
Java review00Java review00
Java review00
 
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
 
Rejectkaigi 2010
Rejectkaigi 2010Rejectkaigi 2010
Rejectkaigi 2010
 
Devoxx France: Développement JAVA avec un IDE dans le Cloud: Yes we can !
Devoxx France: Développement JAVA avec un IDE dans le Cloud: Yes we can !Devoxx France: Développement JAVA avec un IDE dans le Cloud: Yes we can !
Devoxx France: Développement JAVA avec un IDE dans le Cloud: Yes we can !
 
Scalive
ScaliveScalive
Scalive
 
Ugo Cei Presentation
Ugo Cei PresentationUgo Cei Presentation
Ugo Cei Presentation
 
Non blocking io with netty
Non blocking io with nettyNon blocking io with netty
Non blocking io with netty
 
JavaFX Overview
JavaFX OverviewJavaFX Overview
JavaFX Overview
 
Rapid Network Application Development with Apache MINA
Rapid Network Application Development with Apache MINARapid Network Application Development with Apache MINA
Rapid Network Application Development with Apache MINA
 
JCConf 2018 - Retrospect and Prospect of Java
JCConf 2018 - Retrospect and Prospect of JavaJCConf 2018 - Retrospect and Prospect of Java
JCConf 2018 - Retrospect and Prospect of Java
 
Introduction to the Java bytecode - So@t - 20130924
Introduction to the Java bytecode - So@t - 20130924Introduction to the Java bytecode - So@t - 20130924
Introduction to the Java bytecode - So@t - 20130924
 

More from Uehara Junji

Groovy kisobenkyoukai20130309
Groovy kisobenkyoukai20130309Groovy kisobenkyoukai20130309
Groovy kisobenkyoukai20130309
Uehara Junji
 
Java One 2012 Tokyo JVM Lang. BOF(Groovy)
Java One 2012 Tokyo JVM Lang. BOF(Groovy)Java One 2012 Tokyo JVM Lang. BOF(Groovy)
Java One 2012 Tokyo JVM Lang. BOF(Groovy)
Uehara Junji
 
Jggug ws 15th LT 20110224
Jggug ws 15th LT 20110224Jggug ws 15th LT 20110224
Jggug ws 15th LT 20110224
Uehara Junji
 

More from Uehara Junji (20)

Use JWT access-token on Grails REST API
Use JWT access-token on Grails REST APIUse JWT access-token on Grails REST API
Use JWT access-token on Grails REST API
 
Groovy Bootcamp 2015 by JGGUG
Groovy Bootcamp 2015 by JGGUGGroovy Bootcamp 2015 by JGGUG
Groovy Bootcamp 2015 by JGGUG
 
Groovy Shell Scripting 2015
Groovy Shell Scripting 2015Groovy Shell Scripting 2015
Groovy Shell Scripting 2015
 
Shibuya JVM Groovy 20150418
Shibuya JVM Groovy 20150418Shibuya JVM Groovy 20150418
Shibuya JVM Groovy 20150418
 
Markup Template Engine introduced Groovy 2.3
Markup Template Engine introduced Groovy 2.3Markup Template Engine introduced Groovy 2.3
Markup Template Engine introduced Groovy 2.3
 
Introduce Groovy 2.3 trait
Introduce Groovy 2.3 trait Introduce Groovy 2.3 trait
Introduce Groovy 2.3 trait
 
Indy(Invokedynamic) and Bytecode DSL and Brainf*ck
Indy(Invokedynamic) and Bytecode DSL and Brainf*ckIndy(Invokedynamic) and Bytecode DSL and Brainf*ck
Indy(Invokedynamic) and Bytecode DSL and Brainf*ck
 
enterprise grails challenge, 2013 Summer
enterprise grails challenge, 2013 Summerenterprise grails challenge, 2013 Summer
enterprise grails challenge, 2013 Summer
 
New features of Groovy 2.0 and 2.1
New features of Groovy 2.0 and 2.1New features of Groovy 2.0 and 2.1
New features of Groovy 2.0 and 2.1
 
Groovy kisobenkyoukai20130309
Groovy kisobenkyoukai20130309Groovy kisobenkyoukai20130309
Groovy kisobenkyoukai20130309
 
Read Groovy Compile process(Groovy Benkyoukai 2013)
Read Groovy Compile process(Groovy Benkyoukai 2013)Read Groovy Compile process(Groovy Benkyoukai 2013)
Read Groovy Compile process(Groovy Benkyoukai 2013)
 
groovy 2.1.0 20130118
groovy 2.1.0 20130118groovy 2.1.0 20130118
groovy 2.1.0 20130118
 
New feature of Groovy2.0 G*Workshop
New feature of Groovy2.0 G*WorkshopNew feature of Groovy2.0 G*Workshop
New feature of Groovy2.0 G*Workshop
 
G* Workshop in fukuoka 20120901
G* Workshop in fukuoka 20120901G* Workshop in fukuoka 20120901
G* Workshop in fukuoka 20120901
 
JJUG CCC 2012 Real World Groovy/Grails
JJUG CCC 2012 Real World Groovy/GrailsJJUG CCC 2012 Real World Groovy/Grails
JJUG CCC 2012 Real World Groovy/Grails
 
Java One 2012 Tokyo JVM Lang. BOF(Groovy)
Java One 2012 Tokyo JVM Lang. BOF(Groovy)Java One 2012 Tokyo JVM Lang. BOF(Groovy)
Java One 2012 Tokyo JVM Lang. BOF(Groovy)
 
Java x Groovy: improve your java development life
Java x Groovy: improve your java development lifeJava x Groovy: improve your java development life
Java x Groovy: improve your java development life
 
Groovy 1.8の新機能について
Groovy 1.8の新機能についてGroovy 1.8の新機能について
Groovy 1.8の新機能について
 
Let's go Developer 2011 sendai Let's go Java Developer (Programming Language ...
Let's go Developer 2011 sendai Let's go Java Developer (Programming Language ...Let's go Developer 2011 sendai Let's go Java Developer (Programming Language ...
Let's go Developer 2011 sendai Let's go Java Developer (Programming Language ...
 
Jggug ws 15th LT 20110224
Jggug ws 15th LT 20110224Jggug ws 15th LT 20110224
Jggug ws 15th LT 20110224
 

Recently uploaded

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Recently uploaded (20)

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 

Groovy, Transforming Language

  • 1. JJUG CCC 2009 Fall NTT 2009/10/08 2009 10 10
  • 2. Slide# 2 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 3. • NTT • JGGUG • “Gr ” • “Grails ” • JavaWorld • Twitter: uehaj Slide# 3 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 4. • Groovy • Groovy • Groovy • Groovy • Groovy • Groovy • Groovy • Slide# 4 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 5. Slide# 5 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 6. Slide# 6 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 7. • Java (Stand by me) Slide# 6 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 8. • Java (Stand by me) • JavaVM Slide# 6 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 9. • Java (Stand by me) • JavaVM • Java ( ) Slide# 6 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 10. • Java (Stand by me) • JavaVM • Java ( ) • Java • annotation/enum/generics/vararg/static import/ Slide# 6 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 11. • Java (Stand by me) • JavaVM • Java ( ) • Java • annotation/enum/generics/vararg/static import/ • JSP Slide# 6 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 12. • Java (Stand by me) • JavaVM • Java ( ) • Java • annotation/enum/generics/vararg/static import/ • JSP :(Java ) Slide# 6 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 13. • Scala JRuby • Scala Ruby • Java API • • Groovy • Java • Java • Maven Java Slide# 7 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 14. Java API GDK Java • • , / ,etc • • (DSL) Slide# 8 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 15. import java.io.*; String line; import java.net.*; while ((line = bis.readLine()) != null) System.out.println(line); public class SocketAccess { } } public static void main(String[] args) { catch (IOException e) { Socket soc = null; e.printStackTrace(); InputStream ins = null; try { OutputStream outs = null; if (soc != null) soc.close(); try { } soc = new Socket("www.java-users.jp", 80); catch(IOException ex) {} ins = soc.getInputStream(); } outs = soc.getOutputStream(); } outs.write("GET / HTTP/1.0nn".getBytes()); } BufferedReader bis = new BufferedReader(new InputStreamReader(ins)); Slide# 9 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 16. import java.io.*; String line; import java.net.*; while ((line = bis.readLine()) != null) System.out.println(line); public class SocketAccess { } } public static void main(String[] args) { catch (IOException e) { Socket soc = null; e.printStackTrace(); InputStream ins = null; try { OutputStream outs = null; if (soc != null) soc.close(); try { } soc = new Socket("www.java-users.jp", 80); catch(IOException ex) {} ins = soc.getInputStream(); } outs = soc.getOutputStream(); } outs.write("GET / HTTP/1.0nn".getBytes()); } BufferedReader bis = new BufferedReader(new InputStreamReader(ins)); Slide# 10 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 17. import java.io.*; String line; import java.net.*; while ((line = bis.readLine()) != null) System.out.println(line); public class SocketAccess { } } public static void main(String[] args) { catch (IOException e) { Socket soc = null; e.printStackTrace(); InputStream ins = null; try { OutputStream outs = null; if (soc != null) soc.close(); try { } soc = new Socket("www.java-users.jp", 80); catch(IOException ex) {} ins = soc.getInputStream(); } outs = soc.getOutputStream(); } outs.write("GET / HTTP/1.0nn".getBytes()); } BufferedReader bis = new BufferedReader(new InputStreamReader(ins)); Slide# 10 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 18. new Socket("www.java-users.jp", 80).withStreams { ins, outs ->   outs.write("GET / HTTP/1.0nn".bytes)   ins.eachLine {     println it   } } Slide# 11 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 19. new Socket("www.java-users.jp", 80).withStreams { ins, outs ->   outs.write("GET / HTTP/1.0nn".bytes)   ins.eachLine {     println it   } } Slide# 11 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 20. new Socket("www.java-users.jp", 80).withStreams { ins, outs ->   outs.write("GET / HTTP/1.0nn".bytes)   ins.eachLine {     println it   } } Slide# 11 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 21. new Socket("www.java-users.jp", 80).withStreams { ins, outs ->   outs.write("GET / HTTP/1.0nn".bytes)   ins.eachLine {     println it   } } Slide# 11 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 22. println new URL("http://www.java-users.jp").text Slide# 12 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 23. println new URL("http://www.java-users.jp").text Java Groovy Java 7 Slide# 12 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 24. • • (what) SN • 1 • Slide# 13 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 25. • (Algol, Common Lisp, Ada, C++…) (Polyglot Programing) • Groovy Java Slide# 14 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 26. Slide# 15 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 27. 2003 2004 2005 8 3 2 ▲ ▲ 1.0b4 1.0b10 JSR JSR EA 2006 2007 2008 2009 7 2 4 12 2 12 8 ▲ ▲ ▲ ▲ ▲ ▲ ▲ 1.0 JSR-6 1.0 1.1b2 1.5.0 1.5.4 1.5.7 1.6.4 Grails Grails 1.6-rc1 1.7-b1 0.3 0.5.6 Slide# 16 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 28. • 2004 ? • SyntaxError Stacktrace! • • Grails • JRuby Slide# 17 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 29. Slide# 18 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 30. (1.6 ) • Grape(1.6 ) • AST (1.6 ) • Power Assert(1.7 ) Slide# 19 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 31. Slide# 20 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 32. 'ls'.metaClass.exec = { new File(".").eachFile{println it} } 'pwd'.metaClass.exec = { println new File(".").absolutePath } 'env'.metaClass.exec = { System.getenv().each{k,v->println "$k=$v" } } System.in.eachLine {   it.intern().exec() } Slide# 21 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 33. transform Slide# 22 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 34. transformation • Groovy (AST ) • Groovy • AST AST aka Slide# 23 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 35. (Antlr) (Antlr) (ASM) a=a+a 0xCAFEBABE ........ Groovy Java Slide# 24 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 36. (Antlr) (Antlr) (ASM) = a=a+a a = a + 1 a + 0xCAFEBABE ........ a 1 Groovy Java AST Slide# 24 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 37. (Antlr) (Antlr) (ASM) = a=a+a a = a + 1 a + 0xCAFEBABE ........ a 1 Groovy Java AST AST Slide# 24 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 38. (Antlr) (Antlr) (ASM) = a=a+a a = a + 1 a + 0xCAFEBABE ........ a 1 Groovy Java AST AST AST Slide# 24 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 39. (Antlr) (Antlr) (ASM) = a=a+a a = a + 1 a + 0xCAFEBABE ........ a 1 Groovy Java AST AST AST AST Slide# 24 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 40. (Antlr) (Antlr) (ASM) = a=a+a a = a + 1 a + 0xCAFEBABE ........ a 1 Groovy Java AST AST AST AST Slide# 24 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 41. AST • AST • AST • Slide# 25 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 42. • groovyc AST • groovy • Groovy Slide# 26 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 43. transform Slide# 27 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 44. JAR Grape(@Grab) (Apache Ivy ) Assert Power Assert AST Groovy ASTBuilder AST Slide# 28 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 45. @Grab('org.mortbay.jetty:jetty-embedded:6.1.0') import org.mortbay.jetty.Server import org.mortbay.jetty.servlet.* import groovy.servlet.* def server = new Server(8080) def context = new Context(server, "/", Context.SESSIONS) context.resourceBase = "." context.addServlet(TemplateServlet, "*.gsp") server.start() • jetty Jar • Maven Jar ‾/.groovy/ grapes Slide# 29 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 46. a = 4 assert 1+Math.max(3,a)*5==3 ==> EXCEPTION: Assertion failed: assert 1+Math.max(3,a)*5==3 | | | | | 21 4 4 | false 25 • assert FAIL Slide# 30 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 47. @Bindable / Swing @Vetoable (java.beans. PropertyChangeSupport ) @Singleton @Immutable @Delegate @Lazy @Category @Mixin mixin @Newify Python/Ruby new( : Integer(5), Integer.new(5)) @PackageScope package Slide# 31 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 48. @Singleton class Foo {  def hello() { println "hello" } } Foo.instance.hello()  // a = new Foo()  // new ==> EXCEPTION: java.lang.RuntimeException: Can't instantiate singleton Foo. Use Foo.instance at Foo.<init>(Script1.groovy) at Script1.run(Script1.groovy:6) Slide# 32 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 49. @Immutable final class Foo {   String x, y } a  = new Foo(x:"a",y:"b") a.x = "hoge"  // ==> EXCEPTION: groovy.lang.ReadOnlyPropertyException: Cannot set readonly property: x for class: Foo at Foo.setProperty(Script1.groovy) at Script1.run(Script1.groovy:6) Slide# 33 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 50. /Proxy import java.util.concurrent.locks.* class LockableMap {   @Delegate private Map map = [:]   @Delegate private Lock lock = new ReentrantLock () } res = new LockableMap() res.lock() // Lock try {   res.a = 0 // Map } finally {   res.unlock () } assert res instanceof Map assert res instanceof Lock Slide# 34 JJUG CCC 2009 Fall / 2009.10.08 http://www.infoq.com/jp/articles/groovy-1-6 2009 10 10
  • 51. class LazyTest {   @Lazy List s1 ={println "s1 initializing"; [1,2,3] }();   List  s2 = {println "s2 initializing"; [4,5,6] }(); } x = new LazyTest() // s2 initializing println x.s1       // s1 // s1 initializing // [1, 2, 3] println x.s2 // [4, 5, 6] println x.s1 // [1, 2, 3] Slide# 35 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 52. • use @Category(String) class TrMethod {   String tr(from,to) {     def result = this     from.eachWithIndex{it,idx->       result = result.replaceAll(it, to.getAt(idx))     }     result   } } use (TrMethod) {   assert 'abcdef 123'.tr('abc ','XYZ ') == 'XYZdef 123' } Slide# 36 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 53. class Dumpable { x = new MyClass()   void dump() { x.dump() this.metaClass.methods.each{ ==>  println it.name } toString     this.metaClass.properties.each { dump  println it.name } get__timeStamp__239_ne   } 28920761 } set__timeStamp__239_ne 28920761 @Mixin(Dumpable) equals class MyClass { getClass   int field :   void foo() {} bar   int bar(String i) {} foo } field Slide# 37 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 54. • Python/Ruby new class Test {   @Newify(String) // Python   static test() {     def s0 = new String("hoge") // Groovy/Java     def s1 = String("hoge")  // Python     def s2 = String.new("hoge")  // Ruby   } } Slide# 38 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 55. transform Slide# 39 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 56. AST • ( AST ) • Groovy Slide# 40 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 57. AST • • AST • META-INF/services/ org.codehaus.groovy.transform.AST Transformation • Groovy (JAR ) Slide# 41 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 58. ASTTransformation • • void visit(ASTNode[] nodes, SourceUnit source) • SourceUnit getSourceUnit() • visit() AST Visitor Slide# 42 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 59. _FILE_, _LINE_, _CLASS_, _METHOD_ AST • log("$_FILE_:$_LINE_: $_CLASS_:$_METHOD_ ", ..) Slide# 43 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 60. package org.jggug.transform import org.codehaus.groovy.transform.GroovyASTTransformationClass; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import java.lang.annotation.ElementType; @Retention(RetentionPolicy.SOURCE) @Target([ElementType.TYPE]) @GroovyASTTransformationClass("org.jggug.transform.U seSourceInfoSymbolASTTransformation") public @interface UseSourceInfoSymbol { } AST Slide# 44 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 61. package org.jggug.transform   void visitConstructorOrMethod(MethodNode import org.codehaus.groovy.ast.*; node, boolean isConstructor) { import org.codehaus.groovy.ast.expr.*; import org.codehaus.groovy.ast.stmt.Statement;     visitingMethod = node.name import org.codehaus.groovy.control.CompilePhase; import org.codehaus.groovy.control.SourceUnit;     super.visitConstructorOrMethod(node, import org.codehaus.groovy.transform.ASTTransformation; import org.codehaus.groovy.transform.GroovyASTTransformation; isConstructor)   } @GroovyASTTransformation(phase = ( ) CompilePhase.CANONICALIZATION) public class UseSourceInfoSymbolASTTransformation extends ClassCodeExpressionTransformer implements ASTTransformation {   private SourceUnit sourceUnit;   SourceUnit getSourceUnit() {     return sourceUnit;   }   String visitingMethod = null   String visitingClass = null   void visit(ASTNode[] nodes, SourceUnit source) {     sourceUnit = source;     def parent = nodes[1]     visitingClass = parent.name     super.visitClass(parent)   } Slide# 45 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 62.   Expression transform(Expression exp) {     if (exp == null) return null;     switch (exp.class) {     case VariableExpression.class:       switch (exp.name) {         case '_FILE_': return new ConstantExpression(sourceUnit.name)         case '_LINE_': return new ConstantExpression(exp.lineNumber)         case '_COLUMN_': return new ConstantExpression(exp.columnNumber)         case '_CLASS_': return new ConstantExpression(visitingClass)         case '_METHOD_': return new ConstantExpression(visitingMethod)         default: return exp       }     case MethodCallExpression.class:       def args = transform(exp.arguments);       def method = transform(exp.method);       def object = transform(exp.objectExpression);       return new MethodCallExpression(object, method, args);     case ClosureExpression.class:       Statement code = exp.code;       if (code == null) return exp       return code.visit(this)     case ConstructorCallExpression.class:       return exp.transformExpression(this)     default:       return exp.transformExpression(this)     }   } } Slide# 46 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 63. import org.jggug.transform.UseSourceInfoSymbol @UseSourceInfoSymbol class Test {   def foo(hoge, fuga) {     println _FILE_+':'+_LINE_     println _FILE_+':'+_LINE_     println _FILE_+':'+_LINE_     println _FILE_+':'+_LINE_ ==>     println _FILE_+':'+_LINE_ /tmp/test02.groovy:6     println _CLASS_+':'+_METHOD_ /tmp/test02.groovy:7   } /tmp/test02.groovy:8 } /tmp/test02.groovy:9 /tmp/test02.groovy:10 test = new Test() sample.Test:foo test.foo(1,2) Slide# 47 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 64. • $b (Java 7 ) @UseBinaryLit eral println $b01_001_0001 ==> 145 @WithTimeout @WithTimeout(3) def work() { ....... } @Define(symbol="that", value="delegate") @Define @Define(symbol=" ", value="it") @Define(symbol=" ", value="this") Slide# 48 @Define(symbol=" JJUG CCC 2009 Fall / 2009.10.08 ", value="println") 2009 10 10
  • 65. • groovyConsole AST Slide# 49 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 66. • ASTBuilder • buildFromSpec … AST DSL • buildFromString … AST • buildFromCode … ( ) AST Slide# 50 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 67. • • • • Scala @Scalify Slide# 51 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 68. Slide# 52 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 69. • Groovy Java • • : • DSL • • Slide# 53 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 70. • http://www.jggug.org/ Slide# 54 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10
  • 71. http://groovy.codehaus.org/Compile-time+Metaprogramming+-+AST +Transformations Compile-time Metaprogramming - AST Transformations • http://groovy.codehaus.org/AST+Macros+and+Annotations AST Macros and Annotations • http://groovy.codehaus.org/Building+AST+Guide Building AST in Groovy 1.6 and Prior • http://kartik-shah.blogspot.com/2009/03/groovy-16-ast- transformation-example_5323.html Groovy 1.6 AST Transformation Example • http://www.infoq.com/jp/articles/groovy-1-6 Groovy 1.6 - Groovy • http://www.slideshare.net/paulk_asert/groovy-testing- aug2009-1945995 Groovy Testing Sep2009 • http://dl.getdropbox.com/u/132573/groovy_scala/index.html Groovy Scala: JVM • Slide# 55 JJUG CCC 2009 Fall / 2009.10.08 2009 10 10