Open chintana-zz opened 5 years ago
From the stack trace, the exception is before Kraal has decided whether there are irreducible loops or not - at this point, it's just using ASM to analyze the control flow graph and hasn't modified the bytecode for this method. So, in theory you should be able to reproduce the exception just with ASM using Analyzer
and BasicInterpreter
. (And, this is most likely either an ASM issue or a Ballerina issue - just based on the stack trace, it seems unlikely that Kraal is to blame.)
The relevant Kraal code is MethodControlFlowGraph.createEdges(), though the overrides of the Analyzer
methods should be irrelevant here. It should really just be the ceremony of getting an ASM MethodNode
instance for your __init
method and then running an Analyzer
:
val analyzer = Analyzer<BasicValue>(BasicInterpreter())
analyzer.analyze("ballerina/io/WritableTextRecordChannel", myMethodNode)
If you're just looking to work around this, and you know there aren't actually irreducible loops in this class, it wouldn't be too hard to add a feature to Kraal to accept include/exclude filters for packages and classes.
Thanks! Yes, you're right. It works if I exclude standard lib classes in Ballerina. Let me clean it up a bit and send a PR.
Thanks for publishing this useful tool. I'm trying to get native image generation for jars generated by Ballerina language. When I'm testing, I could generate a simple jar file and run it with Ballerina. Also I can use GraalVM to generate a native image out of it. When I try to run kraal on the same jar, I'm seeing following exception.
The file in question ballerina/io/WritableTextRecordChannel.class contains standard IO routines in Ballerina language. Byte code generation in Ballerina is done through ASM lib as well.
javap -c -p -v output for the class can be found here. There the instruction 115 seems to be an aastore. May be I'm looking at the wrong place. Appreciate any tips for debugging this. Thanks.