Module Simula

Class ExtendedClassWriter

java.lang.Object
org.objectweb.asm.ClassVisitor
org.objectweb.asm.ClassWriter
simula.compiler.byteCodeEngineering.ExtendedClassWriter

public class ExtendedClassWriter extends org.objectweb.asm.ClassWriter
Extended ClassWriter.

This class is introduced to compensate for a weakness in ASM ( https://asm.ow2.io/ ).

ClassWriter.getCommonSuperClass does not work because Global.tempClassFileDir is not present in java.class.path

Instead we use the information we have about all generated .class files to find common superclass of two types.

Link to GitHub: Source File.

Author:
Øystein Myhre Andersen
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final boolean
    DEBUG on/off

    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
    ExtendedClassWriter(org.objectweb.asm.ClassReader classReader, int flags)
    Create a new ExtendedClassWriter.
  • Method Summary

    Modifier and Type
    Method
    Description
    private static JavaClassInfo
    Get class info
    protected String
    Returns the common super type of the two given types.

    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
  • Field Details

  • Constructor Details

    • ExtendedClassWriter

      public ExtendedClassWriter(org.objectweb.asm.ClassReader classReader, int flags)
      Create a new ExtendedClassWriter.
      Parameters:
      classReader - the ClassReader used to read the original class.
      flags - option flags that can be used to modify the default behavior of this class.
  • Method Details

    • getCommonSuperClass

      protected String getCommonSuperClass(String type1, String type2)
      Description copied from class: org.objectweb.asm.ClassWriter
      Returns the common super type of the two given types. The default implementation of this method loads the two given classes and uses the java.lang.Class methods to find the common super class. It can be overridden to compute this common super type in other ways, in particular without actually loading any class, or to take into account the class that is currently being generated by this ClassWriter, which can of course not be loaded since it is under construction.
      Overrides:
      getCommonSuperClass in class org.objectweb.asm.ClassWriter
      Parameters:
      type1 - the internal name of a class (see Type.getInternalName()).
      type2 - the internal name of another class (see Type.getInternalName()).
      Returns:
      the internal name of the common super class of the two given classes (see Type.getInternalName()).
    • getClassInfo

      private static JavaClassInfo getClassInfo(String type)
      Get class info
      Parameters:
      type - the type
      Returns:
      the resulting JavaClassInfo