It seems you need a branch and so a different stackmap frame for verification to catch such problems.
I have been staring at this code for a while now wondering how the bad code generated still works:
 
public
class X {
      
public
static
void main(String[]
args) {
             
             
foo(String.class,
switch (42) {
             
default -> {
                    
try {
                          
yield 42;
                     }
finally {
 
                     }
              }
              });
       }
      
      
static
void foo(Class<?>
c,
int
v) {
              System.out.println(c);
              System.out.println(v);
       }
}
 
 
On master, we generate the following code: 
 
  public static void main(java.lang.String[]);
    descriptor: ([Ljava/lang/String;)V
    flags: (0x0009) ACC_PUBLIC, ACC_STATIC
    Code:
      stack=2, locals=3, args_size=1
         0: ldc           #16                 // class java/lang/String
         2: astore_1                        <<ß-------------------- Class Object being stored into String See LVT slot 1 below.
         3: bipush        42
         5: istore_2
         6: aload_1                             <<ß-------------------- aload loads an object statically typed String, but at bci 8 we invoke a method that expects a Class object
         7: iload_2
         8: invokestatic  #18                 // Method foo:(Ljava/lang/Class;I)V
        11: return
      LineNumberTable:
        line 4: 0
        line 7: 3
        line 4: 8
        line 13: 11
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0      12     0  args   [Ljava/lang/String;
            3       5     1  yieldValue0   Ljava/lang/String;  <<ß---------------------- String typed local
            6       2     2  secretYieldValue   I
 
What am I overlooking ??
 
Srikanth