Bug 165145 - [1.5][compiler] Missing raw type warning
Summary: [1.5][compiler] Missing raw type warning
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: 3.3 M4   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-11-20 07:54 EST by Ed Merks CLA
Modified: 2006-12-11 15:54 EST (History)
1 user (show)

See Also:


Attachments
Proposed patch (24.74 KB, patch)
2006-11-22 11:53 EST, Philipe Mulet CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.