Sun, 10 Apr 2011 10:25:12 -0700
Merge
1.1 --- a/make/build.xml Thu Apr 07 15:21:22 2011 -0700 1.2 +++ b/make/build.xml Sun Apr 10 10:25:12 2011 -0700 1.3 @@ -806,6 +806,9 @@ 1.4 <exclude name="**/*.java"/> 1.5 <exclude name="**/*.properties"/> 1.6 <exclude name="**/*-template"/> 1.7 + <exclude name="**/*.rej"/> 1.8 + <exclude name="**/*.orig"/> 1.9 + <exclude name="**/overview.html"/> 1.10 <exclude name="**/package.html"/> 1.11 </fileset> 1.12 </copy>
2.1 --- a/src/share/classes/com/sun/tools/classfile/Type.java Thu Apr 07 15:21:22 2011 -0700 2.2 +++ b/src/share/classes/com/sun/tools/classfile/Type.java Sun Apr 10 10:25:12 2011 -0700 2.3 @@ -1,5 +1,5 @@ 2.4 /* 2.5 - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. 2.6 + * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. 2.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2.8 * 2.9 * This code is free software; you can redistribute it and/or modify it 2.10 @@ -41,6 +41,11 @@ 2.11 */ 2.12 public abstract class Type { 2.13 protected Type() { } 2.14 + 2.15 + public boolean isObject() { 2.16 + return false; 2.17 + } 2.18 + 2.19 public abstract <R,D> R accept(Visitor<R,D> visitor, D data); 2.20 2.21 protected static void append(StringBuilder sb, String prefix, List<? extends Type> types, String suffix) { 2.22 @@ -262,6 +267,13 @@ 2.23 return sb.toString(); 2.24 } 2.25 2.26 + @Override 2.27 + public boolean isObject() { 2.28 + return (outerType == null) 2.29 + && name.equals("java/lang/Object") 2.30 + && (typeArgs == null || typeArgs.isEmpty()); 2.31 + } 2.32 + 2.33 public final ClassType outerType; 2.34 public final String name; 2.35 public final List<Type> typeArgs;
3.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeWriterImpl.java Thu Apr 07 15:21:22 2011 -0700 3.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeWriterImpl.java Sun Apr 10 10:25:12 2011 -0700 3.3 @@ -1,5 +1,5 @@ 3.4 /* 3.5 - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 3.6 + * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. 3.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3.8 * 3.9 * This code is free software; you can redistribute it and/or modify it 3.10 @@ -154,8 +154,8 @@ 3.11 div.addStyle(HtmlStyle.header); 3.12 if (pkgname.length() > 0) { 3.13 Content pkgNameContent = new StringContent(pkgname); 3.14 - Content pkgNamePara = HtmlTree.P(HtmlStyle.subTitle, pkgNameContent); 3.15 - div.addContent(pkgNamePara); 3.16 + Content pkgNameDiv = HtmlTree.DIV(HtmlStyle.subTitle, pkgNameContent); 3.17 + div.addContent(pkgNameDiv); 3.18 } 3.19 LinkInfoImpl linkInfo = new LinkInfoImpl( 3.20 LinkInfoImpl.CONTEXT_CLASS_HEADER, annotationType, false); 3.21 @@ -216,12 +216,15 @@ 3.22 pre.addContent(modifiers); 3.23 LinkInfoImpl linkInfo = new LinkInfoImpl( 3.24 LinkInfoImpl.CONTEXT_CLASS_SIGNATURE, annotationType, false); 3.25 - Content name = new RawHtml (annotationType.name() + 3.26 - getTypeParameterLinks(linkInfo)); 3.27 + Content annotationName = new StringContent(annotationType.name()); 3.28 + Content parameterLinks = new RawHtml(getTypeParameterLinks(linkInfo)); 3.29 if (configuration().linksource) { 3.30 - addSrcLink(annotationType, name, pre); 3.31 + addSrcLink(annotationType, annotationName, pre); 3.32 + pre.addContent(parameterLinks); 3.33 } else { 3.34 - pre.addContent(HtmlTree.STRONG(name)); 3.35 + Content span = HtmlTree.SPAN(HtmlStyle.strong, annotationName); 3.36 + span.addContent(parameterLinks); 3.37 + pre.addContent(span); 3.38 } 3.39 annotationInfoTree.addContent(pre); 3.40 }
4.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java Thu Apr 07 15:21:22 2011 -0700 4.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java Sun Apr 10 10:25:12 2011 -0700 4.3 @@ -1,5 +1,5 @@ 4.4 /* 4.5 - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 4.6 + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. 4.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4.8 * 4.9 * This code is free software; you can redistribute it and/or modify it 4.10 @@ -161,8 +161,8 @@ 4.11 div.addStyle(HtmlStyle.header); 4.12 if (pkgname.length() > 0) { 4.13 Content pkgNameContent = new StringContent(pkgname); 4.14 - Content pkgNamePara = HtmlTree.P(HtmlStyle.subTitle, pkgNameContent); 4.15 - div.addContent(pkgNamePara); 4.16 + Content pkgNameDiv = HtmlTree.DIV(HtmlStyle.subTitle, pkgNameContent); 4.17 + div.addContent(pkgNameDiv); 4.18 } 4.19 LinkInfoImpl linkInfo = new LinkInfoImpl( LinkInfoImpl.CONTEXT_CLASS_HEADER, 4.20 classDoc, false); 4.21 @@ -228,12 +228,15 @@ 4.22 LinkInfoImpl.CONTEXT_CLASS_SIGNATURE, classDoc, false); 4.23 //Let's not link to ourselves in the signature. 4.24 linkInfo.linkToSelf = false; 4.25 - Content name = new RawHtml (classDoc.name() + 4.26 - getTypeParameterLinks(linkInfo)); 4.27 + Content className = new StringContent(classDoc.name()); 4.28 + Content parameterLinks = new RawHtml(getTypeParameterLinks(linkInfo)); 4.29 if (configuration().linksource) { 4.30 - addSrcLink(classDoc, name, pre); 4.31 + addSrcLink(classDoc, className, pre); 4.32 + pre.addContent(parameterLinks); 4.33 } else { 4.34 - pre.addContent(HtmlTree.STRONG(name)); 4.35 + Content span = HtmlTree.SPAN(HtmlStyle.strong, className); 4.36 + span.addContent(parameterLinks); 4.37 + pre.addContent(span); 4.38 } 4.39 if (!isInterface) { 4.40 Type superclass = Util.getFirstVisibleSuperClass(classDoc,
5.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/FrameOutputWriter.java Thu Apr 07 15:21:22 2011 -0700 5.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/FrameOutputWriter.java Sun Apr 10 10:25:12 2011 -0700 5.3 @@ -114,13 +114,10 @@ 5.4 Content noframesHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, 5.5 getResource("doclet.Frame_Alert")); 5.6 noframes.addContent(noframesHead); 5.7 - Content p = HtmlTree.P(getResource("doclet.Frame_Warning_Message")); 5.8 + Content p = HtmlTree.P(getResource("doclet.Frame_Warning_Message", 5.9 + getHyperLinkString(configuration.topFile, 5.10 + configuration.getText("doclet.Non_Frame_Version")))); 5.11 noframes.addContent(p); 5.12 - noframes.addContent(new HtmlTree(HtmlTag.BR)); 5.13 - noframes.addContent(getResource("doclet.Link_To")); 5.14 - Content link = getHyperLink(configuration.topFile, 5.15 - getResource("doclet.Non_Frame_Version")); 5.16 - noframes.addContent(link); 5.17 contentTree.addContent(noframes); 5.18 } 5.19
6.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/HelpWriter.java Thu Apr 07 15:21:22 2011 -0700 6.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/HelpWriter.java Sun Apr 10 10:25:12 2011 -0700 6.3 @@ -1,5 +1,5 @@ 6.4 /* 6.5 - * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. 6.6 + * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. 6.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6.8 * 6.9 * This code is free software; you can redistribute it and/or modify it 6.10 @@ -96,7 +96,7 @@ 6.11 Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, false, HtmlStyle.title, 6.12 getResource("doclet.Help_line_1")); 6.13 Content div = HtmlTree.DIV(HtmlStyle.header, heading); 6.14 - Content line2 = HtmlTree.P(HtmlStyle.subTitle, 6.15 + Content line2 = HtmlTree.DIV(HtmlStyle.subTitle, 6.16 getResource("doclet.Help_line_2")); 6.17 div.addContent(line2); 6.18 contentTree.addContent(div);
7.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/LinkFactoryImpl.java Thu Apr 07 15:21:22 2011 -0700 7.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/LinkFactoryImpl.java Sun Apr 10 10:25:12 2011 -0700 7.3 @@ -1,5 +1,5 @@ 7.4 /* 7.5 - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 7.6 + * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. 7.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 7.8 * 7.9 * This code is free software; you can redistribute it and/or modify it 7.10 @@ -69,9 +69,6 @@ 7.11 StringBuffer label = new StringBuffer( 7.12 classLinkInfo.getClassLinkLabel(m_writer.configuration)); 7.13 classLinkInfo.displayLength += label.length(); 7.14 - if (noLabel && classLinkInfo.excludeTypeParameterLinks) { 7.15 - label.append(getTypeParameterLinks(linkInfo).toString()); 7.16 - } 7.17 Configuration configuration = ConfigurationImpl.getInstance(); 7.18 LinkOutputImpl linkOutput = new LinkOutputImpl(); 7.19 if (classDoc.isIncluded()) {
8.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/LinkInfoImpl.java Thu Apr 07 15:21:22 2011 -0700 8.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/LinkInfoImpl.java Sun Apr 10 10:25:12 2011 -0700 8.3 @@ -1,5 +1,5 @@ 8.4 /* 8.5 - * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved. 8.6 + * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. 8.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 8.8 * 8.9 * This code is free software; you can redistribute it and/or modify it 8.10 @@ -408,10 +408,6 @@ 8.11 8.12 case CONTEXT_PACKAGE: 8.13 case CONTEXT_CLASS_USE: 8.14 - excludeTypeBoundsLinks = true; 8.15 - excludeTypeParameterLinks = true; 8.16 - break; 8.17 - 8.18 case CONTEXT_CLASS_HEADER: 8.19 case CONTEXT_CLASS_SIGNATURE: 8.20 excludeTypeParameterLinks = true;
9.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java Thu Apr 07 15:21:22 2011 -0700 9.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java Sun Apr 10 10:25:12 2011 -0700 9.3 @@ -1,5 +1,5 @@ 9.4 /* 9.5 - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 9.6 + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. 9.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 9.8 * 9.9 * This code is free software; you can redistribute it and/or modify it 9.10 @@ -163,10 +163,10 @@ 9.11 */ 9.12 protected void addOverviewHeader(Content body) { 9.13 if (root.inlineTags().length > 0) { 9.14 - HtmlTree p = new HtmlTree(HtmlTag.P); 9.15 - p.addStyle(HtmlStyle.subTitle); 9.16 - addSummaryComment(root, p); 9.17 - Content div = HtmlTree.DIV(HtmlStyle.header, p); 9.18 + HtmlTree subTitleDiv = new HtmlTree(HtmlTag.DIV); 9.19 + subTitleDiv.addStyle(HtmlStyle.subTitle); 9.20 + addSummaryComment(root, subTitleDiv); 9.21 + Content div = HtmlTree.DIV(HtmlStyle.header, subTitleDiv); 9.22 Content see = seeLabel; 9.23 see.addContent(" "); 9.24 Content descPara = HtmlTree.P(see); 9.25 @@ -188,10 +188,10 @@ 9.26 protected void addOverviewComment(Content htmltree) { 9.27 if (root.inlineTags().length > 0) { 9.28 htmltree.addContent(getMarkerAnchor("overview_description")); 9.29 - HtmlTree p = new HtmlTree(HtmlTag.P); 9.30 - p.addStyle(HtmlStyle.subTitle); 9.31 - addInlineComment(root, p); 9.32 - htmltree.addContent(p); 9.33 + HtmlTree div = new HtmlTree(HtmlTag.DIV); 9.34 + div.addStyle(HtmlStyle.subTitle); 9.35 + addInlineComment(root, div); 9.36 + htmltree.addContent(div); 9.37 } 9.38 } 9.39
10.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/PackageWriterImpl.java Thu Apr 07 15:21:22 2011 -0700 10.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/PackageWriterImpl.java Sun Apr 10 10:25:12 2011 -0700 10.3 @@ -1,5 +1,5 @@ 10.4 /* 10.5 - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 10.6 + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. 10.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 10.8 * 10.9 * This code is free software; you can redistribute it and/or modify it 10.10 @@ -115,10 +115,10 @@ 10.11 tHeading.addContent(packageHead); 10.12 div.addContent(tHeading); 10.13 if (packageDoc.inlineTags().length > 0 && ! configuration.nocomment) { 10.14 - HtmlTree p = new HtmlTree(HtmlTag.P); 10.15 - p.addStyle(HtmlStyle.subTitle); 10.16 - addSummaryComment(packageDoc, p); 10.17 - div.addContent(p); 10.18 + HtmlTree subTitleDiv = new HtmlTree(HtmlTag.DIV); 10.19 + subTitleDiv.addStyle(HtmlStyle.subTitle); 10.20 + addSummaryComment(packageDoc, subTitleDiv); 10.21 + div.addContent(subTitleDiv); 10.22 Content space = getSpace(); 10.23 Content descLink = getHyperLink("", "package_description", 10.24 descriptionLabel, "", "");
11.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java Thu Apr 07 15:21:22 2011 -0700 11.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java Sun Apr 10 10:25:12 2011 -0700 11.3 @@ -1,5 +1,5 @@ 11.4 /* 11.5 - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 11.6 + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. 11.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 11.8 * 11.9 * This code is free software; you can redistribute it and/or modify it 11.10 @@ -188,8 +188,8 @@ 11.11 nextclassLabel = getResource("doclet.Next_Class"); 11.12 summaryLabel = getResource("doclet.Summary"); 11.13 detailLabel = getResource("doclet.Detail"); 11.14 - framesLabel = getResource("doclet.FRAMES"); 11.15 - noframesLabel = getResource("doclet.NO_FRAMES"); 11.16 + framesLabel = getResource("doclet.Frames"); 11.17 + noframesLabel = getResource("doclet.No_Frames"); 11.18 treeLabel = getResource("doclet.Tree"); 11.19 classLabel = getResource("doclet.Class"); 11.20 deprecatedLabel = getResource("doclet.navDeprecated");
12.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties Thu Apr 07 15:21:22 2011 -0700 12.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties Sun Apr 10 10:25:12 2011 -0700 12.3 @@ -11,54 +11,30 @@ 12.4 doclet.Interface_Hierarchy=Interface Hierarchy 12.5 doclet.Enum_Hierarchy=Enum Hierarchy 12.6 doclet.Annotation_Type_Hierarchy=Annotation Type Hierarchy 12.7 -# The following ALL CAPS words should be translated. It is used as "Previous" link on javadoc. 12.8 -doclet.Prev=PREV 12.9 -# The following ALL CAPS words should be translated. It is used as "Next" link on javadoc. 12.10 -doclet.Next=NEXT 12.11 -# The following ALL CAPS words should be translated. It is used as "Previous Class" link on javadoc. 12.12 -doclet.Prev_Class=PREV CLASS 12.13 -# The following ALL CAPS words should be translated. It is used as "Next Class" link on javadoc. 12.14 -doclet.Next_Class=NEXT CLASS 12.15 -# The following ALL CAPS words should be translated. It is used as "Previous Package" link on javadoc. 12.16 -doclet.Prev_Package=PREV PACKAGE 12.17 -# The following ALL CAPS words should be translated. It is used as "Next Package" link on javadoc. 12.18 -doclet.Next_Package=NEXT PACKAGE 12.19 -# The following ALL CAPS words should be translated. It is used as "Previous Letter" link on javadoc alphabetical index. 12.20 -doclet.Prev_Letter=PREV LETTER 12.21 -# The following ALL CAPS words should be translated. It is used as "Next Letter" link on javadoc alphabetical index. 12.22 -doclet.Next_Letter=NEXT LETTER 12.23 -# The following ALL CAPS words should be translated. It is used as "Show List" link on javadoc. 12.24 -doclet.Show_Lists=SHOW LISTS 12.25 -# The following ALL CAPS words should be translated. It is used as "Hide List" link on javadoc. 12.26 -doclet.Hide_Lists=HIDE LISTS 12.27 +doclet.Prev=Prev 12.28 +doclet.Next=Next 12.29 +doclet.Prev_Class=Prev Class 12.30 +doclet.Next_Class=Next Class 12.31 +doclet.Prev_Package=Prev Package 12.32 +doclet.Next_Package=Next Package 12.33 +doclet.Prev_Letter=Prev Letter 12.34 +doclet.Next_Letter=Next Letter 12.35 doclet.Href_Class_Title=class in {0} 12.36 doclet.Href_Interface_Title=interface in {0} 12.37 doclet.Href_Annotation_Title=annotation in {0} 12.38 doclet.Href_Enum_Title=enum in {0} 12.39 doclet.Href_Type_Param_Title=type parameter in {0} 12.40 doclet.Href_Class_Or_Interface_Title=class or interface in {0} 12.41 -# The following ALL CAPS words should be translated. It's used as SUMMARY: NESTED | FIELD | CONSTR | METHOD, meaning Nested Class Summary, Field Summary, Constructor Summary, or Method Summary. 12.42 -doclet.Summary=SUMMARY: 12.43 -# The following ALL CAPS words should be translated. It is used as DETAIL: FIELD | CONSTR | METHOD, meaning Field Detail, Constructor Detail, or Method Detail. 12.44 -doclet.Detail=DETAIL: 12.45 -# The following ALL CAPS words should be translated. It is used as "Nested" (Nested Class Summary) link on javadoc. 12.46 -doclet.navNested=NESTED 12.47 -# The following ALL CAPS words should be translated. It is used as "Optional" (Optional Element Summary) link on javadoc. 12.48 -doclet.navAnnotationTypeOptionalMember=OPTIONAL 12.49 -# The following ALL CAPS words should be translated. It is used as "Required" (Required Element Summary) link on javadoc. 12.50 -doclet.navAnnotationTypeRequiredMember=REQUIRED 12.51 -# The following ALL CAPS words should be translated. It is used as "Element" (Required Element Summary) link on javadoc. 12.52 -doclet.navAnnotationTypeMember=ELEMENT 12.53 -# The following ALL CAPS words should be translated. It is used as "Field" (Field Detail) link on javadoc. 12.54 -doclet.navField=FIELD 12.55 -# The following ALL CAPS words should be translated. It is used as "Enum Constants" link on javadoc. 12.56 -doclet.navEnum=ENUM CONSTANTS 12.57 -# The following ALL CAPS words should be translated. It is used as "Constructor" (Constructor Detail) link on javadoc. 12.58 -doclet.navConstructor=CONSTR 12.59 -# The following ALL CAPS words should be translated. It is used as "Method" (Method Detail) link on javadoc. 12.60 -doclet.navMethod=METHOD 12.61 -# The following resource does not seem to be used anymore. 12.62 -doclet.navFactoryMethod=FACTORY 12.63 +doclet.Summary=Summary: 12.64 +doclet.Detail=Detail: 12.65 +doclet.navNested=Nested 12.66 +doclet.navAnnotationTypeOptionalMember=Optional 12.67 +doclet.navAnnotationTypeRequiredMember=Required 12.68 +doclet.navAnnotationTypeMember=Element 12.69 +doclet.navField=Field 12.70 +doclet.navEnum=Enum Constants 12.71 +doclet.navConstructor=Constr 12.72 +doclet.navMethod=Method 12.73 doclet.Index=Index 12.74 doclet.Window_Single_Index=Index 12.75 doclet.Window_Split_Index={0}-Index 12.76 @@ -66,12 +42,6 @@ 12.77 doclet.Skip_navigation_links=Skip navigation links 12.78 doclet.New_Page=NewPage 12.79 doclet.None=None 12.80 -# The following resource does not seem to be used anymore 12.81 -doclet.CLASSES=CLASSES 12.82 -# The following resource does not seem to be used anymore 12.83 -doclet.MEMBERS=MEMBERS 12.84 -# The following resource does not seem to be used anymore 12.85 -doclet.NONE=NONE 12.86 doclet.Factory_Method_Detail=Static Factory Method Detail 12.87 doclet.navDeprecated=Deprecated 12.88 doclet.Deprecated_List=Deprecated List 12.89 @@ -136,10 +106,7 @@ 12.90 doclet.Option=Option 12.91 doclet.Or=Or 12.92 doclet.Frames=Frames 12.93 -# The following ALL CAPS words should be translated. It is used as "FRAMES" javadoc navigation link to indicate displaying the page with HTML frames. 12.94 -doclet.FRAMES=FRAMES 12.95 -# The following ALL CAPS words should be translated. It is used as "NO FRAMES" javadoc navigation link to indicate displaying the page without HTML frames. 12.96 -doclet.NO_FRAMES=NO FRAMES 12.97 +doclet.No_Frames=No Frames 12.98 doclet.Package_Hierarchies=Package Hierarchies: 12.99 doclet.Hierarchy_For_Package=Hierarchy For Package {0} 12.100 doclet.Source_Code=Source Code: 12.101 @@ -147,11 +114,10 @@ 12.102 doclet.Cannot_handle_no_packages=Cannot handle no packages. 12.103 doclet.Frame_Alert=Frame Alert 12.104 doclet.Overview-Member-Frame=Overview Member Frame 12.105 -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. 12.106 +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}. 12.107 doclet.No_Script_Message=JavaScript is disabled on your browser. 12.108 -doclet.Non_Frame_Version=Non-frame version. 12.109 +doclet.Non_Frame_Version=Non-frame version 12.110 doclet.Frame_Version=Frame version 12.111 -doclet.Link_To=Link to 12.112 doclet.Following_From_Class=Following copied from class: {0} 12.113 doclet.Following_From_Interface=Following copied from interface: {0} 12.114 doclet.Description_From_Interface=Description copied from interface: 12.115 @@ -200,7 +166,6 @@ 12.116 doclet.Help_annotation_type_line_1=Each annotation type has its own separate page with the following sections: 12.117 doclet.Help_annotation_type_line_2=Annotation Type declaration 12.118 doclet.Help_annotation_type_line_3=Annotation Type description 12.119 -doclet.The=The 12.120 doclet.Style_line_1=Javadoc style sheet 12.121 doclet.Style_line_2=Define colors, fonts and other style attributes here to override the defaults 12.122 doclet.Style_line_3=Page background color
13.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/stylesheet.css Thu Apr 07 15:21:22 2011 -0700 13.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/stylesheet.css Sun Apr 10 10:25:12 2011 -0700 13.3 @@ -142,19 +142,19 @@ 13.4 .subNav ul.navList { 13.5 float:left; 13.6 margin:0; 13.7 - font-size:0.7em; 13.8 + font-size:0.8em; 13.9 width:350px; 13.10 } 13.11 ul.subNavList { 13.12 float:left; 13.13 margin:0; 13.14 - font-size:0.7em; 13.15 + font-size:0.8em; 13.16 width:350px; 13.17 } 13.18 ul.subNavList li{ 13.19 list-style:none; 13.20 float:left; 13.21 - font-size:90%; 13.22 + font-size:98%; 13.23 } 13.24 /* 13.25 Page header and footer styles 13.26 @@ -183,8 +183,6 @@ 13.27 .subTitle { 13.28 margin:0; 13.29 padding-top:10px; 13.30 - font-size:0.75em; 13.31 - font-weight:bold; 13.32 } 13.33 /* 13.34 Page layout container styles
14.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 14.2 +++ b/src/share/classes/com/sun/tools/javac/api/ClientCodeWrapper.java Sun Apr 10 10:25:12 2011 -0700 14.3 @@ -0,0 +1,593 @@ 14.4 +/* 14.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 14.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 14.7 + * 14.8 + * This code is free software; you can redistribute it and/or modify it 14.9 + * under the terms of the GNU General Public License version 2 only, as 14.10 + * published by the Free Software Foundation. Oracle designates this 14.11 + * particular file as subject to the "Classpath" exception as provided 14.12 + * by Oracle in the LICENSE file that accompanied this code. 14.13 + * 14.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 14.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14.17 + * version 2 for more details (a copy is included in the LICENSE file that 14.18 + * accompanied this code). 14.19 + * 14.20 + * You should have received a copy of the GNU General Public License version 14.21 + * 2 along with this work; if not, write to the Free Software Foundation, 14.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 14.23 + * 14.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 14.25 + * or visit www.oracle.com if you need additional information or have any 14.26 + * questions. 14.27 + */ 14.28 + 14.29 + 14.30 +package com.sun.tools.javac.api; 14.31 + 14.32 +import java.io.IOException; 14.33 +import java.io.InputStream; 14.34 +import java.io.OutputStream; 14.35 +import java.io.Reader; 14.36 +import java.io.Writer; 14.37 +import java.net.URI; 14.38 +import java.util.ArrayList; 14.39 +import java.util.Collections; 14.40 +import java.util.HashMap; 14.41 +import java.util.Iterator; 14.42 +import java.util.List; 14.43 +import java.util.Map; 14.44 +import java.util.Set; 14.45 + 14.46 +import javax.lang.model.element.NestingKind; 14.47 +import javax.tools.Diagnostic; 14.48 +import javax.tools.FileObject; 14.49 +import javax.tools.JavaFileManager; 14.50 +import javax.tools.JavaFileManager.Location; 14.51 +import javax.tools.JavaFileObject; 14.52 + 14.53 +import com.sun.source.util.TaskEvent; 14.54 +import com.sun.source.util.TaskListener; 14.55 +import com.sun.tools.javac.util.ClientCodeException; 14.56 +import com.sun.tools.javac.util.Context; 14.57 +import java.lang.annotation.ElementType; 14.58 +import java.lang.annotation.Retention; 14.59 +import java.lang.annotation.RetentionPolicy; 14.60 +import java.lang.annotation.Target; 14.61 +import javax.lang.model.element.Modifier; 14.62 +import javax.tools.DiagnosticListener; 14.63 +import javax.tools.JavaFileObject.Kind; 14.64 + 14.65 +/** 14.66 + * Wrap objects to enable unchecked exceptions to be caught and handled. 14.67 + * 14.68 + * For each method, exceptions are handled as follows: 14.69 + * <ul> 14.70 + * <li>Checked exceptions are left alone and propogate upwards in the 14.71 + * obvious way, since they are an expected aspect of the method's 14.72 + * specification. 14.73 + * <li>Unchecked exceptions which have already been caught and wrapped in 14.74 + * ClientCodeException are left alone to continue propogating upwards. 14.75 + * <li>All other unchecked exceptions (i.e. subtypes of RuntimeException 14.76 + * and Error) and caught, and rethrown as a ClientCodeException with 14.77 + * its cause set to the original exception. 14.78 + * </ul> 14.79 + * 14.80 + * The intent is that ClientCodeException can be caught at an appropriate point 14.81 + * in the program and can be distinguished from any unanticipated unchecked 14.82 + * exceptions arising in the main body of the code (i.e. bugs.) When the 14.83 + * ClientCodeException has been caught, either a suitable message can be 14.84 + * generated, or if appropriate, the original cause can be rethrown. 14.85 + * 14.86 + * <p><b>This is NOT part of any supported API. 14.87 + * If you write code that depends on this, you do so at your own risk. 14.88 + * This code and its internal interfaces are subject to change or 14.89 + * deletion without notice.</b> 14.90 + */ 14.91 +public class ClientCodeWrapper { 14.92 + @Retention(RetentionPolicy.RUNTIME) 14.93 + @Target(ElementType.TYPE) 14.94 + public @interface Trusted { } 14.95 + 14.96 + public static ClientCodeWrapper instance(Context context) { 14.97 + ClientCodeWrapper instance = context.get(ClientCodeWrapper.class); 14.98 + if (instance == null) 14.99 + instance = new ClientCodeWrapper(context); 14.100 + return instance; 14.101 + } 14.102 + 14.103 + /** 14.104 + * A map to cache the results of whether or not a specific classes can 14.105 + * be "trusted", and thus does not need to be wrapped. 14.106 + */ 14.107 + Map<Class<?>, Boolean> trustedClasses; 14.108 + 14.109 + protected ClientCodeWrapper(Context context) { 14.110 + trustedClasses = new HashMap<Class<?>, Boolean>(); 14.111 + } 14.112 + 14.113 + public JavaFileManager wrap(JavaFileManager fm) { 14.114 + if (isTrusted(fm)) 14.115 + return fm; 14.116 + return new WrappedJavaFileManager(fm); 14.117 + } 14.118 + 14.119 + public FileObject wrap(FileObject fo) { 14.120 + if (isTrusted(fo)) 14.121 + return fo; 14.122 + return new WrappedFileObject(fo); 14.123 + } 14.124 + 14.125 + FileObject unwrap(FileObject fo) { 14.126 + if (fo instanceof WrappedFileObject) 14.127 + return ((WrappedFileObject) fo).clientFileObject; 14.128 + else 14.129 + return fo; 14.130 + } 14.131 + 14.132 + public JavaFileObject wrap(JavaFileObject fo) { 14.133 + if (isTrusted(fo)) 14.134 + return fo; 14.135 + return new WrappedJavaFileObject(fo); 14.136 + } 14.137 + 14.138 + public Iterable<JavaFileObject> wrapJavaFileObjects(Iterable<? extends JavaFileObject> list) { 14.139 + List<JavaFileObject> wrapped = new ArrayList<JavaFileObject>(); 14.140 + for (JavaFileObject fo : list) 14.141 + wrapped.add(wrap(fo)); 14.142 + return Collections.unmodifiableList(wrapped); 14.143 + } 14.144 + 14.145 + JavaFileObject unwrap(JavaFileObject fo) { 14.146 + if (fo instanceof WrappedJavaFileObject) 14.147 + return ((JavaFileObject) ((WrappedJavaFileObject) fo).clientFileObject); 14.148 + else 14.149 + return fo; 14.150 + } 14.151 + 14.152 + <T> DiagnosticListener<T> wrap(DiagnosticListener<T> dl) { 14.153 + if (isTrusted(dl)) 14.154 + return dl; 14.155 + return new WrappedDiagnosticListener<T>(dl); 14.156 + } 14.157 + 14.158 + TaskListener wrap(TaskListener tl) { 14.159 + if (isTrusted(tl)) 14.160 + return tl; 14.161 + return new WrappedTaskListener(tl); 14.162 + } 14.163 + 14.164 + protected boolean isTrusted(Object o) { 14.165 + Class<?> c = o.getClass(); 14.166 + Boolean trusted = trustedClasses.get(c); 14.167 + if (trusted == null) { 14.168 + trusted = c.getName().startsWith("com.sun.tools.javac.") 14.169 + || c.isAnnotationPresent(Trusted.class); 14.170 + trustedClasses.put(c, trusted); 14.171 + } 14.172 + return trusted; 14.173 + } 14.174 + 14.175 + // <editor-fold defaultstate="collapsed" desc="Wrapper classes"> 14.176 + 14.177 + // FIXME: all these classes should be converted to use multi-catch when 14.178 + // that is available in the bootstrap compiler. 14.179 + 14.180 + protected class WrappedJavaFileManager implements JavaFileManager { 14.181 + protected JavaFileManager clientJavaFileManager; 14.182 + WrappedJavaFileManager(JavaFileManager clientJavaFileManager) { 14.183 + clientJavaFileManager.getClass(); // null check 14.184 + this.clientJavaFileManager = clientJavaFileManager; 14.185 + } 14.186 + 14.187 + @Override 14.188 + public ClassLoader getClassLoader(Location location) { 14.189 + try { 14.190 + return clientJavaFileManager.getClassLoader(location); 14.191 + } catch (ClientCodeException e) { 14.192 + throw e; 14.193 + } catch (RuntimeException e) { 14.194 + throw new ClientCodeException(e); 14.195 + } catch (Error e) { 14.196 + throw new ClientCodeException(e); 14.197 + } 14.198 + } 14.199 + 14.200 + @Override 14.201 + public Iterable<JavaFileObject> list(Location location, String packageName, Set<Kind> kinds, boolean recurse) throws IOException { 14.202 + try { 14.203 + return wrapJavaFileObjects(clientJavaFileManager.list(location, packageName, kinds, recurse)); 14.204 + } catch (ClientCodeException e) { 14.205 + throw e; 14.206 + } catch (RuntimeException e) { 14.207 + throw new ClientCodeException(e); 14.208 + } catch (Error e) { 14.209 + throw new ClientCodeException(e); 14.210 + } 14.211 + } 14.212 + 14.213 + @Override 14.214 + public String inferBinaryName(Location location, JavaFileObject file) { 14.215 + try { 14.216 + return clientJavaFileManager.inferBinaryName(location, unwrap(file)); 14.217 + } catch (ClientCodeException e) { 14.218 + throw e; 14.219 + } catch (RuntimeException e) { 14.220 + throw new ClientCodeException(e); 14.221 + } catch (Error e) { 14.222 + throw new ClientCodeException(e); 14.223 + } 14.224 + } 14.225 + 14.226 + @Override 14.227 + public boolean isSameFile(FileObject a, FileObject b) { 14.228 + try { 14.229 + return clientJavaFileManager.isSameFile(unwrap(a), unwrap(b)); 14.230 + } catch (ClientCodeException e) { 14.231 + throw e; 14.232 + } catch (RuntimeException e) { 14.233 + throw new ClientCodeException(e); 14.234 + } catch (Error e) { 14.235 + throw new ClientCodeException(e); 14.236 + } 14.237 + } 14.238 + 14.239 + @Override 14.240 + public boolean handleOption(String current, Iterator<String> remaining) { 14.241 + try { 14.242 + return clientJavaFileManager.handleOption(current, remaining); 14.243 + } catch (ClientCodeException e) { 14.244 + throw e; 14.245 + } catch (RuntimeException e) { 14.246 + throw new ClientCodeException(e); 14.247 + } catch (Error e) { 14.248 + throw new ClientCodeException(e); 14.249 + } 14.250 + } 14.251 + 14.252 + @Override 14.253 + public boolean hasLocation(Location location) { 14.254 + try { 14.255 + return clientJavaFileManager.hasLocation(location); 14.256 + } catch (ClientCodeException e) { 14.257 + throw e; 14.258 + } catch (RuntimeException e) { 14.259 + throw new ClientCodeException(e); 14.260 + } catch (Error e) { 14.261 + throw new ClientCodeException(e); 14.262 + } 14.263 + } 14.264 + 14.265 + @Override 14.266 + public JavaFileObject getJavaFileForInput(Location location, String className, Kind kind) throws IOException { 14.267 + try { 14.268 + return wrap(clientJavaFileManager.getJavaFileForInput(location, className, kind)); 14.269 + } catch (ClientCodeException e) { 14.270 + throw e; 14.271 + } catch (RuntimeException e) { 14.272 + throw new ClientCodeException(e); 14.273 + } catch (Error e) { 14.274 + throw new ClientCodeException(e); 14.275 + } 14.276 + } 14.277 + 14.278 + @Override 14.279 + public JavaFileObject getJavaFileForOutput(Location location, String className, Kind kind, FileObject sibling) throws IOException { 14.280 + try { 14.281 + return wrap(clientJavaFileManager.getJavaFileForOutput(location, className, kind, unwrap(sibling))); 14.282 + } catch (ClientCodeException e) { 14.283 + throw e; 14.284 + } catch (RuntimeException e) { 14.285 + throw new ClientCodeException(e); 14.286 + } catch (Error e) { 14.287 + throw new ClientCodeException(e); 14.288 + } 14.289 + } 14.290 + 14.291 + @Override 14.292 + public FileObject getFileForInput(Location location, String packageName, String relativeName) throws IOException { 14.293 + try { 14.294 + return wrap(clientJavaFileManager.getFileForInput(location, packageName, relativeName)); 14.295 + } catch (ClientCodeException e) { 14.296 + throw e; 14.297 + } catch (RuntimeException e) { 14.298 + throw new ClientCodeException(e); 14.299 + } catch (Error e) { 14.300 + throw new ClientCodeException(e); 14.301 + } 14.302 + } 14.303 + 14.304 + @Override 14.305 + public FileObject getFileForOutput(Location location, String packageName, String relativeName, FileObject sibling) throws IOException { 14.306 + try { 14.307 + return wrap(clientJavaFileManager.getFileForOutput(location, packageName, relativeName, unwrap(sibling))); 14.308 + } catch (ClientCodeException e) { 14.309 + throw e; 14.310 + } catch (RuntimeException e) { 14.311 + throw new ClientCodeException(e); 14.312 + } catch (Error e) { 14.313 + throw new ClientCodeException(e); 14.314 + } 14.315 + } 14.316 + 14.317 + @Override 14.318 + public void flush() throws IOException { 14.319 + try { 14.320 + clientJavaFileManager.flush(); 14.321 + } catch (ClientCodeException e) { 14.322 + throw e; 14.323 + } catch (RuntimeException e) { 14.324 + throw new ClientCodeException(e); 14.325 + } catch (Error e) { 14.326 + throw new ClientCodeException(e); 14.327 + } 14.328 + } 14.329 + 14.330 + @Override 14.331 + public void close() throws IOException { 14.332 + try { 14.333 + clientJavaFileManager.close(); 14.334 + } catch (ClientCodeException e) { 14.335 + throw e; 14.336 + } catch (RuntimeException e) { 14.337 + throw new ClientCodeException(e); 14.338 + } catch (Error e) { 14.339 + throw new ClientCodeException(e); 14.340 + } 14.341 + } 14.342 + 14.343 + @Override 14.344 + public int isSupportedOption(String option) { 14.345 + try { 14.346 + return clientJavaFileManager.isSupportedOption(option); 14.347 + } catch (ClientCodeException e) { 14.348 + throw e; 14.349 + } catch (RuntimeException e) { 14.350 + throw new ClientCodeException(e); 14.351 + } catch (Error e) { 14.352 + throw new ClientCodeException(e); 14.353 + } 14.354 + } 14.355 + } 14.356 + 14.357 + protected class WrappedFileObject implements FileObject { 14.358 + protected FileObject clientFileObject; 14.359 + WrappedFileObject(FileObject clientFileObject) { 14.360 + clientFileObject.getClass(); // null check 14.361 + this.clientFileObject = clientFileObject; 14.362 + } 14.363 + 14.364 + @Override 14.365 + public URI toUri() { 14.366 + try { 14.367 + return clientFileObject.toUri(); 14.368 + } catch (ClientCodeException e) { 14.369 + throw e; 14.370 + } catch (RuntimeException e) { 14.371 + throw new ClientCodeException(e); 14.372 + } catch (Error e) { 14.373 + throw new ClientCodeException(e); 14.374 + } 14.375 + } 14.376 + 14.377 + @Override 14.378 + public String getName() { 14.379 + try { 14.380 + return clientFileObject.getName(); 14.381 + } catch (ClientCodeException e) { 14.382 + throw e; 14.383 + } catch (RuntimeException e) { 14.384 + throw new ClientCodeException(e); 14.385 + } catch (Error e) { 14.386 + throw new ClientCodeException(e); 14.387 + } 14.388 + } 14.389 + 14.390 + @Override 14.391 + public InputStream openInputStream() throws IOException { 14.392 + try { 14.393 + return clientFileObject.openInputStream(); 14.394 + } catch (ClientCodeException e) { 14.395 + throw e; 14.396 + } catch (RuntimeException e) { 14.397 + throw new ClientCodeException(e); 14.398 + } catch (Error e) { 14.399 + throw new ClientCodeException(e); 14.400 + } 14.401 + } 14.402 + 14.403 + @Override 14.404 + public OutputStream openOutputStream() throws IOException { 14.405 + try { 14.406 + return clientFileObject.openOutputStream(); 14.407 + } catch (ClientCodeException e) { 14.408 + throw e; 14.409 + } catch (RuntimeException e) { 14.410 + throw new ClientCodeException(e); 14.411 + } catch (Error e) { 14.412 + throw new ClientCodeException(e); 14.413 + } 14.414 + } 14.415 + 14.416 + @Override 14.417 + public Reader openReader(boolean ignoreEncodingErrors) throws IOException { 14.418 + try { 14.419 + return clientFileObject.openReader(ignoreEncodingErrors); 14.420 + } catch (ClientCodeException e) { 14.421 + throw e; 14.422 + } catch (RuntimeException e) { 14.423 + throw new ClientCodeException(e); 14.424 + } catch (Error e) { 14.425 + throw new ClientCodeException(e); 14.426 + } 14.427 + } 14.428 + 14.429 + @Override 14.430 + public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException { 14.431 + try { 14.432 + return clientFileObject.getCharContent(ignoreEncodingErrors); 14.433 + } catch (ClientCodeException e) { 14.434 + throw e; 14.435 + } catch (RuntimeException e) { 14.436 + throw new ClientCodeException(e); 14.437 + } catch (Error e) { 14.438 + throw new ClientCodeException(e); 14.439 + } 14.440 + } 14.441 + 14.442 + @Override 14.443 + public Writer openWriter() throws IOException { 14.444 + try { 14.445 + return clientFileObject.openWriter(); 14.446 + } catch (ClientCodeException e) { 14.447 + throw e; 14.448 + } catch (RuntimeException e) { 14.449 + throw new ClientCodeException(e); 14.450 + } catch (Error e) { 14.451 + throw new ClientCodeException(e); 14.452 + } 14.453 + } 14.454 + 14.455 + @Override 14.456 + public long getLastModified() { 14.457 + try { 14.458 + return clientFileObject.getLastModified(); 14.459 + } catch (ClientCodeException e) { 14.460 + throw e; 14.461 + } catch (RuntimeException e) { 14.462 + throw new ClientCodeException(e); 14.463 + } catch (Error e) { 14.464 + throw new ClientCodeException(e); 14.465 + } 14.466 + } 14.467 + 14.468 + @Override 14.469 + public boolean delete() { 14.470 + try { 14.471 + return clientFileObject.delete(); 14.472 + } catch (ClientCodeException e) { 14.473 + throw e; 14.474 + } catch (RuntimeException e) { 14.475 + throw new ClientCodeException(e); 14.476 + } catch (Error e) { 14.477 + throw new ClientCodeException(e); 14.478 + } 14.479 + } 14.480 + } 14.481 + 14.482 + protected class WrappedJavaFileObject extends WrappedFileObject implements JavaFileObject { 14.483 + WrappedJavaFileObject(JavaFileObject clientJavaFileObject) { 14.484 + super(clientJavaFileObject); 14.485 + } 14.486 + 14.487 + @Override 14.488 + public Kind getKind() { 14.489 + try { 14.490 + return ((JavaFileObject)clientFileObject).getKind(); 14.491 + } catch (ClientCodeException e) { 14.492 + throw e; 14.493 + } catch (RuntimeException e) { 14.494 + throw new ClientCodeException(e); 14.495 + } catch (Error e) { 14.496 + throw new ClientCodeException(e); 14.497 + } 14.498 + } 14.499 + 14.500 + @Override 14.501 + public boolean isNameCompatible(String simpleName, Kind kind) { 14.502 + try { 14.503 + return ((JavaFileObject)clientFileObject).isNameCompatible(simpleName, kind); 14.504 + } catch (ClientCodeException e) { 14.505 + throw e; 14.506 + } catch (RuntimeException e) { 14.507 + throw new ClientCodeException(e); 14.508 + } catch (Error e) { 14.509 + throw new ClientCodeException(e); 14.510 + } 14.511 + } 14.512 + 14.513 + @Override 14.514 + public NestingKind getNestingKind() { 14.515 + try { 14.516 + return ((JavaFileObject)clientFileObject).getNestingKind(); 14.517 + } catch (ClientCodeException e) { 14.518 + throw e; 14.519 + } catch (RuntimeException e) { 14.520 + throw new ClientCodeException(e); 14.521 + } catch (Error e) { 14.522 + throw new ClientCodeException(e); 14.523 + } 14.524 + } 14.525 + 14.526 + @Override 14.527 + public Modifier getAccessLevel() { 14.528 + try { 14.529 + return ((JavaFileObject)clientFileObject).getAccessLevel(); 14.530 + } catch (ClientCodeException e) { 14.531 + throw e; 14.532 + } catch (RuntimeException e) { 14.533 + throw new ClientCodeException(e); 14.534 + } catch (Error e) { 14.535 + throw new ClientCodeException(e); 14.536 + } 14.537 + } 14.538 + } 14.539 + 14.540 + protected class WrappedDiagnosticListener<T> implements DiagnosticListener<T> { 14.541 + protected DiagnosticListener<T> clientDiagnosticListener; 14.542 + WrappedDiagnosticListener(DiagnosticListener<T> clientDiagnosticListener) { 14.543 + clientDiagnosticListener.getClass(); // null check 14.544 + this.clientDiagnosticListener = clientDiagnosticListener; 14.545 + } 14.546 + 14.547 + @Override 14.548 + public void report(Diagnostic<? extends T> diagnostic) { 14.549 + try { 14.550 + clientDiagnosticListener.report(diagnostic); 14.551 + } catch (ClientCodeException e) { 14.552 + throw e; 14.553 + } catch (RuntimeException e) { 14.554 + throw new ClientCodeException(e); 14.555 + } catch (Error e) { 14.556 + throw new ClientCodeException(e); 14.557 + } 14.558 + } 14.559 + } 14.560 + 14.561 + protected class WrappedTaskListener implements TaskListener { 14.562 + protected TaskListener clientTaskListener; 14.563 + WrappedTaskListener(TaskListener clientTaskListener) { 14.564 + clientTaskListener.getClass(); // null check 14.565 + this.clientTaskListener = clientTaskListener; 14.566 + } 14.567 + 14.568 + @Override 14.569 + public void started(TaskEvent ev) { 14.570 + try { 14.571 + clientTaskListener.started(ev); 14.572 + } catch (ClientCodeException e) { 14.573 + throw e; 14.574 + } catch (RuntimeException e) { 14.575 + throw new ClientCodeException(e); 14.576 + } catch (Error e) { 14.577 + throw new ClientCodeException(e); 14.578 + } 14.579 + } 14.580 + 14.581 + @Override 14.582 + public void finished(TaskEvent ev) { 14.583 + try { 14.584 + clientTaskListener.finished(ev); 14.585 + } catch (ClientCodeException e) { 14.586 + throw e; 14.587 + } catch (RuntimeException e) { 14.588 + throw new ClientCodeException(e); 14.589 + } catch (Error e) { 14.590 + throw new ClientCodeException(e); 14.591 + } 14.592 + } 14.593 + } 14.594 + 14.595 + // </editor-fold> 14.596 +}
15.1 --- a/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java Thu Apr 07 15:21:22 2011 -0700 15.2 +++ b/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java Sun Apr 10 10:25:12 2011 -0700 15.3 @@ -65,7 +65,7 @@ 15.4 * @author Jonathan Gibbons 15.5 */ 15.6 public class JavacTaskImpl extends JavacTask { 15.7 - private JavacTool tool; 15.8 + private ClientCodeWrapper ccw; 15.9 private Main compilerMain; 15.10 private JavaCompiler compiler; 15.11 private Locale locale; 15.12 @@ -80,12 +80,11 @@ 15.13 15.14 private Integer result = null; 15.15 15.16 - JavacTaskImpl(JavacTool tool, 15.17 - Main compilerMain, 15.18 + JavacTaskImpl(Main compilerMain, 15.19 String[] args, 15.20 Context context, 15.21 List<JavaFileObject> fileObjects) { 15.22 - this.tool = tool; 15.23 + this.ccw = ClientCodeWrapper.instance(context); 15.24 this.compilerMain = compilerMain; 15.25 this.args = args; 15.26 this.context = context; 15.27 @@ -94,17 +93,15 @@ 15.28 // null checks 15.29 compilerMain.getClass(); 15.30 args.getClass(); 15.31 - context.getClass(); 15.32 fileObjects.getClass(); 15.33 } 15.34 15.35 - JavacTaskImpl(JavacTool tool, 15.36 - Main compilerMain, 15.37 + JavacTaskImpl(Main compilerMain, 15.38 Iterable<String> flags, 15.39 Context context, 15.40 Iterable<String> classes, 15.41 Iterable<? extends JavaFileObject> fileObjects) { 15.42 - this(tool, compilerMain, toArray(flags, classes), context, toList(fileObjects)); 15.43 + this(compilerMain, toArray(flags, classes), context, toList(fileObjects)); 15.44 } 15.45 15.46 static private String[] toArray(Iterable<String> flags, Iterable<String> classes) { 15.47 @@ -131,7 +128,7 @@ 15.48 if (!used.getAndSet(true)) { 15.49 initContext(); 15.50 notYetEntered = new HashMap<JavaFileObject, JCCompilationUnit>(); 15.51 - compilerMain.setFatalErrors(true); 15.52 + compilerMain.setAPIMode(true); 15.53 result = compilerMain.compile(args, context, fileObjects, processors); 15.54 cleanup(); 15.55 return result == 0; 15.56 @@ -185,31 +182,9 @@ 15.57 if (context.get(TaskListener.class) != null) 15.58 context.put(TaskListener.class, (TaskListener)null); 15.59 if (taskListener != null) 15.60 - context.put(TaskListener.class, wrap(taskListener)); 15.61 + context.put(TaskListener.class, ccw.wrap(taskListener)); 15.62 //initialize compiler's default locale 15.63 - JavacMessages.instance(context).setCurrentLocale(locale); 15.64 - } 15.65 - // where 15.66 - private TaskListener wrap(final TaskListener tl) { 15.67 - tl.getClass(); // null check 15.68 - return new TaskListener() { 15.69 - public void started(TaskEvent e) { 15.70 - try { 15.71 - tl.started(e); 15.72 - } catch (Throwable t) { 15.73 - throw new ClientCodeException(t); 15.74 - } 15.75 - } 15.76 - 15.77 - public void finished(TaskEvent e) { 15.78 - try { 15.79 - tl.finished(e); 15.80 - } catch (Throwable t) { 15.81 - throw new ClientCodeException(t); 15.82 - } 15.83 - } 15.84 - 15.85 - }; 15.86 + context.put(Locale.class, locale); 15.87 } 15.88 15.89 void cleanup() {
16.1 --- a/src/share/classes/com/sun/tools/javac/api/JavacTool.java Thu Apr 07 15:21:22 2011 -0700 16.2 +++ b/src/share/classes/com/sun/tools/javac/api/JavacTool.java Sun Apr 10 10:25:12 2011 -0700 16.3 @@ -28,8 +28,10 @@ 16.4 import java.io.File; 16.5 import java.io.InputStream; 16.6 import java.io.OutputStream; 16.7 +import java.io.OutputStreamWriter; 16.8 import java.io.PrintWriter; 16.9 import java.io.Writer; 16.10 +import java.nio.charset.Charset; 16.11 import java.util.ArrayList; 16.12 import java.util.Collections; 16.13 import java.util.EnumSet; 16.14 @@ -47,12 +49,11 @@ 16.15 import com.sun.tools.javac.main.Main; 16.16 import com.sun.tools.javac.main.RecognizedOptions.GrumpyHelper; 16.17 import com.sun.tools.javac.main.RecognizedOptions; 16.18 +import com.sun.tools.javac.util.ClientCodeException; 16.19 import com.sun.tools.javac.util.Context; 16.20 import com.sun.tools.javac.util.Log; 16.21 -import com.sun.tools.javac.util.JavacMessages; 16.22 import com.sun.tools.javac.util.Options; 16.23 import com.sun.tools.javac.util.Pair; 16.24 -import java.nio.charset.Charset; 16.25 16.26 /** 16.27 * TODO: describe com.sun.tools.javac.api.Tool 16.28 @@ -145,10 +146,13 @@ 16.29 Locale locale, 16.30 Charset charset) { 16.31 Context context = new Context(); 16.32 - JavacMessages.instance(context).setCurrentLocale(locale); 16.33 + context.put(Locale.class, locale); 16.34 if (diagnosticListener != null) 16.35 context.put(DiagnosticListener.class, diagnosticListener); 16.36 - context.put(Log.outKey, new PrintWriter(System.err, true)); // FIXME 16.37 + PrintWriter pw = (charset == null) 16.38 + ? new PrintWriter(System.err, true) 16.39 + : new PrintWriter(new OutputStreamWriter(System.err, charset), true); 16.40 + context.put(Log.outKey, pw); 16.41 return new JavacFileManager(context, true, charset); 16.42 } 16.43 16.44 @@ -159,38 +163,45 @@ 16.45 Iterable<String> classes, 16.46 Iterable<? extends JavaFileObject> compilationUnits) 16.47 { 16.48 - final String kindMsg = "All compilation units must be of SOURCE kind"; 16.49 - if (options != null) 16.50 - for (String option : options) 16.51 - option.getClass(); // null check 16.52 - if (classes != null) { 16.53 - for (String cls : classes) 16.54 - if (!SourceVersion.isName(cls)) // implicit null check 16.55 - throw new IllegalArgumentException("Not a valid class name: " + cls); 16.56 + try { 16.57 + Context context = new Context(); 16.58 + ClientCodeWrapper ccw = ClientCodeWrapper.instance(context); 16.59 + 16.60 + final String kindMsg = "All compilation units must be of SOURCE kind"; 16.61 + if (options != null) 16.62 + for (String option : options) 16.63 + option.getClass(); // null check 16.64 + if (classes != null) { 16.65 + for (String cls : classes) 16.66 + if (!SourceVersion.isName(cls)) // implicit null check 16.67 + throw new IllegalArgumentException("Not a valid class name: " + cls); 16.68 + } 16.69 + if (compilationUnits != null) { 16.70 + compilationUnits = ccw.wrapJavaFileObjects(compilationUnits); // implicit null check 16.71 + for (JavaFileObject cu : compilationUnits) { 16.72 + if (cu.getKind() != JavaFileObject.Kind.SOURCE) 16.73 + throw new IllegalArgumentException(kindMsg); 16.74 + } 16.75 + } 16.76 + 16.77 + if (diagnosticListener != null) 16.78 + context.put(DiagnosticListener.class, ccw.wrap(diagnosticListener)); 16.79 + 16.80 + if (out == null) 16.81 + context.put(Log.outKey, new PrintWriter(System.err, true)); 16.82 + else 16.83 + context.put(Log.outKey, new PrintWriter(out, true)); 16.84 + 16.85 + if (fileManager == null) 16.86 + fileManager = getStandardFileManager(diagnosticListener, null, null); 16.87 + fileManager = ccw.wrap(fileManager); 16.88 + context.put(JavaFileManager.class, fileManager); 16.89 + processOptions(context, fileManager, options); 16.90 + Main compiler = new Main("javacTask", context.get(Log.outKey)); 16.91 + return new JavacTaskImpl(compiler, options, context, classes, compilationUnits); 16.92 + } catch (ClientCodeException ex) { 16.93 + throw new RuntimeException(ex.getCause()); 16.94 } 16.95 - if (compilationUnits != null) { 16.96 - for (JavaFileObject cu : compilationUnits) { 16.97 - if (cu.getKind() != JavaFileObject.Kind.SOURCE) // implicit null check 16.98 - throw new IllegalArgumentException(kindMsg); 16.99 - } 16.100 - } 16.101 - 16.102 - Context context = new Context(); 16.103 - 16.104 - if (diagnosticListener != null) 16.105 - context.put(DiagnosticListener.class, diagnosticListener); 16.106 - 16.107 - if (out == null) 16.108 - context.put(Log.outKey, new PrintWriter(System.err, true)); 16.109 - else 16.110 - context.put(Log.outKey, new PrintWriter(out, true)); 16.111 - 16.112 - if (fileManager == null) 16.113 - fileManager = getStandardFileManager(diagnosticListener, null, null); 16.114 - context.put(JavaFileManager.class, fileManager); 16.115 - processOptions(context, fileManager, options); 16.116 - Main compiler = new Main("javacTask", context.get(Log.outKey)); 16.117 - return new JavacTaskImpl(this, compiler, options, context, classes, compilationUnits); 16.118 } 16.119 16.120 private static void processOptions(Context context,
17.1 --- a/src/share/classes/com/sun/tools/javac/code/Symtab.java Thu Apr 07 15:21:22 2011 -0700 17.2 +++ b/src/share/classes/com/sun/tools/javac/code/Symtab.java Sun Apr 10 10:25:12 2011 -0700 17.3 @@ -125,12 +125,11 @@ 17.4 public final Type stringBuilderType; 17.5 public final Type cloneableType; 17.6 public final Type serializableType; 17.7 - public final Type transientMethodHandleType; // transient - 292 17.8 public final Type methodHandleType; 17.9 - public final Type transientPolymorphicSignatureType; // transient - 292 17.10 public final Type polymorphicSignatureType; 17.11 public final Type throwableType; 17.12 public final Type errorType; 17.13 + public final Type interruptedExceptionType; 17.14 public final Type illegalArgumentExceptionType; 17.15 public final Type exceptionType; 17.16 public final Type runtimeExceptionType; 17.17 @@ -435,12 +434,11 @@ 17.18 cloneableType = enterClass("java.lang.Cloneable"); 17.19 throwableType = enterClass("java.lang.Throwable"); 17.20 serializableType = enterClass("java.io.Serializable"); 17.21 - transientMethodHandleType = enterClass("java.dyn.MethodHandle"); // transient - 292 17.22 methodHandleType = enterClass("java.lang.invoke.MethodHandle"); 17.23 - transientPolymorphicSignatureType = enterClass("java.dyn.MethodHandle$PolymorphicSignature"); // transient - 292 17.24 polymorphicSignatureType = enterClass("java.lang.invoke.MethodHandle$PolymorphicSignature"); 17.25 errorType = enterClass("java.lang.Error"); 17.26 illegalArgumentExceptionType = enterClass("java.lang.IllegalArgumentException"); 17.27 + interruptedExceptionType = enterClass("java.lang.InterruptedException"); 17.28 exceptionType = enterClass("java.lang.Exception"); 17.29 runtimeExceptionType = enterClass("java.lang.RuntimeException"); 17.30 classNotFoundExceptionType = enterClass("java.lang.ClassNotFoundException"); 17.31 @@ -480,9 +478,9 @@ 17.32 autoCloseableType.tsym); 17.33 trustMeType = enterClass("java.lang.SafeVarargs"); 17.34 17.35 + synthesizeEmptyInterfaceIfMissing(autoCloseableType); 17.36 synthesizeEmptyInterfaceIfMissing(cloneableType); 17.37 synthesizeEmptyInterfaceIfMissing(serializableType); 17.38 - synthesizeEmptyInterfaceIfMissing(transientPolymorphicSignatureType); // transient - 292 17.39 synthesizeEmptyInterfaceIfMissing(polymorphicSignatureType); 17.40 synthesizeBoxTypeIfMissing(doubleType); 17.41 synthesizeBoxTypeIfMissing(floatType);
18.1 --- a/src/share/classes/com/sun/tools/javac/code/Types.java Thu Apr 07 15:21:22 2011 -0700 18.2 +++ b/src/share/classes/com/sun/tools/javac/code/Types.java Sun Apr 10 10:25:12 2011 -0700 18.3 @@ -2461,6 +2461,22 @@ 18.4 } 18.5 }; 18.6 18.7 + public Type createMethodTypeWithReturn(Type original, Type newReturn) { 18.8 + return original.accept(methodWithReturn, newReturn); 18.9 + } 18.10 + // where 18.11 + private final MapVisitor<Type> methodWithReturn = new MapVisitor<Type>() { 18.12 + public Type visitType(Type t, Type newReturn) { 18.13 + throw new IllegalArgumentException("Not a method type: " + t); 18.14 + } 18.15 + public Type visitMethodType(MethodType t, Type newReturn) { 18.16 + return new MethodType(t.argtypes, newReturn, t.thrown, t.tsym); 18.17 + } 18.18 + public Type visitForAll(ForAll t, Type newReturn) { 18.19 + return new ForAll(t.tvars, t.qtype.accept(this, newReturn)); 18.20 + } 18.21 + }; 18.22 + 18.23 // <editor-fold defaultstate="collapsed" desc="createErrorType"> 18.24 public Type createErrorType(Type originalType) { 18.25 return new ErrorType(originalType, syms.errSymbol);
19.1 --- a/src/share/classes/com/sun/tools/javac/comp/Attr.java Thu Apr 07 15:21:22 2011 -0700 19.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java Sun Apr 10 10:25:12 2011 -0700 19.3 @@ -1089,6 +1089,10 @@ 19.4 if (resource.getTag() == JCTree.VARDEF) { 19.5 attribStat(resource, tryEnv); 19.6 chk.checkType(resource, resource.type, syms.autoCloseableType, "try.not.applicable.to.type"); 19.7 + 19.8 + //check that resource type cannot throw InterruptedException 19.9 + checkAutoCloseable(resource.pos(), localEnv, resource.type); 19.10 + 19.11 VarSymbol var = (VarSymbol)TreeInfo.symbolFor(resource); 19.12 var.setData(ElementKind.RESOURCE_VARIABLE); 19.13 } else { 19.14 @@ -1127,6 +1131,35 @@ 19.15 result = null; 19.16 } 19.17 19.18 + void checkAutoCloseable(DiagnosticPosition pos, Env<AttrContext> env, Type resource) { 19.19 + if (!resource.isErroneous() && 19.20 + types.asSuper(resource, syms.autoCloseableType.tsym) != null) { 19.21 + Symbol close = syms.noSymbol; 19.22 + boolean prevDeferDiags = log.deferDiagnostics; 19.23 + Queue<JCDiagnostic> prevDeferredDiags = log.deferredDiagnostics; 19.24 + try { 19.25 + log.deferDiagnostics = true; 19.26 + log.deferredDiagnostics = ListBuffer.lb(); 19.27 + close = rs.resolveQualifiedMethod(pos, 19.28 + env, 19.29 + resource, 19.30 + names.close, 19.31 + List.<Type>nil(), 19.32 + List.<Type>nil()); 19.33 + } 19.34 + finally { 19.35 + log.deferDiagnostics = prevDeferDiags; 19.36 + log.deferredDiagnostics = prevDeferredDiags; 19.37 + } 19.38 + if (close.kind == MTH && 19.39 + close.overrides(syms.autoCloseableClose, resource.tsym, types, true) && 19.40 + chk.isHandled(syms.interruptedExceptionType, types.memberType(resource, close).getThrownTypes()) && 19.41 + env.info.lint.isEnabled(LintCategory.TRY)) { 19.42 + log.warning(LintCategory.TRY, pos, "try.resource.throws.interrupted.exc", resource); 19.43 + } 19.44 + } 19.45 + } 19.46 + 19.47 public void visitConditional(JCConditional tree) { 19.48 attribExpr(tree.cond, env, syms.booleanType); 19.49 attribExpr(tree.truepart, env); 19.50 @@ -1580,7 +1613,7 @@ 19.51 // Attribute clazz expression and store 19.52 // symbol + type back into the attributed tree. 19.53 Type clazztype = attribType(clazz, env); 19.54 - Pair<Scope,Scope> mapping = getSyntheticScopeMapping(clazztype, cdef != null); 19.55 + Pair<Scope,Scope> mapping = getSyntheticScopeMapping(clazztype); 19.56 clazztype = chk.checkDiamond(tree, clazztype); 19.57 chk.validate(clazz, localEnv); 19.58 if (tree.encl != null) { 19.59 @@ -1778,62 +1811,48 @@ 19.60 Pair<Scope, Scope> mapping, 19.61 List<Type> argtypes, 19.62 List<Type> typeargtypes) { 19.63 - if (clazztype.isErroneous() || mapping == erroneousMapping) { 19.64 + if (clazztype.isErroneous() || 19.65 + clazztype.isInterface() || 19.66 + mapping == erroneousMapping) { 19.67 //if the type of the instance creation expression is erroneous, 19.68 - //or something prevented us to form a valid mapping, return the 19.69 - //(possibly erroneous) type unchanged 19.70 + //or if it's an interface, or if something prevented us to form a valid 19.71 + //mapping, return the (possibly erroneous) type unchanged 19.72 return clazztype; 19.73 } 19.74 - else if (clazztype.isInterface()) { 19.75 - //if the type of the instance creation expression is an interface 19.76 - //skip the method resolution step (JLS 15.12.2.7). The type to be 19.77 - //inferred is of the kind <X1,X2, ... Xn>C<X1,X2, ... Xn> 19.78 - clazztype = new ForAll(clazztype.tsym.type.allparams(), clazztype.tsym.type) { 19.79 - @Override 19.80 - public List<Type> getConstraints(TypeVar tv, ConstraintKind ck) { 19.81 - switch (ck) { 19.82 - case EXTENDS: return types.getBounds(tv); 19.83 - default: return List.nil(); 19.84 - } 19.85 - } 19.86 - @Override 19.87 - public Type inst(List<Type> inferred, Types types) throws Infer.NoInstanceException { 19.88 - // check that inferred bounds conform to their bounds 19.89 - infer.checkWithinBounds(tvars, 19.90 - types.subst(tvars, tvars, inferred), Warner.noWarnings); 19.91 - return super.inst(inferred, types); 19.92 - } 19.93 - }; 19.94 + 19.95 + //dup attribution environment and augment the set of inference variables 19.96 + Env<AttrContext> localEnv = env.dup(tree); 19.97 + localEnv.info.tvars = clazztype.tsym.type.getTypeArguments(); 19.98 + 19.99 + //if the type of the instance creation expression is a class type 19.100 + //apply method resolution inference (JLS 15.12.2.7). The return type 19.101 + //of the resolved constructor will be a partially instantiated type 19.102 + ((ClassSymbol) clazztype.tsym).members_field = mapping.snd; 19.103 + Symbol constructor; 19.104 + try { 19.105 + constructor = rs.resolveDiamond(tree.pos(), 19.106 + localEnv, 19.107 + clazztype.tsym.type, 19.108 + argtypes, 19.109 + typeargtypes); 19.110 + } finally { 19.111 + ((ClassSymbol) clazztype.tsym).members_field = mapping.fst; 19.112 + } 19.113 + if (constructor.kind == MTH) { 19.114 + ClassType ct = new ClassType(clazztype.getEnclosingType(), 19.115 + clazztype.tsym.type.getTypeArguments(), 19.116 + clazztype.tsym); 19.117 + clazztype = checkMethod(ct, 19.118 + constructor, 19.119 + localEnv, 19.120 + tree.args, 19.121 + argtypes, 19.122 + typeargtypes, 19.123 + localEnv.info.varArgs).getReturnType(); 19.124 } else { 19.125 - //if the type of the instance creation expression is a class type 19.126 - //apply method resolution inference (JLS 15.12.2.7). The return type 19.127 - //of the resolved constructor will be a partially instantiated type 19.128 - ((ClassSymbol) clazztype.tsym).members_field = mapping.snd; 19.129 - Symbol constructor; 19.130 - try { 19.131 - constructor = rs.resolveDiamond(tree.pos(), 19.132 - env, 19.133 - clazztype.tsym.type, 19.134 - argtypes, 19.135 - typeargtypes); 19.136 - } finally { 19.137 - ((ClassSymbol) clazztype.tsym).members_field = mapping.fst; 19.138 - } 19.139 - if (constructor.kind == MTH) { 19.140 - ClassType ct = new ClassType(clazztype.getEnclosingType(), 19.141 - clazztype.tsym.type.getTypeArguments(), 19.142 - clazztype.tsym); 19.143 - clazztype = checkMethod(ct, 19.144 - constructor, 19.145 - env, 19.146 - tree.args, 19.147 - argtypes, 19.148 - typeargtypes, 19.149 - env.info.varArgs).getReturnType(); 19.150 - } else { 19.151 - clazztype = syms.errType; 19.152 - } 19.153 + clazztype = syms.errType; 19.154 } 19.155 + 19.156 if (clazztype.tag == FORALL && !pt.isErroneous()) { 19.157 //if the resolved constructor's return type has some uninferred 19.158 //type-variables, infer them using the expected type and declared 19.159 @@ -1863,34 +1882,28 @@ 19.160 * inference. The inferred return type of the synthetic constructor IS 19.161 * the inferred type for the diamond operator. 19.162 */ 19.163 - private Pair<Scope, Scope> getSyntheticScopeMapping(Type ctype, boolean overrideProtectedAccess) { 19.164 + private Pair<Scope, Scope> getSyntheticScopeMapping(Type ctype) { 19.165 if (ctype.tag != CLASS) { 19.166 return erroneousMapping; 19.167 } 19.168 + 19.169 Pair<Scope, Scope> mapping = 19.170 new Pair<Scope, Scope>(ctype.tsym.members(), new Scope(ctype.tsym)); 19.171 - List<Type> typevars = ctype.tsym.type.getTypeArguments(); 19.172 + 19.173 + //for each constructor in the original scope, create a synthetic constructor 19.174 + //whose return type is the type of the class in which the constructor is 19.175 + //declared, and insert it into the new scope. 19.176 for (Scope.Entry e = mapping.fst.lookup(names.init); 19.177 e.scope != null; 19.178 e = e.next()) { 19.179 - MethodSymbol newConstr = (MethodSymbol) e.sym.clone(ctype.tsym); 19.180 - if (overrideProtectedAccess && (newConstr.flags() & PROTECTED) != 0) { 19.181 - //make protected constructor public (this is required for 19.182 - //anonymous inner class creation expressions using diamond) 19.183 - newConstr.flags_field |= PUBLIC; 19.184 - newConstr.flags_field &= ~PROTECTED; 19.185 - } 19.186 - newConstr.name = names.init; 19.187 - List<Type> oldTypeargs = List.nil(); 19.188 - if (newConstr.type.tag == FORALL) { 19.189 - oldTypeargs = ((ForAll) newConstr.type).tvars; 19.190 - } 19.191 - newConstr.type = new MethodType(newConstr.type.getParameterTypes(), 19.192 - new ClassType(ctype.getEnclosingType(), ctype.tsym.type.getTypeArguments(), ctype.tsym), 19.193 - newConstr.type.getThrownTypes(), 19.194 - syms.methodClass); 19.195 - newConstr.type = new ForAll(typevars.prependList(oldTypeargs), newConstr.type); 19.196 - mapping.snd.enter(newConstr); 19.197 + Type synthRestype = new ClassType(ctype.getEnclosingType(), 19.198 + ctype.tsym.type.getTypeArguments(), 19.199 + ctype.tsym); 19.200 + MethodSymbol synhConstr = new MethodSymbol(e.sym.flags(), 19.201 + names.init, 19.202 + types.createMethodTypeWithReturn(e.sym.type, synthRestype), 19.203 + e.sym.owner); 19.204 + mapping.snd.enter(synhConstr); 19.205 } 19.206 return mapping; 19.207 } 19.208 @@ -2276,6 +2289,7 @@ 19.209 sitesym.kind == VAR && 19.210 ((VarSymbol)sitesym).isResourceVariable() && 19.211 sym.kind == MTH && 19.212 + sym.name.equals(names.close) && 19.213 sym.overrides(syms.autoCloseableClose, sitesym.type.tsym, types, true) && 19.214 env.info.lint.isEnabled(LintCategory.TRY)) { 19.215 log.warning(LintCategory.TRY, tree, "try.explicit.close.call"); 19.216 @@ -2901,7 +2915,23 @@ 19.217 ctype = chk.checkType(typeTree.pos(), 19.218 chk.checkClassType(typeTree.pos(), ctype), 19.219 syms.throwableType); 19.220 - multicatchTypes.append(ctype); 19.221 + if (!ctype.isErroneous()) { 19.222 + //check that alternatives of a disjunctive type are pairwise 19.223 + //unrelated w.r.t. subtyping 19.224 + if (chk.intersects(ctype, multicatchTypes.toList())) { 19.225 + for (Type t : multicatchTypes) { 19.226 + boolean sub = types.isSubtype(ctype, t); 19.227 + boolean sup = types.isSubtype(t, ctype); 19.228 + if (sub || sup) { 19.229 + //assume 'a' <: 'b' 19.230 + Type a = sub ? ctype : t; 19.231 + Type b = sub ? t : ctype; 19.232 + log.error(typeTree.pos(), "multicatch.types.must.be.disjoint", a, b); 19.233 + } 19.234 + } 19.235 + } 19.236 + multicatchTypes.append(ctype); 19.237 + } 19.238 } 19.239 tree.type = result = check(tree, types.lub(multicatchTypes.toList()), TYP, pkind, pt); 19.240 } 19.241 @@ -3173,6 +3203,9 @@ 19.242 // method conform to the method they implement. 19.243 chk.checkImplementations(tree); 19.244 19.245 + //check that a resource implementing AutoCloseable cannot throw InterruptedException 19.246 + checkAutoCloseable(tree.pos(), env, c.type); 19.247 + 19.248 for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) { 19.249 // Attribute declaration 19.250 attribStat(l.head, env);
20.1 --- a/src/share/classes/com/sun/tools/javac/comp/Check.java Thu Apr 07 15:21:22 2011 -0700 20.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java Sun Apr 10 10:25:12 2011 -0700 20.3 @@ -676,7 +676,7 @@ 20.4 "cant.apply.diamond.1", 20.5 t, diags.fragment("diamond.and.anon.class", t)); 20.6 return types.createErrorType(t); 20.7 - } else if (!t.tsym.type.isParameterized()) { 20.8 + } else if (t.tsym.type.getTypeArguments().isEmpty()) { 20.9 log.error(tree.clazz.pos(), 20.10 "cant.apply.diamond.1", 20.11 t, diags.fragment("diamond.non.generic", t));
21.1 --- a/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java Thu Apr 07 15:21:22 2011 -0700 21.2 +++ b/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java Sun Apr 10 10:25:12 2011 -0700 21.3 @@ -788,8 +788,7 @@ 21.4 // Internally to java.lang.invoke, a @PolymorphicSignature annotation 21.5 // acts like a classfile attribute. 21.6 if (!c.type.isErroneous() && 21.7 - (types.isSameType(c.type, syms.polymorphicSignatureType) || 21.8 - types.isSameType(c.type, syms.transientPolymorphicSignatureType))) { 21.9 + types.isSameType(c.type, syms.polymorphicSignatureType)) { 21.10 if (!target.hasMethodHandles()) { 21.11 // Somebody is compiling JDK7 source code to a JDK6 target. 21.12 // Make it an error, since it is unlikely but important.
22.1 --- a/src/share/classes/com/sun/tools/javac/comp/Resolve.java Thu Apr 07 15:21:22 2011 -0700 22.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java Sun Apr 10 10:25:12 2011 -0700 22.3 @@ -338,7 +338,11 @@ 22.4 22.5 // tvars is the list of formal type variables for which type arguments 22.6 // need to inferred. 22.7 - List<Type> tvars = env.info.tvars; 22.8 + List<Type> tvars = null; 22.9 + if (env.info.tvars != null) { 22.10 + tvars = types.newInstances(env.info.tvars); 22.11 + mt = types.subst(mt, env.info.tvars, tvars); 22.12 + } 22.13 if (typeargtypes == null) typeargtypes = List.nil(); 22.14 if (mt.tag != FORALL && typeargtypes.nonEmpty()) { 22.15 // This is not a polymorphic method, but typeargs are supplied
23.1 --- a/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java Thu Apr 07 15:21:22 2011 -0700 23.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java Sun Apr 10 10:25:12 2011 -0700 23.3 @@ -1162,6 +1162,9 @@ 23.4 ClassSymbol c = readClassSymbol(nextChar()); 23.5 NameAndType nt = (NameAndType)readPool(nextChar()); 23.6 23.7 + if (c.members_field == null) 23.8 + throw badClassFile("bad.enclosing.class", self, c); 23.9 + 23.10 MethodSymbol m = findMethod(nt, c.members_field, self.flags()); 23.11 if (nt != null && m == null) 23.12 throw badClassFile("bad.enclosing.method", self); 23.13 @@ -1318,8 +1321,7 @@ 23.14 else 23.15 proxies.append(proxy); 23.16 if (majorVersion >= V51.major && 23.17 - (proxy.type.tsym == syms.polymorphicSignatureType.tsym || 23.18 - proxy.type.tsym == syms.transientPolymorphicSignatureType.tsym)) { 23.19 + proxy.type.tsym == syms.polymorphicSignatureType.tsym) { 23.20 sym.flags_field |= POLYMORPHIC_SIGNATURE; 23.21 } 23.22 }
24.1 --- a/src/share/classes/com/sun/tools/javac/main/Main.java Thu Apr 07 15:21:22 2011 -0700 24.2 +++ b/src/share/classes/com/sun/tools/javac/main/Main.java Sun Apr 10 10:25:12 2011 -0700 24.3 @@ -65,9 +65,11 @@ 24.4 PrintWriter out; 24.5 24.6 /** 24.7 - * If true, any command line arg errors will cause an exception. 24.8 + * If true, certain errors will cause an exception, such as command line 24.9 + * arg errors, or exceptions in user provided code. 24.10 */ 24.11 - boolean fatalErrors; 24.12 + boolean apiMode; 24.13 + 24.14 24.15 /** Result codes. 24.16 */ 24.17 @@ -163,7 +165,7 @@ 24.18 /** Report a usage error. 24.19 */ 24.20 void error(String key, Object... args) { 24.21 - if (fatalErrors) { 24.22 + if (apiMode) { 24.23 String msg = getLocalizedString(key, args); 24.24 throw new PropagatedException(new IllegalStateException(msg)); 24.25 } 24.26 @@ -192,8 +194,8 @@ 24.27 this.options = options; 24.28 } 24.29 24.30 - public void setFatalErrors(boolean fatalErrors) { 24.31 - this.fatalErrors = fatalErrors; 24.32 + public void setAPIMode(boolean apiMode) { 24.33 + this.apiMode = apiMode; 24.34 } 24.35 24.36 /** Process command line arguments: store all command line options 24.37 @@ -440,7 +442,9 @@ 24.38 } catch (FatalError ex) { 24.39 feMessage(ex); 24.40 return EXIT_SYSERR; 24.41 - } catch(AnnotationProcessingError ex) { 24.42 + } catch (AnnotationProcessingError ex) { 24.43 + if (apiMode) 24.44 + throw new RuntimeException(ex.getCause()); 24.45 apMessage(ex); 24.46 return EXIT_SYSERR; 24.47 } catch (ClientCodeException ex) { 24.48 @@ -458,7 +462,13 @@ 24.49 bugMessage(ex); 24.50 return EXIT_ABNORMAL; 24.51 } finally { 24.52 - if (comp != null) comp.close(); 24.53 + if (comp != null) { 24.54 + try { 24.55 + comp.close(); 24.56 + } catch (ClientCodeException ex) { 24.57 + throw new RuntimeException(ex.getCause()); 24.58 + } 24.59 + } 24.60 filenames = null; 24.61 options = null; 24.62 }
25.1 --- a/src/share/classes/com/sun/tools/javac/nio/PathFileObject.java Thu Apr 07 15:21:22 2011 -0700 25.2 +++ b/src/share/classes/com/sun/tools/javac/nio/PathFileObject.java Sun Apr 10 10:25:12 2011 -0700 25.3 @@ -37,6 +37,7 @@ 25.4 import java.nio.CharBuffer; 25.5 import java.nio.charset.CharsetDecoder; 25.6 import java.nio.file.Files; 25.7 +import java.nio.file.LinkOption; 25.8 import java.nio.file.Path; 25.9 import java.nio.file.attribute.BasicFileAttributes; 25.10 import javax.lang.model.element.Modifier; 25.11 @@ -170,7 +171,7 @@ 25.12 if (pn.equalsIgnoreCase(sn)) { 25.13 try { 25.14 // allow for Windows 25.15 - return path.toRealPath(false).getFileName().toString().equals(sn); 25.16 + return path.toRealPath(LinkOption.NOFOLLOW_LINKS).getFileName().toString().equals(sn); 25.17 } catch (IOException e) { 25.18 } 25.19 }
26.1 --- a/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Thu Apr 07 15:21:22 2011 -0700 26.2 +++ b/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Sun Apr 10 10:25:12 2011 -0700 26.3 @@ -971,7 +971,7 @@ 26.4 if ((mode & EXPR) != 0) { 26.5 mode = EXPR; 26.6 S.nextToken(); 26.7 - if (S.token() == LT) typeArgs = typeArguments(); 26.8 + if (S.token() == LT) typeArgs = typeArguments(false); 26.9 t = creator(pos, typeArgs); 26.10 typeArgs = null; 26.11 } else return illegal(); 26.12 @@ -1036,7 +1036,7 @@ 26.13 mode = EXPR; 26.14 int pos1 = S.pos(); 26.15 S.nextToken(); 26.16 - if (S.token() == LT) typeArgs = typeArguments(); 26.17 + if (S.token() == LT) typeArgs = typeArguments(false); 26.18 t = innerCreator(pos1, typeArgs, t); 26.19 typeArgs = null; 26.20 break loop; 26.21 @@ -1116,7 +1116,7 @@ 26.22 mode = EXPR; 26.23 int pos2 = S.pos(); 26.24 S.nextToken(); 26.25 - if (S.token() == LT) typeArgs = typeArguments(); 26.26 + if (S.token() == LT) typeArgs = typeArguments(false); 26.27 t = innerCreator(pos2, typeArgs, t); 26.28 typeArgs = null; 26.29 } else { 26.30 @@ -1146,7 +1146,7 @@ 26.31 } else { 26.32 int pos = S.pos(); 26.33 accept(DOT); 26.34 - typeArgs = (S.token() == LT) ? typeArguments() : null; 26.35 + typeArgs = (S.token() == LT) ? typeArguments(false) : null; 26.36 t = toP(F.at(pos).Select(t, ident())); 26.37 t = argumentsOpt(typeArgs, t); 26.38 } 26.39 @@ -1206,7 +1206,7 @@ 26.40 (mode & NOPARAMS) == 0) { 26.41 mode = TYPE; 26.42 checkGenerics(); 26.43 - return typeArguments(t); 26.44 + return typeArguments(t, false); 26.45 } else { 26.46 return t; 26.47 } 26.48 @@ -1223,51 +1223,54 @@ 26.49 illegal(); 26.50 } 26.51 mode = useMode; 26.52 - return typeArguments(); 26.53 + return typeArguments(false); 26.54 } 26.55 return null; 26.56 } 26.57 26.58 /** TypeArguments = "<" TypeArgument {"," TypeArgument} ">" 26.59 */ 26.60 - List<JCExpression> typeArguments() { 26.61 - ListBuffer<JCExpression> args = lb(); 26.62 + List<JCExpression> typeArguments(boolean diamondAllowed) { 26.63 if (S.token() == LT) { 26.64 S.nextToken(); 26.65 - if (S.token() == GT && (mode & DIAMOND) != 0) { 26.66 + if (S.token() == GT && diamondAllowed) { 26.67 checkDiamond(); 26.68 + mode |= DIAMOND; 26.69 S.nextToken(); 26.70 return List.nil(); 26.71 - } 26.72 - args.append(((mode & EXPR) == 0) ? typeArgument() : parseType()); 26.73 - while (S.token() == COMMA) { 26.74 - S.nextToken(); 26.75 + } else { 26.76 + ListBuffer<JCExpression> args = ListBuffer.lb(); 26.77 args.append(((mode & EXPR) == 0) ? typeArgument() : parseType()); 26.78 - } 26.79 - switch (S.token()) { 26.80 - case GTGTGTEQ: 26.81 - S.token(GTGTEQ); 26.82 - break; 26.83 - case GTGTEQ: 26.84 - S.token(GTEQ); 26.85 - break; 26.86 - case GTEQ: 26.87 - S.token(EQ); 26.88 - break; 26.89 - case GTGTGT: 26.90 - S.token(GTGT); 26.91 - break; 26.92 - case GTGT: 26.93 - S.token(GT); 26.94 - break; 26.95 - default: 26.96 - accept(GT); 26.97 - break; 26.98 + while (S.token() == COMMA) { 26.99 + S.nextToken(); 26.100 + args.append(((mode & EXPR) == 0) ? typeArgument() : parseType()); 26.101 + } 26.102 + switch (S.token()) { 26.103 + case GTGTGTEQ: 26.104 + S.token(GTGTEQ); 26.105 + break; 26.106 + case GTGTEQ: 26.107 + S.token(GTEQ); 26.108 + break; 26.109 + case GTEQ: 26.110 + S.token(EQ); 26.111 + break; 26.112 + case GTGTGT: 26.113 + S.token(GTGT); 26.114 + break; 26.115 + case GTGT: 26.116 + S.token(GT); 26.117 + break; 26.118 + default: 26.119 + accept(GT); 26.120 + break; 26.121 + } 26.122 + return args.toList(); 26.123 } 26.124 } else { 26.125 syntaxError(S.pos(), "expected", LT); 26.126 + return List.nil(); 26.127 } 26.128 - return args.toList(); 26.129 } 26.130 26.131 /** TypeArgument = Type 26.132 @@ -1303,9 +1306,9 @@ 26.133 } 26.134 } 26.135 26.136 - JCTypeApply typeArguments(JCExpression t) { 26.137 + JCTypeApply typeArguments(JCExpression t, boolean diamondAllowed) { 26.138 int pos = S.pos(); 26.139 - List<JCExpression> args = typeArguments(); 26.140 + List<JCExpression> args = typeArguments(diamondAllowed); 26.141 return toP(F.at(pos).TypeApply(t, args)); 26.142 } 26.143 26.144 @@ -1370,18 +1373,25 @@ 26.145 } 26.146 JCExpression t = qualident(); 26.147 int oldmode = mode; 26.148 - mode = TYPE | DIAMOND; 26.149 + mode = TYPE; 26.150 + boolean diamondFound = false; 26.151 if (S.token() == LT) { 26.152 checkGenerics(); 26.153 - t = typeArguments(t); 26.154 + t = typeArguments(t, true); 26.155 + diamondFound = (mode & DIAMOND) != 0; 26.156 } 26.157 while (S.token() == DOT) { 26.158 + if (diamondFound) { 26.159 + //cannot select after a diamond 26.160 + illegal(S.pos()); 26.161 + } 26.162 int pos = S.pos(); 26.163 S.nextToken(); 26.164 t = toP(F.at(pos).Select(t, ident())); 26.165 if (S.token() == LT) { 26.166 checkGenerics(); 26.167 - t = typeArguments(t); 26.168 + t = typeArguments(t, true); 26.169 + diamondFound = (mode & DIAMOND) != 0; 26.170 } 26.171 } 26.172 mode = oldmode; 26.173 @@ -1416,9 +1426,8 @@ 26.174 JCExpression t = toP(F.at(S.pos()).Ident(ident())); 26.175 if (S.token() == LT) { 26.176 int oldmode = mode; 26.177 - mode |= DIAMOND; 26.178 checkGenerics(); 26.179 - t = typeArguments(t); 26.180 + t = typeArguments(t, true); 26.181 mode = oldmode; 26.182 } 26.183 return classCreatorRest(newpos, encl, typeArgs, t);
27.1 --- a/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java Thu Apr 07 15:21:22 2011 -0700 27.2 +++ b/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java Sun Apr 10 10:25:12 2011 -0700 27.3 @@ -34,8 +34,8 @@ 27.4 import java.io.File; 27.5 import java.io.PrintWriter; 27.6 import java.io.IOException; 27.7 +import java.io.StringWriter; 27.8 import java.net.MalformedURLException; 27.9 -import java.io.StringWriter; 27.10 27.11 import javax.annotation.processing.*; 27.12 import javax.lang.model.SourceVersion; 27.13 @@ -58,6 +58,7 @@ 27.14 import com.sun.tools.javac.file.FSInfo; 27.15 import com.sun.tools.javac.file.JavacFileManager; 27.16 import com.sun.tools.javac.jvm.*; 27.17 +import com.sun.tools.javac.jvm.ClassReader.BadClassFile; 27.18 import com.sun.tools.javac.main.JavaCompiler; 27.19 import com.sun.tools.javac.main.JavaCompiler.CompileState; 27.20 import com.sun.tools.javac.model.JavacElements; 27.21 @@ -67,6 +68,7 @@ 27.22 import com.sun.tools.javac.tree.JCTree.*; 27.23 import com.sun.tools.javac.util.Abort; 27.24 import com.sun.tools.javac.util.Assert; 27.25 +import com.sun.tools.javac.util.ClientCodeException; 27.26 import com.sun.tools.javac.util.Context; 27.27 import com.sun.tools.javac.util.Convert; 27.28 import com.sun.tools.javac.util.FatalError; 27.29 @@ -432,6 +434,8 @@ 27.30 log.error("proc.processor.cant.instantiate", processorName); 27.31 return false; 27.32 } 27.33 + } catch(ClientCodeException e) { 27.34 + throw e; 27.35 } catch(Throwable t) { 27.36 throw new AnnotationProcessingError(t); 27.37 } 27.38 @@ -527,6 +531,8 @@ 27.39 supportedOptionNames.add(optionName); 27.40 } 27.41 27.42 + } catch (ClientCodeException e) { 27.43 + throw e; 27.44 } catch (Throwable t) { 27.45 throw new AnnotationProcessingError(t); 27.46 } 27.47 @@ -785,11 +791,16 @@ 27.48 RoundEnvironment renv) { 27.49 try { 27.50 return proc.process(tes, renv); 27.51 + } catch (BadClassFile ex) { 27.52 + log.error("proc.cant.access.1", ex.sym, ex.getDetailValue()); 27.53 + return false; 27.54 } catch (CompletionFailure ex) { 27.55 StringWriter out = new StringWriter(); 27.56 ex.printStackTrace(new PrintWriter(out)); 27.57 log.error("proc.cant.access", ex.sym, ex.getDetailValue(), out.toString()); 27.58 return false; 27.59 + } catch (ClientCodeException e) { 27.60 + throw e; 27.61 } catch (Throwable t) { 27.62 throw new AnnotationProcessingError(t); 27.63 } 27.64 @@ -1061,6 +1072,11 @@ 27.65 PrintWriter out = context.get(Log.outKey); 27.66 Assert.checkNonNull(out); 27.67 next.put(Log.outKey, out); 27.68 + Locale locale = context.get(Locale.class); 27.69 + if (locale != null) 27.70 + next.put(Locale.class, locale); 27.71 + Assert.checkNonNull(messages); 27.72 + next.put(JavacMessages.messagesKey, messages); 27.73 27.74 final boolean shareNames = true; 27.75 if (shareNames) {
28.1 --- a/src/share/classes/com/sun/tools/javac/resources/compiler.properties Thu Apr 07 15:21:22 2011 -0700 28.2 +++ b/src/share/classes/com/sun/tools/javac/resources/compiler.properties Sun Apr 10 10:25:12 2011 -0700 28.3 @@ -302,6 +302,11 @@ 28.4 compiler.err.multicatch.parameter.may.not.be.assigned=\ 28.5 multi-catch parameter {0} may not be assigned 28.6 28.7 +# 0: type, 1: type 28.8 +compiler.err.multicatch.types.must.be.disjoint=\ 28.9 + Alternatives in a multi-catch statement cannot be related by subclassing\n\ 28.10 + Alternative {0} is a subclass of alternative {1} 28.11 + 28.12 compiler.err.finally.without.try=\ 28.13 ''finally'' without ''try'' 28.14 28.15 @@ -606,12 +611,18 @@ 28.16 28.17 # Errors related to annotation processing 28.18 28.19 +# 0: symbol, 1: string, 2: stack-trace 28.20 compiler.err.proc.cant.access=\ 28.21 cannot access {0}\n\ 28.22 {1}\n\ 28.23 Consult the following stack trace for details.\n\ 28.24 {2} 28.25 28.26 +# 0: symbol, 1: string 28.27 +compiler.err.proc.cant.access.1=\ 28.28 + cannot access {0}\n\ 28.29 + {1} 28.30 + 28.31 # 0: string 28.32 compiler.err.proc.cant.find.class=\ 28.33 Could not find class file for ''{0}''. 28.34 @@ -1239,6 +1250,10 @@ 28.35 compiler.warn.try.resource.not.referenced=\ 28.36 auto-closeable resource {0} is never referenced in body of corresponding try statement 28.37 28.38 +# 0: type 28.39 +compiler.warn.try.resource.throws.interrupted.exc=\ 28.40 + auto-closeable resource {0} has a member method close() that could throw InterruptedException 28.41 + 28.42 compiler.warn.unchecked.assign=\ 28.43 unchecked assignment: {0} to {1} 28.44 28.45 @@ -1415,8 +1430,13 @@ 28.46 compiler.misc.bad.class.signature=\ 28.47 bad class signature: {0} 28.48 28.49 +#0: symbol, 1: symbol 28.50 +compiler.misc.bad.enclosing.class=\ 28.51 + bad enclosing class for {0}: {1} 28.52 + 28.53 +# 0: symbol 28.54 compiler.misc.bad.enclosing.method=\ 28.55 - bad enclosing method attribute: {0} 28.56 + bad enclosing method attribute for class {0} 28.57 28.58 compiler.misc.bad.runtime.invisible.param.annotations=\ 28.59 bad RuntimeInvisibleParameterAnnotations attribute: {0}
29.1 --- a/src/share/classes/com/sun/tools/javac/util/JavacMessages.java Thu Apr 07 15:21:22 2011 -0700 29.2 +++ b/src/share/classes/com/sun/tools/javac/util/JavacMessages.java Sun Apr 10 10:25:12 2011 -0700 29.3 @@ -1,5 +1,5 @@ 29.4 /* 29.5 - * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved. 29.6 + * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. 29.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 29.8 * 29.9 * This code is free software; you can redistribute it and/or modify it 29.10 @@ -44,7 +44,7 @@ 29.11 */ 29.12 public class JavacMessages implements Messages { 29.13 /** The context key for the JavacMessages object. */ 29.14 - protected static final Context.Key<JavacMessages> messagesKey = 29.15 + public static final Context.Key<JavacMessages> messagesKey = 29.16 new Context.Key<JavacMessages>(); 29.17 29.18 /** Get the JavacMessages instance for this context. */ 29.19 @@ -77,7 +77,7 @@ 29.20 /** Creates a JavacMessages object. 29.21 */ 29.22 public JavacMessages(Context context) { 29.23 - this(defaultBundleName); 29.24 + this(defaultBundleName, context.get(Locale.class)); 29.25 context.put(messagesKey, this); 29.26 } 29.27 29.28 @@ -85,10 +85,17 @@ 29.29 * @param bundleName the name to identify the resource buundle of localized messages. 29.30 */ 29.31 public JavacMessages(String bundleName) throws MissingResourceException { 29.32 + this(bundleName, null); 29.33 + } 29.34 + 29.35 + /** Creates a JavacMessages object. 29.36 + * @param bundleName the name to identify the resource buundle of localized messages. 29.37 + */ 29.38 + public JavacMessages(String bundleName, Locale locale) throws MissingResourceException { 29.39 bundleNames = List.nil(); 29.40 bundleCache = new HashMap<Locale, SoftReference<List<ResourceBundle>>>(); 29.41 add(bundleName); 29.42 - setCurrentLocale(Locale.getDefault()); 29.43 + setCurrentLocale(locale); 29.44 } 29.45 29.46 public JavacMessages() throws MissingResourceException {
30.1 --- a/src/share/classes/com/sun/tools/javac/util/Log.java Thu Apr 07 15:21:22 2011 -0700 30.2 +++ b/src/share/classes/com/sun/tools/javac/util/Log.java Sun Apr 10 10:25:12 2011 -0700 30.3 @@ -425,13 +425,8 @@ 30.4 */ 30.5 protected void writeDiagnostic(JCDiagnostic diag) { 30.6 if (diagListener != null) { 30.7 - try { 30.8 - diagListener.report(diag); 30.9 - return; 30.10 - } 30.11 - catch (Throwable t) { 30.12 - throw new ClientCodeException(t); 30.13 - } 30.14 + diagListener.report(diag); 30.15 + return; 30.16 } 30.17 30.18 PrintWriter writer = getWriterForDiagnosticType(diag.getType());
31.1 --- a/src/share/classes/com/sun/tools/javac/util/Names.java Thu Apr 07 15:21:22 2011 -0700 31.2 +++ b/src/share/classes/com/sun/tools/javac/util/Names.java Sun Apr 10 10:25:12 2011 -0700 31.3 @@ -73,7 +73,6 @@ 31.4 public final Name java_io_Serializable; 31.5 public final Name serialVersionUID; 31.6 public final Name java_lang_Enum; 31.7 - public final Name transient_java_dyn_MethodHandle; // transient - 292 31.8 public final Name java_lang_invoke_MethodHandle; 31.9 public final Name package_info; 31.10 public final Name ConstantValue; 31.11 @@ -184,7 +183,6 @@ 31.12 java_lang_Cloneable = fromString("java.lang.Cloneable"); 31.13 java_io_Serializable = fromString("java.io.Serializable"); 31.14 java_lang_Enum = fromString("java.lang.Enum"); 31.15 - transient_java_dyn_MethodHandle = fromString("java.dyn.MethodHandle"); //transient - 292 31.16 java_lang_invoke_MethodHandle = fromString("java.lang.invoke.MethodHandle"); 31.17 package_info = fromString("package-info"); 31.18 serialVersionUID = fromString("serialVersionUID");
32.1 --- a/src/share/classes/com/sun/tools/javap/ClassWriter.java Thu Apr 07 15:21:22 2011 -0700 32.2 +++ b/src/share/classes/com/sun/tools/javap/ClassWriter.java Sun Apr 10 10:25:12 2011 -0700 32.3 @@ -1,5 +1,5 @@ 32.4 /* 32.5 - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. 32.6 + * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. 32.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 32.8 * 32.9 * This code is free software; you can redistribute it and/or modify it 32.10 @@ -48,6 +48,13 @@ 32.11 import com.sun.tools.classfile.Signature_attribute; 32.12 import com.sun.tools.classfile.SourceFile_attribute; 32.13 import com.sun.tools.classfile.Type; 32.14 +import com.sun.tools.classfile.Type.ArrayType; 32.15 +import com.sun.tools.classfile.Type.ClassSigType; 32.16 +import com.sun.tools.classfile.Type.ClassType; 32.17 +import com.sun.tools.classfile.Type.MethodType; 32.18 +import com.sun.tools.classfile.Type.SimpleType; 32.19 +import com.sun.tools.classfile.Type.TypeParamType; 32.20 +import com.sun.tools.classfile.Type.WildcardType; 32.21 32.22 import static com.sun.tools.classfile.AccessFlags.*; 32.23 32.24 @@ -166,8 +173,10 @@ 32.25 // use info from class file header 32.26 if (classFile.isClass() && classFile.super_class != 0 ) { 32.27 String sn = getJavaSuperclassName(cf); 32.28 - print(" extends "); 32.29 - print(sn); 32.30 + if (!sn.equals("java.lang.Object")) { 32.31 + print(" extends "); 32.32 + print(sn); 32.33 + } 32.34 } 32.35 for (int i = 0; i < classFile.interfaces.length; i++) { 32.36 print(i == 0 ? (classFile.isClass() ? " implements " : " extends ") : ","); 32.37 @@ -176,13 +185,14 @@ 32.38 } else { 32.39 try { 32.40 Type t = sigAttr.getParsedSignature().getType(constant_pool); 32.41 + JavaTypePrinter p = new JavaTypePrinter(classFile.isInterface()); 32.42 // The signature parser cannot disambiguate between a 32.43 // FieldType and a ClassSignatureType that only contains a superclass type. 32.44 - if (t instanceof Type.ClassSigType) 32.45 - print(getJavaName(t.toString())); 32.46 - else { 32.47 + if (t instanceof Type.ClassSigType) { 32.48 + print(p.print(t)); 32.49 + } else if (options.verbose || !t.isObject()) { 32.50 print(" extends "); 32.51 - print(getJavaName(t.toString())); 32.52 + print(p.print(t)); 32.53 } 32.54 } catch (ConstantPoolException e) { 32.55 print(report(e)); 32.56 @@ -210,6 +220,124 @@ 32.57 indent(-1); 32.58 println("}"); 32.59 } 32.60 + // where 32.61 + class JavaTypePrinter implements Type.Visitor<StringBuilder,StringBuilder> { 32.62 + boolean isInterface; 32.63 + 32.64 + JavaTypePrinter(boolean isInterface) { 32.65 + this.isInterface = isInterface; 32.66 + } 32.67 + 32.68 + String print(Type t) { 32.69 + return t.accept(this, new StringBuilder()).toString(); 32.70 + } 32.71 + 32.72 + public StringBuilder visitSimpleType(SimpleType type, StringBuilder sb) { 32.73 + sb.append(getJavaName(type.name)); 32.74 + return sb; 32.75 + } 32.76 + 32.77 + public StringBuilder visitArrayType(ArrayType type, StringBuilder sb) { 32.78 + append(sb, type.elemType); 32.79 + sb.append("[]"); 32.80 + return sb; 32.81 + } 32.82 + 32.83 + public StringBuilder visitMethodType(MethodType type, StringBuilder sb) { 32.84 + appendIfNotEmpty(sb, "<", type.typeParamTypes, "> "); 32.85 + append(sb, type.returnType); 32.86 + append(sb, " (", type.paramTypes, ")"); 32.87 + appendIfNotEmpty(sb, " throws ", type.throwsTypes, ""); 32.88 + return sb; 32.89 + } 32.90 + 32.91 + public StringBuilder visitClassSigType(ClassSigType type, StringBuilder sb) { 32.92 + appendIfNotEmpty(sb, "<", type.typeParamTypes, ">"); 32.93 + if (isInterface) { 32.94 + appendIfNotEmpty(sb, " extends ", type.superinterfaceTypes, ""); 32.95 + } else { 32.96 + if (type.superclassType != null 32.97 + && (options.verbose || !type.superclassType.isObject())) { 32.98 + sb.append(" extends "); 32.99 + append(sb, type.superclassType); 32.100 + } 32.101 + appendIfNotEmpty(sb, " implements ", type.superinterfaceTypes, ""); 32.102 + } 32.103 + return sb; 32.104 + } 32.105 + 32.106 + public StringBuilder visitClassType(ClassType type, StringBuilder sb) { 32.107 + if (type.outerType != null) { 32.108 + append(sb, type.outerType); 32.109 + sb.append("."); 32.110 + } 32.111 + sb.append(getJavaName(type.name)); 32.112 + appendIfNotEmpty(sb, "<", type.typeArgs, ">"); 32.113 + return sb; 32.114 + } 32.115 + 32.116 + public StringBuilder visitTypeParamType(TypeParamType type, StringBuilder sb) { 32.117 + sb.append(type.name); 32.118 + String sep = " extends "; 32.119 + if (type.classBound != null 32.120 + && (options.verbose || !type.classBound.isObject())) { 32.121 + sb.append(sep); 32.122 + append(sb, type.classBound); 32.123 + sep = " & "; 32.124 + } 32.125 + if (type.interfaceBounds != null) { 32.126 + for (Type bound: type.interfaceBounds) { 32.127 + sb.append(sep); 32.128 + append(sb, bound); 32.129 + sep = " & "; 32.130 + } 32.131 + } 32.132 + return sb; 32.133 + } 32.134 + 32.135 + public StringBuilder visitWildcardType(WildcardType type, StringBuilder sb) { 32.136 + switch (type.kind) { 32.137 + case UNBOUNDED: 32.138 + sb.append("?"); 32.139 + break; 32.140 + case EXTENDS: 32.141 + sb.append("? extends "); 32.142 + append(sb, type.boundType); 32.143 + break; 32.144 + case SUPER: 32.145 + sb.append("? super "); 32.146 + append(sb, type.boundType); 32.147 + break; 32.148 + default: 32.149 + throw new AssertionError(); 32.150 + } 32.151 + return sb; 32.152 + } 32.153 + 32.154 + private void append(StringBuilder sb, Type t) { 32.155 + t.accept(this, sb); 32.156 + } 32.157 + 32.158 + private void append(StringBuilder sb, String prefix, List<? extends Type> list, String suffix) { 32.159 + sb.append(prefix); 32.160 + String sep = ""; 32.161 + for (Type t: list) { 32.162 + sb.append(sep); 32.163 + append(sb, t); 32.164 + sep = ", "; 32.165 + } 32.166 + sb.append(suffix); 32.167 + } 32.168 + 32.169 + private void appendIfNotEmpty(StringBuilder sb, String prefix, List<? extends Type> list, String suffix) { 32.170 + if (!isEmpty(list)) 32.171 + append(sb, prefix, list, suffix); 32.172 + } 32.173 + 32.174 + private boolean isEmpty(List<? extends Type> list) { 32.175 + return (list == null || list.isEmpty()); 32.176 + } 32.177 + } 32.178 32.179 protected void writeFields() { 32.180 for (Field f: classFile.fields) { 32.181 @@ -298,7 +426,7 @@ 32.182 try { 32.183 methodType = (Type.MethodType) methodSig.getType(constant_pool); 32.184 methodExceptions = methodType.throwsTypes; 32.185 - if (methodExceptions != null && methodExceptions.size() == 0) 32.186 + if (methodExceptions != null && methodExceptions.isEmpty()) 32.187 methodExceptions = null; 32.188 } catch (ConstantPoolException e) { 32.189 // report error?
33.1 --- a/test/com/sun/javadoc/testDeprecatedDocs/TestDeprecatedDocs.java Thu Apr 07 15:21:22 2011 -0700 33.2 +++ b/test/com/sun/javadoc/testDeprecatedDocs/TestDeprecatedDocs.java Sun Apr 10 10:25:12 2011 -0700 33.3 @@ -1,5 +1,5 @@ 33.4 /* 33.5 - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 33.6 + * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. 33.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 33.8 * 33.9 * This code is free software; you can redistribute it and/or modify it 33.10 @@ -27,8 +27,7 @@ 33.11 * @summary <DESC> 33.12 * @author jamieh 33.13 * @library ../lib/ 33.14 - * @build JavadocTester 33.15 - * @build TestDeprecatedDocs 33.16 + * @build JavadocTester TestDeprecatedDocs 33.17 * @run main TestDeprecatedDocs 33.18 */ 33.19 33.20 @@ -77,7 +76,7 @@ 33.21 {TARGET_FILE, "pkg.DeprecatedClassByAnnotation.field"}, 33.22 33.23 {TARGET_FILE2, "<pre>@Deprecated" + NL + 33.24 - "public class <strong>DeprecatedClassByAnnotation</strong>" + NL + 33.25 + "public class <span class=\"strong\">DeprecatedClassByAnnotation</span>" + NL + 33.26 "extends java.lang.Object</pre>"}, 33.27 33.28 {TARGET_FILE2, "<pre>@Deprecated" + NL +
34.1 --- a/test/com/sun/javadoc/testHref/TestHref.java Thu Apr 07 15:21:22 2011 -0700 34.2 +++ b/test/com/sun/javadoc/testHref/TestHref.java Sun Apr 10 10:25:12 2011 -0700 34.3 @@ -1,5 +1,5 @@ 34.4 /* 34.5 - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 34.6 + * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. 34.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 34.8 * 34.9 * This code is free software; you can redistribute it and/or modify it 34.10 @@ -27,8 +27,7 @@ 34.11 * @summary Verify that spaces do not appear in hrefs and anchors. 34.12 * @author jamieh 34.13 * @library ../lib/ 34.14 - * @build JavadocTester 34.15 - * @build TestHref 34.16 + * @build JavadocTester TestHref 34.17 * @run main TestHref 34.18 */ 34.19 34.20 @@ -81,7 +80,7 @@ 34.21 34.22 //Signature does not link to the page itself. 34.23 {BUG_ID + FS + "pkg" + FS + "C4.html", 34.24 - "public abstract class <strong>C4<E extends C4<E>></strong>" 34.25 + "public abstract class <span class=\"strong\">C4<E extends C4<E>></span>" 34.26 }, 34.27 }; 34.28 private static final String[][] NEGATED_TEST =
35.1 --- a/test/com/sun/javadoc/testHtmlDefinitionListTag/TestHtmlDefinitionListTag.java Thu Apr 07 15:21:22 2011 -0700 35.2 +++ b/test/com/sun/javadoc/testHtmlDefinitionListTag/TestHtmlDefinitionListTag.java Sun Apr 10 10:25:12 2011 -0700 35.3 @@ -1,5 +1,5 @@ 35.4 /* 35.5 - * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. 35.6 + * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. 35.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 35.8 * 35.9 * This code is free software; you can redistribute it and/or modify it 35.10 @@ -29,8 +29,7 @@ 35.11 * @summary This test verifies the nesting of definition list tags. 35.12 * @author Bhavesh Patel 35.13 * @library ../lib/ 35.14 - * @build JavadocTester 35.15 - * @build TestHtmlDefinitionListTag 35.16 + * @build JavadocTester TestHtmlDefinitionListTag 35.17 * @run main TestHtmlDefinitionListTag 35.18 */ 35.19 35.20 @@ -43,7 +42,8 @@ 35.21 // Optional Element should print properly nested definition list tags 35.22 // for default value. 35.23 private static final String[][] TEST_ALL = { 35.24 - {BUG_ID + FS + "pkg1" + FS + "C1.html", "<pre>public class <strong>C1</strong>" + NL + 35.25 + {BUG_ID + FS + "pkg1" + FS + "C1.html", "<pre>public class " + 35.26 + "<span class=\"strong\">C1</span>" + NL + 35.27 "extends java.lang.Object" + NL + "implements java.io.Serializable</pre>"}, 35.28 {BUG_ID + FS + "pkg1" + FS + "C4.html", "<dl>" + NL + 35.29 "<dt>Default:</dt>" + NL + "<dd>true</dd>" + NL +
36.1 --- a/test/com/sun/javadoc/testJavascript/TestJavascript.java Thu Apr 07 15:21:22 2011 -0700 36.2 +++ b/test/com/sun/javadoc/testJavascript/TestJavascript.java Sun Apr 10 10:25:12 2011 -0700 36.3 @@ -1,5 +1,5 @@ 36.4 /* 36.5 - * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. 36.6 + * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. 36.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 36.8 * 36.9 * This code is free software; you can redistribute it and/or modify it 36.10 @@ -23,7 +23,7 @@ 36.11 36.12 /* 36.13 * @test 36.14 - * @bug 4665566 4855876 36.15 + * @bug 4665566 4855876 7025314 36.16 * @summary Verify that the output has the right javascript. 36.17 * @author jamieh 36.18 * @library ../lib/ 36.19 @@ -45,9 +45,9 @@ 36.20 //Input for string search tests. 36.21 private static final String[][] TEST = { 36.22 {BUG_ID + FS + "pkg" + FS + "C.html", 36.23 - "<a href=\"../index.html?pkg/C.html\" target=\"_top\">FRAMES</a>"}, 36.24 + "<a href=\"../index.html?pkg/C.html\" target=\"_top\">Frames</a>"}, 36.25 {BUG_ID + FS + "TestJavascript.html", 36.26 - "<a href=\"index.html?TestJavascript.html\" target=\"_top\">FRAMES</a>"}, 36.27 + "<a href=\"index.html?TestJavascript.html\" target=\"_top\">Frames</a>"}, 36.28 {BUG_ID + FS + "index.html", 36.29 "<script type=\"text/javascript\">" + NL + 36.30 " targetPage = \"\" + window.location.search;" + NL +
37.1 --- a/test/com/sun/javadoc/testLinkOption/TestLinkOption.java Thu Apr 07 15:21:22 2011 -0700 37.2 +++ b/test/com/sun/javadoc/testLinkOption/TestLinkOption.java Sun Apr 10 10:25:12 2011 -0700 37.3 @@ -1,5 +1,5 @@ 37.4 /* 37.5 - * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. 37.6 + * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. 37.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 37.8 * 37.9 * This code is free software; you can redistribute it and/or modify it 37.10 @@ -28,8 +28,7 @@ 37.11 * right files. 37.12 * @author jamieh 37.13 * @library ../lib/ 37.14 - * @build JavadocTester 37.15 - * @build TestLinkOption 37.16 + * @build JavadocTester TestLinkOption 37.17 * @run main TestLinkOption 37.18 */ 37.19 37.20 @@ -62,7 +61,7 @@ 37.21 "Object</a> p3)" 37.22 }, 37.23 {BUG_ID + "-1" + FS + "java" + FS + "lang" + FS + "StringBuilderChild.html", 37.24 - "<pre>public abstract class <strong>StringBuilderChild</strong>" + NL + 37.25 + "<pre>public abstract class <span class=\"strong\">StringBuilderChild</span>" + NL + 37.26 "extends <a href=\"http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html?is-external=true\" " + 37.27 "title=\"class or interface in java.lang\">Object</a></pre>" 37.28 },
38.1 --- a/test/com/sun/javadoc/testNavagation/TestNavagation.java Thu Apr 07 15:21:22 2011 -0700 38.2 +++ b/test/com/sun/javadoc/testNavagation/TestNavagation.java Sun Apr 10 10:25:12 2011 -0700 38.3 @@ -1,5 +1,5 @@ 38.4 /* 38.5 - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 38.6 + * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. 38.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 38.8 * 38.9 * This code is free software; you can redistribute it and/or modify it 38.10 @@ -23,7 +23,7 @@ 38.11 38.12 /* 38.13 * @test 38.14 - * @bug 4131628 4664607 38.15 + * @bug 4131628 4664607 7025314 38.16 * @summary Make sure the Next/Prev Class links iterate through all types. 38.17 * Make sure the navagation is 2 columns, not 3. 38.18 * @author jamieh 38.19 @@ -45,20 +45,20 @@ 38.20 38.21 //Input for string search tests. 38.22 private static final String[][] TEST = { 38.23 - {BUG_ID + FS + "pkg" + FS + "A.html", "<li>PREV CLASS</li>"}, 38.24 + {BUG_ID + FS + "pkg" + FS + "A.html", "<li>Prev Class</li>"}, 38.25 {BUG_ID + FS + "pkg" + FS + "A.html", 38.26 - "<a href=\"../pkg/C.html\" title=\"class in pkg\"><span class=\"strong\">NEXT CLASS</span></a>"}, 38.27 + "<a href=\"../pkg/C.html\" title=\"class in pkg\"><span class=\"strong\">Next Class</span></a>"}, 38.28 {BUG_ID + FS + "pkg" + FS + "C.html", 38.29 - "<a href=\"../pkg/A.html\" title=\"annotation in pkg\"><span class=\"strong\">PREV CLASS</span></a>"}, 38.30 + "<a href=\"../pkg/A.html\" title=\"annotation in pkg\"><span class=\"strong\">Prev Class</span></a>"}, 38.31 {BUG_ID + FS + "pkg" + FS + "C.html", 38.32 - "<a href=\"../pkg/E.html\" title=\"enum in pkg\"><span class=\"strong\">NEXT CLASS</span></a>"}, 38.33 + "<a href=\"../pkg/E.html\" title=\"enum in pkg\"><span class=\"strong\">Next Class</span></a>"}, 38.34 {BUG_ID + FS + "pkg" + FS + "E.html", 38.35 - "<a href=\"../pkg/C.html\" title=\"class in pkg\"><span class=\"strong\">PREV CLASS</span></a>"}, 38.36 + "<a href=\"../pkg/C.html\" title=\"class in pkg\"><span class=\"strong\">Prev Class</span></a>"}, 38.37 {BUG_ID + FS + "pkg" + FS + "E.html", 38.38 - "<a href=\"../pkg/I.html\" title=\"interface in pkg\"><span class=\"strong\">NEXT CLASS</span></a>"}, 38.39 + "<a href=\"../pkg/I.html\" title=\"interface in pkg\"><span class=\"strong\">Next Class</span></a>"}, 38.40 {BUG_ID + FS + "pkg" + FS + "I.html", 38.41 - "<a href=\"../pkg/E.html\" title=\"enum in pkg\"><span class=\"strong\">PREV CLASS</span></a>"}, 38.42 - {BUG_ID + FS + "pkg" + FS + "I.html", "<li>NEXT CLASS</li>"}, 38.43 + "<a href=\"../pkg/E.html\" title=\"enum in pkg\"><span class=\"strong\">Prev Class</span></a>"}, 38.44 + {BUG_ID + FS + "pkg" + FS + "I.html", "<li>Next Class</li>"}, 38.45 // Test for 4664607 38.46 {BUG_ID + FS + "pkg" + FS + "I.html", 38.47 "<a href=\"#skip-navbar_top\" title=\"Skip navigation links\"></a><a name=\"navbar_top_firstrow\">" + NL +
39.1 --- a/test/com/sun/javadoc/testNewLanguageFeatures/TestNewLanguageFeatures.java Thu Apr 07 15:21:22 2011 -0700 39.2 +++ b/test/com/sun/javadoc/testNewLanguageFeatures/TestNewLanguageFeatures.java Sun Apr 10 10:25:12 2011 -0700 39.3 @@ -1,5 +1,5 @@ 39.4 /* 39.5 - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 39.6 + * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. 39.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 39.8 * 39.9 * This code is free software; you can redistribute it and/or modify it 39.10 @@ -23,14 +23,13 @@ 39.11 39.12 /* 39.13 * @test 39.14 - * @bug 4789689 4905985 4927164 4827184 4993906 5004549 39.15 + * @bug 4789689 4905985 4927164 4827184 4993906 5004549 7025314 7010344 39.16 * @summary Run Javadoc on a set of source files that demonstrate new 39.17 * language features. Check the output to ensure that the new 39.18 * language features are properly documented. 39.19 * @author jamieh 39.20 * @library ../lib/ 39.21 - * @build JavadocTester 39.22 - * @build TestNewLanguageFeatures 39.23 + * @build JavadocTester TestNewLanguageFeatures 39.24 * @run main TestNewLanguageFeatures 39.25 */ 39.26 39.27 @@ -53,9 +52,10 @@ 39.28 //Make sure enum header is correct. 39.29 {BUG_ID + FS + "pkg" + FS + "Coin.html", "Enum Coin</h2>"}, 39.30 //Make sure enum signature is correct. 39.31 - {BUG_ID + FS + "pkg" + FS + "Coin.html", "<pre>public enum <strong>Coin</strong>" + NL + 39.32 - "extends java.lang.Enum<<a href=\"../pkg/Coin.html\" " + 39.33 - "title=\"enum in pkg\">Coin</a>></pre>" 39.34 + {BUG_ID + FS + "pkg" + FS + "Coin.html", "<pre>public enum " + 39.35 + "<span class=\"strong\">Coin</span>" + NL + 39.36 + "extends java.lang.Enum<<a href=\"../pkg/Coin.html\" " + 39.37 + "title=\"enum in pkg\">Coin</a>></pre>" 39.38 }, 39.39 //Check for enum constant section 39.40 {BUG_ID + FS + "pkg" + FS + "Coin.html", "<caption><span>Enum Constants" + 39.41 @@ -118,8 +118,8 @@ 39.42 39.43 //Signature of subclass that has type parameters. 39.44 {BUG_ID + FS + "pkg" + FS + "TypeParameterSubClass.html", 39.45 - "<pre>public class <strong>TypeParameterSubClass<T extends " + 39.46 - "java.lang.String></strong>" + NL + "extends " + 39.47 + "<pre>public class <span class=\"strong\">TypeParameterSubClass<T extends " + 39.48 + "java.lang.String></span>" + NL + "extends " + 39.49 "<a href=\"../pkg/TypeParameterSuperClass.html\" title=\"class in pkg\">" + 39.50 "TypeParameterSuperClass</a><T></pre>"}, 39.51 39.52 @@ -155,20 +155,20 @@ 39.53 //================================= 39.54 //Make sure the summary links are correct. 39.55 {BUG_ID + FS + "pkg" + FS + "AnnotationType.html", 39.56 - "<li>SUMMARY: </li>" + NL + 39.57 + "<li>Summary: </li>" + NL + 39.58 "<li><a href=\"#annotation_type_required_element_summary\">" + 39.59 - "REQUIRED</a> | </li>" + NL + "<li>" + 39.60 - "<a href=\"#annotation_type_optional_element_summary\">OPTIONAL</a></li>"}, 39.61 + "Required</a> | </li>" + NL + "<li>" + 39.62 + "<a href=\"#annotation_type_optional_element_summary\">Optional</a></li>"}, 39.63 //Make sure the detail links are correct. 39.64 {BUG_ID + FS + "pkg" + FS + "AnnotationType.html", 39.65 - "<li>DETAIL: </li>" + NL + 39.66 - "<li><a href=\"#annotation_type_element_detail\">ELEMENT</a></li>"}, 39.67 + "<li>Detail: </li>" + NL + 39.68 + "<li><a href=\"#annotation_type_element_detail\">Element</a></li>"}, 39.69 //Make sure the heading is correct. 39.70 {BUG_ID + FS + "pkg" + FS + "AnnotationType.html", 39.71 "Annotation Type AnnotationType</h2>"}, 39.72 //Make sure the signature is correct. 39.73 {BUG_ID + FS + "pkg" + FS + "AnnotationType.html", 39.74 - "public @interface <strong>AnnotationType</strong>"}, 39.75 + "public @interface <span class=\"strong\">AnnotationType</span>"}, 39.76 //Make sure member summary headings are correct. 39.77 {BUG_ID + FS + "pkg" + FS + "AnnotationType.html", 39.78 "<h3>Required Element Summary</h3>"}, 39.79 @@ -198,8 +198,8 @@ 39.80 "<a href=\"../pkg/AnnotationType.html#optional()\">optional</a>" + 39.81 "=\"Class Annotation\"," + NL + 39.82 " <a href=\"../pkg/AnnotationType.html#required()\">" + 39.83 - "required</a>=1994)" + NL + "public class <strong>" + 39.84 - "AnnotationTypeUsage</strong>" + NL + "extends java.lang.Object</pre>"}, 39.85 + "required</a>=1994)" + NL + "public class <span class=\"strong\">" + 39.86 + "AnnotationTypeUsage</span>" + NL + "extends java.lang.Object</pre>"}, 39.87 39.88 //FIELD 39.89 {BUG_ID + FS + "pkg" + FS + "AnnotationTypeUsage.html", 39.90 @@ -299,7 +299,7 @@ 39.91 {BUG_ID + FS + "pkg1" + FS + "B.html", 39.92 "<pre><a href=\"../pkg1/A.html\" title=\"annotation in pkg1\">@A</a>"}, 39.93 {BUG_ID + FS + "pkg1" + FS + "B.html", 39.94 - "public interface <strong>B</strong></pre>"}, 39.95 + "public interface <span class=\"strong\">B</span></pre>"}, 39.96 39.97 39.98 //============================================================== 39.99 @@ -320,9 +320,11 @@ 39.100 "Foo</a></span><span class=\"tabEnd\"> </span></caption>" 39.101 }, 39.102 {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo.html", 39.103 - "<td class=\"colLast\"><code><strong><a href=\"../../pkg2/" + 39.104 - "ClassUseTest1.html\" title=\"class in pkg2\">ClassUseTest1" + 39.105 - "<T extends Foo & Foo2></a></strong></code> </td>" 39.106 + "<td class=\"colLast\"><code><strong><a href=\"../../pkg2/ClassUseTest1.html\" " + 39.107 + "title=\"class in pkg2\">ClassUseTest1</a><T extends " + 39.108 + "<a href=\"../../pkg2/Foo.html\" title=\"class in pkg2\">Foo" + 39.109 + "</a> & <a href=\"../../pkg2/Foo2.html\" title=\"interface in pkg2\">" + 39.110 + "Foo2</a>></strong></code> </td>" 39.111 }, 39.112 {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo.html", 39.113 "<caption><span>Methods in <a href=\"../../pkg2/" + 39.114 @@ -370,10 +372,11 @@ 39.115 "</span></caption>" 39.116 }, 39.117 {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo2.html", 39.118 - "<td class=\"colLast\"><code><strong><a href=\"../../pkg2/" + 39.119 - "ClassUseTest1.html\" title=\"class in pkg2\">" + 39.120 - "ClassUseTest1<T extends Foo & Foo2></a></strong>" + 39.121 - "</code> </td>" 39.122 + "<td class=\"colLast\"><code><strong><a href=\"../../pkg2/ClassUseTest1.html\" " + 39.123 + "title=\"class in pkg2\">ClassUseTest1</a><T extends " + 39.124 + "<a href=\"../../pkg2/Foo.html\" title=\"class in pkg2\">Foo" + 39.125 + "</a> & <a href=\"../../pkg2/Foo2.html\" title=\"interface in pkg2\">" + 39.126 + "Foo2</a>></strong></code> </td>" 39.127 }, 39.128 {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo2.html", 39.129 "<caption><span>Methods in <a href=\"../../pkg2/" + 39.130 @@ -398,10 +401,11 @@ 39.131 " </span></caption>" 39.132 }, 39.133 {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest.html", 39.134 - "<td class=\"colLast\"><code><strong><a href=\"../../pkg2/" + 39.135 - "ClassUseTest2.html\" title=\"class in pkg2\">ClassUseTest2<T " + 39.136 - "extends ParamTest<<a href=\"../../pkg2/Foo3.html\" title=\"class " + 39.137 - "in pkg2\">Foo3</a>>></a></strong></code> </td>" 39.138 + "<td class=\"colLast\"><code><strong><a href=\"../../pkg2/ClassUseTest2.html\" " + 39.139 + "title=\"class in pkg2\">ClassUseTest2</a><T extends " + 39.140 + "<a href=\"../../pkg2/ParamTest.html\" title=\"class in pkg2\">" + 39.141 + "ParamTest</a><<a href=\"../../pkg2/Foo3.html\" title=\"class in pkg2\">" + 39.142 + "Foo3</a>>></strong></code> </td>" 39.143 }, 39.144 {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest.html", 39.145 "<caption><span>Methods in <a href=\"../../pkg2/" + 39.146 @@ -452,11 +456,11 @@ 39.147 "Foo3</a></span><span class=\"tabEnd\"> </span></caption>" 39.148 }, 39.149 {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo3.html", 39.150 - "<td class=\"colLast\"><code><strong><a href=\"../../" + 39.151 - "pkg2/ClassUseTest2.html\" title=\"class in pkg2\">" + 39.152 - "ClassUseTest2<T extends ParamTest<<a href=\"../../" + 39.153 - "pkg2/Foo3.html\" title=\"class in pkg2\">Foo3</a>>>" + 39.154 - "</a></strong></code> </td>" 39.155 + "<td class=\"colLast\"><code><strong><a href=\"../../pkg2/ClassUseTest2.html\" " + 39.156 + "title=\"class in pkg2\">ClassUseTest2</a><T extends " + 39.157 + "<a href=\"../../pkg2/ParamTest.html\" title=\"class in pkg2\">" + 39.158 + "ParamTest</a><<a href=\"../../pkg2/Foo3.html\" title=\"class in pkg2\">" + 39.159 + "Foo3</a>>></strong></code> </td>" 39.160 }, 39.161 {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo3.html", 39.162 "<caption><span>Methods in <a href=\"../../pkg2/" + 39.163 @@ -496,10 +500,12 @@ 39.164 " </span></caption>" 39.165 }, 39.166 {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest2.html", 39.167 - "<td class=\"colLast\"><code><strong><a href=\"../../pkg2/" + 39.168 - "ClassUseTest3.html\" title=\"class in pkg2\">" + 39.169 - "ClassUseTest3<T extends ParamTest2<java.util.List" + 39.170 - "<? extends Foo4>>></a></strong></code> </td>" 39.171 + "<td class=\"colLast\"><code><strong><a href=\"../../pkg2/ClassUseTest3.html\" " + 39.172 + "title=\"class in pkg2\">ClassUseTest3</a><T extends " + 39.173 + "<a href=\"../../pkg2/ParamTest2.html\" title=\"class in pkg2\">" + 39.174 + "ParamTest2</a><java.util.List<? extends " + 39.175 + "<a href=\"../../pkg2/Foo4.html\" title=\"class in pkg2\">" + 39.176 + "Foo4</a>>>></strong></code> </td>" 39.177 }, 39.178 {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest2.html", 39.179 "<caption><span>Methods in <a href=\"../../pkg2/" + 39.180 @@ -532,10 +538,12 @@ 39.181 "</span></caption>" 39.182 }, 39.183 {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo4.html", 39.184 - "<td class=\"colLast\"><code><strong><a href=\"../../" + 39.185 - "pkg2/ClassUseTest3.html\" title=\"class in pkg2\">" + 39.186 - "ClassUseTest3<T extends ParamTest2<java.util.List" + 39.187 - "<? extends Foo4>>></a></strong></code> </td>" 39.188 + "<td class=\"colLast\"><code><strong><a href=\"../../pkg2/ClassUseTest3.html\" " + 39.189 + "title=\"class in pkg2\">ClassUseTest3</a><T extends " + 39.190 + "<a href=\"../../pkg2/ParamTest2.html\" title=\"class in pkg2\">" + 39.191 + "ParamTest2</a><java.util.List<? extends " + 39.192 + "<a href=\"../../pkg2/Foo4.html\" title=\"class in pkg2\">" + 39.193 + "Foo4</a>>>></strong></code> </td>" 39.194 }, 39.195 {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo4.html", 39.196 "<caption><span>Methods in <a href=\"../../pkg2/" +
40.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 40.2 +++ b/test/com/sun/javadoc/testNonFrameWarning/TestNonFrameWarning.java Sun Apr 10 10:25:12 2011 -0700 40.3 @@ -0,0 +1,71 @@ 40.4 +/* 40.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 40.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 40.7 + * 40.8 + * This code is free software; you can redistribute it and/or modify it 40.9 + * under the terms of the GNU General Public License version 2 only, as 40.10 + * published by the Free Software Foundation. 40.11 + * 40.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 40.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 40.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 40.15 + * version 2 for more details (a copy is included in the LICENSE file that 40.16 + * accompanied this code). 40.17 + * 40.18 + * You should have received a copy of the GNU General Public License version 40.19 + * 2 along with this work; if not, write to the Free Software Foundation, 40.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 40.21 + * 40.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 40.23 + * or visit www.oracle.com if you need additional information or have any 40.24 + * questions. 40.25 + */ 40.26 + 40.27 +/* 40.28 + * @test 40.29 + * @bug 7001086 40.30 + * @summary Test Non-frame warning. 40.31 + * @author Bhavesh Patel 40.32 + * @library ../lib/ 40.33 + * @build JavadocTester TestNonFrameWarning 40.34 + * @run main TestNonFrameWarning 40.35 + */ 40.36 + 40.37 +public class TestNonFrameWarning extends JavadocTester { 40.38 + 40.39 + private static final String BUG_ID = "7001086"; 40.40 + private static final String[][] TEST = { 40.41 + {BUG_ID + FS + "index.html", 40.42 + "<p>This document is designed to be viewed using the frames feature. " + 40.43 + "If you see this message, you are using a non-frame-capable web client. " + 40.44 + "Link to <a href=\"pkg/package-summary.html\">Non-frame version</a>.</p>" 40.45 + } 40.46 + }; 40.47 + private static final String[] ARGS = new String[]{ 40.48 + "-d", BUG_ID, "-sourcepath", SRC_DIR, "pkg" 40.49 + }; 40.50 + 40.51 + /** 40.52 + * The entry point of the test. 40.53 + * @param args the array of command line arguments. 40.54 + */ 40.55 + public static void main(String[] args) { 40.56 + TestNonFrameWarning tester = new TestNonFrameWarning(); 40.57 + run(tester, ARGS, TEST, NO_TEST); 40.58 + tester.printSummary(); 40.59 + } 40.60 + 40.61 + /** 40.62 + * {@inheritDoc} 40.63 + */ 40.64 + public String getBugId() { 40.65 + return BUG_ID; 40.66 + } 40.67 + 40.68 + /** 40.69 + * {@inheritDoc} 40.70 + */ 40.71 + public String getBugName() { 40.72 + return getClass().getName(); 40.73 + } 40.74 +}
41.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 41.2 +++ b/test/com/sun/javadoc/testNonFrameWarning/pkg/C.java Sun Apr 10 10:25:12 2011 -0700 41.3 @@ -0,0 +1,30 @@ 41.4 +/* 41.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 41.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 41.7 + * 41.8 + * This code is free software; you can redistribute it and/or modify it 41.9 + * under the terms of the GNU General Public License version 2 only, as 41.10 + * published by the Free Software Foundation. 41.11 + * 41.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 41.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 41.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 41.15 + * version 2 for more details (a copy is included in the LICENSE file that 41.16 + * accompanied this code). 41.17 + * 41.18 + * You should have received a copy of the GNU General Public License version 41.19 + * 2 along with this work; if not, write to the Free Software Foundation, 41.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 41.21 + * 41.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 41.23 + * or visit www.oracle.com if you need additional information or have any 41.24 + * questions. 41.25 + */ 41.26 + 41.27 +package pkg; 41.28 + 41.29 +/** 41.30 + * Source file for C 41.31 + */ 41.32 +public class C { 41.33 +}
42.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 42.2 +++ b/test/com/sun/javadoc/testSubTitle/TestSubTitle.java Sun Apr 10 10:25:12 2011 -0700 42.3 @@ -0,0 +1,83 @@ 42.4 +/* 42.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 42.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 42.7 + * 42.8 + * This code is free software; you can redistribute it and/or modify it 42.9 + * under the terms of the GNU General Public License version 2 only, as 42.10 + * published by the Free Software Foundation. 42.11 + * 42.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 42.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 42.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 42.15 + * version 2 for more details (a copy is included in the LICENSE file that 42.16 + * accompanied this code). 42.17 + * 42.18 + * You should have received a copy of the GNU General Public License version 42.19 + * 2 along with this work; if not, write to the Free Software Foundation, 42.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 42.21 + * 42.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 42.23 + * or visit www.oracle.com if you need additional information or have any 42.24 + * questions. 42.25 + */ 42.26 + 42.27 +/* 42.28 + * @test 42.29 + * @bug 7010342 42.30 + * @summary Test for correct sub title generation. 42.31 + * @author Bhavesh Patel 42.32 + * @library ../lib/ 42.33 + * @build JavadocTester 42.34 + * @build TestSubTitle 42.35 + * @run main TestSubTitle 42.36 + */ 42.37 + 42.38 +public class TestSubTitle extends JavadocTester { 42.39 + 42.40 + private static final String BUG_ID = "7010342"; 42.41 + private static final String[][] TEST = { 42.42 + {BUG_ID + FS + "pkg" + FS + "package-summary.html", 42.43 + "<div class=\"subTitle\">" + NL + "<div class=\"block\">This is the " + 42.44 + "description of package pkg.</div>" + NL + "</div>" 42.45 + }, 42.46 + {BUG_ID + FS + "pkg" + FS + "C.html", 42.47 + "<div class=\"subTitle\">pkg</div>" 42.48 + } 42.49 + }; 42.50 + private static final String[][] NEG_TEST = { 42.51 + {BUG_ID + FS + "pkg" + FS + "package-summary.html", 42.52 + "<p class=\"subTitle\">" + NL + "<div class=\"block\">This is the " + 42.53 + "description of package pkg.</div>" + NL + "</p>" 42.54 + }, 42.55 + {BUG_ID + FS + "pkg" + FS + "C.html", 42.56 + "<p class=\"subTitle\">pkg</p>" 42.57 + } 42.58 + }; 42.59 + private static final String[] ARGS = new String[]{ 42.60 + "-d", BUG_ID, "-sourcepath", SRC_DIR, "pkg" 42.61 + }; 42.62 + 42.63 + /** 42.64 + * The entry point of the test. 42.65 + * @param args the array of command line arguments. 42.66 + */ 42.67 + public static void main(String[] args) { 42.68 + TestSubTitle tester = new TestSubTitle(); 42.69 + run(tester, ARGS, TEST, NEG_TEST); 42.70 + tester.printSummary(); 42.71 + } 42.72 + 42.73 + /** 42.74 + * {@inheritDoc} 42.75 + */ 42.76 + public String getBugId() { 42.77 + return BUG_ID; 42.78 + } 42.79 + 42.80 + /** 42.81 + * {@inheritDoc} 42.82 + */ 42.83 + public String getBugName() { 42.84 + return getClass().getName(); 42.85 + } 42.86 +}
43.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 43.2 +++ b/test/com/sun/javadoc/testSubTitle/pkg/C.java Sun Apr 10 10:25:12 2011 -0700 43.3 @@ -0,0 +1,30 @@ 43.4 +/* 43.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 43.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 43.7 + * 43.8 + * This code is free software; you can redistribute it and/or modify it 43.9 + * under the terms of the GNU General Public License version 2 only, as 43.10 + * published by the Free Software Foundation. 43.11 + * 43.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 43.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 43.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 43.15 + * version 2 for more details (a copy is included in the LICENSE file that 43.16 + * accompanied this code). 43.17 + * 43.18 + * You should have received a copy of the GNU General Public License version 43.19 + * 2 along with this work; if not, write to the Free Software Foundation, 43.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 43.21 + * 43.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 43.23 + * or visit www.oracle.com if you need additional information or have any 43.24 + * questions. 43.25 + */ 43.26 + 43.27 +package pkg; 43.28 + 43.29 +/** 43.30 + * Source file for C 43.31 + */ 43.32 +public class C { 43.33 +}
44.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 44.2 +++ b/test/com/sun/javadoc/testSubTitle/pkg/package.html Sun Apr 10 10:25:12 2011 -0700 44.3 @@ -0,0 +1,8 @@ 44.4 +<html lang="en"> 44.5 +<head> 44.6 + <title>Package Summary</title> 44.7 +</head> 44.8 +<body> 44.9 +This is the description of package pkg. 44.10 +</body> 44.11 +</html>
45.1 --- a/test/com/sun/javadoc/testTypeParams/TestTypeParameters.java Thu Apr 07 15:21:22 2011 -0700 45.2 +++ b/test/com/sun/javadoc/testTypeParams/TestTypeParameters.java Sun Apr 10 10:25:12 2011 -0700 45.3 @@ -1,5 +1,5 @@ 45.4 /* 45.5 - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 45.6 + * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. 45.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 45.8 * 45.9 * This code is free software; you can redistribute it and/or modify it 45.10 @@ -23,55 +23,77 @@ 45.11 45.12 /* 45.13 * @test 45.14 - * @bug 4927167 4974929 45.15 + * @bug 4927167 4974929 7010344 45.16 * @summary When the type parameters are more than 10 characters in length, 45.17 * make sure there is a line break between type params and return type 45.18 - * in member summary. 45.19 + * in member summary. Also, test for type parameter links in package-summary and 45.20 + * class-use pages. The class/annotation pages should check for type 45.21 + * parameter links in the class/annotation signature section when -linksource is set. 45.22 * @author jamieh 45.23 * @library ../lib/ 45.24 - * @build JavadocTester 45.25 - * @build TestTypeParameters 45.26 + * @build JavadocTester TestTypeParameters 45.27 * @run main TestTypeParameters 45.28 */ 45.29 45.30 public class TestTypeParameters extends JavadocTester { 45.31 45.32 //Test information. 45.33 - private static final String BUG_ID = "4927167-4974929"; 45.34 + private static final String BUG_ID = "4927167-4974929-7010344"; 45.35 45.36 //Javadoc arguments. 45.37 - private static final String[] ARGS = new String[] { 45.38 - "-d", BUG_ID, "-source", "1.5", "-sourcepath", SRC_DIR, 45.39 - "pkg" 45.40 + private static final String[] ARGS1 = new String[]{ 45.41 + "-d", BUG_ID, "-use", "-source", "1.5", "-sourcepath", SRC_DIR, 45.42 + "pkg" 45.43 + }; 45.44 + private static final String[] ARGS2 = new String[]{ 45.45 + "-d", BUG_ID, "-linksource", "-source", "1.5", "-sourcepath", SRC_DIR, 45.46 + "pkg" 45.47 }; 45.48 45.49 //Input for string search tests. 45.50 - private static final String[][] TEST = 45.51 - { 45.52 + private static final String[][] TEST1 = { 45.53 {BUG_ID + FS + "pkg" + FS + "C.html", 45.54 "<td class=\"colFirst\"><code><W extends java.lang.String,V extends " + 45.55 - "java.util.List> <br>java.lang.Object</code></td>"}, 45.56 + "java.util.List> <br>java.lang.Object</code></td>" 45.57 + }, 45.58 {BUG_ID + FS + "pkg" + FS + "C.html", 45.59 - "<code><T> java.lang.Object</code>"}, 45.60 + "<code><T> java.lang.Object</code>" 45.61 + }, 45.62 {BUG_ID + FS + "pkg" + FS + "package-summary.html", 45.63 - "C<E extends Parent>"}, 45.64 + "C</a><E extends <a href=\"../pkg/Parent.html\" " + 45.65 + "title=\"class in pkg\">Parent</a>>" 45.66 + }, 45.67 + {BUG_ID + FS + "pkg" + FS + "class-use" + FS + "Foo4.html", 45.68 + "<a href=\"../../pkg/ClassUseTest3.html\" title=\"class in pkg\">" + 45.69 + "ClassUseTest3</a><T extends <a href=\"../../pkg/ParamTest2.html\" " + 45.70 + "title=\"class in pkg\">ParamTest2</a><java.util.List<? extends " + 45.71 + "<a href=\"../../pkg/Foo4.html\" title=\"class in pkg\">Foo4</a>>>>" 45.72 + }, 45.73 //Nested type parameters 45.74 {BUG_ID + FS + "pkg" + FS + "C.html", 45.75 "<a name=\"formatDetails(java.util.Collection, java.util.Collection)\">" + NL + 45.76 "<!-- -->" + NL + 45.77 - "</a>"}, 45.78 - 45.79 + "</a>" 45.80 + }, 45.81 + }; 45.82 + private static final String[][] TEST2 = { 45.83 + {BUG_ID + FS + "pkg" + FS + "ClassUseTest3.html", 45.84 + "public class <a href=\"../src-html/pkg/ClassUseTest3.html#line.28\">" + 45.85 + "ClassUseTest3</a><T extends <a href=\"../pkg/ParamTest2.html\" " + 45.86 + "title=\"class in pkg\">ParamTest2</a><java.util.List<? extends " + 45.87 + "<a href=\"../pkg/Foo4.html\" title=\"class in pkg\">Foo4</a>>>>" 45.88 + } 45.89 }; 45.90 private static final String[][] NEGATED_TEST = NO_TEST; 45.91 45.92 - 45.93 /** 45.94 * The entry point of the test. 45.95 * @param args the array of command line arguments. 45.96 */ 45.97 public static void main(String[] args) { 45.98 TestTypeParameters tester = new TestTypeParameters(); 45.99 - run(tester, ARGS, TEST, NEGATED_TEST); 45.100 + run(tester, ARGS1, TEST1, NEGATED_TEST); 45.101 + run(tester, ARGS2, TEST2, NEGATED_TEST); 45.102 tester.printSummary(); 45.103 } 45.104
46.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 46.2 +++ b/test/com/sun/javadoc/testTypeParams/pkg/ClassUseTest3.java Sun Apr 10 10:25:12 2011 -0700 46.3 @@ -0,0 +1,37 @@ 46.4 +/* 46.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 46.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 46.7 + * 46.8 + * This code is free software; you can redistribute it and/or modify it 46.9 + * under the terms of the GNU General Public License version 2 only, as 46.10 + * published by the Free Software Foundation. 46.11 + * 46.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 46.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 46.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 46.15 + * version 2 for more details (a copy is included in the LICENSE file that 46.16 + * accompanied this code). 46.17 + * 46.18 + * You should have received a copy of the GNU General Public License version 46.19 + * 2 along with this work; if not, write to the Free Software Foundation, 46.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 46.21 + * 46.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 46.23 + * or visit www.oracle.com if you need additional information or have any 46.24 + * questions. 46.25 + */ 46.26 + 46.27 +package pkg; 46.28 + 46.29 +import java.util.*; 46.30 + 46.31 +public class ClassUseTest3 <T extends ParamTest2<List<? extends Foo4>>> { 46.32 + 46.33 + public ClassUseTest3(Set<Foo4> p) {} 46.34 + 46.35 + public <T extends ParamTest2<List<? extends Foo4>>> ParamTest2<List<? extends Foo4>> method(T t) { 46.36 + return null; 46.37 + } 46.38 + 46.39 + public void method(Set<Foo4> p) {} 46.40 +}
47.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 47.2 +++ b/test/com/sun/javadoc/testTypeParams/pkg/Foo4.java Sun Apr 10 10:25:12 2011 -0700 47.3 @@ -0,0 +1,26 @@ 47.4 +/* 47.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 47.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 47.7 + * 47.8 + * This code is free software; you can redistribute it and/or modify it 47.9 + * under the terms of the GNU General Public License version 2 only, as 47.10 + * published by the Free Software Foundation. 47.11 + * 47.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 47.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 47.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 47.15 + * version 2 for more details (a copy is included in the LICENSE file that 47.16 + * accompanied this code). 47.17 + * 47.18 + * You should have received a copy of the GNU General Public License version 47.19 + * 2 along with this work; if not, write to the Free Software Foundation, 47.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 47.21 + * 47.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 47.23 + * or visit www.oracle.com if you need additional information or have any 47.24 + * questions. 47.25 + */ 47.26 + 47.27 +package pkg; 47.28 + 47.29 +public class Foo4 {}
48.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 48.2 +++ b/test/com/sun/javadoc/testTypeParams/pkg/ParamTest2.java Sun Apr 10 10:25:12 2011 -0700 48.3 @@ -0,0 +1,27 @@ 48.4 +/* 48.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 48.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 48.7 + * 48.8 + * This code is free software; you can redistribute it and/or modify it 48.9 + * under the terms of the GNU General Public License version 2 only, as 48.10 + * published by the Free Software Foundation. 48.11 + * 48.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 48.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 48.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 48.15 + * version 2 for more details (a copy is included in the LICENSE file that 48.16 + * accompanied this code). 48.17 + * 48.18 + * You should have received a copy of the GNU General Public License version 48.19 + * 2 along with this work; if not, write to the Free Software Foundation, 48.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 48.21 + * 48.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 48.23 + * or visit www.oracle.com if you need additional information or have any 48.24 + * questions. 48.25 + */ 48.26 + 48.27 +package pkg; 48.28 + 48.29 +public class ParamTest2<E> { 48.30 +}
49.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 49.2 +++ b/test/tools/javac/TryWithResources/InterruptedExceptionTest.java Sun Apr 10 10:25:12 2011 -0700 49.3 @@ -0,0 +1,234 @@ 49.4 +/* 49.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 49.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 49.7 + * 49.8 + * This code is free software; you can redistribute it and/or modify it 49.9 + * under the terms of the GNU General Public License version 2 only, as 49.10 + * published by the Free Software Foundation. 49.11 + * 49.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 49.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 49.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 49.15 + * version 2 for more details (a copy is included in the LICENSE file that 49.16 + * accompanied this code). 49.17 + * 49.18 + * You should have received a copy of the GNU General Public License version 49.19 + * 2 along with this work; if not, write to the Free Software Foundation, 49.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 49.21 + * 49.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 49.23 + * or visit www.oracle.com if you need additional information or have any 49.24 + * questions. 49.25 + */ 49.26 + 49.27 +/* 49.28 + * @test 49.29 + * @bug 7027157 49.30 + * @summary Project Coin: javac warnings for AutoCloseable.close throwing InterruptedException 49.31 + */ 49.32 + 49.33 +import com.sun.source.util.JavacTask; 49.34 +import java.net.URI; 49.35 +import java.util.Arrays; 49.36 +import javax.tools.Diagnostic; 49.37 +import javax.tools.JavaCompiler; 49.38 +import javax.tools.JavaFileObject; 49.39 +import javax.tools.SimpleJavaFileObject; 49.40 +import javax.tools.StandardJavaFileManager; 49.41 +import javax.tools.ToolProvider; 49.42 + 49.43 +public class InterruptedExceptionTest { 49.44 + 49.45 + enum XlintOption { 49.46 + NONE("none"), 49.47 + TRY("try"); 49.48 + 49.49 + String opt; 49.50 + 49.51 + XlintOption(String opt) { 49.52 + this.opt = opt; 49.53 + } 49.54 + 49.55 + String getXlintOption() { 49.56 + return "-Xlint:" + opt; 49.57 + } 49.58 + } 49.59 + 49.60 + enum SuppressLevel { 49.61 + NONE, 49.62 + SUPPRESS; 49.63 + 49.64 + String getSuppressAnno() { 49.65 + return this == SUPPRESS ? 49.66 + "@SuppressWarnings(\"try\")" : 49.67 + ""; 49.68 + } 49.69 + } 49.70 + 49.71 + enum ClassKind { 49.72 + ABSTRACT_CLASS("abstract class", "implements", false), 49.73 + CLASS("class", "implements", true), 49.74 + INTERFACE("interface", "extends", false); 49.75 + 49.76 + String kindName; 49.77 + String extendsClause; 49.78 + boolean hasBody; 49.79 + 49.80 + private ClassKind(String kindName, String extendsClause, boolean hasBody) { 49.81 + this.kindName = kindName; 49.82 + this.extendsClause = extendsClause; 49.83 + this.hasBody = hasBody; 49.84 + } 49.85 + 49.86 + String getBody() { 49.87 + return hasBody ? "{}" : ";"; 49.88 + } 49.89 + } 49.90 + 49.91 + enum ExceptionKind { 49.92 + NONE("", false), 49.93 + EXCEPTION("Exception", true), 49.94 + INTERRUPTED_EXCEPTION("InterruptedException", true), 49.95 + ILLEGAL_ARGUMENT_EXCEPTION("IllegalArgumentException", false), 49.96 + X("X", false); 49.97 + 49.98 + String exName; 49.99 + boolean shouldWarn; 49.100 + 49.101 + private ExceptionKind(String exName, boolean shouldWarn) { 49.102 + this.exName = exName; 49.103 + this.shouldWarn = shouldWarn; 49.104 + } 49.105 + 49.106 + String getThrowsClause() { 49.107 + return this == NONE ? "" : "throws " + exName; 49.108 + } 49.109 + 49.110 + String getTypeArguments(ExceptionKind decl) { 49.111 + return (decl != X || this == NONE) ? "" : "<" + exName + ">"; 49.112 + } 49.113 + 49.114 + String getTypeParameter() { 49.115 + return this == X ? "<X extends Exception>" : ""; 49.116 + } 49.117 + } 49.118 + 49.119 + public static void main(String... args) throws Exception { 49.120 + 49.121 + //create default shared JavaCompiler - reused across multiple compilations 49.122 + JavaCompiler comp = ToolProvider.getSystemJavaCompiler(); 49.123 + StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null); 49.124 + 49.125 + for (XlintOption xlint : XlintOption.values()) { 49.126 + for (SuppressLevel suppress_decl : SuppressLevel.values()) { 49.127 + for (SuppressLevel suppress_use : SuppressLevel.values()) { 49.128 + for (ClassKind ck : ClassKind.values()) { 49.129 + for (ExceptionKind ek_decl : ExceptionKind.values()) { 49.130 + for (ExceptionKind ek_use : ExceptionKind.values()) { 49.131 + new InterruptedExceptionTest(xlint, suppress_decl, 49.132 + suppress_use, ck, ek_decl, ek_use).run(comp, fm); 49.133 + } 49.134 + } 49.135 + } 49.136 + } 49.137 + } 49.138 + } 49.139 + } 49.140 + 49.141 + XlintOption xlint; 49.142 + SuppressLevel suppress_decl; 49.143 + SuppressLevel suppress_use; 49.144 + ClassKind ck; 49.145 + ExceptionKind ek_decl; 49.146 + ExceptionKind ek_use; 49.147 + JavaSource source; 49.148 + DiagnosticChecker diagChecker; 49.149 + 49.150 + InterruptedExceptionTest(XlintOption xlint, SuppressLevel suppress_decl, SuppressLevel suppress_use, 49.151 + ClassKind ck, ExceptionKind ek_decl, ExceptionKind ek_use) { 49.152 + this.xlint = xlint; 49.153 + this.suppress_decl = suppress_decl; 49.154 + this.suppress_use = suppress_use; 49.155 + this.ck = ck; 49.156 + this.ek_decl = ek_decl; 49.157 + this.ek_use = ek_use; 49.158 + this.source = new JavaSource(); 49.159 + this.diagChecker = new DiagnosticChecker(); 49.160 + } 49.161 + 49.162 + class JavaSource extends SimpleJavaFileObject { 49.163 + 49.164 + String template = "#S1 #CK Resource#G #EC AutoCloseable {\n" + 49.165 + "public void close() #TK #BK\n" + 49.166 + "}\n" + 49.167 + "class Test {\n" + 49.168 + "#S2 <X> void test() {\n" + 49.169 + "try (Resource#PK r = null) { }\n" + 49.170 + "}\n" + 49.171 + "}\n"; 49.172 + 49.173 + String source; 49.174 + 49.175 + public JavaSource() { 49.176 + super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE); 49.177 + source = template.replace("#S1", suppress_decl.getSuppressAnno()) 49.178 + .replace("#S2", suppress_use.getSuppressAnno()) 49.179 + .replace("#CK", ck.kindName) 49.180 + .replace("#EC", ck.extendsClause) 49.181 + .replace("#G", ek_decl.getTypeParameter()) 49.182 + .replace("#TK", ek_decl.getThrowsClause()) 49.183 + .replace("#BK", ck.getBody()) 49.184 + .replace("#PK", ek_use.getTypeArguments(ek_decl)); 49.185 + } 49.186 + 49.187 + @Override 49.188 + public CharSequence getCharContent(boolean ignoreEncodingErrors) { 49.189 + return source; 49.190 + } 49.191 + } 49.192 + 49.193 + void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception { 49.194 + JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker, 49.195 + Arrays.asList(xlint.getXlintOption()), null, Arrays.asList(source)); 49.196 + ct.analyze(); 49.197 + check(); 49.198 + } 49.199 + 49.200 + void check() { 49.201 + 49.202 + boolean shouldWarnDecl = ek_decl.shouldWarn && 49.203 + xlint == XlintOption.TRY && 49.204 + suppress_decl != SuppressLevel.SUPPRESS; 49.205 + 49.206 + boolean shouldWarnUse = (ek_decl.shouldWarn || 49.207 + ((ek_use.shouldWarn || ek_use == ExceptionKind.NONE) && ek_decl == ExceptionKind.X)) && 49.208 + xlint == XlintOption.TRY && 49.209 + suppress_use != SuppressLevel.SUPPRESS; 49.210 + 49.211 + int foundWarnings = 0; 49.212 + 49.213 + if (shouldWarnDecl) foundWarnings++; 49.214 + if (shouldWarnUse) foundWarnings++; 49.215 + 49.216 + if (foundWarnings != diagChecker.tryWarnFound) { 49.217 + throw new Error("invalid diagnostics for source:\n" + 49.218 + source.getCharContent(true) + 49.219 + "\nOptions: " + xlint.getXlintOption() + 49.220 + "\nFound warnings: " + diagChecker.tryWarnFound + 49.221 + "\nExpected decl warning: " + shouldWarnDecl + 49.222 + "\nExpected use warning: " + shouldWarnUse); 49.223 + } 49.224 + } 49.225 + 49.226 + static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> { 49.227 + 49.228 + int tryWarnFound; 49.229 + 49.230 + public void report(Diagnostic<? extends JavaFileObject> diagnostic) { 49.231 + if (diagnostic.getKind() == Diagnostic.Kind.WARNING && 49.232 + diagnostic.getCode().contains("try.resource.throws.interrupted.exc")) { 49.233 + tryWarnFound++; 49.234 + } 49.235 + } 49.236 + } 49.237 +}
50.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 50.2 +++ b/test/tools/javac/TryWithResources/T7032633.java Sun Apr 10 10:25:12 2011 -0700 50.3 @@ -0,0 +1,40 @@ 50.4 +/* 50.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 50.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 50.7 + * 50.8 + * This code is free software; you can redistribute it and/or modify it 50.9 + * under the terms of the GNU General Public License version 2 only, as 50.10 + * published by the Free Software Foundation. 50.11 + * 50.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 50.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 50.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 50.15 + * version 2 for more details (a copy is included in the LICENSE file that 50.16 + * accompanied this code). 50.17 + * 50.18 + * You should have received a copy of the GNU General Public License version 50.19 + * 2 along with this work; if not, write to the Free Software Foundation, 50.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 50.21 + * 50.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 50.23 + * or visit www.oracle.com if you need additional information or have any 50.24 + * questions. 50.25 + */ 50.26 + 50.27 +/* 50.28 + * @test 50.29 + * @bug 7032633 50.30 + * @summary javac -Xlint:all warns about flush() within try on an auto-closeable resource 50.31 + * @compile -Xlint:try -Werror T7032633.java 50.32 + */ 50.33 + 50.34 +import java.io.IOException; 50.35 +import java.io.OutputStream; 50.36 + 50.37 +public class T7032633 { 50.38 + void test() throws IOException { 50.39 + try (OutputStream out = System.out) { 50.40 + out.flush(); 50.41 + } 50.42 + } 50.43 +}
51.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 51.2 +++ b/test/tools/javac/api/T6437138.java Sun Apr 10 10:25:12 2011 -0700 51.3 @@ -0,0 +1,61 @@ 51.4 +/* 51.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 51.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 51.7 + * 51.8 + * This code is free software; you can redistribute it and/or modify it 51.9 + * under the terms of the GNU General Public License version 2 only, as 51.10 + * published by the Free Software Foundation. 51.11 + * 51.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 51.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 51.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 51.15 + * version 2 for more details (a copy is included in the LICENSE file that 51.16 + * accompanied this code). 51.17 + * 51.18 + * You should have received a copy of the GNU General Public License version 51.19 + * 2 along with this work; if not, write to the Free Software Foundation, 51.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 51.21 + * 51.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 51.23 + * or visit www.oracle.com if you need additional information or have any 51.24 + * questions. 51.25 + */ 51.26 + 51.27 +/* 51.28 + * @test 51.29 + * @bug 6437138 51.30 + * @summary JSR 199: Compiler doesn't diagnose crash in user code 51.31 + */ 51.32 + 51.33 +import java.net.URI; 51.34 +import java.util.Arrays; 51.35 +import javax.tools.*; 51.36 +import static javax.tools.JavaFileObject.Kind.*; 51.37 + 51.38 + 51.39 +public class T6437138 { 51.40 + static class JFO extends SimpleJavaFileObject { 51.41 + public JFO(URI uri, JavaFileObject.Kind kind) { 51.42 + super(uri, kind); 51.43 + } 51.44 + // getCharContent not impl, will throw UnsupportedOperationException 51.45 + } 51.46 + 51.47 + public static void main(String... arg) throws Exception { 51.48 + try { 51.49 + JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); 51.50 + JavaFileObject jfo = new JFO(new URI("JFOTest04.java"),SOURCE); 51.51 + JavaCompiler.CompilationTask ct = javac.getTask(null,null,null,null, 51.52 + null, Arrays.asList(jfo)); 51.53 + ct.call(); 51.54 + throw new Exception("no exception thrown by JavaCompiler.CompilationTask"); 51.55 + } catch (RuntimeException e) { 51.56 + if (e.getCause() instanceof UnsupportedOperationException) { 51.57 + System.err.println("RuntimeException(UnsupportedOperationException) caught as expected"); 51.58 + return; 51.59 + } 51.60 + throw new Exception("unexpected exception caught", e); 51.61 + } 51.62 + } 51.63 +} 51.64 +
52.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 52.2 +++ b/test/tools/javac/api/TestClientCodeWrapper.java Sun Apr 10 10:25:12 2011 -0700 52.3 @@ -0,0 +1,604 @@ 52.4 +/* 52.5 + * Copyright (c) 2011 Oracle and/or its affiliates. All rights reserved. 52.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 52.7 + * 52.8 + * This code is free software; you can redistribute it and/or modify it 52.9 + * under the terms of the GNU General Public License version 2 only, as 52.10 + * published by the Free Software Foundation. 52.11 + * 52.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 52.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 52.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 52.15 + * version 2 for more details (a copy is included in the LICENSE file that 52.16 + * accompanied this code). 52.17 + * 52.18 + * You should have received a copy of the GNU General Public License version 52.19 + * 2 along with this work; if not, write to the Free Software Foundation, 52.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 52.21 + * 52.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 52.23 + * or visit www.oracle.com if you need additional information or have any 52.24 + * questions. 52.25 + */ 52.26 + 52.27 +/* 52.28 + * @test 52.29 + * @bug 6437138 6482554 52.30 + * @summary JSR 199: Compiler doesn't diagnose crash in user code 52.31 + * @library ../lib 52.32 + * @build JavacTestingAbstractProcessor TestClientCodeWrapper 52.33 + * @run main TestClientCodeWrapper 52.34 + */ 52.35 + 52.36 +import java.io.*; 52.37 +import java.lang.reflect.Method; 52.38 +import java.net.URI; 52.39 +import java.util.*; 52.40 +import javax.annotation.processing.*; 52.41 +import javax.lang.model.*; 52.42 +import javax.lang.model.element.*; 52.43 +import javax.tools.*; 52.44 +import com.sun.source.util.*; 52.45 +import com.sun.tools.javac.api.*; 52.46 +import javax.tools.JavaFileObject.Kind; 52.47 + 52.48 +public class TestClientCodeWrapper extends JavacTestingAbstractProcessor { 52.49 + public static void main(String... args) throws Exception { 52.50 + new TestClientCodeWrapper().run(); 52.51 + } 52.52 + 52.53 + /** 52.54 + * Run a series of compilations, each with a different user-provided object 52.55 + * configured to throw an exception when a specific method is invoked. 52.56 + * Then, verify the exception is thrown as expected. 52.57 + * 52.58 + * Some methods are not invoked from the compiler, and are excluded from the test. 52.59 + */ 52.60 + void run() throws Exception { 52.61 + JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); 52.62 + defaultFileManager = compiler.getStandardFileManager(null, null, null); 52.63 + 52.64 + for (Method m: getMethodsExcept(JavaFileManager.class, "close", "getJavaFileForInput")) { 52.65 + test(m); 52.66 + } 52.67 + 52.68 + for (Method m: getMethodsExcept(FileObject.class, "delete")) { 52.69 + test(m); 52.70 + } 52.71 + 52.72 + for (Method m: getMethods(JavaFileObject.class)) { 52.73 + test(m); 52.74 + } 52.75 + 52.76 + for (Method m: getMethodsExcept(Processor.class, "getCompletions")) { 52.77 + test(m); 52.78 + } 52.79 + 52.80 + for (Method m: DiagnosticListener.class.getDeclaredMethods()) { 52.81 + test(m); 52.82 + } 52.83 + 52.84 + for (Method m: TaskListener.class.getDeclaredMethods()) { 52.85 + test(m); 52.86 + } 52.87 + 52.88 + if (errors > 0) 52.89 + throw new Exception(errors + " errors occurred"); 52.90 + } 52.91 + 52.92 + /** Get a sorted set of the methods declared on a class. */ 52.93 + Set<Method> getMethods(Class<?> clazz) { 52.94 + return getMethodsExcept(clazz, new String[0]); 52.95 + } 52.96 + 52.97 + /** Get a sorted set of the methods declared on a class, excluding 52.98 + * specified methods by name. */ 52.99 + Set<Method> getMethodsExcept(Class<?> clazz, String... exclude) { 52.100 + Set<Method> methods = new TreeSet<Method>(new Comparator<Method>() { 52.101 + public int compare(Method m1, Method m2) { 52.102 + return m1.toString().compareTo(m2.toString()); 52.103 + } 52.104 + }); 52.105 + Set<String> e = new HashSet<String>(Arrays.asList(exclude)); 52.106 + for (Method m: clazz.getDeclaredMethods()) { 52.107 + if (!e.contains(m.getName())) 52.108 + methods.add(m); 52.109 + } 52.110 + return methods; 52.111 + } 52.112 + 52.113 + /** 52.114 + * Test a method in a user supplied component, to verify javac's handling 52.115 + * of any exceptions thrown by that method. 52.116 + */ 52.117 + void test(Method m) throws Exception { 52.118 + testNum++; 52.119 + 52.120 + File extDirs = new File("empty-extdirs"); 52.121 + extDirs.mkdirs(); 52.122 + 52.123 + File testClasses = new File("test" + testNum); 52.124 + testClasses.mkdirs(); 52.125 + defaultFileManager.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(testClasses)); 52.126 + 52.127 + System.err.println("test " + testNum + ": " 52.128 + + m.getDeclaringClass().getSimpleName() + "." + m.getName()); 52.129 + 52.130 + StringWriter sw = new StringWriter(); 52.131 + PrintWriter pw = new PrintWriter(sw); 52.132 + 52.133 + List<String> javacOptions = Arrays.asList( 52.134 + "-extdirs", extDirs.getPath(), // for use by filemanager handleOption 52.135 + "-processor", TestClientCodeWrapper.class.getName() 52.136 + ); 52.137 + 52.138 + List<String> classes = Collections.emptyList(); 52.139 + 52.140 + JavacTool tool = JavacTool.create(); 52.141 + try { 52.142 + JavacTask task = tool.getTask(pw, 52.143 + getFileManager(m, defaultFileManager), 52.144 + getDiagnosticListener(m, pw), 52.145 + javacOptions, 52.146 + classes, 52.147 + getCompilationUnits(m)); 52.148 + 52.149 + if (isDeclaredIn(m, Processor.class)) 52.150 + task.setProcessors(getProcessors(m)); 52.151 + 52.152 + if (isDeclaredIn(m, TaskListener.class)) 52.153 + task.setTaskListener(getTaskListener(m, pw)); 52.154 + 52.155 + boolean ok = task.call(); 52.156 + error("compilation " + (ok ? "succeeded" : "failed") + " unexpectedly"); 52.157 + } catch (RuntimeException e) { 52.158 + System.err.println("caught " + e); 52.159 + if (e.getClass() == RuntimeException.class) { 52.160 + Throwable cause = e.getCause(); 52.161 + if (cause instanceof UserError) { 52.162 + String expect = m.getName(); 52.163 + String found = cause.getMessage(); 52.164 + checkEqual("exception messaqe", expect, found); 52.165 + } else { 52.166 + cause.printStackTrace(System.err); 52.167 + error("Unexpected exception: " + cause); 52.168 + } 52.169 + } else { 52.170 + e.printStackTrace(System.err); 52.171 + error("Unexpected exception: " + e); 52.172 + } 52.173 + } 52.174 + 52.175 + pw.close(); 52.176 + String out = sw.toString(); 52.177 + System.err.println(out); 52.178 + } 52.179 + 52.180 + /** Get a file manager to use for the test compilation. */ 52.181 + JavaFileManager getFileManager(Method m, JavaFileManager defaultFileManager) { 52.182 + return isDeclaredIn(m, JavaFileManager.class, FileObject.class, JavaFileObject.class) 52.183 + ? new UserFileManager(m, defaultFileManager) 52.184 + : defaultFileManager; 52.185 + } 52.186 + 52.187 + /** Get a diagnostic listener to use for the test compilation. */ 52.188 + DiagnosticListener<JavaFileObject> getDiagnosticListener(Method m, PrintWriter out) { 52.189 + return isDeclaredIn(m, DiagnosticListener.class) 52.190 + ? new UserDiagnosticListener(m, out) 52.191 + : null; 52.192 + } 52.193 + 52.194 + /** Get a set of file objects to use for the test compilation. */ 52.195 + Iterable<? extends JavaFileObject> getCompilationUnits(Method m) { 52.196 + File testSrc = new File(System.getProperty("test.src")); 52.197 + File thisSrc = new File(testSrc, TestClientCodeWrapper.class.getName() + ".java"); 52.198 + Iterable<? extends JavaFileObject> files = defaultFileManager.getJavaFileObjects(thisSrc); 52.199 + if (isDeclaredIn(m, FileObject.class, JavaFileObject.class)) 52.200 + return Arrays.asList(new UserFileObject(m, files.iterator().next())); 52.201 + else 52.202 + return files; 52.203 + } 52.204 + 52.205 + /** Get a set of annotation processors to use for the test compilation. */ 52.206 + Iterable<? extends Processor> getProcessors(Method m) { 52.207 + return Arrays.asList(new UserProcessor(m)); 52.208 + } 52.209 + 52.210 + /** Get a task listener to use for the test compilation. */ 52.211 + TaskListener getTaskListener(Method m, PrintWriter out) { 52.212 + return new UserTaskListener(m, out); 52.213 + } 52.214 + 52.215 + /** Check if two values are .equal, and report an error if not. */ 52.216 + <T> void checkEqual(String label, T expect, T found) { 52.217 + if (!expect.equals(found)) 52.218 + error("Unexpected value for " + label + ": " + found + "; expected: " + expect); 52.219 + } 52.220 + 52.221 + /** Report an error. */ 52.222 + void error(String msg) { 52.223 + System.err.println("Error: " + msg); 52.224 + errors++; 52.225 + } 52.226 + 52.227 + /** Check if a method is declared in any of a set of classes */ 52.228 + static boolean isDeclaredIn(Method m, Class<?>... classes) { 52.229 + Class<?> dc = m.getDeclaringClass(); 52.230 + for (Class<?> c: classes) { 52.231 + if (c == dc) return true; 52.232 + } 52.233 + return false; 52.234 + } 52.235 + 52.236 + /** Throw an intentional error if the method has a given name. */ 52.237 + static void throwUserExceptionIfNeeded(Method m, String name) { 52.238 + if (m != null && m.getName().equals(name)) 52.239 + throw new UserError(name); 52.240 + } 52.241 + 52.242 + StandardJavaFileManager defaultFileManager; 52.243 + int testNum; 52.244 + int errors; 52.245 + 52.246 + //-------------------------------------------------------------------------- 52.247 + 52.248 + /** 52.249 + * Processor used to trigger use of methods not normally used by javac. 52.250 + */ 52.251 + @Override 52.252 + public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { 52.253 + boolean firstRound = false; 52.254 + for (Element e: roundEnv.getRootElements()) { 52.255 + if (e.getSimpleName().contentEquals(TestClientCodeWrapper.class.getSimpleName())) 52.256 + firstRound = true; 52.257 + } 52.258 + if (firstRound) { 52.259 + try { 52.260 + FileObject f1 = filer.getResource(StandardLocation.CLASS_PATH, "", 52.261 + TestClientCodeWrapper.class.getName() + ".java"); 52.262 + f1.openInputStream().close(); 52.263 + f1.openReader(false).close(); 52.264 + 52.265 + FileObject f2 = filer.createResource( 52.266 + StandardLocation.CLASS_OUTPUT, "", "f2.txt", (Element[]) null); 52.267 + f2.openOutputStream().close(); 52.268 + 52.269 + FileObject f3 = filer.createResource( 52.270 + StandardLocation.CLASS_OUTPUT, "", "f3.txt", (Element[]) null); 52.271 + f3.openWriter().close(); 52.272 + 52.273 + JavaFileObject f4 = filer.createSourceFile("f4", (Element[]) null); 52.274 + f4.openWriter().close(); 52.275 + f4.getNestingKind(); 52.276 + f4.getAccessLevel(); 52.277 + 52.278 + messager.printMessage(Diagnostic.Kind.NOTE, "informational note", 52.279 + roundEnv.getRootElements().iterator().next()); 52.280 + 52.281 + } catch (IOException e) { 52.282 + throw new UserError(e); 52.283 + } 52.284 + } 52.285 + return true; 52.286 + } 52.287 + 52.288 + //-------------------------------------------------------------------------- 52.289 + 52.290 + // <editor-fold defaultstate="collapsed" desc="User classes"> 52.291 + 52.292 + static class UserError extends Error { 52.293 + private static final long serialVersionUID = 1L; 52.294 + UserError(String msg) { 52.295 + super(msg); 52.296 + } 52.297 + UserError(Throwable t) { 52.298 + super(t); 52.299 + } 52.300 + } 52.301 + 52.302 + static class UserFileManager extends ForwardingJavaFileManager<JavaFileManager> { 52.303 + Method fileManagerMethod; 52.304 + Method fileObjectMethod; 52.305 + 52.306 + UserFileManager(Method m, JavaFileManager delegate) { 52.307 + super(delegate); 52.308 + if (isDeclaredIn(m, JavaFileManager.class)) { 52.309 + fileManagerMethod = m; 52.310 + } else if (isDeclaredIn(m, FileObject.class, JavaFileObject.class)) { 52.311 + fileObjectMethod = m; 52.312 + } else 52.313 + assert false; 52.314 + } 52.315 + 52.316 + @Override 52.317 + public ClassLoader getClassLoader(Location location) { 52.318 + throwUserExceptionIfNeeded(fileManagerMethod, "getClassLoader"); 52.319 + return super.getClassLoader(location); 52.320 + } 52.321 + 52.322 + @Override 52.323 + public Iterable<JavaFileObject> list(Location location, String packageName, Set<Kind> kinds, boolean recurse) throws IOException { 52.324 + throwUserExceptionIfNeeded(fileManagerMethod, "list"); 52.325 + return wrap(super.list(location, packageName, kinds, recurse)); 52.326 + } 52.327 + 52.328 + @Override 52.329 + public String inferBinaryName(Location location, JavaFileObject file) { 52.330 + throwUserExceptionIfNeeded(fileManagerMethod, "inferBinaryName"); 52.331 + return super.inferBinaryName(location, unwrap(file)); 52.332 + } 52.333 + 52.334 + @Override 52.335 + public boolean isSameFile(FileObject a, FileObject b) { 52.336 + throwUserExceptionIfNeeded(fileManagerMethod, "isSameFile"); 52.337 + return super.isSameFile(unwrap(a), unwrap(b)); 52.338 + } 52.339 + 52.340 + @Override 52.341 + public boolean handleOption(String current, Iterator<String> remaining) { 52.342 + throwUserExceptionIfNeeded(fileManagerMethod, "handleOption"); 52.343 + return super.handleOption(current, remaining); 52.344 + } 52.345 + 52.346 + @Override 52.347 + public boolean hasLocation(Location location) { 52.348 + throwUserExceptionIfNeeded(fileManagerMethod, "hasLocation"); 52.349 + return super.hasLocation(location); 52.350 + } 52.351 + 52.352 + @Override 52.353 + public JavaFileObject getJavaFileForInput(Location location, String className, Kind kind) throws IOException { 52.354 + throwUserExceptionIfNeeded(fileManagerMethod, "getJavaFileForInput"); 52.355 + return wrap(super.getJavaFileForInput(location, className, kind)); 52.356 + } 52.357 + 52.358 + @Override 52.359 + public JavaFileObject getJavaFileForOutput(Location location, String className, Kind kind, FileObject sibling) throws IOException { 52.360 + throwUserExceptionIfNeeded(fileManagerMethod, "getJavaFileForOutput"); 52.361 + return wrap(super.getJavaFileForOutput(location, className, kind, sibling)); 52.362 + } 52.363 + 52.364 + @Override 52.365 + public FileObject getFileForInput(Location location, String packageName, String relativeName) throws IOException { 52.366 + throwUserExceptionIfNeeded(fileManagerMethod, "getFileForInput"); 52.367 + return wrap(super.getFileForInput(location, packageName, relativeName)); 52.368 + } 52.369 + 52.370 + @Override 52.371 + public FileObject getFileForOutput(Location location, String packageName, String relativeName, FileObject sibling) throws IOException { 52.372 + throwUserExceptionIfNeeded(fileManagerMethod, "getFileForOutput"); 52.373 + return wrap(super.getFileForOutput(location, packageName, relativeName, sibling)); 52.374 + } 52.375 + 52.376 + @Override 52.377 + public void flush() throws IOException { 52.378 + throwUserExceptionIfNeeded(fileManagerMethod, "flush"); 52.379 + super.flush(); 52.380 + } 52.381 + 52.382 + @Override 52.383 + public void close() throws IOException { 52.384 + throwUserExceptionIfNeeded(fileManagerMethod, "close"); 52.385 + super.close(); 52.386 + } 52.387 + 52.388 + @Override 52.389 + public int isSupportedOption(String option) { 52.390 + throwUserExceptionIfNeeded(fileManagerMethod, "isSupportedOption"); 52.391 + return super.isSupportedOption(option); 52.392 + } 52.393 + 52.394 + public FileObject wrap(FileObject fo) { 52.395 + if (fileObjectMethod == null) 52.396 + return fo; 52.397 + return new UserFileObject(fileObjectMethod, (JavaFileObject)fo); 52.398 + } 52.399 + 52.400 + FileObject unwrap(FileObject fo) { 52.401 + if (fo instanceof UserFileObject) 52.402 + return ((UserFileObject) fo).unwrap(); 52.403 + else 52.404 + return fo; 52.405 + } 52.406 + 52.407 + public JavaFileObject wrap(JavaFileObject fo) { 52.408 + if (fileObjectMethod == null) 52.409 + return fo; 52.410 + return new UserFileObject(fileObjectMethod, fo); 52.411 + } 52.412 + 52.413 + public Iterable<JavaFileObject> wrap(Iterable<? extends JavaFileObject> list) { 52.414 + List<JavaFileObject> wrapped = new ArrayList<JavaFileObject>(); 52.415 + for (JavaFileObject fo : list) 52.416 + wrapped.add(wrap(fo)); 52.417 + return Collections.unmodifiableList(wrapped); 52.418 + } 52.419 + 52.420 + JavaFileObject unwrap(JavaFileObject fo) { 52.421 + if (fo instanceof UserFileObject) 52.422 + return ((UserFileObject) fo).unwrap(); 52.423 + else 52.424 + return fo; 52.425 + } 52.426 + } 52.427 + 52.428 + static class UserFileObject extends ForwardingJavaFileObject<JavaFileObject> { 52.429 + Method method; 52.430 + 52.431 + UserFileObject(Method m, JavaFileObject delegate) { 52.432 + super(delegate); 52.433 + assert isDeclaredIn(m, FileObject.class, JavaFileObject.class); 52.434 + this.method = m; 52.435 + } 52.436 + 52.437 + JavaFileObject unwrap() { 52.438 + return fileObject; 52.439 + } 52.440 + 52.441 + @Override 52.442 + public Kind getKind() { 52.443 + throwUserExceptionIfNeeded(method, "getKind"); 52.444 + return super.getKind(); 52.445 + } 52.446 + 52.447 + @Override 52.448 + public boolean isNameCompatible(String simpleName, Kind kind) { 52.449 + throwUserExceptionIfNeeded(method, "isNameCompatible"); 52.450 + return super.isNameCompatible(simpleName, kind); 52.451 + } 52.452 + 52.453 + @Override 52.454 + public NestingKind getNestingKind() { 52.455 + throwUserExceptionIfNeeded(method, "getNestingKind"); 52.456 + return super.getNestingKind(); 52.457 + } 52.458 + 52.459 + @Override 52.460 + public Modifier getAccessLevel() { 52.461 + throwUserExceptionIfNeeded(method, "getAccessLevel"); 52.462 + return super.getAccessLevel(); 52.463 + } 52.464 + 52.465 + @Override 52.466 + public URI toUri() { 52.467 + throwUserExceptionIfNeeded(method, "toUri"); 52.468 + return super.toUri(); 52.469 + } 52.470 + 52.471 + @Override 52.472 + public String getName() { 52.473 + throwUserExceptionIfNeeded(method, "getName"); 52.474 + return super.getName(); 52.475 + } 52.476 + 52.477 + @Override 52.478 + public InputStream openInputStream() throws IOException { 52.479 + throwUserExceptionIfNeeded(method, "openInputStream"); 52.480 + return super.openInputStream(); 52.481 + } 52.482 + 52.483 + @Override 52.484 + public OutputStream openOutputStream() throws IOException { 52.485 + throwUserExceptionIfNeeded(method, "openOutputStream"); 52.486 + return super.openOutputStream(); 52.487 + } 52.488 + 52.489 + @Override 52.490 + public Reader openReader(boolean ignoreEncodingErrors) throws IOException { 52.491 + throwUserExceptionIfNeeded(method, "openReader"); 52.492 + return super.openReader(ignoreEncodingErrors); 52.493 + } 52.494 + 52.495 + @Override 52.496 + public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException { 52.497 + throwUserExceptionIfNeeded(method, "getCharContent"); 52.498 + return super.getCharContent(ignoreEncodingErrors); 52.499 + } 52.500 + 52.501 + @Override 52.502 + public Writer openWriter() throws IOException { 52.503 + throwUserExceptionIfNeeded(method, "openWriter"); 52.504 + return super.openWriter(); 52.505 + } 52.506 + 52.507 + @Override 52.508 + public long getLastModified() { 52.509 + throwUserExceptionIfNeeded(method, "getLastModified"); 52.510 + return super.getLastModified(); 52.511 + } 52.512 + 52.513 + @Override 52.514 + public boolean delete() { 52.515 + throwUserExceptionIfNeeded(method, "delete"); 52.516 + return super.delete(); 52.517 + } 52.518 + 52.519 + } 52.520 + 52.521 + static class UserProcessor extends JavacTestingAbstractProcessor { 52.522 + Method method; 52.523 + 52.524 + UserProcessor(Method m) { 52.525 + assert isDeclaredIn(m, Processor.class); 52.526 + method = m; 52.527 + } 52.528 + 52.529 + @Override 52.530 + public Set<String> getSupportedOptions() { 52.531 + throwUserExceptionIfNeeded(method, "getSupportedOptions"); 52.532 + return super.getSupportedOptions(); 52.533 + } 52.534 + 52.535 + @Override 52.536 + public Set<String> getSupportedAnnotationTypes() { 52.537 + throwUserExceptionIfNeeded(method, "getSupportedAnnotationTypes"); 52.538 + return super.getSupportedAnnotationTypes(); 52.539 + } 52.540 + 52.541 + @Override 52.542 + public SourceVersion getSupportedSourceVersion() { 52.543 + throwUserExceptionIfNeeded(method, "getSupportedSourceVersion"); 52.544 + return super.getSupportedSourceVersion(); 52.545 + } 52.546 + 52.547 + @Override 52.548 + public void init(ProcessingEnvironment processingEnv) { 52.549 + throwUserExceptionIfNeeded(method, "init"); 52.550 + super.init(processingEnv); 52.551 + } 52.552 + 52.553 + @Override 52.554 + public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { 52.555 + throwUserExceptionIfNeeded(method, "process"); 52.556 + return true; 52.557 + } 52.558 + 52.559 + @Override 52.560 + public Iterable<? extends Completion> getCompletions(Element element, AnnotationMirror annotation, ExecutableElement member, String userText) { 52.561 + throwUserExceptionIfNeeded(method, "getCompletions"); 52.562 + return super.getCompletions(element, annotation, member, userText); 52.563 + } 52.564 + } 52.565 + 52.566 + static class UserDiagnosticListener implements DiagnosticListener<JavaFileObject> { 52.567 + Method method; 52.568 + PrintWriter out; 52.569 + 52.570 + UserDiagnosticListener(Method m, PrintWriter out) { 52.571 + assert isDeclaredIn(m, DiagnosticListener.class); 52.572 + this.method = m; 52.573 + this.out = out; 52.574 + } 52.575 + 52.576 + @Override 52.577 + public void report(Diagnostic<? extends JavaFileObject> diagnostic) { 52.578 + throwUserExceptionIfNeeded(method, "report"); 52.579 + out.println("report: " + diagnostic); 52.580 + } 52.581 + } 52.582 + 52.583 + static class UserTaskListener implements TaskListener { 52.584 + Method method; 52.585 + PrintWriter out; 52.586 + 52.587 + UserTaskListener(Method m, PrintWriter out) { 52.588 + assert isDeclaredIn(m, TaskListener.class); 52.589 + this.method = m; 52.590 + this.out = out; 52.591 + } 52.592 + 52.593 + @Override 52.594 + public void started(TaskEvent e) { 52.595 + throwUserExceptionIfNeeded(method, "started"); 52.596 + out.println("started: " + e); 52.597 + } 52.598 + 52.599 + @Override 52.600 + public void finished(TaskEvent e) { 52.601 + throwUserExceptionIfNeeded(method, "finished"); 52.602 + out.println("finished: " + e); 52.603 + } 52.604 + } 52.605 + 52.606 + // </editor-fold> 52.607 +}
53.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 53.2 +++ b/test/tools/javac/classreader/T7031108.java Sun Apr 10 10:25:12 2011 -0700 53.3 @@ -0,0 +1,149 @@ 53.4 +/* 53.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 53.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 53.7 + * 53.8 + * This code is free software; you can redistribute it and/or modify it 53.9 + * under the terms of the GNU General Public License version 2 only, as 53.10 + * published by the Free Software Foundation. 53.11 + * 53.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 53.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 53.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 53.15 + * version 2 for more details (a copy is included in the LICENSE file that 53.16 + * accompanied this code). 53.17 + * 53.18 + * You should have received a copy of the GNU General Public License version 53.19 + * 2 along with this work; if not, write to the Free Software Foundation, 53.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 53.21 + * 53.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 53.23 + * or visit www.oracle.com if you need additional information or have any 53.24 + * questions. 53.25 + */ 53.26 + 53.27 +/* 53.28 + * @test 53.29 + * @bug 7031108 53.30 + * @summary NPE in javac.jvm.ClassReader.findMethod in PackageElement.enclosedElements from AP in incr build 53.31 + * @library ../lib 53.32 + * @build JavacTestingAbstractProcessor T7031108 53.33 + * @run main T7031108 53.34 + */ 53.35 + 53.36 +import java.io.*; 53.37 +import java.net.*; 53.38 +import java.util.*; 53.39 +import javax.annotation.processing.*; 53.40 +import javax.lang.model.element.*; 53.41 +import javax.tools.*; 53.42 +import javax.tools.JavaCompiler.CompilationTask; 53.43 + 53.44 +public class T7031108 extends JavacTestingAbstractProcessor { 53.45 + public static void main(String... args) throws Exception { 53.46 + new T7031108().run(); 53.47 + } 53.48 + 53.49 + /* Class containing a local class definition; 53.50 + * compiled class file will have an EnclosedMethod attribute. 53.51 + */ 53.52 + static final JavaSource pC = 53.53 + new JavaSource("p/C.java", 53.54 + "package p;\n" 53.55 + + "class C {\n" 53.56 + + " void m() {\n" 53.57 + + " new Runnable() {\n" 53.58 + + " public void run() {\n" 53.59 + + " new Runnable() {\n" 53.60 + + " public void run() { }\n" 53.61 + + " };\n" 53.62 + + " }\n" 53.63 + + " };\n" 53.64 + + " }\n" 53.65 + + "}"); 53.66 + 53.67 + /* Dummy source file to compile while running anno processor. */ 53.68 + static final JavaSource dummy = 53.69 + new JavaSource("Dummy.java", 53.70 + "class Dummy { }"); 53.71 + 53.72 + void run() throws Exception { 53.73 + JavaCompiler comp = ToolProvider.getSystemJavaCompiler(); 53.74 + StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null); 53.75 + 53.76 + // step 1: compile test classes 53.77 + File cwd = new File("."); 53.78 + fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(cwd)); 53.79 + compile(comp, fm, null, null, pC); 53.80 + 53.81 + // step 2: verify functioning of processor 53.82 + fm.setLocation(StandardLocation.ANNOTATION_PROCESSOR_PATH, 53.83 + fm.getLocation(StandardLocation.CLASS_PATH)); 53.84 + fm.setLocation(StandardLocation.CLASS_PATH, Arrays.asList(cwd)); 53.85 + compile(comp, fm, null, getClass().getName(), dummy); 53.86 + 53.87 + File pC_class = new File(new File("p"), "C.class"); 53.88 + pC_class.delete(); 53.89 + 53.90 + DiagnosticCollector<JavaFileObject> dc = new DiagnosticCollector<JavaFileObject>(); 53.91 + compile(comp, fm, dc, getClass().getName(), dummy); 53.92 + List<Diagnostic<? extends JavaFileObject>> diags =dc.getDiagnostics(); 53.93 + 53.94 + System.err.println(diags); 53.95 + switch (diags.size()) { 53.96 + case 0: 53.97 + throw new Exception("no diagnostics received"); 53.98 + case 1: 53.99 + String code = diags.get(0).getCode(); 53.100 + String expect = "compiler.err.proc.cant.access.1"; 53.101 + if (!expect.equals(code)) 53.102 + throw new Exception("unexpected diag code: " + code 53.103 + + ", expected: " + expect); 53.104 + break; 53.105 + default: 53.106 + throw new Exception("unexpected diags received"); 53.107 + } 53.108 + } 53.109 + 53.110 + void compile(JavaCompiler comp, JavaFileManager fm, 53.111 + DiagnosticListener<JavaFileObject> dl, 53.112 + String processor, JavaFileObject... files) throws Exception { 53.113 + System.err.println("compile processor:" + processor + ", files:" + Arrays.asList(files)); 53.114 + List<String> opts = new ArrayList<String>(); 53.115 + if (processor != null) { 53.116 + // opts.add("-verbose"); 53.117 + opts.addAll(Arrays.asList("-processor", processor)); 53.118 + } 53.119 + CompilationTask task = comp.getTask(null, fm, dl, opts, null, Arrays.asList(files)); 53.120 + boolean ok = task.call(); 53.121 + if (dl == null && !ok) 53.122 + throw new Exception("compilation failed"); 53.123 + } 53.124 + 53.125 + static class JavaSource extends SimpleJavaFileObject { 53.126 + JavaSource(String name, String text) { 53.127 + super(URI.create("js://" + name), JavaFileObject.Kind.SOURCE); 53.128 + this.text = text; 53.129 + } 53.130 + @Override 53.131 + public CharSequence getCharContent(boolean ignoreEncodingErrors) { 53.132 + return text; 53.133 + } 53.134 + final String text; 53.135 + } 53.136 + 53.137 + // annotation processor method 53.138 + 53.139 + @Override 53.140 + public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { 53.141 + if (!roundEnv.processingOver()) { 53.142 + PackageElement p = elements.getPackageElement("p"); 53.143 + List<? extends Element> elems = p.getEnclosedElements(); 53.144 + System.err.println("contents of package p: " + elems); 53.145 + if (elems.size() != 1 || !elems.get(0).getSimpleName().contentEquals("C")) { 53.146 + messager.printMessage(Diagnostic.Kind.ERROR, "unexpected package contents"); 53.147 + } 53.148 + } 53.149 + return true; 53.150 + } 53.151 +} 53.152 +
54.1 --- a/test/tools/javac/diags/examples.not-yet.txt Thu Apr 07 15:21:22 2011 -0700 54.2 +++ b/test/tools/javac/diags/examples.not-yet.txt Sun Apr 10 10:25:12 2011 -0700 54.3 @@ -27,6 +27,7 @@ 54.4 compiler.err.prob.found.req.1 # Check: DEAD, in unused method 54.5 compiler.err.proc.bad.config.file # JavacProcessingEnvironment 54.6 compiler.err.proc.cant.access # completion failure 54.7 +compiler.err.proc.cant.access.1 # completion failure, no stack trace 54.8 compiler.err.proc.cant.create.loader # security exception from service loader 54.9 compiler.err.proc.no.service # JavacProcessingEnvironment: no service loader available 54.10 compiler.err.proc.processor.bad.option.name # cannot happen? masked by javac.err.invalid.A.key 54.11 @@ -49,6 +50,7 @@ 54.12 compiler.misc.bad.class.signature # bad class file 54.13 compiler.misc.bad.const.pool.tag # bad class file 54.14 compiler.misc.bad.const.pool.tag.at # bad class file 54.15 +compiler.misc.bad.enclosing.class # bad class file 54.16 compiler.misc.bad.enclosing.method # bad class file 54.17 compiler.misc.bad.runtime.invisible.param.annotations # bad class file 54.18 compiler.misc.bad.signature # bad class file
55.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 55.2 +++ b/test/tools/javac/diags/examples/MulticatchTypesMustBeDisjoint.java Sun Apr 10 10:25:12 2011 -0700 55.3 @@ -0,0 +1,39 @@ 55.4 +/* 55.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 55.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 55.7 + * 55.8 + * This code is free software; you can redistribute it and/or modify it 55.9 + * under the terms of the GNU General Public License version 2 only, as 55.10 + * published by the Free Software Foundation. 55.11 + * 55.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 55.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 55.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 55.15 + * version 2 for more details (a copy is included in the LICENSE file that 55.16 + * accompanied this code). 55.17 + * 55.18 + * You should have received a copy of the GNU General Public License version 55.19 + * 2 along with this work; if not, write to the Free Software Foundation, 55.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 55.21 + * 55.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 55.23 + * or visit www.oracle.com if you need additional information or have any 55.24 + * questions. 55.25 + */ 55.26 + 55.27 +// key: compiler.err.multicatch.types.must.be.disjoint 55.28 + 55.29 +class MulticatchTypesMustBeDisjoint { 55.30 + class E1 extends Exception { } 55.31 + class E2 extends E1 { } 55.32 + 55.33 + void e1() throws E1 { } 55.34 + void e2() throws E2 { } 55.35 + 55.36 + void m() { 55.37 + try { 55.38 + e1(); 55.39 + e2(); 55.40 + } catch (E1 | E2 e) { } 55.41 + } 55.42 +}
56.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 56.2 +++ b/test/tools/javac/diags/examples/TryResourceThrowsInterruptedExc.java Sun Apr 10 10:25:12 2011 -0700 56.3 @@ -0,0 +1,29 @@ 56.4 +/* 56.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 56.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 56.7 + * 56.8 + * This code is free software; you can redistribute it and/or modify it 56.9 + * under the terms of the GNU General Public License version 2 only, as 56.10 + * published by the Free Software Foundation. 56.11 + * 56.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 56.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 56.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 56.15 + * version 2 for more details (a copy is included in the LICENSE file that 56.16 + * accompanied this code). 56.17 + * 56.18 + * You should have received a copy of the GNU General Public License version 56.19 + * 2 along with this work; if not, write to the Free Software Foundation, 56.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 56.21 + * 56.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 56.23 + * or visit www.oracle.com if you need additional information or have any 56.24 + * questions. 56.25 + */ 56.26 + 56.27 +// key: compiler.warn.try.resource.throws.interrupted.exc 56.28 +// options: -Xlint:try 56.29 + 56.30 +class TryResourceThrowsInterruptedException implements AutoCloseable { 56.31 + public void close() throws InterruptedException {} 56.32 +}
57.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 57.2 +++ b/test/tools/javac/generics/diamond/7030150/GenericConstructorAndDiamondTest.java Sun Apr 10 10:25:12 2011 -0700 57.3 @@ -0,0 +1,252 @@ 57.4 +/* 57.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 57.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 57.7 + * 57.8 + * This code is free software; you can redistribute it and/or modify it 57.9 + * under the terms of the GNU General Public License version 2 only, as 57.10 + * published by the Free Software Foundation. 57.11 + * 57.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 57.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 57.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 57.15 + * version 2 for more details (a copy is included in the LICENSE file that 57.16 + * accompanied this code). 57.17 + * 57.18 + * You should have received a copy of the GNU General Public License version 57.19 + * 2 along with this work; if not, write to the Free Software Foundation, 57.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 57.21 + * 57.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 57.23 + * or visit www.oracle.com if you need additional information or have any 57.24 + * questions. 57.25 + */ 57.26 + 57.27 +/* 57.28 + * @test 57.29 + * @bug 7030150 57.30 + * @summary Type inference for generic instance creation failed for formal type parameter 57.31 + */ 57.32 + 57.33 +import com.sun.source.util.JavacTask; 57.34 +import java.net.URI; 57.35 +import java.util.Arrays; 57.36 +import javax.tools.Diagnostic; 57.37 +import javax.tools.JavaCompiler; 57.38 +import javax.tools.JavaFileObject; 57.39 +import javax.tools.SimpleJavaFileObject; 57.40 +import javax.tools.StandardJavaFileManager; 57.41 +import javax.tools.ToolProvider; 57.42 + 57.43 +public class GenericConstructorAndDiamondTest { 57.44 + 57.45 + enum BoundKind { 57.46 + NO_BOUND(""), 57.47 + STRING_BOUND("extends String"), 57.48 + INTEGER_BOUND("extends Integer"); 57.49 + 57.50 + String boundStr; 57.51 + 57.52 + private BoundKind(String boundStr) { 57.53 + this.boundStr = boundStr; 57.54 + } 57.55 + 57.56 + boolean matches(TypeArgumentKind tak) { 57.57 + switch (tak) { 57.58 + case NONE: return true; 57.59 + case STRING: return this != INTEGER_BOUND; 57.60 + case INTEGER: return this != STRING_BOUND; 57.61 + default: return false; 57.62 + } 57.63 + } 57.64 + } 57.65 + 57.66 + enum ConstructorKind { 57.67 + NON_GENERIC("Foo(Object o) {}"), 57.68 + GENERIC_NO_BOUND("<T> Foo(T t) {}"), 57.69 + GENERIC_STRING_BOUND("<T extends String> Foo(T t) {}"), 57.70 + GENERIC_INTEGER_BOUND("<T extends Integer> Foo(T t) {}"); 57.71 + 57.72 + String constrStr; 57.73 + 57.74 + private ConstructorKind(String constrStr) { 57.75 + this.constrStr = constrStr; 57.76 + } 57.77 + 57.78 + boolean matches(ArgumentKind ak) { 57.79 + switch (ak) { 57.80 + case STRING: return this != GENERIC_INTEGER_BOUND; 57.81 + case INTEGER: return this != GENERIC_STRING_BOUND; 57.82 + default: return false; 57.83 + } 57.84 + } 57.85 + } 57.86 + 57.87 + enum TypeArgArity { 57.88 + ONE(1), 57.89 + TWO(2), 57.90 + THREE(3); 57.91 + 57.92 + int n; 57.93 + 57.94 + private TypeArgArity(int n) { 57.95 + this.n = n; 57.96 + } 57.97 + } 57.98 + 57.99 + enum TypeArgumentKind { 57.100 + NONE(""), 57.101 + STRING("String"), 57.102 + INTEGER("Integer"); 57.103 + 57.104 + String typeargStr; 57.105 + 57.106 + private TypeArgumentKind(String typeargStr) { 57.107 + this.typeargStr = typeargStr; 57.108 + } 57.109 + 57.110 + String getArgs(TypeArgArity arity) { 57.111 + if (this == NONE) return ""; 57.112 + else { 57.113 + StringBuilder buf = new StringBuilder(); 57.114 + String sep = ""; 57.115 + for (int i = 0 ; i < arity.n ; i++) { 57.116 + buf.append(sep); 57.117 + buf.append(typeargStr); 57.118 + sep = ","; 57.119 + } 57.120 + return "<" + buf.toString() + ">"; 57.121 + } 57.122 + } 57.123 + 57.124 + boolean matches(ArgumentKind ak) { 57.125 + switch (ak) { 57.126 + case STRING: return this != INTEGER; 57.127 + case INTEGER: return this != STRING; 57.128 + default: return false; 57.129 + } 57.130 + } 57.131 + } 57.132 + 57.133 + enum ArgumentKind { 57.134 + STRING("\"\""), 57.135 + INTEGER("1"); 57.136 + 57.137 + String argStr; 57.138 + 57.139 + private ArgumentKind(String argStr) { 57.140 + this.argStr = argStr; 57.141 + } 57.142 + } 57.143 + 57.144 + public static void main(String... args) throws Exception { 57.145 + 57.146 + //create default shared JavaCompiler - reused across multiple compilations 57.147 + JavaCompiler comp = ToolProvider.getSystemJavaCompiler(); 57.148 + StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null); 57.149 + 57.150 + for (BoundKind boundKind : BoundKind.values()) { 57.151 + for (ConstructorKind constructorKind : ConstructorKind.values()) { 57.152 + for (TypeArgumentKind declArgKind : TypeArgumentKind.values()) { 57.153 + for (TypeArgArity arity : TypeArgArity.values()) { 57.154 + for (TypeArgumentKind useArgKind : TypeArgumentKind.values()) { 57.155 + for (ArgumentKind argKind : ArgumentKind.values()) { 57.156 + new GenericConstructorAndDiamondTest(boundKind, constructorKind, 57.157 + declArgKind, arity, useArgKind, argKind).run(comp, fm); 57.158 + } 57.159 + } 57.160 + } 57.161 + } 57.162 + } 57.163 + } 57.164 + } 57.165 + 57.166 + BoundKind boundKind; 57.167 + ConstructorKind constructorKind; 57.168 + TypeArgumentKind declTypeArgumentKind; 57.169 + TypeArgArity useTypeArgArity; 57.170 + TypeArgumentKind useTypeArgumentKind; 57.171 + ArgumentKind argumentKind; 57.172 + JavaSource source; 57.173 + DiagnosticChecker diagChecker; 57.174 + 57.175 + GenericConstructorAndDiamondTest(BoundKind boundKind, ConstructorKind constructorKind, 57.176 + TypeArgumentKind declTypeArgumentKind, TypeArgArity useTypeArgArity, 57.177 + TypeArgumentKind useTypeArgumentKind, ArgumentKind argumentKind) { 57.178 + this.boundKind = boundKind; 57.179 + this.constructorKind = constructorKind; 57.180 + this.declTypeArgumentKind = declTypeArgumentKind; 57.181 + this.useTypeArgArity = useTypeArgArity; 57.182 + this.useTypeArgumentKind = useTypeArgumentKind; 57.183 + this.argumentKind = argumentKind; 57.184 + this.source = new JavaSource(); 57.185 + this.diagChecker = new DiagnosticChecker(); 57.186 + } 57.187 + 57.188 + class JavaSource extends SimpleJavaFileObject { 57.189 + 57.190 + String template = "class Foo<X #BK> {\n" + 57.191 + "#CK\n" + 57.192 + "}\n" + 57.193 + "class Test {\n" + 57.194 + "void test() {\n" + 57.195 + "Foo#TA1 f = new #TA2 Foo<>(#A);\n" + 57.196 + "}\n" + 57.197 + "}\n"; 57.198 + 57.199 + String source; 57.200 + 57.201 + public JavaSource() { 57.202 + super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE); 57.203 + source = template.replace("#BK", boundKind.boundStr). 57.204 + replace("#CK", constructorKind.constrStr) 57.205 + .replace("#TA1", declTypeArgumentKind.getArgs(TypeArgArity.ONE)) 57.206 + .replace("#TA2", useTypeArgumentKind.getArgs(useTypeArgArity)) 57.207 + .replace("#A", argumentKind.argStr); 57.208 + } 57.209 + 57.210 + @Override 57.211 + public CharSequence getCharContent(boolean ignoreEncodingErrors) { 57.212 + return source; 57.213 + } 57.214 + } 57.215 + 57.216 + void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception { 57.217 + JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker, 57.218 + null, null, Arrays.asList(source)); 57.219 + ct.analyze(); 57.220 + check(); 57.221 + } 57.222 + 57.223 + void check() { 57.224 + boolean badActual = !constructorKind.matches(argumentKind); 57.225 + 57.226 + boolean badArity = constructorKind != ConstructorKind.NON_GENERIC && 57.227 + useTypeArgumentKind != TypeArgumentKind.NONE && 57.228 + useTypeArgArity != TypeArgArity.ONE; 57.229 + 57.230 + boolean badMethodTypeArg = constructorKind != ConstructorKind.NON_GENERIC && 57.231 + !useTypeArgumentKind.matches(argumentKind); 57.232 + 57.233 + boolean badGenericType = !boundKind.matches(declTypeArgumentKind); 57.234 + 57.235 + boolean shouldFail = badActual || badArity || badMethodTypeArg || badGenericType; 57.236 + 57.237 + if (shouldFail != diagChecker.errorFound) { 57.238 + throw new Error("invalid diagnostics for source:\n" + 57.239 + source.getCharContent(true) + 57.240 + "\nFound error: " + diagChecker.errorFound + 57.241 + "\nExpected error: " + shouldFail); 57.242 + } 57.243 + } 57.244 + 57.245 + static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> { 57.246 + 57.247 + boolean errorFound; 57.248 + 57.249 + public void report(Diagnostic<? extends JavaFileObject> diagnostic) { 57.250 + if (diagnostic.getKind() == Diagnostic.Kind.ERROR) { 57.251 + errorFound = true; 57.252 + } 57.253 + } 57.254 + } 57.255 +}
58.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 58.2 +++ b/test/tools/javac/generics/diamond/7030150/Neg01.java Sun Apr 10 10:25:12 2011 -0700 58.3 @@ -0,0 +1,17 @@ 58.4 +/* 58.5 + * @test /nodynamiccopyright/ 58.6 + * @bug 7030150 58.7 + * @summary Type inference for generic instance creation failed for formal type parameter 58.8 + * check that explicit type-argument that causes resolution failure is rejected 58.9 + * @compile/fail/ref=Neg01.out -XDrawDiagnostics Neg01.java 58.10 + */ 58.11 + 58.12 +class Neg01 { 58.13 + 58.14 + static class Foo<X> { 58.15 + <T> Foo(T t) {} 58.16 + } 58.17 + 58.18 + Foo<Integer> fi1 = new <String> Foo<>(1); 58.19 + Foo<Integer> fi2 = new <String> Foo<Integer>(1); 58.20 +}
59.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 59.2 +++ b/test/tools/javac/generics/diamond/7030150/Neg01.out Sun Apr 10 10:25:12 2011 -0700 59.3 @@ -0,0 +1,3 @@ 59.4 +Neg01.java:15:24: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg01.Foo), (compiler.misc.infer.no.conforming.assignment.exists: X, int, java.lang.String) 59.5 +Neg01.java:16:24: compiler.err.cant.apply.symbol.1: kindname.constructor, Foo, T, int, kindname.class, Neg01.Foo<X>, (compiler.misc.no.conforming.assignment.exists: int, java.lang.String) 59.6 +2 errors
60.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 60.2 +++ b/test/tools/javac/generics/diamond/7030150/Neg02.java Sun Apr 10 10:25:12 2011 -0700 60.3 @@ -0,0 +1,17 @@ 60.4 +/* 60.5 + * @test /nodynamiccopyright/ 60.6 + * @bug 7030150 60.7 + * @summary Type inference for generic instance creation failed for formal type parameter 60.8 + * check that compiler rejects bad number of explicit type-arguments 60.9 + * @compile/fail/ref=Neg02.out -XDrawDiagnostics Neg02.java 60.10 + */ 60.11 + 60.12 +class Neg02 { 60.13 + 60.14 + static class Foo<X> { 60.15 + <T> Foo(T t) {} 60.16 + } 60.17 + 60.18 + Foo<Integer> fi1 = new <String, Integer> Foo<>(""); 60.19 + Foo<Integer> fi2 = new <String, Integer> Foo<Integer>(""); 60.20 +}
61.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 61.2 +++ b/test/tools/javac/generics/diamond/7030150/Neg02.out Sun Apr 10 10:25:12 2011 -0700 61.3 @@ -0,0 +1,3 @@ 61.4 +Neg02.java:15:24: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg02.Foo), (compiler.misc.arg.length.mismatch) 61.5 +Neg02.java:16:24: compiler.err.cant.apply.symbol.1: kindname.constructor, Foo, T, java.lang.String, kindname.class, Neg02.Foo<X>, (compiler.misc.arg.length.mismatch) 61.6 +2 errors
62.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 62.2 +++ b/test/tools/javac/generics/diamond/7030150/Neg03.java Sun Apr 10 10:25:12 2011 -0700 62.3 @@ -0,0 +1,17 @@ 62.4 +/* 62.5 + * @test /nodynamiccopyright/ 62.6 + * @bug 7030150 62.7 + * @summary Type inference for generic instance creation failed for formal type parameter 62.8 + * check that explicit type-argument that does not conform to bound is rejected 62.9 + * @compile/fail/ref=Neg03.out -XDrawDiagnostics Neg03.java 62.10 + */ 62.11 + 62.12 +class Neg03 { 62.13 + 62.14 + static class Foo<X> { 62.15 + <T extends Integer> Foo(T t) {} 62.16 + } 62.17 + 62.18 + Foo<Integer> fi1 = new <String> Foo<>(1); 62.19 + Foo<Integer> fi2 = new <String> Foo<Integer>(1); 62.20 +}
63.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 63.2 +++ b/test/tools/javac/generics/diamond/7030150/Neg03.out Sun Apr 10 10:25:12 2011 -0700 63.3 @@ -0,0 +1,3 @@ 63.4 +Neg03.java:15:24: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg03.Foo), (compiler.misc.explicit.param.do.not.conform.to.bounds: java.lang.String, java.lang.Integer) 63.5 +Neg03.java:16:24: compiler.err.cant.apply.symbol.1: kindname.constructor, Foo, T, int, kindname.class, Neg03.Foo<X>, (compiler.misc.explicit.param.do.not.conform.to.bounds: java.lang.String, java.lang.Integer) 63.6 +2 errors
64.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 64.2 +++ b/test/tools/javac/generics/diamond/7030150/Pos01.java Sun Apr 10 10:25:12 2011 -0700 64.3 @@ -0,0 +1,44 @@ 64.4 +/* 64.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 64.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 64.7 + * 64.8 + * This code is free software; you can redistribute it and/or modify it 64.9 + * under the terms of the GNU General Public License version 2 only, as 64.10 + * published by the Free Software Foundation. 64.11 + * 64.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 64.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 64.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 64.15 + * version 2 for more details (a copy is included in the LICENSE file that 64.16 + * accompanied this code). 64.17 + * 64.18 + * You should have received a copy of the GNU General Public License version 64.19 + * 2 along with this work; if not, write to the Free Software Foundation, 64.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 64.21 + * 64.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 64.23 + * or visit www.oracle.com if you need additional information or have any 64.24 + * questions. 64.25 + */ 64.26 + 64.27 +/* 64.28 + * @test 64.29 + * @bug 7030150 64.30 + * @summary Type inference for generic instance creation failed for formal type parameter 64.31 + * check that redundant type-arguments on non-generic constructor are accepted 64.32 + * @compile Pos01.java 64.33 + */ 64.34 + 64.35 +class Pos01 { 64.36 + 64.37 + static class Foo<X> { 64.38 + Foo(X t) {} 64.39 + } 64.40 + 64.41 + Foo<Integer> fi1 = new Foo<>(1); 64.42 + Foo<Integer> fi2 = new Foo<Integer>(1); 64.43 + Foo<Integer> fi3 = new <String> Foo<>(1); 64.44 + Foo<Integer> fi4 = new <String> Foo<Integer>(1); 64.45 + Foo<Integer> fi5 = new <String, String> Foo<>(1); 64.46 + Foo<Integer> fi6 = new <String, String> Foo<Integer>(1); 64.47 +}
65.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 65.2 +++ b/test/tools/javac/generics/diamond/7030150/Pos02.java Sun Apr 10 10:25:12 2011 -0700 65.3 @@ -0,0 +1,40 @@ 65.4 +/* 65.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 65.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 65.7 + * 65.8 + * This code is free software; you can redistribute it and/or modify it 65.9 + * under the terms of the GNU General Public License version 2 only, as 65.10 + * published by the Free Software Foundation. 65.11 + * 65.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 65.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 65.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 65.15 + * version 2 for more details (a copy is included in the LICENSE file that 65.16 + * accompanied this code). 65.17 + * 65.18 + * You should have received a copy of the GNU General Public License version 65.19 + * 2 along with this work; if not, write to the Free Software Foundation, 65.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 65.21 + * 65.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 65.23 + * or visit www.oracle.com if you need additional information or have any 65.24 + * questions. 65.25 + */ 65.26 + 65.27 +/* 65.28 + * @test 65.29 + * @bug 7030150 65.30 + * @summary Type inference for generic instance creation failed for formal type parameter 65.31 + * check that diamond in return context works w/o problems 65.32 + * @compile Pos02.java 65.33 + */ 65.34 + 65.35 +class Pos02<X> { 65.36 + 65.37 + Pos02(X x) {} 65.38 + 65.39 + 65.40 + Pos02<X> test(X x) { 65.41 + return new Pos02<>(x); 65.42 + } 65.43 +}
66.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 66.2 +++ b/test/tools/javac/generics/diamond/7030687/ParserTest.java Sun Apr 10 10:25:12 2011 -0700 66.3 @@ -0,0 +1,175 @@ 66.4 +/* 66.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 66.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 66.7 + * 66.8 + * This code is free software; you can redistribute it and/or modify it 66.9 + * under the terms of the GNU General Public License version 2 only, as 66.10 + * published by the Free Software Foundation. 66.11 + * 66.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 66.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 66.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 66.15 + * version 2 for more details (a copy is included in the LICENSE file that 66.16 + * accompanied this code). 66.17 + * 66.18 + * You should have received a copy of the GNU General Public License version 66.19 + * 2 along with this work; if not, write to the Free Software Foundation, 66.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 66.21 + * 66.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 66.23 + * or visit www.oracle.com if you need additional information or have any 66.24 + * questions. 66.25 + */ 66.26 + 66.27 +/* 66.28 + * @test 66.29 + * @bug 7030687 66.30 + * @summary Diamond: compiler accepts erroneous code where diamond is used with non-generic inner class 66.31 + */ 66.32 + 66.33 +import com.sun.source.util.JavacTask; 66.34 +import java.net.URI; 66.35 +import java.util.Arrays; 66.36 +import javax.tools.Diagnostic; 66.37 +import javax.tools.JavaCompiler; 66.38 +import javax.tools.JavaFileObject; 66.39 +import javax.tools.SimpleJavaFileObject; 66.40 +import javax.tools.StandardJavaFileManager; 66.41 +import javax.tools.ToolProvider; 66.42 + 66.43 +public class ParserTest { 66.44 + 66.45 + enum TypeArgumentKind { 66.46 + NONE(""), 66.47 + EXPLICIT("<String>"), 66.48 + DIAMOND("<>"); 66.49 + 66.50 + String typeargStr; 66.51 + 66.52 + private TypeArgumentKind(String typeargStr) { 66.53 + this.typeargStr = typeargStr; 66.54 + } 66.55 + } 66.56 + 66.57 + enum TypeQualifierArity { 66.58 + ONE(1, "A1#TA1"), 66.59 + TWO(2, "A1#TA1.A2#TA2"), 66.60 + THREE(3, "A1#TA1.A2#TA2.A3#TA3"), 66.61 + FOUR(4, "A1#TA1.A2#TA2.A3#TA3.A4#TA4"); 66.62 + 66.63 + int n; 66.64 + String qualifierStr; 66.65 + 66.66 + private TypeQualifierArity(int n, String qualifierStr) { 66.67 + this.n = n; 66.68 + this.qualifierStr = qualifierStr; 66.69 + } 66.70 + 66.71 + String getType(TypeArgumentKind... typeArgumentKinds) { 66.72 + String res = qualifierStr; 66.73 + for (int i = 1 ; i <= typeArgumentKinds.length ; i++) { 66.74 + res = res.replace("#TA" + i, typeArgumentKinds[i-1].typeargStr); 66.75 + } 66.76 + return res; 66.77 + } 66.78 + } 66.79 + 66.80 + public static void main(String... args) throws Exception { 66.81 + 66.82 + //create default shared JavaCompiler - reused across multiple compilations 66.83 + JavaCompiler comp = ToolProvider.getSystemJavaCompiler(); 66.84 + StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null); 66.85 + 66.86 + for (TypeQualifierArity arity : TypeQualifierArity.values()) { 66.87 + for (TypeArgumentKind tak1 : TypeArgumentKind.values()) { 66.88 + if (arity == TypeQualifierArity.ONE) { 66.89 + new ParserTest(arity, tak1).run(comp, fm); 66.90 + continue; 66.91 + } 66.92 + for (TypeArgumentKind tak2 : TypeArgumentKind.values()) { 66.93 + if (arity == TypeQualifierArity.TWO) { 66.94 + new ParserTest(arity, tak1, tak2).run(comp, fm); 66.95 + continue; 66.96 + } 66.97 + for (TypeArgumentKind tak3 : TypeArgumentKind.values()) { 66.98 + if (arity == TypeQualifierArity.THREE) { 66.99 + new ParserTest(arity, tak1, tak2, tak3).run(comp, fm); 66.100 + continue; 66.101 + } 66.102 + for (TypeArgumentKind tak4 : TypeArgumentKind.values()) { 66.103 + new ParserTest(arity, tak1, tak2, tak3, tak4).run(comp, fm); 66.104 + } 66.105 + } 66.106 + } 66.107 + } 66.108 + } 66.109 + } 66.110 + 66.111 + TypeQualifierArity qualifierArity; 66.112 + TypeArgumentKind[] typeArgumentKinds; 66.113 + JavaSource source; 66.114 + DiagnosticChecker diagChecker; 66.115 + 66.116 + ParserTest(TypeQualifierArity qualifierArity, TypeArgumentKind... typeArgumentKinds) { 66.117 + this.qualifierArity = qualifierArity; 66.118 + this.typeArgumentKinds = typeArgumentKinds; 66.119 + this.source = new JavaSource(); 66.120 + this.diagChecker = new DiagnosticChecker(); 66.121 + } 66.122 + 66.123 + class JavaSource extends SimpleJavaFileObject { 66.124 + 66.125 + String template = "class Test {\n" + 66.126 + "R res = new #T();\n" + 66.127 + "}\n"; 66.128 + 66.129 + String source; 66.130 + 66.131 + public JavaSource() { 66.132 + super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE); 66.133 + source = template.replace("#T", qualifierArity.getType(typeArgumentKinds)); 66.134 + } 66.135 + 66.136 + @Override 66.137 + public CharSequence getCharContent(boolean ignoreEncodingErrors) { 66.138 + return source; 66.139 + } 66.140 + } 66.141 + 66.142 + void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception { 66.143 + JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker, 66.144 + null, null, Arrays.asList(source)); 66.145 + ct.parse(); 66.146 + check(); 66.147 + } 66.148 + 66.149 + void check() { 66.150 + 66.151 + boolean errorExpected = false; 66.152 + 66.153 + for (int i = 0 ; i < qualifierArity.n - 1 ; i++) { 66.154 + if (typeArgumentKinds[i] == TypeArgumentKind.DIAMOND) { 66.155 + errorExpected = true; 66.156 + break; 66.157 + } 66.158 + } 66.159 + 66.160 + if (errorExpected != diagChecker.errorFound) { 66.161 + throw new Error("invalid diagnostics for source:\n" + 66.162 + source.getCharContent(true) + 66.163 + "\nFound error: " + diagChecker.errorFound + 66.164 + "\nExpected error: " + errorExpected); 66.165 + } 66.166 + } 66.167 + 66.168 + static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> { 66.169 + 66.170 + boolean errorFound; 66.171 + 66.172 + public void report(Diagnostic<? extends JavaFileObject> diagnostic) { 66.173 + if (diagnostic.getKind() == Diagnostic.Kind.ERROR) { 66.174 + errorFound = true; 66.175 + } 66.176 + } 66.177 + } 66.178 +}
67.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 67.2 +++ b/test/tools/javac/generics/diamond/7030687/T7030687.java Sun Apr 10 10:25:12 2011 -0700 67.3 @@ -0,0 +1,19 @@ 67.4 +/* 67.5 + * @test /nodynamiccopyright/ 67.6 + * @bug 7030687 67.7 + * @summary Diamond: compiler accepts erroneous code where diamond is used with non-generic inner class 67.8 + * @compile/fail/ref=T7030687.out -XDrawDiagnostics T7030687.java 67.9 + */ 67.10 + 67.11 +class T7030687<X> { 67.12 + class Member { } 67.13 + static class Nested {} 67.14 + 67.15 + void test() { 67.16 + class Local {} 67.17 + 67.18 + Member m = new Member<>(); 67.19 + Nested n = new Nested<>(); 67.20 + Local l = new Local<>(); 67.21 + } 67.22 +}
68.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 68.2 +++ b/test/tools/javac/generics/diamond/7030687/T7030687.out Sun Apr 10 10:25:12 2011 -0700 68.3 @@ -0,0 +1,4 @@ 68.4 +T7030687.java:15:30: compiler.err.cant.apply.diamond.1: T7030687<X>.Member, (compiler.misc.diamond.non.generic: T7030687<X>.Member) 68.5 +T7030687.java:16:30: compiler.err.cant.apply.diamond.1: T7030687.Nested, (compiler.misc.diamond.non.generic: T7030687.Nested) 68.6 +T7030687.java:17:28: compiler.err.cant.apply.diamond.1: Local, (compiler.misc.diamond.non.generic: Local) 68.7 +3 errors
69.1 --- a/test/tools/javac/meth/InvokeMH.java Thu Apr 07 15:21:22 2011 -0700 69.2 +++ b/test/tools/javac/meth/InvokeMH.java Sun Apr 10 10:25:12 2011 -0700 69.3 @@ -42,7 +42,7 @@ 69.4 69.5 package meth; 69.6 69.7 -import java.dyn.MethodHandle; 69.8 +import java.lang.invoke.MethodHandle; 69.9 69.10 public class InvokeMH { 69.11 void test(MethodHandle mh_SiO,
70.1 --- a/test/tools/javac/meth/TestCP.java Thu Apr 07 15:21:22 2011 -0700 70.2 +++ b/test/tools/javac/meth/TestCP.java Sun Apr 10 10:25:12 2011 -0700 70.3 @@ -35,7 +35,7 @@ 70.4 import com.sun.tools.classfile.ConstantPool.*; 70.5 import com.sun.tools.classfile.Method; 70.6 70.7 -import java.dyn.*; 70.8 +import java.lang.invoke.*; 70.9 import java.io.*; 70.10 70.11 public class TestCP {
71.1 --- a/test/tools/javac/meth/XlintWarn.java Thu Apr 07 15:21:22 2011 -0700 71.2 +++ b/test/tools/javac/meth/XlintWarn.java Sun Apr 10 10:25:12 2011 -0700 71.3 @@ -30,7 +30,7 @@ 71.4 * @compile -Werror -Xlint:cast XlintWarn.java 71.5 */ 71.6 71.7 -import java.dyn.*; 71.8 +import java.lang.invoke.*; 71.9 71.10 class XlintWarn { 71.11 void test(MethodHandle mh) throws Throwable {
72.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 72.2 +++ b/test/tools/javac/multicatch/7030606/DisjunctiveTypeWellFormednessTest.java Sun Apr 10 10:25:12 2011 -0700 72.3 @@ -0,0 +1,205 @@ 72.4 +/* 72.5 + * Copyright (c) 2011, 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 + * @bug 7030606 72.30 + * @summary Project-coin: multi-catch types should be pairwise disjoint 72.31 + */ 72.32 + 72.33 +import com.sun.source.util.JavacTask; 72.34 +import java.net.URI; 72.35 +import java.util.Arrays; 72.36 +import javax.tools.Diagnostic; 72.37 +import javax.tools.JavaCompiler; 72.38 +import javax.tools.JavaFileObject; 72.39 +import javax.tools.SimpleJavaFileObject; 72.40 +import javax.tools.StandardJavaFileManager; 72.41 +import javax.tools.ToolProvider; 72.42 + 72.43 +public class DisjunctiveTypeWellFormednessTest { 72.44 + 72.45 + enum Alternative { 72.46 + EXCEPTION("Exception"), 72.47 + RUNTIME_EXCEPTION("RuntimeException"), 72.48 + IO_EXCEPTION("java.io.IOException"), 72.49 + FILE_NOT_FOUND_EXCEPTION("java.io.FileNotFoundException"), 72.50 + ILLEGAL_ARGUMENT_EXCEPTION("IllegalArgumentException"); 72.51 + 72.52 + String exceptionStr; 72.53 + 72.54 + private Alternative(String exceptionStr) { 72.55 + this.exceptionStr = exceptionStr; 72.56 + } 72.57 + 72.58 + static String makeDisjunctiveType(Alternative... alternatives) { 72.59 + StringBuilder buf = new StringBuilder(); 72.60 + String sep = ""; 72.61 + for (Alternative alternative : alternatives) { 72.62 + buf.append(sep); 72.63 + buf.append(alternative.exceptionStr); 72.64 + sep = "|"; 72.65 + } 72.66 + return buf.toString(); 72.67 + } 72.68 + 72.69 + boolean disjoint(Alternative that) { 72.70 + return disjoint[this.ordinal()][that.ordinal()]; 72.71 + } 72.72 + 72.73 + static boolean[][] disjoint = { 72.74 + // Exception RuntimeException IOException FileNotFoundException IllegalArgumentException 72.75 + /*Exception*/ { false, false, false, false, false }, 72.76 + /*RuntimeException*/ { false, false, true, true, false }, 72.77 + /*IOException*/ { false, true, false, false, true }, 72.78 + /*FileNotFoundException*/ { false, true, false, false, true }, 72.79 + /*IllegalArgumentException*/ { false, false, true, true, false } 72.80 + }; 72.81 + } 72.82 + 72.83 + enum Arity { 72.84 + ONE(1), 72.85 + TWO(2), 72.86 + THREE(3), 72.87 + FOUR(4), 72.88 + FIVE(5); 72.89 + 72.90 + int n; 72.91 + 72.92 + private Arity(int n) { 72.93 + this.n = n; 72.94 + } 72.95 + } 72.96 + 72.97 + public static void main(String... args) throws Exception { 72.98 + 72.99 + //create default shared JavaCompiler - reused across multiple compilations 72.100 + JavaCompiler comp = ToolProvider.getSystemJavaCompiler(); 72.101 + StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null); 72.102 + 72.103 + for (Arity arity : Arity.values()) { 72.104 + for (Alternative a1 : Alternative.values()) { 72.105 + if (arity == Arity.ONE) { 72.106 + new DisjunctiveTypeWellFormednessTest(a1).run(comp, fm); 72.107 + continue; 72.108 + } 72.109 + for (Alternative a2 : Alternative.values()) { 72.110 + if (arity == Arity.TWO) { 72.111 + new DisjunctiveTypeWellFormednessTest(a1, a2).run(comp, fm); 72.112 + continue; 72.113 + } 72.114 + for (Alternative a3 : Alternative.values()) { 72.115 + if (arity == Arity.THREE) { 72.116 + new DisjunctiveTypeWellFormednessTest(a1, a2, a3).run(comp, fm); 72.117 + continue; 72.118 + } 72.119 + for (Alternative a4 : Alternative.values()) { 72.120 + if (arity == Arity.FOUR) { 72.121 + new DisjunctiveTypeWellFormednessTest(a1, a2, a3, a4).run(comp, fm); 72.122 + continue; 72.123 + } 72.124 + for (Alternative a5 : Alternative.values()) { 72.125 + new DisjunctiveTypeWellFormednessTest(a1, a2, a3, a4, a5).run(comp, fm); 72.126 + } 72.127 + } 72.128 + } 72.129 + } 72.130 + } 72.131 + } 72.132 + } 72.133 + 72.134 + Alternative[] alternatives; 72.135 + JavaSource source; 72.136 + DiagnosticChecker diagChecker; 72.137 + 72.138 + DisjunctiveTypeWellFormednessTest(Alternative... alternatives) { 72.139 + this.alternatives = alternatives; 72.140 + this.source = new JavaSource(); 72.141 + this.diagChecker = new DiagnosticChecker(); 72.142 + } 72.143 + 72.144 + class JavaSource extends SimpleJavaFileObject { 72.145 + 72.146 + String template = "class Test {\n" + 72.147 + "void test() {\n" + 72.148 + "try {} catch (#T e) {}\n" + 72.149 + "}\n" + 72.150 + "}\n"; 72.151 + 72.152 + String source; 72.153 + 72.154 + public JavaSource() { 72.155 + super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE); 72.156 + source = template.replace("#T", Alternative.makeDisjunctiveType(alternatives)); 72.157 + } 72.158 + 72.159 + @Override 72.160 + public CharSequence getCharContent(boolean ignoreEncodingErrors) { 72.161 + return source; 72.162 + } 72.163 + } 72.164 + 72.165 + void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception { 72.166 + JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker, 72.167 + null, null, Arrays.asList(source)); 72.168 + ct.analyze(); 72.169 + check(); 72.170 + } 72.171 + 72.172 + void check() { 72.173 + 72.174 + int non_disjoint = 0; 72.175 + int i = 0; 72.176 + for (Alternative a1 : alternatives) { 72.177 + int j = 0; 72.178 + for (Alternative a2 : alternatives) { 72.179 + if (i == j) continue; 72.180 + if (!a1.disjoint(a2)) { 72.181 + non_disjoint++; 72.182 + break; 72.183 + } 72.184 + j++; 72.185 + } 72.186 + i++; 72.187 + } 72.188 + 72.189 + if (non_disjoint != diagChecker.errorsFound) { 72.190 + throw new Error("invalid diagnostics for source:\n" + 72.191 + source.getCharContent(true) + 72.192 + "\nFound errors: " + diagChecker.errorsFound + 72.193 + "\nExpected errors: " + non_disjoint); 72.194 + } 72.195 + } 72.196 + 72.197 + static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> { 72.198 + 72.199 + int errorsFound; 72.200 + 72.201 + public void report(Diagnostic<? extends JavaFileObject> diagnostic) { 72.202 + if (diagnostic.getKind() == Diagnostic.Kind.ERROR && 72.203 + diagnostic.getCode().startsWith("compiler.err.multicatch.types.must.be.disjoint")) { 72.204 + errorsFound++; 72.205 + } 72.206 + } 72.207 + } 72.208 +}
73.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 73.2 +++ b/test/tools/javac/multicatch/7030606/T7030606.java Sun Apr 10 10:25:12 2011 -0700 73.3 @@ -0,0 +1,57 @@ 73.4 +/* 73.5 + * @test /nodynamiccopyright/ 73.6 + * @bug 7030606 73.7 + * 73.8 + * @summary Project-coin: multi-catch types should be pairwise disjoint 73.9 + * @compile/fail/ref=T7030606.out -XDrawDiagnostics T7030606.java 73.10 + */ 73.11 + 73.12 +class T7030606 { 73.13 + class E1 extends Exception { } 73.14 + class E2 extends E1 { } 73.15 + 73.16 + void e1() throws E1 { } 73.17 + void e2() throws E2 { } 73.18 + 73.19 + void m1() { 73.20 + try { 73.21 + e1(); 73.22 + e2(); 73.23 + } catch (NonExistentType | E2 | E1 e) { } 73.24 + } 73.25 + 73.26 + void m2() { 73.27 + try { 73.28 + e1(); 73.29 + e2(); 73.30 + } catch (NonExistentType | E1 | E2 e) { } 73.31 + } 73.32 + 73.33 + void m3() { 73.34 + try { 73.35 + e1(); 73.36 + e2(); 73.37 + } catch (E2 | NonExistentType | E1 e) { } 73.38 + } 73.39 + 73.40 + void m4() { 73.41 + try { 73.42 + e1(); 73.43 + e2(); 73.44 + } catch (E1 | NonExistentType | E2 e) { } 73.45 + } 73.46 + 73.47 + void m5() { 73.48 + try { 73.49 + e1(); 73.50 + e2(); 73.51 + } catch (E2 | E1 | NonExistentType e) { } 73.52 + } 73.53 + 73.54 + void m6() { 73.55 + try { 73.56 + e1(); 73.57 + e2(); 73.58 + } catch (E1 | E2 | NonExistentType e) { } 73.59 + } 73.60 +}
74.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 74.2 +++ b/test/tools/javac/multicatch/7030606/T7030606.out Sun Apr 10 10:25:12 2011 -0700 74.3 @@ -0,0 +1,13 @@ 74.4 +T7030606.java:20:18: compiler.err.cant.resolve.location: kindname.class, NonExistentType, , , (compiler.misc.location: kindname.class, T7030606, null) 74.5 +T7030606.java:20:41: compiler.err.multicatch.types.must.be.disjoint: T7030606.E2, T7030606.E1 74.6 +T7030606.java:27:18: compiler.err.cant.resolve.location: kindname.class, NonExistentType, , , (compiler.misc.location: kindname.class, T7030606, null) 74.7 +T7030606.java:27:41: compiler.err.multicatch.types.must.be.disjoint: T7030606.E2, T7030606.E1 74.8 +T7030606.java:34:23: compiler.err.cant.resolve.location: kindname.class, NonExistentType, , , (compiler.misc.location: kindname.class, T7030606, null) 74.9 +T7030606.java:34:41: compiler.err.multicatch.types.must.be.disjoint: T7030606.E2, T7030606.E1 74.10 +T7030606.java:41:23: compiler.err.cant.resolve.location: kindname.class, NonExistentType, , , (compiler.misc.location: kindname.class, T7030606, null) 74.11 +T7030606.java:41:41: compiler.err.multicatch.types.must.be.disjoint: T7030606.E2, T7030606.E1 74.12 +T7030606.java:48:23: compiler.err.multicatch.types.must.be.disjoint: T7030606.E2, T7030606.E1 74.13 +T7030606.java:48:28: compiler.err.cant.resolve.location: kindname.class, NonExistentType, , , (compiler.misc.location: kindname.class, T7030606, null) 74.14 +T7030606.java:55:23: compiler.err.multicatch.types.must.be.disjoint: T7030606.E2, T7030606.E1 74.15 +T7030606.java:55:28: compiler.err.cant.resolve.location: kindname.class, NonExistentType, , , (compiler.misc.location: kindname.class, T7030606, null) 74.16 +12 errors
75.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 75.2 +++ b/test/tools/javac/util/T6597678.java Sun Apr 10 10:25:12 2011 -0700 75.3 @@ -0,0 +1,105 @@ 75.4 +/* 75.5 + * Copyright (c) 2011, 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 + * @bug 6597678 75.30 + * @summary Ensure Messages propogated between rounds 75.31 + * @library ../lib 75.32 + * @build JavacTestingAbstractProcessor T6597678 75.33 + * @run main T6597678 75.34 + */ 75.35 + 75.36 +import java.io.*; 75.37 +import java.util.*; 75.38 +import javax.annotation.processing.RoundEnvironment; 75.39 +import javax.annotation.processing.SupportedOptions; 75.40 +import javax.lang.model.element.TypeElement; 75.41 +import javax.tools.Diagnostic; 75.42 + 75.43 + 75.44 +import com.sun.tools.javac.processing.JavacProcessingEnvironment; 75.45 +import com.sun.tools.javac.util.Context; 75.46 +import com.sun.tools.javac.util.JavacMessages; 75.47 + 75.48 +public class T6597678 extends JavacTestingAbstractProcessor { 75.49 + public static void main(String... args) throws Exception { 75.50 + new T6597678().run(); 75.51 + } 75.52 + 75.53 + 75.54 + void run() throws Exception { 75.55 + String myName = T6597678.class.getSimpleName(); 75.56 + File testSrc = new File(System.getProperty("test.src")); 75.57 + File file = new File(testSrc, myName + ".java"); 75.58 + 75.59 + compile( 75.60 + "-proc:only", 75.61 + "-processor", myName, 75.62 + file.getPath()); 75.63 + } 75.64 + 75.65 + void compile(String... args) throws Exception { 75.66 + StringWriter sw = new StringWriter(); 75.67 + PrintWriter pw = new PrintWriter(sw); 75.68 + int rc = com.sun.tools.javac.Main.compile(args, pw); 75.69 + pw.close(); 75.70 + String out = sw.toString(); 75.71 + if (!out.isEmpty()) 75.72 + System.err.println(out); 75.73 + if (rc != 0) 75.74 + throw new Exception("compilation failed unexpectedly: rc=" + rc); 75.75 + } 75.76 + 75.77 + //--------------- 75.78 + 75.79 + @Override 75.80 + public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { 75.81 + Context context = ((JavacProcessingEnvironment) processingEnv).getContext(); 75.82 + Locale locale = context.get(Locale.class); 75.83 + JavacMessages messages = context.get(JavacMessages.messagesKey); 75.84 + 75.85 + round++; 75.86 + if (round == 1) { 75.87 + initialLocale = locale; 75.88 + initialMessages = messages; 75.89 + } else { 75.90 + checkEqual("locale", locale, initialLocale); 75.91 + checkEqual("messages", messages, initialMessages); 75.92 + } 75.93 + 75.94 + return true; 75.95 + } 75.96 + 75.97 + <T> void checkEqual(String label, T actual, T expected) { 75.98 + if (actual != expected) 75.99 + messager.printMessage(Diagnostic.Kind.ERROR, 75.100 + "Unexpected value for " + label 75.101 + + "; expected: " + expected 75.102 + + "; found: " + actual); 75.103 + } 75.104 + 75.105 + int round = 0; 75.106 + Locale initialLocale; 75.107 + JavacMessages initialMessages; 75.108 +}
76.1 --- a/test/tools/javap/6937244/T6937244A.java Thu Apr 07 15:21:22 2011 -0700 76.2 +++ b/test/tools/javap/6937244/T6937244A.java Sun Apr 10 10:25:12 2011 -0700 76.3 @@ -1,5 +1,5 @@ 76.4 /* 76.5 - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 76.6 + * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. 76.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 76.8 * 76.9 * This code is free software; you can redistribute it and/or modify it 76.10 @@ -49,8 +49,8 @@ 76.11 int count = 0; 76.12 76.13 for (String line: out.split("[\r\n]+")) { 76.14 - if (line.contains("extends")) { 76.15 - verify(line, "extends java.lang.Object implements java.util.List<java.lang.String>"); 76.16 + if (line.contains("implements")) { 76.17 + verify(line, "implements java.util.List<java.lang.String>"); 76.18 count++; 76.19 } 76.20
77.1 --- a/test/tools/javap/T4880663.java Thu Apr 07 15:21:22 2011 -0700 77.2 +++ b/test/tools/javap/T4880663.java Sun Apr 10 10:25:12 2011 -0700 77.3 @@ -1,5 +1,5 @@ 77.4 /* 77.5 - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. 77.6 + * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. 77.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 77.8 * 77.9 * This code is free software; you can redistribute it and/or modify it 77.10 @@ -23,7 +23,7 @@ 77.11 77.12 /* 77.13 * @test 77.14 - * @bug 4880663 6715757 77.15 + * @bug 4880663 6715757 7031005 77.16 * @summary javap could output whitespace between class name and opening brace 77.17 * javap prints "extends java.lang.Object" 77.18 */ 77.19 @@ -39,7 +39,7 @@ 77.20 public void run() throws IOException { 77.21 File javaFile = writeTestFile(); 77.22 File classFile = compileTestFile(javaFile); 77.23 - verify(classFile, "class Test extends java.lang.Object {"); 77.24 + verify(classFile, "class Test {"); 77.25 77.26 if (errors > 0) 77.27 throw new Error(errors + " found.");
78.1 --- a/test/tools/javap/T4880672.java Thu Apr 07 15:21:22 2011 -0700 78.2 +++ b/test/tools/javap/T4880672.java Sun Apr 10 10:25:12 2011 -0700 78.3 @@ -1,5 +1,5 @@ 78.4 /* 78.5 - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. 78.6 + * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. 78.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 78.8 * 78.9 * This code is free software; you can redistribute it and/or modify it 78.10 @@ -24,7 +24,7 @@ 78.11 78.12 /* 78.13 * @test 78.14 - * @bug 4880672 78.15 + * @bug 4880672 7031005 78.16 * @summary javap does not output inner interfaces of an interface 78.17 */ 78.18 78.19 @@ -39,7 +39,7 @@ 78.20 78.21 void run() { 78.22 verify("java.util.Map", "public interface java.util.Map$Entry"); 78.23 - verify("T4880672", "class T4880672$A$B extends java.lang.Object"); 78.24 + verify("T4880672", "class T4880672$A$B"); 78.25 verify("C", ""); // must not give error if no InnerClasses attribute 78.26 if (errors > 0) 78.27 throw new Error(errors + " found.");
79.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 79.2 +++ b/test/tools/javap/TestSuperclass.java Sun Apr 10 10:25:12 2011 -0700 79.3 @@ -0,0 +1,178 @@ 79.4 +/* 79.5 + * Copyright (c) 2011, 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 + * @bug 7031005 79.30 + * @summary javap prints "extends java.lang.Object" 79.31 + */ 79.32 + 79.33 +import java.io.File; 79.34 +import java.io.IOException; 79.35 +import java.io.PrintWriter; 79.36 +import java.io.StringWriter; 79.37 +import java.net.URI; 79.38 +import java.util.Arrays; 79.39 +import javax.tools.JavaCompiler; 79.40 +import javax.tools.JavaCompiler.CompilationTask; 79.41 +import javax.tools.JavaFileObject; 79.42 +import javax.tools.SimpleJavaFileObject; 79.43 +import javax.tools.StandardJavaFileManager; 79.44 +import javax.tools.StandardLocation; 79.45 +import javax.tools.ToolProvider; 79.46 + 79.47 +public class TestSuperclass { 79.48 + enum ClassKind { 79.49 + CLASS("class"), 79.50 + INTERFACE("interface"); 79.51 + ClassKind(String keyword) { 79.52 + this.keyword = keyword; 79.53 + } 79.54 + final String keyword; 79.55 + } 79.56 + 79.57 + enum GenericKind { 79.58 + NO(""), 79.59 + YES("<T>"); 79.60 + GenericKind(String typarams) { 79.61 + this.typarams = typarams; 79.62 + } 79.63 + final String typarams; 79.64 + } 79.65 + 79.66 + enum SuperKind { 79.67 + NONE(null), 79.68 + SUPER("Super"); 79.69 + SuperKind(String name) { 79.70 + this.name = name; 79.71 + } 79.72 + String extend() { 79.73 + return (name == null) ? "" : "extends " + name; 79.74 + } 79.75 + String decl(ClassKind ck) { 79.76 + return (name == null) ? "" : ck.keyword + " " + name + " { }"; 79.77 + } 79.78 + final String name; 79.79 + } 79.80 + 79.81 + public static void main(String... args) throws Exception { 79.82 + JavaCompiler comp = ToolProvider.getSystemJavaCompiler(); 79.83 + StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null); 79.84 + int errors = 0; 79.85 + 79.86 + for (ClassKind ck: ClassKind.values()) { 79.87 + for (GenericKind gk: GenericKind.values()) { 79.88 + for (SuperKind sk: SuperKind.values()) { 79.89 + errors += new TestSuperclass(ck, gk, sk).run(comp, fm); 79.90 + } 79.91 + } 79.92 + } 79.93 + 79.94 + if (errors > 0) 79.95 + throw new Exception(errors + " errors found"); 79.96 + } 79.97 + 79.98 + final ClassKind ck; 79.99 + final GenericKind gk; 79.100 + final SuperKind sk; 79.101 + 79.102 + TestSuperclass(ClassKind ck, GenericKind gk, SuperKind sk) { 79.103 + this.ck = ck; 79.104 + this.gk = gk; 79.105 + this.sk = sk; 79.106 + } 79.107 + 79.108 + int run(JavaCompiler comp, StandardJavaFileManager fm) throws IOException { 79.109 + System.err.println("test: ck:" + ck + " gk:" + gk + " sk:" + sk); 79.110 + File testDir = new File(ck + "-" + gk + "-" + sk); 79.111 + testDir.mkdirs(); 79.112 + fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(testDir)); 79.113 + 79.114 + JavaSource js = new JavaSource(); 79.115 + System.err.println(js.getCharContent(false)); 79.116 + CompilationTask t = comp.getTask(null, fm, null, null, null, Arrays.asList(js)); 79.117 + if (!t.call()) 79.118 + throw new Error("compilation failed"); 79.119 + 79.120 + File testClass = new File(testDir, "Test.class"); 79.121 + String out = javap(testClass); 79.122 + 79.123 + // Extract class sig from first line of Java source 79.124 + String expect = js.source.replaceAll("(?s)^(.* Test[^{]+?) *\\{.*", "$1"); 79.125 + 79.126 + // Extract class sig from line from javap output 79.127 + String found = out.replaceAll("(?s).*\n(.* Test[^{]+?) *\\{.*", "$1"); 79.128 + 79.129 + checkEqual("class signature", expect, found); 79.130 + 79.131 + return errors; 79.132 + } 79.133 + 79.134 + String javap(File file) { 79.135 + StringWriter sw = new StringWriter(); 79.136 + PrintWriter pw = new PrintWriter(sw); 79.137 + String[] args = { file.getPath() }; 79.138 + int rc = com.sun.tools.javap.Main.run(args, pw); 79.139 + pw.close(); 79.140 + String out = sw.toString(); 79.141 + if (!out.isEmpty()) 79.142 + System.err.println(out); 79.143 + if (rc != 0) 79.144 + throw new Error("javap failed: rc=" + rc); 79.145 + return out; 79.146 + } 79.147 + 79.148 + void checkEqual(String label, String expect, String found) { 79.149 + if (!expect.equals(found)) 79.150 + error("Unexpected " + label + " found: '" + found + "', expected: '" + expect + "'"); 79.151 + } 79.152 + 79.153 + void error(String msg) { 79.154 + System.err.println("Error: " + msg); 79.155 + errors++; 79.156 + } 79.157 + 79.158 + int errors; 79.159 + 79.160 + class JavaSource extends SimpleJavaFileObject { 79.161 + static final String template = 79.162 + "#CK Test#GK #EK { }\n" 79.163 + + "#SK\n"; 79.164 + final String source; 79.165 + 79.166 + public JavaSource() { 79.167 + super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE); 79.168 + source = template 79.169 + .replace("#CK", ck.keyword) 79.170 + .replace("#GK", gk.typarams) 79.171 + .replace("#EK", sk.extend()) 79.172 + .replace("#SK", sk.decl(ck)); 79.173 + } 79.174 + 79.175 + @Override 79.176 + public CharSequence getCharContent(boolean ignoreEncodingErrors) { 79.177 + return source; 79.178 + } 79.179 + } 79.180 + 79.181 +}