Module java.base

Interface CodeStackTracker

All Superinterfaces:
ClassFileTransformPREVIEW<CodeTransformPREVIEW,CodeElementPREVIEW,CodeBuilderPREVIEW>, CodeTransformPREVIEW

public sealed interface CodeStackTracker extends CodeTransformPREVIEW
CodeStackTracker is a preview API of the Java platform.
Programs can only use CodeStackTracker when preview features are enabled.
Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.
CodeStackTrackerPREVIEW is a CodeTransformPREVIEW tracking stack content and calculating max stack size.

Sample use:

    var stackTracker = CodeStackTracker.of();
    codeBuilder.transforming(stackTracker, trackedBuilder -> {
        trackedBuilder.aload(0);
        trackedBuilder.lconst_0();
        trackedBuilder.ifThen(...);
        ...
        var stack = stackTracker.stack().get();
        int maxStack = stackTracker.maxStackSize().get();
    });
Since:
22