StaticInitMerger breaks interfaces
With a chain of ClassReader->StaticInitMerger->ClassWriter interfaces like this
http://grepcode.com/file_/repo1.maven.org/maven2/net.java.dev.glazedlists/glazedlists_java15/1.8.0/ca/odell/glazedlists/util/concurrent/LockFactory.java/?v=source
are corrupted and the Java VM will complain about illegal modifiers for methods.
The scenario is the following:
Some interfaces have a static fields which are assigned values that require
method calls. In bytecode this non-trivial assignment is compiled to a <clinit>
(however explicit static initializers in interfaces are not allowed by the Java
compiler).
StaticInitMerger simply renames all static initializers it finds and calls them
all in the single static initializer it creates.
In the case of the mentioned interface this results in one additional
non-abstract method in the interface which is not allowed by the Java VM. To
fix this special case we might want to combine/inline all initializers into a
single one in order to fix this problem.
I know that fields in interfaces are considered as bad practice by many
developers but this unfortunately happens in quite a lot of libraries which I
cannot simply ignore/replace.