View Javadoc
1   /*
2    * MIT License
3    * Copyright (c) 2006-2025 JMockit developers
4    * See LICENSE file for full license text.
5    */
6   package mockit.asm.controlFlow;
7   
8   import edu.umd.cs.findbugs.annotations.NonNull;
9   
10  /**
11   * An edge in the control flow graph of a method body. See {@link Label}.
12   */
13  public final class Edge {
14      /**
15       * Denotes a normal control flow graph edge.
16       */
17      static final int NORMAL = 0;
18  
19      /**
20       * Denotes a control flow graph edge corresponding to an exception handler. More precisely any {@link Edge} whose
21       * {@link #info} is strictly positive corresponds to an exception handler. The actual value of {@link #info} is the
22       * index, in the type table of the classfile being written, of the exception that is caught.
23       */
24      public static final int EXCEPTION = 0x7FFFFFFF;
25  
26      /**
27       * Information about this control flow graph edge. For classfiles older than 1.7, this field is the (relative) stack
28       * size in the basic block from which this edge originates. This size is equal to the stack size at the "jump"
29       * instruction to which this edge corresponds, relatively to the stack size at the beginning of the originating
30       * basic block. For 1.7+ classfiles, this field is the kind of this control flow graph edge (i.e. NORMAL or
31       * EXCEPTION).
32       */
33      final int info;
34  
35      /**
36       * The successor block of the basic block from which this edge originates.
37       */
38      final Label successor;
39  
40      /**
41       * The next edge in the list of successors of the originating basic block. See {@link Label#successors}.
42       */
43      Edge next;
44  
45      public Edge(int info, @NonNull Label successor) {
46          this.info = info;
47          this.successor = successor;
48      }
49  
50      /**
51       * Sets the {@link #next} edge.
52       */
53      public void setNext(Edge next) {
54          this.next = next;
55      }
56  }