java synthetic class

Synthetic class does not appear in your code, but made up by compiler. E.g. Bridge method made up by compiler in java is typically synthetic.

public class Pair {
private T first;
private T second;
public void setSecond(T newValue) {
second = newValue;
}// Of seSecond
}// Of class Pair


public class DateInterval extends Pair {
public void setSecond(String second) {
System.out.println("OK sub");
}

public static void main(String[] args) throws NoSuchFieldException, SecurityException {

DateInterval interval = new DateInterval();
Pair pair = interval;
pair.setSecond("string1");
}
}
Using javap -verbose DateInterval instruction, u can see a bridge method

public void setSecond(java.lang.Object);
flags: ACC_PUBLIC, ACC_BRIDGE, ACC_SYNTHETIC
it is made up by compiler, however does not appear in your code.

你可能感兴趣的:(java,学习日志)