jilc-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Jilc-dev] "switch-case" Causing Problems


From: Gaurav Vaish
Subject: [Jilc-dev] "switch-case" Causing Problems
Date: Mon, 25 Feb 2002 11:15:58 +0530

Hi,
    I executed the deassembler on a program with switch-case and it fails.
    I am including (inline) the program and the output thrown. The same result
is emitted whether I use the new code or the original code.

    I tried experimenting with the values in the SWITCH block in jdasm.c, but
only wasting my time. All the bytes (code[start +n], 0<=n<=3) give values as
ZERO!!

    The SWITCH is driving me crazy...
    (Don't worry about the numbers before the deassembled code, I was working
with label management.)

Cheers,
Gaurav Vaish
http://home.iitk.ac.in/student/gvaish
http://calendar.yahoo.com/mastergaurav
-----------------------

Program:

import java.lang.*;
public class Test6
{
    public void switchTest(int val)
    {
        switch(val)
        {
            case 9: return;
            case 0: switchTest(++val);
                        break;
            case 1: switchTest(++val);
            case 2: switchTest(++val);
                        break;
            default: break;
        }
    }
}

-----------------------------------
Output:

.source Test6.java
.class public synchronized Test6
.super java/lang/Object

.method public <init>()V
.limit stack 1
.limit locals 1
    0 aload_0
    1 invokenonvirtual java/lang/Object/<init> ()V
    4 return
.end method

.method public switchTest(I)V
.limit stack 2
.limit locals 2
    0 iload_1
    1 tableswitch //0 key-values            <-- Problem here
                                        <-- Where are the values 9, 0, 1, 2?
        default: 87
    12 nop
    13 nop
    14 nop
    15 lconst_0
    16 nop
    17 nop
    18 nop
    19 fstore 0
    21 nop
    22 nop
    23 fstore_0
    24 nop
    25 nop
    26 nop
    27 astore_0
    28 nop
    29 nop
    30 nop
    31 sastore
    32 nop
    33 nop
    34 nop
    35 sastore
    36 nop
    37 nop
    38 nop
    39 sastore
    40 nop
    41 nop
    42 nop
    43 sastore
    44 nop
    45 nop
    46 nop
    47 sastore
    48 nop
    49 nop
    50 nop
    51 sastore
    52 nop
    53 nop
    54 nop
    55 lstore 177
    57 aload_0
    58 iinc 1 1
    61 iload_1
    62 invokevirtual Test6/switchTest (I)V
    65 goto 87         //code offset
    68 aload_0
    69 iinc 1 1
    72 iload_1
    73 invokevirtual Test6/switchTest (I)V
    76 aload_0
    77 iinc 1 1
    80 iload_1
    81 invokevirtual Test6/switchTest (I)V
    84 goto 87         //code offset
    87 return
.end method

// TODO: label management
// TODO: wide opcode not supported
-----------------------------------------






reply via email to

[Prev in Thread] Current Thread [Next in Thread]