Class CompactArrayInitializer

java.lang.Object
EDU.purdue.cs.bloat.trans.CompactArrayInitializer
All Implemented Interfaces:
Opcode

public class CompactArrayInitializer extends Object implements Opcode
CompactArrayInitializer optimizes the initialization of arrays by transforming the initialization code into a loop that loads the array elements from a string in the class's constant pool.
  • Field Details

    • DEBUG

      public static boolean DEBUG
  • Constructor Details

    • CompactArrayInitializer

      public CompactArrayInitializer()
  • Method Details

    • transform

      public static boolean transform(MethodEditor method)
      Some Java compilers initialize arrays using straight-line code. For classes that have large, initialized arrays this results in unnecessarily large classfiles. CompactArrayInitializer examines a method (via its MethodEditor) creates a string in the method's class's constant pool that contains all of the elements of the initialized array. After the old initialization code is removed from the method, new code is inserted that essentially is a loop that loads each element from the string into the array. Note that only arrays of int, short, char, byte, and boolean are compacted.
      Parameters:
      method - The method whose array initializations are to be compacted.