Class Ek9ClassWriter
java.lang.Object
org.objectweb.asm.ClassVisitor
org.objectweb.asm.ClassWriter
org.ek9lang.compiler.backend.jvm.Ek9ClassWriter
final class Ek9ClassWriter
extends org.objectweb.asm.ClassWriter
Custom ClassWriter that doesn't require loading classes during frame computation.
Standard ClassWriter.COMPUTE_FRAMES uses ClassLoader to find common superclasses when computing stack map frames. This fails when generating multiple classes in the same compilation unit because referenced classes aren't on classpath yet.
This custom writer overrides getCommonSuperClass() to use a simpler heuristic: - For exception types, use java/lang/Throwable as common superclass - For other types, use java/lang/Object as common superclass
This is safe because: - Exception handler frame computation only needs to know exception hierarchy - EK9 exception types all extend java.lang.Exception (which extends Throwable) - Worst case: slightly larger stack frames, but still correct bytecode
-
Field Summary
Fields inherited from class org.objectweb.asm.ClassWriter
COMPUTE_FRAMES, COMPUTE_MAXSFields inherited from class org.objectweb.asm.ClassVisitor
api, cv -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringgetCommonSuperClass(String type1, String type2) Override getCommonSuperClass to avoid ClassLoader dependency.Methods inherited from class org.objectweb.asm.ClassWriter
getClassLoader, hasFlags, newClass, newConst, newConstantDynamic, newField, newHandle, newHandle, newInvokeDynamic, newMethod, newMethodType, newModule, newNameType, newPackage, newUTF8, setFlags, toByteArray, visit, visitAnnotation, visitAttribute, visitEnd, visitField, visitInnerClass, visitMethod, visitModule, visitNestHost, visitNestMember, visitOuterClass, visitPermittedSubclass, visitRecordComponent, visitSource, visitTypeAnnotationMethods inherited from class org.objectweb.asm.ClassVisitor
getDelegate
-
Constructor Details
-
Ek9ClassWriter
Ek9ClassWriter(int flags)
-
-
Method Details
-
getCommonSuperClass
Override getCommonSuperClass to avoid ClassLoader dependency. Uses conservative estimate instead of precise type hierarchy lookup.- Overrides:
getCommonSuperClassin classorg.objectweb.asm.ClassWriter- Parameters:
type1- First type (internal name, e.g., "bytecode/test/CustomExceptionA")type2- Second type (internal name, e.g., "bytecode/test/CustomExceptionB")- Returns:
- Common superclass internal name
-