Bug 72754 - problem with 1.5 support for generics in foreach
Summary: problem with 1.5 support for generics in foreach
Status: RESOLVED DUPLICATE of bug 72560
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M2   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-08-26 21:40 EDT by Alan Malloy CLA
Modified: 2006-03-17 09:07 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alan Malloy CLA 2004-08-26 21:40:00 EDT
There seems to be a problem with nested parameterized types, like Map<String, 
Set<String>>, being used in a foreach loop. I've written two versions of a 
simple method, which should have (nearly) identical behavior.

Version 1 (Works):
private static void printMap(TreeMap<String, TreeSet<String>> map)
{
   for (String key : map.keySet())
   {
      System.out.print(key + ":");
      TreeSet<String> vals = map.get(key);
      for (String val : vals)
         System.out.print(" " + val);
      
      System.out.println();
   }
}

Version 2 (Does NOT work):
private static void printMap(TreeMap<String, TreeSet<String>> map)
{
   for (String key : map.keySet())
   {
      System.out.print(key + ":");
      TreeSet<String> vals = map.get(key);
      for (String val : map.get(key))
         System.out.print(" " + val);
      
      System.out.println();
   }
}

Version 2 should produce the same output as version 1, but does not. Both of 
them compile with no error messages, but when running the program with version 
2, an error window with the following message is created: "Could not find the 
main class. Program will exit." Also the console view displays the following 
text: "java.lang.VerifyError: (class: 
org/malloys/akm/horstmann/prereq/ImportReporter, method: printMap signature: 
(Ljava/util/TreeMap;)V) Incompatible object argument for function call
Exception in thread 'main'".
Comment 1 Olivier Thomann CLA 2004-08-27 09:23:10 EDT
I am investigating. I believe this is a duplicate of bug 72560. I will double-check.
Comment 2 Alan Malloy CLA 2004-08-27 14:15:59 EDT
Ohhhhh, you're right. I saw that bug when looking for duplicates, but I didn't 
quite understand what he was saying at the time. Yes, I'm sure you're right 
that it's a duplicate. Sorry to bother you *smile*.
Comment 3 Olivier Thomann CLA 2004-08-27 14:22:12 EDT

*** This bug has been marked as a duplicate of 72560 ***
Comment 4 Steven Marsten CLA 2006-03-17 02:47:26 EST
(In reply to comment #0)
> There seems to be a problem with nested parameterized types, like Map<String, 
> Set<String>>, being used in a foreach loop. I've written two versions of a 
> simple method, which should have (nearly) identical behavior.
> Version 1 (Works):
> private static void printMap(TreeMap<String, TreeSet<String>> map)
> {
>    for (String key : map.keySet())
>    {
>       System.out.print(key + ":");
>       TreeSet<String> vals = map.get(key);
>       for (String val : vals)
>          System.out.print(" " + val);
>       
>       System.out.println();
>    }
> }
> Version 2 (Does NOT work):
> private static void printMap(TreeMap<String, TreeSet<String>> map)
> {
>    for (String key : map.keySet())
>    {
>       System.out.print(key + ":");
>       TreeSet<String> vals = map.get(key);
>       for (String val : map.get(key))
>          System.out.print(" " + val);
>       
>       System.out.println();
>    }
> }
> Version 2 should produce the same output as version 1, but does not. Both of 
> them compile with no error messages, but when running the program with version 
> 2, an error window with the following message is created: "Could not find the 
> main class. Program will exit." Also the console view displays the following 
> text: "java.lang.VerifyError: (class: 
> org/malloys/akm/horstmann/prereq/ImportReporter, method: printMap signature: 
> (Ljava/util/TreeMap;)V) Incompatible object argument for function call
> Exception in thread 'main'".

I have the same issue, however, no for loop. You are probably correct about the nested types in function call. I have the issue with JBuilder 6. 

My error mssg is as follows: java.lang.VerifyError: (class: wcurve/wcurve14, method: slotUpdateControls signature: (Lorg/kde/qt/QWidget;)V) Incompatible object argument for function call

Exception in thread "main" 

---

My function call is as follows:

pQAction.connect((QObject)pWorkspace, pQAction.SIGNAL("windowActivated(QWidget)"), (QObject)((Object)this),
    pQAction.SLOT("slotUpdateControls(QWidget)")); 

---

My function signature is as follows:

void slotUpdateControls(QWidget w){

Funny that there was no error for the windowActivated nested call.

Any ideas....??

Steve

PS. I changed the type in the call to QOBject and got the same error but with ref to (Lorg/kde/qt/QObject)
Comment 5 Olivier Thomann CLA 2006-03-17 09:07:12 EST
Could you please open a new bug report for this issue?
Specify your build ID and give us a test case that reproduces the problem.
Thanks.