7025784: Add SourceVersion.RELEASE_8

Wed, 01 Jun 2011 23:56:31 -0700

author
darcy
date
Wed, 01 Jun 2011 23:56:31 -0700
changeset 1042
defdd98cb7ce
parent 1012
fdc22d73b6f3
child 1043
3b1fd4ac2e71

7025784: Add SourceVersion.RELEASE_8
7025786: Add -source 8 and -target 8 to javac
7025789: Change javac source and target default to 8
Reviewed-by: jjg

src/share/classes/com/sun/tools/javac/code/Source.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javac/jvm/Target.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javac/processing/PrintingProcessor.java file | annotate | diff | comparison | revisions
src/share/classes/javax/lang/model/SourceVersion.java file | annotate | diff | comparison | revisions
test/tools/javac/6330997/T6330997.java file | annotate | diff | comparison | revisions
test/tools/javac/api/T6395981.java file | annotate | diff | comparison | revisions
test/tools/javac/processing/warnings/TestSourceVersionWarnings.java file | annotate | diff | comparison | revisions
test/tools/javac/quid/T6999438.java file | annotate | diff | comparison | revisions
test/tools/javac/versions/check.sh file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/classes/com/sun/tools/javac/code/Source.java	Tue May 24 15:28:18 2011 -0700
     1.2 +++ b/src/share/classes/com/sun/tools/javac/code/Source.java	Wed Jun 01 23:56:31 2011 -0700
     1.3 @@ -64,8 +64,11 @@
     1.4      /** 1.6 reports encoding problems as errors instead of warnings. */
     1.5      JDK1_6("1.6"),
     1.6  
     1.7 -    /** 1.7 covers the to be determined language features that will be added in JDK 7. */
     1.8 -    JDK1_7("1.7");
     1.9 +    /** 1.7 introduced try-with-resources, multi-catch, string switch, etc. */
    1.10 +    JDK1_7("1.7"),
    1.11 +
    1.12 +    /** 1.8 covers the to be determined language features that will be added in JDK 8. */
    1.13 +    JDK1_8("1.8");
    1.14  
    1.15      private static final Context.Key<Source> sourceKey
    1.16          = new Context.Key<Source>();
    1.17 @@ -92,19 +95,21 @@
    1.18          tab.put("5", JDK1_5); // Make 5 an alias for 1.5
    1.19          tab.put("6", JDK1_6); // Make 6 an alias for 1.6
    1.20          tab.put("7", JDK1_7); // Make 7 an alias for 1.7
    1.21 +        tab.put("8", JDK1_8); // Make 8 an alias for 1.8
    1.22      }
    1.23  
    1.24      private Source(String name) {
    1.25          this.name = name;
    1.26      }
    1.27  
    1.28 -    public static final Source DEFAULT = JDK1_7;
    1.29 +    public static final Source DEFAULT = JDK1_8;
    1.30  
    1.31      public static Source lookup(String name) {
    1.32          return tab.get(name);
    1.33      }
    1.34  
    1.35      public Target requiredTarget() {
    1.36 +        if (this.compareTo(JDK1_8) >= 0) return Target.JDK1_8;
    1.37          if (this.compareTo(JDK1_7) >= 0) return Target.JDK1_7;
    1.38          if (this.compareTo(JDK1_6) >= 0) return Target.JDK1_6;
    1.39          if (this.compareTo(JDK1_5) >= 0) return Target.JDK1_5;
    1.40 @@ -203,6 +208,8 @@
    1.41              return RELEASE_6;
    1.42          case JDK1_7:
    1.43              return RELEASE_7;
    1.44 +        case JDK1_8:
    1.45 +            return RELEASE_8;
    1.46          default:
    1.47              return null;
    1.48          }
     2.1 --- a/src/share/classes/com/sun/tools/javac/jvm/Target.java	Tue May 24 15:28:18 2011 -0700
     2.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/Target.java	Wed Jun 01 23:56:31 2011 -0700
     2.3 @@ -1,5 +1,5 @@
     2.4  /*
     2.5 - * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
     2.6 + * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
     2.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2.8   *
     2.9   * This code is free software; you can redistribute it and/or modify it
    2.10 @@ -66,7 +66,10 @@
    2.11      JDK1_6("1.6", 50, 0),
    2.12  
    2.13      /** JDK 7. */
    2.14 -    JDK1_7("1.7", 51, 0);
    2.15 +    JDK1_7("1.7", 51, 0),
    2.16 +
    2.17 +    /** JDK 8. */ // For now, a clone of 7
    2.18 +    JDK1_8("1.8", 51, 0);
    2.19  
    2.20      private static final Context.Key<Target> targetKey =
    2.21          new Context.Key<Target>();
    2.22 @@ -99,6 +102,7 @@
    2.23          tab.put("5", JDK1_5);
    2.24          tab.put("6", JDK1_6);
    2.25          tab.put("7", JDK1_7);
    2.26 +        tab.put("8", JDK1_8);
    2.27      }
    2.28  
    2.29      public final String name;
    2.30 @@ -110,7 +114,7 @@
    2.31          this.minorVersion = minorVersion;
    2.32      }
    2.33  
    2.34 -    public static final Target DEFAULT = JDK1_7;
    2.35 +    public static final Target DEFAULT = JDK1_8;
    2.36  
    2.37      public static Target lookup(String name) {
    2.38          return tab.get(name);
     3.1 --- a/src/share/classes/com/sun/tools/javac/processing/PrintingProcessor.java	Tue May 24 15:28:18 2011 -0700
     3.2 +++ b/src/share/classes/com/sun/tools/javac/processing/PrintingProcessor.java	Wed Jun 01 23:56:31 2011 -0700
     3.3 @@ -1,5 +1,5 @@
     3.4  /*
     3.5 - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
     3.6 + * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
     3.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3.8   *
     3.9   * This code is free software; you can redistribute it and/or modify it
    3.10 @@ -48,8 +48,7 @@
    3.11   * deletion without notice.</b>
    3.12   */
    3.13  @SupportedAnnotationTypes("*")
    3.14 -// TODO: Change to version 7 based visitors when available
    3.15 -@SupportedSourceVersion(SourceVersion.RELEASE_7)
    3.16 +@SupportedSourceVersion(SourceVersion.RELEASE_8)
    3.17  public class PrintingProcessor extends AbstractProcessor {
    3.18      PrintWriter writer;
    3.19  
     4.1 --- a/src/share/classes/javax/lang/model/SourceVersion.java	Tue May 24 15:28:18 2011 -0700
     4.2 +++ b/src/share/classes/javax/lang/model/SourceVersion.java	Wed Jun 01 23:56:31 2011 -0700
     4.3 @@ -1,5 +1,5 @@
     4.4  /*
     4.5 - * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
     4.6 + * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
     4.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4.8   *
     4.9   * This code is free software; you can redistribute it and/or modify it
    4.10 @@ -124,7 +124,15 @@
    4.11       *
    4.12       * @since 1.7
    4.13       */
    4.14 -    RELEASE_7;
    4.15 +    RELEASE_7,
    4.16 +
    4.17 +    /**
    4.18 +     * The version recognized by the Java Platform, Standard Edition
    4.19 +     * 8.
    4.20 +     *
    4.21 +     * @since 1.8
    4.22 +     */
    4.23 +    RELEASE_8;
    4.24  
    4.25      // Note that when adding constants for newer releases, the
    4.26      // behavior of latest() and latestSupported() must be updated too.
    4.27 @@ -135,7 +143,7 @@
    4.28       * @return the latest source version that can be modeled
    4.29       */
    4.30      public static SourceVersion latest() {
    4.31 -        return RELEASE_7;
    4.32 +        return RELEASE_8;
    4.33      }
    4.34  
    4.35      private static final SourceVersion latestSupported = getLatestSupported();
    4.36 @@ -143,9 +151,12 @@
    4.37      private static SourceVersion getLatestSupported() {
    4.38          try {
    4.39              String specVersion = System.getProperty("java.specification.version");
    4.40 -            if ("1.7".equals(specVersion))
    4.41 +
    4.42 +            if ("1.8".equals(specVersion))
    4.43 +                return RELEASE_8;
    4.44 +            else if("1.7".equals(specVersion))
    4.45                  return RELEASE_7;
    4.46 -            else if ("1.6".equals(specVersion))
    4.47 +            else if("1.6".equals(specVersion))
    4.48                  return RELEASE_6;
    4.49          } catch (SecurityException se) {}
    4.50  
     5.1 --- a/test/tools/javac/6330997/T6330997.java	Tue May 24 15:28:18 2011 -0700
     5.2 +++ b/test/tools/javac/6330997/T6330997.java	Wed Jun 01 23:56:31 2011 -0700
     5.3 @@ -1,5 +1,5 @@
     5.4  /*
     5.5 - * Copyright (c) 2006, 2007, Oracle and/or its affiliates. All rights reserved.
     5.6 + * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
     5.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     5.8   *
     5.9   * This code is free software; you can redistribute it and/or modify it
    5.10 @@ -23,12 +23,12 @@
    5.11  
    5.12  /**
    5.13   * @test
    5.14 - * @bug     6330997
    5.15 + * @bug     6330997 7025789
    5.16   * @summary javac should accept class files with major version of the next release
    5.17   * @author  Wei Tao
    5.18   * @clean T1 T2
    5.19 - * @compile -target 7 T1.java
    5.20 - * @compile -target 7 T2.java
    5.21 + * @compile -target 8 T1.java
    5.22 + * @compile -target 8 T2.java
    5.23   * @run main/othervm T6330997
    5.24   */
    5.25  
     6.1 --- a/test/tools/javac/api/T6395981.java	Tue May 24 15:28:18 2011 -0700
     6.2 +++ b/test/tools/javac/api/T6395981.java	Wed Jun 01 23:56:31 2011 -0700
     6.3 @@ -1,5 +1,5 @@
     6.4  /*
     6.5 - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
     6.6 + * Copyright (c) 2006, 2011 Oracle and/or its affiliates. All rights reserved.
     6.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     6.8   *
     6.9   * This code is free software; you can redistribute it and/or modify it
    6.10 @@ -23,13 +23,13 @@
    6.11  
    6.12  /*
    6.13   * @test
    6.14 - * @bug     6395981 6458819
    6.15 + * @bug     6395981 6458819 7025784
    6.16   * @summary JavaCompilerTool and Tool must specify version of JLS and JVMS
    6.17   * @author  Peter von der Ah\u00e9
    6.18   * @run main/fail T6395981
    6.19   * @run main/fail T6395981 RELEASE_3 RELEASE_5 RELEASE_6
    6.20   * @run main/fail T6395981 RELEASE_0 RELEASE_1 RELEASE_2 RELEASE_3 RELEASE_4 RELEASE_5 RELEASE_6
    6.21 - * @run main T6395981 RELEASE_3 RELEASE_4 RELEASE_5 RELEASE_6 RELEASE_7
    6.22 + * @run main T6395981 RELEASE_3 RELEASE_4 RELEASE_5 RELEASE_6 RELEASE_7 RELEASE_8
    6.23   */
    6.24  
    6.25  import java.util.EnumSet;
     7.1 --- a/test/tools/javac/processing/warnings/TestSourceVersionWarnings.java	Tue May 24 15:28:18 2011 -0700
     7.2 +++ b/test/tools/javac/processing/warnings/TestSourceVersionWarnings.java	Wed Jun 01 23:56:31 2011 -0700
     7.3 @@ -1,5 +1,5 @@
     7.4  /*
     7.5 - * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
     7.6 + * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
     7.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     7.8   *
     7.9   * This code is free software; you can redistribute it and/or modify it
    7.10 @@ -23,7 +23,7 @@
    7.11  
    7.12  /*
    7.13   * @test
    7.14 - * @bug 6376083 6376084 6458819
    7.15 + * @bug 6376083 6376084 6458819 7025784 7025786 7025789
    7.16   * @summary Test that warnings about source versions are output as expected.
    7.17   * @author  Joseph D. Darcy
    7.18   * @compile TestSourceVersionWarnings.java
    7.19 @@ -35,7 +35,8 @@
    7.20   * @compile/ref=gold_sv_warn_5_6.out   -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_5 -source 1.6 -Xlint:-options HelloWorld.java
    7.21   * @compile/ref=gold_sv_none.out       -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_6 -source 1.6 -Xlint:-options HelloWorld.java
    7.22   * @compile/ref=gold_unsp_warn.out     -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_6 -source 1.6 -Xlint:-options -Aunsupported HelloWorld.java
    7.23 - * @compile/ref=gold_sv_none.out       -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_7 -source 1.7                 HelloWorld.java
    7.24 + * @compile/ref=gold_sv_none.out       -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_7 -source 1.7 -Xlint:-options HelloWorld.java
    7.25 + * @compile/ref=gold_sv_none.out       -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_8 -source 1.8                 HelloWorld.java
    7.26   */
    7.27  
    7.28  import java.util.Set;
    7.29 @@ -51,7 +52,8 @@
    7.30  /**
    7.31   * This processor returns the supported source level as indicated by
    7.32   * the "SourceLevel" option; therefore, don't use
    7.33 - * JavacTestingAbstractProcessor which returns the latest source level.
    7.34 + * JavacTestingAbstractProcessor which returns the latest source
    7.35 + * level.
    7.36   */
    7.37  @SupportedAnnotationTypes("*")
    7.38  @SupportedOptions("SourceVersion")
     8.1 --- a/test/tools/javac/quid/T6999438.java	Tue May 24 15:28:18 2011 -0700
     8.2 +++ b/test/tools/javac/quid/T6999438.java	Wed Jun 01 23:56:31 2011 -0700
     8.3 @@ -1,7 +1,7 @@
     8.4  /* @test /nodynamiccopyright/
     8.5   * @bug 6999438
     8.6   * @summary remove support for exotic identifiers from JDK 7
     8.7 - * @compile/fail/ref=T6999438.out -XDrawDiagnostics -source 7 T6999438.java
     8.8 + * @compile/fail/ref=T6999438.out -XDrawDiagnostics T6999438.java
     8.9   */
    8.10  
    8.11  class Test {
     9.1 --- a/test/tools/javac/versions/check.sh	Tue May 24 15:28:18 2011 -0700
     9.2 +++ b/test/tools/javac/versions/check.sh	Wed Jun 01 23:56:31 2011 -0700
     9.3 @@ -22,7 +22,7 @@
     9.4  #
     9.5  
     9.6  # @test
     9.7 -# @bug 4981566 5028634 5094412 6304984
     9.8 +# @bug 4981566 5028634 5094412 6304984 7025786 7025789
     9.9  # @summary Check interpretation of -target and -source options
    9.10  # @build CheckClassFileVersion
    9.11  # @run shell check.sh 
    9.12 @@ -65,9 +65,14 @@
    9.13  check 51.0 -source 6
    9.14  check 51.0 -source 1.7
    9.15  check 51.0 -source 7
    9.16 -check 51.0 -target 1.7
    9.17 -check 51.0 -target 7
    9.18 +check 51.0 -source 7 -target 1.7
    9.19 +check 51.0 -source 7 -target 7
    9.20  
    9.21 +# Update when class file version is revved
    9.22 +check 51.0 -source 1.8
    9.23 +check 51.0 -source 8
    9.24 +check 51.0 -target 1.8
    9.25 +check 51.0 -target 8
    9.26  
    9.27  # Check source versions
    9.28  
    9.29 @@ -96,6 +101,7 @@
    9.30  checksrc15() { pass $* $TC/X.java; pass $* $TC/Y.java; }
    9.31  checksrc16() { checksrc15 $* ; }
    9.32  checksrc17() { checksrc15 $* ; }
    9.33 +checksrc18() { checksrc15 $* ; }
    9.34  
    9.35  checksrc14 -source 1.4
    9.36  checksrc14 -source 1.4 -target 1.5
    9.37 @@ -108,16 +114,24 @@
    9.38  checksrc16 -source 1.6 -target 1.6
    9.39  checksrc16 -source 6 -target 6
    9.40  
    9.41 -checksrc17
    9.42 -checksrc17 -target 1.7
    9.43 -checksrc17 -target 7
    9.44  checksrc17 -source 1.7
    9.45  checksrc17 -source 7
    9.46  checksrc17 -source 1.7 -target 1.7
    9.47  checksrc17 -source 7 -target 7
    9.48  
    9.49 +checksrc18
    9.50 +checksrc18 -target 1.8
    9.51 +checksrc18 -target 8
    9.52 +checksrc18 -source 1.8
    9.53 +checksrc18 -source 8
    9.54 +checksrc18 -source 1.8 -target 1.8
    9.55 +checksrc18 -source 8 -target 8
    9.56 +
    9.57  fail -source 1.5 -target 1.4 $TC/X.java
    9.58  fail -source 1.6 -target 1.4 $TC/X.java
    9.59  fail -source 6   -target 1.4 $TC/X.java
    9.60  fail -source 1.6 -target 1.5 $TC/X.java
    9.61  fail -source 6   -target 1.5 $TC/X.java
    9.62 +fail -source 7   -target 1.6 $TC/X.java
    9.63 +fail -source 8   -target 1.6 $TC/X.java
    9.64 +fail -source 8   -target 1.7 $TC/X.java

mercurial