Bug 304416

Summary: VerifyError after compiling without preserve all locals
Product: [Eclipse Project] JDT Reporter: Andrew Niefer <aniefer>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: VERIFIED FIXED QA Contact:
Severity: critical    
Priority: P3    
Version: 3.6   
Target Milestone: 3.6 M6   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
patch to reproduce
none
Proposed fix none

Description Andrew Niefer CLA 2010-03-02 15:26:16 EST
Created attachment 160679 [details]
patch to reproduce

Running I20100302-0800 on linux.gtk.x86

If "Preserve unused (never read) local variables" is not checked (this is what happens during export or a releng build), then running the bundle org.eclipse.equinox.frameworkadmin.equinox gives:

java.lang.VerifyError: (org/eclipse/equinox/internal/frameworkadmin/equinox/EquinoxFwConfigFileParser) local variable index out of range in load in method 8 (readFwConfig(Lorg/eclipse/equinox/internal/provisional/frameworkadmin/Manipulator;Ljava/io/File;)V) at pc=285

For the source, get (/cvsroot/rt/org.eclipse.equinox/p2/bundles/)
org.eclipse.equinox.frameworkadmin
org.eclipse.equinox.frameworkadmin.equinox
from head and apply the attached patch.
Comment 1 Olivier Thomann CLA 2010-03-02 15:43:51 EST
This is bad. I believe this is due to the usage of FAKE_USED for one of the locals.
The small test case reproduces the issue:

public class X {
  public static void main(String[] args) {
  	String s = null;
  	String s2 = null;
  	if (s != null && s2 != null) {
  		System.out.println(s);
  		System.out.println(s2);
  	}
  }
}

In the test (s != null && s2 != null), s2 is tagged as FAKE_USED and therefore doesn't get a resolved position. When we end up generating the code for it, we generate aload 255 since its resolved position is set to -1.
Comment 2 Olivier Thomann CLA 2010-03-02 15:44:19 EST
Created attachment 160683 [details]
Proposed fix

Patch under testing.
Comment 3 Olivier Thomann CLA 2010-03-03 13:24:33 EST
Released for 3.6M6.
Added regression tests:
org.eclipse.jdt.core.tests.compiler.regression.NullReferenceTest#testBug304416
Comment 4 Frederic Fusier CLA 2010-03-09 12:05:28 EST
Verified for 3.6M6 using I20100307-2000 build.