Skip to content

filtering JAVAC.SYNTHCLASS

marchof edited this page Jan 10, 2013 · 9 revisions

Description

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 result 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.

Filtering

Synthetic classes are completely removed.

Source Example

switch (orientation) {
    case NORTH: ... ;
    case EAST: ... ;
    case SOUTH: ... ;
    case WEST: ... ;
}

Bytecode Pattern

There are two ways to mark synthetic classes:

  • ACC_SYNTHETIC bit in the access_flags field
  • Synthetic class attribute