Class StaticClassWriter


  • public class StaticClassWriter
    extends org.objectweb.asm.ClassWriter
    A ClassWriter that looks for static class data in the classpath when the classes are not available at runtime.

    ClassWriter uses class hierarchy information, which it gets by looking at loaded classes, to make some decisions about the best way to write classes. The problem with this is that it fails if the superclass hasn't been loaded yet. StaticClassWriter fails over to looking for the class hierarchy information in the ClassLoader's resources (usually the classpath) if the class it needs hasn't been loaded yet.

    This class was heavily influenced by ASM's org.objectweb.asm.util.ClassWriterComputeFramesTest, which contains the same logic in a subclass. The code here has been slightly cleaned up for readability.

    • 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
      StaticClassWriter​(org.objectweb.asm.ClassReader classReader, int flags, java.lang.ClassLoader classLoader)
      StaticClassWriter​(org.objectweb.asm.ClassReader classReader, int flags, java.lang.ClassLoader classLoader, boolean alwaysStatic)
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected java.lang.String getCommonSuperClass​(java.lang.String type1, java.lang.String type2)
      • Methods inherited from class org.objectweb.asm.ClassWriter

        getClassLoader, hasFlags, 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 org.objectweb.asm.ClassVisitor

        getDelegate
      • Methods inherited from class java.lang.Object

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

      • StaticClassWriter

        public StaticClassWriter​(org.objectweb.asm.ClassReader classReader,
                                 int flags,
                                 java.lang.ClassLoader classLoader)
        Parameters:
        classLoader - the class loader that loaded this class
      • StaticClassWriter

        public StaticClassWriter​(org.objectweb.asm.ClassReader classReader,
                                 int flags,
                                 java.lang.ClassLoader classLoader,
                                 boolean alwaysStatic)
        Parameters:
        classLoader - the class loader that loaded this class
        alwaysStatic - whether to always load class data statically
    • Method Detail

      • getCommonSuperClass

        protected java.lang.String getCommonSuperClass​(java.lang.String type1,
                                                       java.lang.String type2)
        Overrides:
        getCommonSuperClass in class org.objectweb.asm.ClassWriter