jump to case label ... crosses initialization

Raffaello Giulietti raffaello.giulietti at gmail.com
Tue Sep 1 04:03:10 PDT 2009


Hello,

the gcc compiler (I'm using 4.3.3) correctly complains about "jump to
case label ... crosses initialization" twice.

In fact, when declaring a var "inside" a case in a switch, braces are
needed to make a block out of the statements. Otherwise the declaration
has a wider scope than the case.




I'm in
$davinci/sources/hotspot/src/share/vm/prims
and here's a --git patch:


diff --git a/src/share/vm/prims/methodHandleWalk.cpp
b/src/share/vm/prims/methodHandleWalk.cpp
--- a/src/share/vm/prims/methodHandleWalk.cpp
+++ b/src/share/vm/prims/methodHandleWalk.cpp
@@ -621,11 +621,12 @@

 void MethodHandleCompiler::emit_load_constant(ArgToken arg) {
   switch (arg.basic_type()) {
-  case T_OBJECT:
-    int index = cpool_object_put(arg.object());
-    _bytecode.push(Bytecodes::_ldc);
-    _bytecode.push(index);
-    _max_stack++;
+  case T_OBJECT: {
+      int index = cpool_object_put(arg.object());
+      _bytecode.push(Bytecodes::_ldc);
+      _bytecode.push(index);
+      _max_stack++;
+    }
     break;
   default:
     ShouldNotReachHere();
@@ -665,13 +666,14 @@
       index = new_local(type);
     emit_store(type, index);
     break;
-  case Bytecodes::_checkcast:
-    emit_load(srctype, index);
-    int class_index = cpool_klass_put(tk);
-    _bytecode.push(op);
-    _bytecode.push(class_index >> 8);
-    _bytecode.push(class_index);
-    emit_store(srctype, index);
+  case Bytecodes::_checkcast: {
+      emit_load(srctype, index);
+      int class_index = cpool_klass_put(tk);
+      _bytecode.push(op);
+      _bytecode.push(class_index >> 8);
+      _bytecode.push(class_index);
+      emit_store(srctype, index);
+    }
     break;
   default:
     ShouldNotReachHere();



More information about the mlvm-dev mailing list