• Max Cai's avatar
    Avoid class initializers to help ProGuard. · 04feb76f
    Max Cai authored
    Class initializers prevent ProGuard from inlining any methods
    because it thinks the class initializer may have side effects.
    This is true for static methods, but instance methods can still
    be inlined, because to have an instance you will have touched
    the class and any class initializers would have run. But
    ProGuard only starts inlining instance methods of classes with
    class initializers from v4.11b6, and Android uses v4.4 now.
    
    This change tries to avoid the class initializers as much as
    possible, by delaying the initialization of the empty array and
    some fields' saved defaults until when they're needed. However,
    if the message hosts any extensions, they must be public static
    final and therefore introducing the class initializer. In that
    case we won't bother with lazy initialization.
    
    Change-Id: I00d8296f6eb0023112b93ee135cdb28dbd52b0b8
    04feb76f
javanano_message_field.cc 8.62 KB