Bug 103227 - [1.5][compiler] VerifyError in case of a parametrized anonymous class inside a static inner class
Summary: [1.5][compiler] VerifyError in case of a parametrized anonymous class inside ...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 blocker (vote)
Target Milestone: 3.1.1   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-07-08 18:08 EDT by Rémi Forax CLA
Modified: 2005-09-26 10:55 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rémi Forax CLA 2005-07-08 18:08:00 EDT
The following code doesn't pass verifier because
the method String get(int) of the anonymous class
because eclipse compiler generate as last byte-code a
ireturn and not a areturn.

program :
package fr.umlv.tatoo.test;

import java.util.AbstractList;
import java.util.List;

public class BogusVerifier {

  private static class Entry {
    public void doIt(final List<? extends String> args) {
      List<String> list=new AbstractList<String>() {
          @Override public int size() {
            return 0;
          }
          @Override public String get(int i) {
            return args.get(i);
          }
        };
    }
  }

}

javap output:

public java.lang.String get(int);
  Code:
   0:	aload_0
   1:	getfield	#15; //Field val$args:Ljava/util/List;
   4:	iload_1
   5:	invokeinterface	#31,  2; //InterfaceMethod
java/util/List.get:(I)Ljava/lang/Object;
   10:	checkcast	#33; //class java/lang/String
   13:	ireturn // <-------------- OUPS

Rémi Forax
Comment 1 Philipe Mulet CLA 2005-07-12 12:20:03 EDT
Also bridge method Object get(...) has an unoptimal 'checkcast: Object'.

  // Method descriptor #29 (I)Ljava/lang/Object;
  // Stack: 2, Locals: 2
  public bridge synthetic Object get(int arg);
    0  aload_0
    1  iload_1
    2  invokevirtual X$1.get(int) : String  [37]
    5  checkcast Object [39]
    8  areturn
Comment 2 Philipe Mulet CLA 2005-07-13 08:29:40 EDT
VerifyError comes from miscomputation of implicit conversion in presence of
wildcard capture type.

Fixed by using its erasure.

Added GenericTypeTest#test779-780.
Comment 3 Maxime Daniel CLA 2005-08-09 11:18:17 EDT
Verified in 3.2 M1 with build I20050808-2000.
Comment 4 David Audel CLA 2005-09-26 10:55:49 EDT
Verified using M20050923-1430 for 3.1.1