Forum Stats

  • 3,769,464 Users
  • 2,252,967 Discussions
  • 7,875,037 Comments

Discussions

Code not compiling with java7 but compiling with java6

955312
955312 Member Posts: 3
Hello all,

I have following class:
public class StrangeClass<T extends StrangeClass<S, T>, S extends StrangeClass<T, S>> {

public static void main(String[] args) throws InstantiationException, IllegalAccessException {
System.out.println("test");
}
}

It's compiling with eclipse (Java 7) and with java 6u33 (oracle) but not compiling with java 7u5 (oracle)

StrangeClass.java:1: error: type argument S is not within bounds of type-variable T
public class StrangeClass<T extends StrangeClass<S, T>, S extends StrangeClass<T, S>> {
^
where S,T are type-variables:
S extends StrangeClass<T,S> declared in class StrangeClass
T extends StrangeClass<S,T> declared in class StrangeClass
1 error

Do you think it's a bug or expected behavior?

Best Answer

  • gimbal2
    gimbal2 Member Posts: 11,949 Gold Trophy
    edited Aug 13, 2012 10:23AM Accepted Answer
    Because they're two separate things? Java 7 is NOT simply an "upgrade" from Java 6, its a new platform. Therefore things can and will be different.

    Might in this case simply be that a bug in the compiler was plugged though.

Answers

This discussion has been closed.