17. 静的型チェックにより検出されるエラー例
import groovy.transform.TypeChecked
@TypeChecked 型が違う!
int foo(String s) { そんなメソッド無い!
int i = s
// [Static type checking] - Cannot assign value of type java.lang.String to
variable of type int
String result = s.toUppperCase()
// [Static type checking] - Cannot find matching method
java.lang.String#toUppperCase(). Please check if the declared type is right and
if the method exists. 型が違う!
return result
// [Static type checking] - Cannot return value of type java.lang.String on
method returning type int
}
Slide # 11 JGGUG G*Workshop Copyright(C) 2012 NTT Software Corporation All rights reserved.
18. GGTS 3.0.0から利用
Slide # 12 JGGUG G*Workshop Copyright(C) 2012 NTT Software Corporation All rights reserved.
19. フローセンシティブタイピング
def a = -3
a.abs()
a.toUpperCase()
a = "ABC"
a.abs()
a.toUpperCase()
Slide # 13 JGGUG G*Workshop Copyright(C) 2012 NTT Software Corporation All rights reserved.
20. フローセンシティブタイピング
aはint型と見な
def a = -3
a.abs()
a.toUpperCase()
a = "ABC"
a.abs()
a.toUpperCase()
Slide # 13 JGGUG G*Workshop Copyright(C) 2012 NTT Software Corporation All rights reserved.
21. フローセンシティブタイピング
aはint型と見な
def a = -3
a.abs()
a.toUpperCase()
a = "ABC" aはString型と
a.abs()
a.toUpperCase()
Slide # 13 JGGUG G*Workshop Copyright(C) 2012 NTT Software Corporation All rights reserved.
22. フローセンシティブタイピング
aはint型と見な
def a = -3
[Static type checking] -
a.abs() Cannot find matching method
java.lang.Integer#toUpperCas
a.toUpperCase() e()
a = "ABC" aはString型と
a.abs()
a.toUpperCase()
Slide # 13 JGGUG G*Workshop Copyright(C) 2012 NTT Software Corporation All rights reserved.
23. フローセンシティブタイピング
aはint型と見な
def a = -3
[Static type checking] -
a.abs() Cannot find matching method
java.lang.Integer#toUpperCas
a.toUpperCase() e()
a = "ABC" aはString型と
a.abs()
[Static type checking] - Cannot
a.toUpperCase() find matching method
Slide # 13 JGGUG G*Workshop
java.lang.String#abs() rights reserved.
Copyright(C) 2012 NTT Software Corporation All
27. ベンチマーク(CompileStatic)
1.2##
1.0##
0.8##
CompileStatic
0.6##
Groovy#1.8.2#
0.4## Groovy#2.0.1#
Groovy#2.0.1#CompileSta<c#
0.2## Java#SE#1.7.0u6#
0.0##
]#
#
)]#
#
]#
)]#
]#
#
]#
#
a]
f)]
g]
rt]
es
y)
m
ch
ry
#i f
in
st
c#i
so
ar
or
re
ku
ce
na
a
dR
a<
rn
ck
lN
[F
y#T
nn
an
er
ea
#te
ui
( st
ra
ar
c#t
a
st
[Q
hr
ct
[F
ce
ib
(i n
in
a<
pe
[T
[F
an
[B
ib
( st
[S
st
[F
ib
(i n
[F
ib
[F
https://github.com/alextkachman/fib-benchmark をベースに計測。
グラフはJavaを1としたときの実行時間の比率(大きいほど速い)。
Slide # 15 JGGUG G*Workshop Copyright(C) 2012 NTT Software Corporation All rights reserved.
33. ベンチマーク(vs. Groovy++)
1.2##
Grroovy++
1.0##
0.8##
Groovy#1.8.2#
0.6##
Groovy#2.0.1#
0.4## Groovy#2.0.1#CompileSta<c#
Java#SE#1.7.0u6#
0.2## Groovy#2.0.1#indy#
Groovy++0.9.0/1.8.2#
0.0##
]#
#
)]#
)]#
]#
)]#
]#
#
]#
#
a]
g]
rt]
es
y)
m
ch
ry
f
#i f
in
st
c#i
so
ar
or
re
ku
ce
na
a
dR
a<
rn
ck
lN
[F
y#T
nn
an
er
ea
#te
ui
( st
ra
ar
c#t
a
st
[Q
hr
ct
[F
ce
ib
(i n
in
a<
pe
[T
[F
an
[B
ib
( st
[S
st
[F
ib
(i n
[F
ib
[F
Slide # 21 JGGUG G*Workshop Copyright(C) 2012 NTT Software Corporation All rights reserved.
36. ベンチマーク(indy)
1.2##
1.0##
0.8##
0.6## Groovy#1.8.2#
Groovy#2.0.1#
0.4##
Groovy#2.0.1#CompileSta<c#
Java#SE#1.7.0u6#
0.2##
Groovy#2.0.1#indy#
0.0##
]#
#
)]#
)]#
]#
)]#
]#
#
]#
#
a]
g]
rt]
es
y)
m
ch
ry
f
#i f
in
st
c#i
so
ar
or
re
ku
ce
na
a
dR
a<
rn
ck
lN
[F
y#T
nn
an
er
ea
#te
ui
( st
ra
ar
c#t
a
st
[Q
hr
ct
[F
ce
ib
(i n
in
a<
pe
[T
[F
an
[B
ib
( st
[S
st
[F
Groovy 2.0.1 -indy
ib
(i n
[F
ib
[F
Slide # 24 JGGUG G*Workshop Copyright(C) 2012 NTT Software Corporation All rights reserved.