Esempio n. 1
0
  protected void markProgramClassBody(ProgramClass programClass) {
    // Mark this class's name.
    markConstant(programClass, programClass.u2thisClass);

    // Mark the superclass.
    if (programClass.u2superClass != 0) {
      markConstant(programClass, programClass.u2superClass);
    }

    // Give the interfaces preliminary marks.
    programClass.hierarchyAccept(false, false, true, false, interfaceUsageMarker);

    // Explicitly mark the <clinit> method.
    programClass.methodAccept(
        ClassConstants.INTERNAL_METHOD_NAME_CLINIT,
        ClassConstants.INTERNAL_METHOD_TYPE_CLINIT,
        this);

    // Explicitly mark the parameterless <init> method.
    programClass.methodAccept(
        ClassConstants.INTERNAL_METHOD_NAME_INIT, ClassConstants.INTERNAL_METHOD_TYPE_INIT, this);

    // Process all class members that have already been marked as possibly used.
    programClass.fieldsAccept(possiblyUsedMemberUsageMarker);
    programClass.methodsAccept(possiblyUsedMemberUsageMarker);

    // Mark the attributes.
    programClass.attributesAccept(this);
  }
  public void visitProgramClass(ProgramClass programClass) {
    if (DEBUG) {
      System.out.println("SimpleEnumClassSimplifier: [" + programClass.getName() + "]");
    }

    // Unmark the class as an enum.
    programClass.u2accessFlags &= ~ClassConstants.ACC_ENUM;

    // Remove the valueOf method, if present.
    Method valueOfMethod = programClass.findMethod(ClassConstants.METHOD_NAME_VALUEOF, null);
    if (valueOfMethod != null) {
      new ClassEditor(programClass).removeMethod(valueOfMethod);
    }

    // Simplify the static initializer.
    programClass.methodAccept(
        ClassConstants.METHOD_NAME_CLINIT,
        ClassConstants.METHOD_TYPE_CLINIT,
        initializerSimplifier);
  }