Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: 1.8-beta-1
-
Fix Version/s: None
-
Component/s: class generator
-
Labels:None
-
Number of attachments :
Description
The following code compiles, but it shouldn't because T is a non-static generic type, and difference instances of Outer will have different concrete representations of T. Hence it makes no sense that static inner classes should be able to use such generic type variables.
class Outer<T> {
T ofoo
static class Inner {
T ifoo
}
}
Similarly, all the cases below should not compile as well:
class Test1<T> {
static T f1
}
class Test2<T> {
static foo(T param1) {}
}
class Test3<T> {
static foo() {
T localVar1
}
}
Activity
Roshan Dawrani
made changes -
| Field | Original Value | New Value |
|---|---|---|
| Summary | Static inner classes should not be able to access generic types | Static members should not be able to access generic types |
| Description |
The following code compiles, but it shouldn't because T is a non-static generic type, and difference instances of Outer will have different concrete representations of T. Hence it makes no sense that static inner classes should be able to use such generic type variables.
{code} class Outer<T> { T ofoo static class Inner { T ifoo } } {code} |
The following code compiles, but it shouldn't because T is a non-static generic type, and difference instances of Outer will have different concrete representations of T. Hence it makes no sense that static inner classes should be able to use such generic type variables.
{code} class Outer<T> { T ofoo static class Inner { T ifoo } } {code} Similarly, all the cases below should not compile as well: {code} class Test1<T> { static T f1 } class Test2<T> { static foo(T param1) {} } class Test3<T> { static foo() { T localVar1 } } {code} |