java Synthetics
public class TestSynthetic {
public static void main ( String[ ] args) {
Inner inner = new Inner ( ) ;
System. out. println ( inner. i) ;
System. out. println ( inner. m ( ) ) ;
print ( Inner. class ) ;
}
private static void print ( Class clazz ) {
System. out. println ( "------fields------" ) ;
Field[ ] fields = clazz. getDeclaredFields ( ) ;
for ( Field field: fields) {
System. out. println ( field. isSynthetic ( ) + " " + field. getType ( ) + " " + field. getName ( ) ) ;
}
System. out. println ( "------methods------" ) ;
Method[ ] methods = clazz. getDeclaredMethods ( ) ;
for ( Method method: methods) {
System. out. println ( method. isSynthetic ( ) + " " + method. getReturnType ( ) + " " + method. getName ( ) ) ;
}
System. out. println ( "------constructs------" ) ;
Constructor< ? > [ ] cons = clazz. getDeclaredConstructors ( ) ;
for ( Constructor con: cons) {
System. out. println ( con. isSynthetic ( ) + " " + con. getName ( ) ) ;
}
}
static class Inner {
private Inner ( ) { }
private int i;
private int m ( ) {
return 1 ;
}
}
}
0
1
-- -- -- fields-- -- --
false int i
-- -- -- methods-- -- --
true int access$100
true int access$200
false int m
-- -- -- constructs-- -- --
true com. lry. basic. jvm. TestSynthetic$Inner
false com. lry. basic. jvm. TestSynthetic$Inner