src/jdk/nashorn/internal/codegen/CodeGenerator.java

Print this page

        

@@ -1843,11 +1843,12 @@
             final Type type = expression.getType();
 
             // If expression not int see if we can convert, if not use deflt to trigger default.
             if (!type.isInteger()) {
                 method.load(deflt);
-                method.invoke(staticCallNoLookup(ScriptRuntime.class, "switchTagAsInt", int.class, type.getTypeClass(), int.class));
+                final Class exprClass = type.getTypeClass();
+                method.invoke(staticCallNoLookup(ScriptRuntime.class, "switchTagAsInt", int.class, exprClass.isPrimitive()? exprClass : Object.class, int.class));
             }
 
             // If reasonable size and not too sparse (80%), use table otherwise use lookup.
             if (range > 0 && range < 4096 && range < (size * 5 / 4)) {
                 final Label[] table = new Label[range];