Bug 8773

Summary: VerifyError : A .class file exported from VAJ does not run in JDK 1.2.2 (1GPPET0)
Product: [Eclipse Project] JDT Reporter: Philipe Mulet <philippe_mulet>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P1    
Version: 2.0   
Target Milestone: 2.0 M3   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description Philipe Mulet CLA 2002-01-30 13:00:21 EST
Build 20020125

This defect was originally reported against VAJ 3.5.3, and we have the same bug 
in Eclipse.

==================
When compiling the following test case and running it, we get a verification 
error:

  "Exception in thread "main" java.lang.VerifyError:
   (class: VerifyEr, method: err signature: ()Z)
   Register 1 contains wrong type"

STEPS TO RECREATE THE PROBLEM:

1. Have VAJava installed.  Also install JDK 1.2.2.
2. Create a test project and import VerifyEr.java to the test project.
3. Run the "test" class from the "Workbench" window.  This confirms that
   the class compiled using VAJava compiler runs normally on VAJava
   environment.
4. Export the class to a directory.
5. Run the exported class on JDK.  This produces the verify error as
   mentioned above. <----------------------------- This is the problem !
6. Compile the VerifyEr.java using JDK.
7. Run the class compiled by JDK on JDK.  Confirm "No Err".

THE SOURCE CODE FOR THE TEST CASE:

/**
 * VerifyError
  * @author: Administrator
 */
class VerifyEr {

     protected int ii;

/**
 * VerifyEr
 */
public VerifyEr() {
     super();
     System.out.println("No Err");
}
protected boolean err() {
     try {

          ii = 0;
          System.out.println("I'm here");

     } catch (Throwable t) {

          return getb();
     } finally {
          try {
               if (getb()) {
                    return getb();
               }
          } finally {
               if (getb()) {
                    return false;
               }
          }
     }
     return false;
}
protected boolean getb() {
     System.out.println("I'm here");
     return false;

}
/**
 */
public static void main(String[] args) {

     new VerifyEr();
}
}
Comment 1 Philipe Mulet CLA 2002-01-30 13:03:22 EST
Bug is due to the fact we share all saveValueVariables, and in case of nested 
finally blocks, it clearly shouldn't occur.

Simpler test case:

class VerifyEr {
protected boolean err(boolean b) {
     try {
          System.out.print("SUCC");
     } catch (Throwable t) {
          return b;
     } finally {
          try {
               if (b) {
                    return b;
               }
          } finally {
          		System.out.println("ESS");
          }
     }
     return false;
}

public static void main(String[] args) {
     new VerifyEr().err(false);
}
}

should print SUCCESS and doesn't
Comment 2 Philipe Mulet CLA 2002-01-30 13:04:03 EST
Fixed in latest, added regression test.