javac 8 with target level 7

Gernot Neppert mcnepp02 at googlemail.com
Sun Dec 22 03:41:03 PST 2013


Hi,

I think the option "-target 7" mandates that the generated *classfiles* 
be compatible with a Java-7 VM.
The option "-source 7" would mandate that the compiler accept all 
sources that were valid Java-7 sources.
However, there is no option that would force a newer compiler to 
*reject* the same set of sources that was rejected in an earlier version.
(The reason is, of course, that making previously invalid sources 
compilable certainly does not break any promises of compatibility.)

Does that make sense?

> Hi,
>
> The code compiles with java 8 (b. 119) target 7, but fails to compile with
> javac 7 target 7:
>
> import java.util.Comparator;
>
> class GenericMethod {
>      <E extends Comparable<E>> Comparator<E> getComparator() {
>          return null;
>      }
>
>      <E> void useComparator(Comparator<? super E> comparator) {
>      }
>
>      void test() {
>          useComparator(this.getComparator());
>      }
> }
>
> Was that intended?
>
> Thanks,
> Anna
>
>



More information about the lambda-dev mailing list