Skip to content

filtering JAVAC.SYNTHMETH

marchof edited this page Jan 10, 2013 · 2 revisions

Description

Synthetic methods have no direct correspondence in source code and are created by the compiler for technical reasons. For example synthetic bridge methods are required to give inner classes access to private members of the containing class.

Filtering

Synthetic methods are completely removed.

Source Example

class Outer {

   private int counter;

    private class Inner {
        private void inc() {
            counter++;
        }
    }
}

Bytecode Pattern

There are two ways to mark synthetic methods:

  • ACC_SYNTHETIC bit in the access_flags field of the method
  • Synthetic method attribute