11. Code representations
for (int i = 0; i < 8; i++) ...for (int i = 0; i < 8; i++) ...
iconst 0
istore v0
iload v0
bipush 8
ificmpge +12
...
iinc v0, 1
goto -12
iconst 0
istore v0
iload v0
bipush 8
ificmpge +12
...
iinc v0, 1
goto -12
const/4 v0, #0
const/16 v1, #8
if-ge v0, v1, 8
...
add-int/lit8 v0, v0, #1
goto -9
const/4 v0, #0
const/16 v1, #8
if-ge v0, v1, 8
...
add-int/lit8 v0, v0, #1
goto -9
.class .dex
.java
Efficient to store and execute
Inconvenient to process
12. Code representations
for (int i = 0; i < 8; i++) ...for (int i = 0; i < 8; i++) ...
iconst 0
istore v0
iload v0
bipush 8
ificmpge +12
...
iinc v0, 1
goto -12
iconst 0
istore v0
iload v0
bipush 8
ificmpge +12
...
iinc v0, 1
goto -12
const/4 v0, #0
const/16 v1, #8
if-ge v0, v1, 8
...
add-int/lit8 v0, v0, #1
goto -9
const/4 v0, #0
const/16 v1, #8
if-ge v0, v1, 8
...
add-int/lit8 v0, v0, #1
goto -9
LOCAL int n
FOR_STATEMENT:
- EXPRESSION_STATEMENT:
- ASG_OPERATION:
- LOCAL_REF i
- INT_LITERAL 1
- LT_OPERATION:
- LOCAL_REF i
- INT_LITERAL 8
- POSTFIX_INC_OPERATION:
- LOCAL_REF i
- ...
LOCAL int n
FOR_STATEMENT:
- EXPRESSION_STATEMENT:
- ASG_OPERATION:
- LOCAL_REF i
- INT_LITERAL 1
- LT_OPERATION:
- LOCAL_REF i
- INT_LITERAL 8
- POSTFIX_INC_OPERATION:
- LOCAL_REF i
- ...
.jayce.class .dex
.java
13. Implications of Jack and Jill
●
Java annotation processors – supported in Jack
E.g. Dagger, Butterknife
●
Bytecode processors – only supported via Jill
E.g. JaCoCo, Retrolambda
●
Other JVM languages – only supported via Jill
E.g. Scala, Groovy, Dart
14. Implications of Jack and Jill
Libraries
(.jayce)
Jack
Assets
Compiled
XML resources
(.xml)
Aapt
Dalvik bytecode
(classes.dex)
Javac annotation processors
E.g. Dagger, Butterknife
Source code
(.scala,...)
Libraries
(.class)
XML resources
(.xml)
Assets
Runtime
(.class)
Jill
Jill Runtime
(.jayce)
Bytecode processors
Java bytecode
(.class)Scalac
Application
(.jayce)Jill
20. Support for Java 8 – closures
●
Under development in branch 'ub-jack-lang-dev'
●
Test cases
●
Compiled to anonymous classes
Interface lambda = i -> i + 1;Interface lambda = i -> i + 1;
$ java -jar jack.jar --help-properties
...
jack.java.source.version:
Java source version (default is '1.8')
{1.3,1.4,1.5,5.0,5,1.6,6.0,6,1.7,7.0,7,1.8,8.0,8}
...
$ java -jar jack.jar --help-properties
...
jack.java.source.version:
Java source version (default is '1.8')
{1.3,1.4,1.5,5.0,5,1.6,6.0,6,1.7,7.0,7,1.8,8.0,8}
...
Interface lambda = new Interface() {
public int m(int i) {
return i + 1;
}
}
Interface lambda = new Interface() {
public int m(int i) {
return i + 1;
}
}