Skip to content

Commit 87581ce

Browse files
committed
better synthetic exampls
1 parent 4960431 commit 87581ce

1 file changed

Lines changed: 22 additions & 16 deletions

File tree

example-code/Synthetic.java

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,27 @@
11
public class Synthetic {
22

3-
class Inner {
4-
// contains auto-generated (synthetic)
5-
// field "this$0" of type Synthetic
6-
}
3+
class Inner {
4+
// contains auto-generated (synthetic)
5+
// field "this$0" of type Synthetic
6+
}
77

8-
public static void main(String[] args) {
9-
Synthetic a = new Synthetic();
10-
Synthetic b = new Synthetic();
11-
Inner c = a.new Inner();
12-
Inner d = b.new Inner();
13-
// end of first
8+
public static void main(String[] args) {
9+
Synthetic a = new Synthetic();
10+
Synthetic b = new Synthetic();
11+
Inner c = a.new Inner();
12+
Inner d = b.new Inner();
13+
// end of first
1414

15-
final String[] magic = {"7", "8"};
16-
// anonymous class
17-
Object e = new Object(){public String toString() {return magic[1];}};
18-
// it has a synthetic variable val$magic
19-
System.out.println(e.toString());
20-
}
15+
final String[] magic = {"7", "8"};
16+
// anonymous class
17+
Object e = new Object(){public String toString() {return magic[1];}};
18+
// it has a synthetic variable val$magic
19+
System.out.println(e.toString());
20+
21+
class Local {
22+
void foo() {System.out.println(magic.length);}
23+
}
24+
Local x = new Local();
25+
x.foo();
26+
}
2127
}

0 commit comments

Comments
 (0)