Bug 72387 - [1.5] Generics bug with array of types
Summary: [1.5] Generics bug with array of types
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: All All
: P3 major (vote)
Target Milestone: 3.1 M4   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-08-21 10:32 EDT by Erwin Bolwidt CLA
Modified: 2005-01-08 11:49 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Erwin Bolwidt CLA 2004-08-21 10:32:39 EDT
I don't know exactly how to give a title for this bug, but it is easily
reproducible.

Take this example source code:

---
import java.util.Arrays;

public class GenericTest {
  public static void main(String[] args) {
    Arrays.asList(GenericTest.class.getConstructors()[0].getParameterTypes());
  }
}
---

It will generate this compilation error: The method asList(T[]) in the type
Arrays is not applicable for the arguments (Class<?>[])
This error is wrong. There also a workaround: add an import statement for
java.lang.reflect.Constructor

import java.lang.reflect.Constructor;

Then this piece of code will compile correctly.

I discovered this bug because I have a workspace with the open source projects
pico-container and jmock in it, and they both use this expression in their
test-cases.

Sun's javac compiler of jdk1.5.0beta2 compiles this code without problems, even
without an import statement.
Comment 1 Erwin Bolwidt CLA 2004-08-21 10:33:17 EDT
BTW this bug is in Eclipse version 3.1M1, but I can't select this version when
entering a bug report.
Comment 2 Olivier Thomann CLA 2004-08-21 14:28:28 EDT
Add 1.5 in the title.
Comment 3 Kent Johnson CLA 2004-08-26 11:12:08 EDT
This the definition of Arrays.asList:

public static <T> List<T> asList(T... a) {
   return new ArrayList<T>(a);
}

We do not currently support variable args in method parameters.

The 1.5 support in eclipse is constantly improving, please check the release 
notes for when support has been added.
Comment 4 Kent Johnson CLA 2005-01-08 11:49:11 EST
Vararg support was released a while ago... missed this bug in Later.
Comment 5 Kent Johnson CLA 2005-01-08 11:49:52 EST
.