Skip to content

filtering JAVAC.SYNTHMETH

Evgeny Mandrikov edited this page Mar 11, 2017 · 4 revisions

This page discusses a not yet available feature!

Description

Some 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. Also synthetic methods are required for lambda expressions and their code corresponds to body of lambda expression.

Filtering

Synthetic methods whose name doesn't start from lambda$ 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