Bug 165145

Summary: [1.5][compiler] Missing raw type warning
Product: [Eclipse Project] JDT Reporter: Ed Merks <Ed.Merks>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: VERIFIED FIXED QA Contact:
Severity: major    
Priority: P3 CC: marcelop
Version: 3.3   
Target Milestone: 3.3 M4   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Proposed patch none

Description Ed Merks CLA 2006-11-20 07:54:07 EST
I was trying to understand when the Eclipse compiler generates warnings about raw types.  In this example I think all casts to (List)/(Map)should produce a warning, but some don't...

package org.example;

import java.util.List;
import java.util.Map;

public class Warning 
{
  public static void main(String[] args)
  {
    Object object = null;
    
    List list = (List)object; // 
    
    foo((List)object);  // This should produce a raw type warning, right?
    foo((List<?>)object);
    foo((List<Object>)object); // 
    foo((List<? extends Object>)object);
    
    foo((Map)object);  // This should produce a raw type warning, right?
    foo((Map<?, ?>)object);
    foo((Map<Object, ?>)object);
    foo((Map<?, Object>)object);
    foo((Map<Object, Object>)object); // 
    foo((Map<? extends Object, Object>)object);
    foo((Map<? extends Object, ? extends Object>)object);
  }
  
  public static void foo(List<?> list)
  {
    System.out.println("###" + list);
  }

  public static void foo(Map<?, ?> map)
  {
    System.out.println("###" + map);
  }
}

I've marked this as "major" because we are trying to eliminate all warnings in the EMF code and more importantly in the generated code EMF produces so I want to be sure that the current set of warnings are complete that we don't suddenly get new ones when oversights in where to produce warnings are fixed.
Comment 1 Philipe Mulet CLA 2006-11-22 09:44:30 EST
Fix is simple, but I remember we actually explicitly disabled the raw type check in cast expression. Due to cast semantics, there would be situations where we would recommend parameterization, and then hit some unchecked cast...
Need to investigate if this is still the case nowadays.
Comment 2 Philipe Mulet CLA 2006-11-22 11:53:07 EST
Created attachment 54347 [details]
Proposed patch
Comment 3 Philipe Mulet CLA 2006-11-22 11:53:35 EST
Released for 3.3M4.
Fixed

Tuned existing tests.
Comment 4 Olivier Thomann CLA 2006-12-11 15:54:56 EST
Verified for 3.3M4 with I20061211-1119.
4 raw type warnings are reported.