-
Notifications
You must be signed in to change notification settings - Fork 1.1k
filtering JAVAC.SYNTHCLASS
This page discusses a not yet available feature!
Synthetic class have no direct relationship to the classes defined in source code and are created by the compiler for technical reasons.
For example switches on enums when compiled with javac results in a synthetic class which holds a "switch map" to map the actual enum ordinals (which may change if the enum is modified) to constants int values which are used in the lookupswitch
instruction. Note that javac 1.5.0_22 marks only field with map as synthetic, but not a class. Also note that ECJ places "switch map" and synthetic method for its initialization into the same class instead.
Synthetic classes are completely removed.
This results in instructions partial coverage of switch statement, because static initializer with uncovered exception handler in generated class refers to it:
class Fun {
enum E {
A, B
}
void fun(E e) {
switch (e) {
case A: ... ;
default: ... ;
}
}
public static void main(String[] args) {
fun(E.A);
fun(E.B);
}
}
There are two ways to mark synthetic classes:
-
ACC_SYNTHETIC
bit in theaccess_flags
field -
Synthetic
class attribute