Class InstrumentingClassWriter

java.lang.Object
org.objectweb.asm.ClassVisitor
org.objectweb.asm.ClassWriter
org.robolectric.internal.bytecode.InstrumentingClassWriter

public class InstrumentingClassWriter
extends org.objectweb.asm.ClassWriter
ClassWriter implementation that verifies classes by comparing type information obtained from loading the classes as resources. This was taken from the ASM ClassWriter unit tests.
  • Field Summary

    Fields inherited from class org.objectweb.asm.ClassWriter

    COMPUTE_FRAMES, COMPUTE_MAXS

    Fields inherited from class org.objectweb.asm.ClassVisitor

    api, cv
  • Constructor Summary

    Constructors 
    Constructor Description
    InstrumentingClassWriter​(ClassNodeProvider classNodeProvider, org.objectweb.asm.tree.ClassNode classNode)
    Preserve stack map frames for V51 and newer bytecode.
  • Method Summary

    Modifier and Type Method Description
    protected String getCommonSuperClass​(String type1, String type2)
    Returns the common super type of the two given types without actually loading the classes in the ClassLoader.

    Methods inherited from class org.objectweb.asm.ClassWriter

    getClassLoader, newClass, newConst, newConstantDynamic, newField, newHandle, newHandle, newInvokeDynamic, newMethod, newMethodType, newModule, newNameType, newPackage, newUTF8, toByteArray, visit, visitAnnotation, visitAttribute, visitEnd, visitField, visitInnerClass, visitMethod, visitModule, visitNestHost, visitNestMember, visitOuterClass, visitPermittedSubclass, visitRecordComponent, visitSource, visitTypeAnnotation

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • InstrumentingClassWriter

      public InstrumentingClassWriter​(ClassNodeProvider classNodeProvider, org.objectweb.asm.tree.ClassNode classNode)
      Preserve stack map frames for V51 and newer bytecode. This fixes class verification errors for JDK7 and JDK8. The option to disable bytecode verification was removed in JDK8.

      Don't bother for V50 and earlier bytecode, because it doesn't contain stack map frames, and also because ASM's stack map frame handling doesn't support the JSR and RET instructions present in legacy bytecode.

  • Method Details

    • getCommonSuperClass

      protected String getCommonSuperClass​(String type1, String type2)
      Returns the common super type of the two given types without actually loading the classes in the ClassLoader.
      Overrides:
      getCommonSuperClass in class org.objectweb.asm.ClassWriter