在 java 代码中使用 switch case 注入代码生成器时出现 Int switch 错误

Int switch error when inject code generator with switch case in java code

Caused by: java.lang.AssertionError at com.android.tools.r8.ir.code.IntSwitch.valid(IntSwitch.java:67) at com.android.tools.r8.ir.code.IntSwitch.(IntSwitch.java:35) at com.android.tools.r8.ir.conversion.IRBuilder.createSwitch(IRBuilder.java:1922) at com.android.tools.r8.ir.conversion.IRBuilder.addSwitch(IRBuilder.java:1886) at com.android.tools.r8.cf.code.CfSwitch.buildIR(CfSwitch.java:101) at com.android.tools.r8.ir.conversion.CfSourceCode.build(CfSourceCode.java:581) Caused by: com.android.builder.dexing.DexArchiveBuilderException: Error while dexing.

java样本

 public IFactory getInjectMap(String var1) {
          byte var2 = -1;
          switch(var1.hashCode()) {
          case 2011670744:
             if (var1.equals("xxx.xxx.xxx.xxx")) {
                var2 = 0;
             }
             break;
          case -1047643106:
             if (var1.equals("xxx.xxx.xxx.xxx")) {
                var2 = 1;
             }
             break;
          }
    
          switch(var2) {
          case 0:
             var2 = (byte)(new xxxxFactory());
             break;
          case 1:
             var2 = (byte)(new xxxxFactory());
             break;
          default:
             var2 = (byte)null;
          }
    
          return var2;
       }
    }

assertion error you hit is validating that the values in the lookupswitch instruction is ordered, as mandated by the JVM specification。这表明生成的字节码不符合规范。此代码 运行 在 JVM 上吗?

这也被报告为 https://issuetracker.google.com/200284898#comment6