Merge jdk8-b65

Fri, 09 Nov 2012 14:47:22 -0800

author
lana
date
Fri, 09 Nov 2012 14:47:22 -0800
changeset 1403
5f2faba89cac
parent 1388
056d828ac1e1
parent 1402
a1dc543483fc
child 1404
b5d326a809a1
child 1408
b486794d160d
child 1424
da48ab364ea4

Merge

     1.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties	Thu Nov 08 11:53:23 2012 -0800
     1.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties	Fri Nov 09 14:47:22 2012 -0800
     1.3 @@ -41,32 +41,21 @@
     1.4  doclet.Help=Help
     1.5  doclet.Skip_navigation_links=Skip navigation links
     1.6  doclet.New_Page=NewPage
     1.7 -doclet.None=None
     1.8 -doclet.Factory_Method_Detail=Static Factory Method Detail
     1.9  doclet.navDeprecated=Deprecated
    1.10 -doclet.Deprecated_List=Deprecated List
    1.11  doclet.Window_Deprecated_List=Deprecated List
    1.12 -doclet.Note_0_is_deprecated=Note: {0} is deprecated.
    1.13  doclet.Overrides=Overrides:
    1.14  doclet.in_class=in class
    1.15 -doclet.0_Fields_and_Methods="{0}" Fields and Methods
    1.16 -doclet.Index_of_Fields_and_Methods=Index of Fields and Methods
    1.17  doclet.Static_variable_in=Static variable in {0}
    1.18  doclet.Variable_in=Variable in {0}
    1.19  doclet.Constructor_for=Constructor for {0}
    1.20  doclet.Static_method_in=Static method in {0}
    1.21  doclet.Method_in=Method in {0}
    1.22 -doclet.throws=throws
    1.23  doclet.package=package
    1.24  doclet.MalformedURL=Malformed URL: {0}
    1.25  doclet.File_error=Error reading file: {0}
    1.26  doclet.URL_error=Error fetching URL: {0}
    1.27 -doclet.No_Package_Comment_File=For Package {0} Package.Comment file not found
    1.28 -doclet.No_Source_For_Class=Source information for class {0} not available.
    1.29  doclet.see.class_or_package_not_found=Tag {0}: reference not found: {1}
    1.30  doclet.see.class_or_package_not_accessible=Tag {0}: reference not accessible: {1}
    1.31 -doclet.see.malformed_tag=Tag {0}: Malformed: {1}
    1.32 -doclet.Inherited_API_Summary=Inherited API Summary
    1.33  doclet.Deprecated_API=Deprecated API
    1.34  doclet.Deprecated_Packages=Deprecated Packages
    1.35  doclet.Deprecated_Classes=Deprecated Classes
    1.36 @@ -92,10 +81,7 @@
    1.37  doclet.deprecated_methods=deprecated methods
    1.38  doclet.deprecated_enum_constants=deprecated enum constants
    1.39  doclet.deprecated_annotation_type_members=deprecated annotation type elements
    1.40 -doclet.Frame_Output=Frame Output
    1.41 -doclet.Docs_generated_by_Javadoc=Documentation generated by Javadoc.
    1.42  doclet.Generated_Docs_Untitled=Generated Documentation (Untitled)
    1.43 -doclet.Blank=Blank
    1.44  doclet.Other_Packages=Other Packages
    1.45  doclet.Package_Description=Package {0} Description
    1.46  doclet.Description=Description
    1.47 @@ -105,32 +91,22 @@
    1.48  doclet.Subinterfaces=All Known Subinterfaces:
    1.49  doclet.Implementing_Classes=All Known Implementing Classes:
    1.50  doclet.also=also
    1.51 -doclet.Option=Option
    1.52 -doclet.Or=Or
    1.53  doclet.Frames=Frames
    1.54  doclet.No_Frames=No Frames
    1.55  doclet.Package_Hierarchies=Package Hierarchies:
    1.56  doclet.Hierarchy_For_Package=Hierarchy For Package {0}
    1.57 -doclet.Source_Code=Source Code:
    1.58  doclet.Hierarchy_For_All_Packages=Hierarchy For All Packages
    1.59 -doclet.Cannot_handle_no_packages=Cannot handle no packages.
    1.60  doclet.Frame_Alert=Frame Alert
    1.61 -doclet.Overview-Member-Frame=Overview Member Frame
    1.62  doclet.Frame_Warning_Message=This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. Link to {0}.
    1.63  doclet.No_Script_Message=JavaScript is disabled on your browser.
    1.64  doclet.Non_Frame_Version=Non-frame version
    1.65 -doclet.Frame_Version=Frame version
    1.66 -doclet.Following_From_Class=Following copied from class: {0}
    1.67 -doclet.Following_From_Interface=Following copied from interface: {0}
    1.68  doclet.Description_From_Interface=Description copied from interface:
    1.69  doclet.Description_From_Class=Description copied from class:
    1.70 -doclet.Standard_doclet_invoked=Standard doclet invoked...
    1.71  doclet.No_Non_Deprecated_Classes_To_Document=No non-deprecated classes found to document.
    1.72  doclet.Interfaces_Italic=Interfaces (italic)
    1.73  doclet.Enclosing_Class=Enclosing class:
    1.74  doclet.Enclosing_Interface=Enclosing interface:
    1.75  doclet.Window_Source_title=Source code
    1.76 -doclet.Help_title=API Help
    1.77  doclet.Window_Help_title=API Help
    1.78  doclet.Help_line_1=How This API Document Is Organized
    1.79  doclet.Help_line_2=This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.
    1.80 @@ -168,19 +144,6 @@
    1.81  doclet.Help_annotation_type_line_1=Each annotation type has its own separate page with the following sections:
    1.82  doclet.Help_annotation_type_line_2=Annotation Type declaration
    1.83  doclet.Help_annotation_type_line_3=Annotation Type description
    1.84 -doclet.Style_line_1=Javadoc style sheet
    1.85 -doclet.Style_line_2=Define colors, fonts and other style attributes here to override the defaults
    1.86 -doclet.Style_line_3=Page background color
    1.87 -doclet.Style_Headings=Headings
    1.88 -doclet.Style_line_4=Table colors
    1.89 -doclet.Style_line_5=Dark mauve
    1.90 -doclet.Style_line_6=Light mauve
    1.91 -doclet.Style_line_7=White
    1.92 -doclet.Style_line_8=Font used in left-hand frame lists
    1.93 -doclet.Style_line_9=Example of smaller, sans-serif font in frames
    1.94 -doclet.Style_line_10=Navigation bar fonts and colors
    1.95 -doclet.Style_line_11=Dark Blue
    1.96 -doclet.Style_line_12=Table caption style
    1.97  doclet.ClassUse_Packages.that.use.0=Packages that use {0}
    1.98  doclet.ClassUse_Uses.of.0.in.1=Uses of {0} in {1}
    1.99  doclet.ClassUse_Classes.in.0.used.by.1=Classes in {0} used by {1}
   1.100 @@ -210,12 +173,9 @@
   1.101  doclet.Window_ClassUse_Header=Uses of {0} {1}
   1.102  doclet.ClassUse_Title=Uses of {0}<br>{1}
   1.103  doclet.navClassUse=Use
   1.104 -doclet.link_option_twice=Extern URL link option (link or linkoffline) used twice.
   1.105  doclet.Error_in_packagelist=Error in using -group option: {0} {1}
   1.106  doclet.Groupname_already_used=In -group option, groupname already used: {0}
   1.107  doclet.Same_package_name_used=Package name format used twice: {0}
   1.108 -doclet.Serialization.Excluded_Class=Non-transient field {1} uses excluded class {0}.
   1.109 -doclet.Serialization.Nonexcluded_Class=Non-transient field {1} uses hidden, non-included class {0}.
   1.110  doclet.exception_encountered=Exception encountered while processing {1}\n{0}
   1.111  doclet.usage=Provided by Standard doclet:\n\
   1.112    -d <directory>                    Destination directory for output files\n\
     2.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets.properties	Thu Nov 08 11:53:23 2012 -0800
     2.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets.properties	Fri Nov 09 14:47:22 2012 -0800
     2.3 @@ -21,10 +21,8 @@
     2.4  doclet.Copying_File_0_To_File_1=Copying file {0} to file {1}...
     2.5  doclet.No_Public_Classes_To_Document=No public or protected classes found to document.
     2.6  doclet.Unable_to_create_directory_0=Unable to create directory {0}
     2.7 -doclet.destination_directory_not_found_0=Destination directory not found {0}
     2.8  doclet.destination_directory_not_directory_0=Destination directory is not a directory {0}
     2.9  doclet.destination_directory_not_writable_0=Destination directory not writable {0}
    2.10 -doclet.Error_creating_tmp_file=Error creating temporary file, using default platform encoding.
    2.11  doclet.Encoding_not_supported=Encoding not supported: {0}
    2.12  doclet.Building_Tree=Building tree for all the packages and classes...
    2.13  doclet.Building_Index=Building index for all the packages and classes...
    2.14 @@ -74,7 +72,6 @@
    2.15  doclet.Enum_Constant_Summary=Enum Constant Summary
    2.16  doclet.Constructor_Summary=Constructor Summary
    2.17  doclet.Method_Summary=Method Summary
    2.18 -doclet.Factory_Method_Summary=Static Factory Method Summary
    2.19  doclet.Interfaces=Interfaces
    2.20  doclet.Enums=Enums
    2.21  doclet.AnnotationTypes=Annotation Types
    2.22 @@ -88,7 +85,6 @@
    2.23  doclet.All_Implemented_Interfaces=All Implemented Interfaces:
    2.24  doclet.All_classes_and_interfaces=All classes and interfaces (except non-static nested types)
    2.25  doclet.Package_class_and_interface_descriptions=Package, class and interface descriptions
    2.26 -doclet.Members=Members
    2.27  doclet.Interface=Interface
    2.28  doclet.Class=Class
    2.29  doclet.AnnotationType=Annotation Type
    2.30 @@ -107,18 +103,13 @@
    2.31  doclet.Exception=Exception
    2.32  doclet.exception=exception
    2.33  doclet.exceptions=exceptions
    2.34 -doclet.extended_by=extended by
    2.35 -doclet.extends=extends
    2.36  doclet.Package_private=(package private)
    2.37 -doclet.implements=implementsdoclet.Same_package_name_used=Package name format used twice: {0}
    2.38  doclet.Nested_Classes_Interfaces_Inherited_From_Class=Nested classes/interfaces inherited from class
    2.39  doclet.Nested_Classes_Interface_Inherited_From_Interface=Nested classes/interfaces inherited from interface
    2.40  doclet.Methods_Inherited_From_Class=Methods inherited from class
    2.41  doclet.Methods_Inherited_From_Interface=Methods inherited from interface
    2.42  doclet.Fields_Inherited_From_Class=Fields inherited from class
    2.43  doclet.Fields_Inherited_From_Interface=Fields inherited from interface
    2.44 -doclet.Serializable=Serializable
    2.45 -doclet.Externalizable=Externalizable
    2.46  doclet.Annotation_Type_Member_Detail=Element Detail
    2.47  doclet.Enum_Constant_Detail=Enum Constant Detail
    2.48  doclet.Constants_Summary=Constant Field Values
    2.49 @@ -126,7 +117,6 @@
    2.50  doclet.Method_Detail=Method Detail
    2.51  doclet.Constructor_Detail=Constructor Detail
    2.52  doclet.Deprecated=Deprecated.
    2.53 -doclet.Deprecated_class=This class is deprecated.
    2.54  doclet.Groupname_already_used=In -group option, groupname already used: {0}
    2.55  doclet.value_tag_invalid_reference={0} (referenced by @value tag) is an unknown reference.
    2.56  doclet.value_tag_invalid_constant=@value tag (which references {0}) can only be used in constants.
     3.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java	Thu Nov 08 11:53:23 2012 -0800
     3.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java	Fri Nov 09 14:47:22 2012 -0800
     3.3 @@ -555,7 +555,7 @@
     3.4       *
     3.5       * @param cd the ClassDoc to check.
     3.6       * @param lowerCaseOnly true if you want the name returned in lower case.
     3.7 -     *                      If false, the first letter of the name is capatilized.
     3.8 +     *                      If false, the first letter of the name is capitalized.
     3.9       * @return
    3.10       */
    3.11      public static String getTypeName(Configuration config,
     4.1 --- a/src/share/classes/com/sun/tools/javac/code/Flags.java	Thu Nov 08 11:53:23 2012 -0800
     4.2 +++ b/src/share/classes/com/sun/tools/javac/code/Flags.java	Fri Nov 09 14:47:22 2012 -0800
     4.3 @@ -67,7 +67,6 @@
     4.4          if ((mask&NATIVE) != 0) flags.add(Flag.NATIVE);
     4.5          if ((mask&INTERFACE) != 0) flags.add(Flag.INTERFACE);
     4.6          if ((mask&ABSTRACT) != 0) flags.add(Flag.ABSTRACT);
     4.7 -        if ((mask&DEFAULT) != 0) flags.add(Flag.DEFAULT);
     4.8          if ((mask&STRICTFP) != 0) flags.add(Flag.STRICTFP);
     4.9          if ((mask&BRIDGE) != 0) flags.add(Flag.BRIDGE);
    4.10          if ((mask&SYNTHETIC) != 0) flags.add(Flag.SYNTHETIC);
     5.1 --- a/src/share/classes/com/sun/tools/javac/code/Source.java	Thu Nov 08 11:53:23 2012 -0800
     5.2 +++ b/src/share/classes/com/sun/tools/javac/code/Source.java	Fri Nov 09 14:47:22 2012 -0800
     5.3 @@ -206,6 +206,9 @@
     5.4      public boolean allowDefaultMethods() {
     5.5          return compareTo(JDK1_8) >= 0;
     5.6      }
     5.7 +    public boolean allowStrictMethodClashCheck() {
     5.8 +        return compareTo(JDK1_8) >= 0;
     5.9 +    }
    5.10      public boolean allowEffectivelyFinalInInnerClasses() {
    5.11          return compareTo(JDK1_8) >= 0;
    5.12      }
     6.1 --- a/src/share/classes/com/sun/tools/javac/code/Symbol.java	Thu Nov 08 11:53:23 2012 -0800
     6.2 +++ b/src/share/classes/com/sun/tools/javac/code/Symbol.java	Fri Nov 09 14:47:22 2012 -0800
     6.3 @@ -1192,9 +1192,9 @@
     6.4  
     6.5              // check for an inherited implementation
     6.6              if ((flags() & ABSTRACT) != 0 ||
     6.7 -                (other.flags() & ABSTRACT) == 0 ||
     6.8 -                !other.isOverridableIn(origin) ||
     6.9 -                !this.isMemberOf(origin, types))
    6.10 +                    (other.flags() & ABSTRACT) == 0 ||
    6.11 +                    !other.isOverridableIn(origin) ||
    6.12 +                    !this.isMemberOf(origin, types))
    6.13                  return false;
    6.14  
    6.15              // assert types.asSuper(origin.type, other.owner) != null;
     7.1 --- a/src/share/classes/com/sun/tools/javac/code/Types.java	Thu Nov 08 11:53:23 2012 -0800
     7.2 +++ b/src/share/classes/com/sun/tools/javac/code/Types.java	Fri Nov 09 14:47:22 2012 -0800
     7.3 @@ -75,6 +75,7 @@
     7.4      final boolean allowBoxing;
     7.5      final boolean allowCovariantReturns;
     7.6      final boolean allowObjectToPrimitiveCast;
     7.7 +    final boolean allowDefaultMethods;
     7.8      final ClassReader reader;
     7.9      final Check chk;
    7.10      JCDiagnostic.Factory diags;
    7.11 @@ -98,6 +99,7 @@
    7.12          allowBoxing = source.allowBoxing();
    7.13          allowCovariantReturns = source.allowCovariantReturns();
    7.14          allowObjectToPrimitiveCast = source.allowObjectToPrimitiveCast();
    7.15 +        allowDefaultMethods = source.allowDefaultMethods();
    7.16          reader = ClassReader.instance(context);
    7.17          chk = Check.instance(context);
    7.18          capturedName = names.fromString("<captured wildcard>");
    7.19 @@ -2146,6 +2148,13 @@
    7.20                  return List.nil();
    7.21              }
    7.22          };
    7.23 +
    7.24 +    public boolean isDirectSuperInterface(Type t, TypeSymbol tsym) {
    7.25 +        for (Type t2 : interfaces(tsym.type)) {
    7.26 +            if (isSameType(t, t2)) return true;
    7.27 +        }
    7.28 +        return false;
    7.29 +    }
    7.30      // </editor-fold>
    7.31  
    7.32      // <editor-fold defaultstate="collapsed" desc="isDerivedRaw">
    7.33 @@ -2310,6 +2319,10 @@
    7.34          return false;
    7.35      }
    7.36  
    7.37 +    public boolean overridesObjectMethod(Symbol msym) {
    7.38 +        return ((MethodSymbol)msym).implementation(syms.objectType.tsym, this, true) != null;
    7.39 +    }
    7.40 +
    7.41      // <editor-fold defaultstate="collapsed" desc="Determining method implementation in given site">
    7.42      class ImplementationCache {
    7.43  
    7.44 @@ -2455,6 +2468,70 @@
    7.45      }
    7.46      // </editor-fold>
    7.47  
    7.48 +
    7.49 +    //where
    7.50 +    public List<MethodSymbol> interfaceCandidates(Type site, MethodSymbol ms) {
    7.51 +        return interfaceCandidates(site, ms, false);
    7.52 +    }
    7.53 +
    7.54 +    public List<MethodSymbol> interfaceCandidates(Type site, MethodSymbol ms, boolean intfOnly) {
    7.55 +        Filter<Symbol> filter = new MethodFilter(ms, site, intfOnly);
    7.56 +        List<MethodSymbol> candidates = List.nil();
    7.57 +        for (Symbol s : membersClosure(site, false).getElements(filter)) {
    7.58 +            if (!site.tsym.isInterface() && !s.owner.isInterface()) {
    7.59 +                return List.of((MethodSymbol)s);
    7.60 +            } else if (!candidates.contains(s)) {
    7.61 +                candidates = candidates.prepend((MethodSymbol)s);
    7.62 +            }
    7.63 +        }
    7.64 +        return prune(candidates, ownerComparator);
    7.65 +    }
    7.66 +
    7.67 +    public List<MethodSymbol> prune(List<MethodSymbol> methods, Comparator<MethodSymbol> cmp) {
    7.68 +        ListBuffer<MethodSymbol> methodsMin = ListBuffer.lb();
    7.69 +        for (MethodSymbol m1 : methods) {
    7.70 +            boolean isMin_m1 = true;
    7.71 +            for (MethodSymbol m2 : methods) {
    7.72 +                if (m1 == m2) continue;
    7.73 +                if (cmp.compare(m2, m1) < 0) {
    7.74 +                    isMin_m1 = false;
    7.75 +                    break;
    7.76 +                }
    7.77 +            }
    7.78 +            if (isMin_m1)
    7.79 +                methodsMin.append(m1);
    7.80 +        }
    7.81 +        return methodsMin.toList();
    7.82 +    }
    7.83 +
    7.84 +    Comparator<MethodSymbol> ownerComparator = new Comparator<MethodSymbol>() {
    7.85 +        public int compare(MethodSymbol s1, MethodSymbol s2) {
    7.86 +            return s1.owner.isSubClass(s2.owner, Types.this) ? -1 : 1;
    7.87 +        }
    7.88 +    };
    7.89 +    // where
    7.90 +            private class MethodFilter implements Filter<Symbol> {
    7.91 +
    7.92 +                Symbol msym;
    7.93 +                Type site;
    7.94 +                boolean intfOnly;
    7.95 +
    7.96 +                MethodFilter(Symbol msym, Type site, boolean intfOnly) {
    7.97 +                    this.msym = msym;
    7.98 +                    this.site = site;
    7.99 +                    this.intfOnly = intfOnly;
   7.100 +                }
   7.101 +
   7.102 +                public boolean accepts(Symbol s) {
   7.103 +                    return s.kind == Kinds.MTH &&
   7.104 +                            (!intfOnly || s.owner.isInterface()) &&
   7.105 +                            s.name == msym.name &&
   7.106 +                            s.isInheritedIn(site.tsym, Types.this) &&
   7.107 +                            overrideEquivalent(memberType(site, s), memberType(site, msym));
   7.108 +                }
   7.109 +            };
   7.110 +    // </editor-fold>
   7.111 +
   7.112      /**
   7.113       * Does t have the same arguments as s?  It is assumed that both
   7.114       * types are (possibly polymorphic) method types.  Monomorphic
     8.1 --- a/src/share/classes/com/sun/tools/javac/comp/Attr.java	Thu Nov 08 11:53:23 2012 -0800
     8.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java	Fri Nov 09 14:47:22 2012 -0800
     8.3 @@ -135,6 +135,7 @@
     8.4          allowStringsInSwitch = source.allowStringsInSwitch();
     8.5          allowPoly = source.allowPoly() && options.isSet("allowPoly");
     8.6          allowLambda = source.allowLambda();
     8.7 +        allowDefaultMethods = source.allowDefaultMethods();
     8.8          sourceName = source.name;
     8.9          relax = (options.isSet("-retrofit") ||
    8.10                   options.isSet("-relax"));
    8.11 @@ -178,6 +179,10 @@
    8.12       */
    8.13      boolean allowCovariantReturns;
    8.14  
    8.15 +    /** Switch: support default methods ?
    8.16 +     */
    8.17 +    boolean allowDefaultMethods;
    8.18 +
    8.19      /** Switch: support lambda expressions ?
    8.20       */
    8.21      boolean allowLambda;
    8.22 @@ -898,6 +903,10 @@
    8.23  
    8.24              localEnv.info.lint = lint;
    8.25  
    8.26 +            if (isDefaultMethod && types.overridesObjectMethod(m)) {
    8.27 +                log.error(tree, "default.overrides.object.member", m.name, Kinds.kindName(m.location()), m.location());
    8.28 +            }
    8.29 +
    8.30              // Enter all type parameters into the local method scope.
    8.31              for (List<JCTypeParameter> l = tree.typarams; l.nonEmpty(); l = l.tail)
    8.32                  localEnv.info.scope.enterIfAbsent(l.head.type.tsym);
    8.33 @@ -961,10 +970,12 @@
    8.34                          log.error(tree.pos(),
    8.35                                    "default.allowed.in.intf.annotation.member");
    8.36                  }
    8.37 -            } else if ((owner.flags() & INTERFACE) != 0 && !isDefaultMethod) {
    8.38 -                log.error(tree.body.pos(), "intf.meth.cant.have.body");
    8.39 -            } else if ((tree.mods.flags & ABSTRACT) != 0) {
    8.40 -                log.error(tree.pos(), "abstract.meth.cant.have.body");
    8.41 +            } else if ((tree.sym.flags() & ABSTRACT) != 0 && !isDefaultMethod) {
    8.42 +                if ((owner.flags() & INTERFACE) != 0) {
    8.43 +                    log.error(tree.body.pos(), "intf.meth.cant.have.body");
    8.44 +                } else {
    8.45 +                    log.error(tree.pos(), "abstract.meth.cant.have.body");
    8.46 +                }
    8.47              } else if ((tree.mods.flags & NATIVE) != 0) {
    8.48                  log.error(tree.pos(), "native.meth.cant.have.body");
    8.49              } else {
    8.50 @@ -3281,6 +3292,23 @@
    8.51              }
    8.52          }
    8.53  
    8.54 +        if (env.info.defaultSuperCallSite != null &&
    8.55 +                !types.interfaceCandidates(env.enclClass.type, (MethodSymbol)sym, true).contains(sym)) {
    8.56 +            Symbol ovSym = null;
    8.57 +            for (MethodSymbol msym : types.interfaceCandidates(env.enclClass.type, (MethodSymbol)sym, true)) {
    8.58 +                if (msym.overrides(sym, msym.enclClass(), types, true)) {
    8.59 +                    for (Type i : types.interfaces(env.enclClass.type)) {
    8.60 +                        if (i.tsym.isSubClass(msym.owner, types)) {
    8.61 +                            ovSym = i.tsym;
    8.62 +                            break;
    8.63 +                        }
    8.64 +                    }
    8.65 +                }
    8.66 +            }
    8.67 +            log.error(env.tree.pos(), "illegal.default.super.call", env.info.defaultSuperCallSite,
    8.68 +                    diags.fragment("overridden.default", sym, ovSym));
    8.69 +        }
    8.70 +
    8.71          // Compute the identifier's instantiated type.
    8.72          // For methods, we need to compute the instance type by
    8.73          // Resolve.instantiate from the symbol's type as well as
    8.74 @@ -3700,6 +3728,9 @@
    8.75              // are compatible (i.e. no two define methods with same arguments
    8.76              // yet different return types).  (JLS 8.4.6.3)
    8.77              chk.checkCompatibleSupertypes(tree.pos(), c.type);
    8.78 +            if (allowDefaultMethods) {
    8.79 +                chk.checkDefaultMethodClashes(tree.pos(), c.type);
    8.80 +            }
    8.81          }
    8.82  
    8.83          // Check that class does not import the same parameterized interface
     9.1 --- a/src/share/classes/com/sun/tools/javac/comp/AttrContext.java	Thu Nov 08 11:53:23 2012 -0800
     9.2 +++ b/src/share/classes/com/sun/tools/javac/comp/AttrContext.java	Fri Nov 09 14:47:22 2012 -0800
     9.3 @@ -72,6 +72,10 @@
     9.4       */
     9.5      Attr.ResultInfo returnResult = null;
     9.6  
     9.7 +    /** Symbol corresponding to the site of a qualified default super call
     9.8 +     */
     9.9 +    Type defaultSuperCallSite = null;
    9.10 +
    9.11      /** Duplicate this context, replacing scope field and copying all others.
    9.12       */
    9.13      AttrContext dup(Scope scope) {
    9.14 @@ -84,6 +88,7 @@
    9.15          info.lint = lint;
    9.16          info.enclVar = enclVar;
    9.17          info.returnResult = returnResult;
    9.18 +        info.defaultSuperCallSite = defaultSuperCallSite;
    9.19          return info;
    9.20      }
    9.21  
    10.1 --- a/src/share/classes/com/sun/tools/javac/comp/Check.java	Thu Nov 08 11:53:23 2012 -0800
    10.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java	Fri Nov 09 14:47:22 2012 -0800
    10.3 @@ -119,6 +119,9 @@
    10.4          allowAnnotations = source.allowAnnotations();
    10.5          allowCovariantReturns = source.allowCovariantReturns();
    10.6          allowSimplifiedVarargs = source.allowSimplifiedVarargs();
    10.7 +        allowDefaultMethods = source.allowDefaultMethods();
    10.8 +        allowStrictMethodClashCheck = source.allowStrictMethodClashCheck() &&
    10.9 +                options.isSet("strictMethodClashCheck"); //pre-lambda guard
   10.10          complexInference = options.isSet("complexinference");
   10.11          warnOnSyntheticConflicts = options.isSet("warnOnSyntheticConflicts");
   10.12          suppressAbortOnBadClassFile = options.isSet("suppressAbortOnBadClassFile");
   10.13 @@ -162,6 +165,14 @@
   10.14       */
   10.15      boolean allowSimplifiedVarargs;
   10.16  
   10.17 +    /** Switch: default methods enabled?
   10.18 +     */
   10.19 +    boolean allowDefaultMethods;
   10.20 +
   10.21 +    /** Switch: should unrelated return types trigger a method clash?
   10.22 +     */
   10.23 +    boolean allowStrictMethodClashCheck;
   10.24 +
   10.25      /** Switch: -complexinference option set?
   10.26       */
   10.27      boolean complexInference;
   10.28 @@ -1114,7 +1125,7 @@
   10.29              }  else if ((sym.owner.flags_field & INTERFACE) != 0) {
   10.30                  if ((flags & DEFAULT) != 0) {
   10.31                      mask = InterfaceDefaultMethodMask;
   10.32 -                    implicit = PUBLIC;
   10.33 +                    implicit = PUBLIC | ABSTRACT;
   10.34                  } else {
   10.35                      mask = implicit = InterfaceMethodFlags;
   10.36                  }
   10.37 @@ -2047,11 +2058,21 @@
   10.38                       undef == null && e != null;
   10.39                       e = e.sibling) {
   10.40                      if (e.sym.kind == MTH &&
   10.41 -                        (e.sym.flags() & (ABSTRACT|IPROXY)) == ABSTRACT) {
   10.42 +                        (e.sym.flags() & (ABSTRACT|IPROXY|DEFAULT)) == ABSTRACT) {
   10.43                          MethodSymbol absmeth = (MethodSymbol)e.sym;
   10.44                          MethodSymbol implmeth = absmeth.implementation(impl, types, true);
   10.45 -                        if (implmeth == null || implmeth == absmeth)
   10.46 +                        if (implmeth == null || implmeth == absmeth) {
   10.47 +                            //look for default implementations
   10.48 +                            if (allowDefaultMethods) {
   10.49 +                                MethodSymbol prov = types.interfaceCandidates(impl.type, absmeth).head;
   10.50 +                                if (prov != null && prov.overrides(absmeth, impl, types, true)) {
   10.51 +                                    implmeth = prov;
   10.52 +                                }
   10.53 +                            }
   10.54 +                        }
   10.55 +                        if (implmeth == null || implmeth == absmeth) {
   10.56                              undef = absmeth;
   10.57 +                        }
   10.58                      }
   10.59                  }
   10.60                  if (undef == null) {
   10.61 @@ -2354,7 +2375,7 @@
   10.62                  if (m2 == m1) continue;
   10.63                  //if (i) the signature of 'sym' is not a subsignature of m1 (seen as
   10.64                  //a member of 'site') and (ii) m1 has the same erasure as m2, issue an error
   10.65 -                if (!types.isSubSignature(sym.type, types.memberType(site, m2), false) &&
   10.66 +                if (!types.isSubSignature(sym.type, types.memberType(site, m2), allowStrictMethodClashCheck) &&
   10.67                          types.hasSameArgs(m2.erasure(types), m1.erasure(types))) {
   10.68                      sym.flags_field |= CLASH;
   10.69                      String key = m1 == sym ?
   10.70 @@ -2386,7 +2407,7 @@
   10.71          for (Symbol s : types.membersClosure(site, true).getElementsByName(sym.name, cf)) {
   10.72              //if (i) the signature of 'sym' is not a subsignature of m1 (seen as
   10.73              //a member of 'site') and (ii) 'sym' has the same erasure as m1, issue an error
   10.74 -            if (!types.isSubSignature(sym.type, types.memberType(site, s), false) &&
   10.75 +            if (!types.isSubSignature(sym.type, types.memberType(site, s), allowStrictMethodClashCheck) &&
   10.76                      types.hasSameArgs(s.erasure(types), sym.erasure(types))) {
   10.77                  log.error(pos,
   10.78                          "name.clash.same.erasure.no.hide",
   10.79 @@ -2420,6 +2441,62 @@
   10.80           }
   10.81       }
   10.82  
   10.83 +    void checkDefaultMethodClashes(DiagnosticPosition pos, Type site) {
   10.84 +        DefaultMethodClashFilter dcf = new DefaultMethodClashFilter(site);
   10.85 +        for (Symbol m : types.membersClosure(site, false).getElements(dcf)) {
   10.86 +            Assert.check(m.kind == MTH);
   10.87 +            List<MethodSymbol> prov = types.interfaceCandidates(site, (MethodSymbol)m);
   10.88 +            if (prov.size() > 1) {
   10.89 +                ListBuffer<Symbol> abstracts = ListBuffer.lb();
   10.90 +                ListBuffer<Symbol> defaults = ListBuffer.lb();
   10.91 +                for (MethodSymbol provSym : prov) {
   10.92 +                    if ((provSym.flags() & DEFAULT) != 0) {
   10.93 +                        defaults = defaults.append(provSym);
   10.94 +                    } else if ((provSym.flags() & ABSTRACT) != 0) {
   10.95 +                        abstracts = abstracts.append(provSym);
   10.96 +                    }
   10.97 +                    if (defaults.nonEmpty() && defaults.size() + abstracts.size() >= 2) {
   10.98 +                        //strong semantics - issue an error if two sibling interfaces
   10.99 +                        //have two override-equivalent defaults - or if one is abstract
  10.100 +                        //and the other is default
  10.101 +                        String errKey;
  10.102 +                        Symbol s1 = defaults.first();
  10.103 +                        Symbol s2;
  10.104 +                        if (defaults.size() > 1) {
  10.105 +                            errKey = "types.incompatible.unrelated.defaults";
  10.106 +                            s2 = defaults.toList().tail.head;
  10.107 +                        } else {
  10.108 +                            errKey = "types.incompatible.abstract.default";
  10.109 +                            s2 = abstracts.first();
  10.110 +                        }
  10.111 +                        log.error(pos, errKey,
  10.112 +                                Kinds.kindName(site.tsym), site,
  10.113 +                                m.name, types.memberType(site, m).getParameterTypes(),
  10.114 +                                s1.location(), s2.location());
  10.115 +                        break;
  10.116 +                    }
  10.117 +                }
  10.118 +            }
  10.119 +        }
  10.120 +    }
  10.121 +
  10.122 +    //where
  10.123 +     private class DefaultMethodClashFilter implements Filter<Symbol> {
  10.124 +
  10.125 +         Type site;
  10.126 +
  10.127 +         DefaultMethodClashFilter(Type site) {
  10.128 +             this.site = site;
  10.129 +         }
  10.130 +
  10.131 +         public boolean accepts(Symbol s) {
  10.132 +             return s.kind == MTH &&
  10.133 +                     (s.flags() & DEFAULT) != 0 &&
  10.134 +                     s.isInheritedIn(site.tsym, types) &&
  10.135 +                     !s.isConstructor();
  10.136 +         }
  10.137 +     }
  10.138 +
  10.139      /** Report a conflict between a user symbol and a synthetic symbol.
  10.140       */
  10.141      private void syntheticError(DiagnosticPosition pos, Symbol sym) {
    11.1 --- a/src/share/classes/com/sun/tools/javac/comp/Lower.java	Thu Nov 08 11:53:23 2012 -0800
    11.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Lower.java	Fri Nov 09 14:47:22 2012 -0800
    11.3 @@ -502,7 +502,7 @@
    11.4          JCNewClass tree = make.NewClass(null,
    11.5              null, make.QualIdent(ctype.tsym), args, null);
    11.6          tree.constructor = rs.resolveConstructor(
    11.7 -            make_pos, attrEnv, ctype, TreeInfo.types(args), null, false, false);
    11.8 +            make_pos, attrEnv, ctype, TreeInfo.types(args), List.<Type>nil());
    11.9          tree.type = ctype;
   11.10          return tree;
   11.11      }
   11.12 @@ -3631,15 +3631,26 @@
   11.13  
   11.14      public void visitSelect(JCFieldAccess tree) {
   11.15          // need to special case-access of the form C.super.x
   11.16 -        // these will always need an access method.
   11.17 +        // these will always need an access method, unless C
   11.18 +        // is a default interface subclassed by the current class.
   11.19          boolean qualifiedSuperAccess =
   11.20              tree.selected.hasTag(SELECT) &&
   11.21 -            TreeInfo.name(tree.selected) == names._super;
   11.22 +            TreeInfo.name(tree.selected) == names._super &&
   11.23 +            !types.isDirectSuperInterface(((JCFieldAccess)tree.selected).selected.type, currentClass);
   11.24          tree.selected = translate(tree.selected);
   11.25 -        if (tree.name == names._class)
   11.26 +        if (tree.name == names._class) {
   11.27              result = classOf(tree.selected);
   11.28 -        else if (tree.name == names._this || tree.name == names._super)
   11.29 +        }
   11.30 +        else if (tree.name == names._super &&
   11.31 +                types.isDirectSuperInterface(tree.selected.type, currentClass)) {
   11.32 +            //default super call!! Not a classic qualified super call
   11.33 +            TypeSymbol supSym = tree.selected.type.tsym;
   11.34 +            Assert.checkNonNull(types.asSuper(currentClass.type, supSym));
   11.35 +            result = tree;
   11.36 +        }
   11.37 +        else if (tree.name == names._this || tree.name == names._super) {
   11.38              result = makeThis(tree.pos(), tree.selected.type.tsym);
   11.39 +        }
   11.40          else
   11.41              result = access(tree.sym, tree, enclOp, qualifiedSuperAccess);
   11.42      }
    12.1 --- a/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Thu Nov 08 11:53:23 2012 -0800
    12.2 +++ b/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Fri Nov 09 14:47:22 2012 -0800
    12.3 @@ -560,6 +560,12 @@
    12.4          MethodSymbol m = new MethodSymbol(0, tree.name, null, enclScope.owner);
    12.5          m.flags_field = chk.checkFlags(tree.pos(), tree.mods.flags, m, tree);
    12.6          tree.sym = m;
    12.7 +
    12.8 +        //if this is a default method, add the DEFAULT flag to the enclosing interface
    12.9 +        if ((tree.mods.flags & DEFAULT) != 0) {
   12.10 +            m.enclClass().flags_field |= DEFAULT;
   12.11 +        }
   12.12 +
   12.13          Env<AttrContext> localEnv = methodEnv(tree, env);
   12.14  
   12.15          DeferredLintHandler prevLintHandler =
   12.16 @@ -677,7 +683,7 @@
   12.17              localEnv.info.scope.owner = tree.sym;
   12.18          }
   12.19          if ((tree.mods.flags & STATIC) != 0 ||
   12.20 -            (env.enclClass.sym.flags() & INTERFACE) != 0)
   12.21 +                ((env.enclClass.sym.flags() & INTERFACE) != 0 && env.enclMethod == null))
   12.22              localEnv.info.staticLevel++;
   12.23          return localEnv;
   12.24      }
   12.25 @@ -1001,20 +1007,19 @@
   12.26                  }
   12.27              }
   12.28  
   12.29 -            // If this is a class, enter symbols for this and super into
   12.30 -            // current scope.
   12.31 -            if ((c.flags_field & INTERFACE) == 0) {
   12.32 -                VarSymbol thisSym =
   12.33 -                    new VarSymbol(FINAL | HASINIT, names._this, c.type, c);
   12.34 -                thisSym.pos = Position.FIRSTPOS;
   12.35 -                env.info.scope.enter(thisSym);
   12.36 -                if (ct.supertype_field.hasTag(CLASS)) {
   12.37 -                    VarSymbol superSym =
   12.38 -                        new VarSymbol(FINAL | HASINIT, names._super,
   12.39 -                                      ct.supertype_field, c);
   12.40 -                    superSym.pos = Position.FIRSTPOS;
   12.41 -                    env.info.scope.enter(superSym);
   12.42 -                }
   12.43 +            // enter symbols for 'this' into current scope.
   12.44 +            VarSymbol thisSym =
   12.45 +                new VarSymbol(FINAL | HASINIT, names._this, c.type, c);
   12.46 +            thisSym.pos = Position.FIRSTPOS;
   12.47 +            env.info.scope.enter(thisSym);
   12.48 +            // if this is a class, enter symbol for 'super' into current scope.
   12.49 +            if ((c.flags_field & INTERFACE) == 0 &&
   12.50 +                    ct.supertype_field.hasTag(CLASS)) {
   12.51 +                VarSymbol superSym =
   12.52 +                    new VarSymbol(FINAL | HASINIT, names._super,
   12.53 +                                  ct.supertype_field, c);
   12.54 +                superSym.pos = Position.FIRSTPOS;
   12.55 +                env.info.scope.enter(superSym);
   12.56              }
   12.57  
   12.58              // check that no package exists with same fully qualified name,
    13.1 --- a/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Thu Nov 08 11:53:23 2012 -0800
    13.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Fri Nov 09 14:47:22 2012 -0800
    13.3 @@ -51,7 +51,10 @@
    13.4  import java.util.EnumMap;
    13.5  import java.util.EnumSet;
    13.6  import java.util.Iterator;
    13.7 +import java.util.LinkedHashMap;
    13.8 +import java.util.LinkedHashSet;
    13.9  import java.util.Map;
   13.10 +import java.util.Set;
   13.11  
   13.12  import javax.lang.model.element.ElementVisitor;
   13.13  
   13.14 @@ -88,6 +91,7 @@
   13.15      public final boolean boxingEnabled; // = source.allowBoxing();
   13.16      public final boolean varargsEnabled; // = source.allowVarargs();
   13.17      public final boolean allowMethodHandles;
   13.18 +    public final boolean allowDefaultMethods;
   13.19      private final boolean debugResolve;
   13.20      final EnumSet<VerboseResolutionMode> verboseResolutionMode;
   13.21  
   13.22 @@ -122,6 +126,7 @@
   13.23          verboseResolutionMode = VerboseResolutionMode.getVerboseResolutionMode(options);
   13.24          Target target = Target.instance(context);
   13.25          allowMethodHandles = target.hasMethodHandles();
   13.26 +        allowDefaultMethods = source.allowDefaultMethods();
   13.27          polymorphicSignatureScope = new Scope(syms.noSymbol);
   13.28  
   13.29          inapplicableMethodException = new InapplicableMethodException(diags);
   13.30 @@ -447,22 +452,9 @@
   13.31                          List<Type> typeargtypes,
   13.32                          boolean allowBoxing,
   13.33                          boolean useVarargs,
   13.34 -                        Warner warn)
   13.35 -        throws Infer.InferenceException {
   13.36 -        if (useVarargs && (m.flags() & VARARGS) == 0) {
   13.37 -            //better error recovery - if we stumbled upon a non-varargs method
   13.38 -            //during varargs applicability phase, the method should be treated as
   13.39 -            //not applicable; the reason for inapplicability can be found in the
   13.40 -            //candidate for 'm' that was created during the BOX phase.
   13.41 -            Candidate prevCandidate = currentResolutionContext.getCandidate(m, BOX);
   13.42 -            JCDiagnostic details = null;
   13.43 -            if (prevCandidate != null && !prevCandidate.isApplicable()) {
   13.44 -                details = prevCandidate.details;
   13.45 -            }
   13.46 -            throw inapplicableMethodException.setMessage(details);
   13.47 -        }
   13.48 +                        Warner warn) throws Infer.InferenceException {
   13.49 +
   13.50          Type mt = types.memberType(site, m);
   13.51 -
   13.52          // tvars is the list of formal type variables for which type arguments
   13.53          // need to inferred.
   13.54          List<Type> tvars = List.nil();
   13.55 @@ -1020,8 +1012,11 @@
   13.56                        boolean allowBoxing,
   13.57                        boolean useVarargs,
   13.58                        boolean operator) {
   13.59 -        if (sym.kind == ERR) return bestSoFar;
   13.60 -        if (!sym.isInheritedIn(site.tsym, types)) return bestSoFar;
   13.61 +        if (sym.kind == ERR ||
   13.62 +                !sym.isInheritedIn(site.tsym, types) ||
   13.63 +                (useVarargs && (sym.flags() & VARARGS) == 0)) {
   13.64 +            return bestSoFar;
   13.65 +        }
   13.66          Assert.check(sym.kind < AMBIGUOUS);
   13.67          try {
   13.68              Type mt = rawInstantiate(env, site, sym, null, argtypes, typeargtypes,
   13.69 @@ -1032,13 +1027,13 @@
   13.70              if (!operator)
   13.71                  currentResolutionContext.addInapplicableCandidate(sym, ex.getDiagnostic());
   13.72              switch (bestSoFar.kind) {
   13.73 -            case ABSENT_MTH:
   13.74 -                return new InapplicableSymbolError(currentResolutionContext);
   13.75 -            case WRONG_MTH:
   13.76 -                if (operator) return bestSoFar;
   13.77 -                bestSoFar = new InapplicableSymbolsError(currentResolutionContext);
   13.78 -            default:
   13.79 -                return bestSoFar;
   13.80 +                case ABSENT_MTH:
   13.81 +                    return new InapplicableSymbolError(currentResolutionContext);
   13.82 +                case WRONG_MTH:
   13.83 +                    if (operator) return bestSoFar;
   13.84 +                    bestSoFar = new InapplicableSymbolsError(currentResolutionContext);
   13.85 +                default:
   13.86 +                    return bestSoFar;
   13.87              }
   13.88          }
   13.89          if (!isAccessible(env, site, sym)) {
   13.90 @@ -1327,6 +1322,42 @@
   13.91          }
   13.92      }
   13.93  
   13.94 +    Symbol findMethodInScope(Env<AttrContext> env,
   13.95 +            Type site,
   13.96 +            Name name,
   13.97 +            List<Type> argtypes,
   13.98 +            List<Type> typeargtypes,
   13.99 +            Scope sc,
  13.100 +            Symbol bestSoFar,
  13.101 +            boolean allowBoxing,
  13.102 +            boolean useVarargs,
  13.103 +            boolean operator,
  13.104 +            boolean abstractok) {
  13.105 +        for (Symbol s : sc.getElementsByName(name, new LookupFilter(abstractok))) {
  13.106 +            bestSoFar = selectBest(env, site, argtypes, typeargtypes, s,
  13.107 +                    bestSoFar, allowBoxing, useVarargs, operator);
  13.108 +        }
  13.109 +        return bestSoFar;
  13.110 +    }
  13.111 +    //where
  13.112 +        class LookupFilter implements Filter<Symbol> {
  13.113 +
  13.114 +            boolean abstractOk;
  13.115 +
  13.116 +            LookupFilter(boolean abstractOk) {
  13.117 +                this.abstractOk = abstractOk;
  13.118 +            }
  13.119 +
  13.120 +            public boolean accepts(Symbol s) {
  13.121 +                long flags = s.flags();
  13.122 +                return s.kind == MTH &&
  13.123 +                        (flags & SYNTHETIC) == 0 &&
  13.124 +                        (abstractOk ||
  13.125 +                        (flags & DEFAULT) != 0 ||
  13.126 +                        (flags & ABSTRACT) == 0);
  13.127 +            }
  13.128 +        };
  13.129 +
  13.130      /** Find best qualified method matching given name, type and value
  13.131       *  arguments.
  13.132       *  @param env       The current environment.
  13.133 @@ -1371,49 +1402,76 @@
  13.134                                boolean allowBoxing,
  13.135                                boolean useVarargs,
  13.136                                boolean operator) {
  13.137 -        boolean abstractOk = true;
  13.138 -        List<Type> itypes = List.nil();
  13.139 +        @SuppressWarnings({"unchecked","rawtypes"})
  13.140 +        List<Type>[] itypes = (List<Type>[])new List[] { List.<Type>nil(), List.<Type>nil() };
  13.141 +        InterfaceLookupPhase iphase = InterfaceLookupPhase.ABSTRACT_OK;
  13.142          for (TypeSymbol s : superclasses(intype)) {
  13.143 -            bestSoFar = lookupMethod(env, site, name, argtypes, typeargtypes,
  13.144 +            bestSoFar = findMethodInScope(env, site, name, argtypes, typeargtypes,
  13.145                      s.members(), bestSoFar, allowBoxing, useVarargs, operator, true);
  13.146 -            //We should not look for abstract methods if receiver is a concrete class
  13.147 -            //(as concrete classes are expected to implement all abstracts coming
  13.148 -            //from superinterfaces)
  13.149 -            abstractOk &= (s.flags() & (ABSTRACT | INTERFACE | ENUM)) != 0;
  13.150 -            if (abstractOk) {
  13.151 +            if (name == names.init) return bestSoFar;
  13.152 +            iphase = (iphase == null) ? null : iphase.update(s, this);
  13.153 +            if (iphase != null) {
  13.154                  for (Type itype : types.interfaces(s.type)) {
  13.155 -                    itypes = types.union(types.closure(itype), itypes);
  13.156 +                    itypes[iphase.ordinal()] = types.union(types.closure(itype), itypes[iphase.ordinal()]);
  13.157                  }
  13.158              }
  13.159 -            if (name == names.init) break;
  13.160          }
  13.161  
  13.162          Symbol concrete = bestSoFar.kind < ERR &&
  13.163                  (bestSoFar.flags() & ABSTRACT) == 0 ?
  13.164                  bestSoFar : methodNotFound;
  13.165  
  13.166 -        if (name != names.init) {
  13.167 +        for (InterfaceLookupPhase iphase2 : InterfaceLookupPhase.values()) {
  13.168 +            if (iphase2 == InterfaceLookupPhase.DEFAULT_OK && !allowDefaultMethods) break;
  13.169              //keep searching for abstract methods
  13.170 -            for (Type itype : itypes) {
  13.171 +            for (Type itype : itypes[iphase2.ordinal()]) {
  13.172                  if (!itype.isInterface()) continue; //skip j.l.Object (included by Types.closure())
  13.173 -                bestSoFar = lookupMethod(env, site, name, argtypes, typeargtypes,
  13.174 -                    itype.tsym.members(), bestSoFar, allowBoxing, useVarargs, operator, true);
  13.175 -                    if (concrete != bestSoFar &&
  13.176 -                            concrete.kind < ERR  && bestSoFar.kind < ERR &&
  13.177 -                            types.isSubSignature(concrete.type, bestSoFar.type)) {
  13.178 -                        //this is an hack - as javac does not do full membership checks
  13.179 -                        //most specific ends up comparing abstract methods that might have
  13.180 -                        //been implemented by some concrete method in a subclass and,
  13.181 -                        //because of raw override, it is possible for an abstract method
  13.182 -                        //to be more specific than the concrete method - so we need
  13.183 -                        //to explicitly call that out (see CR 6178365)
  13.184 -                        bestSoFar = concrete;
  13.185 -                    }
  13.186 +                if (iphase2 == InterfaceLookupPhase.DEFAULT_OK &&
  13.187 +                        (itype.tsym.flags() & DEFAULT) == 0) continue;
  13.188 +                bestSoFar = findMethodInScope(env, site, name, argtypes, typeargtypes,
  13.189 +                        itype.tsym.members(), bestSoFar, allowBoxing, useVarargs, operator, true);
  13.190 +                if (concrete != bestSoFar &&
  13.191 +                        concrete.kind < ERR  && bestSoFar.kind < ERR &&
  13.192 +                        types.isSubSignature(concrete.type, bestSoFar.type)) {
  13.193 +                    //this is an hack - as javac does not do full membership checks
  13.194 +                    //most specific ends up comparing abstract methods that might have
  13.195 +                    //been implemented by some concrete method in a subclass and,
  13.196 +                    //because of raw override, it is possible for an abstract method
  13.197 +                    //to be more specific than the concrete method - so we need
  13.198 +                    //to explicitly call that out (see CR 6178365)
  13.199 +                    bestSoFar = concrete;
  13.200 +                }
  13.201              }
  13.202          }
  13.203          return bestSoFar;
  13.204      }
  13.205  
  13.206 +    enum InterfaceLookupPhase {
  13.207 +        ABSTRACT_OK() {
  13.208 +            @Override
  13.209 +            InterfaceLookupPhase update(Symbol s, Resolve rs) {
  13.210 +                //We should not look for abstract methods if receiver is a concrete class
  13.211 +                //(as concrete classes are expected to implement all abstracts coming
  13.212 +                //from superinterfaces)
  13.213 +                if ((s.flags() & (ABSTRACT | INTERFACE | ENUM)) != 0) {
  13.214 +                    return this;
  13.215 +                } else if (rs.allowDefaultMethods) {
  13.216 +                    return DEFAULT_OK;
  13.217 +                } else {
  13.218 +                    return null;
  13.219 +                }
  13.220 +            }
  13.221 +        },
  13.222 +        DEFAULT_OK() {
  13.223 +            @Override
  13.224 +            InterfaceLookupPhase update(Symbol s, Resolve rs) {
  13.225 +                return this;
  13.226 +            }
  13.227 +        };
  13.228 +
  13.229 +        abstract InterfaceLookupPhase update(Symbol s, Resolve rs);
  13.230 +    }
  13.231 +
  13.232      /**
  13.233       * Return an Iterable object to scan the superclasses of a given type.
  13.234       * It's crucial that the scan is done lazily, as we don't want to accidentally
  13.235 @@ -1467,34 +1525,6 @@
  13.236          };
  13.237      }
  13.238  
  13.239 -    /**
  13.240 -     * Lookup a method with given name and argument types in a given scope
  13.241 -     */
  13.242 -    Symbol lookupMethod(Env<AttrContext> env,
  13.243 -            Type site,
  13.244 -            Name name,
  13.245 -            List<Type> argtypes,
  13.246 -            List<Type> typeargtypes,
  13.247 -            Scope sc,
  13.248 -            Symbol bestSoFar,
  13.249 -            boolean allowBoxing,
  13.250 -            boolean useVarargs,
  13.251 -            boolean operator,
  13.252 -            boolean abstractok) {
  13.253 -        for (Symbol s : sc.getElementsByName(name, lookupFilter)) {
  13.254 -            bestSoFar = selectBest(env, site, argtypes, typeargtypes, s,
  13.255 -                    bestSoFar, allowBoxing, useVarargs, operator);
  13.256 -        }
  13.257 -        return bestSoFar;
  13.258 -    }
  13.259 -    //where
  13.260 -        Filter<Symbol> lookupFilter = new Filter<Symbol>() {
  13.261 -            public boolean accepts(Symbol s) {
  13.262 -                return s.kind == MTH &&
  13.263 -                        (s.flags() & SYNTHETIC) == 0;
  13.264 -            }
  13.265 -        };
  13.266 -
  13.267      /** Find unqualified method matching given name, type and value arguments.
  13.268       *  @param env       The current environment.
  13.269       *  @param name      The method's name.
  13.270 @@ -1898,7 +1928,7 @@
  13.271                          ((InapplicableSymbolError)errSym).errCandidate().sym : accessedSym;
  13.272  
  13.273                  List<Type> argtypes2 = Type.map(argtypes,
  13.274 -                        deferredAttr.new RecoveryDeferredTypeMap(AttrMode.SPECULATIVE, msym, currentResolutionContext.firstErroneousResolutionPhase()));
  13.275 +                        deferredAttr.new RecoveryDeferredTypeMap(AttrMode.SPECULATIVE, msym, currentResolutionContext.step));
  13.276  
  13.277                  if (msym != accessedSym) {
  13.278                      //fixup deferred type caches - this 'hack' is required because the symbol
  13.279 @@ -1920,7 +1950,7 @@
  13.280      /** Check that sym is not an abstract method.
  13.281       */
  13.282      void checkNonAbstract(DiagnosticPosition pos, Symbol sym) {
  13.283 -        if ((sym.flags() & ABSTRACT) != 0)
  13.284 +        if ((sym.flags() & ABSTRACT) != 0 && (sym.flags() & DEFAULT) == 0)
  13.285              log.error(pos, "abstract.cant.be.accessed.directly",
  13.286                        kindName(sym), sym, sym.location());
  13.287      }
  13.288 @@ -1992,33 +2022,14 @@
  13.289                           Name name,
  13.290                           List<Type> argtypes,
  13.291                           List<Type> typeargtypes) {
  13.292 -        MethodResolutionContext prevResolutionContext = currentResolutionContext;
  13.293 -        try {
  13.294 -            currentResolutionContext = new MethodResolutionContext();
  13.295 -            Symbol sym = methodNotFound;
  13.296 -            List<MethodResolutionPhase> steps = methodResolutionSteps;
  13.297 -            while (steps.nonEmpty() &&
  13.298 -                   steps.head.isApplicable(boxingEnabled, varargsEnabled) &&
  13.299 -                   sym.kind >= ERRONEOUS) {
  13.300 -                currentResolutionContext.step = env.info.pendingResolutionPhase = steps.head;
  13.301 -                sym = findFun(env, name, argtypes, typeargtypes,
  13.302 -                        steps.head.isBoxingRequired,
  13.303 -                        steps.head.isVarargsRequired);
  13.304 -                currentResolutionContext.resolutionCache.put(steps.head, sym);
  13.305 -                steps = steps.tail;
  13.306 +        return lookupMethod(env, pos, env.enclClass.sym, new BasicLookupHelper(name, env.enclClass.sym.type, argtypes, typeargtypes) {
  13.307 +            @Override
  13.308 +            Symbol lookup(Env<AttrContext> env, MethodResolutionPhase phase) {
  13.309 +                return findFun(env, name, argtypes, typeargtypes,
  13.310 +                        phase.isBoxingRequired(),
  13.311 +                        phase.isVarargsRequired());
  13.312              }
  13.313 -            if (sym.kind >= AMBIGUOUS) {//if nothing is found return the 'first' error
  13.314 -                MethodResolutionPhase errPhase =
  13.315 -                        currentResolutionContext.firstErroneousResolutionPhase();
  13.316 -                sym = accessMethod(currentResolutionContext.resolutionCache.get(errPhase),
  13.317 -                        pos, env.enclClass.sym.type, name, false, argtypes, typeargtypes);
  13.318 -                env.info.pendingResolutionPhase = errPhase;
  13.319 -            }
  13.320 -            return sym;
  13.321 -        }
  13.322 -        finally {
  13.323 -            currentResolutionContext = prevResolutionContext;
  13.324 -        }
  13.325 +        });
  13.326      }
  13.327  
  13.328      /** Resolve a qualified method identifier
  13.329 @@ -2044,40 +2055,27 @@
  13.330                                    DiagnosticPosition pos, Env<AttrContext> env,
  13.331                                    Symbol location, Type site, Name name, List<Type> argtypes,
  13.332                                    List<Type> typeargtypes) {
  13.333 -        MethodResolutionContext prevResolutionContext = currentResolutionContext;
  13.334 -        try {
  13.335 -            currentResolutionContext = resolveContext;
  13.336 -            Symbol sym = methodNotFound;
  13.337 -            List<MethodResolutionPhase> steps = methodResolutionSteps;
  13.338 -            while (steps.nonEmpty() &&
  13.339 -                   steps.head.isApplicable(boxingEnabled, varargsEnabled) &&
  13.340 -                   sym.kind >= ERRONEOUS) {
  13.341 -                currentResolutionContext.step = env.info.pendingResolutionPhase = steps.head;
  13.342 -                sym = findMethod(env, site, name, argtypes, typeargtypes,
  13.343 -                        steps.head.isBoxingRequired(),
  13.344 -                        steps.head.isVarargsRequired(), false);
  13.345 -                currentResolutionContext.resolutionCache.put(steps.head, sym);
  13.346 -                steps = steps.tail;
  13.347 +        return lookupMethod(env, pos, location, resolveContext, new BasicLookupHelper(name, site, argtypes, typeargtypes) {
  13.348 +            @Override
  13.349 +            Symbol lookup(Env<AttrContext> env, MethodResolutionPhase phase) {
  13.350 +                return findMethod(env, site, name, argtypes, typeargtypes,
  13.351 +                        phase.isBoxingRequired(),
  13.352 +                        phase.isVarargsRequired(), false);
  13.353              }
  13.354 -            if (sym.kind >= AMBIGUOUS) {
  13.355 -                //if nothing is found return the 'first' error
  13.356 -                MethodResolutionPhase errPhase =
  13.357 -                        currentResolutionContext.firstErroneousResolutionPhase();
  13.358 -                sym = accessMethod(currentResolutionContext.resolutionCache.get(errPhase),
  13.359 -                        pos, location, site, name, true, argtypes, typeargtypes);
  13.360 -                env.info.pendingResolutionPhase = errPhase;
  13.361 -            } else if (allowMethodHandles) {
  13.362 -                MethodSymbol msym = (MethodSymbol)sym;
  13.363 -                if (msym.isSignaturePolymorphic(types)) {
  13.364 -                    env.info.pendingResolutionPhase = BASIC;
  13.365 -                    return findPolymorphicSignatureInstance(env, sym, argtypes);
  13.366 +            @Override
  13.367 +            Symbol access(Env<AttrContext> env, DiagnosticPosition pos, Symbol location, Symbol sym) {
  13.368 +                if (sym.kind >= AMBIGUOUS) {
  13.369 +                    sym = super.access(env, pos, location, sym);
  13.370 +                } else if (allowMethodHandles) {
  13.371 +                    MethodSymbol msym = (MethodSymbol)sym;
  13.372 +                    if (msym.isSignaturePolymorphic(types)) {
  13.373 +                        env.info.pendingResolutionPhase = BASIC;
  13.374 +                        return findPolymorphicSignatureInstance(env, sym, argtypes);
  13.375 +                    }
  13.376                  }
  13.377 +                return sym;
  13.378              }
  13.379 -            return sym;
  13.380 -        }
  13.381 -        finally {
  13.382 -            currentResolutionContext = prevResolutionContext;
  13.383 -        }
  13.384 +        });
  13.385      }
  13.386  
  13.387      /** Find or create an implicit method of exactly the given type (after erasure).
  13.388 @@ -2145,38 +2143,53 @@
  13.389                                List<Type> typeargtypes) {
  13.390          return resolveConstructor(new MethodResolutionContext(), pos, env, site, argtypes, typeargtypes);
  13.391      }
  13.392 +
  13.393      private Symbol resolveConstructor(MethodResolutionContext resolveContext,
  13.394 -                              DiagnosticPosition pos,
  13.395 +                              final DiagnosticPosition pos,
  13.396                                Env<AttrContext> env,
  13.397                                Type site,
  13.398                                List<Type> argtypes,
  13.399                                List<Type> typeargtypes) {
  13.400 -        MethodResolutionContext prevResolutionContext = currentResolutionContext;
  13.401 -        try {
  13.402 -            currentResolutionContext = resolveContext;
  13.403 -            Symbol sym = methodNotFound;
  13.404 -            List<MethodResolutionPhase> steps = methodResolutionSteps;
  13.405 -            while (steps.nonEmpty() &&
  13.406 -                   steps.head.isApplicable(boxingEnabled, varargsEnabled) &&
  13.407 -                   sym.kind >= ERRONEOUS) {
  13.408 -                currentResolutionContext.step = env.info.pendingResolutionPhase = steps.head;
  13.409 -                sym = findConstructor(pos, env, site, argtypes, typeargtypes,
  13.410 -                        steps.head.isBoxingRequired(),
  13.411 -                        steps.head.isVarargsRequired());
  13.412 -                currentResolutionContext.resolutionCache.put(steps.head, sym);
  13.413 -                steps = steps.tail;
  13.414 +        return lookupMethod(env, pos, site.tsym, resolveContext, new BasicLookupHelper(names.init, site, argtypes, typeargtypes) {
  13.415 +            @Override
  13.416 +            Symbol lookup(Env<AttrContext> env, MethodResolutionPhase phase) {
  13.417 +                return findConstructor(pos, env, site, argtypes, typeargtypes,
  13.418 +                        phase.isBoxingRequired(),
  13.419 +                        phase.isVarargsRequired());
  13.420              }
  13.421 -            if (sym.kind >= AMBIGUOUS) {//if nothing is found return the 'first' error
  13.422 -                MethodResolutionPhase errPhase = currentResolutionContext.firstErroneousResolutionPhase();
  13.423 -                sym = accessMethod(currentResolutionContext.resolutionCache.get(errPhase),
  13.424 -                        pos, site, names.init, true, argtypes, typeargtypes);
  13.425 -                env.info.pendingResolutionPhase = errPhase;
  13.426 -            }
  13.427 -            return sym;
  13.428 -        }
  13.429 -        finally {
  13.430 -            currentResolutionContext = prevResolutionContext;
  13.431 -        }
  13.432 +        });
  13.433 +    }
  13.434 +
  13.435 +    /** Resolve a constructor, throw a fatal error if not found.
  13.436 +     *  @param pos       The position to use for error reporting.
  13.437 +     *  @param env       The environment current at the method invocation.
  13.438 +     *  @param site      The type to be constructed.
  13.439 +     *  @param argtypes  The types of the invocation's value arguments.
  13.440 +     *  @param typeargtypes  The types of the invocation's type arguments.
  13.441 +     */
  13.442 +    public MethodSymbol resolveInternalConstructor(DiagnosticPosition pos, Env<AttrContext> env,
  13.443 +                                        Type site,
  13.444 +                                        List<Type> argtypes,
  13.445 +                                        List<Type> typeargtypes) {
  13.446 +        MethodResolutionContext resolveContext = new MethodResolutionContext();
  13.447 +        resolveContext.internalResolution = true;
  13.448 +        Symbol sym = resolveConstructor(resolveContext, pos, env, site, argtypes, typeargtypes);
  13.449 +        if (sym.kind == MTH) return (MethodSymbol)sym;
  13.450 +        else throw new FatalError(
  13.451 +                 diags.fragment("fatal.err.cant.locate.ctor", site));
  13.452 +    }
  13.453 +
  13.454 +    Symbol findConstructor(DiagnosticPosition pos, Env<AttrContext> env,
  13.455 +                              Type site, List<Type> argtypes,
  13.456 +                              List<Type> typeargtypes,
  13.457 +                              boolean allowBoxing,
  13.458 +                              boolean useVarargs) {
  13.459 +        Symbol sym = findMethod(env, site,
  13.460 +                                    names.init, argtypes,
  13.461 +                                    typeargtypes, allowBoxing,
  13.462 +                                    useVarargs, false);
  13.463 +        chk.checkDeprecated(pos, env.info.scope.owner, sym);
  13.464 +        return sym;
  13.465      }
  13.466  
  13.467      /** Resolve constructor using diamond inference.
  13.468 @@ -2194,47 +2207,36 @@
  13.469                                Type site,
  13.470                                List<Type> argtypes,
  13.471                                List<Type> typeargtypes) {
  13.472 -        MethodResolutionContext prevResolutionContext = currentResolutionContext;
  13.473 -        try {
  13.474 -            currentResolutionContext = new MethodResolutionContext();
  13.475 -            Symbol sym = methodNotFound;
  13.476 -            List<MethodResolutionPhase> steps = methodResolutionSteps;
  13.477 -            while (steps.nonEmpty() &&
  13.478 -                   steps.head.isApplicable(boxingEnabled, varargsEnabled) &&
  13.479 -                   sym.kind >= ERRONEOUS) {
  13.480 -                currentResolutionContext.step = env.info.pendingResolutionPhase = steps.head;
  13.481 -                sym = findDiamond(env, site, argtypes, typeargtypes,
  13.482 -                        steps.head.isBoxingRequired(),
  13.483 -                        steps.head.isVarargsRequired());
  13.484 -                currentResolutionContext.resolutionCache.put(steps.head, sym);
  13.485 -                steps = steps.tail;
  13.486 +        return lookupMethod(env, pos, site.tsym, new BasicLookupHelper(names.init, site, argtypes, typeargtypes) {
  13.487 +            @Override
  13.488 +            Symbol lookup(Env<AttrContext> env, MethodResolutionPhase phase) {
  13.489 +                return findDiamond(env, site, argtypes, typeargtypes,
  13.490 +                        phase.isBoxingRequired(),
  13.491 +                        phase.isVarargsRequired());
  13.492              }
  13.493 -            if (sym.kind >= AMBIGUOUS) {
  13.494 -                Symbol errSym =
  13.495 -                        currentResolutionContext.resolutionCache.get(currentResolutionContext.firstErroneousResolutionPhase());
  13.496 -                final JCDiagnostic details = errSym.kind == WRONG_MTH ?
  13.497 -                                ((InapplicableSymbolError)errSym).errCandidate().details :
  13.498 -                                null;
  13.499 -                errSym = new InapplicableSymbolError(errSym.kind, "diamondError", currentResolutionContext) {
  13.500 -                    @Override
  13.501 -                    JCDiagnostic getDiagnostic(DiagnosticType dkind, DiagnosticPosition pos,
  13.502 -                            Symbol location, Type site, Name name, List<Type> argtypes, List<Type> typeargtypes) {
  13.503 -                        String key = details == null ?
  13.504 -                            "cant.apply.diamond" :
  13.505 -                            "cant.apply.diamond.1";
  13.506 -                        return diags.create(dkind, log.currentSource(), pos, key,
  13.507 -                                diags.fragment("diamond", site.tsym), details);
  13.508 -                    }
  13.509 -                };
  13.510 -                MethodResolutionPhase errPhase = currentResolutionContext.firstErroneousResolutionPhase();
  13.511 -                sym = accessMethod(errSym, pos, site, names.init, true, argtypes, typeargtypes);
  13.512 -                env.info.pendingResolutionPhase = errPhase;
  13.513 +            @Override
  13.514 +            Symbol access(Env<AttrContext> env, DiagnosticPosition pos, Symbol location, Symbol sym) {
  13.515 +                if (sym.kind >= AMBIGUOUS) {
  13.516 +                    final JCDiagnostic details = sym.kind == WRONG_MTH ?
  13.517 +                                    ((InapplicableSymbolError)sym).errCandidate().details :
  13.518 +                                    null;
  13.519 +                    sym = new InapplicableSymbolError(sym.kind, "diamondError", currentResolutionContext) {
  13.520 +                        @Override
  13.521 +                        JCDiagnostic getDiagnostic(DiagnosticType dkind, DiagnosticPosition pos,
  13.522 +                                Symbol location, Type site, Name name, List<Type> argtypes, List<Type> typeargtypes) {
  13.523 +                            String key = details == null ?
  13.524 +                                "cant.apply.diamond" :
  13.525 +                                "cant.apply.diamond.1";
  13.526 +                            return diags.create(dkind, log.currentSource(), pos, key,
  13.527 +                                    diags.fragment("diamond", site.tsym), details);
  13.528 +                        }
  13.529 +                    };
  13.530 +                    sym = accessMethod(sym, pos, site, names.init, true, argtypes, typeargtypes);
  13.531 +                    env.info.pendingResolutionPhase = currentResolutionContext.step;
  13.532 +                }
  13.533 +                return sym;
  13.534              }
  13.535 -            return sym;
  13.536 -        }
  13.537 -        finally {
  13.538 -            currentResolutionContext = prevResolutionContext;
  13.539 -        }
  13.540 +        });
  13.541      }
  13.542  
  13.543      /** This method scans all the constructor symbol in a given class scope -
  13.544 @@ -2281,6 +2283,58 @@
  13.545          return bestSoFar;
  13.546      }
  13.547  
  13.548 +
  13.549 +
  13.550 +    /** Resolve operator.
  13.551 +     *  @param pos       The position to use for error reporting.
  13.552 +     *  @param optag     The tag of the operation tree.
  13.553 +     *  @param env       The environment current at the operation.
  13.554 +     *  @param argtypes  The types of the operands.
  13.555 +     */
  13.556 +    Symbol resolveOperator(DiagnosticPosition pos, JCTree.Tag optag,
  13.557 +                           Env<AttrContext> env, List<Type> argtypes) {
  13.558 +        MethodResolutionContext prevResolutionContext = currentResolutionContext;
  13.559 +        try {
  13.560 +            currentResolutionContext = new MethodResolutionContext();
  13.561 +            Name name = treeinfo.operatorName(optag);
  13.562 +            Symbol sym = findMethod(env, syms.predefClass.type, name, argtypes,
  13.563 +                                    null, false, false, true);
  13.564 +            if (boxingEnabled && sym.kind >= WRONG_MTHS)
  13.565 +                sym = findMethod(env, syms.predefClass.type, name, argtypes,
  13.566 +                                 null, true, false, true);
  13.567 +            return accessMethod(sym, pos, env.enclClass.sym.type, name,
  13.568 +                          false, argtypes, null);
  13.569 +        }
  13.570 +        finally {
  13.571 +            currentResolutionContext = prevResolutionContext;
  13.572 +        }
  13.573 +    }
  13.574 +
  13.575 +    /** Resolve operator.
  13.576 +     *  @param pos       The position to use for error reporting.
  13.577 +     *  @param optag     The tag of the operation tree.
  13.578 +     *  @param env       The environment current at the operation.
  13.579 +     *  @param arg       The type of the operand.
  13.580 +     */
  13.581 +    Symbol resolveUnaryOperator(DiagnosticPosition pos, JCTree.Tag optag, Env<AttrContext> env, Type arg) {
  13.582 +        return resolveOperator(pos, optag, env, List.of(arg));
  13.583 +    }
  13.584 +
  13.585 +    /** Resolve binary operator.
  13.586 +     *  @param pos       The position to use for error reporting.
  13.587 +     *  @param optag     The tag of the operation tree.
  13.588 +     *  @param env       The environment current at the operation.
  13.589 +     *  @param left      The types of the left operand.
  13.590 +     *  @param right     The types of the right operand.
  13.591 +     */
  13.592 +    Symbol resolveBinaryOperator(DiagnosticPosition pos,
  13.593 +                                 JCTree.Tag optag,
  13.594 +                                 Env<AttrContext> env,
  13.595 +                                 Type left,
  13.596 +                                 Type right) {
  13.597 +        return resolveOperator(pos, optag, env, List.of(left, right));
  13.598 +    }
  13.599 +
  13.600      /**
  13.601       * Resolution of member references is typically done as a single
  13.602       * overload resolution step, where the argument types A are inferred from
  13.603 @@ -2314,17 +2368,18 @@
  13.604                                    Name name, List<Type> argtypes,
  13.605                                    List<Type> typeargtypes,
  13.606                                    boolean boxingAllowed) {
  13.607 +        MethodResolutionPhase maxPhase = boxingAllowed ? VARARITY : BASIC;
  13.608          //step 1 - bound lookup
  13.609          ReferenceLookupHelper boundLookupHelper = name.equals(names.init) ?
  13.610 -                new ConstructorReferenceLookupHelper(referenceTree, site, argtypes, typeargtypes, boxingAllowed) :
  13.611 -                new MethodReferenceLookupHelper(referenceTree, name, site, argtypes, typeargtypes, boxingAllowed);
  13.612 +                new ConstructorReferenceLookupHelper(referenceTree, site, argtypes, typeargtypes, maxPhase) :
  13.613 +                new MethodReferenceLookupHelper(referenceTree, name, site, argtypes, typeargtypes, maxPhase);
  13.614          Env<AttrContext> boundEnv = env.dup(env.tree, env.info.dup());
  13.615 -        Symbol boundSym = findMemberReference(boundEnv, boundLookupHelper);
  13.616 +        Symbol boundSym = lookupMethod(boundEnv, env.tree.pos(), site.tsym, boundLookupHelper);
  13.617  
  13.618          //step 2 - unbound lookup
  13.619          ReferenceLookupHelper unboundLookupHelper = boundLookupHelper.unboundLookup();
  13.620          Env<AttrContext> unboundEnv = env.dup(env.tree, env.info.dup());
  13.621 -        Symbol unboundSym = findMemberReference(unboundEnv, unboundLookupHelper);
  13.622 +        Symbol unboundSym = lookupMethod(unboundEnv, env.tree.pos(), site.tsym, unboundLookupHelper);
  13.623  
  13.624          //merge results
  13.625          Pair<Symbol, ReferenceLookupHelper> res;
  13.626 @@ -2361,11 +2416,23 @@
  13.627          /** type arguments used during the lookup */
  13.628          List<Type> typeargtypes;
  13.629  
  13.630 -        LookupHelper(Name name, Type site, List<Type> argtypes, List<Type> typeargtypes) {
  13.631 +        /** Max overload resolution phase handled by this helper */
  13.632 +        MethodResolutionPhase maxPhase;
  13.633 +
  13.634 +        LookupHelper(Name name, Type site, List<Type> argtypes, List<Type> typeargtypes, MethodResolutionPhase maxPhase) {
  13.635              this.name = name;
  13.636              this.site = site;
  13.637              this.argtypes = argtypes;
  13.638              this.typeargtypes = typeargtypes;
  13.639 +            this.maxPhase = maxPhase;
  13.640 +        }
  13.641 +
  13.642 +        /**
  13.643 +         * Should lookup stop at given phase with given result
  13.644 +         */
  13.645 +        protected boolean shouldStop(Symbol sym, MethodResolutionPhase phase) {
  13.646 +            return phase.ordinal() > maxPhase.ordinal() ||
  13.647 +                    sym.kind < ERRONEOUS || sym.kind == AMBIGUOUS;
  13.648          }
  13.649  
  13.650          /**
  13.651 @@ -2377,7 +2444,23 @@
  13.652          /**
  13.653           * Validate the result of the lookup
  13.654           */
  13.655 -        abstract Symbol access(Env<AttrContext> env, Symbol symbol);
  13.656 +        abstract Symbol access(Env<AttrContext> env, DiagnosticPosition pos, Symbol location, Symbol sym);
  13.657 +    }
  13.658 +
  13.659 +    abstract class BasicLookupHelper extends LookupHelper {
  13.660 +
  13.661 +        BasicLookupHelper(Name name, Type site, List<Type> argtypes, List<Type> typeargtypes) {
  13.662 +            super(name, site, argtypes, typeargtypes, MethodResolutionPhase.VARARITY);
  13.663 +        }
  13.664 +
  13.665 +        @Override
  13.666 +        Symbol access(Env<AttrContext> env, DiagnosticPosition pos, Symbol location, Symbol sym) {
  13.667 +            if (sym.kind >= AMBIGUOUS) {
  13.668 +                //if nothing is found return the 'first' error
  13.669 +                sym = accessMethod(sym, pos, location, site, name, true, argtypes, typeargtypes);
  13.670 +            }
  13.671 +            return sym;
  13.672 +        }
  13.673      }
  13.674  
  13.675      /**
  13.676 @@ -2391,14 +2474,11 @@
  13.677          /** The member reference tree */
  13.678          JCMemberReference referenceTree;
  13.679  
  13.680 -        /** Max overload resolution phase handled by this helper */
  13.681 -        MethodResolutionPhase maxPhase;
  13.682 -
  13.683          ReferenceLookupHelper(JCMemberReference referenceTree, Name name, Type site,
  13.684 -                List<Type> argtypes, List<Type> typeargtypes, boolean boxingAllowed) {
  13.685 -            super(name, site, argtypes, typeargtypes);
  13.686 +                List<Type> argtypes, List<Type> typeargtypes, MethodResolutionPhase maxPhase) {
  13.687 +            super(name, site, argtypes, typeargtypes, maxPhase);
  13.688              this.referenceTree = referenceTree;
  13.689 -            this.maxPhase = boxingAllowed ? VARARITY : BASIC;
  13.690 +
  13.691          }
  13.692  
  13.693          /**
  13.694 @@ -2407,13 +2487,13 @@
  13.695           */
  13.696          ReferenceLookupHelper unboundLookup() {
  13.697              //dummy loopkup helper that always return 'methodNotFound'
  13.698 -            return new ReferenceLookupHelper(referenceTree, name, site, argtypes, typeargtypes, maxPhase.isBoxingRequired()) {
  13.699 +            return new ReferenceLookupHelper(referenceTree, name, site, argtypes, typeargtypes, maxPhase) {
  13.700                  @Override
  13.701                  ReferenceLookupHelper unboundLookup() {
  13.702                      return this;
  13.703                  }
  13.704                  @Override
  13.705 -                Symbol lookupReference(Env<AttrContext> env, MethodResolutionPhase phase) {
  13.706 +                Symbol lookup(Env<AttrContext> env, MethodResolutionPhase phase) {
  13.707                      return methodNotFound;
  13.708                  }
  13.709                  @Override
  13.710 @@ -2429,23 +2509,8 @@
  13.711           */
  13.712          abstract JCMemberReference.ReferenceKind referenceKind(Symbol sym);
  13.713  
  13.714 -        @Override
  13.715 -        Symbol lookup(Env<AttrContext> env, MethodResolutionPhase phase) {
  13.716 -            return (env.info.pendingResolutionPhase.ordinal() > maxPhase.ordinal()) ?
  13.717 -                    methodNotFound : lookupReference(env, phase);
  13.718 -        }
  13.719 -
  13.720 -        abstract Symbol lookupReference(Env<AttrContext> env, MethodResolutionPhase phase);
  13.721 -
  13.722 -        Symbol access(Env<AttrContext> env, Symbol sym) {
  13.723 -            if (sym.kind >= AMBIGUOUS) {
  13.724 -                MethodResolutionPhase errPhase = currentResolutionContext.firstErroneousResolutionPhase();
  13.725 -                if (errPhase.ordinal() > maxPhase.ordinal()) {
  13.726 -                    errPhase = maxPhase;
  13.727 -                }
  13.728 -                env.info.pendingResolutionPhase = errPhase;
  13.729 -                sym = currentResolutionContext.resolutionCache.get(errPhase);
  13.730 -            }
  13.731 +        Symbol access(Env<AttrContext> env, DiagnosticPosition pos, Symbol location, Symbol sym) {
  13.732 +            //skip error reporting
  13.733              return sym;
  13.734          }
  13.735      }
  13.736 @@ -2459,8 +2524,8 @@
  13.737      class MethodReferenceLookupHelper extends ReferenceLookupHelper {
  13.738  
  13.739          MethodReferenceLookupHelper(JCMemberReference referenceTree, Name name, Type site,
  13.740 -                List<Type> argtypes, List<Type> typeargtypes, boolean boxingAllowed) {
  13.741 -            super(referenceTree, name, site, argtypes, typeargtypes, boxingAllowed);
  13.742 +                List<Type> argtypes, List<Type> typeargtypes, MethodResolutionPhase maxPhase) {
  13.743 +            super(referenceTree, name, site, argtypes, typeargtypes, maxPhase);
  13.744          }
  13.745  
  13.746          protected Symbol lookupReferenceInternal(Env<AttrContext> env, MethodResolutionPhase phase) {
  13.747 @@ -2475,7 +2540,7 @@
  13.748          }
  13.749  
  13.750          @Override
  13.751 -        final Symbol lookupReference(Env<AttrContext> env, MethodResolutionPhase phase) {
  13.752 +        final Symbol lookup(Env<AttrContext> env, MethodResolutionPhase phase) {
  13.753              return adjustLookupResult(env, lookupReferenceInternal(env, phase));
  13.754          }
  13.755  
  13.756 @@ -2485,7 +2550,7 @@
  13.757                      argtypes.nonEmpty() &&
  13.758                      types.isSubtypeUnchecked(argtypes.head, site)) {
  13.759                  return new UnboundMethodReferenceLookupHelper(referenceTree, name,
  13.760 -                        site, argtypes, typeargtypes, maxPhase.isBoxingRequired());
  13.761 +                        site, argtypes, typeargtypes, maxPhase);
  13.762              } else {
  13.763                  return super.unboundLookup();
  13.764              }
  13.765 @@ -2515,10 +2580,10 @@
  13.766      class UnboundMethodReferenceLookupHelper extends MethodReferenceLookupHelper {
  13.767  
  13.768          UnboundMethodReferenceLookupHelper(JCMemberReference referenceTree, Name name, Type site,
  13.769 -                List<Type> argtypes, List<Type> typeargtypes, boolean boxingAllowed) {
  13.770 +                List<Type> argtypes, List<Type> typeargtypes, MethodResolutionPhase maxPhase) {
  13.771              super(referenceTree, name,
  13.772                      site.isRaw() ? types.asSuper(argtypes.head, site.tsym) : site,
  13.773 -                    argtypes.tail, typeargtypes, boxingAllowed);
  13.774 +                    argtypes.tail, typeargtypes, maxPhase);
  13.775          }
  13.776  
  13.777          @Override
  13.778 @@ -2550,8 +2615,8 @@
  13.779          boolean needsInference;
  13.780  
  13.781          ConstructorReferenceLookupHelper(JCMemberReference referenceTree, Type site, List<Type> argtypes,
  13.782 -                List<Type> typeargtypes, boolean boxingAllowed) {
  13.783 -            super(referenceTree, names.init, site, argtypes, typeargtypes, boxingAllowed);
  13.784 +                List<Type> typeargtypes, MethodResolutionPhase maxPhase) {
  13.785 +            super(referenceTree, names.init, site, argtypes, typeargtypes, maxPhase);
  13.786              if (site.isRaw()) {
  13.787                  this.site = new ClassType(site.getEnclosingType(), site.tsym.type.getTypeArguments(), site.tsym);
  13.788                  needsInference = true;
  13.789 @@ -2559,7 +2624,7 @@
  13.790          }
  13.791  
  13.792          @Override
  13.793 -        protected Symbol lookupReference(Env<AttrContext> env, MethodResolutionPhase phase) {
  13.794 +        protected Symbol lookup(Env<AttrContext> env, MethodResolutionPhase phase) {
  13.795              Symbol sym = needsInference ?
  13.796                  findDiamond(env, site, argtypes, typeargtypes, phase.isBoxingRequired(), phase.isVarargsRequired()) :
  13.797                  findMethod(env, site, name, argtypes, typeargtypes,
  13.798 @@ -2584,140 +2649,36 @@
  13.799      }
  13.800  
  13.801      /**
  13.802 -     * Resolution step for member reference. This generalizes a standard
  13.803 -     * method/constructor lookup - on each overload resolution step, a
  13.804 -     * lookup helper class is used to perform the reference lookup; at the end
  13.805 -     * of the lookup, the helper is used to validate the results.
  13.806 +     * Main overload resolution routine. On each overload resolution step, a
  13.807 +     * lookup helper class is used to perform the method/constructor lookup;
  13.808 +     * at the end of the lookup, the helper is used to validate the results
  13.809 +     * (this last step might trigger overload resolution diagnostics).
  13.810       */
  13.811 -    Symbol findMemberReference(Env<AttrContext> env, LookupHelper lookupHelper) {
  13.812 +    Symbol lookupMethod(Env<AttrContext> env, DiagnosticPosition pos, Symbol location, LookupHelper lookupHelper) {
  13.813 +        return lookupMethod(env, pos, location, new MethodResolutionContext(), lookupHelper);
  13.814 +    }
  13.815 +
  13.816 +    Symbol lookupMethod(Env<AttrContext> env, DiagnosticPosition pos, Symbol location,
  13.817 +            MethodResolutionContext resolveContext, LookupHelper lookupHelper) {
  13.818          MethodResolutionContext prevResolutionContext = currentResolutionContext;
  13.819          try {
  13.820 -            currentResolutionContext = new MethodResolutionContext();
  13.821 -            Symbol sym = methodNotFound;
  13.822 -            List<MethodResolutionPhase> steps = methodResolutionSteps;
  13.823 -            while (steps.nonEmpty() &&
  13.824 -                   steps.head.isApplicable(boxingEnabled, varargsEnabled) &&
  13.825 -                   sym.kind >= ERRONEOUS) {
  13.826 -                currentResolutionContext.step = env.info.pendingResolutionPhase = steps.head;
  13.827 -                sym = lookupHelper.lookup(env, steps.head);
  13.828 -                currentResolutionContext.resolutionCache.put(steps.head, sym);
  13.829 -                steps = steps.tail;
  13.830 +            Symbol bestSoFar = methodNotFound;
  13.831 +            currentResolutionContext = resolveContext;
  13.832 +            for (MethodResolutionPhase phase : methodResolutionSteps) {
  13.833 +                if (!phase.isApplicable(boxingEnabled, varargsEnabled) ||
  13.834 +                        lookupHelper.shouldStop(bestSoFar, phase)) break;
  13.835 +                MethodResolutionPhase prevPhase = currentResolutionContext.step;
  13.836 +                Symbol prevBest = bestSoFar;
  13.837 +                currentResolutionContext.step = phase;
  13.838 +                bestSoFar = phase.mergeResults(bestSoFar, lookupHelper.lookup(env, phase));
  13.839 +                env.info.pendingResolutionPhase = (prevBest == bestSoFar) ? prevPhase : phase;
  13.840              }
  13.841 -            return lookupHelper.access(env, sym);
  13.842 -        }
  13.843 -        finally {
  13.844 +            return lookupHelper.access(env, pos, location, bestSoFar);
  13.845 +        } finally {
  13.846              currentResolutionContext = prevResolutionContext;
  13.847          }
  13.848      }
  13.849  
  13.850 -    /** Resolve constructor.
  13.851 -     *  @param pos       The position to use for error reporting.
  13.852 -     *  @param env       The environment current at the constructor invocation.
  13.853 -     *  @param site      The type of class for which a constructor is searched.
  13.854 -     *  @param argtypes  The types of the constructor invocation's value
  13.855 -     *                   arguments.
  13.856 -     *  @param typeargtypes  The types of the constructor invocation's type
  13.857 -     *                   arguments.
  13.858 -     *  @param allowBoxing Allow boxing and varargs conversions.
  13.859 -     *  @param useVarargs Box trailing arguments into an array for varargs.
  13.860 -     */
  13.861 -    Symbol resolveConstructor(DiagnosticPosition pos, Env<AttrContext> env,
  13.862 -                              Type site, List<Type> argtypes,
  13.863 -                              List<Type> typeargtypes,
  13.864 -                              boolean allowBoxing,
  13.865 -                              boolean useVarargs) {
  13.866 -        MethodResolutionContext prevResolutionContext = currentResolutionContext;
  13.867 -        try {
  13.868 -            currentResolutionContext = new MethodResolutionContext();
  13.869 -            return findConstructor(pos, env, site, argtypes, typeargtypes, allowBoxing, useVarargs);
  13.870 -        }
  13.871 -        finally {
  13.872 -            currentResolutionContext = prevResolutionContext;
  13.873 -        }
  13.874 -    }
  13.875 -
  13.876 -    Symbol findConstructor(DiagnosticPosition pos, Env<AttrContext> env,
  13.877 -                              Type site, List<Type> argtypes,
  13.878 -                              List<Type> typeargtypes,
  13.879 -                              boolean allowBoxing,
  13.880 -                              boolean useVarargs) {
  13.881 -        Symbol sym = findMethod(env, site,
  13.882 -                                    names.init, argtypes,
  13.883 -                                    typeargtypes, allowBoxing,
  13.884 -                                    useVarargs, false);
  13.885 -        chk.checkDeprecated(pos, env.info.scope.owner, sym);
  13.886 -        return sym;
  13.887 -    }
  13.888 -
  13.889 -    /** Resolve a constructor, throw a fatal error if not found.
  13.890 -     *  @param pos       The position to use for error reporting.
  13.891 -     *  @param env       The environment current at the method invocation.
  13.892 -     *  @param site      The type to be constructed.
  13.893 -     *  @param argtypes  The types of the invocation's value arguments.
  13.894 -     *  @param typeargtypes  The types of the invocation's type arguments.
  13.895 -     */
  13.896 -    public MethodSymbol resolveInternalConstructor(DiagnosticPosition pos, Env<AttrContext> env,
  13.897 -                                        Type site,
  13.898 -                                        List<Type> argtypes,
  13.899 -                                        List<Type> typeargtypes) {
  13.900 -        MethodResolutionContext resolveContext = new MethodResolutionContext();
  13.901 -        resolveContext.internalResolution = true;
  13.902 -        Symbol sym = resolveConstructor(resolveContext, pos, env, site, argtypes, typeargtypes);
  13.903 -        if (sym.kind == MTH) return (MethodSymbol)sym;
  13.904 -        else throw new FatalError(
  13.905 -                 diags.fragment("fatal.err.cant.locate.ctor", site));
  13.906 -    }
  13.907 -
  13.908 -    /** Resolve operator.
  13.909 -     *  @param pos       The position to use for error reporting.
  13.910 -     *  @param optag     The tag of the operation tree.
  13.911 -     *  @param env       The environment current at the operation.
  13.912 -     *  @param argtypes  The types of the operands.
  13.913 -     */
  13.914 -    Symbol resolveOperator(DiagnosticPosition pos, JCTree.Tag optag,
  13.915 -                           Env<AttrContext> env, List<Type> argtypes) {
  13.916 -        MethodResolutionContext prevResolutionContext = currentResolutionContext;
  13.917 -        try {
  13.918 -            currentResolutionContext = new MethodResolutionContext();
  13.919 -            Name name = treeinfo.operatorName(optag);
  13.920 -            Symbol sym = findMethod(env, syms.predefClass.type, name, argtypes,
  13.921 -                                    null, false, false, true);
  13.922 -            if (boxingEnabled && sym.kind >= WRONG_MTHS)
  13.923 -                sym = findMethod(env, syms.predefClass.type, name, argtypes,
  13.924 -                                 null, true, false, true);
  13.925 -            return accessMethod(sym, pos, env.enclClass.sym.type, name,
  13.926 -                          false, argtypes, null);
  13.927 -        }
  13.928 -        finally {
  13.929 -            currentResolutionContext = prevResolutionContext;
  13.930 -        }
  13.931 -    }
  13.932 -
  13.933 -    /** Resolve operator.
  13.934 -     *  @param pos       The position to use for error reporting.
  13.935 -     *  @param optag     The tag of the operation tree.
  13.936 -     *  @param env       The environment current at the operation.
  13.937 -     *  @param arg       The type of the operand.
  13.938 -     */
  13.939 -    Symbol resolveUnaryOperator(DiagnosticPosition pos, JCTree.Tag optag, Env<AttrContext> env, Type arg) {
  13.940 -        return resolveOperator(pos, optag, env, List.of(arg));
  13.941 -    }
  13.942 -
  13.943 -    /** Resolve binary operator.
  13.944 -     *  @param pos       The position to use for error reporting.
  13.945 -     *  @param optag     The tag of the operation tree.
  13.946 -     *  @param env       The environment current at the operation.
  13.947 -     *  @param left      The types of the left operand.
  13.948 -     *  @param right     The types of the right operand.
  13.949 -     */
  13.950 -    Symbol resolveBinaryOperator(DiagnosticPosition pos,
  13.951 -                                 JCTree.Tag optag,
  13.952 -                                 Env<AttrContext> env,
  13.953 -                                 Type left,
  13.954 -                                 Type right) {
  13.955 -        return resolveOperator(pos, optag, env, List.of(left, right));
  13.956 -    }
  13.957 -
  13.958      /**
  13.959       * Resolve `c.name' where name == this or name == super.
  13.960       * @param pos           The position to use for error reporting.
  13.961 @@ -2744,9 +2705,47 @@
  13.962              if ((env1.enclClass.sym.flags() & STATIC) != 0) staticOnly = true;
  13.963              env1 = env1.outer;
  13.964          }
  13.965 +        if (allowDefaultMethods && c.isInterface() &&
  13.966 +                name == names._super && !isStatic(env) &&
  13.967 +                types.isDirectSuperInterface(c.type, env.enclClass.sym)) {
  13.968 +            //this might be a default super call if one of the superinterfaces is 'c'
  13.969 +            for (Type t : pruneInterfaces(env.enclClass.type)) {
  13.970 +                if (t.tsym == c) {
  13.971 +                    env.info.defaultSuperCallSite = t;
  13.972 +                    return new VarSymbol(0, names._super,
  13.973 +                            types.asSuper(env.enclClass.type, c), env.enclClass.sym);
  13.974 +                }
  13.975 +            }
  13.976 +            //find a direct superinterface that is a subtype of 'c'
  13.977 +            for (Type i : types.interfaces(env.enclClass.type)) {
  13.978 +                if (i.tsym.isSubClass(c, types) && i.tsym != c) {
  13.979 +                    log.error(pos, "illegal.default.super.call", c,
  13.980 +                            diags.fragment("redundant.supertype", c, i));
  13.981 +                    return syms.errSymbol;
  13.982 +                }
  13.983 +            }
  13.984 +            Assert.error();
  13.985 +        }
  13.986          log.error(pos, "not.encl.class", c);
  13.987          return syms.errSymbol;
  13.988      }
  13.989 +    //where
  13.990 +    private List<Type> pruneInterfaces(Type t) {
  13.991 +        ListBuffer<Type> result = ListBuffer.lb();
  13.992 +        for (Type t1 : types.interfaces(t)) {
  13.993 +            boolean shouldAdd = true;
  13.994 +            for (Type t2 : types.interfaces(t)) {
  13.995 +                if (t1 != t2 && types.isSubtypeNoCapture(t2, t1)) {
  13.996 +                    shouldAdd = false;
  13.997 +                }
  13.998 +            }
  13.999 +            if (shouldAdd) {
 13.1000 +                result.append(t1);
 13.1001 +            }
 13.1002 +        }
 13.1003 +        return result.toList();
 13.1004 +    }
 13.1005 +
 13.1006  
 13.1007      /**
 13.1008       * Resolve `c.this' for an enclosing class c that contains the
 13.1009 @@ -3114,20 +3113,14 @@
 13.1010              return types.createErrorType(name, location, syms.errSymbol.type).tsym;
 13.1011          }
 13.1012  
 13.1013 -        protected boolean shouldReport(Candidate c) {
 13.1014 -            MethodResolutionPhase errPhase = resolveContext.firstErroneousResolutionPhase();
 13.1015 -            return !c.isApplicable() &&
 13.1016 -                    c.step == errPhase;
 13.1017 -        }
 13.1018 -
 13.1019          private Candidate errCandidate() {
 13.1020 +            Candidate bestSoFar = null;
 13.1021              for (Candidate c : resolveContext.candidates) {
 13.1022 -                if (shouldReport(c)) {
 13.1023 -                    return c;
 13.1024 -                }
 13.1025 +                if (c.isApplicable()) continue;
 13.1026 +                bestSoFar = c;
 13.1027              }
 13.1028 -            Assert.error();
 13.1029 -            return null;
 13.1030 +            Assert.checkNonNull(bestSoFar);
 13.1031 +            return bestSoFar;
 13.1032          }
 13.1033      }
 13.1034  
 13.1035 @@ -3156,7 +3149,7 @@
 13.1036                          pos,
 13.1037                          "cant.apply.symbols",
 13.1038                          name == names.init ? KindName.CONSTRUCTOR : absentKind(kind),
 13.1039 -                        getName(),
 13.1040 +                        name == names.init ? site.tsym.name : name,
 13.1041                          argtypes);
 13.1042                  return new JCDiagnostic.MultilineDiagnostic(err, candidateDetails(site));
 13.1043              } else {
 13.1044 @@ -3167,24 +3160,17 @@
 13.1045  
 13.1046          //where
 13.1047          List<JCDiagnostic> candidateDetails(Type site) {
 13.1048 -            List<JCDiagnostic> details = List.nil();
 13.1049 +            Map<Symbol, JCDiagnostic> details = new LinkedHashMap<Symbol, JCDiagnostic>();
 13.1050              for (Candidate c : resolveContext.candidates) {
 13.1051 -                if (!shouldReport(c)) continue;
 13.1052 +                if (c.isApplicable()) continue;
 13.1053                  JCDiagnostic detailDiag = diags.fragment("inapplicable.method",
 13.1054                          Kinds.kindName(c.sym),
 13.1055                          c.sym.location(site, types),
 13.1056                          c.sym.asMemberOf(site, types),
 13.1057                          c.details);
 13.1058 -                details = details.prepend(detailDiag);
 13.1059 +                details.put(c.sym, detailDiag);
 13.1060              }
 13.1061 -            return details.reverse();
 13.1062 -        }
 13.1063 -
 13.1064 -        private Name getName() {
 13.1065 -            Symbol sym = resolveContext.candidates.head.sym;
 13.1066 -            return sym.name == names.init ?
 13.1067 -                sym.owner.name :
 13.1068 -                sym.name;
 13.1069 +            return List.from(details.values());
 13.1070          }
 13.1071      }
 13.1072  
 13.1073 @@ -3322,7 +3308,21 @@
 13.1074      enum MethodResolutionPhase {
 13.1075          BASIC(false, false),
 13.1076          BOX(true, false),
 13.1077 -        VARARITY(true, true);
 13.1078 +        VARARITY(true, true) {
 13.1079 +            @Override
 13.1080 +            public Symbol mergeResults(Symbol bestSoFar, Symbol sym) {
 13.1081 +                switch (sym.kind) {
 13.1082 +                    case WRONG_MTH:
 13.1083 +                        return (bestSoFar.kind == WRONG_MTH || bestSoFar.kind == WRONG_MTHS) ?
 13.1084 +                            bestSoFar :
 13.1085 +                            sym;
 13.1086 +                    case ABSENT_MTH:
 13.1087 +                        return bestSoFar;
 13.1088 +                    default:
 13.1089 +                        return sym;
 13.1090 +                }
 13.1091 +            }
 13.1092 +        };
 13.1093  
 13.1094          boolean isBoxingRequired;
 13.1095          boolean isVarargsRequired;
 13.1096 @@ -3344,6 +3344,10 @@
 13.1097              return (varargsEnabled || !isVarargsRequired) &&
 13.1098                     (boxingEnabled || !isBoxingRequired);
 13.1099          }
 13.1100 +
 13.1101 +        public Symbol mergeResults(Symbol prev, Symbol sym) {
 13.1102 +            return sym;
 13.1103 +        }
 13.1104      }
 13.1105  
 13.1106      final List<MethodResolutionPhase> methodResolutionSteps = List.of(BASIC, BOX, VARARITY);
 13.1107 @@ -3359,29 +3363,11 @@
 13.1108  
 13.1109          private List<Candidate> candidates = List.nil();
 13.1110  
 13.1111 -        private Map<MethodResolutionPhase, Symbol> resolutionCache =
 13.1112 -            new EnumMap<MethodResolutionPhase, Symbol>(MethodResolutionPhase.class);
 13.1113 -
 13.1114          MethodResolutionPhase step = null;
 13.1115  
 13.1116          private boolean internalResolution = false;
 13.1117          private DeferredAttr.AttrMode attrMode = DeferredAttr.AttrMode.SPECULATIVE;
 13.1118  
 13.1119 -        private MethodResolutionPhase firstErroneousResolutionPhase() {
 13.1120 -            MethodResolutionPhase bestSoFar = BASIC;
 13.1121 -            Symbol sym = methodNotFound;
 13.1122 -            List<MethodResolutionPhase> steps = methodResolutionSteps;
 13.1123 -            while (steps.nonEmpty() &&
 13.1124 -                   steps.head.isApplicable(boxingEnabled, varargsEnabled) &&
 13.1125 -                   sym.kind >= WRONG_MTHS) {
 13.1126 -                sym = resolutionCache.get(steps.head);
 13.1127 -                if (sym.kind == ABSENT_MTH) break; //ignore spurious empty entries
 13.1128 -                bestSoFar = steps.head;
 13.1129 -                steps = steps.tail;
 13.1130 -            }
 13.1131 -            return bestSoFar;
 13.1132 -        }
 13.1133 -
 13.1134          void addInapplicableCandidate(Symbol sym, JCDiagnostic details) {
 13.1135              Candidate c = new Candidate(currentResolutionContext.step, sym, details, null);
 13.1136              candidates = candidates.append(c);
 13.1137 @@ -3392,16 +3378,6 @@
 13.1138              candidates = candidates.append(c);
 13.1139          }
 13.1140  
 13.1141 -        Candidate getCandidate(Symbol sym, MethodResolutionPhase phase) {
 13.1142 -            for (Candidate c : currentResolutionContext.candidates) {
 13.1143 -                if (c.step == phase &&
 13.1144 -                        c.sym.baseSymbol() == sym.baseSymbol()) {
 13.1145 -                    return c;
 13.1146 -                }
 13.1147 -            }
 13.1148 -            return null;
 13.1149 -        }
 13.1150 -
 13.1151          /**
 13.1152           * This class represents an overload resolution candidate. There are two
 13.1153           * kinds of candidates: applicable methods and inapplicable methods;
    14.1 --- a/src/share/classes/com/sun/tools/javac/jvm/CRTable.java	Thu Nov 08 11:53:23 2012 -0800
    14.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/CRTable.java	Fri Nov 09 14:47:22 2012 -0800
    14.3 @@ -503,6 +503,14 @@
    14.4              result = sr;
    14.5          }
    14.6  
    14.7 +        @Override
    14.8 +        public void visitLetExpr(LetExpr tree) {
    14.9 +            SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
   14.10 +            sr.mergeWith(csp(tree.defs));
   14.11 +            sr.mergeWith(csp(tree.expr));
   14.12 +            result = sr;
   14.13 +        }
   14.14 +
   14.15          public void visitTypeParameter(JCTypeParameter tree) {
   14.16              SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
   14.17              sr.mergeWith(csp(tree.bounds));
   14.18 @@ -525,7 +533,7 @@
   14.19           */
   14.20          public int startPos(JCTree tree) {
   14.21              if (tree == null) return Position.NOPOS;
   14.22 -            return tree.pos;
   14.23 +            return TreeInfo.getStartPos(tree);
   14.24          }
   14.25  
   14.26          /** The end position of given tree, if it has
   14.27 @@ -533,9 +541,7 @@
   14.28           */
   14.29          public int endPos(JCTree tree) {
   14.30              if (tree == null) return Position.NOPOS;
   14.31 -            if (tree.hasTag(JCTree.Tag.BLOCK))
   14.32 -                return ((JCBlock) tree).endpos;
   14.33 -            return endPosTable.getEndPos(tree);
   14.34 +            return TreeInfo.getEndPos(tree, endPosTable);
   14.35          }
   14.36      }
   14.37  
    15.1 --- a/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Thu Nov 08 11:53:23 2012 -0800
    15.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Fri Nov 09 14:47:22 2012 -0800
    15.3 @@ -115,6 +115,9 @@
    15.4       */
    15.5      boolean lintClassfile;
    15.6  
    15.7 +    /** Switch: allow default methods
    15.8 +     */
    15.9 +    boolean allowDefaultMethods;
   15.10  
   15.11      /** Switch: preserve parameter names from the variable table.
   15.12       */
   15.13 @@ -279,6 +282,7 @@
   15.14          allowVarargs     = source.allowVarargs();
   15.15          allowAnnotations = source.allowAnnotations();
   15.16          allowSimplifiedVarargs = source.allowSimplifiedVarargs();
   15.17 +        allowDefaultMethods = source.allowDefaultMethods();
   15.18          saveParameterNames = options.isSet("save-parameter-names");
   15.19          cacheCompletionFailure = options.isUnset("dev");
   15.20          preferSource = "source".equals(options.get("-Xprefer"));
   15.21 @@ -937,6 +941,18 @@
   15.22  
   15.23              new AttributeReader(names.Code, V45_3, MEMBER_ATTRIBUTE) {
   15.24                  protected void read(Symbol sym, int attrLen) {
   15.25 +                    if (currentOwner.isInterface() &&
   15.26 +                            (sym.flags_field & ABSTRACT) == 0 && !name.equals(names.clinit)) {
   15.27 +                        if (majorVersion > Target.JDK1_8.majorVersion ||
   15.28 +                                //todo replace with Target.Version when available
   15.29 +                                (majorVersion == Target.JDK1_8.majorVersion && minorVersion >= Target.JDK1_8.minorVersion)) {
   15.30 +                            currentOwner.flags_field |= DEFAULT;
   15.31 +                            sym.flags_field |= DEFAULT | ABSTRACT;
   15.32 +                        } else {
   15.33 +                            //protect against ill-formed classfiles
   15.34 +                            throw new CompletionFailure(currentOwner, "default method found in pre JDK 8 classfile");
   15.35 +                        }
   15.36 +                    }
   15.37                      if (readAllOfClassFile || saveParameterNames)
   15.38                          ((MethodSymbol)sym).code = readCode(sym);
   15.39                      else
    16.1 --- a/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java	Thu Nov 08 11:53:23 2012 -0800
    16.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java	Fri Nov 09 14:47:22 2012 -0800
    16.3 @@ -1540,7 +1540,7 @@
    16.4          List<Type> interfaces = types.interfaces(c.type);
    16.5          List<Type> typarams = c.type.getTypeArguments();
    16.6  
    16.7 -        int flags = adjustFlags(c.flags());
    16.8 +        int flags = adjustFlags(c.flags() & ~DEFAULT);
    16.9          if ((flags & PROTECTED) != 0) flags |= PUBLIC;
   16.10          flags = flags & ClassFlags & ~STRICTFP;
   16.11          if ((flags & INTERFACE) == 0) flags |= ACC_SUPER;
   16.12 @@ -1676,6 +1676,8 @@
   16.13              result |= ACC_BRIDGE;
   16.14          if ((flags & VARARGS) != 0  && target.useVarargsFlag())
   16.15              result |= ACC_VARARGS;
   16.16 +        if ((flags & DEFAULT) != 0)
   16.17 +            result &= ~ABSTRACT;
   16.18          return result;
   16.19      }
   16.20  
    17.1 --- a/src/share/classes/com/sun/tools/javac/jvm/Items.java	Thu Nov 08 11:53:23 2012 -0800
    17.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/Items.java	Fri Nov 09 14:47:22 2012 -0800
    17.3 @@ -523,7 +523,7 @@
    17.4          Item invoke() {
    17.5              MethodType mtype = (MethodType)member.externalType(types);
    17.6              int rescode = Code.typecode(mtype.restype);
    17.7 -            if ((member.owner.flags() & Flags.INTERFACE) != 0) {
    17.8 +            if ((member.owner.flags() & Flags.INTERFACE) != 0 && !nonvirtual) {
    17.9                  code.emitInvokeinterface(pool.put(member), mtype);
   17.10              } else if (nonvirtual) {
   17.11                  code.emitInvokespecial(pool.put(member), mtype);
    18.1 --- a/src/share/classes/com/sun/tools/javac/jvm/Target.java	Thu Nov 08 11:53:23 2012 -0800
    18.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/Target.java	Fri Nov 09 14:47:22 2012 -0800
    18.3 @@ -1,5 +1,5 @@
    18.4  /*
    18.5 - * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
    18.6 + * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
    18.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    18.8   *
    18.9   * This code is free software; you can redistribute it and/or modify it
   18.10 @@ -68,8 +68,8 @@
   18.11      /** JDK 7. */
   18.12      JDK1_7("1.7", 51, 0),
   18.13  
   18.14 -    /** JDK 8. */ // For now, a clone of 7
   18.15 -    JDK1_8("1.8", 51, 0);
   18.16 +    /** JDK 8. */
   18.17 +    JDK1_8("1.8", 52, 0);
   18.18  
   18.19      private static final Context.Key<Target> targetKey =
   18.20          new Context.Key<Target>();
    19.1 --- a/src/share/classes/com/sun/tools/javac/main/Main.java	Thu Nov 08 11:53:23 2012 -0800
    19.2 +++ b/src/share/classes/com/sun/tools/javac/main/Main.java	Fri Nov 09 14:47:22 2012 -0800
    19.3 @@ -533,7 +533,7 @@
    19.4       * annotation processor.
    19.5       */
    19.6      void apMessage(AnnotationProcessingError ex) {
    19.7 -        log.printLines("msg.proc.annotation.uncaught.exception");
    19.8 +        log.printLines(PrefixKind.JAVAC, "msg.proc.annotation.uncaught.exception");
    19.9          ex.getCause().printStackTrace(log.getWriter(WriterKind.NOTICE));
   19.10      }
   19.11  
    20.1 --- a/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Thu Nov 08 11:53:23 2012 -0800
    20.2 +++ b/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Fri Nov 09 14:47:22 2012 -0800
    20.3 @@ -88,6 +88,15 @@
    20.4      /** End position mappings container */
    20.5      private final AbstractEndPosTable endPosTable;
    20.6  
    20.7 +    interface ErrorRecoveryAction {
    20.8 +        JCTree doRecover(JavacParser parser);
    20.9 +    }
   20.10 +
   20.11 +    enum BasicErrorRecoveryAction implements ErrorRecoveryAction {
   20.12 +        BLOCK_STMT {public JCTree doRecover(JavacParser parser) { return parser.parseStatementAsBlock(); }},
   20.13 +        CATCH_CLAUSE {public JCTree doRecover(JavacParser parser) { return parser.catchClause(); }}
   20.14 +    }
   20.15 +
   20.16      /** Construct a parser from a given scanner, tree factory and log.
   20.17       */
   20.18      protected JavacParser(ParserFactory fac,
   20.19 @@ -2102,11 +2111,15 @@
   20.20              nextToken();
   20.21              return toP(F.at(pos).Skip());
   20.22          case ELSE:
   20.23 -            return toP(F.Exec(syntaxError("else.without.if")));
   20.24 +            int elsePos = token.pos;
   20.25 +            nextToken();
   20.26 +            return doRecover(elsePos, BasicErrorRecoveryAction.BLOCK_STMT, "else.without.if");
   20.27          case FINALLY:
   20.28 -            return toP(F.Exec(syntaxError("finally.without.try")));
   20.29 +            int finallyPos = token.pos;
   20.30 +            nextToken();
   20.31 +            return doRecover(finallyPos, BasicErrorRecoveryAction.BLOCK_STMT, "finally.without.try");
   20.32          case CATCH:
   20.33 -            return toP(F.Exec(syntaxError("catch.without.try")));
   20.34 +            return doRecover(token.pos, BasicErrorRecoveryAction.CATCH_CLAUSE, "catch.without.try");
   20.35          case ASSERT: {
   20.36              if (allowAsserts && token.kind == ASSERT) {
   20.37                  nextToken();
   20.38 @@ -2139,6 +2152,13 @@
   20.39          }
   20.40      }
   20.41  
   20.42 +    private JCStatement doRecover(int startPos, ErrorRecoveryAction action, String key) {
   20.43 +        int errPos = S.errPos();
   20.44 +        JCTree stm = action.doRecover(this);
   20.45 +        S.errPos(errPos);
   20.46 +        return toP(F.Exec(syntaxError(startPos, List.<JCTree>of(stm), key)));
   20.47 +    }
   20.48 +
   20.49      /** CatchClause     = CATCH "(" FormalParameter ")" Block
   20.50       */
   20.51      protected JCCatch catchClause() {
    21.1 --- a/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Thu Nov 08 11:53:23 2012 -0800
    21.2 +++ b/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Fri Nov 09 14:47:22 2012 -0800
    21.3 @@ -574,7 +574,7 @@
    21.4      interface expected here
    21.5  
    21.6  compiler.err.intf.meth.cant.have.body=\
    21.7 -    interface methods cannot have body
    21.8 +    interface abstract methods cannot have body
    21.9  
   21.10  compiler.err.invalid.annotation.member.type=\
   21.11      invalid type for annotation member
   21.12 @@ -941,6 +941,31 @@
   21.13  compiler.err.types.incompatible.diff.ret=\
   21.14      types {0} and {1} are incompatible; both define {2}, but with unrelated return types
   21.15  
   21.16 +# 0: kind, 1: type, 2: name, 3: list of type, 4: symbol, 5: symbol
   21.17 +compiler.err.types.incompatible.unrelated.defaults=\
   21.18 +    {0} {1} inherits unrelated defaults for {2}({3}) from types {4} and {5}
   21.19 +
   21.20 +# 0: kind, 1: type, 2: name, 3: list of type, 4: symbol, 5: symbol
   21.21 +compiler.err.types.incompatible.abstract.default=\
   21.22 +    {0} {1} inherits abstract and default for {2}({3}) from types {4} and {5}
   21.23 +
   21.24 +# 0: name, 1: kind, 2: symbol
   21.25 +compiler.err.default.overrides.object.member=\
   21.26 +    default method {0} in {1} {2} overrides a member of java.lang.Object
   21.27 +
   21.28 +# 0: type, 1: message segment
   21.29 +compiler.err.illegal.default.super.call=\
   21.30 +    bad type qualifier {0} in default super call\n\
   21.31 +    {1}
   21.32 +
   21.33 +# 0: symbol, 1: type
   21.34 +compiler.misc.overridden.default=\
   21.35 +    method {0} is overridden in {2}
   21.36 +
   21.37 +# 0: symbol, 1: symbol
   21.38 +compiler.misc.redundant.supertype=\
   21.39 +    redundant interface {0} is extended by {1}
   21.40 +
   21.41  compiler.err.unclosed.char.lit=\
   21.42      unclosed character literal
   21.43  
    22.1 --- a/src/share/classes/com/sun/tools/javadoc/JavadocMemberEnter.java	Thu Nov 08 11:53:23 2012 -0800
    22.2 +++ b/src/share/classes/com/sun/tools/javadoc/JavadocMemberEnter.java	Fri Nov 09 14:47:22 2012 -0800
    22.3 @@ -81,6 +81,9 @@
    22.4              docenv.makeAnnotationTypeElementDoc(meth, docComment, tree, lineMap);
    22.5          else
    22.6              docenv.makeMethodDoc(meth, docComment, tree, lineMap);
    22.7 +
    22.8 +        // release resources
    22.9 +        tree.body = null;
   22.10      }
   22.11  
   22.12      @Override
    23.1 --- a/src/share/classes/com/sun/tools/javadoc/SeeTagImpl.java	Thu Nov 08 11:53:23 2012 -0800
    23.2 +++ b/src/share/classes/com/sun/tools/javadoc/SeeTagImpl.java	Fri Nov 09 14:47:22 2012 -0800
    23.3 @@ -267,8 +267,6 @@
    23.4              }
    23.5  
    23.6              if (referencedClass == null) { /* may just not be in this run */
    23.7 -//                docenv().warning(holder, "tag.see.class_not_found",
    23.8 -//                                 where, text);
    23.9                  // check if it's a package name
   23.10                  referencedPackage = docenv().lookupPackage(where);
   23.11                  return;
    24.1 --- a/src/share/classes/com/sun/tools/javadoc/Start.java	Thu Nov 08 11:53:23 2012 -0800
    24.2 +++ b/src/share/classes/com/sun/tools/javadoc/Start.java	Fri Nov 09 14:47:22 2012 -0800
    24.3 @@ -54,6 +54,8 @@
    24.4   * @author Neal Gafter (rewrite)
    24.5   */
    24.6  class Start {
    24.7 +    /** Context for this invocation. */
    24.8 +    private final Context context;
    24.9  
   24.10      private final String defaultDocletClassName;
   24.11      private final ClassLoader docletParentClassLoader;
   24.12 @@ -69,7 +71,7 @@
   24.13  
   24.14      private long defaultFilter = PUBLIC | PROTECTED;
   24.15  
   24.16 -    private Messager messager;
   24.17 +    private final Messager messager;
   24.18  
   24.19      String docLocale = "";
   24.20  
   24.21 @@ -96,8 +98,8 @@
   24.22            PrintWriter noticeWriter,
   24.23            String defaultDocletClassName,
   24.24            ClassLoader docletParentClassLoader) {
   24.25 -        Context tempContext = new Context(); // interim context until option decoding completed
   24.26 -        messager = new Messager(tempContext, programName, errWriter, warnWriter, noticeWriter);
   24.27 +        context = new Context();
   24.28 +        messager = new Messager(context, programName, errWriter, warnWriter, noticeWriter);
   24.29          this.defaultDocletClassName = defaultDocletClassName;
   24.30          this.docletParentClassLoader = docletParentClassLoader;
   24.31      }
   24.32 @@ -108,8 +110,8 @@
   24.33  
   24.34      Start(String programName, String defaultDocletClassName,
   24.35            ClassLoader docletParentClassLoader) {
   24.36 -        Context tempContext = new Context(); // interim context until option decoding completed
   24.37 -        messager = new Messager(tempContext, programName);
   24.38 +        context = new Context();
   24.39 +        messager = new Messager(context, programName);
   24.40          this.defaultDocletClassName = defaultDocletClassName;
   24.41          this.docletParentClassLoader = docletParentClassLoader;
   24.42      }
   24.43 @@ -219,16 +221,6 @@
   24.44          ListBuffer<String> subPackages = new ListBuffer<String>();
   24.45          ListBuffer<String> excludedPackages = new ListBuffer<String>();
   24.46  
   24.47 -        Context context = new Context();
   24.48 -        // Setup a new Messager, using the same initial parameters as the
   24.49 -        // existing Messager, except that this one will be able to use any
   24.50 -        // options that may be set up below.
   24.51 -        Messager.preRegister(context,
   24.52 -                messager.programName,
   24.53 -                messager.getWriter(Log.WriterKind.ERROR),
   24.54 -                messager.getWriter(Log.WriterKind.WARNING),
   24.55 -                messager.getWriter(Log.WriterKind.NOTICE));
   24.56 -
   24.57          Options compOpts = Options.instance(context);
   24.58          boolean docClasses = false;
   24.59  
   24.60 @@ -368,6 +360,7 @@
   24.61                  javaNames.append(arg);
   24.62              }
   24.63          }
   24.64 +        compOpts.notifyListeners();
   24.65  
   24.66          if (javaNames.isEmpty() && subPackages.isEmpty()) {
   24.67              usageError("main.No_packages_or_classes_specified");
   24.68 @@ -394,14 +387,13 @@
   24.69                  // legacy?
   24.70                  languageVersion == null || languageVersion == LanguageVersion.JAVA_1_1, quiet);
   24.71  
   24.72 +        // release resources
   24.73 +        comp = null;
   24.74 +
   24.75          // pass off control to the doclet
   24.76          boolean ok = root != null;
   24.77          if (ok) ok = docletInvoker.start(root);
   24.78  
   24.79 -        Messager docletMessager = Messager.instance0(context);
   24.80 -        messager.nwarnings += docletMessager.nwarnings;
   24.81 -        messager.nerrors += docletMessager.nerrors;
   24.82 -
   24.83          // We're done.
   24.84          if (compOpts.get("-verbose") != null) {
   24.85              tm = System.currentTimeMillis() - tm;
    25.1 --- a/src/share/classes/com/sun/tools/javadoc/resources/javadoc.properties	Thu Nov 08 11:53:23 2012 -0800
    25.2 +++ b/src/share/classes/com/sun/tools/javadoc/resources/javadoc.properties	Fri Nov 09 14:47:22 2012 -0800
    25.3 @@ -1,5 +1,5 @@
    25.4  #
    25.5 -# Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
    25.6 +# Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
    25.7  # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    25.8  #
    25.9  # This code is free software; you can redistribute it and/or modify it
   25.10 @@ -64,7 +64,6 @@
   25.11  main.incompatible.access.flags=More than one of -public, -private, -package, or -protected specified.
   25.12  main.cant.read=cannot read {0}
   25.13  main.Loading_source_files_for_package=Loading source files for package {0}...
   25.14 -main.Loading_source_file_for_class=Loading source file for class {0}...
   25.15  main.Loading_source_file=Loading source file {0}...
   25.16  main.Building_tree=Constructing Javadoc information...
   25.17  main.no_source_files_for_package=No source files for package {0}
   25.18 @@ -96,13 +95,12 @@
   25.19  tag.see.can_not_find_member=Tag {0}: can''t find {1} in {2}
   25.20  tag.see.no_close_bracket_on_url=Tag {0}: missing final ''>'': "{1}"
   25.21  tag.see.no_close_quote=Tag {0}: no final close quote: "{1}"
   25.22 -tag.see.class_not_found=class {0} not found for @see tag: "{1}"
   25.23  tag.see.class_not_specified=Tag {0}: class not specified: "{1}"
   25.24  tag.see.illegal_character=Tag {0}:illegal character: "{1}" in "{2}"
   25.25  tag.see.malformed_see_tag=Tag {0}: malformed: "{1}"
   25.26 -tag.throws.exception_not_found={0} tag, class {1} not found.
   25.27  tag.End_delimiter_missing_for_possible_SeeTag=End Delimiter } missing for possible See Tag in comment string: "{0}"
   25.28  tag.Improper_Use_Of_Link_Tag=Missing closing ''}'' character for inline tag: "{0}"
   25.29 +tag.serialField.illegal_character=illegal character {0} in @serialField tag: {1}.
   25.30  javadoc.File_Read_Error=Error while reading file {0}
   25.31  javadoc.Body_missing_from_html_file=Body tag missing from HTML file
   25.32  javadoc.End_body_missing_from_html_file=Close body tag missing from HTML file
   25.33 @@ -110,4 +108,3 @@
   25.34  javadoc.class_not_found=Class {0} not found.
   25.35  javadoc.error=error
   25.36  javadoc.warning=warning
   25.37 -tag.serialField.illegal_character=illegal character {0} in @serialField tag: {1}.
    26.1 --- a/test/tools/javac/7132880/T7132880.out	Thu Nov 08 11:53:23 2012 -0800
    26.2 +++ b/test/tools/javac/7132880/T7132880.out	Fri Nov 09 14:47:22 2012 -0800
    26.3 @@ -1,4 +1,4 @@
    26.4  T7132880.java:23:12: compiler.err.cant.apply.symbol: kindname.method, m1, java.lang.Integer, java.lang.String, kindname.class, Outer.Inner1, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Integer))
    26.5 -T7132880.java:33:12: compiler.err.cant.apply.symbols: kindname.method, m1, java.lang.String,{(compiler.misc.inapplicable.method: kindname.method, Outer.Inner2, m1(java.lang.Double), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Double))),(compiler.misc.inapplicable.method: kindname.method, Outer.Inner2, m1(java.lang.Integer), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Integer)))}
    26.6 +T7132880.java:33:12: compiler.err.cant.apply.symbols: kindname.method, m1, java.lang.String,{(compiler.misc.inapplicable.method: kindname.method, Outer.Inner2, m1(java.lang.Integer), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Integer))),(compiler.misc.inapplicable.method: kindname.method, Outer.Inner2, m1(java.lang.Double), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Double)))}
    26.7  T7132880.java:43:12: compiler.err.ref.ambiguous: m2, kindname.method, m2(java.lang.Object,int), Outer.Inner3, kindname.method, m2(int,java.lang.Object), Outer.Inner3
    26.8  3 errors
    27.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    27.2 +++ b/test/tools/javac/8002286/T8002286.java	Fri Nov 09 14:47:22 2012 -0800
    27.3 @@ -0,0 +1,12 @@
    27.4 +/*
    27.5 + * @test /nodynamiccopyright/
    27.6 + * @bug 8002286
    27.7 + * @summary Resolve should support nested resolution contexts
    27.8 + * @compile/fail/ref=T8002286.out -XDrawDiagnostics T8002286.java
    27.9 + */
   27.10 +class T8002286 {
   27.11 +    @Anno(nonExistent())
   27.12 +    static class Test { }
   27.13 +
   27.14 +    @interface Anno { }
   27.15 +}
    28.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    28.2 +++ b/test/tools/javac/8002286/T8002286.out	Fri Nov 09 14:47:22 2012 -0800
    28.3 @@ -0,0 +1,3 @@
    28.4 +T8002286.java:8:22: compiler.err.cant.resolve.location.args: kindname.method, value, , , (compiler.misc.location: kindname.annotation, T8002286.Anno, null)
    28.5 +T8002286.java:8:11: compiler.err.cant.resolve.location.args: kindname.method, nonExistent, , , (compiler.misc.location: kindname.class, T8002286, null)
    28.6 +2 errors
    29.1 --- a/test/tools/javac/Diagnostics/6799605/T6799605.out	Thu Nov 08 11:53:23 2012 -0800
    29.2 +++ b/test/tools/javac/Diagnostics/6799605/T6799605.out	Fri Nov 09 14:47:22 2012 -0800
    29.3 @@ -1,4 +1,4 @@
    29.4 -T6799605.java:17:9: compiler.err.cant.apply.symbols: kindname.method, m, T6799605<compiler.misc.type.captureof: 1, ?>,{(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>,T6799605<T>,T6799605<T>), (compiler.misc.infer.arg.length.mismatch: T)),(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>,T6799605<T>), (compiler.misc.infer.arg.length.mismatch: T)),(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>), (compiler.misc.inferred.do.not.conform.to.upper.bounds: compiler.misc.type.captureof: 1, ?, T6799605<compiler.misc.type.captureof: 1, ?>))}
    29.5 -T6799605.java:18:9: compiler.err.cant.apply.symbols: kindname.method, m, T6799605<compiler.misc.type.captureof: 1, ?>,T6799605<compiler.misc.type.captureof: 2, ?>,{(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>,T6799605<T>,T6799605<T>), (compiler.misc.infer.arg.length.mismatch: T)),(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>,T6799605<T>), (compiler.misc.inferred.do.not.conform.to.eq.bounds: compiler.misc.type.captureof: 2, ?, compiler.misc.type.captureof: 2, ?,compiler.misc.type.captureof: 1, ?)),(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>), (compiler.misc.infer.arg.length.mismatch: T))}
    29.6 -T6799605.java:19:9: compiler.err.cant.apply.symbols: kindname.method, m, T6799605<compiler.misc.type.captureof: 1, ?>,T6799605<compiler.misc.type.captureof: 2, ?>,T6799605<compiler.misc.type.captureof: 3, ?>,{(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>,T6799605<T>,T6799605<T>), (compiler.misc.inferred.do.not.conform.to.eq.bounds: compiler.misc.type.captureof: 3, ?, compiler.misc.type.captureof: 3, ?,compiler.misc.type.captureof: 2, ?,compiler.misc.type.captureof: 1, ?)),(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>,T6799605<T>), (compiler.misc.infer.arg.length.mismatch: T)),(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>), (compiler.misc.infer.arg.length.mismatch: T))}
    29.7 +T6799605.java:17:9: compiler.err.cant.apply.symbols: kindname.method, m, T6799605<compiler.misc.type.captureof: 1, ?>,{(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>), (compiler.misc.inferred.do.not.conform.to.upper.bounds: compiler.misc.type.captureof: 1, ?, T6799605<compiler.misc.type.captureof: 1, ?>)),(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>,T6799605<T>), (compiler.misc.infer.arg.length.mismatch: T)),(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>,T6799605<T>,T6799605<T>), (compiler.misc.infer.arg.length.mismatch: T))}
    29.8 +T6799605.java:18:9: compiler.err.cant.apply.symbols: kindname.method, m, T6799605<compiler.misc.type.captureof: 1, ?>,T6799605<compiler.misc.type.captureof: 2, ?>,{(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>), (compiler.misc.infer.arg.length.mismatch: T)),(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>,T6799605<T>), (compiler.misc.inferred.do.not.conform.to.eq.bounds: compiler.misc.type.captureof: 2, ?, compiler.misc.type.captureof: 2, ?,compiler.misc.type.captureof: 1, ?)),(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>,T6799605<T>,T6799605<T>), (compiler.misc.infer.arg.length.mismatch: T))}
    29.9 +T6799605.java:19:9: compiler.err.cant.apply.symbols: kindname.method, m, T6799605<compiler.misc.type.captureof: 1, ?>,T6799605<compiler.misc.type.captureof: 2, ?>,T6799605<compiler.misc.type.captureof: 3, ?>,{(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>), (compiler.misc.infer.arg.length.mismatch: T)),(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>,T6799605<T>), (compiler.misc.infer.arg.length.mismatch: T)),(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>,T6799605<T>,T6799605<T>), (compiler.misc.inferred.do.not.conform.to.eq.bounds: compiler.misc.type.captureof: 3, ?, compiler.misc.type.captureof: 3, ?,compiler.misc.type.captureof: 2, ?,compiler.misc.type.captureof: 1, ?))}
   29.10  3 errors
    30.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    30.2 +++ b/test/tools/javac/annotations/repeatingAnnotations/combo/BasicSyntaxCombo.java	Fri Nov 09 14:47:22 2012 -0800
    30.3 @@ -0,0 +1,209 @@
    30.4 +/*
    30.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    30.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    30.7 + *
    30.8 + * This code is free software; you can redistribute it and/or modify it
    30.9 + * under the terms of the GNU General Public License version 2 only, as
   30.10 + * published by the Free Software Foundation.
   30.11 + *
   30.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   30.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   30.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   30.15 + * version 2 for more details (a copy is included in the LICENSE file that
   30.16 + * accompanied this code).
   30.17 + *
   30.18 + * You should have received a copy of the GNU General Public License version
   30.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   30.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   30.21 + *
   30.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   30.23 + * or visit www.oracle.com if you need additional information or have any
   30.24 + * questions.
   30.25 + */
   30.26 +
   30.27 +/**
   30.28 + * @test
   30.29 + * @bug      8002157
   30.30 + * @author   sogoel
   30.31 + * @summary  Basic Syntax test for repeating annotations on all elements
   30.32 + * @build    Helper
   30.33 + * @compile  BasicSyntaxCombo.java
   30.34 + * @run main BasicSyntaxCombo
   30.35 + */
   30.36 +
   30.37 +
   30.38 +import java.util.Arrays;
   30.39 +import javax.tools.DiagnosticCollector;
   30.40 +import javax.tools.JavaFileObject;
   30.41 +import javax.tools.Diagnostic;
   30.42 +
   30.43 +/*
   30.44 + * Generate test src for element kinds with repeating annotations.
   30.45 + * The test uses Helper.java to get the template to create test src and
   30.46 + * compile the test src.
   30.47 + * The test passes if valid test src compile as expected and
   30.48 + * and invalid test src fail as expected.
   30.49 + */
   30.50 +
   30.51 +public class BasicSyntaxCombo extends Helper{
   30.52 +    static int errors = 0;
   30.53 +    static boolean exitMode = false;
   30.54 +    static String TESTPKG = "testpkg";
   30.55 +    static String srcContent = "";
   30.56 +    static String pkgInfoContent = "";
   30.57 +
   30.58 +    static {
   30.59 +        // If EXIT_ON_FAIL is set, the combo test will exit at the first error
   30.60 +        String exitOnFail = System.getenv("EXIT_ON_FAIL");
   30.61 +        if (exitOnFail == null || exitOnFail == ""  ) {
   30.62 +            exitMode = false;
   30.63 +        }
   30.64 +        else {
   30.65 +            if (exitOnFail.equalsIgnoreCase("YES") ||
   30.66 +                    exitOnFail.equalsIgnoreCase("Y") ||
   30.67 +                    exitOnFail.equalsIgnoreCase("TRUE") ||
   30.68 +                    exitOnFail.equalsIgnoreCase("T")) {
   30.69 +                exitMode = true;
   30.70 +            }
   30.71 +        }
   30.72 +    }
   30.73 +
   30.74 +    enum TestElem {
   30.75 +        ANNOTATION_TYPE(true),
   30.76 +        PACKAGE(true),
   30.77 +        CONSTRUCTOR(true),
   30.78 +        FIELD(true),
   30.79 +        LOCAL_VARIABLE(true),
   30.80 +        METHOD(true),
   30.81 +        TYPE(true),
   30.82 +        PARAMETER(true),
   30.83 +        INNER_CLASS(true),
   30.84 +        STATIC_INI(false),
   30.85 +        INSTANCE_INI(false);
   30.86 +
   30.87 +        TestElem(boolean compile) {
   30.88 +            this.compile = compile;
   30.89 +        }
   30.90 +
   30.91 +        boolean compile;
   30.92 +        boolean shouldCompile() {
   30.93 +            return compile;
   30.94 +        }
   30.95 +    }
   30.96 +
   30.97 +    public static void main(String[] args) throws Exception {
   30.98 +        new BasicSyntaxCombo().runTest();
   30.99 +    }
  30.100 +
  30.101 +    public void runTest() throws Exception {
  30.102 +        boolean result = false;
  30.103 +        Iterable<? extends JavaFileObject> files = null;
  30.104 +        int testCtr = 0;
  30.105 +        for (TestElem type : TestElem.values()) {
  30.106 +            testCtr++;
  30.107 +            String className = "BasicCombo_"+type;
  30.108 +            files = getFileList(className, type);
  30.109 +
  30.110 +            boolean shouldCompile = type.shouldCompile();
  30.111 +            result = getCompileResult(className, shouldCompile,files);
  30.112 +
  30.113 +            if (shouldCompile && !result) {
  30.114 +                error(className + " did not compile as expected", srcContent);
  30.115 +                if(!pkgInfoContent.isEmpty()) {
  30.116 +                    System.out.println("package-info.java contents: " + pkgInfoContent);
  30.117 +                }
  30.118 +            }
  30.119 +
  30.120 +            if (!shouldCompile && !result) {
  30.121 +                error(className + " compiled unexpectedly", srcContent);
  30.122 +                if(!pkgInfoContent.isEmpty()) {
  30.123 +                    System.out.println("package-info.java contents: " + pkgInfoContent);
  30.124 +                }
  30.125 +            }
  30.126 +        }
  30.127 +
  30.128 +        System.out.println("Total number of tests run: " + testCtr);
  30.129 +        System.out.println("Total number of errors: " + errors);
  30.130 +
  30.131 +        if (errors > 0)
  30.132 +            throw new Exception(errors + " errors found");
  30.133 +    }
  30.134 +
  30.135 +    private boolean getCompileResult(String className, boolean shouldCompile,
  30.136 +            Iterable<? extends JavaFileObject> files) throws Exception {
  30.137 +
  30.138 +        DiagnosticCollector<JavaFileObject> diagnostics =
  30.139 +                new DiagnosticCollector<JavaFileObject>();
  30.140 +        boolean ok =  Helper.compileCode(diagnostics,files);
  30.141 +        if (!shouldCompile && !ok) {
  30.142 +            checkErrorKeys(className, diagnostics);
  30.143 +        }
  30.144 +        return (shouldCompile == ok);
  30.145 +    }
  30.146 +
  30.147 +    private void checkErrorKeys (
  30.148 +            String className, DiagnosticCollector<JavaFileObject> diagnostics) throws Exception {
  30.149 +        String expectedErrKey = "compiler.err.illegal.start.of.type";
  30.150 +        for (Diagnostic<?> d : diagnostics.getDiagnostics()) {
  30.151 +            if ((d.getKind() == Diagnostic.Kind.ERROR) &&
  30.152 +                d.getCode().contains(expectedErrKey)) {
  30.153 +                break; // Found the expected error
  30.154 +            } else {
  30.155 +                error("Incorrect error key, expected = "
  30.156 +                      + expectedErrKey + ", Actual = " + d.getCode()
  30.157 +                      + " for className = " + className, srcContent);
  30.158 +            }
  30.159 +        }
  30.160 +    }
  30.161 +
  30.162 +    private Iterable<? extends JavaFileObject> getFileList(String className,
  30.163 +            TestElem type ) {
  30.164 +
  30.165 +        String template = Helper.template;
  30.166 +        String replaceStr = "/*"+type+"*/";
  30.167 +        StringBuilder annoData = new StringBuilder();
  30.168 +        annoData.append(Helper.ContentVars.IMPORTCONTAINERSTMTS.getVal())
  30.169 +                .append(Helper.ContentVars.CONTAINERFOR.getVal())
  30.170 +                .append(Helper.ContentVars.CONTAINER.getVal())
  30.171 +                .append(Helper.ContentVars.CONTAINEDBY.getVal())
  30.172 +                .append(Helper.ContentVars.BASE.getVal());
  30.173 +
  30.174 +        JavaFileObject pkgInfoFile = null;
  30.175 +
  30.176 +        if (type.equals("PACKAGE")) {
  30.177 +            srcContent = template.replace(replaceStr, "package testpkg;")
  30.178 +                        .replace("#ClassName", className);
  30.179 +
  30.180 +            String pkgInfoName = TESTPKG+"."+"package-info";
  30.181 +            pkgInfoContent = Helper.ContentVars.REPEATABLEANNO.getVal()
  30.182 +                             + "package " + TESTPKG + ";"
  30.183 +                             + annoData;
  30.184 +            pkgInfoFile = getFile(pkgInfoName, pkgInfoContent);
  30.185 +        } else {
  30.186 +            template = template.replace(replaceStr, Helper.ContentVars.REPEATABLEANNO.getVal())
  30.187 +                       .replace("#ClassName", className);
  30.188 +            srcContent = annoData + template;
  30.189 +        }
  30.190 +
  30.191 +        JavaFileObject srcFile = getFile(className, srcContent);
  30.192 +
  30.193 +        Iterable<? extends JavaFileObject> files = null;
  30.194 +        if (pkgInfoFile != null) {
  30.195 +            files = Arrays.asList(pkgInfoFile,srcFile);
  30.196 +        }
  30.197 +        else {
  30.198 +            files = Arrays.asList(srcFile);
  30.199 +        }
  30.200 +        return files;
  30.201 +    }
  30.202 +
  30.203 +    private void error(String msg, String... contents) throws Exception {
  30.204 +        System.out.println("error: " + msg);
  30.205 +        errors++;
  30.206 +        if (contents.length == 1) {
  30.207 +            System.out.println("Contents = " + contents[0]);
  30.208 +        }
  30.209 +        // Test exits as soon as it gets a failure
  30.210 +        if (exitMode) throw new Exception();
  30.211 +    }
  30.212 +}
    31.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    31.2 +++ b/test/tools/javac/annotations/repeatingAnnotations/combo/DeprecatedAnnoCombo.java	Fri Nov 09 14:47:22 2012 -0800
    31.3 @@ -0,0 +1,155 @@
    31.4 +/*
    31.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    31.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    31.7 + *
    31.8 + * This code is free software; you can redistribute it and/or modify it
    31.9 + * under the terms of the GNU General Public License version 2 only, as
   31.10 + * published by the Free Software Foundation.
   31.11 + *
   31.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   31.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   31.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   31.15 + * version 2 for more details (a copy is included in the LICENSE file that
   31.16 + * accompanied this code).
   31.17 + *
   31.18 + * You should have received a copy of the GNU General Public License version
   31.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   31.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   31.21 + *
   31.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   31.23 + * or visit www.oracle.com if you need additional information or have any
   31.24 + * questions.
   31.25 + */
   31.26 +
   31.27 +/**
   31.28 + * @test
   31.29 + * @bug      8002157
   31.30 + * @author   sogoel
   31.31 + * @summary  Combo test to check for usage of Deprecated
   31.32 + * @build    Helper
   31.33 + * @compile  DeprecatedAnnoCombo.java
   31.34 + * @run main DeprecatedAnnoCombo
   31.35 + */
   31.36 +
   31.37 +import java.util.List;
   31.38 +import javax.tools.Diagnostic;
   31.39 +import javax.tools.DiagnosticCollector;
   31.40 +import javax.tools.JavaFileObject;
   31.41 +
   31.42 +/*
   31.43 + * Generate test src for use of @Deprecated on base anno
   31.44 + * or container anno or on both. In all cases, test src should compile and a
   31.45 + * warning should be generated. Repeating annotations used only on class for
   31.46 + * these generated test src.
   31.47 + */
   31.48 +
   31.49 +public class DeprecatedAnnoCombo extends Helper {
   31.50 +    static int errors = 0;
   31.51 +
   31.52 +    enum TestCases {
   31.53 +        DeprecatedonBoth,
   31.54 +        DeprecatedonContainer,
   31.55 +        DeprecatedonBase;
   31.56 +    }
   31.57 +
   31.58 +    public static void main(String[] args) throws Exception {
   31.59 +        new DeprecatedAnnoCombo().runTest();
   31.60 +    }
   31.61 +
   31.62 +    public void runTest() throws Exception {
   31.63 +        boolean ok = false;
   31.64 +        int testCtr = 0;
   31.65 +
   31.66 +        for (TestCases clName : TestCases.values()) {
   31.67 +            testCtr++;
   31.68 +
   31.69 +            // Create test source content
   31.70 +            String contents = getContent(clName.toString());
   31.71 +
   31.72 +            // Compile the generated source file
   31.73 +            DiagnosticCollector<JavaFileObject> diagnostics =
   31.74 +                    new DiagnosticCollector<JavaFileObject>();
   31.75 +            ok = compileCode(clName.toString(), contents, diagnostics);
   31.76 +
   31.77 +            String errorKey1 = "compiler.note.deprecated.filename";
   31.78 +            String errorKey2 = "compiler.note.deprecated.recompile";
   31.79 +            List<Diagnostic<? extends JavaFileObject>> diags = diagnostics.getDiagnostics();
   31.80 +
   31.81 +            //Check for deprecated warnings
   31.82 +            if (ok) {
   31.83 +                if (diags.size() == 0) {
   31.84 +                    error("Did not get any warnings for @Deprecated usage");
   31.85 +                } else {
   31.86 +                    for (Diagnostic<?> d : diags) {
   31.87 +                        if (d.getKind() == Diagnostic.Kind.NOTE) {
   31.88 +                            if (d.getCode().contains(errorKey1)
   31.89 +                                || d.getCode().contains(errorKey2)) {
   31.90 +                                System.out.println("TestCase =" + clName + " passed as expected");
   31.91 +                            } else {
   31.92 +                                error("TestCase =" + clName + " did not give correct warnings" +
   31.93 +                                    "Expected warning keys: " +
   31.94 +                                    "errorKey1 = " + errorKey1 +
   31.95 +                                    "errorKey2 = " + errorKey2 +
   31.96 +                                    "actualErrorKey = " + d.getCode(), contents);
   31.97 +                            }
   31.98 +                        } else {
   31.99 +                            error("Diagnostic Kind is incorrect, expected = " +
  31.100 +                                 Diagnostic.Kind.NOTE + "actual = " + d.getKind(), contents);
  31.101 +                        }
  31.102 +                    }
  31.103 +                }
  31.104 +            } else {
  31.105 +                error("TestCase =" + clName + " did not compile as expected", contents);
  31.106 +            }
  31.107 +        }
  31.108 +
  31.109 +        System.out.println("Total number of tests run: " + testCtr);
  31.110 +        System.out.println("Total number of errors: " + errors);
  31.111 +        if (errors > 0)
  31.112 +            throw new Exception(errors + " errors found");
  31.113 +    }
  31.114 +
  31.115 +    private String getContent(String className) {
  31.116 +        StringBuilder annoData = new StringBuilder();
  31.117 +
  31.118 +        switch(className) {
  31.119 +        case "DeprecatedonBoth":
  31.120 +            annoData.append(Helper.ContentVars.DEPRECATED.getVal())
  31.121 +                    .append(Helper.ContentVars.CONTAINERFOR.getVal())
  31.122 +                    .append(Helper.ContentVars.CONTAINER.getVal())
  31.123 +                    .append(Helper.ContentVars.DEPRECATED.getVal())
  31.124 +                    .append(Helper.ContentVars.CONTAINEDBY.getVal())
  31.125 +                    .append(Helper.ContentVars.BASE.getVal());
  31.126 +            break;
  31.127 +        case "DeprecatedonBase":
  31.128 +            annoData.append(Helper.ContentVars.CONTAINERFOR.getVal())
  31.129 +                    .append(Helper.ContentVars.CONTAINER.getVal())
  31.130 +                    .append(Helper.ContentVars.DEPRECATED.getVal())
  31.131 +                    .append(Helper.ContentVars.CONTAINEDBY.getVal())
  31.132 +                    .append(Helper.ContentVars.BASE.getVal());
  31.133 +            break;
  31.134 +        case "DeprecatedonContainer":
  31.135 +            annoData.append(Helper.ContentVars.DEPRECATED.getVal())
  31.136 +                    .append(Helper.ContentVars.CONTAINERFOR.getVal())
  31.137 +                    .append(Helper.ContentVars.CONTAINER.getVal())
  31.138 +                    .append(Helper.ContentVars.CONTAINEDBY.getVal())
  31.139 +                    .append(Helper.ContentVars.BASE.getVal());
  31.140 +            break;
  31.141 +        }
  31.142 +
  31.143 +        String contents = Helper.ContentVars.IMPORTCONTAINERSTMTS.getVal()
  31.144 +                          + Helper.ContentVars.IMPORTDEPRECATED.getVal()
  31.145 +                          + annoData
  31.146 +                          + Helper.ContentVars.REPEATABLEANNO.getVal()
  31.147 +                          + "\nclass "+ className + "{}";
  31.148 +        return contents;
  31.149 +    }
  31.150 +
  31.151 +    private void error(String msg, String... contents) {
  31.152 +        System.out.println("error: " + msg);
  31.153 +        errors++;
  31.154 +        if (contents.length == 1) {
  31.155 +            System.out.println("Contents = " + contents[0]);
  31.156 +        }
  31.157 +    }
  31.158 +}
    32.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    32.2 +++ b/test/tools/javac/annotations/repeatingAnnotations/combo/DocumentedAnnoCombo.java	Fri Nov 09 14:47:22 2012 -0800
    32.3 @@ -0,0 +1,127 @@
    32.4 +/*
    32.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    32.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    32.7 + *
    32.8 + * This code is free software; you can redistribute it and/or modify it
    32.9 + * under the terms of the GNU General Public License version 2 only, as
   32.10 + * published by the Free Software Foundation.
   32.11 + *
   32.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   32.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   32.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   32.15 + * version 2 for more details (a copy is included in the LICENSE file that
   32.16 + * accompanied this code).
   32.17 + *
   32.18 + * You should have received a copy of the GNU General Public License version
   32.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   32.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   32.21 + *
   32.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   32.23 + * or visit www.oracle.com if you need additional information or have any
   32.24 + * questions.
   32.25 + */
   32.26 +
   32.27 +/**
   32.28 + * @test
   32.29 + * @bug      8002157
   32.30 + * @author   sogoel
   32.31 + * @summary  Positive combo test for use of Documented on baseAnno/containerAnno
   32.32 + * @build    Helper
   32.33 + * @compile  DocumentedAnnoCombo.java
   32.34 + * @run main DocumentedAnnoCombo
   32.35 + */
   32.36 +
   32.37 +import javax.tools.DiagnosticCollector;
   32.38 +import javax.tools.JavaFileObject;
   32.39 +
   32.40 +/*
   32.41 + * Generate valid test src for the use of @Documented on container anno
   32.42 + * or on both base anno and container anno. Both test src should compile.
   32.43 + * Repeating annotations used only on class for these generated test src.
   32.44 + */
   32.45 +public class DocumentedAnnoCombo extends Helper {
   32.46 +    static int errors = 0;
   32.47 +
   32.48 +    enum TestCases {
   32.49 +        DocumentedonBothAnno(true),
   32.50 +        DocumentedonContainer(true);
   32.51 +
   32.52 +        TestCases(boolean compile) {
   32.53 +            this.compile = compile;
   32.54 +        }
   32.55 +
   32.56 +        boolean compile;
   32.57 +        boolean shouldCompile() {
   32.58 +            return compile;
   32.59 +        }
   32.60 +    }
   32.61 +
   32.62 +    public static void main(String[] args) throws Exception {
   32.63 +        new DocumentedAnnoCombo().runTest();
   32.64 +    }
   32.65 +
   32.66 +    public void runTest() throws Exception {
   32.67 +        boolean ok = false;
   32.68 +        int testCtr = 0;
   32.69 +
   32.70 +        // Create test source content
   32.71 +        for (TestCases className : TestCases.values()) {
   32.72 +            testCtr++;
   32.73 +            String contents = getContent(className.toString());
   32.74 +
   32.75 +            // Compile the generated source file
   32.76 +            DiagnosticCollector<JavaFileObject> diagnostics =
   32.77 +                    new DiagnosticCollector<JavaFileObject>();
   32.78 +            ok = compileCode(className.toString(), contents, diagnostics);
   32.79 +            if (!ok) {
   32.80 +                error("Class="+ className +" did not compile as expected", contents);
   32.81 +            } else {
   32.82 +                System.out.println("Test passed for className: " + className);
   32.83 +            }
   32.84 +        }
   32.85 +
   32.86 +        System.out.println("Total number of tests run: " + testCtr);
   32.87 +        System.out.println("Total number of errors: " + errors);
   32.88 +
   32.89 +        if (errors > 0)
   32.90 +            throw new Exception(errors + " errors found");
   32.91 +    }
   32.92 +
   32.93 +    private String getContent(String className) {
   32.94 +
   32.95 +        StringBuilder annoData = new StringBuilder();
   32.96 +        switch(className) {
   32.97 +            case "DocumentedonBothAnno":
   32.98 +                annoData.append(Helper.ContentVars.DOCUMENTED.getVal())
   32.99 +                .append(Helper.ContentVars.CONTAINERFOR.getVal())
  32.100 +                .append(Helper.ContentVars.CONTAINER.getVal())
  32.101 +                .append(Helper.ContentVars.DOCUMENTED.getVal())
  32.102 +                .append(Helper.ContentVars.CONTAINEDBY.getVal())
  32.103 +                .append(Helper.ContentVars.BASE.getVal());
  32.104 +            break;
  32.105 +            case "DocumentedonContainer":
  32.106 +                annoData.append(Helper.ContentVars.DOCUMENTED.getVal())
  32.107 +                .append(Helper.ContentVars.CONTAINERFOR.getVal())
  32.108 +                .append(Helper.ContentVars.CONTAINER.getVal())
  32.109 +                .append(Helper.ContentVars.CONTAINEDBY.getVal())
  32.110 +                .append(Helper.ContentVars.BASE.getVal());
  32.111 +            break;
  32.112 +        }
  32.113 +
  32.114 +        String contents = Helper.ContentVars.IMPORTCONTAINERSTMTS.getVal()
  32.115 +                          + Helper.ContentVars.IMPORTDOCUMENTED.getVal()
  32.116 +                          + annoData
  32.117 +                          + Helper.ContentVars.REPEATABLEANNO.getVal()
  32.118 +                          + "\nclass "+ className + "{}";
  32.119 +        return contents;
  32.120 +    }
  32.121 +
  32.122 +    private void error(String msg, String... contents) {
  32.123 +        System.out.println("error: " + msg);
  32.124 +        errors++;
  32.125 +        if (contents.length == 1) {
  32.126 +            System.out.println("Contents = " + contents[0]);
  32.127 +        }
  32.128 +    }
  32.129 +}
  32.130 +
    33.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    33.2 +++ b/test/tools/javac/annotations/repeatingAnnotations/combo/Helper.java	Fri Nov 09 14:47:22 2012 -0800
    33.3 @@ -0,0 +1,154 @@
    33.4 +/*
    33.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    33.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    33.7 + *
    33.8 + * This code is free software; you can redistribute it and/or modify it
    33.9 + * under the terms of the GNU General Public License version 2 only, as
   33.10 + * published by the Free Software Foundation.
   33.11 + *
   33.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   33.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   33.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   33.15 + * version 2 for more details (a copy is included in the LICENSE file that
   33.16 + * accompanied this code).
   33.17 + *
   33.18 + * You should have received a copy of the GNU General Public License version
   33.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   33.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   33.21 + *
   33.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   33.23 + * or visit www.oracle.com if you need additional information or have any
   33.24 + * questions.
   33.25 + */
   33.26 +
   33.27 +import java.net.URI;
   33.28 +import java.net.URISyntaxException;
   33.29 +import java.util.Arrays;
   33.30 +import javax.tools.DiagnosticCollector;
   33.31 +import javax.tools.JavaCompiler;
   33.32 +import javax.tools.JavaFileObject;
   33.33 +import javax.tools.SimpleJavaFileObject;
   33.34 +import javax.tools.ToolProvider;
   33.35 +import javax.tools.JavaCompiler.CompilationTask;
   33.36 +
   33.37 +public class Helper {
   33.38 +
   33.39 +    enum ContentVars {
   33.40 +        IMPORTCONTAINERSTMTS("\nimport java.lang.annotation.ContainedBy;\n" +
   33.41 +                            "\nimport java.lang.annotation.ContainerFor;\n"),
   33.42 +        IMPORTDEPRECATED("import java.lang.Deprecated;\n"),
   33.43 +        IMPORTDOCUMENTED("import java.lang.annotation.Documented;\n"),
   33.44 +        IMPORTINHERITED("import java.lang.annotation.Inherited;\n"),
   33.45 +        IMPORTRETENTION("import java.lang.annotation.Retention;\n" +
   33.46 +                        "\nimport java.lang.annotation.RetentionPolicy;\n"),
   33.47 +        CONTAINEDBY("\n@ContainedBy(FooContainer.class)\n"),
   33.48 +        CONTAINERFOR("@ContainerFor(Foo.class)\n"),
   33.49 +        CONTAINER("@interface FooContainer {\n" +"  Foo[] value();\n}\n"),
   33.50 +        BASE("@interface Foo {}\n"),
   33.51 +        REPEATABLEANNO("\n@Foo() @Foo()"),
   33.52 +        DEPRECATED("\n@Deprecated"),
   33.53 +        DOCUMENTED("\n@Documented"),
   33.54 +        INHERITED("\n@Inherited"),
   33.55 +        RETENTION("@Retention(RetentionPolicy.#VAL)\n");
   33.56 +
   33.57 +        private String val;
   33.58 +
   33.59 +
   33.60 +        private ContentVars(String val) {
   33.61 +            this.val = val;
   33.62 +        }
   33.63 +
   33.64 +        public String getVal() {
   33.65 +            return val;
   33.66 +        }
   33.67 +    }
   33.68 +
   33.69 +    /* String template where /*<TYPE>*/ /*gets replaced by repeating anno
   33.70 +     * Used to generate test src for combo tests
   33.71 +     *   - BasicSyntaxCombo.java
   33.72 +     *   - TargetAnnoCombo.java
   33.73 +     */
   33.74 +    public static final String template =
   33.75 +            "/*PACKAGE*/\n" +
   33.76 +            "//pkg test;\n\n" +
   33.77 +            "/*TYPE*/ //class\n" +
   33.78 +            "class #ClassName {\n" +
   33.79 +            "  /*FIELD*/ //instance var\n" +
   33.80 +            "  public int x = 0;\n\n" +
   33.81 +            "  /*FIELD*/ //Enum constants\n" +
   33.82 +            "  TestEnum testEnum;\n\n" +
   33.83 +            "  /*FIELD*/ // Static field\n" +
   33.84 +            "  public static int num;\n\n" +
   33.85 +            "  /*STATIC_INI*/\n" +
   33.86 +            "  static { \n" + "num = 10; \n  }\n\n" +
   33.87 +            "  /*CONSTRUCTOR*/\n" +
   33.88 +            "  #ClassName() {}\n\n" +
   33.89 +            "  /*INSTANCE_INI*/\n" +
   33.90 +            "  { \n x = 10; \n }" +
   33.91 +            "  /*INNER_CLASS*/\n" +
   33.92 +            "  class innerClass {}\n" +
   33.93 +            "  /*METHOD*/\n" +
   33.94 +            "  void bar(/*PARAMETER*/ int baz) {\n" +
   33.95 +            "    /*LOCAL_VARIABLE*/\n" +
   33.96 +            "    int y = 0;\n" +
   33.97 +            "  }\n" +
   33.98 +            "}\n\n" +
   33.99 +            "/*TYPE*/ //Enum\n" +
  33.100 +            "enum TestEnum {}\n\n" +
  33.101 +            "/*TYPE*/ //Interface\n" +
  33.102 +            "interface TestInterface {}\n\n" +
  33.103 +            "/*TYPE*/\n" +
  33.104 +            "/*ANNOTATION_TYPE*/\n" +
  33.105 +            "@interface TestAnnotationType{}\n";
  33.106 +
  33.107 +    // Create and compile FileObject using values for className and contents
  33.108 +    public static boolean compileCode(String className, String contents,
  33.109 +            DiagnosticCollector<JavaFileObject> diagnostics) {
  33.110 +        boolean ok = false;
  33.111 +        JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
  33.112 +        if (compiler == null) {
  33.113 +            throw new RuntimeException("can't get javax.tools.JavaCompiler!");
  33.114 +        }
  33.115 +
  33.116 +        JavaFileObject file = getFile(className, contents);
  33.117 +        Iterable<? extends JavaFileObject> compilationUnit = Arrays.asList(file);
  33.118 +
  33.119 +        CompilationTask task = compiler.getTask(null, null, diagnostics, null, null, compilationUnit);
  33.120 +        ok = task.call();
  33.121 +        return ok;
  33.122 +
  33.123 +    }
  33.124 +
  33.125 +    // Compile a list of FileObjects
  33.126 +    public static boolean compileCode(DiagnosticCollector<JavaFileObject> diagnostics, Iterable<? extends JavaFileObject> files) {
  33.127 +        JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
  33.128 +        if (compiler == null) {
  33.129 +            throw new RuntimeException("can't get javax.tools.JavaCompiler!");
  33.130 +        }
  33.131 +
  33.132 +        CompilationTask task = compiler.getTask(null, null, diagnostics, null, null, files);
  33.133 +        boolean ok = task.call();
  33.134 +        return ok;
  33.135 +    }
  33.136 +
  33.137 +    static JavaFileObject getFile(String name, String code) {
  33.138 +        JavaFileObject o = null;
  33.139 +        try {
  33.140 +            o = new JavaStringFileObject(name, code);
  33.141 +        } catch (URISyntaxException e) {
  33.142 +            throw new RuntimeException(e);
  33.143 +        }
  33.144 +        return o;
  33.145 +    }
  33.146 +    static class JavaStringFileObject extends SimpleJavaFileObject {
  33.147 +        final String theCode;
  33.148 +        public JavaStringFileObject(String fileName, String theCode) throws URISyntaxException {
  33.149 +            super(new URI("string:///" + fileName.replace('.','/') + ".java"), Kind.SOURCE);
  33.150 +            this.theCode = theCode;
  33.151 +        }
  33.152 +        @Override
  33.153 +        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
  33.154 +            return theCode;
  33.155 +        }
  33.156 +    }
  33.157 +}
    34.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    34.2 +++ b/test/tools/javac/annotations/repeatingAnnotations/combo/InheritedAnnoCombo.java	Fri Nov 09 14:47:22 2012 -0800
    34.3 @@ -0,0 +1,128 @@
    34.4 +/*
    34.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    34.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    34.7 + *
    34.8 + * This code is free software; you can redistribute it and/or modify it
    34.9 + * under the terms of the GNU General Public License version 2 only, as
   34.10 + * published by the Free Software Foundation.
   34.11 + *
   34.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   34.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   34.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   34.15 + * version 2 for more details (a copy is included in the LICENSE file that
   34.16 + * accompanied this code).
   34.17 + *
   34.18 + * You should have received a copy of the GNU General Public License version
   34.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   34.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   34.21 + *
   34.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   34.23 + * or visit www.oracle.com if you need additional information or have any
   34.24 + * questions.
   34.25 + */
   34.26 +
   34.27 +/**
   34.28 + * @test
   34.29 + * @bug      8002157
   34.30 + * @author   sogoel
   34.31 + * @summary  Positive combo test for use of Inherited on baseAnno/containerAnno
   34.32 + * @build    Helper
   34.33 + * @compile  InheritedAnnoCombo.java
   34.34 + * @run main InheritedAnnoCombo
   34.35 + */
   34.36 +
   34.37 +import javax.tools.DiagnosticCollector;
   34.38 +import javax.tools.JavaFileObject;
   34.39 +
   34.40 +/*
   34.41 + * Generate valid test src for the use of @Inherited on container anno
   34.42 + * or on both base anno and container anno. Both test src should compile.
   34.43 + * Repeating annotations used only on class for these generated test src.
   34.44 + */
   34.45 +
   34.46 +public class InheritedAnnoCombo extends Helper {
   34.47 +    static int errors = 0;
   34.48 +    enum TestCases {
   34.49 +        InheritedonBothAnno(true),
   34.50 +        InheritedonBase(true);
   34.51 +
   34.52 +        TestCases(boolean compile) {
   34.53 +            this.compile = compile;
   34.54 +        }
   34.55 +
   34.56 +        boolean compile;
   34.57 +        boolean shouldCompile() {
   34.58 +            return compile;
   34.59 +        }
   34.60 +    }
   34.61 +
   34.62 +    public static void main(String[] args) throws Exception {
   34.63 +        new InheritedAnnoCombo().runTest();
   34.64 +    }
   34.65 +
   34.66 +    public void runTest() throws Exception {
   34.67 +        int testCtr = 0;
   34.68 +        boolean ok = false;
   34.69 +
   34.70 +        // Create test source content
   34.71 +        for (TestCases className : TestCases.values()) {
   34.72 +            testCtr++;
   34.73 +            String contents = getContent(className.toString());
   34.74 +
   34.75 +            // Compile the generated code
   34.76 +            DiagnosticCollector<JavaFileObject> diagnostics =
   34.77 +                    new DiagnosticCollector<JavaFileObject>();
   34.78 +            ok = compileCode(className.toString(), contents, diagnostics);
   34.79 +
   34.80 +            if (!ok) {
   34.81 +                error("Class="+ className +" did not compile as expected", contents);
   34.82 +            } else {
   34.83 +                System.out.println("Test passed for className: " + className);
   34.84 +            }
   34.85 +        }
   34.86 +
   34.87 +        System.out.println("Total number of tests run: " + testCtr);
   34.88 +        System.out.println("Total number of errors: " + errors);
   34.89 +
   34.90 +        if (errors > 0)
   34.91 +            throw new Exception(errors + " errors found");
   34.92 +    }
   34.93 +
   34.94 +    private String getContent(String className) {
   34.95 +
   34.96 +        StringBuilder annoData = new StringBuilder();
   34.97 +        switch(className) {
   34.98 +        case "InheritedonBothAnno":
   34.99 +            annoData.append(Helper.ContentVars.INHERITED.getVal())
  34.100 +            .append(Helper.ContentVars.CONTAINERFOR.getVal())
  34.101 +            .append(Helper.ContentVars.CONTAINER.getVal())
  34.102 +            .append(Helper.ContentVars.INHERITED.getVal())
  34.103 +            .append(Helper.ContentVars.CONTAINEDBY.getVal())
  34.104 +            .append(Helper.ContentVars.BASE.getVal());
  34.105 +            break;
  34.106 +        case "InheritedonBase":
  34.107 +            annoData.append(Helper.ContentVars.INHERITED.getVal())
  34.108 +            .append(Helper.ContentVars.CONTAINERFOR.getVal())
  34.109 +            .append(Helper.ContentVars.CONTAINER.getVal())
  34.110 +            .append(Helper.ContentVars.CONTAINEDBY.getVal())
  34.111 +            .append(Helper.ContentVars.BASE.getVal());
  34.112 +            break;
  34.113 +        }
  34.114 +
  34.115 +        String contents = Helper.ContentVars.IMPORTCONTAINERSTMTS.getVal()
  34.116 +                          + Helper.ContentVars.IMPORTINHERITED.getVal()
  34.117 +                          + annoData
  34.118 +                          + Helper.ContentVars.REPEATABLEANNO.getVal()
  34.119 +                          + "\nclass "+ className + "{}";
  34.120 +        return contents;
  34.121 +    }
  34.122 +
  34.123 +    private void error(String msg, String... contents) {
  34.124 +        System.out.println("error: " + msg);
  34.125 +        errors++;
  34.126 +        if (contents.length == 1) {
  34.127 +            System.out.println("Contents = " + contents[0]);
  34.128 +        }
  34.129 +    }
  34.130 +}
  34.131 +
    35.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    35.2 +++ b/test/tools/javac/annotations/repeatingAnnotations/combo/RetentionAnnoCombo.java	Fri Nov 09 14:47:22 2012 -0800
    35.3 @@ -0,0 +1,201 @@
    35.4 +/*
    35.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    35.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    35.7 + *
    35.8 + * This code is free software; you can redistribute it and/or modify it
    35.9 + * under the terms of the GNU General Public License version 2 only, as
   35.10 + * published by the Free Software Foundation.
   35.11 + *
   35.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   35.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   35.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   35.15 + * version 2 for more details (a copy is included in the LICENSE file that
   35.16 + * accompanied this code).
   35.17 + *
   35.18 + * You should have received a copy of the GNU General Public License version
   35.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   35.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   35.21 + *
   35.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   35.23 + * or visit www.oracle.com if you need additional information or have any
   35.24 + * questions.
   35.25 + */
   35.26 +
   35.27 +/**
   35.28 + * @test
   35.29 + * @bug      8002157
   35.30 + * @author   sogoel
   35.31 + * @summary  Combo test for all possible combinations for Retention Values
   35.32 + * @build    Helper
   35.33 + * @compile  RetentionAnnoCombo.java
   35.34 + * @run main RetentionAnnoCombo
   35.35 + */
   35.36 +
   35.37 +import java.util.HashMap;
   35.38 +import java.util.Map;
   35.39 +
   35.40 +import javax.tools.DiagnosticCollector;
   35.41 +import javax.tools.JavaFileObject;
   35.42 +import javax.tools.Diagnostic;
   35.43 +
   35.44 +/*
   35.45 + * Generate all combinations for the use of @Retention on base anno or container
   35.46 + * anno or both. The test passes if valid test src compile as expected and
   35.47 + * and invalid test src fail as expected.
   35.48 + * Repeating annotations used only on class for these generated test src.
   35.49 + */
   35.50 +
   35.51 +public class RetentionAnnoCombo extends Helper {
   35.52 +    static int errors = 0;
   35.53 +    static boolean exitMode = false;
   35.54 +    static {
   35.55 +        String exitOnFail = System.getenv("EXIT_ON_FAIL");
   35.56 +        if (exitOnFail == null || exitOnFail == ""  ) {
   35.57 +            exitMode = false;
   35.58 +        }
   35.59 +        else {
   35.60 +            if (exitOnFail.equalsIgnoreCase("YES") ||
   35.61 +                    exitOnFail.equalsIgnoreCase("Y") ||
   35.62 +                    exitOnFail.equalsIgnoreCase("TRUE") ||
   35.63 +                    exitOnFail.equalsIgnoreCase("T")) {
   35.64 +                exitMode = true;
   35.65 +            }
   35.66 +        }
   35.67 +    }
   35.68 +
   35.69 +    public static void main(String args[]) throws Exception {
   35.70 +        new RetentionAnnoCombo().runTest();
   35.71 +    }
   35.72 +
   35.73 +    public void runTest() throws Exception {
   35.74 +
   35.75 +        /* 4x4 matrix for Retention values SOURCE, DEFAULT, CLASS, RUNTIME
   35.76 +         * i -> Retention value on ContainerAnno
   35.77 +         * j -> Retention value on BaseAnno
   35.78 +         * 1 -> retention value combo should compile
   35.79 +         */
   35.80 +        int[][] retention = { {1, 0, 0, 0},
   35.81 +                              {1, 1, 1, 0},
   35.82 +                              {1, 1, 1, 0},
   35.83 +                              {1, 1, 1, 1} };
   35.84 +
   35.85 +        Map<Integer, String> retMap = setRetentionValMatrix();
   35.86 +        String contents = "";
   35.87 +        boolean result = false;
   35.88 +        int testCtr = 0;
   35.89 +        for (int i = 0; i < 4 ; i ++) {
   35.90 +            for (int j = 0; j < 4; j++ ) {
   35.91 +                testCtr++;
   35.92 +                String className = "RetentionTest_"+i+"_"+j;
   35.93 +                contents = getContent(className, retMap, i, j);
   35.94 +                if (retention[i][j] == 1) {
   35.95 +                    // Code generated should compile
   35.96 +                    result = getCompileResult(contents,className, true);
   35.97 +                    if (!result) {
   35.98 +                        error("FAIL: " +  className + " did not compile as expected!", contents);
   35.99 +                    }
  35.100 +                } else {
  35.101 +                    result = getCompileResult(contents,className, false);
  35.102 +                    if (!result) {
  35.103 +                        error("FAIL: " +  className + " compiled unexpectedly!", contents);
  35.104 +                    }
  35.105 +                }
  35.106 +                if (result) {
  35.107 +                    System.out.println("Test passed for className = " + className);
  35.108 +                }
  35.109 +            }
  35.110 +        }
  35.111 +
  35.112 +        System.out.println("Total number of tests run: " + testCtr);
  35.113 +        System.out.println("Total number of errors: " + errors);
  35.114 +
  35.115 +        if (errors > 0)
  35.116 +            throw new Exception(errors + " errors found");
  35.117 +    }
  35.118 +
  35.119 +    private boolean getCompileResult(String contents, String className,
  35.120 +            boolean shouldCompile) throws Exception{
  35.121 +
  35.122 +        DiagnosticCollector<JavaFileObject> diagnostics =
  35.123 +                new DiagnosticCollector<JavaFileObject>();
  35.124 +        boolean ok = compileCode(className, contents, diagnostics);
  35.125 +
  35.126 +        String expectedErrKey = "compiler.err.invalid.containedby" +
  35.127 +                                        ".annotation.retention";
  35.128 +        if (!shouldCompile && !ok) {
  35.129 +            for (Diagnostic<?> d : diagnostics.getDiagnostics()) {
  35.130 +                if (!((d.getKind() == Diagnostic.Kind.ERROR) &&
  35.131 +                    d.getCode().contains(expectedErrKey))) {
  35.132 +                    error("FAIL: Incorrect error given, expected = "
  35.133 +                            + expectedErrKey + ", Actual = " + d.getCode()
  35.134 +                            + " for className = " + className, contents);
  35.135 +                }
  35.136 +            }
  35.137 +        }
  35.138 +
  35.139 +        return (shouldCompile  == ok);
  35.140 +    }
  35.141 +
  35.142 +    private Map<Integer,String> setRetentionValMatrix() {
  35.143 +        HashMap<Integer,String> hm = new HashMap<>();
  35.144 +        hm.put(0,"SOURCE");
  35.145 +        hm.put(1,"DEFAULT");
  35.146 +        hm.put(2,"CLASS");
  35.147 +        hm.put(3,"RUNTIME");
  35.148 +        return hm;
  35.149 +    }
  35.150 +
  35.151 +    private String getContent(String className, Map<Integer, String> retMap,
  35.152 +            int i, int j) {
  35.153 +
  35.154 +        String retContainerVal = retMap.get(i).toString();
  35.155 +        String retBaseVal = retMap.get(j).toString();
  35.156 +        String replacedRetBaseVal = "", replacedRetCAVal = "";
  35.157 +        String retention = Helper.ContentVars.RETENTION.getVal();
  35.158 +
  35.159 +        // @Retention is available as default for both base and container anno
  35.160 +        if (retContainerVal.equalsIgnoreCase("DEFAULT")
  35.161 +                && retBaseVal.equalsIgnoreCase("DEFAULT")) {
  35.162 +            replacedRetBaseVal = "";
  35.163 +            replacedRetCAVal = "";
  35.164 +        // @Retention is available as default for container anno
  35.165 +        } else if (retContainerVal.equalsIgnoreCase("DEFAULT")) {
  35.166 +            replacedRetBaseVal = retention.replace("#VAL", retBaseVal);
  35.167 +            replacedRetCAVal = "";
  35.168 +        // @Retention is available as default for base anno
  35.169 +        } else if (retBaseVal.equalsIgnoreCase("DEFAULT")) {
  35.170 +            replacedRetBaseVal = "";
  35.171 +            replacedRetCAVal = retention.replace("#VAL", retContainerVal);
  35.172 +        // @Retention is not available as default for both base and container anno
  35.173 +        } else {
  35.174 +            replacedRetBaseVal = retention.replace("#VAL", retBaseVal);
  35.175 +            replacedRetCAVal = retention.replace("#VAL", retContainerVal);
  35.176 +        }
  35.177 +
  35.178 +        StringBuilder annoData = new StringBuilder();
  35.179 +        annoData.append(Helper.ContentVars.IMPORTCONTAINERSTMTS.getVal())
  35.180 +                .append(Helper.ContentVars.IMPORTRETENTION.getVal())
  35.181 +                .append(Helper.ContentVars.CONTAINERFOR.getVal())
  35.182 +                .append(replacedRetCAVal)
  35.183 +                .append(Helper.ContentVars.CONTAINER.getVal())
  35.184 +                .append(Helper.ContentVars.CONTAINEDBY.getVal())
  35.185 +                .append(replacedRetBaseVal)
  35.186 +                .append(Helper.ContentVars.BASE.getVal());
  35.187 +
  35.188 +        String contents = annoData
  35.189 +                          + Helper.ContentVars.REPEATABLEANNO.getVal()
  35.190 +                          + "\nclass "+ className + "{}";
  35.191 +        return contents;
  35.192 +    }
  35.193 +
  35.194 +    private void error(String msg,String... contents) throws Exception {
  35.195 +        System.out.println("error: " + msg);
  35.196 +        errors++;
  35.197 +        if (contents.length == 1) {
  35.198 +            System.out.println("Contents = " + contents[0]);
  35.199 +        }
  35.200 +        // Test exits as soon as it gets a failure
  35.201 +        if (exitMode) throw new Exception();
  35.202 +    }
  35.203 +}
  35.204 +
    36.1 --- a/test/tools/javac/classfiles/ClassVersionChecker.java	Thu Nov 08 11:53:23 2012 -0800
    36.2 +++ b/test/tools/javac/classfiles/ClassVersionChecker.java	Fri Nov 09 14:47:22 2012 -0800
    36.3 @@ -23,7 +23,7 @@
    36.4  
    36.5  /*
    36.6   * @test
    36.7 - * @bug 7157626
    36.8 + * @bug 7157626 8001112
    36.9   * @summary Test major version for all legal combinations for -source and -target
   36.10   * @author sgoel
   36.11   *
   36.12 @@ -57,14 +57,14 @@
   36.13           * -1 => invalid combinations
   36.14           */
   36.15          int[][] ver =
   36.16 -                {{51, -1, -1, -1, -1, -1, -1, -1},
   36.17 -                 {48, 46, 47, 48, 49, 50, 51, 51},
   36.18 -                 {48, 46, 47, 48, 49, 50, 51, 51},
   36.19 -                 {48, -1, -1, 48, 49, 50, 51, 51},
   36.20 -                 {51, -1, -1, -1, 49, 50, 51, 51},
   36.21 -                 {51, -1, -1, -1, -1, 50, 51, 51},
   36.22 -                 {51, -1, -1, -1, -1, -1, 51, 51},
   36.23 -                 {51, -1, -1, -1, -1, -1, -1, 51}};
   36.24 +                {{52, -1, -1, -1, -1, -1, -1, -1},
   36.25 +                 {48, 46, 47, 48, 49, 50, 51, 52},
   36.26 +                 {48, 46, 47, 48, 49, 50, 51, 52},
   36.27 +                 {48, -1, -1, 48, 49, 50, 51, 52},
   36.28 +                 {52, -1, -1, -1, 49, 50, 51, 52},
   36.29 +                 {52, -1, -1, -1, -1, 50, 51, 52},
   36.30 +                 {52, -1, -1, -1, -1, -1, 51, 52},
   36.31 +                 {52, -1, -1, -1, -1, -1, -1, 52}};
   36.32  
   36.33          // Loop to run all possible combinations of source/target values
   36.34          for (int i = 0; i< ver.length; i++) {
    37.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    37.2 +++ b/test/tools/javac/defaultMethods/ClassReaderTest/ClassReaderTest.java	Fri Nov 09 14:47:22 2012 -0800
    37.3 @@ -0,0 +1,32 @@
    37.4 +/*
    37.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
    37.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    37.7 + *
    37.8 + * This code is free software; you can redistribute it and/or modify it
    37.9 + * under the terms of the GNU General Public License version 2 only, as
   37.10 + * published by the Free Software Foundation.
   37.11 + *
   37.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   37.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   37.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   37.15 + * version 2 for more details (a copy is included in the LICENSE file that
   37.16 + * accompanied this code).
   37.17 + *
   37.18 + * You should have received a copy of the GNU General Public License version
   37.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   37.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   37.21 + *
   37.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   37.23 + * or visit www.oracle.com if you need additional information or have any
   37.24 + * questions.
   37.25 + */
   37.26 +
   37.27 +/*
   37.28 + * @test
   37.29 + * @summary check that default methods don't cause ClassReader to complete classes recursively
   37.30 + * @author  Maurizio Cimadamore
   37.31 + * @compile -XDallowDefaultMethods pkg/Foo.java
   37.32 + * @compile ClassReaderTest.java
   37.33 + */
   37.34 +
   37.35 +abstract class ClassReaderTest implements pkg.Foo {}
    38.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    38.2 +++ b/test/tools/javac/defaultMethods/ClassReaderTest/pkg/Foo.java	Fri Nov 09 14:47:22 2012 -0800
    38.3 @@ -0,0 +1,34 @@
    38.4 +/*
    38.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
    38.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    38.7 + *
    38.8 + * This code is free software; you can redistribute it and/or modify it
    38.9 + * under the terms of the GNU General Public License version 2 only, as
   38.10 + * published by the Free Software Foundation.
   38.11 + *
   38.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   38.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   38.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   38.15 + * version 2 for more details (a copy is included in the LICENSE file that
   38.16 + * accompanied this code).
   38.17 + *
   38.18 + * You should have received a copy of the GNU General Public License version
   38.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   38.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   38.21 + *
   38.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   38.23 + * or visit www.oracle.com if you need additional information or have any
   38.24 + * questions.
   38.25 + */
   38.26 +
   38.27 +package pkg;
   38.28 +
   38.29 +public interface Foo  {
   38.30 +    default void m1() { Impl.m1(this); }
   38.31 +    default void m2() { Impl.m2(this); }
   38.32 +}
   38.33 +
   38.34 +class Impl {
   38.35 +    static void m1(Foo f) { }
   38.36 +    static void m2(Foo f) { }
   38.37 +}
    39.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    39.2 +++ b/test/tools/javac/defaultMethods/Neg01.java	Fri Nov 09 14:47:22 2012 -0800
    39.3 @@ -0,0 +1,18 @@
    39.4 +/*
    39.5 + * @test /nodynamiccopyright/
    39.6 + * @summary negative test for ambiguous defaults
    39.7 + * @compile/fail/ref=Neg01.out -XDallowDefaultMethods -XDrawDiagnostics Neg01.java
    39.8 + */
    39.9 +
   39.10 +class Neg01 {
   39.11 +    interface IA { default int m() { return Neg01.m1(this); } }
   39.12 +    interface IB { default int m() { return Neg01.m2(this); } }
   39.13 +
   39.14 +    static class A implements IA {}
   39.15 +    static class B implements IB {}
   39.16 +
   39.17 +    static class AB implements IA, IB {}
   39.18 +
   39.19 +    static int m1(IA a) { return 0; }
   39.20 +    static int m2(IB b) { return 0; }
   39.21 +}
    40.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    40.2 +++ b/test/tools/javac/defaultMethods/Neg01.out	Fri Nov 09 14:47:22 2012 -0800
    40.3 @@ -0,0 +1,2 @@
    40.4 +Neg01.java:14:12: compiler.err.types.incompatible.unrelated.defaults: kindname.class, Neg01.AB, m, , Neg01.IA, Neg01.IB
    40.5 +1 error
    41.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    41.2 +++ b/test/tools/javac/defaultMethods/Neg02.java	Fri Nov 09 14:47:22 2012 -0800
    41.3 @@ -0,0 +1,26 @@
    41.4 +/*
    41.5 + * @test /nodynamiccopyright/
    41.6 + * @summary check that ill-formed MI hierarchies do not compile
    41.7 + * @compile/fail/ref=Neg02.out -XDallowDefaultMethods -XDrawDiagnostics Neg02.java
    41.8 + */
    41.9 +
   41.10 +class Neg02 {
   41.11 +     interface A {
   41.12 +         default void m() { Neg02.impl(this); }
   41.13 +     }
   41.14 +
   41.15 +     interface B {
   41.16 +         default void m() { Neg02.impl(this); }
   41.17 +     }
   41.18 +
   41.19 +     static class X implements A, B { } //error
   41.20 +
   41.21 +     void test(X x) {
   41.22 +         x.m();
   41.23 +         ((A)x).m();
   41.24 +         ((B)x).m();
   41.25 +     }
   41.26 +
   41.27 +     static void impl(A a) { }
   41.28 +     static void impl(B b) { }
   41.29 +}
    42.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    42.2 +++ b/test/tools/javac/defaultMethods/Neg02.out	Fri Nov 09 14:47:22 2012 -0800
    42.3 @@ -0,0 +1,2 @@
    42.4 +Neg02.java:16:13: compiler.err.types.incompatible.unrelated.defaults: kindname.class, Neg02.X, m, , Neg02.A, Neg02.B
    42.5 +1 error
    43.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    43.2 +++ b/test/tools/javac/defaultMethods/Neg03.java	Fri Nov 09 14:47:22 2012 -0800
    43.3 @@ -0,0 +1,38 @@
    43.4 +/*
    43.5 + * @test /nodynamiccopyright/
    43.6 + * @summary check that re-abstraction works properly
    43.7 + * @compile/fail/ref=Neg03.out -XDallowDefaultMethods -XDrawDiagnostics Neg03.java
    43.8 + */
    43.9 +
   43.10 +class Neg03 {
   43.11 +    interface A {
   43.12 +        default void m() { Neg03.one(this); }
   43.13 +    }
   43.14 +
   43.15 +    interface B {
   43.16 +        default void m() { Neg03.two(this); }
   43.17 +    }
   43.18 +
   43.19 +    interface C extends A, B {
   43.20 +        default void m() { Neg03.one(this); }
   43.21 +    }
   43.22 +
   43.23 +    static class X implements C, A { } //ok - ignore extraneous remix of A
   43.24 +
   43.25 +    interface D extends A, B {
   43.26 +      void m();  // ok - m() is not reabstracted!
   43.27 +    }
   43.28 +
   43.29 +    static class Y implements D, A { } // invalid - abstract D.m()
   43.30 +
   43.31 +    interface E extends A {
   43.32 +        void m();  // reabstraction of m()
   43.33 +    }
   43.34 +
   43.35 +    static class W implements D, E { } // invalid - abstracts D.m()/E.m()
   43.36 +
   43.37 +    static class Z implements D, A, B { } // invalid - abstract D.m()
   43.38 +
   43.39 +    static void one(Object a) {  }
   43.40 +    static void two(Object a) {  }
   43.41 +}
    44.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    44.2 +++ b/test/tools/javac/defaultMethods/Neg03.out	Fri Nov 09 14:47:22 2012 -0800
    44.3 @@ -0,0 +1,4 @@
    44.4 +Neg03.java:26:12: compiler.err.does.not.override.abstract: Neg03.Y, m(), Neg03.D
    44.5 +Neg03.java:32:12: compiler.err.does.not.override.abstract: Neg03.W, m(), Neg03.D
    44.6 +Neg03.java:34:12: compiler.err.does.not.override.abstract: Neg03.Z, m(), Neg03.D
    44.7 +3 errors
    45.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    45.2 +++ b/test/tools/javac/defaultMethods/Neg04.java	Fri Nov 09 14:47:22 2012 -0800
    45.3 @@ -0,0 +1,14 @@
    45.4 +/*
    45.5 + * @test /nodynamiccopyright/
    45.6 + * @summary check that default method must have most specific return type
    45.7 + * @compile/fail/ref=Neg04.out -XDallowDefaultMethods -XDrawDiagnostics Neg04.java
    45.8 + */
    45.9 +
   45.10 +class Neg04 {
   45.11 +    interface IA1 { Integer m(); }
   45.12 +    interface IA2 extends IA1 { default Number m() { return Neg04.m(this); } } //error
   45.13 +
   45.14 +    abstract class C implements IA1, IA2 {}
   45.15 +
   45.16 +    static int m(IA2 a) { return 0; }
   45.17 +}
    46.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    46.2 +++ b/test/tools/javac/defaultMethods/Neg04.out	Fri Nov 09 14:47:22 2012 -0800
    46.3 @@ -0,0 +1,2 @@
    46.4 +Neg04.java:9:48: compiler.err.override.incompatible.ret: (compiler.misc.clashes.with: m(), Neg04.IA2, m(), Neg04.IA1), java.lang.Number, java.lang.Integer
    46.5 +1 error
    47.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    47.2 +++ b/test/tools/javac/defaultMethods/Neg05.java	Fri Nov 09 14:47:22 2012 -0800
    47.3 @@ -0,0 +1,16 @@
    47.4 +/*
    47.5 + * @test /nodynamiccopyright/
    47.6 + * @summary check that abstract methods are compatible with inherited defaults
    47.7 + * @compile/fail/ref=Neg05.out -XDallowDefaultMethods -XDrawDiagnostics Neg05.java
    47.8 + */
    47.9 +
   47.10 +class Neg05 {
   47.11 +    interface IA1 { default Number m() { return Neg05.m1(this); } }
   47.12 +    interface IA2 extends IA1 { default Integer m() { return Neg05.m2(this); } }
   47.13 +    interface IA3 extends IA2 { Number m(); } //error
   47.14 +
   47.15 +    static class C implements IA3{}
   47.16 +
   47.17 +    static int m1(IA1 a) { return 0; }
   47.18 +    static int m2(IA2 b) { return 0; }
   47.19 +}
    48.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    48.2 +++ b/test/tools/javac/defaultMethods/Neg05.out	Fri Nov 09 14:47:22 2012 -0800
    48.3 @@ -0,0 +1,3 @@
    48.4 +Neg05.java:10:40: compiler.err.override.incompatible.ret: (compiler.misc.clashes.with: m(), Neg05.IA3, m(), Neg05.IA2), java.lang.Number, java.lang.Integer
    48.5 +Neg05.java:12:12: compiler.err.does.not.override.abstract: Neg05.C, m(), Neg05.IA3
    48.6 +2 errors
    49.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    49.2 +++ b/test/tools/javac/defaultMethods/Neg06.java	Fri Nov 09 14:47:22 2012 -0800
    49.3 @@ -0,0 +1,16 @@
    49.4 +/*
    49.5 + * @test /nodynamiccopyright/
    49.6 + * @summary flow analysis is not run on inlined default bodies
    49.7 + * @compile/fail/ref=Neg06.out -XDallowDefaultMethods -XDrawDiagnostics Neg06.java
    49.8 + */
    49.9 +
   49.10 +class Neg06 {
   49.11 +
   49.12 +    interface A {
   49.13 +        default String m() { C.m(); }
   49.14 +    }
   49.15 +
   49.16 +    static class C {
   49.17 +        static String m() { return ""; }
   49.18 +    }
   49.19 +}
    50.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    50.2 +++ b/test/tools/javac/defaultMethods/Neg06.out	Fri Nov 09 14:47:22 2012 -0800
    50.3 @@ -0,0 +1,2 @@
    50.4 +Neg06.java:10:37: compiler.err.missing.ret.stmt
    50.5 +1 error
    51.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    51.2 +++ b/test/tools/javac/defaultMethods/Neg07.java	Fri Nov 09 14:47:22 2012 -0800
    51.3 @@ -0,0 +1,21 @@
    51.4 +/*
    51.5 + * @test /nodynamiccopyright/
    51.6 + * @summary check that default overrides are properly type-checked
    51.7 + * @compile/fail/ref=Neg07.out -XDallowDefaultMethods -XDrawDiagnostics Neg07.java
    51.8 + */
    51.9 +
   51.10 +class Neg07 {
   51.11 +    interface I {
   51.12 +        default int m() { return 1; }
   51.13 +    }
   51.14 +
   51.15 +    static class C1 {
   51.16 +        public void m() { } //incompatible return
   51.17 +    }
   51.18 +
   51.19 +    static class C2 extends C1 implements I { }
   51.20 +
   51.21 +    static class C3 implements I {
   51.22 +        public void m() { } //incompatible return
   51.23 +    }
   51.24 +}
    52.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    52.2 +++ b/test/tools/javac/defaultMethods/Neg07.out	Fri Nov 09 14:47:22 2012 -0800
    52.3 @@ -0,0 +1,3 @@
    52.4 +Neg07.java:16:12: compiler.err.override.incompatible.ret: (compiler.misc.cant.implement: m(), Neg07.C1, m(), Neg07.I), void, int
    52.5 +Neg07.java:19:21: compiler.err.override.incompatible.ret: (compiler.misc.cant.implement: m(), Neg07.C3, m(), Neg07.I), void, int
    52.6 +2 errors
    53.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    53.2 +++ b/test/tools/javac/defaultMethods/Neg08.java	Fri Nov 09 14:47:22 2012 -0800
    53.3 @@ -0,0 +1,20 @@
    53.4 +/*
    53.5 + * @test /nodynamiccopyright/
    53.6 + * @summary check that default overrides are properly type-checked
    53.7 + * @compile/fail/ref=Neg08.out -XDallowDefaultMethods -XDrawDiagnostics Neg08.java
    53.8 + */
    53.9 +class Neg08 {
   53.10 +    interface I {
   53.11 +        default void m() { }
   53.12 +    }
   53.13 +
   53.14 +    static class C1 {
   53.15 +        void m() { } //weaker modifier
   53.16 +    }
   53.17 +
   53.18 +    static class C2 extends C1 implements I { }
   53.19 +
   53.20 +    static class C3 implements I {
   53.21 +        void m() { } //weaker modifier
   53.22 +    }
   53.23 +}
    54.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    54.2 +++ b/test/tools/javac/defaultMethods/Neg08.out	Fri Nov 09 14:47:22 2012 -0800
    54.3 @@ -0,0 +1,3 @@
    54.4 +Neg08.java:15:12: compiler.err.override.weaker.access: (compiler.misc.cant.implement: m(), Neg08.C1, m(), Neg08.I), public
    54.5 +Neg08.java:18:14: compiler.err.override.weaker.access: (compiler.misc.cant.implement: m(), Neg08.C3, m(), Neg08.I), public
    54.6 +2 errors
    55.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    55.2 +++ b/test/tools/javac/defaultMethods/Neg09.java	Fri Nov 09 14:47:22 2012 -0800
    55.3 @@ -0,0 +1,22 @@
    55.4 +/*
    55.5 + * @test /nodynamiccopyright/
    55.6 + * @summary check that default overrides are properly type-checked
    55.7 + * @compile/fail/ref=Neg09.out -Werror -Xlint:unchecked -XDallowDefaultMethods -XDrawDiagnostics Neg09.java
    55.8 + */
    55.9 +import java.util.List;
   55.10 +
   55.11 +class Neg09 {
   55.12 +    interface I {
   55.13 +        default List<String> m() { return null; }
   55.14 +    }
   55.15 +
   55.16 +    static class C1 {
   55.17 +        public List m() { return null; } //unchecked (return) override
   55.18 +    }
   55.19 +
   55.20 +    static class C2 extends C1 implements I { }
   55.21 +
   55.22 +    static class C3 implements I {
   55.23 +        public List m() { return null; } //unchecked (return) override
   55.24 +    }
   55.25 +}
    56.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    56.2 +++ b/test/tools/javac/defaultMethods/Neg09.out	Fri Nov 09 14:47:22 2012 -0800
    56.3 @@ -0,0 +1,5 @@
    56.4 +Neg09.java:17:12: compiler.warn.override.unchecked.ret: (compiler.misc.unchecked.implement: m(), Neg09.C1, m(), Neg09.I), java.util.List, java.util.List<java.lang.String>
    56.5 +Neg09.java:20:21: compiler.warn.override.unchecked.ret: (compiler.misc.unchecked.implement: m(), Neg09.C3, m(), Neg09.I), java.util.List, java.util.List<java.lang.String>
    56.6 +- compiler.err.warnings.and.werror
    56.7 +1 error
    56.8 +2 warnings
    57.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    57.2 +++ b/test/tools/javac/defaultMethods/Neg10.java	Fri Nov 09 14:47:22 2012 -0800
    57.3 @@ -0,0 +1,20 @@
    57.4 +/*
    57.5 + * @test /nodynamiccopyright/
    57.6 + * @summary check that default overrides are properly type-checked
    57.7 + * @compile/fail/ref=Neg10.out -Werror -Xlint:unchecked -XDallowDefaultMethods -XDrawDiagnostics Neg10.java
    57.8 + */
    57.9 +class Neg10 {
   57.10 +    interface I<X extends Exception> {
   57.11 +        default void m() throws X { }
   57.12 +    }
   57.13 +
   57.14 +    static class C1 {
   57.15 +        public void m() throws Exception { } //unchecked (throws) override
   57.16 +    }
   57.17 +
   57.18 +    static class C2<Z extends Exception> extends C1 implements I<Z> { }
   57.19 +
   57.20 +    static class C3<Z extends Exception> implements I<Z> {
   57.21 +        public void m() throws Exception { } //unchecked (throws) override
   57.22 +    }
   57.23 +}
    58.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    58.2 +++ b/test/tools/javac/defaultMethods/Neg10.out	Fri Nov 09 14:47:22 2012 -0800
    58.3 @@ -0,0 +1,5 @@
    58.4 +Neg10.java:15:12: compiler.warn.override.unchecked.thrown: (compiler.misc.cant.implement: m(), Neg10.C1, m(), Neg10.I), java.lang.Exception
    58.5 +Neg10.java:18:21: compiler.warn.override.unchecked.thrown: (compiler.misc.cant.implement: m(), Neg10.C3, m(), Neg10.I), java.lang.Exception
    58.6 +- compiler.err.warnings.and.werror
    58.7 +1 error
    58.8 +2 warnings
    59.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    59.2 +++ b/test/tools/javac/defaultMethods/Neg11.java	Fri Nov 09 14:47:22 2012 -0800
    59.3 @@ -0,0 +1,20 @@
    59.4 +/*
    59.5 + * @test /nodynamiccopyright/
    59.6 + * @summary check that default overrides are properly type-checked
    59.7 + * @compile/fail/ref=Neg11.out -XDallowDefaultMethods -XDrawDiagnostics Neg11.java
    59.8 + */
    59.9 +class Neg11 {
   59.10 +    interface I {
   59.11 +        default void m() { }
   59.12 +    }
   59.13 +
   59.14 +    static class C1 {
   59.15 +        public void m() throws Exception { } //bad throws
   59.16 +    }
   59.17 +
   59.18 +    static class C2 extends C1 implements I { }
   59.19 +
   59.20 +    static class C3 implements I {
   59.21 +        public void m() throws Exception { } //bad throws
   59.22 +    }
   59.23 +}
    60.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    60.2 +++ b/test/tools/javac/defaultMethods/Neg11.out	Fri Nov 09 14:47:22 2012 -0800
    60.3 @@ -0,0 +1,3 @@
    60.4 +Neg11.java:15:12: compiler.err.override.meth.doesnt.throw: (compiler.misc.cant.implement: m(), Neg11.C1, m(), Neg11.I), java.lang.Exception
    60.5 +Neg11.java:18:21: compiler.err.override.meth.doesnt.throw: (compiler.misc.cant.implement: m(), Neg11.C3, m(), Neg11.I), java.lang.Exception
    60.6 +2 errors
    61.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    61.2 +++ b/test/tools/javac/defaultMethods/Neg12.java	Fri Nov 09 14:47:22 2012 -0800
    61.3 @@ -0,0 +1,27 @@
    61.4 +/*
    61.5 + * @test /nodynamiccopyright/
    61.6 + * @summary check that abstract methods are discarded in overload resolution diags
    61.7 + * @compile/fail/ref=Neg12.out -XDallowDefaultMethods -XDrawDiagnostics Neg12.java
    61.8 + */
    61.9 +class Neg12 {
   61.10 +
   61.11 +    interface I1 {
   61.12 +        default void m(String s) {};
   61.13 +    }
   61.14 +
   61.15 +    interface I2 {
   61.16 +        void m(String s);
   61.17 +    }
   61.18 +
   61.19 +    static class B {
   61.20 +        void m(Integer i) { }
   61.21 +    }
   61.22 +
   61.23 +    static class C extends B implements I1 { }
   61.24 +    static class D extends B implements I2 { }
   61.25 +
   61.26 +    void test(C c, D d) {
   61.27 +        c.m();
   61.28 +        d.m();
   61.29 +    }
   61.30 +}
    62.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    62.2 +++ b/test/tools/javac/defaultMethods/Neg12.out	Fri Nov 09 14:47:22 2012 -0800
    62.3 @@ -0,0 +1,4 @@
    62.4 +Neg12.java:21:12: compiler.err.does.not.override.abstract: Neg12.D, m(java.lang.String), Neg12.I2
    62.5 +Neg12.java:24:10: compiler.err.cant.apply.symbols: kindname.method, m, ,{(compiler.misc.inapplicable.method: kindname.method, Neg12.I1, m(java.lang.String), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, Neg12.B, m(java.lang.Integer), (compiler.misc.arg.length.mismatch))}
    62.6 +Neg12.java:25:10: compiler.err.cant.apply.symbol: kindname.method, m, java.lang.Integer, compiler.misc.no.args, kindname.class, Neg12.B, (compiler.misc.arg.length.mismatch)
    62.7 +3 errors
    63.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    63.2 +++ b/test/tools/javac/defaultMethods/Neg13.java	Fri Nov 09 14:47:22 2012 -0800
    63.3 @@ -0,0 +1,18 @@
    63.4 +/*
    63.5 + * @test /nodynamiccopyright/
    63.6 + * @summary check that default method overriding object members are flagged as error
    63.7 + * @compile/fail/ref=Neg13.out -XDallowDefaultMethods -XDrawDiagnostics Neg13.java
    63.8 + */
    63.9 +interface Neg13 {
   63.10 +    default protected Object clone() { return null; } //protected not allowed here
   63.11 +    default boolean equals(Object obj) { return false; }
   63.12 +    default protected void finalize() { } //protected not allowed here
   63.13 +    default Class<?> getClass() { return null; }
   63.14 +    default int hashCode() { return 0; }
   63.15 +    default void notify() { }
   63.16 +    default void notifyAll() { }
   63.17 +    default String toString() { return null; }
   63.18 +    default void wait() { }
   63.19 +    default void wait(long timeout) { }
   63.20 +    default void wait(long timeout, int nanos) { }
   63.21 +}
    64.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    64.2 +++ b/test/tools/javac/defaultMethods/Neg13.out	Fri Nov 09 14:47:22 2012 -0800
    64.3 @@ -0,0 +1,12 @@
    64.4 +Neg13.java:7:30: compiler.err.mod.not.allowed.here: protected
    64.5 +Neg13.java:9:28: compiler.err.mod.not.allowed.here: protected
    64.6 +Neg13.java:8:21: compiler.err.default.overrides.object.member: equals, kindname.interface, Neg13
    64.7 +Neg13.java:10:22: compiler.err.override.meth: (compiler.misc.cant.override: getClass(), Neg13, getClass(), java.lang.Object), final
    64.8 +Neg13.java:11:17: compiler.err.default.overrides.object.member: hashCode, kindname.interface, Neg13
    64.9 +Neg13.java:12:18: compiler.err.override.meth: (compiler.misc.cant.override: notify(), Neg13, notify(), java.lang.Object), final
   64.10 +Neg13.java:13:18: compiler.err.override.meth: (compiler.misc.cant.override: notifyAll(), Neg13, notifyAll(), java.lang.Object), final
   64.11 +Neg13.java:14:20: compiler.err.default.overrides.object.member: toString, kindname.interface, Neg13
   64.12 +Neg13.java:15:18: compiler.err.override.meth: (compiler.misc.cant.override: wait(), Neg13, wait(), java.lang.Object), final
   64.13 +Neg13.java:16:18: compiler.err.override.meth: (compiler.misc.cant.override: wait(long), Neg13, wait(long), java.lang.Object), final
   64.14 +Neg13.java:17:18: compiler.err.override.meth: (compiler.misc.cant.override: wait(long,int), Neg13, wait(long,int), java.lang.Object), final
   64.15 +11 errors
    65.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    65.2 +++ b/test/tools/javac/defaultMethods/Neg14.java	Fri Nov 09 14:47:22 2012 -0800
    65.3 @@ -0,0 +1,11 @@
    65.4 +/*
    65.5 + * @test /nodynamiccopyright/
    65.6 + * @summary check that a class cannot have two sibling interfaces with a default and abstract method
    65.7 + * @compile/fail/ref=Neg14.out -XDallowDefaultMethods -XDrawDiagnostics Neg14.java
    65.8 + */
    65.9 +class Neg14 {
   65.10 +    interface IA { int m(); }
   65.11 +    interface IB { default int m() { return 1; } }
   65.12 +
   65.13 +    abstract class AB implements IA, IB {}
   65.14 +}
    66.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    66.2 +++ b/test/tools/javac/defaultMethods/Neg14.out	Fri Nov 09 14:47:22 2012 -0800
    66.3 @@ -0,0 +1,2 @@
    66.4 +Neg14.java:10:14: compiler.err.types.incompatible.abstract.default: kindname.class, Neg14.AB, m, , Neg14.IB, Neg14.IA
    66.5 +1 error
    67.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    67.2 +++ b/test/tools/javac/defaultMethods/Neg15.java	Fri Nov 09 14:47:22 2012 -0800
    67.3 @@ -0,0 +1,14 @@
    67.4 +/*
    67.5 + * @test /nodynamiccopyright/
    67.6 + * @summary check that level skipping in default super calls is correctly rejected
    67.7 + * @compile/fail/ref=Neg15.out -XDallowDefaultMethods -XDrawDiagnostics Neg15.java
    67.8 + */
    67.9 +class Neg15 {
   67.10 +    interface I { default void m() {  } }
   67.11 +    interface J extends I { default void m() {  } }
   67.12 +    interface K extends I {}
   67.13 +
   67.14 +    static class C implements J, K {
   67.15 +        void foo() { K.super.m(); }
   67.16 +    }
   67.17 +}
    68.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    68.2 +++ b/test/tools/javac/defaultMethods/Neg15.out	Fri Nov 09 14:47:22 2012 -0800
    68.3 @@ -0,0 +1,2 @@
    68.4 +Neg15.java:12:31: compiler.err.illegal.default.super.call: Neg15.K, (compiler.misc.overridden.default: m(), Neg15.J)
    68.5 +1 error
    69.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    69.2 +++ b/test/tools/javac/defaultMethods/Neg16.java	Fri Nov 09 14:47:22 2012 -0800
    69.3 @@ -0,0 +1,13 @@
    69.4 +/*
    69.5 + * @test /nodynamiccopyright/
    69.6 + * @summary check that level skipping in default super calls is correctly rejected
    69.7 + * @compile/fail/ref=Neg16.out -XDallowDefaultMethods -XDrawDiagnostics Neg16.java
    69.8 + */
    69.9 +class Neg16 {
   69.10 +    interface I { default void m() {  } }
   69.11 +    interface J extends I { default void m() {  } }
   69.12 +
   69.13 +    static class C implements I, J {
   69.14 +        void foo() { I.super.m(); }
   69.15 +    }
   69.16 +}
    70.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    70.2 +++ b/test/tools/javac/defaultMethods/Neg16.out	Fri Nov 09 14:47:22 2012 -0800
    70.3 @@ -0,0 +1,2 @@
    70.4 +Neg16.java:11:23: compiler.err.illegal.default.super.call: Neg16.I, (compiler.misc.redundant.supertype: Neg16.I, Neg16.J)
    70.5 +1 error
    71.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    71.2 +++ b/test/tools/javac/defaultMethods/Pos01.java	Fri Nov 09 14:47:22 2012 -0800
    71.3 @@ -0,0 +1,61 @@
    71.4 +/*
    71.5 + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
    71.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    71.7 + *
    71.8 + * This code is free software; you can redistribute it and/or modify it
    71.9 + * under the terms of the GNU General Public License version 2 only, as
   71.10 + * published by the Free Software Foundation.
   71.11 + *
   71.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   71.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   71.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   71.15 + * version 2 for more details (a copy is included in the LICENSE file that
   71.16 + * accompanied this code).
   71.17 + *
   71.18 + * You should have received a copy of the GNU General Public License version
   71.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   71.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   71.21 + *
   71.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   71.23 + * or visit www.oracle.com if you need additional information or have any
   71.24 + * questions.
   71.25 + */
   71.26 +
   71.27 +/*
   71.28 + * @test
   71.29 + * @summary basic test for default methods
   71.30 + * @ignore awaits lambda support
   71.31 + * @author  Maurizio Cimadamore
   71.32 + * @compile -XDallowLambda -XDallowPoly -XDallowDefaultMethods Pos01.java
   71.33 + */
   71.34 +
   71.35 +import java.util.*;
   71.36 +
   71.37 +class Pos01 {
   71.38 +
   71.39 +    interface Mapper<T> {
   71.40 +        T map(T in);
   71.41 +    }
   71.42 +
   71.43 +    interface ExtendedList<T> extends List<T> {
   71.44 +        default List<T> testMap(Mapper<T> r) {
   71.45 +            return Pos01.<T>listMapper(this, r);
   71.46 +        }
   71.47 +    }
   71.48 +
   71.49 +    static class MyList<E> extends ArrayList<E> implements ExtendedList<E> {}
   71.50 +
   71.51 +    public static void main(String[] args) {
   71.52 +       MyList<Integer> l = new MyList<Integer>();
   71.53 +       l.add(1); l.add(2); l.add(3);
   71.54 +       l.testMap((Integer x) -> x * x );
   71.55 +    }
   71.56 +
   71.57 +    static <T> List<T> listMapper(List<T> l, Mapper<T> mapper) {
   71.58 +        MyList<T> new_list = new MyList<T>();
   71.59 +        for (T el : l) {
   71.60 +            new_list.add(mapper.map(el));
   71.61 +        }
   71.62 +        return new_list;
   71.63 +    }
   71.64 +}
    72.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    72.2 +++ b/test/tools/javac/defaultMethods/Pos02.java	Fri Nov 09 14:47:22 2012 -0800
    72.3 @@ -0,0 +1,48 @@
    72.4 +/*
    72.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    72.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    72.7 + *
    72.8 + * This code is free software; you can redistribute it and/or modify it
    72.9 + * under the terms of the GNU General Public License version 2 only, as
   72.10 + * published by the Free Software Foundation.
   72.11 + *
   72.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   72.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   72.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   72.15 + * version 2 for more details (a copy is included in the LICENSE file that
   72.16 + * accompanied this code).
   72.17 + *
   72.18 + * You should have received a copy of the GNU General Public License version
   72.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   72.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   72.21 + *
   72.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   72.23 + * or visit www.oracle.com if you need additional information or have any
   72.24 + * questions.
   72.25 + */
   72.26 +
   72.27 +/*
   72.28 + * @test
   72.29 + * @summary test for explicit resolution of ambiguous default methods
   72.30 + * @author  Maurizio Cimadamore
   72.31 + * @compile -XDallowDefaultMethods Pos02.java
   72.32 + */
   72.33 +
   72.34 +class Pos02 {
   72.35 +    interface IA { default int m() { return Pos02.m1(this); } }
   72.36 +    interface IB { default int m() { return Pos02.m2(this); } }
   72.37 +
   72.38 +    static class A implements IA {}
   72.39 +    static class B implements IB {}
   72.40 +
   72.41 +    static class AB implements IA, IB {
   72.42 +        public int m() { return 0; }
   72.43 +        void test() {
   72.44 +            AB.this.m();
   72.45 +            IA.super.m();
   72.46 +        }
   72.47 +    }
   72.48 +
   72.49 +    static int m1(IA a) { return 0; }
   72.50 +    static int m2(IB b) { return 0; }
   72.51 +}
    73.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    73.2 +++ b/test/tools/javac/defaultMethods/Pos04.java	Fri Nov 09 14:47:22 2012 -0800
    73.3 @@ -0,0 +1,43 @@
    73.4 +/*
    73.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    73.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    73.7 + *
    73.8 + * This code is free software; you can redistribute it and/or modify it
    73.9 + * under the terms of the GNU General Public License version 2 only, as
   73.10 + * published by the Free Software Foundation.
   73.11 + *
   73.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   73.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   73.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   73.15 + * version 2 for more details (a copy is included in the LICENSE file that
   73.16 + * accompanied this code).
   73.17 + *
   73.18 + * You should have received a copy of the GNU General Public License version
   73.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   73.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   73.21 + *
   73.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   73.23 + * or visit www.oracle.com if you need additional information or have any
   73.24 + * questions.
   73.25 + */
   73.26 +
   73.27 +/*
   73.28 + * @test
   73.29 + * @summary test for overriding with default method
   73.30 + * @author  Maurizio Cimadamore
   73.31 + * @compile -XDallowDefaultMethods Pos04.java
   73.32 + */
   73.33 +
   73.34 +class Pos04 {
   73.35 +    interface A { default int m() { return Pos04.m(this); } }
   73.36 +    static abstract class B { public int m() { return 0; } }
   73.37 +
   73.38 +    static class C extends B implements A {
   73.39 +        void test() {
   73.40 +            C.this.m();
   73.41 +            A.super.m();
   73.42 +        }
   73.43 +    }
   73.44 +
   73.45 +    static int m(A a) { return 0; }
   73.46 +}
    74.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    74.2 +++ b/test/tools/javac/defaultMethods/Pos05.java	Fri Nov 09 14:47:22 2012 -0800
    74.3 @@ -0,0 +1,45 @@
    74.4 +/*
    74.5 + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
    74.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    74.7 + *
    74.8 + * This code is free software; you can redistribute it and/or modify it
    74.9 + * under the terms of the GNU General Public License version 2 only, as
   74.10 + * published by the Free Software Foundation.
   74.11 + *
   74.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   74.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   74.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   74.15 + * version 2 for more details (a copy is included in the LICENSE file that
   74.16 + * accompanied this code).
   74.17 + *
   74.18 + * You should have received a copy of the GNU General Public License version
   74.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   74.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   74.21 + *
   74.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   74.23 + * or visit www.oracle.com if you need additional information or have any
   74.24 + * questions.
   74.25 + */
   74.26 +
   74.27 +/*
   74.28 + * @test
   74.29 + * @summary check that indirectly inherited default methods are discovered during resolution
   74.30 + * @author  Maurizio Cimadamore
   74.31 + * @compile -XDallowDefaultMethods Pos05.java
   74.32 + */
   74.33 +
   74.34 +class Pos05  {
   74.35 +     interface A {
   74.36 +         default void m() { Pos05.impl(this); }
   74.37 +     }
   74.38 +
   74.39 +     interface B extends A { }
   74.40 +
   74.41 +     static class E implements B { }
   74.42 +
   74.43 +     void test(E e) {
   74.44 +         e.m();
   74.45 +     }
   74.46 +
   74.47 +     static void impl(A a) { }
   74.48 +}
    75.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    75.2 +++ b/test/tools/javac/defaultMethods/Pos06.java	Fri Nov 09 14:47:22 2012 -0800
    75.3 @@ -0,0 +1,49 @@
    75.4 +/*
    75.5 + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
    75.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    75.7 + *
    75.8 + * This code is free software; you can redistribute it and/or modify it
    75.9 + * under the terms of the GNU General Public License version 2 only, as
   75.10 + * published by the Free Software Foundation.
   75.11 + *
   75.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   75.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   75.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   75.15 + * version 2 for more details (a copy is included in the LICENSE file that
   75.16 + * accompanied this code).
   75.17 + *
   75.18 + * You should have received a copy of the GNU General Public License version
   75.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   75.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   75.21 + *
   75.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   75.23 + * or visit www.oracle.com if you need additional information or have any
   75.24 + * questions.
   75.25 + */
   75.26 +
   75.27 +/*
   75.28 + * @test
   75.29 + * @summary check that well-formed MI hierarchies behaves well w.r.t. method resolution (i.e. no ambiguities)
   75.30 + * @author  Maurizio Cimadamore
   75.31 + * @compile -XDallowDefaultMethods Pos06.java
   75.32 + */
   75.33 +
   75.34 +class Pos06 {
   75.35 +     interface A {
   75.36 +         default void m() { Pos06.impl(this); }
   75.37 +     }
   75.38 +
   75.39 +     interface B extends A {
   75.40 +         default void m() { Pos06.impl(this); }
   75.41 +     }
   75.42 +
   75.43 +     static class X implements A, B { }
   75.44 +
   75.45 +     void test(X x) {
   75.46 +         x.m();
   75.47 +         ((A)x).m();
   75.48 +         ((B)x).m();
   75.49 +     }
   75.50 +
   75.51 +     static void impl(Object a) { }
   75.52 +}
    76.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    76.2 +++ b/test/tools/javac/defaultMethods/Pos07.java	Fri Nov 09 14:47:22 2012 -0800
    76.3 @@ -0,0 +1,44 @@
    76.4 +/*
    76.5 + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
    76.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    76.7 + *
    76.8 + * This code is free software; you can redistribute it and/or modify it
    76.9 + * under the terms of the GNU General Public License version 2 only, as
   76.10 + * published by the Free Software Foundation.
   76.11 + *
   76.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   76.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   76.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   76.15 + * version 2 for more details (a copy is included in the LICENSE file that
   76.16 + * accompanied this code).
   76.17 + *
   76.18 + * You should have received a copy of the GNU General Public License version
   76.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   76.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   76.21 + *
   76.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   76.23 + * or visit www.oracle.com if you need additional information or have any
   76.24 + * questions.
   76.25 + */
   76.26 +
   76.27 +/*
   76.28 + * @test
   76.29 + * @summary check that compilation order does not matter
   76.30 + * @author  Maurizio Cimadamore
   76.31 + * @compile -XDallowDefaultMethods Pos07.java
   76.32 + */
   76.33 +
   76.34 +class Pos07 {
   76.35 +    interface A {
   76.36 +         default void foo() { Pos07.impl(this); }
   76.37 +         default void bar() { Pos07.impl(this); }
   76.38 +    }
   76.39 +
   76.40 +    static class C implements B, A {}
   76.41 +
   76.42 +    interface B extends A {
   76.43 +        default void foo() { Pos07.impl(this); }
   76.44 +    }
   76.45 +
   76.46 +    static void impl(A a) {}
   76.47 +}
    77.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    77.2 +++ b/test/tools/javac/defaultMethods/Pos08.java	Fri Nov 09 14:47:22 2012 -0800
    77.3 @@ -0,0 +1,46 @@
    77.4 +/*
    77.5 + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
    77.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    77.7 + *
    77.8 + * This code is free software; you can redistribute it and/or modify it
    77.9 + * under the terms of the GNU General Public License version 2 only, as
   77.10 + * published by the Free Software Foundation.
   77.11 + *
   77.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   77.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   77.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   77.15 + * version 2 for more details (a copy is included in the LICENSE file that
   77.16 + * accompanied this code).
   77.17 + *
   77.18 + * You should have received a copy of the GNU General Public License version
   77.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   77.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   77.21 + *
   77.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   77.23 + * or visit www.oracle.com if you need additional information or have any
   77.24 + * questions.
   77.25 + */
   77.26 +
   77.27 +/*
   77.28 + * @test
   77.29 + * @summary check that common overrider solves default method conflicts
   77.30 + * @author  Maurizio Cimadamore
   77.31 + * @compile -XDallowDefaultMethods Pos08.java
   77.32 + */
   77.33 +
   77.34 +class Pos08 {
   77.35 +    interface A {
   77.36 +        default void m() { Pos08.a(this); }
   77.37 +    }
   77.38 +
   77.39 +    interface B {
   77.40 +        default void m() { Pos08.b(this); }
   77.41 +    }
   77.42 +
   77.43 +    interface C extends A, B {
   77.44 +        default void m() { Pos08.b(this); }
   77.45 +    }
   77.46 +
   77.47 +    static void a(A o) { }
   77.48 +    static void b(B o) { }
   77.49 +}
    78.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    78.2 +++ b/test/tools/javac/defaultMethods/Pos10.java	Fri Nov 09 14:47:22 2012 -0800
    78.3 @@ -0,0 +1,43 @@
    78.4 +/*
    78.5 + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
    78.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    78.7 + *
    78.8 + * This code is free software; you can redistribute it and/or modify it
    78.9 + * under the terms of the GNU General Public License version 2 only, as
   78.10 + * published by the Free Software Foundation.
   78.11 + *
   78.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   78.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   78.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   78.15 + * version 2 for more details (a copy is included in the LICENSE file that
   78.16 + * accompanied this code).
   78.17 + *
   78.18 + * You should have received a copy of the GNU General Public License version
   78.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   78.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   78.21 + *
   78.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   78.23 + * or visit www.oracle.com if you need additional information or have any
   78.24 + * questions.
   78.25 + */
   78.26 +
   78.27 +/*
   78.28 + * @test
   78.29 + * @summary check that type-variables in generic extension decl can be accessed from default impl
   78.30 + * @author  Maurizio Cimadamore
   78.31 + * @compile -XDallowDefaultMethods Pos10.java
   78.32 + */
   78.33 +
   78.34 +class Pos10 {
   78.35 +    interface Function<X,Y> {
   78.36 +        Y apply(X x);
   78.37 +    }
   78.38 +
   78.39 +    interface A<T> {
   78.40 +        default <R> void m(Function<T,R> f) { Impl.<T,R>m(this, f); }
   78.41 +    }
   78.42 +
   78.43 +    static class Impl {
   78.44 +        static <T,R> void m(A<T> a, Function<T,R> f) {  }
   78.45 +    }
   78.46 +}
    79.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    79.2 +++ b/test/tools/javac/defaultMethods/Pos11.java	Fri Nov 09 14:47:22 2012 -0800
    79.3 @@ -0,0 +1,56 @@
    79.4 +/*
    79.5 + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
    79.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    79.7 + *
    79.8 + * This code is free software; you can redistribute it and/or modify it
    79.9 + * under the terms of the GNU General Public License version 2 only, as
   79.10 + * published by the Free Software Foundation.
   79.11 + *
   79.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   79.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   79.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   79.15 + * version 2 for more details (a copy is included in the LICENSE file that
   79.16 + * accompanied this code).
   79.17 + *
   79.18 + * You should have received a copy of the GNU General Public License version
   79.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   79.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   79.21 + *
   79.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   79.23 + * or visit www.oracle.com if you need additional information or have any
   79.24 + * questions.
   79.25 + */
   79.26 +
   79.27 +/*
   79.28 + * @test
   79.29 + * @summary complex test with conflict resolution via overriding
   79.30 + * @author  Brian Goetz
   79.31 + * @compile -XDallowDefaultMethods Pos11.java
   79.32 + */
   79.33 +
   79.34 +class Pos11 {
   79.35 +    interface A {
   79.36 +        default void get() { Pos11.one(this); }
   79.37 +    }
   79.38 +
   79.39 +    interface B {
   79.40 +        default void get() { Pos11.two(this); }
   79.41 +    }
   79.42 +
   79.43 +    interface C extends A {
   79.44 +        default void get() { Pos11.two(this); }
   79.45 +    }
   79.46 +
   79.47 +    interface D extends A, B {
   79.48 +        default void get() { Pos11.two(this); }
   79.49 +    }
   79.50 +
   79.51 +    static class X implements C { }
   79.52 +
   79.53 +    static class Y implements C, A { }
   79.54 +
   79.55 +    static class Z implements D, A, B { }
   79.56 +
   79.57 +    static void one(Object a) {  }
   79.58 +    static void two(Object a) {  }
   79.59 +}
    80.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    80.2 +++ b/test/tools/javac/defaultMethods/Pos12.java	Fri Nov 09 14:47:22 2012 -0800
    80.3 @@ -0,0 +1,39 @@
    80.4 +/*
    80.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    80.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    80.7 + *
    80.8 + * This code is free software; you can redistribute it and/or modify it
    80.9 + * under the terms of the GNU General Public License version 2 only, as
   80.10 + * published by the Free Software Foundation.
   80.11 + *
   80.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   80.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   80.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   80.15 + * version 2 for more details (a copy is included in the LICENSE file that
   80.16 + * accompanied this code).
   80.17 + *
   80.18 + * You should have received a copy of the GNU General Public License version
   80.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   80.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   80.21 + *
   80.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   80.23 + * or visit www.oracle.com if you need additional information or have any
   80.24 + * questions.
   80.25 + */
   80.26 +
   80.27 +/*
   80.28 + * @test
   80.29 + * @summary check that 'this' can be used from within an extension method
   80.30 + * @compile -XDallowDefaultMethods Pos12.java
   80.31 + */
   80.32 +
   80.33 +interface Pos12 {
   80.34 +
   80.35 +    default Object m() {
   80.36 +        Object o = this;
   80.37 +        f(this);
   80.38 +        return this;
   80.39 +    }
   80.40 +
   80.41 +    void f(Object o);
   80.42 +}
    81.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    81.2 +++ b/test/tools/javac/defaultMethods/Pos13.java	Fri Nov 09 14:47:22 2012 -0800
    81.3 @@ -0,0 +1,62 @@
    81.4 +/*
    81.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    81.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    81.7 + *
    81.8 + * This code is free software; you can redistribute it and/or modify it
    81.9 + * under the terms of the GNU General Public License version 2 only, as
   81.10 + * published by the Free Software Foundation.
   81.11 + *
   81.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   81.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   81.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   81.15 + * version 2 for more details (a copy is included in the LICENSE file that
   81.16 + * accompanied this code).
   81.17 + *
   81.18 + * You should have received a copy of the GNU General Public License version
   81.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   81.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   81.21 + *
   81.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   81.23 + * or visit www.oracle.com if you need additional information or have any
   81.24 + * questions.
   81.25 + */
   81.26 +
   81.27 +/*
   81.28 + * @test
   81.29 + * @summary qualified 'this' inside default method causes StackOverflowException
   81.30 + * @compile -XDallowDefaultMethods Pos13.java
   81.31 + */
   81.32 +
   81.33 +public class Pos13 {
   81.34 +
   81.35 +    static int assertionCount = 0;
   81.36 +
   81.37 +    static void assertTrue(boolean cond) {
   81.38 +        assertionCount++;
   81.39 +        if (!cond)
   81.40 +            throw new AssertionError();
   81.41 +    }
   81.42 +
   81.43 +    interface Outer {
   81.44 +        abstract void doSomething();
   81.45 +
   81.46 +        default void m() {
   81.47 +            new SubOuter() {
   81.48 +                public void doSomething() {
   81.49 +                    Outer.this.doSomething();
   81.50 +                }
   81.51 +            }.doSomething();
   81.52 +        }
   81.53 +    }
   81.54 +
   81.55 +    interface SubOuter extends Outer { }
   81.56 +
   81.57 +    static class E implements Outer {
   81.58 +        public void doSomething() { assertTrue(true); }
   81.59 +    }
   81.60 +
   81.61 +    public static void main(String[] args) {
   81.62 +        new E().m();
   81.63 +        assertTrue(assertionCount == 1);
   81.64 +    }
   81.65 +}
    82.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    82.2 +++ b/test/tools/javac/defaultMethods/Pos14.java	Fri Nov 09 14:47:22 2012 -0800
    82.3 @@ -0,0 +1,39 @@
    82.4 +/*
    82.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    82.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    82.7 + *
    82.8 + * This code is free software; you can redistribute it and/or modify it
    82.9 + * under the terms of the GNU General Public License version 2 only, as
   82.10 + * published by the Free Software Foundation.
   82.11 + *
   82.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   82.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   82.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   82.15 + * version 2 for more details (a copy is included in the LICENSE file that
   82.16 + * accompanied this code).
   82.17 + *
   82.18 + * You should have received a copy of the GNU General Public License version
   82.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   82.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   82.21 + *
   82.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   82.23 + * or visit www.oracle.com if you need additional information or have any
   82.24 + * questions.
   82.25 + */
   82.26 +
   82.27 +/*
   82.28 + * @test
   82.29 + * @summary check that overload resolution selects most specific signature
   82.30 + * @compile -XDallowDefaultMethods Pos14.java
   82.31 + */
   82.32 +
   82.33 +class Pos14 {
   82.34 +    interface A { default Object m() { return null; } }
   82.35 +    static abstract class B { abstract public String m(); }
   82.36 +
   82.37 +    static abstract class C extends B implements A {
   82.38 +        void test() {
   82.39 +            m().length();
   82.40 +        }
   82.41 +    }
   82.42 +}
    83.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    83.2 +++ b/test/tools/javac/defaultMethods/Pos15.java	Fri Nov 09 14:47:22 2012 -0800
    83.3 @@ -0,0 +1,39 @@
    83.4 +/*
    83.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    83.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    83.7 + *
    83.8 + * This code is free software; you can redistribute it and/or modify it
    83.9 + * under the terms of the GNU General Public License version 2 only, as
   83.10 + * published by the Free Software Foundation.
   83.11 + *
   83.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   83.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   83.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   83.15 + * version 2 for more details (a copy is included in the LICENSE file that
   83.16 + * accompanied this code).
   83.17 + *
   83.18 + * You should have received a copy of the GNU General Public License version
   83.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   83.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   83.21 + *
   83.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   83.23 + * or visit www.oracle.com if you need additional information or have any
   83.24 + * questions.
   83.25 + */
   83.26 +
   83.27 +/*
   83.28 + * @test
   83.29 + * @summary check that overload resolution selects most specific signature
   83.30 + * @compile -XDallowDefaultMethods Pos15.java
   83.31 + */
   83.32 +
   83.33 +class Pos15 {
   83.34 +    interface A { default String m() { return null; } }
   83.35 +    static abstract class B { abstract public Object m(); }
   83.36 +
   83.37 +    static abstract class C extends B implements A {
   83.38 +        void test() {
   83.39 +            m().length();
   83.40 +        }
   83.41 +    }
   83.42 +}
    84.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    84.2 +++ b/test/tools/javac/defaultMethods/Pos16.java	Fri Nov 09 14:47:22 2012 -0800
    84.3 @@ -0,0 +1,42 @@
    84.4 +/*
    84.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    84.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    84.7 + *
    84.8 + * This code is free software; you can redistribute it and/or modify it
    84.9 + * under the terms of the GNU General Public License version 2 only, as
   84.10 + * published by the Free Software Foundation.
   84.11 + *
   84.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   84.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   84.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   84.15 + * version 2 for more details (a copy is included in the LICENSE file that
   84.16 + * accompanied this code).
   84.17 + *
   84.18 + * You should have received a copy of the GNU General Public License version
   84.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   84.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   84.21 + *
   84.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   84.23 + * or visit www.oracle.com if you need additional information or have any
   84.24 + * questions.
   84.25 + */
   84.26 +
   84.27 +/*
   84.28 + * @test
   84.29 + * @summary 'class wins' should not short-circuit overload resolution
   84.30 + * @compile -XDallowDefaultMethods Pos16.java
   84.31 + */
   84.32 +
   84.33 +class Pos16 {
   84.34 +    interface I {
   84.35 +        default String m(Integer i) { return ""; }
   84.36 +    }
   84.37 +
   84.38 +    class C implements I {
   84.39 +        Integer m(Object o) { return 1; }
   84.40 +    }
   84.41 +
   84.42 +    void test(C c) {
   84.43 +        c.m(1).length();
   84.44 +    }
   84.45 +}
    85.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    85.2 +++ b/test/tools/javac/defaultMethods/TestDefaultBody.java	Fri Nov 09 14:47:22 2012 -0800
    85.3 @@ -0,0 +1,125 @@
    85.4 +/*
    85.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
    85.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    85.7 + *
    85.8 + * This code is free software; you can redistribute it and/or modify it
    85.9 + * under the terms of the GNU General Public License version 2 only, as
   85.10 + * published by the Free Software Foundation.
   85.11 + *
   85.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   85.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   85.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   85.15 + * version 2 for more details (a copy is included in the LICENSE file that
   85.16 + * accompanied this code).
   85.17 + *
   85.18 + * You should have received a copy of the GNU General Public License version
   85.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   85.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   85.21 + *
   85.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   85.23 + * or visit www.oracle.com if you need additional information or have any
   85.24 + * questions.
   85.25 + */
   85.26 +
   85.27 +/*
   85.28 + * @test
   85.29 + * @ignore awaits for VM support
   85.30 + * @summary  check that code attributed for default methods is correctly generated
   85.31 + * @compile -XDallowDefaultMethods TestDefaultBody.java
   85.32 + * @run main TestDefaultBody
   85.33 + */
   85.34 +
   85.35 +import com.sun.tools.classfile.AccessFlags;
   85.36 +import com.sun.tools.classfile.Attribute;
   85.37 +import com.sun.tools.classfile.ClassFile;
   85.38 +import com.sun.tools.classfile.ConstantPool.*;
   85.39 +import com.sun.tools.classfile.Code_attribute;
   85.40 +import com.sun.tools.classfile.Instruction;
   85.41 +import com.sun.tools.classfile.Method;
   85.42 +
   85.43 +import com.sun.tools.classfile.Opcode;
   85.44 +import java.io.*;
   85.45 +
   85.46 +public class TestDefaultBody {
   85.47 +
   85.48 +    interface TestInterface {
   85.49 +        int no_default(int i);
   85.50 +        default int yes_default(int i) { return impl(this, i); }
   85.51 +    }
   85.52 +
   85.53 +    static int impl(TestInterface ti, int i) { return 0; }
   85.54 +
   85.55 +    static final String TARGET_CLASS_NAME = "TestDefaultBody";
   85.56 +    static final String TARGET_NAME = "impl";
   85.57 +    static final String TARGET_TYPE = "(LTestDefaultBody$TestInterface;I)I";
   85.58 +    static final String SUBTEST_NAME = TestInterface.class.getName() + ".class";
   85.59 +    static final String TEST_METHOD_NAME = "yes_default";
   85.60 +
   85.61 +    public static void main(String... args) throws Exception {
   85.62 +        new TestDefaultBody().run();
   85.63 +    }
   85.64 +
   85.65 +    public void run() throws Exception {
   85.66 +        String workDir = System.getProperty("test.classes");
   85.67 +        File compiledTest = new File(workDir, SUBTEST_NAME);
   85.68 +        verifyDefaultBody(compiledTest);
   85.69 +    }
   85.70 +
   85.71 +    void verifyDefaultBody(File f) {
   85.72 +        System.err.println("verify: " + f);
   85.73 +        try {
   85.74 +            ClassFile cf = ClassFile.read(f);
   85.75 +            Method testMethod = null;
   85.76 +            Code_attribute codeAttr = null;
   85.77 +            for (Method m : cf.methods) {
   85.78 +                codeAttr = (Code_attribute)m.attributes.get(Attribute.Code);
   85.79 +                String mname = m.getName(cf.constant_pool);
   85.80 +                if (mname.equals(TEST_METHOD_NAME)) {
   85.81 +                    testMethod = m;
   85.82 +                    break;
   85.83 +                } else {
   85.84 +                    codeAttr = null;
   85.85 +                }
   85.86 +            }
   85.87 +            if (testMethod == null) {
   85.88 +                throw new Error("Test method not found");
   85.89 +            }
   85.90 +            if (testMethod.access_flags.is(AccessFlags.ACC_ABSTRACT)) {
   85.91 +                throw new Error("Test method is abstract");
   85.92 +            }
   85.93 +            if (codeAttr == null) {
   85.94 +                throw new Error("Code attribute in test method not found");
   85.95 +            }
   85.96 +
   85.97 +            boolean found = false;
   85.98 +            for (Instruction instr : codeAttr.getInstructions()) {
   85.99 +                if (instr.getOpcode() == Opcode.INVOKESTATIC) {
  85.100 +                    found = true;
  85.101 +                    int pc_index = instr.getShort(1);
  85.102 +                    CONSTANT_Methodref_info mref = (CONSTANT_Methodref_info)cf.constant_pool.get(pc_index);
  85.103 +                    String className = mref.getClassName();
  85.104 +                    String targetName = mref.getNameAndTypeInfo().getName();
  85.105 +                    String targetType = mref.getNameAndTypeInfo().getType();
  85.106 +
  85.107 +                    if (!className.equals(TARGET_CLASS_NAME)) {
  85.108 +                        throw new Error("unexpected class in default method body " + className);
  85.109 +                    }
  85.110 +                    if (!targetName.equals(TARGET_NAME)) {
  85.111 +                        throw new Error("unexpected method name in default method body " + targetName);
  85.112 +                    }
  85.113 +                    if (!targetType.equals(TARGET_TYPE)) {
  85.114 +                        throw new Error("unexpected method type in default method body " + targetType);
  85.115 +                    }
  85.116 +                    break;
  85.117 +                }
  85.118 +            }
  85.119 +
  85.120 +            if (!found) {
  85.121 +                throw new Error("no invokestatic found in default method body");
  85.122 +            }
  85.123 +        } catch (Exception e) {
  85.124 +            e.printStackTrace();
  85.125 +            throw new Error("error reading " + f +": " + e);
  85.126 +        }
  85.127 +    }
  85.128 +}
    86.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    86.2 +++ b/test/tools/javac/defaultMethods/TestNoBridgeOnDefaults.java	Fri Nov 09 14:47:22 2012 -0800
    86.3 @@ -0,0 +1,87 @@
    86.4 +/*
    86.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
    86.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    86.7 + *
    86.8 + * This code is free software; you can redistribute it and/or modify it
    86.9 + * under the terms of the GNU General Public License version 2 only, as
   86.10 + * published by the Free Software Foundation.
   86.11 + *
   86.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   86.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   86.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   86.15 + * version 2 for more details (a copy is included in the LICENSE file that
   86.16 + * accompanied this code).
   86.17 + *
   86.18 + * You should have received a copy of the GNU General Public License version
   86.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   86.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   86.21 + *
   86.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   86.23 + * or visit www.oracle.com if you need additional information or have any
   86.24 + * questions.
   86.25 + */
   86.26 +
   86.27 +/*
   86.28 + * @test
   86.29 + * @ignore awaits for VM support
   86.30 + * @summary  check that javac does not generate bridge methods for defaults
   86.31 + * @compile -XDallowDefaultMethods TestNoBridgeOnDefaults.java
   86.32 + * @run main TestNoBridgeOnDefaults
   86.33 + */
   86.34 +
   86.35 +import com.sun.tools.classfile.ClassFile;
   86.36 +import com.sun.tools.classfile.ConstantPool.*;
   86.37 +import com.sun.tools.classfile.Method;
   86.38 +
   86.39 +import java.io.*;
   86.40 +
   86.41 +public class TestNoBridgeOnDefaults {
   86.42 +
   86.43 +    interface A<X> {
   86.44 +        default <Y> A<X> m(X x, Y y) { return Impl.<X,Y>m1(this, x, y); }
   86.45 +    }
   86.46 +
   86.47 +    static abstract class B<X> implements A<X> { }
   86.48 +
   86.49 +    interface C<X> extends A<X> {
   86.50 +        default <Y> C<X> m(X x, Y y) { return Impl.<X,Y>m2(this, x, y); }
   86.51 +    }
   86.52 +
   86.53 +    static abstract class D<X> extends B<X> implements C<X> { }
   86.54 +
   86.55 +    static class Impl {
   86.56 +       static <X, Y> A<X> m1(A<X> rec, X x, Y y) { return null; }
   86.57 +       static <X, Y> C<X> m2(C<X> rec, X x, Y y) { return null; }
   86.58 +    }
   86.59 +
   86.60 +    static final String[] SUBTEST_NAMES = { B.class.getName() + ".class", D.class.getName() + ".class" };
   86.61 +    static final String TEST_METHOD_NAME = "m";
   86.62 +
   86.63 +    public static void main(String... args) throws Exception {
   86.64 +        new TestNoBridgeOnDefaults().run();
   86.65 +    }
   86.66 +
   86.67 +    public void run() throws Exception {
   86.68 +        String workDir = System.getProperty("test.classes");
   86.69 +        for (int i = 0 ; i < SUBTEST_NAMES.length ; i ++) {
   86.70 +            File compiledTest = new File(workDir, SUBTEST_NAMES[i]);
   86.71 +            checkNoBridgeOnDefaults(compiledTest);
   86.72 +        }
   86.73 +    }
   86.74 +
   86.75 +    void checkNoBridgeOnDefaults(File f) {
   86.76 +        System.err.println("check: " + f);
   86.77 +        try {
   86.78 +            ClassFile cf = ClassFile.read(f);
   86.79 +            for (Method m : cf.methods) {
   86.80 +                String mname = m.getName(cf.constant_pool);
   86.81 +                if (mname.equals(TEST_METHOD_NAME)) {
   86.82 +                    throw new Error("unexpected bridge method found " + m);
   86.83 +                }
   86.84 +            }
   86.85 +        } catch (Exception e) {
   86.86 +            e.printStackTrace();
   86.87 +            throw new Error("error reading " + f +": " + e);
   86.88 +        }
   86.89 +    }
   86.90 +}
    87.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    87.2 +++ b/test/tools/javac/defaultMethods/crossCompile/Clinit.java	Fri Nov 09 14:47:22 2012 -0800
    87.3 @@ -0,0 +1,29 @@
    87.4 +/*
    87.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    87.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    87.7 + *
    87.8 + * This code is free software; you can redistribute it and/or modify it
    87.9 + * under the terms of the GNU General Public License version 2 only, as
   87.10 + * published by the Free Software Foundation.
   87.11 + *
   87.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   87.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   87.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   87.15 + * version 2 for more details (a copy is included in the LICENSE file that
   87.16 + * accompanied this code).
   87.17 + *
   87.18 + * You should have received a copy of the GNU General Public License version
   87.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   87.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   87.21 + *
   87.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   87.23 + * or visit www.oracle.com if you need additional information or have any
   87.24 + * questions.
   87.25 + */
   87.26 +interface Clinit {
   87.27 +    String s = Inner.m();
   87.28 +
   87.29 +    static class Inner {
   87.30 +        static String m() { return ""; }
   87.31 +    }
   87.32 +}
    88.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    88.2 +++ b/test/tools/javac/defaultMethods/crossCompile/CrossCompile.java	Fri Nov 09 14:47:22 2012 -0800
    88.3 @@ -0,0 +1,34 @@
    88.4 +/*
    88.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    88.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    88.7 + *
    88.8 + * This code is free software; you can redistribute it and/or modify it
    88.9 + * under the terms of the GNU General Public License version 2 only, as
   88.10 + * published by the Free Software Foundation.
   88.11 + *
   88.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   88.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   88.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   88.15 + * version 2 for more details (a copy is included in the LICENSE file that
   88.16 + * accompanied this code).
   88.17 + *
   88.18 + * You should have received a copy of the GNU General Public License version
   88.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   88.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   88.21 + *
   88.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   88.23 + * or visit www.oracle.com if you need additional information or have any
   88.24 + * questions.
   88.25 + */
   88.26 +
   88.27 +/*
   88.28 + * @test
   88.29 + * @summary check that clinit in interface doesn't cause spurious default method diagnostics
   88.30 + * @compile -source 1.4 -target 1.4 Clinit.java
   88.31 + * @compile CrossCompile.java
   88.32 + */
   88.33 +class CrossCompile {
   88.34 +   void test() {
   88.35 +        String s = Clinit.s;
   88.36 +   }
   88.37 +}
    89.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    89.2 +++ b/test/tools/javac/defaultMethods/fd/FDTest.java	Fri Nov 09 14:47:22 2012 -0800
    89.3 @@ -0,0 +1,147 @@
    89.4 +/*
    89.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    89.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    89.7 + *
    89.8 + * This code is free software; you can redistribute it and/or modify it
    89.9 + * under the terms of the GNU General Public License version 2 only, as
   89.10 + * published by the Free Software Foundation.
   89.11 + *
   89.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   89.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   89.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   89.15 + * version 2 for more details (a copy is included in the LICENSE file that
   89.16 + * accompanied this code).
   89.17 + *
   89.18 + * You should have received a copy of the GNU General Public License version
   89.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   89.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   89.21 + *
   89.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   89.23 + * or visit www.oracle.com if you need additional information or have any
   89.24 + * questions.
   89.25 + */
   89.26 +
   89.27 +/*
   89.28 + * @test
   89.29 + * @summary Automatic test for checking correctness of default resolution
   89.30 + */
   89.31 +
   89.32 +import shapegen.*;
   89.33 +
   89.34 +import com.sun.source.util.JavacTask;
   89.35 +
   89.36 +import java.net.URI;
   89.37 +import java.util.Arrays;
   89.38 +import java.util.ArrayList;
   89.39 +import java.util.Collection;
   89.40 +import java.util.List;
   89.41 +
   89.42 +import javax.tools.Diagnostic;
   89.43 +import javax.tools.JavaCompiler;
   89.44 +import javax.tools.JavaFileObject;
   89.45 +import javax.tools.SimpleJavaFileObject;
   89.46 +import javax.tools.StandardJavaFileManager;
   89.47 +import javax.tools.ToolProvider;
   89.48 +
   89.49 +public class FDTest {
   89.50 +
   89.51 +    enum TestKind {
   89.52 +        POSITIVE,
   89.53 +        NEGATIVE;
   89.54 +
   89.55 +        Collection<Hierarchy> getHierarchy(HierarchyGenerator hg) {
   89.56 +            return this == POSITIVE ?
   89.57 +                    hg.getOK() : hg.getErr();
   89.58 +        }
   89.59 +    }
   89.60 +
   89.61 +    public static void main(String[] args) throws Exception {
   89.62 +        //create default shared JavaCompiler - reused across multiple compilations
   89.63 +        JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
   89.64 +        StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
   89.65 +
   89.66 +        HierarchyGenerator hg = new HierarchyGenerator();
   89.67 +        for (TestKind tk : TestKind.values()) {
   89.68 +            for (Hierarchy hs : tk.getHierarchy(hg)) {
   89.69 +                new FDTest(tk, hs).run(comp, fm);
   89.70 +            }
   89.71 +        }
   89.72 +    }
   89.73 +
   89.74 +    TestKind tk;
   89.75 +    Hierarchy hs;
   89.76 +    DefenderTestSource source;
   89.77 +    DiagnosticChecker diagChecker;
   89.78 +
   89.79 +    FDTest(TestKind tk, Hierarchy hs) {
   89.80 +        this.tk = tk;
   89.81 +        this.hs = hs;
   89.82 +        this.source = new DefenderTestSource();
   89.83 +        this.diagChecker = new DiagnosticChecker();
   89.84 +    }
   89.85 +
   89.86 +    void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception {
   89.87 +        JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker,
   89.88 +                Arrays.asList("-XDallowDefaultMethods"), null, Arrays.asList(source));
   89.89 +        try {
   89.90 +            ct.analyze();
   89.91 +        } catch (Throwable ex) {
   89.92 +            throw new AssertionError("Error thrown when analyzing the following source:\n" + source.getCharContent(true));
   89.93 +        }
   89.94 +        check();
   89.95 +    }
   89.96 +
   89.97 +    void check() {
   89.98 +        boolean errorExpected = tk == TestKind.NEGATIVE;
   89.99 +        if (errorExpected != diagChecker.errorFound) {
  89.100 +            throw new AssertionError("problem in source: \n" +
  89.101 +                    "\nerror found = " + diagChecker.errorFound +
  89.102 +                    "\nerror expected = " + errorExpected +
  89.103 +                    "\n" + dumpHierarchy() +
  89.104 +                    "\n" + source.getCharContent(true));
  89.105 +        }
  89.106 +    }
  89.107 +
  89.108 +    String dumpHierarchy() {
  89.109 +        StringBuilder buf = new StringBuilder();
  89.110 +        buf.append("root = " + hs.root + "\n");
  89.111 +        for (ClassCase cc : hs.all) {
  89.112 +            buf.append("  class name = " + cc.getName() + "\n");
  89.113 +            buf.append("    class OK = " + cc.get_OK() + "\n");
  89.114 +            buf.append("    prov = " + cc.get_mprov() + "\n");
  89.115 +
  89.116 +        }
  89.117 +        return buf.toString();
  89.118 +    }
  89.119 +
  89.120 +    class DefenderTestSource extends SimpleJavaFileObject {
  89.121 +
  89.122 +        String source;
  89.123 +
  89.124 +        public DefenderTestSource() {
  89.125 +            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
  89.126 +            StringBuilder buf = new StringBuilder();
  89.127 +            List<ClassCase> defaultRef = new ArrayList<>();
  89.128 +            for (ClassCase cc : hs.all) {
  89.129 +                hs.genClassDef(buf, cc, null, defaultRef);
  89.130 +            }
  89.131 +            source = buf.toString();
  89.132 +        }
  89.133 +
  89.134 +        @Override
  89.135 +        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
  89.136 +            return source;
  89.137 +        }
  89.138 +    }
  89.139 +
  89.140 +    static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
  89.141 +
  89.142 +        boolean errorFound;
  89.143 +
  89.144 +        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
  89.145 +            if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
  89.146 +                errorFound = true;
  89.147 +            }
  89.148 +        }
  89.149 +    }
  89.150 +}
    90.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    90.2 +++ b/test/tools/javac/defaultMethods/fd/shapegen/ClassCase.java	Fri Nov 09 14:47:22 2012 -0800
    90.3 @@ -0,0 +1,310 @@
    90.4 +/*
    90.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    90.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    90.7 + *
    90.8 + * This code is free software; you can redistribute it and/or modify it
    90.9 + * under the terms of the GNU General Public License version 2 only, as
   90.10 + * published by the Free Software Foundation.  Oracle designates this
   90.11 + * particular file as subject to the "Classpath" exception as provided
   90.12 + * by Oracle in the LICENSE file that accompanied this code.
   90.13 + *
   90.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
   90.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   90.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   90.17 + * version 2 for more details (a copy is included in the LICENSE file that
   90.18 + * accompanied this code).
   90.19 + *
   90.20 + * You should have received a copy of the GNU General Public License version
   90.21 + * 2 along with this work; if not, write to the Free Software Foundation,
   90.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   90.23 + *
   90.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   90.25 + * or visit www.oracle.com if you need additional information or have any
   90.26 + * questions.
   90.27 + */
   90.28 +
   90.29 +package shapegen;
   90.30 +
   90.31 +import java.util.ArrayList;
   90.32 +import java.util.HashSet;
   90.33 +import java.util.List;
   90.34 +import java.util.Map;
   90.35 +import java.util.Set;
   90.36 +
   90.37 +/**
   90.38 + *
   90.39 + * @author Robert Field
   90.40 + */
   90.41 +public class ClassCase {
   90.42 +
   90.43 +    public enum Kind {
   90.44 +        IVAC        (true,  "v"),
   90.45 +        IPRESENT    (true,  "p"),
   90.46 +        IDEFAULT    (true,  "d"),
   90.47 +        CNONE       (false, "n"),
   90.48 +        CABSTRACT   (false, "a"),
   90.49 +        CCONCRETE   (false, "c");
   90.50 +
   90.51 +        private final String prefix;
   90.52 +        public final boolean isInterface;
   90.53 +
   90.54 +        Kind(boolean isInterface, String prefix) {
   90.55 +            this.isInterface = isInterface;
   90.56 +            this.prefix = prefix;
   90.57 +        }
   90.58 +    }
   90.59 +
   90.60 +    public final Kind kind;
   90.61 +    private final ClassCase superclass;
   90.62 +    private final List<ClassCase> supertypes;
   90.63 +
   90.64 +    private String name;
   90.65 +    private boolean _OK;
   90.66 +    private boolean _HasClassMethod;
   90.67 +    private Set<ClassCase> _mprov;
   90.68 +    private boolean _IsConcrete;
   90.69 +    private boolean _HasDefault;
   90.70 +    private ClassCase _mres;
   90.71 +    private ClassCase _mdefend;
   90.72 +
   90.73 +    private Set<RuleGroup> executed = new HashSet<RuleGroup>() {};
   90.74 +
   90.75 +    public ClassCase(Kind kind, ClassCase superclass, List<ClassCase> interfaces) {
   90.76 +        this.kind = kind;
   90.77 +        this.superclass = superclass;
   90.78 +
   90.79 +        // Set supertypes from superclass (if any) and interfaces
   90.80 +        List<ClassCase> lc;
   90.81 +        if (superclass == null) {
   90.82 +            lc = interfaces;
   90.83 +        } else {
   90.84 +            lc = new ArrayList<>();
   90.85 +            lc.add(superclass);
   90.86 +            lc.addAll(interfaces);
   90.87 +        }
   90.88 +        this.supertypes = lc;
   90.89 +    }
   90.90 +
   90.91 +    public final boolean isInterface() { return kind.isInterface; }
   90.92 +    public final boolean isClass() { return !kind.isInterface; }
   90.93 +
   90.94 +    public Set<ClassCase> get_mprov() {
   90.95 +        exec(RuleGroup.PROVENENCE);
   90.96 +        return _mprov;
   90.97 +    }
   90.98 +
   90.99 +    public void set_mprov(ClassCase cc) {
  90.100 +        Set<ClassCase> s = new HashSet<>();
  90.101 +        s.add(cc);
  90.102 +        _mprov = s;
  90.103 +    }
  90.104 +
  90.105 +    public void set_mprov(Set<ClassCase> s) {
  90.106 +        _mprov = s;
  90.107 +    }
  90.108 +
  90.109 +    public ClassCase get_mres() {
  90.110 +        exec(RuleGroup.RESOLUTION);
  90.111 +        return _mres;
  90.112 +    }
  90.113 +
  90.114 +    public void set_mres(ClassCase cc) {
  90.115 +        _mres = cc;
  90.116 +    }
  90.117 +
  90.118 +    public ClassCase get_mdefend() {
  90.119 +        exec(RuleGroup.DEFENDER);
  90.120 +        return _mdefend;
  90.121 +    }
  90.122 +
  90.123 +    public void set_mdefend(ClassCase cc) {
  90.124 +        _mdefend = cc;
  90.125 +    }
  90.126 +
  90.127 +    public boolean get_HasClassMethod() {
  90.128 +        exec(RuleGroup.PROVENENCE);
  90.129 +        return _HasClassMethod;
  90.130 +    }
  90.131 +
  90.132 +    public void set_HasClassMethod(boolean bool) {
  90.133 +        _HasClassMethod = bool;
  90.134 +    }
  90.135 +
  90.136 +    public boolean get_HasDefault() {
  90.137 +        exec(RuleGroup.MARKER);
  90.138 +        return _HasDefault;
  90.139 +    }
  90.140 +
  90.141 +    public void set_HasDefault(boolean bool) {
  90.142 +        _HasDefault = bool;
  90.143 +    }
  90.144 +
  90.145 +    public boolean get_IsConcrete() {
  90.146 +        exec(RuleGroup.MARKER);
  90.147 +        return _IsConcrete;
  90.148 +    }
  90.149 +
  90.150 +    public void set_IsConcrete(boolean bool) {
  90.151 +        _IsConcrete = bool;
  90.152 +    }
  90.153 +
  90.154 +    public boolean get_OK() {
  90.155 +        exec(RuleGroup.CHECKING);
  90.156 +        return _OK;
  90.157 +    }
  90.158 +
  90.159 +    public void set_OK(boolean bool) {
  90.160 +        _OK = bool;
  90.161 +    }
  90.162 +
  90.163 +    public boolean isMethodDefined() {
  90.164 +        for (ClassCase cc : supertypes) {
  90.165 +            if (cc.isMethodDefined()) {
  90.166 +                return true;
  90.167 +            }
  90.168 +        }
  90.169 +        switch (kind) {
  90.170 +            case CCONCRETE:
  90.171 +            case CABSTRACT:
  90.172 +            case IPRESENT:
  90.173 +            case IDEFAULT:
  90.174 +                return true;
  90.175 +            default:
  90.176 +                return false;
  90.177 +        }
  90.178 +    }
  90.179 +
  90.180 +    public boolean isAbstract() {
  90.181 +        return isMethodDefined() && (get_mres()==null);
  90.182 +    }
  90.183 +
  90.184 +    public boolean hasSuperclass() {
  90.185 +        return superclass != null;
  90.186 +    }
  90.187 +
  90.188 +    public ClassCase getSuperclass() {
  90.189 +        return superclass;
  90.190 +    }
  90.191 +
  90.192 +    public List<ClassCase> getSupertypes() {
  90.193 +        return supertypes;
  90.194 +    }
  90.195 +
  90.196 +    public List<ClassCase> getInterfaces() {
  90.197 +        if (superclass != null) {
  90.198 +            if (supertypes.get(0) != superclass) {
  90.199 +                throw new AssertionError("superclass missing from supertypes");
  90.200 +            }
  90.201 +            return supertypes.subList(1, supertypes.size());
  90.202 +        } else {
  90.203 +            return supertypes;
  90.204 +        }
  90.205 +    }
  90.206 +
  90.207 +    public boolean isSubtypeOf(ClassCase cc) {
  90.208 +        // S-Refl
  90.209 +        if (cc.equals(this)) {
  90.210 +            return true;
  90.211 +        }
  90.212 +
  90.213 +        // S-Def
  90.214 +        for (ClassCase sp : getSupertypes()) {
  90.215 +            if (cc.equals(sp)) {
  90.216 +                return true;
  90.217 +            }
  90.218 +        }
  90.219 +
  90.220 +        // _S-Trans
  90.221 +        for (ClassCase sp : getSupertypes()) {
  90.222 +            if (sp.isSubtypeOf(cc)) {
  90.223 +                return true;
  90.224 +            }
  90.225 +        }
  90.226 +
  90.227 +        return false;
  90.228 +    }
  90.229 +
  90.230 +    public void init(Map<String, Integer> namingContext) {
  90.231 +        if (name != null) {
  90.232 +            return; // Already inited
  90.233 +        }
  90.234 +
  90.235 +        for (ClassCase sup : supertypes) {
  90.236 +            sup.init(namingContext);
  90.237 +        }
  90.238 +
  90.239 +        // Build name
  90.240 +        StringBuilder sb = new StringBuilder();
  90.241 +        if (!supertypes.isEmpty()) {
  90.242 +            sb.append(isInterface() ? "I" : "C");
  90.243 +            for (ClassCase cc : supertypes) {
  90.244 +                sb.append(cc.getName());
  90.245 +            }
  90.246 +            sb.append(kind.isInterface ? "i" : "c");
  90.247 +        }
  90.248 +        sb.append(kind.prefix);
  90.249 +        String pname = sb.toString();
  90.250 +        Integer icnt = namingContext.get(pname);
  90.251 +        int cnt = icnt == null ? 0 : icnt;
  90.252 +        ++cnt;
  90.253 +        namingContext.put(pname, cnt);
  90.254 +        if (cnt > 1) {
  90.255 +            sb.append(cnt);
  90.256 +        }
  90.257 +        this.name = sb.toString();
  90.258 +    }
  90.259 +
  90.260 +    public boolean isa(Kind... kinds) {
  90.261 +        for (Kind k : kinds) {
  90.262 +            if (kind == k) {
  90.263 +                return true;
  90.264 +            }
  90.265 +        }
  90.266 +        return false;
  90.267 +    }
  90.268 +
  90.269 +    private void exec(RuleGroup rg ) {
  90.270 +        if (!executed.contains(rg)) {
  90.271 +            rg.exec(this);
  90.272 +            executed.add(rg);
  90.273 +        }
  90.274 +    }
  90.275 +
  90.276 +    public void collectClasses(Set<ClassCase> seen) {
  90.277 +        seen.add(this);
  90.278 +        for (ClassCase cc : supertypes) {
  90.279 +            cc.collectClasses(seen);
  90.280 +        }
  90.281 +    }
  90.282 +
  90.283 +    public String getID() {
  90.284 +        if (name == null) {
  90.285 +            throw new Error("Access to uninitialized ClassCase");
  90.286 +        } else {
  90.287 +            return name;
  90.288 +        }
  90.289 +    }
  90.290 +
  90.291 +    public final String getName() {
  90.292 +        if (name == null) {
  90.293 +            return "ClassCase uninited@" + hashCode();
  90.294 +        } else {
  90.295 +            return name;
  90.296 +        }
  90.297 +    }
  90.298 +
  90.299 +    @Override
  90.300 +    public boolean equals(Object obj) {
  90.301 +        return obj instanceof ClassCase && getID().equals(((ClassCase)obj).getID());
  90.302 +    }
  90.303 +
  90.304 +    @Override
  90.305 +    public int hashCode() {
  90.306 +        return getID().hashCode();
  90.307 +    }
  90.308 +
  90.309 +    @Override
  90.310 +    public String toString() {
  90.311 +        return getName();
  90.312 +    }
  90.313 +}
    91.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    91.2 +++ b/test/tools/javac/defaultMethods/fd/shapegen/Hierarchy.java	Fri Nov 09 14:47:22 2012 -0800
    91.3 @@ -0,0 +1,143 @@
    91.4 +/*
    91.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    91.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    91.7 + *
    91.8 + * This code is free software; you can redistribute it and/or modify it
    91.9 + * under the terms of the GNU General Public License version 2 only, as
   91.10 + * published by the Free Software Foundation.  Oracle designates this
   91.11 + * particular file as subject to the "Classpath" exception as provided
   91.12 + * by Oracle in the LICENSE file that accompanied this code.
   91.13 + *
   91.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
   91.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   91.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   91.17 + * version 2 for more details (a copy is included in the LICENSE file that
   91.18 + * accompanied this code).
   91.19 + *
   91.20 + * You should have received a copy of the GNU General Public License version
   91.21 + * 2 along with this work; if not, write to the Free Software Foundation,
   91.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   91.23 + *
   91.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   91.25 + * or visit www.oracle.com if you need additional information or have any
   91.26 + * questions.
   91.27 + */
   91.28 +
   91.29 +package shapegen;
   91.30 +
   91.31 +import java.util.List;
   91.32 +import java.util.HashMap;
   91.33 +import java.util.HashSet;
   91.34 +import java.util.Set;
   91.35 +
   91.36 +import static shapegen.ClassCase.Kind.*;
   91.37 +
   91.38 +/**
   91.39 + *
   91.40 + * @author Robert Field
   91.41 + */
   91.42 +public class Hierarchy {
   91.43 +
   91.44 +    public final ClassCase root;
   91.45 +    public final Set<ClassCase> all;
   91.46 +
   91.47 +    public Hierarchy(ClassCase root) {
   91.48 +        this.root = root;
   91.49 +        root.init(new HashMap<String,Integer>());
   91.50 +        Set<ClassCase> allClasses = new HashSet<>();
   91.51 +        root.collectClasses(allClasses);
   91.52 +        this.all = allClasses;
   91.53 +    }
   91.54 +
   91.55 +    public boolean anyDefaults() {
   91.56 +        for (ClassCase cc : all) {
   91.57 +            if (cc.kind == IDEFAULT) {
   91.58 +                return true;
   91.59 +            }
   91.60 +        }
   91.61 +        return false;
   91.62 +    }
   91.63 +
   91.64 +    public boolean get_OK() {
   91.65 +        return root.get_OK();
   91.66 +    }
   91.67 +
   91.68 +    public String testName() {
   91.69 +        return root + "Test";
   91.70 +    }
   91.71 +
   91.72 +    private static void genInterfaceList(StringBuilder buf, String prefix, List<ClassCase> interfaces) {
   91.73 +        if (!interfaces.isEmpty()) {
   91.74 +            buf.append(" ");
   91.75 +            buf.append(prefix);
   91.76 +            buf.append(" ");
   91.77 +            buf.append(interfaces.get(0));
   91.78 +            for (int i = 1; i < interfaces.size(); ++i) {
   91.79 +                buf.append(", " + interfaces.get(i));
   91.80 +            }
   91.81 +        }
   91.82 +    }
   91.83 +
   91.84 +    public static void genClassDef(StringBuilder buf, ClassCase cc, String implClass, List<ClassCase> defaultRef) {
   91.85 +        if (cc.isInterface()) {
   91.86 +            buf.append("interface ");
   91.87 +            buf.append(cc.getName() + " ");
   91.88 +            genInterfaceList(buf, "extends", cc.getInterfaces());
   91.89 +            buf.append(" {\n");
   91.90 +
   91.91 +            switch (cc.kind) {
   91.92 +                case IDEFAULT:
   91.93 +                    buf.append("    default String m() { return \"\"; }\n");
   91.94 +                    defaultRef.add(cc);
   91.95 +                    break;
   91.96 +                case IPRESENT:
   91.97 +                    buf.append("    String m();\n");
   91.98 +                    break;
   91.99 +                case IVAC:
  91.100 +                    break;
  91.101 +                default:
  91.102 +                    throw new AssertionError("Unexpected kind");
  91.103 +            }
  91.104 +            buf.append("}\n\n");
  91.105 +        } else {
  91.106 +            buf.append((cc.isAbstract()? "abstract " : ""));
  91.107 +            buf.append(" class " + cc.getName());
  91.108 +            if (cc.getSuperclass() != null) {
  91.109 +                buf.append(" extends " + cc.getSuperclass());
  91.110 +            }
  91.111 +
  91.112 +            genInterfaceList(buf, "implements", cc.getInterfaces());
  91.113 +            buf.append(" {\n");
  91.114 +
  91.115 +            switch (cc.kind) {
  91.116 +                case CCONCRETE:
  91.117 +                    buf.append("   public String m() { return \"\"; }\n");
  91.118 +                    break;
  91.119 +                case CABSTRACT:
  91.120 +                    buf.append("   public abstract String m();\n");
  91.121 +                    break;
  91.122 +                case CNONE:
  91.123 +                    break;
  91.124 +                default:
  91.125 +                    throw new AssertionError("Unexpected kind");
  91.126 +            }
  91.127 +            buf.append("}\n\n");
  91.128 +        }
  91.129 +    }
  91.130 +
  91.131 +    @Override
  91.132 +    public boolean equals(Object obj) {
  91.133 +        return obj instanceof Hierarchy && root.getID().equals(((Hierarchy)obj).root.getID());
  91.134 +    }
  91.135 +
  91.136 +    @Override
  91.137 +    public int hashCode() {
  91.138 +        return root.getID().hashCode();
  91.139 +    }
  91.140 +
  91.141 +    @Override
  91.142 +    public String toString() {
  91.143 +        return root.getName();
  91.144 +    }
  91.145 +
  91.146 +}
    92.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    92.2 +++ b/test/tools/javac/defaultMethods/fd/shapegen/HierarchyGenerator.java	Fri Nov 09 14:47:22 2012 -0800
    92.3 @@ -0,0 +1,190 @@
    92.4 +/*
    92.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    92.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    92.7 + *
    92.8 + * This code is free software; you can redistribute it and/or modify it
    92.9 + * under the terms of the GNU General Public License version 2 only, as
   92.10 + * published by the Free Software Foundation.  Oracle designates this
   92.11 + * particular file as subject to the "Classpath" exception as provided
   92.12 + * by Oracle in the LICENSE file that accompanied this code.
   92.13 + *
   92.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
   92.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   92.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   92.17 + * version 2 for more details (a copy is included in the LICENSE file that
   92.18 + * accompanied this code).
   92.19 + *
   92.20 + * You should have received a copy of the GNU General Public License version
   92.21 + * 2 along with this work; if not, write to the Free Software Foundation,
   92.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   92.23 + *
   92.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   92.25 + * or visit www.oracle.com if you need additional information or have any
   92.26 + * questions.
   92.27 + */
   92.28 +
   92.29 +package shapegen;
   92.30 +
   92.31 +import shapegen.ClassCase.Kind;
   92.32 +
   92.33 +import java.util.Collection;
   92.34 +import java.util.Set;
   92.35 +import java.util.HashSet;
   92.36 +import java.util.Collections;
   92.37 +import java.util.ArrayList;
   92.38 +import java.util.List;
   92.39 +
   92.40 +import static shapegen.ClassCase.Kind.*;
   92.41 +
   92.42 +import static java.lang.Math.pow;
   92.43 +
   92.44 +/**
   92.45 + *
   92.46 + * @author Robert Field
   92.47 + */
   92.48 +public final class HierarchyGenerator {
   92.49 +
   92.50 +    private static int okcnt = 0;
   92.51 +    private static int errcnt = 0;
   92.52 +    private static Set<Hierarchy> uniqueOK = new HashSet<>();
   92.53 +    private static Set<Hierarchy> uniqueErr = new HashSet<>();
   92.54 +
   92.55 +    /**
   92.56 +     * @param args the command line arguments
   92.57 +     */
   92.58 +    public HierarchyGenerator() {
   92.59 +        organize("exhaustive interface", iExhaustive(2));
   92.60 +        organize("exhaustive class", cExhaustive());
   92.61 +        organize("shapes interface", iShapes());
   92.62 +        organize("shapes class/interface", ciShapes());
   92.63 +
   92.64 +        System.out.printf("\nExpect OK:    %d -- unique %d",   okcnt,  uniqueOK.size());
   92.65 +        System.out.printf("\nExpect Error: %d -- unique %d\n", errcnt, uniqueErr.size());
   92.66 +    }
   92.67 +
   92.68 +    public Collection<Hierarchy> getOK() {
   92.69 +        return uniqueOK;
   92.70 +    }
   92.71 +
   92.72 +    public Collection<Hierarchy> getErr() {
   92.73 +        return uniqueErr;
   92.74 +    }
   92.75 +
   92.76 +    private void organize(String tname, List<Hierarchy> totest) {
   92.77 +        System.out.printf("\nTesting %s....\n", tname);
   92.78 +        int nodefault = 0;
   92.79 +        List<Hierarchy> ok = new ArrayList<>();
   92.80 +        List<Hierarchy> err = new ArrayList<>();
   92.81 +        for (Hierarchy cc : totest) {
   92.82 +            if (cc.anyDefaults()) {
   92.83 +                //System.out.printf("  %s\n", cc);
   92.84 +                if (cc.get_OK()) {
   92.85 +                    ok.add(cc);
   92.86 +                } else {
   92.87 +                    err.add(cc);
   92.88 +                }
   92.89 +            } else {
   92.90 +                ++nodefault;
   92.91 +            }
   92.92 +        }
   92.93 +
   92.94 +        errcnt += err.size();
   92.95 +        okcnt += ok.size();
   92.96 +        uniqueErr.addAll(err);
   92.97 +        uniqueOK.addAll(ok);
   92.98 +
   92.99 +        System.out.printf("  %5d No default\n  %5d Error\n  %5d OK\n  %5d Total\n",
  92.100 +                nodefault, err.size(), ok.size(), totest.size());
  92.101 +    }
  92.102 +
  92.103 +    public List<Hierarchy> iExhaustive(int idepth) {
  92.104 +        List<ClassCase> current = new ArrayList<>();
  92.105 +        for (int i = 0; i < idepth; ++i) {
  92.106 +            current = ilayer(current);
  92.107 +        }
  92.108 +        return wrapInClassAndHierarchy(current);
  92.109 +    }
  92.110 +
  92.111 +    private List<ClassCase> ilayer(List<ClassCase> srcLayer) {
  92.112 +        List<ClassCase> lay = new ArrayList<>();
  92.113 +        for (int i = (int) pow(2, srcLayer.size()) - 1; i >= 0; --i) {
  92.114 +            List<ClassCase> itfs = new ArrayList<>();
  92.115 +            for (int b = srcLayer.size() - 1; b >= 0; --b) {
  92.116 +                if ((i & (1<<b)) != 0) {
  92.117 +                    itfs.add(srcLayer.get(b));
  92.118 +                }
  92.119 +            }
  92.120 +            lay.add(new ClassCase(IVAC, null, itfs));
  92.121 +            lay.add(new ClassCase(IPRESENT, null, itfs));
  92.122 +            lay.add(new ClassCase(IDEFAULT, null, itfs));
  92.123 +            lay.add(new ClassCase(IDEFAULT, null, itfs));
  92.124 +        }
  92.125 +        return lay;
  92.126 +    }
  92.127 +
  92.128 +    public List<Hierarchy> cExhaustive() {
  92.129 +        final Kind[] iKinds = new Kind[]{IDEFAULT, IVAC, IPRESENT, null};
  92.130 +        final Kind[] cKinds = new Kind[]{CNONE, CABSTRACT, CCONCRETE};
  92.131 +        List<Hierarchy> totest = new ArrayList<>();
  92.132 +        for (int i1 = 0; i1 < iKinds.length; ++i1) {
  92.133 +            for (int i2 = 0; i2 < iKinds.length; ++i2) {
  92.134 +                for (int i3 = 0; i3 < iKinds.length; ++i3) {
  92.135 +                    for (int c1 = 0; c1 < cKinds.length; ++c1) {
  92.136 +                        for (int c2 = 0; c2 < cKinds.length; ++c2) {
  92.137 +                            for (int c3 = 0; c3 < cKinds.length; ++c3) {
  92.138 +                                totest.add( new Hierarchy(
  92.139 +                                        new ClassCase(cKinds[c1],
  92.140 +                                            new ClassCase(cKinds[c2],
  92.141 +                                                new ClassCase(cKinds[c3],
  92.142 +                                                    null,
  92.143 +                                                    iList(iKinds[i1])
  92.144 +                                                ),
  92.145 +                                                iList(iKinds[i2])
  92.146 +                                            ),
  92.147 +                                            iList(iKinds[i3])
  92.148 +                                        )));
  92.149 +                            }
  92.150 +                        }
  92.151 +                    }
  92.152 +                }
  92.153 +            }
  92.154 +        }
  92.155 +        return totest;
  92.156 +    }
  92.157 +
  92.158 +    private List<ClassCase> iList(Kind kind) {
  92.159 +        if (kind == null) {
  92.160 +            return Collections.EMPTY_LIST;
  92.161 +        } else {
  92.162 +            List<ClassCase> itfs = new ArrayList<>();
  92.163 +            itfs.add(new ClassCase(kind, null, Collections.EMPTY_LIST));
  92.164 +            return itfs;
  92.165 +        }
  92.166 +    }
  92.167 +
  92.168 +    public List<Hierarchy> ciShapes() {
  92.169 +        return wrapInHierarchy(TTShape.allCases(true));
  92.170 +    }
  92.171 +
  92.172 +    public List<Hierarchy> iShapes() {
  92.173 +        return wrapInClassAndHierarchy(TTShape.allCases(false));
  92.174 +    }
  92.175 +
  92.176 +    public List<Hierarchy> wrapInClassAndHierarchy(List<ClassCase> ihs) {
  92.177 +        List<Hierarchy> totest = new ArrayList<>();
  92.178 +        for (ClassCase cc : ihs) {
  92.179 +            List<ClassCase> interfaces = new ArrayList<>();
  92.180 +            interfaces.add(cc);
  92.181 +            totest.add(new Hierarchy(new ClassCase(CNONE, null, interfaces)));
  92.182 +        }
  92.183 +        return totest;
  92.184 +    }
  92.185 +
  92.186 +    public List<Hierarchy> wrapInHierarchy(List<ClassCase> ihs) {
  92.187 +        List<Hierarchy> totest = new ArrayList<>();
  92.188 +        for (ClassCase cc : ihs) {
  92.189 +            totest.add(new Hierarchy(cc));
  92.190 +        }
  92.191 +        return totest;
  92.192 +    }
  92.193 +}
    93.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    93.2 +++ b/test/tools/javac/defaultMethods/fd/shapegen/Rule.java	Fri Nov 09 14:47:22 2012 -0800
    93.3 @@ -0,0 +1,48 @@
    93.4 +/*
    93.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    93.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    93.7 + *
    93.8 + * This code is free software; you can redistribute it and/or modify it
    93.9 + * under the terms of the GNU General Public License version 2 only, as
   93.10 + * published by the Free Software Foundation.  Oracle designates this
   93.11 + * particular file as subject to the "Classpath" exception as provided
   93.12 + * by Oracle in the LICENSE file that accompanied this code.
   93.13 + *
   93.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
   93.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   93.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   93.17 + * version 2 for more details (a copy is included in the LICENSE file that
   93.18 + * accompanied this code).
   93.19 + *
   93.20 + * You should have received a copy of the GNU General Public License version
   93.21 + * 2 along with this work; if not, write to the Free Software Foundation,
   93.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   93.23 + *
   93.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   93.25 + * or visit www.oracle.com if you need additional information or have any
   93.26 + * questions.
   93.27 + */
   93.28 +
   93.29 +package shapegen;
   93.30 +
   93.31 +/**
   93.32 + *
   93.33 + * @author Robert Field
   93.34 + */
   93.35 +public abstract class Rule {
   93.36 +
   93.37 +    public final String name;
   93.38 +
   93.39 +    public Rule(String name) {
   93.40 +        this.name = name;
   93.41 +    }
   93.42 +
   93.43 +    abstract boolean guard(ClassCase cc);
   93.44 +
   93.45 +    abstract void eval(ClassCase cc);
   93.46 +
   93.47 +    @Override
   93.48 +    public String toString() {
   93.49 +        return name;
   93.50 +    }
   93.51 +}
    94.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    94.2 +++ b/test/tools/javac/defaultMethods/fd/shapegen/RuleGroup.java	Fri Nov 09 14:47:22 2012 -0800
    94.3 @@ -0,0 +1,206 @@
    94.4 +/*
    94.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    94.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    94.7 + *
    94.8 + * This code is free software; you can redistribute it and/or modify it
    94.9 + * under the terms of the GNU General Public License version 2 only, as
   94.10 + * published by the Free Software Foundation.  Oracle designates this
   94.11 + * particular file as subject to the "Classpath" exception as provided
   94.12 + * by Oracle in the LICENSE file that accompanied this code.
   94.13 + *
   94.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
   94.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   94.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   94.17 + * version 2 for more details (a copy is included in the LICENSE file that
   94.18 + * accompanied this code).
   94.19 + *
   94.20 + * You should have received a copy of the GNU General Public License version
   94.21 + * 2 along with this work; if not, write to the Free Software Foundation,
   94.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   94.23 + *
   94.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   94.25 + * or visit www.oracle.com if you need additional information or have any
   94.26 + * questions.
   94.27 + */
   94.28 +
   94.29 +package shapegen;
   94.30 +
   94.31 +import java.util.HashSet;
   94.32 +import java.util.Set;
   94.33 +
   94.34 +import static shapegen.ClassCase.Kind.*;
   94.35 +
   94.36 +/**
   94.37 + *
   94.38 + * @author Robert Field
   94.39 + */
   94.40 +public class RuleGroup {
   94.41 +
   94.42 +    final String name;
   94.43 +    private final Rule[] rules;
   94.44 +
   94.45 +    public RuleGroup(String name, Rule[] rules) {
   94.46 +        this.name = name;
   94.47 +        this.rules = rules;
   94.48 +    }
   94.49 +
   94.50 +    public boolean exec(ClassCase cc) {
   94.51 +        boolean found = false;
   94.52 +        for (Rule rule : rules) {
   94.53 +            if (rule.guard(cc)) {
   94.54 +                if (found) {
   94.55 +                    throw new RuntimeException("Bad rules -- multiple matches " + toString() + " for " + cc);
   94.56 +                } else {
   94.57 +                    rule.eval(cc);
   94.58 +                    found = true;
   94.59 +                }
   94.60 +            }
   94.61 +        }
   94.62 +        return found;
   94.63 +    }
   94.64 +
   94.65 +    @Override
   94.66 +    public String toString() {
   94.67 +        return name;
   94.68 +    }
   94.69 +
   94.70 +    public static RuleGroup PROVENENCE = new RuleGroup("Provenence", new Rule[] {
   94.71 +        new Rule("P-CDeclare") {
   94.72 +            boolean guard(ClassCase cc) {
   94.73 +                return cc.isa(CCONCRETE, CABSTRACT);
   94.74 +            }
   94.75 +
   94.76 +            void eval(ClassCase cc) {
   94.77 +                cc.set_mprov(cc);
   94.78 +                cc.set_HasClassMethod(true);
   94.79 +            }
   94.80 +        },
   94.81 +
   94.82 +        new Rule("P-IDeclare") {
   94.83 +            boolean guard(ClassCase cc) {
   94.84 +                return cc.isa(IDEFAULT, IPRESENT);
   94.85 +            }
   94.86 +
   94.87 +            void eval(ClassCase cc) {
   94.88 +                cc.set_mprov(cc);
   94.89 +            }
   94.90 +        },
   94.91 +
   94.92 +        new Rule("P-IntfInh") {
   94.93 +            boolean guard(ClassCase cc) {
   94.94 +                return cc.isa(IVAC, CNONE) && !(cc.hasSuperclass() && cc.getSuperclass().get_HasClassMethod());
   94.95 +            }
   94.96 +
   94.97 +            void eval(ClassCase cc) {
   94.98 +                Set<ClassCase> _S = new HashSet<>();
   94.99 +                for (ClassCase t : cc.getSupertypes()) {
  94.100 +                    _S.addAll(t.get_mprov());
  94.101 +                }
  94.102 +                Set<ClassCase> tops = new HashSet<>();
  94.103 +                for (ClassCase _W : _S) {
  94.104 +                    for (ClassCase _V : _S) {
  94.105 +                        if (_V.equals(_W) || !(_V.isSubtypeOf(_W))) {
  94.106 +                            tops.add(_W);
  94.107 +                        }
  94.108 +                    }
  94.109 +                }
  94.110 +                cc.set_mprov(tops);
  94.111 +            }
  94.112 +        },
  94.113 +
  94.114 +        new Rule("P-ClassInh") {
  94.115 +            boolean guard(ClassCase cc) {
  94.116 +                return cc.isa(CNONE) && (cc.hasSuperclass() && cc.getSuperclass().get_HasClassMethod());
  94.117 +            }
  94.118 +
  94.119 +            void eval(ClassCase cc) {
  94.120 +                cc.set_mprov(cc.getSuperclass());
  94.121 +                cc.set_HasClassMethod(true);
  94.122 +            }
  94.123 +        },
  94.124 +
  94.125 +    });
  94.126 +
  94.127 +    public static RuleGroup MARKER = new RuleGroup("Marker", new Rule[] {
  94.128 +        new Rule("M-Default") {
  94.129 +            boolean guard(ClassCase cc) {
  94.130 +                return cc.isa(IDEFAULT);
  94.131 +            }
  94.132 +
  94.133 +            void eval(ClassCase cc) {
  94.134 +                cc.set_HasDefault(true);
  94.135 +            }
  94.136 +        },
  94.137 +
  94.138 +        new Rule("M-Conc") {
  94.139 +            boolean guard(ClassCase cc) {
  94.140 +              return cc.isa(CCONCRETE);
  94.141 +            }
  94.142 +
  94.143 +            void eval(ClassCase cc) {
  94.144 +                cc.set_IsConcrete(true);
  94.145 +            }
  94.146 +        },
  94.147 +
  94.148 +    });
  94.149 +
  94.150 +    public static RuleGroup RESOLUTION = new RuleGroup("Resolution", new Rule[] {
  94.151 +        new Rule("R-Resolve") {
  94.152 +            boolean guard(ClassCase cc) {
  94.153 +                if (!(cc.isClass() && cc.get_mprov().size() == 1)) {
  94.154 +                    return false;
  94.155 +                }
  94.156 +                ClassCase _V = cc.get_mprov().iterator().next();
  94.157 +                return _V.get_IsConcrete() || _V.get_HasDefault();
  94.158 +            }
  94.159 +
  94.160 +            void eval(ClassCase cc) {
  94.161 +                ClassCase _V = cc.get_mprov().iterator().next();
  94.162 +                cc.set_mres(_V);
  94.163 +            }
  94.164 +        },
  94.165 +
  94.166 +    });
  94.167 +
  94.168 +    public static RuleGroup DEFENDER = new RuleGroup("Defender", new Rule[] {
  94.169 +        new Rule("D-Defend") {
  94.170 +            boolean guard(ClassCase cc) {
  94.171 +                ClassCase mresSuper = cc.hasSuperclass() ? cc.getSuperclass().get_mres() : null;
  94.172 +                boolean eq = cc.get_mres() == null ? mresSuper == null : cc.get_mres().equals(mresSuper);
  94.173 +                return cc.isa(CNONE) && !eq;
  94.174 +            }
  94.175 +
  94.176 +            void eval(ClassCase cc) {
  94.177 +                cc.set_mdefend(cc.get_mres());
  94.178 +            }
  94.179 +        },
  94.180 +
  94.181 +    });
  94.182 +
  94.183 +    public static RuleGroup CHECKING = new RuleGroup("Checking", new Rule[] {
  94.184 +        new Rule("C-Check") {
  94.185 +            boolean guard(ClassCase cc) {
  94.186 +                for (ClassCase t : cc.getSupertypes()) {
  94.187 +                    if (! t.get_OK()) {
  94.188 +                        return false;
  94.189 +                    }
  94.190 +                }
  94.191 +                int defenderCount = 0;
  94.192 +                int provCount = 0;
  94.193 +                for (ClassCase prov : cc.get_mprov()) {
  94.194 +                    if (prov.get_HasDefault()) {
  94.195 +                        defenderCount++;
  94.196 +                    }
  94.197 +                    provCount++;
  94.198 +                }
  94.199 +                return provCount <= 1 || defenderCount == 0;
  94.200 +            }
  94.201 +
  94.202 +            void eval(ClassCase cc) {
  94.203 +                cc.set_OK(true);
  94.204 +            }
  94.205 +        },
  94.206 +
  94.207 +    });
  94.208 +
  94.209 +}
    95.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    95.2 +++ b/test/tools/javac/defaultMethods/fd/shapegen/TTNode.java	Fri Nov 09 14:47:22 2012 -0800
    95.3 @@ -0,0 +1,126 @@
    95.4 +/*
    95.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    95.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    95.7 + *
    95.8 + * This code is free software; you can redistribute it and/or modify it
    95.9 + * under the terms of the GNU General Public License version 2 only, as
   95.10 + * published by the Free Software Foundation.  Oracle designates this
   95.11 + * particular file as subject to the "Classpath" exception as provided
   95.12 + * by Oracle in the LICENSE file that accompanied this code.
   95.13 + *
   95.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
   95.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   95.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   95.17 + * version 2 for more details (a copy is included in the LICENSE file that
   95.18 + * accompanied this code).
   95.19 + *
   95.20 + * You should have received a copy of the GNU General Public License version
   95.21 + * 2 along with this work; if not, write to the Free Software Foundation,
   95.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   95.23 + *
   95.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   95.25 + * or visit www.oracle.com if you need additional information or have any
   95.26 + * questions.
   95.27 + */
   95.28 +
   95.29 +package shapegen;
   95.30 +
   95.31 +import shapegen.ClassCase.Kind;
   95.32 +
   95.33 +import java.util.ArrayList;
   95.34 +import java.util.List;
   95.35 +import java.util.Set;
   95.36 +
   95.37 +import static shapegen.ClassCase.Kind.*;
   95.38 +
   95.39 +/**
   95.40 + * Type Template Node
   95.41 + *
   95.42 + * @author Robert Field
   95.43 + */
   95.44 +public class TTNode {
   95.45 +
   95.46 +    final List<TTNode> supertypes;
   95.47 +    final boolean canBeClass;
   95.48 +
   95.49 +    private int currentKindIndex;
   95.50 +    private Kind[] kinds;
   95.51 +
   95.52 +    public TTNode(List<TTNode> subtypes, boolean canBeClass) {
   95.53 +        this.supertypes = subtypes;
   95.54 +        this.canBeClass = canBeClass;
   95.55 +    }
   95.56 +
   95.57 +    public void start(boolean includeClasses) {
   95.58 +        kinds =
   95.59 +             supertypes.isEmpty()?
   95.60 +                (new Kind[]{IDEFAULT, IPRESENT})
   95.61 +             :  ((includeClasses && canBeClass)?
   95.62 +                  new Kind[]{CNONE, IVAC, IDEFAULT, IPRESENT}
   95.63 +                : new Kind[]{IVAC, IDEFAULT, IPRESENT});
   95.64 +        currentKindIndex = 0;
   95.65 +
   95.66 +        for (TTNode sub : supertypes) {
   95.67 +            sub.start(includeClasses);
   95.68 +        }
   95.69 +    }
   95.70 +
   95.71 +    public boolean next() {
   95.72 +        ++currentKindIndex;
   95.73 +        if (currentKindIndex >= kinds.length) {
   95.74 +            currentKindIndex = 0;
   95.75 +            return false;
   95.76 +        } else {
   95.77 +            return true;
   95.78 +        }
   95.79 +    }
   95.80 +
   95.81 +    public void collectAllSubtypes(Set<TTNode> subs) {
   95.82 +        subs.add(this);
   95.83 +        for (TTNode n : supertypes) {
   95.84 +            n.collectAllSubtypes(subs);
   95.85 +        }
   95.86 +    }
   95.87 +
   95.88 +    private Kind getKind() {
   95.89 +        return kinds[currentKindIndex];
   95.90 +    }
   95.91 +
   95.92 +    boolean isInterface() {
   95.93 +        return getKind().isInterface;
   95.94 +    }
   95.95 +
   95.96 +    boolean isClass() {
   95.97 +        return !isInterface();
   95.98 +    }
   95.99 +
  95.100 +    boolean hasDefault() {
  95.101 +        return getKind() == IDEFAULT;
  95.102 +    }
  95.103 +
  95.104 +    public boolean isValid() {
  95.105 +        for (TTNode n : supertypes) {
  95.106 +            if (!n.isValid() || (isInterface() && n.isClass())) {
  95.107 +                return false;
  95.108 +            }
  95.109 +        }
  95.110 +        return true;
  95.111 +    }
  95.112 +
  95.113 +    public ClassCase genCase() {
  95.114 +        ClassCase subclass;
  95.115 +        List<TTNode> ttintfs;
  95.116 +        if (isClass() && !supertypes.isEmpty() && supertypes.get(0).isClass()) {
  95.117 +            subclass = supertypes.get(0).genCase();
  95.118 +            ttintfs = supertypes.subList(1, supertypes.size());
  95.119 +        } else {
  95.120 +            subclass = null;
  95.121 +            ttintfs = supertypes;
  95.122 +        }
  95.123 +        List<ClassCase> intfs = new ArrayList<>();
  95.124 +        for (TTNode node : ttintfs) {
  95.125 +            intfs.add(node.genCase());
  95.126 +        }
  95.127 +        return new ClassCase(getKind(), subclass, intfs);
  95.128 +    }
  95.129 +}
    96.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    96.2 +++ b/test/tools/javac/defaultMethods/fd/shapegen/TTParser.java	Fri Nov 09 14:47:22 2012 -0800
    96.3 @@ -0,0 +1,100 @@
    96.4 +/*
    96.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    96.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    96.7 + *
    96.8 + * This code is free software; you can redistribute it and/or modify it
    96.9 + * under the terms of the GNU General Public License version 2 only, as
   96.10 + * published by the Free Software Foundation.  Oracle designates this
   96.11 + * particular file as subject to the "Classpath" exception as provided
   96.12 + * by Oracle in the LICENSE file that accompanied this code.
   96.13 + *
   96.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
   96.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   96.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   96.17 + * version 2 for more details (a copy is included in the LICENSE file that
   96.18 + * accompanied this code).
   96.19 + *
   96.20 + * You should have received a copy of the GNU General Public License version
   96.21 + * 2 along with this work; if not, write to the Free Software Foundation,
   96.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   96.23 + *
   96.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   96.25 + * or visit www.oracle.com if you need additional information or have any
   96.26 + * questions.
   96.27 + */
   96.28 +
   96.29 +package shapegen;
   96.30 +
   96.31 +import java.util.ArrayList;
   96.32 +import java.util.HashMap;
   96.33 +import java.util.List;
   96.34 +import java.util.Map;
   96.35 +import java.io.IOException;
   96.36 +import java.io.StringReader;
   96.37 +
   96.38 +import static java.lang.Character.isLetter;
   96.39 +import static java.lang.Character.isUpperCase;
   96.40 +import static java.lang.Character.isWhitespace;
   96.41 +
   96.42 +/**
   96.43 + * Parse a type template definition string
   96.44 + *
   96.45 + *   input     :: classDef
   96.46 + *   classDef  :: letter [ ( classDef* ) ]
   96.47 + *
   96.48 + * @author Robert Field
   96.49 + */
   96.50 +public class TTParser extends StringReader {
   96.51 +
   96.52 +    private Map<Character, TTNode> letterMap = new HashMap<>();
   96.53 +    private char ch;
   96.54 +
   96.55 +    private final String def;
   96.56 +
   96.57 +    public TTParser(String s) {
   96.58 +        super(s);
   96.59 +        this.def = s;
   96.60 +    }
   96.61 +
   96.62 +    private void advance() throws IOException {
   96.63 +        do {
   96.64 +            ch = (char)read();
   96.65 +        } while (isWhitespace(ch));
   96.66 +    }
   96.67 +
   96.68 +    public TTNode parse() {
   96.69 +        try {
   96.70 +            advance();
   96.71 +            return classDef();
   96.72 +        } catch (IOException t) {
   96.73 +            throw new RuntimeException(t);
   96.74 +        }
   96.75 +    }
   96.76 +
   96.77 +    private TTNode classDef() throws IOException {
   96.78 +        if (!isLetter(ch)) {
   96.79 +            if (ch == (char)-1) {
   96.80 +                throw new IOException("Unexpected end of type template in " + def);
   96.81 +            } else {
   96.82 +                throw new IOException("Unexpected character in type template: " + (Character)ch + " in " + def);
   96.83 +            }
   96.84 +        }
   96.85 +        char nodeCh = ch;
   96.86 +        TTNode node = letterMap.get(nodeCh);
   96.87 +        boolean canBeClass = isUpperCase(nodeCh);
   96.88 +        advance();
   96.89 +        if (node == null) {
   96.90 +            List<TTNode> subtypes = new ArrayList<>();
   96.91 +            if (ch == '(') {
   96.92 +                advance();
   96.93 +                while (ch != ')') {
   96.94 +                    subtypes.add(classDef());
   96.95 +                }
   96.96 +                advance();
   96.97 +            }
   96.98 +            node = new TTNode(subtypes, canBeClass);
   96.99 +            letterMap.put(nodeCh, node);
  96.100 +        }
  96.101 +        return node;
  96.102 +    }
  96.103 +}
    97.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    97.2 +++ b/test/tools/javac/defaultMethods/fd/shapegen/TTShape.java	Fri Nov 09 14:47:22 2012 -0800
    97.3 @@ -0,0 +1,104 @@
    97.4 +/*
    97.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    97.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    97.7 + *
    97.8 + * This code is free software; you can redistribute it and/or modify it
    97.9 + * under the terms of the GNU General Public License version 2 only, as
   97.10 + * published by the Free Software Foundation.  Oracle designates this
   97.11 + * particular file as subject to the "Classpath" exception as provided
   97.12 + * by Oracle in the LICENSE file that accompanied this code.
   97.13 + *
   97.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
   97.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   97.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   97.17 + * version 2 for more details (a copy is included in the LICENSE file that
   97.18 + * accompanied this code).
   97.19 + *
   97.20 + * You should have received a copy of the GNU General Public License version
   97.21 + * 2 along with this work; if not, write to the Free Software Foundation,
   97.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   97.23 + *
   97.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   97.25 + * or visit www.oracle.com if you need additional information or have any
   97.26 + * questions.
   97.27 + */
   97.28 +
   97.29 +package shapegen;
   97.30 +
   97.31 +import java.util.ArrayList;
   97.32 +import java.util.HashSet;
   97.33 +import java.util.List;
   97.34 +import java.util.Set;
   97.35 +
   97.36 +/**
   97.37 + *
   97.38 + * @author Robert Field
   97.39 + */
   97.40 +public class TTShape {
   97.41 +
   97.42 +    private final TTNode root;
   97.43 +    private final TTNode[] nodes;
   97.44 +
   97.45 +    TTShape(TTNode root) {
   97.46 +        this.root = root;
   97.47 +        Set<TTNode> subs = new HashSet<>();
   97.48 +        root.collectAllSubtypes(subs);
   97.49 +        nodes = subs.toArray(new TTNode[subs.size()]);
   97.50 +    }
   97.51 +
   97.52 +    private List<ClassCase> toCases(boolean includeClasses) {
   97.53 +        List<ClassCase> ccs = new ArrayList<>();
   97.54 +        root.start(includeClasses);
   97.55 +        int i;
   97.56 +        outer:
   97.57 +        while (true) {
   97.58 +            if (root.isValid()) {
   97.59 +                ClassCase cc = root.genCase();
   97.60 +                //System.out.println(cc);
   97.61 +                ccs.add(cc);
   97.62 +            }
   97.63 +
   97.64 +            i = 0;
   97.65 +            do {
   97.66 +                if (i >= nodes.length) {
   97.67 +                    break outer;
   97.68 +                }
   97.69 +            } while(!nodes[i++].next());
   97.70 +        }
   97.71 +        return ccs;
   97.72 +    }
   97.73 +
   97.74 +   public static List<ClassCase> allCases(boolean includeClasses) {
   97.75 +        List<ClassCase> ccs = new ArrayList<>();
   97.76 +        for (TTShape shape : SHAPES) {
   97.77 +            ccs.addAll(shape.toCases(includeClasses));
   97.78 +        }
   97.79 +        return ccs;
   97.80 +    }
   97.81 +
   97.82 +    public static TTShape parse(String s) {
   97.83 +        return new TTShape(new TTParser(s).parse());
   97.84 +    }
   97.85 +
   97.86 +    public static final TTShape[] SHAPES = new TTShape[] {
   97.87 +        parse("a"),
   97.88 +        parse("a(b)"),
   97.89 +        parse("A(bb)"),
   97.90 +        parse("A(B(d)c(d))"),
   97.91 +        parse("A(b(c))"),
   97.92 +        parse("A(B(cd)d)"),
   97.93 +        parse("A(B(c)c)"),
   97.94 +        parse("A(B(Ce)d(e))"),
   97.95 +        parse("A(B(C)d(e))"),
   97.96 +        parse("A(Bc(d))"),
   97.97 +        parse("A(B(d)dc)"),
   97.98 +        parse("A(B(dc)dc)"),
   97.99 +        parse("A(B(c(d))d)"),
  97.100 +        parse("A(B(C(d))d)"),
  97.101 +        parse("A(B(C(e)d(e))e)"),
  97.102 +        parse("A(B(c(d))c)"),
  97.103 +        parse("A(B(dc(d))c)"),
  97.104 +        parse("A(B(C(d))d)"),
  97.105 +    };
  97.106 +
  97.107 +}
    98.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    98.2 +++ b/test/tools/javac/defaultMethods/separate/Separate.java	Fri Nov 09 14:47:22 2012 -0800
    98.3 @@ -0,0 +1,40 @@
    98.4 +/*
    98.5 + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
    98.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    98.7 + *
    98.8 + * This code is free software; you can redistribute it and/or modify it
    98.9 + * under the terms of the GNU General Public License version 2 only, as
   98.10 + * published by the Free Software Foundation.
   98.11 + *
   98.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   98.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   98.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   98.15 + * version 2 for more details (a copy is included in the LICENSE file that
   98.16 + * accompanied this code).
   98.17 + *
   98.18 + * You should have received a copy of the GNU General Public License version
   98.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   98.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   98.21 + *
   98.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   98.23 + * or visit www.oracle.com if you need additional information or have any
   98.24 + * questions.
   98.25 + */
   98.26 +
   98.27 +/*
   98.28 + * @test
   98.29 + * @summary smoke test for separate compilation of default methods
   98.30 + * @author  Maurizio Cimadamore
   98.31 + * @compile -XDallowDefaultMethods pkg1/A.java
   98.32 + * @compile -XDallowDefaultMethods Separate.java
   98.33 + */
   98.34 +
   98.35 +import pkg1.A;
   98.36 +
   98.37 +class Separate {
   98.38 +    interface B extends A.I {
   98.39 +        default void m() { A.m(this); }
   98.40 +    }
   98.41 +
   98.42 +    interface C extends A.I, B { }
   98.43 +}
    99.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    99.2 +++ b/test/tools/javac/defaultMethods/separate/pkg1/A.java	Fri Nov 09 14:47:22 2012 -0800
    99.3 @@ -0,0 +1,32 @@
    99.4 +/*
    99.5 + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
    99.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    99.7 + *
    99.8 + * This code is free software; you can redistribute it and/or modify it
    99.9 + * under the terms of the GNU General Public License version 2 only, as
   99.10 + * published by the Free Software Foundation.
   99.11 + *
   99.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   99.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   99.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   99.15 + * version 2 for more details (a copy is included in the LICENSE file that
   99.16 + * accompanied this code).
   99.17 + *
   99.18 + * You should have received a copy of the GNU General Public License version
   99.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   99.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   99.21 + *
   99.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   99.23 + * or visit www.oracle.com if you need additional information or have any
   99.24 + * questions.
   99.25 + */
   99.26 +
   99.27 +package pkg1;
   99.28 +
   99.29 +public class A {
   99.30 +    public interface I {
   99.31 +        default void m() { A.m(this); }
   99.32 +    }
   99.33 +
   99.34 +    public static void m(Object o) {}
   99.35 +}
   100.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   100.2 +++ b/test/tools/javac/defaultMethods/super/TestDefaultSuperCall.java	Fri Nov 09 14:47:22 2012 -0800
   100.3 @@ -0,0 +1,406 @@
   100.4 +/*
   100.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
   100.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   100.7 + *
   100.8 + * This code is free software; you can redistribute it and/or modify it
   100.9 + * under the terms of the GNU General Public License version 2 only, as
  100.10 + * published by the Free Software Foundation.
  100.11 + *
  100.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
  100.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  100.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  100.15 + * version 2 for more details (a copy is included in the LICENSE file that
  100.16 + * accompanied this code).
  100.17 + *
  100.18 + * You should have received a copy of the GNU General Public License version
  100.19 + * 2 along with this work; if not, write to the Free Software Foundation,
  100.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  100.21 + *
  100.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  100.23 + * or visit www.oracle.com if you need additional information or have any
  100.24 + * questions.
  100.25 + */
  100.26 +
  100.27 +/*
  100.28 + * @test
  100.29 + * @summary Automatic test for checking correctness of default super/this resolution
  100.30 + */
  100.31 +
  100.32 +import com.sun.source.util.JavacTask;
  100.33 +import java.net.URI;
  100.34 +import java.util.Arrays;
  100.35 +import java.util.ArrayList;
  100.36 +import java.util.List;
  100.37 +import java.util.Locale;
  100.38 +import java.util.Map;
  100.39 +import javax.tools.Diagnostic;
  100.40 +import javax.tools.JavaCompiler;
  100.41 +import javax.tools.JavaFileObject;
  100.42 +import javax.tools.SimpleJavaFileObject;
  100.43 +import javax.tools.StandardJavaFileManager;
  100.44 +import javax.tools.ToolProvider;
  100.45 +
  100.46 +public class TestDefaultSuperCall {
  100.47 +
  100.48 +    static int checkCount = 0;
  100.49 +
  100.50 +    enum InterfaceKind {
  100.51 +        DEFAULT("interface A extends B { default void m() { } }"),
  100.52 +        ABSTRACT("interface A extends B { void m(); }"),
  100.53 +        NONE("interface A extends B { }");
  100.54 +
  100.55 +        String interfaceStr;
  100.56 +
  100.57 +        InterfaceKind(String interfaceStr) {
  100.58 +            this.interfaceStr = interfaceStr;
  100.59 +        }
  100.60 +
  100.61 +        boolean methodDefined() {
  100.62 +            return this == DEFAULT;
  100.63 +        }
  100.64 +    }
  100.65 +
  100.66 +    enum PruneKind {
  100.67 +        NO_PRUNE("interface C { }"),
  100.68 +        PRUNE("interface C extends A { }");
  100.69 +
  100.70 +        boolean methodDefined(InterfaceKind ik) {
  100.71 +            return this == PRUNE &&
  100.72 +                    ik.methodDefined();
  100.73 +        }
  100.74 +
  100.75 +        String interfaceStr;
  100.76 +
  100.77 +        PruneKind(String interfaceStr) {
  100.78 +            this.interfaceStr = interfaceStr;
  100.79 +        }
  100.80 +    }
  100.81 +
  100.82 +    enum QualifierKind {
  100.83 +        DIRECT_1("C"),
  100.84 +        DIRECT_2("A"),
  100.85 +        INDIRECT("B"),
  100.86 +        UNRELATED("E"),
  100.87 +        ENCLOSING_1(null),
  100.88 +        ENCLOSING_2(null);
  100.89 +
  100.90 +        String qualifierStr;
  100.91 +
  100.92 +        QualifierKind(String qualifierStr) {
  100.93 +            this.qualifierStr = qualifierStr;
  100.94 +        }
  100.95 +
  100.96 +        String getQualifier(Shape sh) {
  100.97 +            switch (this) {
  100.98 +                case ENCLOSING_1: return sh.enclosingAt(0);
  100.99 +                case ENCLOSING_2: return sh.enclosingAt(1);
 100.100 +                default:
 100.101 +                    return qualifierStr;
 100.102 +            }
 100.103 +        }
 100.104 +
 100.105 +        boolean isEnclosing() {
 100.106 +            return this == ENCLOSING_1 ||
 100.107 +                    this == ENCLOSING_2;
 100.108 +        }
 100.109 +
 100.110 +        boolean allowSuperCall(InterfaceKind ik, PruneKind pk) {
 100.111 +            switch (this) {
 100.112 +                case DIRECT_1:
 100.113 +                    return pk.methodDefined(ik);
 100.114 +                case DIRECT_2:
 100.115 +                    return ik.methodDefined() && pk == PruneKind.NO_PRUNE;
 100.116 +                default:
 100.117 +                    return false;
 100.118 +            }
 100.119 +        }
 100.120 +    }
 100.121 +
 100.122 +    enum ExprKind {
 100.123 +        THIS("this"),
 100.124 +        SUPER("super");
 100.125 +
 100.126 +        String exprStr;
 100.127 +
 100.128 +        ExprKind(String exprStr) {
 100.129 +            this.exprStr = exprStr;
 100.130 +        }
 100.131 +    }
 100.132 +
 100.133 +    enum ElementKind {
 100.134 +        INTERFACE("interface #N { #B }", true),
 100.135 +        INTERFACE_EXTENDS("interface #N extends A, C { #B }", true),
 100.136 +        CLASS("class #N { #B }", false),
 100.137 +        CLASS_EXTENDS("abstract class #N implements A, C { #B }", false),
 100.138 +        STATIC_CLASS("static class #N { #B }", true),
 100.139 +        STATIC_CLASS_EXTENDS("abstract static class #N implements A, C { #B }", true),
 100.140 +        ANON_CLASS("new Object() { #B };", false),
 100.141 +        METHOD("void test() { #B }", false),
 100.142 +        STATIC_METHOD("static void test() { #B }", true),
 100.143 +        DEFAULT_METHOD("default void test() { #B }", false);
 100.144 +
 100.145 +        String templateDecl;
 100.146 +        boolean isStatic;
 100.147 +
 100.148 +        ElementKind(String templateDecl, boolean isStatic) {
 100.149 +            this.templateDecl = templateDecl;
 100.150 +            this.isStatic = isStatic;
 100.151 +        }
 100.152 +
 100.153 +        boolean isClassDecl() {
 100.154 +            switch(this) {
 100.155 +                case METHOD:
 100.156 +                case STATIC_METHOD:
 100.157 +                case DEFAULT_METHOD:
 100.158 +                    return false;
 100.159 +                default:
 100.160 +                    return true;
 100.161 +            }
 100.162 +        }
 100.163 +
 100.164 +        boolean isAllowedEnclosing(ElementKind ek, boolean isTop) {
 100.165 +            switch (this) {
 100.166 +                case CLASS:
 100.167 +                case CLASS_EXTENDS:
 100.168 +                    //class is implicitly static inside interface, so skip this combo
 100.169 +                    return ek.isClassDecl() &&
 100.170 +                            ek != INTERFACE && ek != INTERFACE_EXTENDS;
 100.171 +                case ANON_CLASS:
 100.172 +                    return !ek.isClassDecl();
 100.173 +                case METHOD:
 100.174 +                    return ek == CLASS || ek == CLASS_EXTENDS ||
 100.175 +                            ek == STATIC_CLASS || ek == STATIC_CLASS_EXTENDS ||
 100.176 +                            ek == ANON_CLASS;
 100.177 +                case INTERFACE:
 100.178 +                case INTERFACE_EXTENDS:
 100.179 +                case STATIC_CLASS:
 100.180 +                case STATIC_CLASS_EXTENDS:
 100.181 +                case STATIC_METHOD:
 100.182 +                    return (isTop && (ek == CLASS || ek == CLASS_EXTENDS)) ||
 100.183 +                            ek == STATIC_CLASS || ek == STATIC_CLASS_EXTENDS;
 100.184 +                case DEFAULT_METHOD:
 100.185 +                    return ek == INTERFACE || ek == INTERFACE_EXTENDS;
 100.186 +                default:
 100.187 +                    throw new AssertionError("Bad enclosing element kind" + this);
 100.188 +            }
 100.189 +        }
 100.190 +
 100.191 +        boolean isAllowedTop() {
 100.192 +            switch (this) {
 100.193 +                case CLASS:
 100.194 +                case CLASS_EXTENDS:
 100.195 +                case INTERFACE:
 100.196 +                case INTERFACE_EXTENDS:
 100.197 +                    return true;
 100.198 +                default:
 100.199 +                    return false;
 100.200 +            }
 100.201 +        }
 100.202 +
 100.203 +        boolean hasSuper() {
 100.204 +            return this == INTERFACE_EXTENDS ||
 100.205 +                    this == STATIC_CLASS_EXTENDS ||
 100.206 +                    this == CLASS_EXTENDS;
 100.207 +        }
 100.208 +    }
 100.209 +
 100.210 +    static class Shape {
 100.211 +
 100.212 +        String shapeStr;
 100.213 +        List<ElementKind> enclosingElements;
 100.214 +        List<String> enclosingNames;
 100.215 +        List<String> elementsWithMethod;
 100.216 +
 100.217 +        Shape(ElementKind... elements) {
 100.218 +            System.err.println("elements = " + Arrays.toString(elements));
 100.219 +            enclosingElements = new ArrayList<>();
 100.220 +            enclosingNames = new ArrayList<>();
 100.221 +            elementsWithMethod = new ArrayList<>();
 100.222 +            int count = 0;
 100.223 +            String prevName = null;
 100.224 +            for (ElementKind ek : elements) {
 100.225 +                String name = "name"+count++;
 100.226 +                if (ek.isStatic) {
 100.227 +                    enclosingElements = new ArrayList<>();
 100.228 +                    enclosingNames = new ArrayList<>();
 100.229 +                }
 100.230 +                if (ek.isClassDecl()) {
 100.231 +                    enclosingElements.add(ek);
 100.232 +                    enclosingNames.add(name);
 100.233 +                } else {
 100.234 +                    elementsWithMethod.add(prevName);
 100.235 +                }
 100.236 +                String element = ek.templateDecl.replaceAll("#N", name);
 100.237 +                shapeStr = shapeStr == null ? element : shapeStr.replaceAll("#B", element);
 100.238 +                prevName = name;
 100.239 +            }
 100.240 +        }
 100.241 +
 100.242 +        String getShape(QualifierKind qk, ExprKind ek) {
 100.243 +            String methName = ek == ExprKind.THIS ? "test" : "m";
 100.244 +            String call = qk.getQualifier(this) + "." + ek.exprStr + "." + methName + "();";
 100.245 +            return shapeStr.replaceAll("#B", call);
 100.246 +        }
 100.247 +
 100.248 +        String enclosingAt(int index) {
 100.249 +            return index < enclosingNames.size() ? enclosingNames.get(index) : "BAD";
 100.250 +        }
 100.251 +    }
 100.252 +
 100.253 +    public static void main(String... args) throws Exception {
 100.254 +
 100.255 +        //create default shared JavaCompiler - reused across multiple compilations
 100.256 +        JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
 100.257 +        StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
 100.258 +
 100.259 +        for (InterfaceKind ik : InterfaceKind.values()) {
 100.260 +            for (PruneKind pk : PruneKind.values()) {
 100.261 +                for (ElementKind ek1 : ElementKind.values()) {
 100.262 +                    if (!ek1.isAllowedTop()) continue;
 100.263 +                    for (ElementKind ek2 : ElementKind.values()) {
 100.264 +                        if (!ek2.isAllowedEnclosing(ek1, true)) continue;
 100.265 +                        for (ElementKind ek3 : ElementKind.values()) {
 100.266 +                            if (!ek3.isAllowedEnclosing(ek2, false)) continue;
 100.267 +                            for (ElementKind ek4 : ElementKind.values()) {
 100.268 +                                if (!ek4.isAllowedEnclosing(ek3, false)) continue;
 100.269 +                                for (ElementKind ek5 : ElementKind.values()) {
 100.270 +                                    if (!ek5.isAllowedEnclosing(ek4, false) || ek5.isClassDecl()) continue;
 100.271 +                                    for (QualifierKind qk : QualifierKind.values()) {
 100.272 +                                        for (ExprKind ek : ExprKind.values()) {
 100.273 +                                            new TestDefaultSuperCall(ik, pk, new Shape(ek1, ek2, ek3, ek4, ek5), qk, ek).run(comp, fm);
 100.274 +                                        }
 100.275 +                                    }
 100.276 +                                }
 100.277 +                            }
 100.278 +                        }
 100.279 +                    }
 100.280 +                }
 100.281 +            }
 100.282 +        }
 100.283 +        System.out.println("Total check executed: " + checkCount);
 100.284 +    }
 100.285 +
 100.286 +    InterfaceKind ik;
 100.287 +    PruneKind pk;
 100.288 +    Shape sh;
 100.289 +    QualifierKind qk;
 100.290 +    ExprKind ek;
 100.291 +    JavaSource source;
 100.292 +    DiagnosticChecker diagChecker;
 100.293 +
 100.294 +    TestDefaultSuperCall(InterfaceKind ik, PruneKind pk, Shape sh, QualifierKind qk, ExprKind ek) {
 100.295 +        this.ik = ik;
 100.296 +        this.pk = pk;
 100.297 +        this.sh = sh;
 100.298 +        this.qk = qk;
 100.299 +        this.ek = ek;
 100.300 +        this.source = new JavaSource();
 100.301 +        this.diagChecker = new DiagnosticChecker();
 100.302 +    }
 100.303 +
 100.304 +    class JavaSource extends SimpleJavaFileObject {
 100.305 +
 100.306 +        String template = "interface E {}\n" +
 100.307 +                          "interface B { }\n" +
 100.308 +                          "#I\n" +
 100.309 +                          "#P\n" +
 100.310 +                          "#C";
 100.311 +
 100.312 +        String source;
 100.313 +
 100.314 +        public JavaSource() {
 100.315 +            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
 100.316 +            source = template.replaceAll("#I", ik.interfaceStr)
 100.317 +                    .replaceAll("#P", pk.interfaceStr)
 100.318 +                    .replaceAll("#C", sh.getShape(qk, ek));
 100.319 +        }
 100.320 +
 100.321 +        @Override
 100.322 +        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
 100.323 +            return source;
 100.324 +        }
 100.325 +    }
 100.326 +
 100.327 +    void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception {
 100.328 +        JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker,
 100.329 +                Arrays.asList("-XDallowDefaultMethods"), null, Arrays.asList(source));
 100.330 +        try {
 100.331 +            ct.analyze();
 100.332 +        } catch (Throwable ex) {
 100.333 +            throw new AssertionError("Error thrown when analyzing the following source:\n" + source.getCharContent(true));
 100.334 +        }
 100.335 +        check();
 100.336 +    }
 100.337 +
 100.338 +    void check() {
 100.339 +        boolean errorExpected = false;
 100.340 +
 100.341 +        boolean badEnclosing = false;
 100.342 +        boolean badThis = false;
 100.343 +        boolean badSuper = false;
 100.344 +
 100.345 +        if (qk == QualifierKind.ENCLOSING_1 &&
 100.346 +                sh.enclosingNames.size() < 1) {
 100.347 +            errorExpected |= true;
 100.348 +            badEnclosing = true;
 100.349 +        }
 100.350 +
 100.351 +        if (qk == QualifierKind.ENCLOSING_2 &&
 100.352 +                sh.enclosingNames.size() < 2) {
 100.353 +            errorExpected |= true;
 100.354 +            badEnclosing = true;
 100.355 +        }
 100.356 +
 100.357 +        if (ek == ExprKind.THIS) {
 100.358 +            boolean found = false;
 100.359 +            for (int i = 0; i < sh.enclosingElements.size(); i++) {
 100.360 +                if (sh.enclosingElements.get(i) == ElementKind.ANON_CLASS) continue;
 100.361 +                if (sh.enclosingNames.get(i).equals(qk.getQualifier(sh))) {
 100.362 +                    found = sh.elementsWithMethod.contains(sh.enclosingNames.get(i));
 100.363 +                    break;
 100.364 +                }
 100.365 +            }
 100.366 +            errorExpected |= !found;
 100.367 +            if (!found) {
 100.368 +                badThis = true;
 100.369 +            }
 100.370 +        }
 100.371 +
 100.372 +        if (ek == ExprKind.SUPER) {
 100.373 +
 100.374 +            int lastIdx = sh.enclosingElements.size() - 1;
 100.375 +            boolean found = lastIdx == -1 ? false :
 100.376 +                    sh.enclosingElements.get(lastIdx).hasSuper() && qk.allowSuperCall(ik, pk);
 100.377 +
 100.378 +            errorExpected |= !found;
 100.379 +            if (!found) {
 100.380 +                badSuper = true;
 100.381 +            }
 100.382 +        }
 100.383 +
 100.384 +        checkCount++;
 100.385 +        if (diagChecker.errorFound != errorExpected) {
 100.386 +            throw new AssertionError("Problem when compiling source:\n" + source.getCharContent(true) +
 100.387 +                    "\nenclosingElems: " + sh.enclosingElements +
 100.388 +                    "\nenclosingNames: " + sh.enclosingNames +
 100.389 +                    "\nelementsWithMethod: " + sh.elementsWithMethod +
 100.390 +                    "\nbad encl: " + badEnclosing +
 100.391 +                    "\nbad this: " + badThis +
 100.392 +                    "\nbad super: " + badSuper +
 100.393 +                    "\nqual kind: " + qk +
 100.394 +                    "\nfound error: " + diagChecker.errorFound);
 100.395 +        }
 100.396 +    }
 100.397 +
 100.398 +    static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
 100.399 +
 100.400 +        boolean errorFound;
 100.401 +
 100.402 +        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
 100.403 +            if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
 100.404 +                System.err.println(diagnostic.getMessage(Locale.getDefault()));
 100.405 +                errorFound = true;
 100.406 +            }
 100.407 +        }
 100.408 +    }
 100.409 +}
   101.1 --- a/test/tools/javac/diags/CheckResourceKeys.java	Thu Nov 08 11:53:23 2012 -0800
   101.2 +++ b/test/tools/javac/diags/CheckResourceKeys.java	Fri Nov 09 14:47:22 2012 -0800
   101.3 @@ -310,9 +310,8 @@
   101.4                      pkg, EnumSet.of(JavaFileObject.Kind.CLASS), true)) {
   101.5                  String name = fo.getName();
   101.6                  // ignore resource files, and files which are not really part of javac
   101.7 -                if (name.contains("resources")
   101.8 -                        || name.contains("Launcher.class")
   101.9 -                        || name.contains("CreateSymbols.class"))
  101.10 +                if (name.matches(".*resources.[A-Za-z_0-9]+\\.class.*")
  101.11 +                        || name.matches(".*CreateSymbols\\.class.*"))
  101.12                      continue;
  101.13                  scan(fo, results);
  101.14              }
   102.1 --- a/test/tools/javac/diags/examples/CatchWithoutTry.java	Thu Nov 08 11:53:23 2012 -0800
   102.2 +++ b/test/tools/javac/diags/examples/CatchWithoutTry.java	Fri Nov 09 14:47:22 2012 -0800
   102.3 @@ -22,9 +22,6 @@
   102.4   */
   102.5  
   102.6  // key: compiler.err.catch.without.try
   102.7 -// key: compiler.err.expected
   102.8 -// key: compiler.err.not.stmt
   102.9 -// key: compiler.err.lambda.not.supported.in.source
  102.10  
  102.11  class CatchWithoutTry {
  102.12      void m() {
   103.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   103.2 +++ b/test/tools/javac/diags/examples/DefaultOverridesObjectMember.java	Fri Nov 09 14:47:22 2012 -0800
   103.3 @@ -0,0 +1,29 @@
   103.4 +/*
   103.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
   103.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   103.7 + *
   103.8 + * This code is free software; you can redistribute it and/or modify it
   103.9 + * under the terms of the GNU General Public License version 2 only, as
  103.10 + * published by the Free Software Foundation.
  103.11 + *
  103.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
  103.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  103.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  103.15 + * version 2 for more details (a copy is included in the LICENSE file that
  103.16 + * accompanied this code).
  103.17 + *
  103.18 + * You should have received a copy of the GNU General Public License version
  103.19 + * 2 along with this work; if not, write to the Free Software Foundation,
  103.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  103.21 + *
  103.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  103.23 + * or visit www.oracle.com if you need additional information or have any
  103.24 + * questions.
  103.25 + */
  103.26 +
  103.27 +// key: compiler.err.default.overrides.object.member
  103.28 +// options: -XDallowDefaultMethods
  103.29 +
  103.30 +interface DefaultOverridesObjectMember {
  103.31 +    default String toString() { return ""; }
  103.32 +}
   104.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   104.2 +++ b/test/tools/javac/diags/examples/OverriddenDefault.java	Fri Nov 09 14:47:22 2012 -0800
   104.3 @@ -0,0 +1,36 @@
   104.4 +/*
   104.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
   104.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   104.7 + *
   104.8 + * This code is free software; you can redistribute it and/or modify it
   104.9 + * under the terms of the GNU General Public License version 2 only, as
  104.10 + * published by the Free Software Foundation.
  104.11 + *
  104.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
  104.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  104.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  104.15 + * version 2 for more details (a copy is included in the LICENSE file that
  104.16 + * accompanied this code).
  104.17 + *
  104.18 + * You should have received a copy of the GNU General Public License version
  104.19 + * 2 along with this work; if not, write to the Free Software Foundation,
  104.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  104.21 + *
  104.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  104.23 + * or visit www.oracle.com if you need additional information or have any
  104.24 + * questions.
  104.25 + */
  104.26 +
  104.27 +// key: compiler.err.illegal.default.super.call
  104.28 +// key: compiler.misc.overridden.default
  104.29 +// options: -XDallowDefaultMethods
  104.30 +
  104.31 +class OverriddenDefault {
  104.32 +    interface I { default void m() {  } }
  104.33 +    interface J extends I { default void m() {  } }
  104.34 +    interface K extends I {}
  104.35 +
  104.36 +    static class C implements J, K {
  104.37 +        void foo() { K.super.m(); }
  104.38 +    }
  104.39 +}
  104.40 \ No newline at end of file
   105.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   105.2 +++ b/test/tools/javac/diags/examples/RedundantSupertype.java	Fri Nov 09 14:47:22 2012 -0800
   105.3 @@ -0,0 +1,35 @@
   105.4 +/*
   105.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
   105.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   105.7 + *
   105.8 + * This code is free software; you can redistribute it and/or modify it
   105.9 + * under the terms of the GNU General Public License version 2 only, as
  105.10 + * published by the Free Software Foundation.
  105.11 + *
  105.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
  105.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  105.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  105.15 + * version 2 for more details (a copy is included in the LICENSE file that
  105.16 + * accompanied this code).
  105.17 + *
  105.18 + * You should have received a copy of the GNU General Public License version
  105.19 + * 2 along with this work; if not, write to the Free Software Foundation,
  105.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  105.21 + *
  105.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  105.23 + * or visit www.oracle.com if you need additional information or have any
  105.24 + * questions.
  105.25 + */
  105.26 +
  105.27 +// key: compiler.err.illegal.default.super.call
  105.28 +// key: compiler.misc.redundant.supertype
  105.29 +// options: -XDallowDefaultMethods
  105.30 +
  105.31 +class RedundantSupertype {
  105.32 +    interface I { default void m() {  } }
  105.33 +    interface J extends I { default void m() {  } }
  105.34 +
  105.35 +    static class C implements I, J {
  105.36 +        void foo() { I.super.m(); }
  105.37 +    }
  105.38 +}
   106.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   106.2 +++ b/test/tools/javac/diags/examples/TypesIncompatibleAbstractDefault.java	Fri Nov 09 14:47:22 2012 -0800
   106.3 @@ -0,0 +1,37 @@
   106.4 +/*
   106.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
   106.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   106.7 + *
   106.8 + * This code is free software; you can redistribute it and/or modify it
   106.9 + * under the terms of the GNU General Public License version 2 only, as
  106.10 + * published by the Free Software Foundation.
  106.11 + *
  106.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
  106.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  106.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  106.15 + * version 2 for more details (a copy is included in the LICENSE file that
  106.16 + * accompanied this code).
  106.17 + *
  106.18 + * You should have received a copy of the GNU General Public License version
  106.19 + * 2 along with this work; if not, write to the Free Software Foundation,
  106.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  106.21 + *
  106.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  106.23 + * or visit www.oracle.com if you need additional information or have any
  106.24 + * questions.
  106.25 + */
  106.26 +
  106.27 +// key: compiler.err.types.incompatible.abstract.default
  106.28 +// options: -XDallowDefaultMethods
  106.29 +
  106.30 +class TypesIncompatibleAbstractDefault {
  106.31 +    interface A {
  106.32 +        default void m() { }
  106.33 +    }
  106.34 +
  106.35 +    interface B {
  106.36 +        void m();
  106.37 +    }
  106.38 +
  106.39 +    interface AB extends A, B { }
  106.40 +}
   107.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   107.2 +++ b/test/tools/javac/diags/examples/TypesIncompatibleUnrelatedDefaults.java	Fri Nov 09 14:47:22 2012 -0800
   107.3 @@ -0,0 +1,37 @@
   107.4 +/*
   107.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
   107.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   107.7 + *
   107.8 + * This code is free software; you can redistribute it and/or modify it
   107.9 + * under the terms of the GNU General Public License version 2 only, as
  107.10 + * published by the Free Software Foundation.
  107.11 + *
  107.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
  107.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  107.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  107.15 + * version 2 for more details (a copy is included in the LICENSE file that
  107.16 + * accompanied this code).
  107.17 + *
  107.18 + * You should have received a copy of the GNU General Public License version
  107.19 + * 2 along with this work; if not, write to the Free Software Foundation,
  107.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  107.21 + *
  107.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  107.23 + * or visit www.oracle.com if you need additional information or have any
  107.24 + * questions.
  107.25 + */
  107.26 +
  107.27 +// key: compiler.err.types.incompatible.unrelated.defaults
  107.28 +// options: -XDallowDefaultMethods
  107.29 +
  107.30 +class TypesIncompatibleUnrelatedDefaults {
  107.31 +    interface A {
  107.32 +        default void m() { }
  107.33 +    }
  107.34 +
  107.35 +    interface B {
  107.36 +        default void m() { }
  107.37 +    }
  107.38 +
  107.39 +    interface AB extends A, B { }
  107.40 +}
   108.1 --- a/test/tools/javac/generics/7022054/T7022054pos1.java	Thu Nov 08 11:53:23 2012 -0800
   108.2 +++ b/test/tools/javac/generics/7022054/T7022054pos1.java	Fri Nov 09 14:47:22 2012 -0800
   108.3 @@ -26,7 +26,8 @@
   108.4   * @bug 7022054
   108.5   *
   108.6   * @summary  Invalid compiler error on covariant overriding methods with the same erasure
   108.7 - * @compile T7022054pos1.java
   108.8 + * @compile -source 7 T7022054pos1.java
   108.9 + * @compile/fail -XDstrictMethodClashCheck T7022054pos1.java
  108.10   *
  108.11   */
  108.12  
   109.1 --- a/test/tools/javac/generics/7022054/T7022054pos2.java	Thu Nov 08 11:53:23 2012 -0800
   109.2 +++ b/test/tools/javac/generics/7022054/T7022054pos2.java	Fri Nov 09 14:47:22 2012 -0800
   109.3 @@ -26,8 +26,8 @@
   109.4   * @bug 7022054
   109.5   *
   109.6   * @summary  Invalid compiler error on covariant overriding methods with the same erasure
   109.7 - * @compile T7022054pos2.java
   109.8 - *
   109.9 + * @compile -source 7 T7022054pos2.java
  109.10 + * @compile/fail -XDstrictMethodClashCheck T7022054pos2.java
  109.11   */
  109.12  
  109.13  class T7022054pos2 {
   110.1 --- a/test/tools/javac/generics/inference/6611449/T6611449.out	Thu Nov 08 11:53:23 2012 -0800
   110.2 +++ b/test/tools/javac/generics/inference/6611449/T6611449.out	Fri Nov 09 14:47:22 2012 -0800
   110.3 @@ -1,5 +1,5 @@
   110.4 -T6611449.java:18:9: compiler.err.cant.apply.symbols: kindname.constructor, T6611449, int,{(compiler.misc.inapplicable.method: kindname.constructor, T6611449, <T>T6611449(T,T), (compiler.misc.infer.arg.length.mismatch: T)),(compiler.misc.inapplicable.method: kindname.constructor, T6611449, <T>T6611449(T), (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.Integer, S))}
   110.5 -T6611449.java:19:9: compiler.err.cant.apply.symbols: kindname.constructor, T6611449, int,int,{(compiler.misc.inapplicable.method: kindname.constructor, T6611449, <T>T6611449(T,T), (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.Integer, S)),(compiler.misc.inapplicable.method: kindname.constructor, T6611449, <T>T6611449(T), (compiler.misc.infer.arg.length.mismatch: T))}
   110.6 +T6611449.java:18:9: compiler.err.cant.apply.symbols: kindname.constructor, T6611449, int,{(compiler.misc.inapplicable.method: kindname.constructor, T6611449, <T>T6611449(T), (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.Integer, S)),(compiler.misc.inapplicable.method: kindname.constructor, T6611449, <T>T6611449(T,T), (compiler.misc.infer.arg.length.mismatch: T))}
   110.7 +T6611449.java:19:9: compiler.err.cant.apply.symbols: kindname.constructor, T6611449, int,int,{(compiler.misc.inapplicable.method: kindname.constructor, T6611449, <T>T6611449(T), (compiler.misc.infer.arg.length.mismatch: T)),(compiler.misc.inapplicable.method: kindname.constructor, T6611449, <T>T6611449(T,T), (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.Integer, S))}
   110.8  T6611449.java:20:9: compiler.err.cant.apply.symbol: kindname.method, m1, T, int, kindname.class, T6611449<S>, (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.Integer, S)
   110.9  T6611449.java:21:9: compiler.err.cant.apply.symbol: kindname.method, m2, T,T, int,int, kindname.class, T6611449<S>, (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.Integer, S)
  110.10  4 errors
   111.1 --- a/test/tools/javac/generics/inference/7086601/T7086601a.out	Thu Nov 08 11:53:23 2012 -0800
   111.2 +++ b/test/tools/javac/generics/inference/7086601/T7086601a.out	Fri Nov 09 14:47:22 2012 -0800
   111.3 @@ -1,5 +1,5 @@
   111.4 -T7086601a.java:20:9: compiler.err.cant.apply.symbols: kindname.method, m1, java.lang.Iterable<java.lang.String>,java.lang.Iterable<java.lang.Integer>,{(compiler.misc.inapplicable.method: kindname.method, T7086601, m1(java.lang.Object), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, T7086601, <S>m1(java.lang.Iterable<? super S>,java.lang.Iterable<? super S>), (compiler.misc.incompatible.upper.bounds: S, java.lang.Integer,java.lang.String,java.lang.Object))}
   111.5 -T7086601a.java:24:9: compiler.err.cant.apply.symbols: kindname.method, m2, java.lang.Iterable<java.lang.String>,java.lang.Iterable<java.lang.Integer>,java.lang.Iterable<java.lang.Double>,{(compiler.misc.inapplicable.method: kindname.method, T7086601, m2(java.lang.Object), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, T7086601, <S>m2(java.lang.Iterable<? super S>,java.lang.Iterable<? super S>,java.lang.Iterable<? super S>), (compiler.misc.incompatible.upper.bounds: S, java.lang.Double,java.lang.Integer,java.lang.String,java.lang.Object))}
   111.6 -T7086601a.java:28:9: compiler.err.cant.apply.symbols: kindname.method, m3, java.lang.Iterable<java.lang.String>,java.lang.Iterable<java.lang.Integer>,{(compiler.misc.inapplicable.method: kindname.method, T7086601, m3(java.lang.Object), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, T7086601, <S>m3(java.lang.Iterable<? super S>...), (compiler.misc.incompatible.upper.bounds: S, java.lang.Integer,java.lang.String,java.lang.Object))}
   111.7 -T7086601a.java:32:9: compiler.err.cant.apply.symbols: kindname.method, m3, java.lang.Iterable<java.lang.String>,java.lang.Iterable<java.lang.Integer>,java.lang.Iterable<java.lang.Double>,{(compiler.misc.inapplicable.method: kindname.method, T7086601, m3(java.lang.Object), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, T7086601, <S>m3(java.lang.Iterable<? super S>...), (compiler.misc.incompatible.upper.bounds: S, java.lang.Double,java.lang.Integer,java.lang.String,java.lang.Object))}
   111.8 +T7086601a.java:20:9: compiler.err.cant.apply.symbols: kindname.method, m1, java.lang.Iterable<java.lang.String>,java.lang.Iterable<java.lang.Integer>,{(compiler.misc.inapplicable.method: kindname.method, T7086601, <S>m1(java.lang.Iterable<? super S>,java.lang.Iterable<? super S>), (compiler.misc.incompatible.upper.bounds: S, java.lang.Integer,java.lang.String,java.lang.Object)),(compiler.misc.inapplicable.method: kindname.method, T7086601, m1(java.lang.Object), (compiler.misc.arg.length.mismatch))}
   111.9 +T7086601a.java:24:9: compiler.err.cant.apply.symbols: kindname.method, m2, java.lang.Iterable<java.lang.String>,java.lang.Iterable<java.lang.Integer>,java.lang.Iterable<java.lang.Double>,{(compiler.misc.inapplicable.method: kindname.method, T7086601, <S>m2(java.lang.Iterable<? super S>,java.lang.Iterable<? super S>,java.lang.Iterable<? super S>), (compiler.misc.incompatible.upper.bounds: S, java.lang.Double,java.lang.Integer,java.lang.String,java.lang.Object)),(compiler.misc.inapplicable.method: kindname.method, T7086601, m2(java.lang.Object), (compiler.misc.arg.length.mismatch))}
  111.10 +T7086601a.java:28:9: compiler.err.cant.apply.symbols: kindname.method, m3, java.lang.Iterable<java.lang.String>,java.lang.Iterable<java.lang.Integer>,{(compiler.misc.inapplicable.method: kindname.method, T7086601, <S>m3(java.lang.Iterable<? super S>...), (compiler.misc.incompatible.upper.bounds: S, java.lang.Integer,java.lang.String,java.lang.Object)),(compiler.misc.inapplicable.method: kindname.method, T7086601, m3(java.lang.Object), (compiler.misc.arg.length.mismatch))}
  111.11 +T7086601a.java:32:9: compiler.err.cant.apply.symbols: kindname.method, m3, java.lang.Iterable<java.lang.String>,java.lang.Iterable<java.lang.Integer>,java.lang.Iterable<java.lang.Double>,{(compiler.misc.inapplicable.method: kindname.method, T7086601, <S>m3(java.lang.Iterable<? super S>...), (compiler.misc.incompatible.upper.bounds: S, java.lang.Double,java.lang.Integer,java.lang.String,java.lang.Object)),(compiler.misc.inapplicable.method: kindname.method, T7086601, m3(java.lang.Object), (compiler.misc.arg.length.mismatch))}
  111.12  4 errors
   112.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   112.2 +++ b/test/tools/javac/incompleteStatements/T8000484.java	Fri Nov 09 14:47:22 2012 -0800
   112.3 @@ -0,0 +1,17 @@
   112.4 +/*
   112.5 + * @test /nodynamiccopyright/
   112.6 + * @bug 8000484
   112.7 + * @summary Bad error recovery when 'catch' without 'try' is found
   112.8 + * @compile/fail/ref=T8000484.out -XDrawDiagnostics T8000484.java
   112.9 + */
  112.10 +
  112.11 +public class T8000484 {
  112.12 +    void m() {
  112.13 +        catch (Exception e){}
  112.14 +        else{}
  112.15 +        finally{}
  112.16 +        catch (Exception e) {catch (Exception e){}}
  112.17 +        else{else{}}
  112.18 +        finally{finally{}}
  112.19 +    }
  112.20 +}
   113.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   113.2 +++ b/test/tools/javac/incompleteStatements/T8000484.out	Fri Nov 09 14:47:22 2012 -0800
   113.3 @@ -0,0 +1,10 @@
   113.4 +T8000484.java:10:9: compiler.err.catch.without.try
   113.5 +T8000484.java:11:9: compiler.err.else.without.if
   113.6 +T8000484.java:12:9: compiler.err.finally.without.try
   113.7 +T8000484.java:13:30: compiler.err.catch.without.try
   113.8 +T8000484.java:13:9: compiler.err.catch.without.try
   113.9 +T8000484.java:14:14: compiler.err.else.without.if
  113.10 +T8000484.java:14:9: compiler.err.else.without.if
  113.11 +T8000484.java:15:17: compiler.err.finally.without.try
  113.12 +T8000484.java:15:9: compiler.err.finally.without.try
  113.13 +9 errors
   114.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   114.2 +++ b/test/tools/javac/options/T6949443.java	Fri Nov 09 14:47:22 2012 -0800
   114.3 @@ -0,0 +1,36 @@
   114.4 +/*
   114.5 + * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
   114.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   114.7 + *
   114.8 + * This code is free software; you can redistribute it and/or modify it
   114.9 + * under the terms of the GNU General Public License version 2 only, as
  114.10 + * published by the Free Software Foundation.
  114.11 + *
  114.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
  114.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  114.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  114.15 + * version 2 for more details (a copy is included in the LICENSE file that
  114.16 + * accompanied this code).
  114.17 + *
  114.18 + * You should have received a copy of the GNU General Public License version
  114.19 + * 2 along with this work; if not, write to the Free Software Foundation,
  114.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  114.21 + *
  114.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  114.23 + * or visit www.oracle.com if you need additional information or have any
  114.24 + * questions.
  114.25 + */
  114.26 +
  114.27 +/*
  114.28 + * @test
  114.29 + * @bug 6949443
  114.30 + * @summary VisitTree assertion triggered using -Xjcov on small sample program
  114.31 + * @compile -Xjcov T6949443.java
  114.32 + */
  114.33 +
  114.34 +public class T6949443 {
  114.35 +    public static void main(String[] args) {
  114.36 +        Integer i = 0;
  114.37 +        i++;
  114.38 +    }
  114.39 +}
   115.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   115.2 +++ b/test/tools/javac/resolve/tests/AmbiguityPrecedence.java	Fri Nov 09 14:47:22 2012 -0800
   115.3 @@ -0,0 +1,45 @@
   115.4 +/*
   115.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
   115.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   115.7 + *
   115.8 + * This code is free software; you can redistribute it and/or modify it
   115.9 + * under the terms of the GNU General Public License version 2 only, as
  115.10 + * published by the Free Software Foundation.
  115.11 + *
  115.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
  115.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  115.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  115.15 + * version 2 for more details (a copy is included in the LICENSE file that
  115.16 + * accompanied this code).
  115.17 + *
  115.18 + * You should have received a copy of the GNU General Public License version
  115.19 + * 2 along with this work; if not, write to the Free Software Foundation,
  115.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  115.21 + *
  115.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  115.23 + * or visit www.oracle.com if you need additional information or have any
  115.24 + * questions.
  115.25 + */
  115.26 +
  115.27 +@TraceResolve(keys={"compiler.err.ref.ambiguous"})
  115.28 +class AmbiguityPrecedence {
  115.29 +
  115.30 +    @Candidate(applicable=Phase.BASIC)
  115.31 +    static void m1(long l, int i) {}
  115.32 +    @Candidate(applicable=Phase.BASIC)
  115.33 +    static void m1(int i, long l) {}
  115.34 +    @Candidate
  115.35 +    static void m1(Integer i1, Integer i2) {}
  115.36 +
  115.37 +    @Candidate(applicable=Phase.BOX)
  115.38 +    static void m2(Object o, Integer i) {}
  115.39 +    @Candidate(applicable=Phase.BOX)
  115.40 +    static void m2(Integer i, Object o) {}
  115.41 +    @Candidate
  115.42 +    static void m2(Integer... o) {}
  115.43 +
  115.44 +    {
  115.45 +        m1(1, 1);
  115.46 +        m2(1, 1);
  115.47 +    }
  115.48 +}
   116.1 --- a/test/tools/javac/scope/7046348/EagerInterfaceCompletionTest.java	Thu Nov 08 11:53:23 2012 -0800
   116.2 +++ b/test/tools/javac/scope/7046348/EagerInterfaceCompletionTest.java	Fri Nov 09 14:47:22 2012 -0800
   116.3 @@ -30,6 +30,7 @@
   116.4  import java.io.File;
   116.5  import java.net.URI;
   116.6  import java.util.Arrays;
   116.7 +import java.util.List;
   116.8  
   116.9  import javax.tools.Diagnostic;
  116.10  import javax.tools.DiagnosticListener;
  116.11 @@ -43,13 +44,15 @@
  116.12  
  116.13      JavaCompiler javacTool;
  116.14      File testDir;
  116.15 +    VersionKind versionKind;
  116.16      HierarchyKind hierarchyKind;
  116.17      TestKind testKind;
  116.18      ActionKind actionKind;
  116.19  
  116.20 -    EagerInterfaceCompletionTest(JavaCompiler javacTool, File testDir,
  116.21 +    EagerInterfaceCompletionTest(JavaCompiler javacTool, File testDir, VersionKind versionKind,
  116.22              HierarchyKind hierarchyKind, TestKind testKind, ActionKind actionKind) {
  116.23          this.javacTool = javacTool;
  116.24 +        this.versionKind = versionKind;
  116.25          this.hierarchyKind = hierarchyKind;
  116.26          this.testDir = testDir;
  116.27          this.testKind = testKind;
  116.28 @@ -62,7 +65,7 @@
  116.29          actionKind.doAction(this);
  116.30          DiagnosticChecker dc = new DiagnosticChecker();
  116.31          compile(dc, testKind.source);
  116.32 -        if (testKind.completionFailure(actionKind, hierarchyKind) != dc.errorFound) {
  116.33 +        if (testKind.completionFailure(versionKind, actionKind, hierarchyKind) != dc.errorFound) {
  116.34              if (dc.errorFound) {
  116.35                  error("Unexpected completion failure" +
  116.36                        "\nhierarhcyKind " + hierarchyKind +
  116.37 @@ -80,7 +83,8 @@
  116.38      void compile(DiagnosticChecker dc, JavaSource... sources) {
  116.39          try {
  116.40              CompilationTask ct = javacTool.getTask(null, null, dc,
  116.41 -                    Arrays.asList("-d", testDir.getAbsolutePath(), "-cp", testDir.getAbsolutePath()),
  116.42 +                    Arrays.asList("-d", testDir.getAbsolutePath(), "-cp",
  116.43 +                    testDir.getAbsolutePath(), versionKind.optsArr[0], versionKind.optsArr[1]),
  116.44                      null, Arrays.asList(sources));
  116.45              ct.call();
  116.46          }
  116.47 @@ -108,12 +112,25 @@
  116.48          boolean errorFound = false;
  116.49  
  116.50          public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
  116.51 -            errorFound = true;
  116.52 +            if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
  116.53 +                errorFound = true;
  116.54 +            }
  116.55          }
  116.56      }
  116.57  
  116.58      //global declarations
  116.59  
  116.60 +    enum VersionKind {
  116.61 +        PRE_LAMBDA("-source", "7"),
  116.62 +        LAMBDA("-source", "8");
  116.63 +
  116.64 +        String[] optsArr;
  116.65 +
  116.66 +        VersionKind(String... optsArr) {
  116.67 +            this.optsArr = optsArr;
  116.68 +        }
  116.69 +    }
  116.70 +
  116.71      enum HierarchyKind {
  116.72          INTERFACE("interface A { boolean f = false; void m(); }\n" +
  116.73                    "class B implements A { public void m() {} }"),
  116.74 @@ -157,13 +174,14 @@
  116.75              this.source = new JavaSource("Test2.java", code);
  116.76          }
  116.77  
  116.78 -        boolean completionFailure(ActionKind ak, HierarchyKind hk) {
  116.79 +        boolean completionFailure(VersionKind vk, ActionKind ak, HierarchyKind hk) {
  116.80              switch (this) {
  116.81                  case ACCESS_ONLY:
  116.82                  case CONSTR: return ak == ActionKind.REMOVE_B;
  116.83                  case FIELD:
  116.84                  case SUPER: return true;
  116.85 -                case METHOD: return hk != HierarchyKind.INTERFACE || ak == ActionKind.REMOVE_B;
  116.86 +                case METHOD: return hk != HierarchyKind.INTERFACE || ak == ActionKind.REMOVE_B ||
  116.87 +                        (hk == HierarchyKind.INTERFACE && ak == ActionKind.REMOVE_A && vk == VersionKind.LAMBDA);
  116.88                  default: throw new AssertionError("Unexpected test kind " + this);
  116.89              }
  116.90          }
  116.91 @@ -173,12 +191,15 @@
  116.92          String SCRATCH_DIR = System.getProperty("user.dir");
  116.93          JavaCompiler javacTool = ToolProvider.getSystemJavaCompiler();
  116.94          int n = 0;
  116.95 -        for (HierarchyKind hierarchyKind : HierarchyKind.values()) {
  116.96 -            for (TestKind testKind : TestKind.values()) {
  116.97 -                for (ActionKind actionKind : ActionKind.values()) {
  116.98 -                    File testDir = new File(SCRATCH_DIR, "test"+n);
  116.99 -                    new EagerInterfaceCompletionTest(javacTool, testDir, hierarchyKind, testKind, actionKind).test();
 116.100 -                    n++;
 116.101 +        for (VersionKind versionKind : VersionKind.values()) {
 116.102 +            for (HierarchyKind hierarchyKind : HierarchyKind.values()) {
 116.103 +                for (TestKind testKind : TestKind.values()) {
 116.104 +                    for (ActionKind actionKind : ActionKind.values()) {
 116.105 +                        File testDir = new File(SCRATCH_DIR, "test"+n);
 116.106 +                        new EagerInterfaceCompletionTest(javacTool, testDir, versionKind,
 116.107 +                                hierarchyKind, testKind, actionKind).test();
 116.108 +                        n++;
 116.109 +                    }
 116.110                  }
 116.111              }
 116.112          }
   117.1 --- a/test/tools/javac/versions/check.sh	Thu Nov 08 11:53:23 2012 -0800
   117.2 +++ b/test/tools/javac/versions/check.sh	Fri Nov 09 14:47:22 2012 -0800
   117.3 @@ -1,5 +1,5 @@
   117.4  #
   117.5 -# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
   117.6 +# Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
   117.7  # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   117.8  #
   117.9  # This code is free software; you can redistribute it and/or modify it
  117.10 @@ -22,7 +22,7 @@
  117.11  #
  117.12  
  117.13  # @test
  117.14 -# @bug 4981566 5028634 5094412 6304984 7025786 7025789
  117.15 +# @bug 4981566 5028634 5094412 6304984 7025786 7025789 8001112
  117.16  # @summary Check interpretation of -target and -source options
  117.17  # @build CheckClassFileVersion
  117.18  # @run shell check.sh 
  117.19 @@ -47,32 +47,39 @@
  117.20    "$JC" ${TESTTOOLVMOPTS} -d $TC $* $TC/X.java && "$J" $CFV $TC/X.class $V || exit 2
  117.21  }
  117.22  
  117.23 +# check for all combinations of target values
  117.24 +check_target() {
  117.25 +  check $1 -source $2 -target $3
  117.26 +  check $1 -source $2 -target 1.${3}
  117.27 +}
  117.28 +# check for all combinations of source and target values
  117.29 +check_source_target() {
  117.30 +  check_target $1 $2     $3
  117.31 +  check_target $1 1.${2} $3
  117.32 +}
  117.33 +
  117.34  check 48.0 -source 1.4
  117.35  
  117.36  check 49.0 -source 1.4 -target 1.5
  117.37  check 49.0 -source 1.5 -target 1.5
  117.38  
  117.39 -check 50.0 -source 1.4 -target 1.6
  117.40 -check 50.0 -source 1.5 -target 1.6
  117.41 -check 50.0 -source 1.6 -target 1.6
  117.42 -check 50.0 -source 1.6 -target 6
  117.43 -check 50.0 -source 6 -target 1.6
  117.44 -check 50.0 -source 6 -target 6
  117.45 +check_target        50.0 1.4 6
  117.46 +check_target        50.0 1.5 6
  117.47 +check_source_target 50.0 6   6
  117.48  
  117.49 -check 51.0
  117.50 -check 51.0 -source 1.5
  117.51 -check 51.0 -source 1.6
  117.52 -check 51.0 -source 6
  117.53 -check 51.0 -source 1.7
  117.54 -check 51.0 -source 7
  117.55 -check 51.0 -source 7 -target 1.7
  117.56 -check 51.0 -source 7 -target 7
  117.57 +check_target        51.0 1.4 7
  117.58 +check_target        51.0 1.5 7
  117.59 +check_source_target 51.0 6   7
  117.60 +check_source_target 51.0 7   7
  117.61  
  117.62 -# Update when class file version is revved
  117.63 -check 51.0 -source 1.8
  117.64 -check 51.0 -source 8
  117.65 -check 51.0 -target 1.8
  117.66 -check 51.0 -target 8
  117.67 +check_target        52.0 1.4 8
  117.68 +check_target        52.0 1.5 8
  117.69 +check_source_target 52.0 6   8
  117.70 +check_source_target 52.0 7   8
  117.71 +check_source_target 52.0 8   8
  117.72 +
  117.73 +# and finally the default with no options
  117.74 +check 52.0
  117.75  
  117.76  # Check source versions
  117.77  
   118.1 --- a/test/tools/javadoc/6958836/Test.java	Thu Nov 08 11:53:23 2012 -0800
   118.2 +++ b/test/tools/javadoc/6958836/Test.java	Fri Nov 09 14:47:22 2012 -0800
   118.3 @@ -1,5 +1,5 @@
   118.4  /*
   118.5 - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
   118.6 + * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
   118.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   118.8   *
   118.9   * This code is free software; you can redistribute it and/or modify it
  118.10 @@ -23,7 +23,7 @@
  118.11  
  118.12  /*
  118.13   * @test
  118.14 - * @bug 6958836
  118.15 + * @bug 6958836 8002168
  118.16   * @summary javadoc should support -Xmaxerrs and -Xmaxwarns
  118.17   */
  118.18  
   119.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   119.2 +++ b/test/tools/javadoc/CheckResourceKeys.java	Fri Nov 09 14:47:22 2012 -0800
   119.3 @@ -0,0 +1,240 @@
   119.4 +/*
   119.5 + * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
   119.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   119.7 + *
   119.8 + * This code is free software; you can redistribute it and/or modify it
   119.9 + * under the terms of the GNU General Public License version 2 only, as
  119.10 + * published by the Free Software Foundation.
  119.11 + *
  119.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
  119.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  119.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  119.15 + * version 2 for more details (a copy is included in the LICENSE file that
  119.16 + * accompanied this code).
  119.17 + *
  119.18 + * You should have received a copy of the GNU General Public License version
  119.19 + * 2 along with this work; if not, write to the Free Software Foundation,
  119.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  119.21 + *
  119.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  119.23 + * or visit www.oracle.com if you need additional information or have any
  119.24 + * questions.
  119.25 + */
  119.26 +
  119.27 +/*
  119.28 + * @test
  119.29 + * @bug 8000612
  119.30 + * @summary need test program to validate javadoc resource bundles
  119.31 + */
  119.32 +
  119.33 +import java.io.*;
  119.34 +import java.util.*;
  119.35 +import javax.tools.*;
  119.36 +import com.sun.tools.classfile.*;
  119.37 +
  119.38 +/**
  119.39 + * Compare string constants in javadoc classes against keys in javadoc resource bundles.
  119.40 + */
  119.41 +public class CheckResourceKeys {
  119.42 +    /**
  119.43 +     * Main program.
  119.44 +     * Options:
  119.45 +     * -finddeadkeys
  119.46 +     *      look for keys in resource bundles that are no longer required
  119.47 +     * -findmissingkeys
  119.48 +     *      look for keys in resource bundles that are missing
  119.49 +     *
  119.50 +     * @throws Exception if invoked by jtreg and errors occur
  119.51 +     */
  119.52 +    public static void main(String... args) throws Exception {
  119.53 +        CheckResourceKeys c = new CheckResourceKeys();
  119.54 +        if (c.run(args))
  119.55 +            return;
  119.56 +
  119.57 +        if (is_jtreg())
  119.58 +            throw new Exception(c.errors + " errors occurred");
  119.59 +        else
  119.60 +            System.exit(1);
  119.61 +    }
  119.62 +
  119.63 +    static boolean is_jtreg() {
  119.64 +        return (System.getProperty("test.src") != null);
  119.65 +    }
  119.66 +
  119.67 +    /**
  119.68 +     * Main entry point.
  119.69 +     */
  119.70 +    boolean run(String... args) throws Exception {
  119.71 +        boolean findDeadKeys = false;
  119.72 +        boolean findMissingKeys = false;
  119.73 +
  119.74 +        if (args.length == 0) {
  119.75 +            if (is_jtreg()) {
  119.76 +                findDeadKeys = true;
  119.77 +                findMissingKeys = true;
  119.78 +            } else {
  119.79 +                System.err.println("Usage: java CheckResourceKeys <options>");
  119.80 +                System.err.println("where options include");
  119.81 +                System.err.println("  -finddeadkeys      find keys in resource bundles which are no longer required");
  119.82 +                System.err.println("  -findmissingkeys   find keys in resource bundles that are required but missing");
  119.83 +                return true;
  119.84 +            }
  119.85 +        } else {
  119.86 +            for (String arg: args) {
  119.87 +                if (arg.equalsIgnoreCase("-finddeadkeys"))
  119.88 +                    findDeadKeys = true;
  119.89 +                else if (arg.equalsIgnoreCase("-findmissingkeys"))
  119.90 +                    findMissingKeys = true;
  119.91 +                else
  119.92 +                    error("bad option: " + arg);
  119.93 +            }
  119.94 +        }
  119.95 +
  119.96 +        if (errors > 0)
  119.97 +            return false;
  119.98 +
  119.99 +        Set<String> codeKeys = getCodeKeys();
 119.100 +        Set<String> resourceKeys = getResourceKeys();
 119.101 +
 119.102 +        System.err.println("found " + codeKeys.size() + " keys in code");
 119.103 +        System.err.println("found " + resourceKeys.size() + " keys in resource bundles");
 119.104 +
 119.105 +        if (findDeadKeys)
 119.106 +            findDeadKeys(codeKeys, resourceKeys);
 119.107 +
 119.108 +        if (findMissingKeys)
 119.109 +            findMissingKeys(codeKeys, resourceKeys);
 119.110 +
 119.111 +        return (errors == 0);
 119.112 +    }
 119.113 +
 119.114 +    /**
 119.115 +     * Find keys in resource bundles which are probably no longer required.
 119.116 +     * A key is required if there is a string in the code that is a resource key,
 119.117 +     * or if the key is well-known according to various pragmatic rules.
 119.118 +     */
 119.119 +    void findDeadKeys(Set<String> codeKeys, Set<String> resourceKeys) {
 119.120 +        for (String rk: resourceKeys) {
 119.121 +            if (codeKeys.contains(rk))
 119.122 +                continue;
 119.123 +
 119.124 +            error("Resource key not found in code: " + rk);
 119.125 +        }
 119.126 +    }
 119.127 +
 119.128 +    /**
 119.129 +     * For all strings in the code that look like they might be
 119.130 +     * a resource key, verify that a key exists.
 119.131 +     */
 119.132 +    void findMissingKeys(Set<String> codeKeys, Set<String> resourceKeys) {
 119.133 +        for (String ck: codeKeys) {
 119.134 +            if (resourceKeys.contains(ck))
 119.135 +                continue;
 119.136 +            error("No resource for \"" + ck + "\"");
 119.137 +        }
 119.138 +    }
 119.139 +
 119.140 +    /**
 119.141 +     * Get the set of strings from (most of) the javadoc classfiles.
 119.142 +     */
 119.143 +    Set<String> getCodeKeys() throws IOException {
 119.144 +        Set<String> results = new TreeSet<String>();
 119.145 +        JavaCompiler c = ToolProvider.getSystemJavaCompiler();
 119.146 +        JavaFileManager fm = c.getStandardFileManager(null, null, null);
 119.147 +        JavaFileManager.Location javadocLoc = findJavadocLocation(fm);
 119.148 +        String[] pkgs = {
 119.149 +            "com.sun.tools.doclets",
 119.150 +            "com.sun.tools.javadoc"
 119.151 +        };
 119.152 +        for (String pkg: pkgs) {
 119.153 +            for (JavaFileObject fo: fm.list(javadocLoc,
 119.154 +                    pkg, EnumSet.of(JavaFileObject.Kind.CLASS), true)) {
 119.155 +                String name = fo.getName();
 119.156 +                // ignore resource files
 119.157 +                if (name.matches(".*resources.[A-Za-z_0-9]+\\.class.*"))
 119.158 +                    continue;
 119.159 +                scan(fo, results);
 119.160 +            }
 119.161 +        }
 119.162 +
 119.163 +        // special handling for code strings synthesized in
 119.164 +        // com.sun.tools.doclets.internal.toolkit.util.Util.getTypeName
 119.165 +        String[] extras = {
 119.166 +            "AnnotationType", "Class", "Enum", "Error", "Exception", "Interface"
 119.167 +        };
 119.168 +        for (String s: extras) {
 119.169 +            if (results.contains("doclet." + s))
 119.170 +                results.add("doclet." + s.toLowerCase());
 119.171 +        }
 119.172 +
 119.173 +        return results;
 119.174 +    }
 119.175 +
 119.176 +    // depending on how the test is run, javadoc may be on bootclasspath or classpath
 119.177 +    JavaFileManager.Location findJavadocLocation(JavaFileManager fm) {
 119.178 +        JavaFileManager.Location[] locns =
 119.179 +            { StandardLocation.PLATFORM_CLASS_PATH, StandardLocation.CLASS_PATH };
 119.180 +        try {
 119.181 +            for (JavaFileManager.Location l: locns) {
 119.182 +                JavaFileObject fo = fm.getJavaFileForInput(l,
 119.183 +                    "com.sun.tools.javadoc.Main", JavaFileObject.Kind.CLASS);
 119.184 +                if (fo != null) {
 119.185 +                    System.err.println("found javadoc in " + l);
 119.186 +                    return l;
 119.187 +                }
 119.188 +            }
 119.189 +        } catch (IOException e) {
 119.190 +            throw new Error(e);
 119.191 +        }
 119.192 +        throw new IllegalStateException("Cannot find javadoc");
 119.193 +    }
 119.194 +
 119.195 +    /**
 119.196 +     * Get the set of strings from a class file.
 119.197 +     * Only strings that look like they might be a resource key are returned.
 119.198 +     */
 119.199 +    void scan(JavaFileObject fo, Set<String> results) throws IOException {
 119.200 +        //System.err.println("scan " + fo.getName());
 119.201 +        InputStream in = fo.openInputStream();
 119.202 +        try {
 119.203 +            ClassFile cf = ClassFile.read(in);
 119.204 +            for (ConstantPool.CPInfo cpinfo: cf.constant_pool.entries()) {
 119.205 +                if (cpinfo.getTag() == ConstantPool.CONSTANT_Utf8) {
 119.206 +                    String v = ((ConstantPool.CONSTANT_Utf8_info) cpinfo).value;
 119.207 +                    if (v.matches("(doclet|main|javadoc|tag)\\.[A-Za-z0-9-_.]+"))
 119.208 +                        results.add(v);
 119.209 +                }
 119.210 +            }
 119.211 +        } catch (ConstantPoolException ignore) {
 119.212 +        } finally {
 119.213 +            in.close();
 119.214 +        }
 119.215 +    }
 119.216 +
 119.217 +    /**
 119.218 +     * Get the set of keys from the javadoc resource bundles.
 119.219 +     */
 119.220 +    Set<String> getResourceKeys() {
 119.221 +        String[] names = {
 119.222 +                "com.sun.tools.doclets.formats.html.resources.standard",
 119.223 +                "com.sun.tools.doclets.internal.toolkit.resources.doclets",
 119.224 +                "com.sun.tools.javadoc.resources.javadoc",
 119.225 +        };
 119.226 +        Set<String> results = new TreeSet<String>();
 119.227 +        for (String name : names) {
 119.228 +            ResourceBundle b = ResourceBundle.getBundle(name);
 119.229 +            results.addAll(b.keySet());
 119.230 +        }
 119.231 +        return results;
 119.232 +    }
 119.233 +
 119.234 +    /**
 119.235 +     * Report an error.
 119.236 +     */
 119.237 +    void error(String msg) {
 119.238 +        System.err.println("Error: " + msg);
 119.239 +        errors++;
 119.240 +    }
 119.241 +
 119.242 +    int errors;
 119.243 +}

mercurial