Fri, 02 Nov 2012 17:55:34 -0700
Merge
src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DirectoryManager.java | file | annotate | diff | comparison | revisions | |
src/share/classes/com/sun/tools/doclets/internal/toolkit/util/SourcePath.java | file | annotate | diff | comparison | revisions | |
src/share/classes/com/sun/tools/javac/code/TypeTags.java | file | annotate | diff | comparison | revisions |
1.1 --- a/make/tools/genstubs/GenStubs.java Thu Nov 01 14:13:13 2012 -0700 1.2 +++ b/make/tools/genstubs/GenStubs.java Fri Nov 02 17:55:34 2012 -0700 1.3 @@ -35,7 +35,7 @@ 1.4 import com.sun.source.util.JavacTask; 1.5 import com.sun.tools.javac.api.JavacTool; 1.6 import com.sun.tools.javac.code.Flags; 1.7 -import com.sun.tools.javac.code.TypeTags; 1.8 +import com.sun.tools.javac.code.TypeTag; 1.9 import com.sun.tools.javac.tree.JCTree; 1.10 import com.sun.tools.javac.tree.JCTree.JCCompilationUnit; 1.11 import com.sun.tools.javac.tree.JCTree.JCFieldAccess; 1.12 @@ -244,23 +244,23 @@ 1.13 else { 1.14 String t = tree.vartype.toString(); 1.15 if (t.equals("boolean")) 1.16 - tree.init = new JCLiteral(TypeTags.BOOLEAN, 0) { }; 1.17 + tree.init = new JCLiteral(TypeTag.BOOLEAN, 0) { }; 1.18 else if (t.equals("byte")) 1.19 - tree.init = new JCLiteral(TypeTags.BYTE, 0) { }; 1.20 + tree.init = new JCLiteral(TypeTag.BYTE, 0) { }; 1.21 else if (t.equals("char")) 1.22 - tree.init = new JCLiteral(TypeTags.CHAR, 0) { }; 1.23 + tree.init = new JCLiteral(TypeTag.CHAR, 0) { }; 1.24 else if (t.equals("double")) 1.25 - tree.init = new JCLiteral(TypeTags.DOUBLE, 0.d) { }; 1.26 + tree.init = new JCLiteral(TypeTag.DOUBLE, 0.d) { }; 1.27 else if (t.equals("float")) 1.28 - tree.init = new JCLiteral(TypeTags.FLOAT, 0.f) { }; 1.29 + tree.init = new JCLiteral(TypeTag.FLOAT, 0.f) { }; 1.30 else if (t.equals("int")) 1.31 - tree.init = new JCLiteral(TypeTags.INT, 0) { }; 1.32 + tree.init = new JCLiteral(TypeTag.INT, 0) { }; 1.33 else if (t.equals("long")) 1.34 - tree.init = new JCLiteral(TypeTags.LONG, 0) { }; 1.35 + tree.init = new JCLiteral(TypeTag.LONG, 0) { }; 1.36 else if (t.equals("short")) 1.37 - tree.init = new JCLiteral(TypeTags.SHORT, 0) { }; 1.38 + tree.init = new JCLiteral(TypeTag.SHORT, 0) { }; 1.39 else 1.40 - tree.init = new JCLiteral(TypeTags.BOT, null) { }; 1.41 + tree.init = new JCLiteral(TypeTag.BOT, null) { }; 1.42 } 1.43 } 1.44 result = tree;
2.1 --- a/src/share/classes/com/sun/javadoc/SerialFieldTag.java Thu Nov 01 14:13:13 2012 -0700 2.2 +++ b/src/share/classes/com/sun/javadoc/SerialFieldTag.java Fri Nov 02 17:55:34 2012 -0700 2.3 @@ -1,5 +1,5 @@ 2.4 /* 2.5 - * Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved. 2.6 + * Copyright (c) 1998, 2012, 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 @@ -46,7 +46,7 @@ 2.11 public interface SerialFieldTag extends Tag, Comparable<Object> { 2.12 2.13 /** 2.14 - * Return the serialziable field name. 2.15 + * Return the serializable field name. 2.16 */ 2.17 public String fieldName(); 2.18
3.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/AbstractIndexWriter.java Thu Nov 01 14:13:13 2012 -0700 3.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/AbstractIndexWriter.java Fri Nov 02 17:55:34 2012 -0700 3.3 @@ -56,32 +56,18 @@ 3.4 protected IndexBuilder indexbuilder; 3.5 3.6 /** 3.7 - * This constructor will be used by {@link SplitIndexWriter}. Initialises 3.8 + * This constructor will be used by {@link SplitIndexWriter}. Initializes 3.9 * path to this file and relative path from this file. 3.10 * 3.11 + * @param configuration The current configuration 3.12 * @param path Path to the file which is getting generated. 3.13 - * @param filename Name of the file which is getting genrated. 3.14 - * @param relpath Relative path from this file to the current directory. 3.15 * @param indexbuilder Unicode based Index from {@link IndexBuilder} 3.16 */ 3.17 protected AbstractIndexWriter(ConfigurationImpl configuration, 3.18 - String path, String filename, 3.19 - String relpath, IndexBuilder indexbuilder) 3.20 + DocPath path, 3.21 + IndexBuilder indexbuilder) 3.22 throws IOException { 3.23 - super(configuration, path, filename, relpath); 3.24 - this.indexbuilder = indexbuilder; 3.25 - } 3.26 - 3.27 - /** 3.28 - * This Constructor will be used by {@link SingleIndexWriter}. 3.29 - * 3.30 - * @param filename Name of the file which is getting genrated. 3.31 - * @param indexbuilder Unicode based Index form {@link IndexBuilder} 3.32 - */ 3.33 - protected AbstractIndexWriter(ConfigurationImpl configuration, 3.34 - String filename, IndexBuilder indexbuilder) 3.35 - throws IOException { 3.36 - super(configuration, filename); 3.37 + super(configuration, path); 3.38 this.indexbuilder = indexbuilder; 3.39 } 3.40
4.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/AbstractPackageIndexWriter.java Thu Nov 01 14:13:13 2012 -0700 4.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/AbstractPackageIndexWriter.java Fri Nov 02 17:55:34 2012 -0700 4.3 @@ -27,9 +27,11 @@ 4.4 4.5 import java.io.*; 4.6 import java.util.*; 4.7 + 4.8 import com.sun.javadoc.*; 4.9 import com.sun.tools.doclets.formats.html.markup.*; 4.10 import com.sun.tools.doclets.internal.toolkit.*; 4.11 +import com.sun.tools.doclets.internal.toolkit.util.DocPath; 4.12 4.13 /** 4.14 * Abstract class to generate the overview files in 4.15 @@ -52,14 +54,14 @@ 4.16 protected PackageDoc[] packages; 4.17 4.18 /** 4.19 - * Constructor. Also initialises the packages variable. 4.20 + * Constructor. Also initializes the packages variable. 4.21 * 4.22 + * @param configuration The current configuration 4.23 * @param filename Name of the package index file to be generated. 4.24 */ 4.25 public AbstractPackageIndexWriter(ConfigurationImpl configuration, 4.26 - String filename) throws IOException { 4.27 + DocPath filename) throws IOException { 4.28 super(configuration, filename); 4.29 - this.relativepathNoSlash = "."; 4.30 packages = configuration.packages; 4.31 } 4.32
5.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/AbstractTreeWriter.java Thu Nov 01 14:13:13 2012 -0700 5.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/AbstractTreeWriter.java Fri Nov 02 17:55:34 2012 -0700 5.3 @@ -56,46 +56,23 @@ 5.4 private static final String LI_CIRCLE = "circle"; 5.5 5.6 /** 5.7 - * Constructor initilises classtree variable. This constructor will be used 5.8 + * Constructor initializes classtree variable. This constructor will be used 5.9 * while generating global tree file "overview-tree.html". 5.10 * 5.11 + * @param configuration The current configuration 5.12 * @param filename File to be generated. 5.13 * @param classtree Tree built by {@link ClassTree}. 5.14 * @throws IOException 5.15 * @throws DocletAbortException 5.16 */ 5.17 protected AbstractTreeWriter(ConfigurationImpl configuration, 5.18 - String filename, ClassTree classtree) 5.19 + DocPath filename, ClassTree classtree) 5.20 throws IOException { 5.21 super(configuration, filename); 5.22 this.classtree = classtree; 5.23 } 5.24 5.25 /** 5.26 - * Create appropriate directory for the package and also initilise the 5.27 - * relative path from this generated file to the current or 5.28 - * the destination directory. This constructor will be used while 5.29 - * generating "package tree" file. 5.30 - * 5.31 - * @param path Directories in this path will be created if they are not 5.32 - * already there. 5.33 - * @param filename Name of the package tree file to be generated. 5.34 - * @param classtree The tree built using {@link ClassTree}. 5.35 - * for the package pkg. 5.36 - * @param pkg PackageDoc for which tree file will be generated. 5.37 - * @throws IOException 5.38 - * @throws DocletAbortException 5.39 - */ 5.40 - protected AbstractTreeWriter(ConfigurationImpl configuration, 5.41 - String path, String filename, 5.42 - ClassTree classtree, PackageDoc pkg) 5.43 - throws IOException { 5.44 - super(configuration, 5.45 - path, filename, DirectoryManager.getRelativePath(pkg.name())); 5.46 - this.classtree = classtree; 5.47 - } 5.48 - 5.49 - /** 5.50 * Add each level of the class tree. For each sub-class or 5.51 * sub-interface indents the next level information. 5.52 * Recurses itself to add subclasses info.
6.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/AllClassesFrameWriter.java Thu Nov 01 14:13:13 2012 -0700 6.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/AllClassesFrameWriter.java Fri Nov 02 17:55:34 2012 -0700 6.3 @@ -51,16 +51,6 @@ 6.4 public class AllClassesFrameWriter extends HtmlDocletWriter { 6.5 6.6 /** 6.7 - * The name of the output file with frames 6.8 - */ 6.9 - public static final String OUTPUT_FILE_NAME_FRAMES = "allclasses-frame.html"; 6.10 - 6.11 - /** 6.12 - * The name of the output file without frames 6.13 - */ 6.14 - public static final String OUTPUT_FILE_NAME_NOFRAMES = "allclasses-noframe.html"; 6.15 - 6.16 - /** 6.17 * Index of all the classes. 6.18 */ 6.19 protected IndexBuilder indexbuilder; 6.20 @@ -71,13 +61,16 @@ 6.21 final HtmlTree BR = new HtmlTree(HtmlTag.BR); 6.22 6.23 /** 6.24 - * Construct AllClassesFrameWriter object. Also initilises the indexbuilder 6.25 + * Construct AllClassesFrameWriter object. Also initializes the indexbuilder 6.26 * variable in this class. 6.27 + * @param configuration The current configuration 6.28 + * @param filename Path to the file which is getting generated. 6.29 + * @param indexbuilder Unicode based Index from {@link IndexBuilder} 6.30 * @throws IOException 6.31 * @throws DocletAbortException 6.32 */ 6.33 public AllClassesFrameWriter(ConfigurationImpl configuration, 6.34 - String filename, IndexBuilder indexbuilder) 6.35 + DocPath filename, IndexBuilder indexbuilder) 6.36 throws IOException { 6.37 super(configuration, filename); 6.38 this.indexbuilder = indexbuilder; 6.39 @@ -94,13 +87,13 @@ 6.40 public static void generate(ConfigurationImpl configuration, 6.41 IndexBuilder indexbuilder) { 6.42 AllClassesFrameWriter allclassgen; 6.43 - String filename = OUTPUT_FILE_NAME_FRAMES; 6.44 + DocPath filename = DocPaths.ALLCLASSES_FRAME; 6.45 try { 6.46 allclassgen = new AllClassesFrameWriter(configuration, 6.47 filename, indexbuilder); 6.48 allclassgen.buildAllClassesFile(true); 6.49 allclassgen.close(); 6.50 - filename = OUTPUT_FILE_NAME_NOFRAMES; 6.51 + filename = DocPaths.ALLCLASSES_NOFRAME; 6.52 allclassgen = new AllClassesFrameWriter(configuration, 6.53 filename, indexbuilder); 6.54 allclassgen.buildAllClassesFile(false);
7.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java Thu Nov 01 14:13:13 2012 -0700 7.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java Fri Nov 02 17:55:34 2012 -0700 7.3 @@ -141,7 +141,7 @@ 7.4 */ 7.5 protected Content getNavSummaryLink(ClassDoc cd, boolean link) { 7.6 if (link) { 7.7 - return writer.getHyperLink("", "annotation_type_optional_element_summary", 7.8 + return writer.getHyperLink("annotation_type_optional_element_summary", 7.9 writer.getResource("doclet.navAnnotationTypeOptionalMember")); 7.10 } else { 7.11 return writer.getResource("doclet.navAnnotationTypeOptionalMember");
8.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java Thu Nov 01 14:13:13 2012 -0700 8.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java Fri Nov 02 17:55:34 2012 -0700 8.3 @@ -260,7 +260,7 @@ 8.4 */ 8.5 protected Content getNavSummaryLink(ClassDoc cd, boolean link) { 8.6 if (link) { 8.7 - return writer.getHyperLink("", "annotation_type_required_element_summary", 8.8 + return writer.getHyperLink("annotation_type_required_element_summary", 8.9 writer.getResource("doclet.navAnnotationTypeRequiredMember")); 8.10 } else { 8.11 return writer.getResource("doclet.navAnnotationTypeRequiredMember"); 8.12 @@ -272,7 +272,7 @@ 8.13 */ 8.14 protected void addNavDetailLink(boolean link, Content liNav) { 8.15 if (link) { 8.16 - liNav.addContent(writer.getHyperLink("", "annotation_type_element_detail", 8.17 + liNav.addContent(writer.getHyperLink("annotation_type_element_detail", 8.18 writer.getResource("doclet.navAnnotationTypeMember"))); 8.19 } else { 8.20 liNav.addContent(writer.getResource("doclet.navAnnotationTypeMember"));
9.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeWriterImpl.java Thu Nov 01 14:13:13 2012 -0700 9.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeWriterImpl.java Fri Nov 02 17:55:34 2012 -0700 9.3 @@ -65,13 +65,10 @@ 9.4 * @param prevType the previous class that was documented. 9.5 * @param nextType the next class being documented. 9.6 */ 9.7 - public AnnotationTypeWriterImpl (AnnotationTypeDoc annotationType, 9.8 + public AnnotationTypeWriterImpl(AnnotationTypeDoc annotationType, 9.9 Type prevType, Type nextType) 9.10 - throws Exception { 9.11 - super(ConfigurationImpl.getInstance(), 9.12 - DirectoryManager.getDirectoryPath(annotationType.containingPackage()), 9.13 - annotationType.name() + ".html", 9.14 - DirectoryManager.getRelativePath(annotationType.containingPackage().name())); 9.15 + throws Exception { 9.16 + super(ConfigurationImpl.getInstance(), DocPath.forClass(annotationType)); 9.17 this.annotationType = annotationType; 9.18 configuration.currentcd = annotationType.asClassDoc(); 9.19 this.prev = prevType; 9.20 @@ -84,7 +81,7 @@ 9.21 * @return a content tree for the package link 9.22 */ 9.23 protected Content getNavLinkPackage() { 9.24 - Content linkContent = getHyperLink("package-summary.html", "", 9.25 + Content linkContent = getHyperLink(DocPaths.PACKAGE_SUMMARY, 9.26 packageLabel); 9.27 Content li = HtmlTree.LI(linkContent); 9.28 return li; 9.29 @@ -106,7 +103,7 @@ 9.30 * @return a content tree for the class use link 9.31 */ 9.32 protected Content getNavLinkClassUse() { 9.33 - Content linkContent = getHyperLink("class-use/" + filename, "", useLabel); 9.34 + Content linkContent = getHyperLink(DocPaths.CLASS_USE.resolve(filename), useLabel); 9.35 Content li = HtmlTree.LI(linkContent); 9.36 return li; 9.37 } 9.38 @@ -289,8 +286,8 @@ 9.39 * {@inheritDoc} 9.40 */ 9.41 protected Content getNavLinkTree() { 9.42 - Content treeLinkContent = getHyperLink("package-tree.html", 9.43 - "", treeLabel, "", ""); 9.44 + Content treeLinkContent = getHyperLink(DocPaths.PACKAGE_TREE, 9.45 + treeLabel, "", ""); 9.46 Content li = HtmlTree.LI(treeLinkContent); 9.47 return li; 9.48 }
10.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java Thu Nov 01 14:13:13 2012 -0700 10.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java Fri Nov 02 17:55:34 2012 -0700 10.3 @@ -82,7 +82,6 @@ 10.4 final String methodUseTableSummary; 10.5 final String constructorUseTableSummary; 10.6 10.7 - 10.8 /** 10.9 * Constructor. 10.10 * 10.11 @@ -91,10 +90,9 @@ 10.12 * @throws DocletAbortException 10.13 */ 10.14 public ClassUseWriter(ConfigurationImpl configuration, 10.15 - ClassUseMapper mapper, String path, 10.16 - String filename, String relpath, 10.17 + ClassUseMapper mapper, DocPath filename, 10.18 ClassDoc classdoc) throws IOException { 10.19 - super(configuration, path, filename, relpath); 10.20 + super(configuration, filename); 10.21 this.classdoc = classdoc; 10.22 if (mapper.classToPackageAnnotations.containsKey(classdoc.qualifiedName())) 10.23 pkgToPackageAnnotations = new HashSet<PackageDoc>(mapper.classToPackageAnnotations.get(classdoc.qualifiedName())); 10.24 @@ -199,23 +197,19 @@ 10.25 public static void generate(ConfigurationImpl configuration, 10.26 ClassUseMapper mapper, ClassDoc classdoc) { 10.27 ClassUseWriter clsgen; 10.28 - String path = DirectoryManager.getDirectoryPath(classdoc. 10.29 - containingPackage()); 10.30 - path += "class-use" + DirectoryManager.URL_FILE_SEPARATOR; 10.31 - String filename = classdoc.name() + ".html"; 10.32 - String pkgname = classdoc.containingPackage().name(); 10.33 - pkgname += (pkgname.length() > 0)? ".class-use": "class-use"; 10.34 - String relpath = DirectoryManager.getRelativePath(pkgname); 10.35 + DocPath path = DocPath.forPackage(classdoc) 10.36 + .resolve(DocPaths.CLASS_USE) 10.37 + .resolve(DocPath.forName(classdoc)); 10.38 try { 10.39 clsgen = new ClassUseWriter(configuration, 10.40 - mapper, path, filename, 10.41 - relpath, classdoc); 10.42 + mapper, path, 10.43 + classdoc); 10.44 clsgen.generateClassUseFile(); 10.45 clsgen.close(); 10.46 } catch (IOException exc) { 10.47 configuration.standardmessage. 10.48 error("doclet.exception_encountered", 10.49 - exc.toString(), filename); 10.50 + exc.toString(), path.getPath()); 10.51 throw new DocletAbortException(); 10.52 } 10.53 } 10.54 @@ -359,7 +353,7 @@ 10.55 */ 10.56 protected void addPackageUse(PackageDoc pkg, Content contentTree) throws IOException { 10.57 Content tdFirst = HtmlTree.TD(HtmlStyle.colFirst, 10.58 - getHyperLink("", pkg.name(), new StringContent(Util.getPackageName(pkg)))); 10.59 + getHyperLink(pkg.name(), new StringContent(Util.getPackageName(pkg)))); 10.60 contentTree.addContent(tdFirst); 10.61 HtmlTree tdLast = new HtmlTree(HtmlTag.TD); 10.62 tdLast.addStyle(HtmlStyle.colLast); 10.63 @@ -470,8 +464,8 @@ 10.64 * @return a content tree for the package link 10.65 */ 10.66 protected Content getNavLinkPackage() { 10.67 - Content linkContent = getHyperLink("../package-summary.html", "", 10.68 - packageLabel); 10.69 + Content linkContent = 10.70 + getHyperLink(DocPath.parent.resolve(DocPaths.PACKAGE_SUMMARY), packageLabel); 10.71 Content li = HtmlTree.LI(linkContent); 10.72 return li; 10.73 } 10.74 @@ -506,8 +500,8 @@ 10.75 */ 10.76 protected Content getNavLinkTree() { 10.77 Content linkContent = classdoc.containingPackage().isIncluded() ? 10.78 - getHyperLink("../package-tree.html", "", treeLabel) : 10.79 - getHyperLink(relativePath + "overview-tree.html", "", treeLabel); 10.80 + getHyperLink(DocPath.parent.resolve(DocPaths.PACKAGE_TREE), treeLabel) : 10.81 + getHyperLink(pathToRoot.resolve(DocPaths.OVERVIEW_TREE), treeLabel); 10.82 Content li = HtmlTree.LI(linkContent); 10.83 return li; 10.84 }
11.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java Thu Nov 01 14:13:13 2012 -0700 11.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java Fri Nov 02 17:55:34 2012 -0700 11.3 @@ -72,11 +72,8 @@ 11.4 */ 11.5 public ClassWriterImpl (ClassDoc classDoc, 11.6 ClassDoc prevClass, ClassDoc nextClass, ClassTree classTree) 11.7 - throws Exception { 11.8 - super(ConfigurationImpl.getInstance(), 11.9 - DirectoryManager.getDirectoryPath(classDoc.containingPackage()), 11.10 - classDoc.name() + ".html", 11.11 - DirectoryManager.getRelativePath(classDoc.containingPackage().name())); 11.12 + throws Exception { 11.13 + super(ConfigurationImpl.getInstance(), DocPath.forClass(classDoc)); 11.14 this.classDoc = classDoc; 11.15 configuration.currentcd = classDoc; 11.16 this.classtree = classTree; 11.17 @@ -90,7 +87,7 @@ 11.18 * @return a content tree for the package link 11.19 */ 11.20 protected Content getNavLinkPackage() { 11.21 - Content linkContent = getHyperLink("package-summary.html", "", 11.22 + Content linkContent = getHyperLink(DocPaths.PACKAGE_SUMMARY, 11.23 packageLabel); 11.24 Content li = HtmlTree.LI(linkContent); 11.25 return li; 11.26 @@ -112,7 +109,7 @@ 11.27 * @return a content tree for the class use link 11.28 */ 11.29 protected Content getNavLinkClassUse() { 11.30 - Content linkContent = getHyperLink("class-use/" + filename, "", useLabel); 11.31 + Content linkContent = getHyperLink(DocPaths.CLASS_USE.resolve(filename), useLabel); 11.32 Content li = HtmlTree.LI(linkContent); 11.33 return li; 11.34 } 11.35 @@ -567,8 +564,8 @@ 11.36 * {@inheritDoc} 11.37 */ 11.38 protected Content getNavLinkTree() { 11.39 - Content treeLinkContent = getHyperLink("package-tree.html", 11.40 - "", treeLabel, "", ""); 11.41 + Content treeLinkContent = getHyperLink(DocPaths.PACKAGE_TREE, 11.42 + treeLabel, "", ""); 11.43 Content li = HtmlTree.LI(treeLinkContent); 11.44 return li; 11.45 }
12.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java Thu Nov 01 14:13:13 2012 -0700 12.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java Fri Nov 02 17:55:34 2012 -0700 12.3 @@ -25,7 +25,6 @@ 12.4 12.5 package com.sun.tools.doclets.formats.html; 12.6 12.7 -import java.io.*; 12.8 import java.net.*; 12.9 import java.util.*; 12.10 12.11 @@ -46,6 +45,11 @@ 12.12 * use "-helpfile" option when already "-nohelp" option is used. 12.13 * </p> 12.14 * 12.15 + * <p><b>This is NOT part of any supported API. 12.16 + * If you write code that depends on this, you do so at your own risk. 12.17 + * This code and its internal interfaces are subject to change or 12.18 + * deletion without notice.</b> 12.19 + * 12.20 * @author Robert Field. 12.21 * @author Atul Dambalkar. 12.22 * @author Jamie Ho 12.23 @@ -62,11 +66,6 @@ 12.24 public static final String BUILD_DATE = System.getProperty("java.version"); 12.25 12.26 /** 12.27 - * The name of the constant values file. 12.28 - */ 12.29 - public static final String CONSTANTS_FILE_NAME = "constant-values.html"; 12.30 - 12.31 - /** 12.32 * Argument for command line option "-header". 12.33 */ 12.34 public String header = ""; 12.35 @@ -179,7 +178,7 @@ 12.36 * First file to appear in the right-hand frame in the generated 12.37 * documentation. 12.38 */ 12.39 - public String topFile = ""; 12.40 + public DocPath topFile = DocPath.empty; 12.41 12.42 /** 12.43 * The classdoc for the class file getting generated. 12.44 @@ -367,7 +366,7 @@ 12.45 "-helpfile")); 12.46 return false; 12.47 } 12.48 - File help = new File(os[1]); 12.49 + DocFile help = DocFile.createFileForInput(this, os[1]); 12.50 if (!help.exists()) { 12.51 reporter.printError(getText("doclet.File_not_found", os[1])); 12.52 return false; 12.53 @@ -447,18 +446,17 @@ 12.54 return; 12.55 } 12.56 if (createoverview) { 12.57 - topFile = "overview-summary.html"; 12.58 + topFile = DocPaths.OVERVIEW_SUMMARY; 12.59 } else { 12.60 if (packages.length == 1 && packages[0].name().equals("")) { 12.61 if (root.classes().length > 0) { 12.62 ClassDoc[] classarr = root.classes(); 12.63 Arrays.sort(classarr); 12.64 ClassDoc cd = getValidClass(classarr); 12.65 - topFile = DirectoryManager.getPathToClass(cd); 12.66 + topFile = DocPath.forClass(cd); 12.67 } 12.68 } else { 12.69 - topFile = DirectoryManager.getPathToPackage(packages[0], 12.70 - "package-summary.html"); 12.71 + topFile = DocPath.forPackage(packages[0]).resolve(DocPaths.PACKAGE_SUMMARY); 12.72 } 12.73 } 12.74 }
13.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/ConstantsSummaryWriterImpl.java Thu Nov 01 14:13:13 2012 -0700 13.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/ConstantsSummaryWriterImpl.java Fri Nov 02 17:55:34 2012 -0700 13.3 @@ -69,7 +69,7 @@ 13.4 */ 13.5 public ConstantsSummaryWriterImpl(ConfigurationImpl configuration) 13.6 throws IOException { 13.7 - super(configuration, ConfigurationImpl.CONSTANTS_FILE_NAME); 13.8 + super(configuration, DocPaths.CONSTANT_VALUES); 13.9 this.configuration = configuration; 13.10 constantsTableSummary = configuration.getText("doclet.Constants_Table_Summary", 13.11 configuration.getText("doclet.Constants_Summary")); 13.12 @@ -107,13 +107,13 @@ 13.13 //add link to summary 13.14 Content link; 13.15 if (packageName.length() == 0) { 13.16 - link = getHyperLink("#" + DocletConstants.UNNAMED_PACKAGE_ANCHOR, 13.17 - "", defaultPackageLabel, "", ""); 13.18 + link = getHyperLink(DocLink.fragment(DocletConstants.UNNAMED_PACKAGE_ANCHOR), 13.19 + defaultPackageLabel, "", ""); 13.20 } else { 13.21 Content packageNameContent = getPackageLabel(parsedPackageName); 13.22 packageNameContent.addContent(".*"); 13.23 - link = getHyperLink("#" + parsedPackageName, 13.24 - "", packageNameContent, "", ""); 13.25 + link = getHyperLink(DocLink.fragment(parsedPackageName), 13.26 + packageNameContent, "", ""); 13.27 printedPackageHeaders.add(parsedPackageName); 13.28 } 13.29 contentListTree.addContent(HtmlTree.LI(link));
14.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/ConstructorWriterImpl.java Thu Nov 01 14:13:13 2012 -0700 14.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/ConstructorWriterImpl.java Fri Nov 02 17:55:34 2012 -0700 14.3 @@ -280,7 +280,7 @@ 14.4 */ 14.5 protected Content getNavSummaryLink(ClassDoc cd, boolean link) { 14.6 if (link) { 14.7 - return writer.getHyperLink("", "constructor_summary", 14.8 + return writer.getHyperLink("constructor_summary", 14.9 writer.getResource("doclet.navConstructor")); 14.10 } else { 14.11 return writer.getResource("doclet.navConstructor"); 14.12 @@ -292,7 +292,7 @@ 14.13 */ 14.14 protected void addNavDetailLink(boolean link, Content liNav) { 14.15 if (link) { 14.16 - liNav.addContent(writer.getHyperLink("", "constructor_detail", 14.17 + liNav.addContent(writer.getHyperLink("constructor_detail", 14.18 writer.getResource("doclet.navConstructor"))); 14.19 } else { 14.20 liNav.addContent(writer.getResource("doclet.navConstructor"));
15.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/DeprecatedListWriter.java Thu Nov 01 14:13:13 2012 -0700 15.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/DeprecatedListWriter.java Fri Nov 02 17:55:34 2012 -0700 15.3 @@ -95,7 +95,7 @@ 15.4 * @param filename the file to be generated. 15.5 */ 15.6 public DeprecatedListWriter(ConfigurationImpl configuration, 15.7 - String filename) throws IOException { 15.8 + DocPath filename) throws IOException { 15.9 super(configuration, filename); 15.10 this.configuration = configuration; 15.11 NestedClassWriterImpl classW = new NestedClassWriterImpl(this); 15.12 @@ -116,7 +116,7 @@ 15.13 * @param configuration the current configuration of the doclet. 15.14 */ 15.15 public static void generate(ConfigurationImpl configuration) { 15.16 - String filename = "deprecated-list.html"; 15.17 + DocPath filename = DocPaths.DEPRECATED_LIST; 15.18 try { 15.19 DeprecatedListWriter depr = 15.20 new DeprecatedListWriter(configuration, filename); 15.21 @@ -180,7 +180,7 @@ 15.22 private void addIndexLink(DeprecatedAPIListBuilder builder, 15.23 int type, Content contentTree) { 15.24 if (builder.hasDocumentation(type)) { 15.25 - Content li = HtmlTree.LI(getHyperLink("#" + ANCHORS[type], 15.26 + Content li = HtmlTree.LI(getHyperLink(ANCHORS[type], 15.27 getResource(HEADING_KEYS[type]))); 15.28 contentTree.addContent(li); 15.29 }
16.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/EnumConstantWriterImpl.java Thu Nov 01 14:13:13 2012 -0700 16.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/EnumConstantWriterImpl.java Fri Nov 02 17:55:34 2012 -0700 16.3 @@ -263,7 +263,7 @@ 16.4 */ 16.5 protected Content getNavSummaryLink(ClassDoc cd, boolean link) { 16.6 if (link) { 16.7 - return writer.getHyperLink("", (cd == null)? 16.8 + return writer.getHyperLink((cd == null)? 16.9 "enum_constant_summary": 16.10 "enum_constants_inherited_from_class_" + 16.11 configuration().getClassName(cd), 16.12 @@ -278,7 +278,7 @@ 16.13 */ 16.14 protected void addNavDetailLink(boolean link, Content liNav) { 16.15 if (link) { 16.16 - liNav.addContent(writer.getHyperLink("", "enum_constant_detail", 16.17 + liNav.addContent(writer.getHyperLink("enum_constant_detail", 16.18 writer.getResource("doclet.navEnum"))); 16.19 } else { 16.20 liNav.addContent(writer.getResource("doclet.navEnum"));
17.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java Thu Nov 01 14:13:13 2012 -0700 17.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java Fri Nov 02 17:55:34 2012 -0700 17.3 @@ -293,7 +293,7 @@ 17.4 */ 17.5 protected Content getNavSummaryLink(ClassDoc cd, boolean link) { 17.6 if (link) { 17.7 - return writer.getHyperLink("", (cd == null)? 17.8 + return writer.getHyperLink((cd == null)? 17.9 "field_summary": 17.10 "fields_inherited_from_class_" + 17.11 configuration().getClassName(cd), 17.12 @@ -308,7 +308,7 @@ 17.13 */ 17.14 protected void addNavDetailLink(boolean link, Content liNav) { 17.15 if (link) { 17.16 - liNav.addContent(writer.getHyperLink("", "field_detail", 17.17 + liNav.addContent(writer.getHyperLink("field_detail", 17.18 writer.getResource("doclet.navField"))); 17.19 } else { 17.20 liNav.addContent(writer.getResource("doclet.navField"));
18.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/FrameOutputWriter.java Thu Nov 01 14:13:13 2012 -0700 18.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/FrameOutputWriter.java Fri Nov 02 17:55:34 2012 -0700 18.3 @@ -63,7 +63,7 @@ 18.4 * @param filename File to be generated. 18.5 */ 18.6 public FrameOutputWriter(ConfigurationImpl configuration, 18.7 - String filename) throws IOException { 18.8 + DocPath filename) throws IOException { 18.9 super(configuration, filename); 18.10 noOfPackages = configuration.packages.length; 18.11 } 18.12 @@ -77,9 +77,9 @@ 18.13 */ 18.14 public static void generate(ConfigurationImpl configuration) { 18.15 FrameOutputWriter framegen; 18.16 - String filename = ""; 18.17 + DocPath filename = DocPath.empty; 18.18 try { 18.19 - filename = "index.html"; 18.20 + filename = DocPaths.INDEX; 18.21 framegen = new FrameOutputWriter(configuration, filename); 18.22 framegen.generateFrameFile(); 18.23 framegen.close(); 18.24 @@ -92,7 +92,7 @@ 18.25 } 18.26 18.27 /** 18.28 - * Generate the contants in the "index.html" file. Print the frame details 18.29 + * Generate the constants in the "index.html" file. Print the frame details 18.30 * as well as warning if browser is not supporting the Html frames. 18.31 */ 18.32 protected void generateFrameFile() throws IOException { 18.33 @@ -155,8 +155,8 @@ 18.34 * @param contentTree the content tree to which the information will be added 18.35 */ 18.36 private void addAllPackagesFrameTag(Content contentTree) { 18.37 - HtmlTree frame = HtmlTree.FRAME("overview-frame.html", "packageListFrame", 18.38 - configuration.getText("doclet.All_Packages")); 18.39 + HtmlTree frame = HtmlTree.FRAME(DocPaths.OVERVIEW_FRAME.getPath(), 18.40 + "packageListFrame", configuration.getText("doclet.All_Packages")); 18.41 contentTree.addContent(frame); 18.42 } 18.43 18.44 @@ -166,8 +166,8 @@ 18.45 * @param contentTree the content tree to which the information will be added 18.46 */ 18.47 private void addAllClassesFrameTag(Content contentTree) { 18.48 - HtmlTree frame = HtmlTree.FRAME("allclasses-frame.html", "packageFrame", 18.49 - configuration.getText("doclet.All_classes_and_interfaces")); 18.50 + HtmlTree frame = HtmlTree.FRAME(DocPaths.ALLCLASSES_FRAME.getPath(), 18.51 + "packageFrame", configuration.getText("doclet.All_classes_and_interfaces")); 18.52 contentTree.addContent(frame); 18.53 } 18.54 18.55 @@ -177,7 +177,7 @@ 18.56 * @param contentTree the content tree to which the information will be added 18.57 */ 18.58 private void addClassFrameTag(Content contentTree) { 18.59 - HtmlTree frame = HtmlTree.FRAME(configuration.topFile, "classFrame", 18.60 + HtmlTree frame = HtmlTree.FRAME(configuration.topFile.getPath(), "classFrame", 18.61 configuration.getText("doclet.Package_class_and_interface_descriptions"), 18.62 SCROLL_YES); 18.63 contentTree.addContent(frame);
19.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/HelpWriter.java Thu Nov 01 14:13:13 2012 -0700 19.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/HelpWriter.java Fri Nov 02 17:55:34 2012 -0700 19.3 @@ -49,7 +49,7 @@ 19.4 * @param filename File to be generated. 19.5 */ 19.6 public HelpWriter(ConfigurationImpl configuration, 19.7 - String filename) throws IOException { 19.8 + DocPath filename) throws IOException { 19.9 super(configuration, filename); 19.10 } 19.11 19.12 @@ -62,9 +62,9 @@ 19.13 */ 19.14 public static void generate(ConfigurationImpl configuration) { 19.15 HelpWriter helpgen; 19.16 - String filename = ""; 19.17 + DocPath filename = DocPath.empty; 19.18 try { 19.19 - filename = "help-doc.html"; 19.20 + filename = DocPaths.HELP_DOC; 19.21 helpgen = new HelpWriter(configuration, filename); 19.22 helpgen.generateHelpFile(); 19.23 helpgen.close(); 19.24 @@ -113,7 +113,7 @@ 19.25 getResource("doclet.Overview")); 19.26 Content liOverview = HtmlTree.LI(HtmlStyle.blockList, overviewHeading); 19.27 Content line3 = getResource("doclet.Help_line_3", 19.28 - getHyperLinkString("overview-summary.html", 19.29 + getHyperLinkString(DocPaths.OVERVIEW_SUMMARY, 19.30 configuration.getText("doclet.Overview"))); 19.31 Content overviewPara = HtmlTree.P(line3); 19.32 liOverview.addContent(overviewPara); 19.33 @@ -234,7 +234,7 @@ 19.34 getResource("doclet.Help_line_16")); 19.35 Content liTree = HtmlTree.LI(HtmlStyle.blockList, treeHead); 19.36 Content line17 = getResource("doclet.Help_line_17_with_tree_link", 19.37 - getHyperLinkString("overview-tree.html", 19.38 + getHyperLinkString(DocPaths.OVERVIEW_TREE, 19.39 configuration.getText("doclet.Class_Hierarchy"))); 19.40 Content treePara = HtmlTree.P(line17); 19.41 liTree.addContent(treePara); 19.42 @@ -252,7 +252,7 @@ 19.43 getResource("doclet.Deprecated_API")); 19.44 Content liDeprecated = HtmlTree.LI(HtmlStyle.blockList, dHead); 19.45 Content line20 = getResource("doclet.Help_line_20_with_deprecated_api_link", 19.46 - getHyperLinkString("deprecated-list.html", 19.47 + getHyperLinkString(DocPaths.DEPRECATED_LIST, 19.48 configuration.getText("doclet.Deprecated_API"))); 19.49 Content dPara = HtmlTree.P(line20); 19.50 liDeprecated.addContent(dPara); 19.51 @@ -261,10 +261,10 @@ 19.52 if (configuration.createindex) { 19.53 String indexlink; 19.54 if (configuration.splitindex) { 19.55 - indexlink = getHyperLinkString("index-files/index-1.html", 19.56 + indexlink = getHyperLinkString(DocPaths.INDEX_FILES.resolve(DocPaths.indexN(1)), 19.57 configuration.getText("doclet.Index")); 19.58 } else { 19.59 - indexlink = getHyperLinkString("index-all.html", 19.60 + indexlink = getHyperLinkString(DocPaths.INDEX_ALL, 19.61 configuration.getText("doclet.Index")); 19.62 } 19.63 Content indexHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, 19.64 @@ -293,7 +293,7 @@ 19.65 getResource("doclet.All_Classes")); 19.66 Content liAllClasses = HtmlTree.LI(HtmlStyle.blockList, allclassesHead); 19.67 Content line27 = getResource("doclet.Help_line_27", 19.68 - getHyperLinkString("allclasses-noframe.html", 19.69 + getHyperLinkString(DocPaths.ALLCLASSES_NOFRAME, 19.70 configuration.getText("doclet.All_Classes"))); 19.71 Content allclassesPara = HtmlTree.P(line27); 19.72 liAllClasses.addContent(allclassesPara); 19.73 @@ -309,7 +309,7 @@ 19.74 getResource("doclet.Constants_Summary")); 19.75 Content liConst = HtmlTree.LI(HtmlStyle.blockList, constHead); 19.76 Content line29 = getResource("doclet.Help_line_29", 19.77 - getHyperLinkString("constant-values.html", 19.78 + getHyperLinkString(DocPaths.CONSTANT_VALUES, 19.79 configuration.getText("doclet.Constants_Summary"))); 19.80 Content constPara = HtmlTree.P(line29); 19.81 liConst.addContent(constPara); 19.82 @@ -325,6 +325,7 @@ 19.83 * 19.84 * @return a content tree for the help label 19.85 */ 19.86 + @Override 19.87 protected Content getNavLinkHelp() { 19.88 Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, helpLabel); 19.89 return li;
20.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDoclet.java Thu Nov 01 14:13:13 2012 -0700 20.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDoclet.java Fri Nov 02 17:55:34 2012 -0700 20.3 @@ -94,31 +94,22 @@ 20.4 throws Exception { 20.5 super.generateOtherFiles(root, classtree); 20.6 if (configuration.linksource) { 20.7 - if (configuration.destDirName.length() > 0) { 20.8 - SourceToHTMLConverter.convertRoot(configuration, 20.9 - root, configuration.destDirName + File.separator 20.10 - + DocletConstants.SOURCE_OUTPUT_DIR_NAME); 20.11 - } else { 20.12 - SourceToHTMLConverter.convertRoot(configuration, 20.13 - root, DocletConstants.SOURCE_OUTPUT_DIR_NAME); 20.14 - } 20.15 + SourceToHTMLConverter.convertRoot(configuration, 20.16 + root, DocPaths.SOURCE_OUTPUT); 20.17 } 20.18 20.19 - if (configuration.topFile.length() == 0) { 20.20 + if (configuration.topFile.isEmpty()) { 20.21 configuration.standardmessage. 20.22 error("doclet.No_Non_Deprecated_Classes_To_Document"); 20.23 return; 20.24 } 20.25 boolean nodeprecated = configuration.nodeprecated; 20.26 - String configdestdir = configuration.destDirName; 20.27 - String confighelpfile = configuration.helpfile; 20.28 - String configstylefile = configuration.stylesheetfile; 20.29 - performCopy(configdestdir, confighelpfile); 20.30 - performCopy(configdestdir, configstylefile); 20.31 - Util.copyResourceFile(configuration, "background.gif", false); 20.32 - Util.copyResourceFile(configuration, "tab.gif", false); 20.33 - Util.copyResourceFile(configuration, "titlebar.gif", false); 20.34 - Util.copyResourceFile(configuration, "titlebar_end.gif", false); 20.35 + performCopy(configuration.helpfile); 20.36 + performCopy(configuration.stylesheetfile); 20.37 + copyResourceFile("background.gif"); 20.38 + copyResourceFile("tab.gif"); 20.39 + copyResourceFile("titlebar.gif"); 20.40 + copyResourceFile("titlebar_end.gif"); 20.41 // do early to reduce memory footprint 20.42 if (configuration.classuse) { 20.43 ClassUseWriter.generate(configuration, classtree); 20.44 @@ -155,9 +146,8 @@ 20.45 // If a stylesheet file is not specified, copy the default stylesheet 20.46 // and replace newline with platform-specific newline. 20.47 if (configuration.stylesheetfile.length() == 0) { 20.48 - Util.copyFile(configuration, "stylesheet.css", Util.RESOURCESDIR, 20.49 - (configdestdir.isEmpty()) ? 20.50 - System.getProperty("user.dir") : configdestdir, false, true); 20.51 + DocFile f = DocFile.createFileForOutput(configuration, DocPaths.STYLESHEET); 20.52 + f.copyResource(DocPaths.RESOURCES.resolve(DocPaths.STYLESHEET), false, true); 20.53 } 20.54 } 20.55 20.56 @@ -258,29 +248,33 @@ 20.57 return (ConfigurationImpl.getInstance()).validOptions(options, reporter); 20.58 } 20.59 20.60 - private void performCopy(String configdestdir, String filename) { 20.61 + /** 20.62 + * Copy a file in the resources directory to the destination directory. 20.63 + * @param resource The name of the resource file to copy 20.64 + */ 20.65 + private void copyResourceFile(String resource) { 20.66 + DocPath p = DocPaths.RESOURCES.resolve(resource); 20.67 + DocFile f = DocFile.createFileForOutput(configuration, p); 20.68 + f.copyResource(p, false, false); 20.69 + } 20.70 + 20.71 + private void performCopy(String filename) { 20.72 + if (filename.isEmpty()) 20.73 + return; 20.74 + 20.75 try { 20.76 - String destdir = (configdestdir.length() > 0) ? 20.77 - configdestdir + File.separatorChar: ""; 20.78 - if (filename.length() > 0) { 20.79 - File helpstylefile = new File(filename); 20.80 - String parent = helpstylefile.getParent(); 20.81 - String helpstylefilename = (parent == null)? 20.82 - filename: 20.83 - filename.substring(parent.length() + 1); 20.84 - File desthelpfile = new File(destdir + helpstylefilename); 20.85 - if (!desthelpfile.getCanonicalPath().equals( 20.86 - helpstylefile.getCanonicalPath())) { 20.87 - configuration.message. 20.88 - notice((SourcePosition) null, 20.89 - "doclet.Copying_File_0_To_File_1", 20.90 - helpstylefile.toString(), desthelpfile.toString()); 20.91 - Util.copyFile(desthelpfile, helpstylefile); 20.92 - } 20.93 - } 20.94 + DocFile fromfile = DocFile.createFileForInput(configuration, filename); 20.95 + DocPath path = DocPath.create(fromfile.getName()); 20.96 + DocFile toFile = DocFile.createFileForOutput(configuration, path); 20.97 + if (toFile.isSameFile(fromfile)) 20.98 + return; 20.99 + 20.100 + configuration.message.notice((SourcePosition) null, 20.101 + "doclet.Copying_File_0_To_File_1", 20.102 + fromfile.toString(), path.getPath()); 20.103 + toFile.copyFile(fromfile); 20.104 } catch (IOException exc) { 20.105 - configuration.message. 20.106 - error((SourcePosition) null, 20.107 + configuration.message.error((SourcePosition) null, 20.108 "doclet.perform_copy_exception_encountered", 20.109 exc.toString()); 20.110 throw new DocletAbortException();
21.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java Thu Nov 01 14:13:13 2012 -0700 21.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java Fri Nov 02 17:55:34 2012 -0700 21.3 @@ -55,32 +55,24 @@ 21.4 /** 21.5 * Relative path from the file getting generated to the destination 21.6 * directory. For example, if the file getting generated is 21.7 - * "java/lang/Object.html", then the relative path string is "../../". 21.8 + * "java/lang/Object.html", then the path to the root is "../..". 21.9 * This string can be empty if the file getting generated is in 21.10 * the destination directory. 21.11 */ 21.12 - public String relativePath = ""; 21.13 + public final DocPath pathToRoot; 21.14 21.15 /** 21.16 - * Same as relativepath, but normalized to never be empty or 21.17 - * end with a slash. 21.18 - */ 21.19 - public String relativepathNoSlash = ""; 21.20 - 21.21 - /** 21.22 - * Platform-dependent directory path from the current or the 21.23 + * Platform-independent path from the current or the 21.24 * destination directory to the file getting generated. 21.25 * Used when creating the file. 21.26 - * For example, if the file getting generated is 21.27 - * "java/lang/Object.html", then the path string is "java/lang". 21.28 */ 21.29 - public String path = ""; 21.30 + public final DocPath path; 21.31 21.32 /** 21.33 * Name of the file getting generated. If the file getting generated is 21.34 * "java/lang/Object.html", then the filename is "Object.html". 21.35 */ 21.36 - public String filename = ""; 21.37 + public final DocPath filename; 21.38 21.39 /** 21.40 * The display length used for indentation while generating the class page. 21.41 @@ -100,33 +92,15 @@ 21.42 /** 21.43 * Constructor to construct the HtmlStandardWriter object. 21.44 * 21.45 - * @param filename File to be generated. 21.46 + * @param path File to be generated. 21.47 */ 21.48 - public HtmlDocletWriter(ConfigurationImpl configuration, 21.49 - String filename) throws IOException { 21.50 - super(configuration, filename); 21.51 - this.configuration = configuration; 21.52 - this.filename = filename; 21.53 - } 21.54 - 21.55 - /** 21.56 - * Constructor to construct the HtmlStandardWriter object. 21.57 - * 21.58 - * @param path Platform-dependent {@link #path} used when 21.59 - * creating file. 21.60 - * @param filename Name of file to be generated. 21.61 - * @param relativePath Value for the variable {@link #relativePath}. 21.62 - */ 21.63 - public HtmlDocletWriter(ConfigurationImpl configuration, 21.64 - String path, String filename, 21.65 - String relativePath) throws IOException { 21.66 - super(configuration, path, filename); 21.67 + public HtmlDocletWriter(ConfigurationImpl configuration, DocPath path) 21.68 + throws IOException { 21.69 + super(configuration, path); 21.70 this.configuration = configuration; 21.71 this.path = path; 21.72 - this.relativePath = relativePath; 21.73 - this.relativepathNoSlash = 21.74 - DirectoryManager.getPathNoTrailingSlash(this.relativePath); 21.75 - this.filename = filename; 21.76 + this.pathToRoot = path.parent().invert(); 21.77 + this.filename = path.basename(); 21.78 } 21.79 21.80 /** 21.81 @@ -165,8 +139,9 @@ 21.82 int previndex = 0; 21.83 while (true) { 21.84 if (configuration.docrootparent.length() > 0) { 21.85 + final String docroot_parent = "{@docroot}/.."; 21.86 // Search for lowercase version of {@docRoot}/.. 21.87 - index = lowerHtml.indexOf("{@docroot}/..", previndex); 21.88 + index = lowerHtml.indexOf(docroot_parent, previndex); 21.89 // If next {@docRoot}/.. pattern not found, append rest of htmlstr and exit loop 21.90 if (index < 0) { 21.91 buf.append(htmlstr.substring(previndex)); 21.92 @@ -174,17 +149,18 @@ 21.93 } 21.94 // If next {@docroot}/.. pattern found, append htmlstr up to start of tag 21.95 buf.append(htmlstr.substring(previndex, index)); 21.96 - previndex = index + 13; // length for {@docroot}/.. string 21.97 + previndex = index + docroot_parent.length(); 21.98 // Insert docrootparent absolute path where {@docRoot}/.. was located 21.99 21.100 buf.append(configuration.docrootparent); 21.101 // Append slash if next character is not a slash 21.102 if (previndex < htmlstr.length() && htmlstr.charAt(previndex) != '/') { 21.103 - buf.append(DirectoryManager.URL_FILE_SEPARATOR); 21.104 + buf.append('/'); 21.105 } 21.106 } else { 21.107 + final String docroot = "{@docroot}"; 21.108 // Search for lowercase version of {@docRoot} 21.109 - index = lowerHtml.indexOf("{@docroot}", previndex); 21.110 + index = lowerHtml.indexOf(docroot, previndex); 21.111 // If next {@docRoot} tag not found, append rest of htmlstr and exit loop 21.112 if (index < 0) { 21.113 buf.append(htmlstr.substring(previndex)); 21.114 @@ -192,13 +168,12 @@ 21.115 } 21.116 // If next {@docroot} tag found, append htmlstr up to start of tag 21.117 buf.append(htmlstr.substring(previndex, index)); 21.118 - previndex = index + 10; // length for {@docroot} string 21.119 + previndex = index + docroot.length(); 21.120 // Insert relative path where {@docRoot} was located 21.121 - buf.append(relativepathNoSlash); 21.122 + buf.append(pathToRoot.isEmpty() ? "." : pathToRoot.getPath()); 21.123 // Append slash if next character is not a slash 21.124 - if (relativepathNoSlash.length() > 0 && previndex < htmlstr.length() && 21.125 - htmlstr.charAt(previndex) != '/') { 21.126 - buf.append(DirectoryManager.URL_FILE_SEPARATOR); 21.127 + if (previndex < htmlstr.length() && htmlstr.charAt(previndex) != '/') { 21.128 + buf.append('/'); 21.129 } 21.130 } 21.131 } 21.132 @@ -312,7 +287,7 @@ 21.133 */ 21.134 public Content getTargetPackageLink(PackageDoc pd, String target, 21.135 Content label) { 21.136 - return getHyperLink(pathString(pd, "package-summary.html"), "", label, "", target); 21.137 + return getHyperLink(pathString(pd, DocPaths.PACKAGE_SUMMARY), label, "", target); 21.138 } 21.139 21.140 /** 21.141 @@ -432,9 +407,10 @@ 21.142 allClassesId += "navbar_top"; 21.143 Content a = getMarkerAnchor("navbar_top"); 21.144 navDiv.addContent(a); 21.145 - Content skipLinkContent = getHyperLink("", 21.146 - "skip-navbar_top", HtmlTree.EMPTY, configuration.getText( 21.147 - "doclet.Skip_navigation_links"), ""); 21.148 + Content skipLinkContent = getHyperLink(DocLink.fragment("skip-navbar_top"), 21.149 + HtmlTree.EMPTY, 21.150 + configuration.getText("doclet.Skip_navigation_links"), 21.151 + ""); 21.152 navDiv.addContent(skipLinkContent); 21.153 } else { 21.154 body.addContent(HtmlConstants.START_OF_BOTTOM_NAVBAR); 21.155 @@ -442,9 +418,10 @@ 21.156 allClassesId += "navbar_bottom"; 21.157 Content a = getMarkerAnchor("navbar_bottom"); 21.158 navDiv.addContent(a); 21.159 - Content skipLinkContent = getHyperLink("", 21.160 - "skip-navbar_bottom", HtmlTree.EMPTY, configuration.getText( 21.161 - "doclet.Skip_navigation_links"), ""); 21.162 + Content skipLinkContent = getHyperLink(DocLink.fragment("skip-navbar_bottom"), 21.163 + HtmlTree.EMPTY, 21.164 + configuration.getText("doclet.Skip_navigation_links"), 21.165 + ""); 21.166 navDiv.addContent(skipLinkContent); 21.167 } 21.168 if (header) { 21.169 @@ -539,8 +516,8 @@ 21.170 * @return a content tree for the link 21.171 */ 21.172 protected Content getNavLinkContents() { 21.173 - Content linkContent = getHyperLink(relativePath + 21.174 - "overview-summary.html", "", overviewLabel, "", ""); 21.175 + Content linkContent = getHyperLink(pathToRoot.resolve(DocPaths.OVERVIEW_SUMMARY), 21.176 + overviewLabel, "", ""); 21.177 Content li = HtmlTree.LI(linkContent); 21.178 return li; 21.179 } 21.180 @@ -584,10 +561,10 @@ 21.181 * @param prev File name for the prev link 21.182 * @return a content tree for the link 21.183 */ 21.184 - public Content getNavLinkPrevious(String prev) { 21.185 + public Content getNavLinkPrevious(DocPath prev) { 21.186 Content li; 21.187 if (prev != null) { 21.188 - li = HtmlTree.LI(getHyperLink(prev, "", prevLabel, "", "")); 21.189 + li = HtmlTree.LI(getHyperLink(prev, prevLabel, "", "")); 21.190 } 21.191 else 21.192 li = HtmlTree.LI(prevLabel); 21.193 @@ -601,10 +578,10 @@ 21.194 * @param next File name for the next link 21.195 * @return a content tree for the link 21.196 */ 21.197 - public Content getNavLinkNext(String next) { 21.198 + public Content getNavLinkNext(DocPath next) { 21.199 Content li; 21.200 if (next != null) { 21.201 - li = HtmlTree.LI(getHyperLink(next, "", nextLabel, "", "")); 21.202 + li = HtmlTree.LI(getHyperLink(next, nextLabel, "", "")); 21.203 } 21.204 else 21.205 li = HtmlTree.LI(nextLabel); 21.206 @@ -617,9 +594,9 @@ 21.207 * @param link File to be linked, "index.html" 21.208 * @return a content tree for the link 21.209 */ 21.210 - protected Content getNavShowLists(String link) { 21.211 - Content framesContent = getHyperLink(link + "?" + path + 21.212 - filename, "", framesLabel, "", "_top"); 21.213 + protected Content getNavShowLists(DocPath link) { 21.214 + DocLink dl = new DocLink(link, path.getPath(), null); 21.215 + Content framesContent = getHyperLink(dl, framesLabel, "", "_top"); 21.216 Content li = HtmlTree.LI(framesContent); 21.217 return li; 21.218 } 21.219 @@ -630,7 +607,7 @@ 21.220 * @return a content tree for the link 21.221 */ 21.222 protected Content getNavShowLists() { 21.223 - return getNavShowLists(relativePath + "index.html"); 21.224 + return getNavShowLists(pathToRoot.resolve(DocPaths.INDEX)); 21.225 } 21.226 21.227 /** 21.228 @@ -639,8 +616,8 @@ 21.229 * @param link File to be linked 21.230 * @return a content tree for the link 21.231 */ 21.232 - protected Content getNavHideLists(String link) { 21.233 - Content noFramesContent = getHyperLink(link, "", noframesLabel, "", "_top"); 21.234 + protected Content getNavHideLists(DocPath link) { 21.235 + Content noFramesContent = getHyperLink(link, noframesLabel, "", "_top"); 21.236 Content li = HtmlTree.LI(noFramesContent); 21.237 return li; 21.238 } 21.239 @@ -658,11 +635,11 @@ 21.240 PackageDoc[] packages = configuration.root.specifiedPackages(); 21.241 if (packages.length == 1 && configuration.root.specifiedClasses().length == 0) { 21.242 treeLinkContent = getHyperLink(pathString(packages[0], 21.243 - "package-tree.html"), "", treeLabel, 21.244 + DocPaths.PACKAGE_TREE), treeLabel, 21.245 "", ""); 21.246 } else { 21.247 - treeLinkContent = getHyperLink(relativePath + "overview-tree.html", 21.248 - "", treeLabel, "", ""); 21.249 + treeLinkContent = getHyperLink(pathToRoot.resolve(DocPaths.OVERVIEW_TREE), 21.250 + treeLabel, "", ""); 21.251 } 21.252 Content li = HtmlTree.LI(treeLinkContent); 21.253 return li; 21.254 @@ -675,7 +652,7 @@ 21.255 * @return a content tree for the link 21.256 */ 21.257 protected Content getNavLinkMainTree(String label) { 21.258 - Content mainTreeContent = getHyperLink(relativePath + "overview-tree.html", 21.259 + Content mainTreeContent = getHyperLink(pathToRoot.resolve(DocPaths.OVERVIEW_TREE), 21.260 new StringContent(label)); 21.261 Content li = HtmlTree.LI(mainTreeContent); 21.262 return li; 21.263 @@ -697,8 +674,8 @@ 21.264 * @return a content tree for the link 21.265 */ 21.266 protected Content getNavLinkDeprecated() { 21.267 - Content linkContent = getHyperLink(relativePath + 21.268 - "deprecated-list.html", "", deprecatedLabel, "", ""); 21.269 + Content linkContent = getHyperLink(pathToRoot.resolve(DocPaths.DEPRECATED_LIST), 21.270 + deprecatedLabel, "", ""); 21.271 Content li = HtmlTree.LI(linkContent); 21.272 return li; 21.273 } 21.274 @@ -711,8 +688,8 @@ 21.275 * @return a content tree for the link 21.276 */ 21.277 protected Content getNavLinkClassIndex() { 21.278 - Content allClassesContent = getHyperLink(relativePath + 21.279 - AllClassesFrameWriter.OUTPUT_FILE_NAME_NOFRAMES, "", 21.280 + Content allClassesContent = getHyperLink(pathToRoot.resolve( 21.281 + DocPaths.ALLCLASSES_NOFRAME), 21.282 allclassesLabel, "", ""); 21.283 Content li = HtmlTree.LI(allClassesContent); 21.284 return li; 21.285 @@ -724,9 +701,10 @@ 21.286 * @return a content tree for the link 21.287 */ 21.288 protected Content getNavLinkIndex() { 21.289 - Content linkContent = getHyperLink(relativePath +(configuration.splitindex? 21.290 - DirectoryManager.getPath("index-files") + fileseparator: "") + 21.291 - (configuration.splitindex?"index-1.html" : "index-all.html"), "", 21.292 + Content linkContent = getHyperLink(pathToRoot.resolve( 21.293 + (configuration.splitindex 21.294 + ? DocPaths.INDEX_FILES.resolve(DocPaths.indexN(1)) 21.295 + : DocPaths.INDEX_ALL)), 21.296 indexLabel, "", ""); 21.297 Content li = HtmlTree.LI(linkContent); 21.298 return li; 21.299 @@ -740,16 +718,15 @@ 21.300 * @return a content tree for the link 21.301 */ 21.302 protected Content getNavLinkHelp() { 21.303 - String helpfilenm = configuration.helpfile; 21.304 - if (helpfilenm.equals("")) { 21.305 - helpfilenm = "help-doc.html"; 21.306 + String helpfile = configuration.helpfile; 21.307 + DocPath helpfilenm; 21.308 + if (helpfile.isEmpty()) { 21.309 + helpfilenm = DocPaths.HELP_DOC; 21.310 } else { 21.311 - int lastsep; 21.312 - if ((lastsep = helpfilenm.lastIndexOf(File.separatorChar)) != -1) { 21.313 - helpfilenm = helpfilenm.substring(lastsep + 1); 21.314 - } 21.315 + DocFile file = DocFile.createFileForInput(configuration, helpfile); 21.316 + helpfilenm = DocPath.create(file.getName()); 21.317 } 21.318 - Content linkContent = getHyperLink(relativePath + helpfilenm, "", 21.319 + Content linkContent = getHyperLink(pathToRoot.resolve(helpfilenm), 21.320 helpLabel, "", ""); 21.321 Content li = HtmlTree.LI(linkContent); 21.322 return li; 21.323 @@ -884,25 +861,12 @@ 21.324 } 21.325 21.326 /** 21.327 - * Return path to the class page for a classdoc. For example, the class 21.328 - * name is "java.lang.Object" and if the current file getting generated is 21.329 - * "java/io/File.html", then the path string to the class, returned is 21.330 - * "../../java/lang.Object.html". 21.331 - * 21.332 - * @param cd Class to which the path is requested. 21.333 - */ 21.334 - protected String pathToClass(ClassDoc cd) { 21.335 - return pathString(cd.containingPackage(), cd.name() + ".html"); 21.336 - } 21.337 - 21.338 - /** 21.339 - * Return the path to the class page for a classdoc. Works same as 21.340 - * {@link #pathToClass(ClassDoc)}. 21.341 + * Return the path to the class page for a classdoc. 21.342 * 21.343 * @param cd Class to which the path is requested. 21.344 * @param name Name of the file(doesn't include path). 21.345 */ 21.346 - protected String pathString(ClassDoc cd, String name) { 21.347 + protected DocPath pathString(ClassDoc cd, DocPath name) { 21.348 return pathString(cd.containingPackage(), name); 21.349 } 21.350 21.351 @@ -915,10 +879,8 @@ 21.352 * @param pd Package in which the file name is assumed to be. 21.353 * @param name File name, to which path string is. 21.354 */ 21.355 - protected String pathString(PackageDoc pd, String name) { 21.356 - StringBuilder buf = new StringBuilder(relativePath); 21.357 - buf.append(DirectoryManager.getPathToPackage(pd, name)); 21.358 - return buf.toString(); 21.359 + protected DocPath pathString(PackageDoc pd, DocPath name) { 21.360 + return pathToRoot.resolve(DocPath.forPackage(pd).resolve(name)); 21.361 } 21.362 21.363 /** 21.364 @@ -956,12 +918,12 @@ 21.365 } 21.366 } 21.367 if (included || pkg == null) { 21.368 - return getHyperLinkString(pathString(pkg, "package-summary.html"), 21.369 - "", label, isStrong, style); 21.370 + return getHyperLinkString(pathString(pkg, DocPaths.PACKAGE_SUMMARY), 21.371 + label, isStrong, style); 21.372 } else { 21.373 - String crossPkgLink = getCrossPackageLink(Util.getPackageName(pkg)); 21.374 + DocLink crossPkgLink = getCrossPackageLink(Util.getPackageName(pkg)); 21.375 if (crossPkgLink != null) { 21.376 - return getHyperLinkString(crossPkgLink, "", label, isStrong, style); 21.377 + return getHyperLinkString(crossPkgLink, label, isStrong, style); 21.378 } else { 21.379 return label; 21.380 } 21.381 @@ -987,12 +949,12 @@ 21.382 } 21.383 } 21.384 if (included || pkg == null) { 21.385 - return getHyperLink(pathString(pkg, "package-summary.html"), 21.386 - "", label); 21.387 + return getHyperLink(pathString(pkg, DocPaths.PACKAGE_SUMMARY), 21.388 + label); 21.389 } else { 21.390 - String crossPkgLink = getCrossPackageLink(Util.getPackageName(pkg)); 21.391 + DocLink crossPkgLink = getCrossPackageLink(Util.getPackageName(pkg)); 21.392 if (crossPkgLink != null) { 21.393 - return getHyperLink(crossPkgLink, "", label); 21.394 + return getHyperLink(crossPkgLink, label); 21.395 } else { 21.396 return label; 21.397 } 21.398 @@ -1020,10 +982,10 @@ 21.399 //d must be a class doc since in has no containing class. 21.400 cd = (ClassDoc) doc; 21.401 } 21.402 - String href = relativePath + DocletConstants.SOURCE_OUTPUT_DIR_NAME 21.403 - + DirectoryManager.getDirectoryPath(cd.containingPackage()) 21.404 - + cd.name() + ".html#" + SourceToHTMLConverter.getAnchorName(doc); 21.405 - Content linkContent = getHyperLink(href, "", label, "", ""); 21.406 + DocPath href = pathToRoot 21.407 + .resolve(DocPaths.SOURCE_OUTPUT) 21.408 + .resolve(DocPath.forClass(cd)); 21.409 + Content linkContent = getHyperLink(href.fragment(SourceToHTMLConverter.getAnchorName(doc)), label, "", ""); 21.410 htmltree.addContent(linkContent); 21.411 } 21.412 21.413 @@ -1036,7 +998,7 @@ 21.414 */ 21.415 public String getLink(LinkInfoImpl linkInfo) { 21.416 LinkFactoryImpl factory = new LinkFactoryImpl(this); 21.417 - String link = ((LinkOutputImpl) factory.getLinkOutput(linkInfo)).toString(); 21.418 + String link = factory.getLinkOutput(linkInfo).toString(); 21.419 displayLength += linkInfo.displayLength; 21.420 return link; 21.421 } 21.422 @@ -1049,8 +1011,7 @@ 21.423 */ 21.424 public String getTypeParameterLinks(LinkInfoImpl linkInfo) { 21.425 LinkFactoryImpl factory = new LinkFactoryImpl(this); 21.426 - return ((LinkOutputImpl) 21.427 - factory.getTypeParameterLinks(linkInfo, false)).toString(); 21.428 + return factory.getTypeParameterLinks(linkInfo, false).toString(); 21.429 } 21.430 21.431 /************************************************************* 21.432 @@ -1070,10 +1031,10 @@ 21.433 public String getCrossClassLink(String qualifiedClassName, String refMemName, 21.434 String label, boolean strong, String style, 21.435 boolean code) { 21.436 - String className = "", 21.437 - packageName = qualifiedClassName == null ? "" : qualifiedClassName; 21.438 + String className = ""; 21.439 + String packageName = qualifiedClassName == null ? "" : qualifiedClassName; 21.440 int periodIndex; 21.441 - while((periodIndex = packageName.lastIndexOf('.')) != -1) { 21.442 + while ((periodIndex = packageName.lastIndexOf('.')) != -1) { 21.443 className = packageName.substring(periodIndex + 1, packageName.length()) + 21.444 (className.length() > 0 ? "." + className : ""); 21.445 String defaultLabel = code ? codeText(className) : className; 21.446 @@ -1084,11 +1045,12 @@ 21.447 //the -link option. There are ways to determine if an external package 21.448 //exists, but no way to determine if the external class exists. We just 21.449 //have to assume that it does. 21.450 - return getHyperLinkString( 21.451 - configuration.extern.getExternalLink(packageName, relativePath, 21.452 - className + ".html?is-external=true"), 21.453 - refMemName == null ? "" : refMemName, 21.454 - label == null || label.length() == 0 ? defaultLabel : label, 21.455 + DocLink link = configuration.extern.getExternalLink(packageName, pathToRoot, 21.456 + className + ".html", refMemName); 21.457 + return getHyperLinkString(link, 21.458 + (label == null) || label.length() == 0 ? defaultLabel : label, 21.459 + 21.460 + 21.461 strong, style, 21.462 configuration.getText("doclet.Href_Class_Or_Interface_Title", packageName), 21.463 ""); 21.464 @@ -1104,9 +1066,9 @@ 21.465 return configuration.extern.isExternal(cd); 21.466 } 21.467 21.468 - public String getCrossPackageLink(String pkgName) { 21.469 - return configuration.extern.getExternalLink(pkgName, relativePath, 21.470 - "package-summary.html?is-external=true"); 21.471 + public DocLink getCrossPackageLink(String pkgName) { 21.472 + return configuration.extern.getExternalLink(pkgName, pathToRoot, 21.473 + DocPaths.PACKAGE_SUMMARY.getPath()); 21.474 } 21.475 21.476 /** 21.477 @@ -1134,7 +1096,7 @@ 21.478 21.479 /** 21.480 * Retrieve the class link with the package portion of the label in 21.481 - * plain text. If the qualifier is excluded, it willnot be included in the 21.482 + * plain text. If the qualifier is excluded, it will not be included in the 21.483 * link label. 21.484 * 21.485 * @param cd the class to link to. 21.486 @@ -1318,10 +1280,11 @@ 21.487 return getPackageLinkString(refPackage, label, false); 21.488 } else { 21.489 //@see is not referencing an included class or package. Check for cross links. 21.490 - String classCrossLink, packageCrossLink = getCrossPackageLink(refClassName); 21.491 + String classCrossLink; 21.492 + DocLink packageCrossLink = getCrossPackageLink(refClassName); 21.493 if (packageCrossLink != null) { 21.494 //Package cross link found 21.495 - return getHyperLinkString(packageCrossLink, "", 21.496 + return getHyperLinkString(packageCrossLink, 21.497 (label.isEmpty() ? text : label), false); 21.498 } else if ((classCrossLink = getCrossClassLink(refClassName, 21.499 refMemName, label, false, "", !plain)) != null) { 21.500 @@ -1450,7 +1413,7 @@ 21.501 * @param doc the doc for which the comment tags will be generated 21.502 * @param tags the first sentence tags for the doc 21.503 * @param depr true if it is deprecated 21.504 - * @param first true if the first sentenge tags should be added 21.505 + * @param first true if the first sentence tags should be added 21.506 * @param htmltree the documentation tree to which the comment tags will be added 21.507 */ 21.508 private void addCommentTags(Doc doc, Tag[] tags, boolean depr, 21.509 @@ -1561,7 +1524,7 @@ 21.510 21.511 /** 21.512 * Suppose a piece of documentation has a relative link. When you copy 21.513 - * that documetation to another place such as the index or class-use page, 21.514 + * that documentation to another place such as the index or class-use page, 21.515 * that relative link will no longer work. We should redirect those links 21.516 * so that they will work again. 21.517 * <p> 21.518 @@ -1587,21 +1550,17 @@ 21.519 return text; 21.520 } 21.521 21.522 - String redirectPathFromRoot; 21.523 + DocPath redirectPathFromRoot; 21.524 if (doc instanceof ClassDoc) { 21.525 - redirectPathFromRoot = DirectoryManager.getDirectoryPath(((ClassDoc) doc).containingPackage()); 21.526 + redirectPathFromRoot = DocPath.forPackage(((ClassDoc) doc).containingPackage()); 21.527 } else if (doc instanceof MemberDoc) { 21.528 - redirectPathFromRoot = DirectoryManager.getDirectoryPath(((MemberDoc) doc).containingPackage()); 21.529 + redirectPathFromRoot = DocPath.forPackage(((MemberDoc) doc).containingPackage()); 21.530 } else if (doc instanceof PackageDoc) { 21.531 - redirectPathFromRoot = DirectoryManager.getDirectoryPath((PackageDoc) doc); 21.532 + redirectPathFromRoot = DocPath.forPackage((PackageDoc) doc); 21.533 } else { 21.534 return text; 21.535 } 21.536 21.537 - if (! redirectPathFromRoot.endsWith(DirectoryManager.URL_FILE_SEPARATOR)) { 21.538 - redirectPathFromRoot += DirectoryManager.URL_FILE_SEPARATOR; 21.539 - } 21.540 - 21.541 //Redirect all relative links. 21.542 int end, begin = text.toLowerCase().indexOf("<a"); 21.543 if(begin >= 0){ 21.544 @@ -1627,22 +1586,21 @@ 21.545 //might be missing '>' character because the href has an inline tag. 21.546 break; 21.547 } 21.548 - if(textBuff.substring(begin, end).indexOf("\"") != -1){ 21.549 + if (textBuff.substring(begin, end).indexOf("\"") != -1){ 21.550 begin = textBuff.indexOf("\"", begin) + 1; 21.551 end = textBuff.indexOf("\"", begin +1); 21.552 - if(begin == 0 || end == -1){ 21.553 + if (begin == 0 || end == -1){ 21.554 //Link is missing a quote. 21.555 break; 21.556 } 21.557 } 21.558 String relativeLink = textBuff.substring(begin, end); 21.559 - if(!(relativeLink.toLowerCase().startsWith("mailto:") || 21.560 - relativeLink.toLowerCase().startsWith("http:") || 21.561 - relativeLink.toLowerCase().startsWith("https:") || 21.562 - relativeLink.toLowerCase().startsWith("file:"))){ 21.563 - relativeLink = "{@"+(new DocRootTaglet()).getName() + "}" 21.564 - + redirectPathFromRoot 21.565 - + relativeLink; 21.566 + if (!(relativeLink.toLowerCase().startsWith("mailto:") || 21.567 + relativeLink.toLowerCase().startsWith("http:") || 21.568 + relativeLink.toLowerCase().startsWith("https:") || 21.569 + relativeLink.toLowerCase().startsWith("file:"))) { 21.570 + relativeLink = "{@"+(new DocRootTaglet()).getName() + "}/" 21.571 + + redirectPathFromRoot.resolve(relativeLink).getPath(); 21.572 textBuff.replace(begin, end, relativeLink); 21.573 } 21.574 begin = textBuff.toString().toLowerCase().indexOf("<a", begin + 1); 21.575 @@ -1714,18 +1672,17 @@ 21.576 * @return an HtmlTree for the lINK tag which provides the stylesheet location 21.577 */ 21.578 public HtmlTree getStyleSheetProperties() { 21.579 - String filename = configuration.stylesheetfile; 21.580 - if (filename.length() > 0) { 21.581 - File stylefile = new File(filename); 21.582 - String parent = stylefile.getParent(); 21.583 - filename = (parent == null)? 21.584 - filename: 21.585 - filename.substring(parent.length() + 1); 21.586 + String stylesheetfile = configuration.stylesheetfile; 21.587 + DocPath stylesheet; 21.588 + if (stylesheetfile.isEmpty()) { 21.589 + stylesheet = DocPaths.STYLESHEET; 21.590 } else { 21.591 - filename = "stylesheet.css"; 21.592 + DocFile file = DocFile.createFileForInput(configuration, stylesheetfile); 21.593 + stylesheet = DocPath.create(file.getName()); 21.594 } 21.595 - filename = relativePath + filename; 21.596 - HtmlTree link = HtmlTree.LINK("stylesheet", "text/css", filename, "Style"); 21.597 + HtmlTree link = HtmlTree.LINK("stylesheet", "text/css", 21.598 + pathToRoot.resolve(stylesheet).getPath(), 21.599 + "Style"); 21.600 return link; 21.601 } 21.602
22.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/LinkFactoryImpl.java Thu Nov 01 14:13:13 2012 -0700 22.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/LinkFactoryImpl.java Fri Nov 02 17:55:34 2012 -0700 22.3 @@ -78,11 +78,12 @@ 22.4 LinkOutputImpl linkOutput = new LinkOutputImpl(); 22.5 if (classDoc.isIncluded()) { 22.6 if (configuration.isGeneratedDoc(classDoc)) { 22.7 - String filename = pathString(classLinkInfo); 22.8 + DocPath filename = getPath(classLinkInfo); 22.9 if (linkInfo.linkToSelf || 22.10 - !(linkInfo.classDoc.name() + ".html").equals(m_writer.filename)) { 22.11 - linkOutput.append(m_writer.getHyperLinkString(filename, 22.12 - classLinkInfo.where, label.toString(), 22.13 + !(DocPath.forName(classDoc)).equals(m_writer.filename)) { 22.14 + linkOutput.append(m_writer.getHyperLinkString( 22.15 + filename.fragment(classLinkInfo.where), 22.16 + label.toString(), 22.17 classLinkInfo.isStrong, classLinkInfo.styleName, 22.18 title, classLinkInfo.target)); 22.19 if (noLabel && !classLinkInfo.excludeTypeParameterLinks) { 22.20 @@ -161,16 +162,12 @@ 22.21 * 22.22 * @param linkInfo the information about the link. 22.23 */ 22.24 - private String pathString(LinkInfoImpl linkInfo) { 22.25 + private DocPath getPath(LinkInfoImpl linkInfo) { 22.26 if (linkInfo.context == LinkInfoImpl.PACKAGE_FRAME) { 22.27 //Not really necessary to do this but we want to be consistent 22.28 //with 1.4.2 output. 22.29 - return linkInfo.classDoc.name() + ".html"; 22.30 + return DocPath.forName(linkInfo.classDoc); 22.31 } 22.32 - StringBuilder buf = new StringBuilder(m_writer.relativePath); 22.33 - buf.append(DirectoryManager.getPathToPackage( 22.34 - linkInfo.classDoc.containingPackage(), 22.35 - linkInfo.classDoc.name() + ".html")); 22.36 - return buf.toString(); 22.37 + return m_writer.pathToRoot.resolve(DocPath.forClass(linkInfo.classDoc)); 22.38 } 22.39 }
23.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java Thu Nov 01 14:13:13 2012 -0700 23.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java Fri Nov 02 17:55:34 2012 -0700 23.3 @@ -400,7 +400,7 @@ 23.4 */ 23.5 protected Content getNavSummaryLink(ClassDoc cd, boolean link) { 23.6 if (link) { 23.7 - return writer.getHyperLink("", (cd == null)? 23.8 + return writer.getHyperLink((cd == null)? 23.9 "method_summary": 23.10 "methods_inherited_from_class_" + 23.11 configuration().getClassName(cd), 23.12 @@ -415,7 +415,7 @@ 23.13 */ 23.14 protected void addNavDetailLink(boolean link, Content liNav) { 23.15 if (link) { 23.16 - liNav.addContent(writer.getHyperLink("", "method_detail", 23.17 + liNav.addContent(writer.getHyperLink("method_detail", 23.18 writer.getResource("doclet.navMethod"))); 23.19 } else { 23.20 liNav.addContent(writer.getResource("doclet.navMethod"));
24.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/NestedClassWriterImpl.java Thu Nov 01 14:13:13 2012 -0700 24.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/NestedClassWriterImpl.java Fri Nov 02 17:55:34 2012 -0700 24.3 @@ -203,9 +203,8 @@ 24.4 */ 24.5 protected Content getNavSummaryLink(ClassDoc cd, boolean link) { 24.6 if (link) { 24.7 - return writer.getHyperLink("", (cd == null) ? "nested_class_summary": 24.8 - "nested_classes_inherited_from_class_" + 24.9 - cd.qualifiedName(), 24.10 + return writer.getHyperLink((cd == null) ? "nested_class_summary": 24.11 + "nested_classes_inherited_from_class_" + cd.qualifiedName(), 24.12 writer.getResource("doclet.navNested")); 24.13 } else { 24.14 return writer.getResource("doclet.navNested");
25.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/PackageFrameWriter.java Thu Nov 01 14:13:13 2012 -0700 25.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/PackageFrameWriter.java Fri Nov 02 17:55:34 2012 -0700 25.3 @@ -60,17 +60,12 @@ 25.4 private Set<ClassDoc> documentedClasses; 25.5 25.6 /** 25.7 - * The name of the output file. 25.8 - */ 25.9 - public static final String OUTPUT_FILE_NAME = "package-frame.html"; 25.10 - 25.11 - /** 25.12 * Constructor to construct PackageFrameWriter object and to generate 25.13 * "package-frame.html" file in the respective package directory. 25.14 * For example for package "java.lang" this will generate file 25.15 * "package-frame.html" file in the "java/lang" directory. It will also 25.16 * create "java/lang" directory in the current or the destination directory 25.17 - * if it doesen't exist. 25.18 + * if it doesn't exist. 25.19 * 25.20 * @param configuration the configuration of the doclet. 25.21 * @param packageDoc PackageDoc under consideration. 25.22 @@ -78,7 +73,7 @@ 25.23 public PackageFrameWriter(ConfigurationImpl configuration, 25.24 PackageDoc packageDoc) 25.25 throws IOException { 25.26 - super(configuration, DirectoryManager.getDirectoryPath(packageDoc), OUTPUT_FILE_NAME, DirectoryManager.getRelativePath(packageDoc)); 25.27 + super(configuration, DocPath.forPackage(packageDoc).resolve(DocPaths.PACKAGE_FRAME)); 25.28 this.packageDoc = packageDoc; 25.29 if (configuration.root.specifiedPackages().length == 0) { 25.30 documentedClasses = new HashSet<ClassDoc>(Arrays.asList(configuration.root.classes())); 25.31 @@ -113,7 +108,7 @@ 25.32 } catch (IOException exc) { 25.33 configuration.standardmessage.error( 25.34 "doclet.exception_encountered", 25.35 - exc.toString(), OUTPUT_FILE_NAME); 25.36 + exc.toString(), DocPaths.PACKAGE_FRAME.getPath()); 25.37 throw new DocletAbortException(); 25.38 } 25.39 }
26.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexFrameWriter.java Thu Nov 01 14:13:13 2012 -0700 26.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexFrameWriter.java Fri Nov 02 17:55:34 2012 -0700 26.3 @@ -52,7 +52,7 @@ 26.4 * @param filename Name of the package index file to be generated. 26.5 */ 26.6 public PackageIndexFrameWriter(ConfigurationImpl configuration, 26.7 - String filename) throws IOException { 26.8 + DocPath filename) throws IOException { 26.9 super(configuration, filename); 26.10 } 26.11 26.12 @@ -62,7 +62,7 @@ 26.13 */ 26.14 public static void generate(ConfigurationImpl configuration) { 26.15 PackageIndexFrameWriter packgen; 26.16 - String filename = "overview-frame.html"; 26.17 + DocPath filename = DocPaths.OVERVIEW_FRAME; 26.18 try { 26.19 packgen = new PackageIndexFrameWriter(configuration, filename); 26.20 packgen.buildPackageIndexFile("doclet.Window_Overview", false); 26.21 @@ -109,12 +109,12 @@ 26.22 if (pd.name().length() > 0) { 26.23 packageLabel = getPackageLabel(pd.name()); 26.24 packageLinkContent = getHyperLink(pathString(pd, 26.25 - "package-frame.html"), "", packageLabel, "", 26.26 + DocPaths.PACKAGE_FRAME), packageLabel, "", 26.27 "packageFrame"); 26.28 } else { 26.29 packageLabel = new RawHtml("<unnamed package>"); 26.30 - packageLinkContent = getHyperLink("package-frame.html", 26.31 - "", packageLabel, "", "packageFrame"); 26.32 + packageLinkContent = getHyperLink(DocPaths.PACKAGE_FRAME, 26.33 + packageLabel, "", "packageFrame"); 26.34 } 26.35 Content li = HtmlTree.LI(packageLinkContent); 26.36 return li; 26.37 @@ -148,7 +148,7 @@ 26.38 * @param body the Content object to which the all classes link should be added 26.39 */ 26.40 protected void addAllClassesLink(Content body) { 26.41 - Content linkContent = getHyperLink("allclasses-frame.html", "", 26.42 + Content linkContent = getHyperLink(DocPaths.ALLCLASSES_FRAME, 26.43 allclassesLabel, "", "packageFrame"); 26.44 Content div = HtmlTree.DIV(HtmlStyle.indexHeader, linkContent); 26.45 body.addContent(div);
27.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java Thu Nov 01 14:13:13 2012 -0700 27.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java Fri Nov 02 17:55:34 2012 -0700 27.3 @@ -36,7 +36,7 @@ 27.4 /** 27.5 * Generate the package index page "overview-summary.html" for the right-hand 27.6 * frame. A click on the package name on this page will update the same frame 27.7 - * with the "pacakge-summary.html" file for the clicked package. 27.8 + * with the "package-summary.html" file for the clicked package. 27.9 * 27.10 * <p><b>This is NOT part of any supported API. 27.11 * If you write code that depends on this, you do so at your own risk. 27.12 @@ -73,7 +73,7 @@ 27.13 * @see Group 27.14 */ 27.15 public PackageIndexWriter(ConfigurationImpl configuration, 27.16 - String filename) 27.17 + DocPath filename) 27.18 throws IOException { 27.19 super(configuration, filename); 27.20 this.root = configuration.root; 27.21 @@ -88,7 +88,7 @@ 27.22 */ 27.23 public static void generate(ConfigurationImpl configuration) { 27.24 PackageIndexWriter packgen; 27.25 - String filename = "overview-summary.html"; 27.26 + DocPath filename = DocPaths.OVERVIEW_SUMMARY; 27.27 try { 27.28 packgen = new PackageIndexWriter(configuration, filename); 27.29 packgen.buildPackageIndexFile("doclet.Window_Overview_Summary", true); 27.30 @@ -178,7 +178,7 @@ 27.31 Content see = seeLabel; 27.32 see.addContent(" "); 27.33 Content descPara = HtmlTree.P(see); 27.34 - Content descLink = getHyperLink("", "overview_description", 27.35 + Content descLink = getHyperLink(DocLink.fragment("overview_description"), 27.36 descriptionLabel, "", ""); 27.37 descPara.addContent(descLink); 27.38 div.addContent(descPara);
28.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/PackageTreeWriter.java Thu Nov 01 14:13:13 2012 -0700 28.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/PackageTreeWriter.java Fri Nov 02 17:55:34 2012 -0700 28.3 @@ -67,15 +67,14 @@ 28.4 * @throws DocletAbortException 28.5 */ 28.6 public PackageTreeWriter(ConfigurationImpl configuration, 28.7 - String path, String filename, 28.8 + DocPath path, 28.9 PackageDoc packagedoc, 28.10 PackageDoc prev, PackageDoc next) 28.11 throws IOException { 28.12 - super(configuration, path, filename, 28.13 + super(configuration, path, 28.14 new ClassTree( 28.15 configuration.classDocCatalog.allClasses(packagedoc), 28.16 - configuration), 28.17 - packagedoc); 28.18 + configuration)); 28.19 this.packagedoc = packagedoc; 28.20 this.prev = prev; 28.21 this.next = next; 28.22 @@ -96,17 +95,16 @@ 28.23 PackageDoc pkg, PackageDoc prev, 28.24 PackageDoc next, boolean noDeprecated) { 28.25 PackageTreeWriter packgen; 28.26 - String path = DirectoryManager.getDirectoryPath(pkg); 28.27 - String filename = "package-tree.html"; 28.28 + DocPath path = DocPath.forPackage(pkg).resolve(DocPaths.PACKAGE_TREE); 28.29 try { 28.30 - packgen = new PackageTreeWriter(configuration, path, filename, pkg, 28.31 + packgen = new PackageTreeWriter(configuration, path, pkg, 28.32 prev, next); 28.33 packgen.generatePackageTreeFile(); 28.34 packgen.close(); 28.35 } catch (IOException exc) { 28.36 configuration.standardmessage.error( 28.37 "doclet.exception_encountered", 28.38 - exc.toString(), filename); 28.39 + exc.toString(), path.getPath()); 28.40 throw new DocletAbortException(); 28.41 } 28.42 } 28.43 @@ -175,9 +173,8 @@ 28.44 if (prev == null) { 28.45 return getNavLinkPrevious(null); 28.46 } else { 28.47 - String path = DirectoryManager.getRelativePath(packagedoc.name(), 28.48 - prev.name()); 28.49 - return getNavLinkPrevious(path + "package-tree.html"); 28.50 + DocPath path = DocPath.relativePath(packagedoc, prev); 28.51 + return getNavLinkPrevious(path.resolve(DocPaths.PACKAGE_TREE)); 28.52 } 28.53 } 28.54 28.55 @@ -190,9 +187,8 @@ 28.56 if (next == null) { 28.57 return getNavLinkNext(null); 28.58 } else { 28.59 - String path = DirectoryManager.getRelativePath(packagedoc.name(), 28.60 - next.name()); 28.61 - return getNavLinkNext(path + "package-tree.html"); 28.62 + DocPath path = DocPath.relativePath(packagedoc, next); 28.63 + return getNavLinkNext(path.resolve(DocPaths.PACKAGE_TREE)); 28.64 } 28.65 } 28.66 28.67 @@ -202,7 +198,7 @@ 28.68 * @return a content tree for the package link 28.69 */ 28.70 protected Content getNavLinkPackage() { 28.71 - Content linkContent = getHyperLink("package-summary.html", "", 28.72 + Content linkContent = getHyperLink(DocPaths.PACKAGE_SUMMARY, 28.73 packageLabel); 28.74 Content li = HtmlTree.LI(linkContent); 28.75 return li;
29.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/PackageUseWriter.java Thu Nov 01 14:13:13 2012 -0700 29.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/PackageUseWriter.java Fri Nov 02 17:55:34 2012 -0700 29.3 @@ -57,11 +57,9 @@ 29.4 * @throws DocletAbortException 29.5 */ 29.6 public PackageUseWriter(ConfigurationImpl configuration, 29.7 - ClassUseMapper mapper, String filename, 29.8 + ClassUseMapper mapper, DocPath filename, 29.9 PackageDoc pkgdoc) throws IOException { 29.10 - super(configuration, DirectoryManager.getDirectoryPath(pkgdoc), 29.11 - filename, 29.12 - DirectoryManager.getRelativePath(pkgdoc.name())); 29.13 + super(configuration, DocPath.forPackage(pkgdoc).resolve(filename)); 29.14 this.pkgdoc = pkgdoc; 29.15 29.16 // by examining all classes in this package, find what packages 29.17 @@ -98,7 +96,7 @@ 29.18 public static void generate(ConfigurationImpl configuration, 29.19 ClassUseMapper mapper, PackageDoc pkgdoc) { 29.20 PackageUseWriter pkgusegen; 29.21 - String filename = "package-use.html"; 29.22 + DocPath filename = DocPaths.PACKAGE_USE; 29.23 try { 29.24 pkgusegen = new PackageUseWriter(configuration, 29.25 mapper, filename, pkgdoc); 29.26 @@ -232,10 +230,10 @@ 29.27 */ 29.28 protected void addClassRow(ClassDoc usedClass, String packageName, 29.29 Content contentTree) { 29.30 - String path = pathString(usedClass, 29.31 - "class-use/" + usedClass.name() + ".html"); 29.32 + DocPath dp = pathString(usedClass, 29.33 + DocPaths.CLASS_USE.resolve(DocPath.forName(usedClass))); 29.34 Content td = HtmlTree.TD(HtmlStyle.colOne, 29.35 - getHyperLink(path, packageName, new StringContent(usedClass.name()))); 29.36 + getHyperLink(dp.fragment(packageName), new StringContent(usedClass.name()))); 29.37 addIndexComment(usedClass, td); 29.38 contentTree.addContent(td); 29.39 } 29.40 @@ -248,7 +246,7 @@ 29.41 */ 29.42 protected void addPackageUse(PackageDoc pkg, Content contentTree) throws IOException { 29.43 Content tdFirst = HtmlTree.TD(HtmlStyle.colFirst, 29.44 - getHyperLink("", Util.getPackageName(pkg), 29.45 + getHyperLink(Util.getPackageName(pkg), 29.46 new RawHtml(Util.getPackageName(pkg)))); 29.47 contentTree.addContent(tdFirst); 29.48 HtmlTree tdLast = new HtmlTree(HtmlTag.TD); 29.49 @@ -288,7 +286,7 @@ 29.50 * @return a content tree for the package link 29.51 */ 29.52 protected Content getNavLinkPackage() { 29.53 - Content linkContent = getHyperLink("package-summary.html", "", 29.54 + Content linkContent = getHyperLink(DocPaths.PACKAGE_SUMMARY, 29.55 packageLabel); 29.56 Content li = HtmlTree.LI(linkContent); 29.57 return li; 29.58 @@ -310,7 +308,7 @@ 29.59 * @return a content tree for the tree link 29.60 */ 29.61 protected Content getNavLinkTree() { 29.62 - Content linkContent = getHyperLink("package-tree.html", "", 29.63 + Content linkContent = getHyperLink(DocPaths.PACKAGE_TREE, 29.64 treeLabel); 29.65 Content li = HtmlTree.LI(linkContent); 29.66 return li;
30.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/PackageWriterImpl.java Thu Nov 01 14:13:13 2012 -0700 30.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/PackageWriterImpl.java Fri Nov 02 17:55:34 2012 -0700 30.3 @@ -65,17 +65,12 @@ 30.4 protected PackageDoc packageDoc; 30.5 30.6 /** 30.7 - * The name of the output file. 30.8 - */ 30.9 - private static final String OUTPUT_FILE_NAME = "package-summary.html"; 30.10 - 30.11 - /** 30.12 * Constructor to construct PackageWriter object and to generate 30.13 * "package-summary.html" file in the respective package directory. 30.14 * For example for package "java.lang" this will generate file 30.15 * "package-summary.html" file in the "java/lang" directory. It will also 30.16 * create "java/lang" directory in the current or the destination directory 30.17 - * if it doesen't exist. 30.18 + * if it doesn't exist. 30.19 * 30.20 * @param configuration the configuration of the doclet. 30.21 * @param packageDoc PackageDoc under consideration. 30.22 @@ -83,25 +78,15 @@ 30.23 * @param next Next package in the sorted array. 30.24 */ 30.25 public PackageWriterImpl(ConfigurationImpl configuration, 30.26 - PackageDoc packageDoc, PackageDoc prev, PackageDoc next) 30.27 - throws IOException { 30.28 - super(configuration, DirectoryManager.getDirectoryPath(packageDoc), OUTPUT_FILE_NAME, 30.29 - DirectoryManager.getRelativePath(packageDoc.name())); 30.30 + PackageDoc packageDoc, PackageDoc prev, PackageDoc next) 30.31 + throws IOException { 30.32 + super(configuration, DocPath.forPackage(packageDoc).resolve(DocPaths.PACKAGE_SUMMARY)); 30.33 this.prev = prev; 30.34 this.next = next; 30.35 this.packageDoc = packageDoc; 30.36 } 30.37 30.38 /** 30.39 - * Return the name of the output file. 30.40 - * 30.41 - * @return the name of the output file. 30.42 - */ 30.43 - public String getOutputFileName() { 30.44 - return OUTPUT_FILE_NAME; 30.45 - } 30.46 - 30.47 - /** 30.48 * {@inheritDoc} 30.49 */ 30.50 public Content getPackageHeader(String heading) { 30.51 @@ -127,7 +112,7 @@ 30.52 addSummaryComment(packageDoc, docSummaryDiv); 30.53 div.addContent(docSummaryDiv); 30.54 Content space = getSpace(); 30.55 - Content descLink = getHyperLink("", "package_description", 30.56 + Content descLink = getHyperLink(DocLink.fragment("package_description"), 30.57 descriptionLabel, "", ""); 30.58 Content descPara = new HtmlTree(HtmlTag.P, seeLabel, space, descLink); 30.59 div.addContent(descPara); 30.60 @@ -265,7 +250,7 @@ 30.61 * @return a content tree for the class use link 30.62 */ 30.63 protected Content getNavLinkClassUse() { 30.64 - Content useLink = getHyperLink("package-use.html", "", 30.65 + Content useLink = getHyperLink(DocPaths.PACKAGE_USE, 30.66 useLabel, "", ""); 30.67 Content li = HtmlTree.LI(useLink); 30.68 return li; 30.69 @@ -281,9 +266,8 @@ 30.70 if (prev == null) { 30.71 li = HtmlTree.LI(prevpackageLabel); 30.72 } else { 30.73 - String path = DirectoryManager.getRelativePath(packageDoc.name(), 30.74 - prev.name()); 30.75 - li = HtmlTree.LI(getHyperLink(path + "package-summary.html", "", 30.76 + DocPath path = DocPath.relativePath(packageDoc, prev); 30.77 + li = HtmlTree.LI(getHyperLink(path.resolve(DocPaths.PACKAGE_SUMMARY), 30.78 prevpackageLabel, "", "")); 30.79 } 30.80 return li; 30.81 @@ -299,9 +283,8 @@ 30.82 if (next == null) { 30.83 li = HtmlTree.LI(nextpackageLabel); 30.84 } else { 30.85 - String path = DirectoryManager.getRelativePath(packageDoc.name(), 30.86 - next.name()); 30.87 - li = HtmlTree.LI(getHyperLink(path + "package-summary.html", "", 30.88 + DocPath path = DocPath.relativePath(packageDoc, next); 30.89 + li = HtmlTree.LI(getHyperLink(path.resolve(DocPaths.PACKAGE_SUMMARY), 30.90 nextpackageLabel, "", "")); 30.91 } 30.92 return li; 30.93 @@ -314,7 +297,7 @@ 30.94 * @return a content tree for the tree link 30.95 */ 30.96 protected Content getNavLinkTree() { 30.97 - Content useLink = getHyperLink("package-tree.html", "", 30.98 + Content useLink = getHyperLink(DocPaths.PACKAGE_TREE, 30.99 treeLabel, "", ""); 30.100 Content li = HtmlTree.LI(useLink); 30.101 return li;
31.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/SerializedFormWriterImpl.java Thu Nov 01 14:13:13 2012 -0700 31.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/SerializedFormWriterImpl.java Fri Nov 02 17:55:34 2012 -0700 31.3 @@ -29,6 +29,7 @@ 31.4 import com.sun.javadoc.*; 31.5 import com.sun.tools.doclets.formats.html.markup.*; 31.6 import com.sun.tools.doclets.internal.toolkit.*; 31.7 +import com.sun.tools.doclets.internal.toolkit.util.DocPaths; 31.8 import com.sun.tools.doclets.internal.toolkit.util.DocletAbortException; 31.9 31.10 /** 31.11 @@ -44,14 +45,12 @@ 31.12 public class SerializedFormWriterImpl extends SubWriterHolderWriter 31.13 implements SerializedFormWriter { 31.14 31.15 - private static final String FILE_NAME = "serialized-form.html"; 31.16 - 31.17 /** 31.18 * @throws IOException 31.19 * @throws DocletAbortException 31.20 */ 31.21 public SerializedFormWriterImpl() throws IOException { 31.22 - super(ConfigurationImpl.getInstance(), FILE_NAME); 31.23 + super(ConfigurationImpl.getInstance(), DocPaths.SERIALIZED_FORM); 31.24 } 31.25 31.26 /**
32.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/SingleIndexWriter.java Thu Nov 01 14:13:13 2012 -0700 32.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/SingleIndexWriter.java Fri Nov 02 17:55:34 2012 -0700 32.3 @@ -55,11 +55,9 @@ 32.4 * @param indexbuilder Unicode based Index from {@link IndexBuilder} 32.5 */ 32.6 public SingleIndexWriter(ConfigurationImpl configuration, 32.7 - String filename, 32.8 + DocPath filename, 32.9 IndexBuilder indexbuilder) throws IOException { 32.10 super(configuration, filename, indexbuilder); 32.11 - relativepathNoSlash = "."; 32.12 - relativePath = "./"; 32.13 } 32.14 32.15 /** 32.16 @@ -71,7 +69,7 @@ 32.17 public static void generate(ConfigurationImpl configuration, 32.18 IndexBuilder indexbuilder) { 32.19 SingleIndexWriter indexgen; 32.20 - String filename = "index-all.html"; 32.21 + DocPath filename = DocPaths.INDEX_ALL; 32.22 try { 32.23 indexgen = new SingleIndexWriter(configuration, 32.24 filename, indexbuilder); 32.25 @@ -117,7 +115,7 @@ 32.26 for (int i = 0; i < indexbuilder.elements().length; i++) { 32.27 String unicode = (indexbuilder.elements())[i].toString(); 32.28 contentTree.addContent( 32.29 - getHyperLink("#_" + unicode + "_", new StringContent(unicode))); 32.30 + getHyperLink("_" + unicode + "_", new StringContent(unicode))); 32.31 contentTree.addContent(getSpace()); 32.32 } 32.33 }
33.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/SourceToHTMLConverter.java Thu Nov 01 14:13:13 2012 -0700 33.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/SourceToHTMLConverter.java Fri Nov 02 17:55:34 2012 -0700 33.3 @@ -26,11 +26,13 @@ 33.4 package com.sun.tools.doclets.formats.html; 33.5 33.6 import java.io.*; 33.7 + 33.8 import javax.tools.FileObject; 33.9 + 33.10 import com.sun.javadoc.*; 33.11 +import com.sun.tools.doclets.formats.html.markup.*; 33.12 import com.sun.tools.doclets.internal.toolkit.*; 33.13 import com.sun.tools.doclets.internal.toolkit.util.*; 33.14 -import com.sun.tools.doclets.formats.html.markup.*; 33.15 33.16 /** 33.17 * Converts Java Source Code to HTML. 33.18 @@ -62,7 +64,7 @@ 33.19 * Relative path from the documentation root to the file that is being 33.20 * generated. 33.21 */ 33.22 - private static String relativePath = ""; 33.23 + private static DocPath relativePath = DocPath.empty; 33.24 33.25 /** 33.26 * Source is converted to HTML using static methods below. 33.27 @@ -77,7 +79,7 @@ 33.28 * @param outputdir the name of the directory to output to. 33.29 */ 33.30 public static void convertRoot(ConfigurationImpl configuration, RootDoc rd, 33.31 - String outputdir) { 33.32 + DocPath outputdir) { 33.33 if (rd == null || outputdir == null) { 33.34 return; 33.35 } 33.36 @@ -95,8 +97,7 @@ 33.37 // package files to HTML. 33.38 if (!(configuration.nodeprecated && 33.39 (Util.isDeprecated(cds[i]) || Util.isDeprecated(cds[i].containingPackage())))) 33.40 - convertClass(configuration, cds[i], 33.41 - getPackageOutputDir(outputdir, cds[i].containingPackage())); 33.42 + convertClass(configuration, cds[i], outputdir); 33.43 } 33.44 } 33.45 33.46 @@ -108,11 +109,10 @@ 33.47 * @param outputdir the name of the directory to output to. 33.48 */ 33.49 public static void convertPackage(ConfigurationImpl configuration, PackageDoc pd, 33.50 - String outputdir) { 33.51 - if (pd == null || outputdir == null) { 33.52 + DocPath outputdir) { 33.53 + if (pd == null) { 33.54 return; 33.55 } 33.56 - String classOutputdir = getPackageOutputDir(outputdir, pd); 33.57 ClassDoc[] cds = pd.allClasses(); 33.58 for (int i = 0; i < cds.length; i++) { 33.59 // If -nodeprecated option is set and the class is marked as deprecated, 33.60 @@ -120,23 +120,11 @@ 33.61 // containing package deprecation since it is already check in 33.62 // the calling method above. 33.63 if (!(configuration.nodeprecated && Util.isDeprecated(cds[i]))) 33.64 - convertClass(configuration, cds[i], classOutputdir); 33.65 + convertClass(configuration, cds[i], outputdir); 33.66 } 33.67 } 33.68 33.69 /** 33.70 - * Return the directory write output to for the given package. 33.71 - * 33.72 - * @param outputDir the directory to output to. 33.73 - * @param pd the Package to generate output for. 33.74 - * @return the package output directory as a String. 33.75 - */ 33.76 - private static String getPackageOutputDir(String outputDir, PackageDoc pd) { 33.77 - return outputDir + File.separator + 33.78 - DirectoryManager.getDirectoryPath(pd) + File.separator; 33.79 - } 33.80 - 33.81 - /** 33.82 * Convert the given Class to an HTML. 33.83 * 33.84 * @param configuration the configuration. 33.85 @@ -144,8 +132,8 @@ 33.86 * @param outputdir the name of the directory to output to. 33.87 */ 33.88 public static void convertClass(ConfigurationImpl configuration, ClassDoc cd, 33.89 - String outputdir) { 33.90 - if (cd == null || outputdir == null) { 33.91 + DocPath outputdir) { 33.92 + if (cd == null) { 33.93 return; 33.94 } 33.95 try { 33.96 @@ -168,8 +156,9 @@ 33.97 LineNumberReader reader = new LineNumberReader(r); 33.98 int lineno = 1; 33.99 String line; 33.100 - relativePath = DirectoryManager.getRelativePath(DocletConstants.SOURCE_OUTPUT_DIR_NAME) + 33.101 - DirectoryManager.getRelativePath(cd.containingPackage()); 33.102 + relativePath = DocPaths.SOURCE_OUTPUT 33.103 + .resolve(DocPath.forPackage(cd)) 33.104 + .invert(); 33.105 Content body = getHeader(); 33.106 Content pre = new HtmlTree(HtmlTag.PRE); 33.107 try { 33.108 @@ -184,8 +173,8 @@ 33.109 addBlankLines(pre); 33.110 Content div = HtmlTree.DIV(HtmlStyle.sourceContainer, pre); 33.111 body.addContent(div); 33.112 - writeToFile(body, outputdir, cd.name(), configuration); 33.113 - } catch (Exception e){ 33.114 + writeToFile(body, outputdir.resolve(DocPath.forClass(cd)), configuration); 33.115 + } catch (IOException e) { 33.116 e.printStackTrace(); 33.117 } 33.118 } 33.119 @@ -194,12 +183,11 @@ 33.120 * Write the output to the file. 33.121 * 33.122 * @param body the documentation content to be written to the file. 33.123 - * @param outputDir the directory to output to. 33.124 - * @param className the name of the class that I am converting to HTML. 33.125 + * @param path the path for the file. 33.126 * @param configuration the Doclet configuration to pass notices to. 33.127 */ 33.128 - private static void writeToFile(Content body, String outputDir, 33.129 - String className, ConfigurationImpl configuration) throws IOException { 33.130 + private static void writeToFile(Content body, DocPath path, 33.131 + ConfigurationImpl configuration) throws IOException { 33.132 Content htmlDocType = DocType.Transitional(); 33.133 Content head = new HtmlTree(HtmlTag.HEAD); 33.134 head.addContent(HtmlTree.TITLE(new StringContent( 33.135 @@ -208,15 +196,15 @@ 33.136 Content htmlTree = HtmlTree.HTML(configuration.getLocale().getLanguage(), 33.137 head, body); 33.138 Content htmlDocument = new HtmlDocument(htmlDocType, htmlTree); 33.139 - File dir = new File(outputDir); 33.140 - dir.mkdirs(); 33.141 - File newFile = new File(dir, className + ".html"); 33.142 - configuration.message.notice("doclet.Generating_0", newFile.getPath()); 33.143 - FileOutputStream fout = new FileOutputStream(newFile); 33.144 - BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fout)); 33.145 - bw.write(htmlDocument.toString()); 33.146 - bw.close(); 33.147 - fout.close(); 33.148 + configuration.message.notice("doclet.Generating_0", path.getPath()); 33.149 + DocFile df = DocFile.createFileForOutput(configuration, path); 33.150 + Writer w = df.openWriter(); 33.151 + try { 33.152 + htmlDocument.write(w, true); 33.153 + } finally { 33.154 + w.close(); 33.155 + } 33.156 + 33.157 } 33.158 33.159 /** 33.160 @@ -227,17 +215,15 @@ 33.161 */ 33.162 public static HtmlTree getStyleSheetProperties(ConfigurationImpl configuration) { 33.163 String filename = configuration.stylesheetfile; 33.164 + DocPath stylesheet; 33.165 if (filename.length() > 0) { 33.166 - File stylefile = new File(filename); 33.167 - String parent = stylefile.getParent(); 33.168 - filename = (parent == null)? 33.169 - filename: 33.170 - filename.substring(parent.length() + 1); 33.171 + DocFile file = DocFile.createFileForInput(configuration, filename); 33.172 + stylesheet = DocPath.create(file.getName()); 33.173 } else { 33.174 - filename = "stylesheet.css"; 33.175 + stylesheet = DocPaths.STYLESHEET; 33.176 } 33.177 - filename = relativePath + filename; 33.178 - HtmlTree link = HtmlTree.LINK("stylesheet", "text/css", filename, "Style"); 33.179 + DocPath p = relativePath.resolve(stylesheet); 33.180 + HtmlTree link = HtmlTree.LINK("stylesheet", "text/css", p.getPath(), "Style"); 33.181 return link; 33.182 } 33.183
34.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/SplitIndexWriter.java Thu Nov 01 14:13:13 2012 -0700 34.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/SplitIndexWriter.java Fri Nov 02 17:55:34 2012 -0700 34.3 @@ -62,15 +62,13 @@ 34.4 * from this file. 34.5 * 34.6 * @param path Path to the file which is getting generated. 34.7 - * @param filename Name of the file which is getting genrated. 34.8 - * @param relpath Relative path from this file to the current directory. 34.9 * @param indexbuilder Unicode based Index from {@link IndexBuilder} 34.10 */ 34.11 public SplitIndexWriter(ConfigurationImpl configuration, 34.12 - String path, String filename, 34.13 - String relpath, IndexBuilder indexbuilder, 34.14 + DocPath path, 34.15 + IndexBuilder indexbuilder, 34.16 int prev, int next) throws IOException { 34.17 - super(configuration, path, filename, relpath, indexbuilder); 34.18 + super(configuration, path, indexbuilder); 34.19 this.prev = prev; 34.20 this.next = next; 34.21 } 34.22 @@ -85,17 +83,16 @@ 34.23 public static void generate(ConfigurationImpl configuration, 34.24 IndexBuilder indexbuilder) { 34.25 SplitIndexWriter indexgen; 34.26 - String filename = ""; 34.27 - String path = DirectoryManager.getPath("index-files"); 34.28 - String relpath = DirectoryManager.getRelativePath("index-files"); 34.29 + DocPath filename = DocPath.empty; 34.30 + DocPath path = DocPaths.INDEX_FILES; 34.31 try { 34.32 for (int i = 0; i < indexbuilder.elements().length; i++) { 34.33 int j = i + 1; 34.34 int prev = (j == 1)? -1: i; 34.35 int next = (j == indexbuilder.elements().length)? -1: j + 1; 34.36 - filename = "index-" + j +".html"; 34.37 + filename = DocPaths.indexN(j); 34.38 indexgen = new SplitIndexWriter(configuration, 34.39 - path, filename, relpath, 34.40 + path.resolve(filename), 34.41 indexbuilder, prev, next); 34.42 indexgen.generateIndexFile((Character)indexbuilder. 34.43 elements()[i]); 34.44 @@ -104,7 +101,7 @@ 34.45 } catch (IOException exc) { 34.46 configuration.standardmessage.error( 34.47 "doclet.exception_encountered", 34.48 - exc.toString(), filename); 34.49 + exc.toString(), filename.getPath()); 34.50 throw new DocletAbortException(); 34.51 } 34.52 } 34.53 @@ -142,7 +139,7 @@ 34.54 Object[] unicodeChars = indexbuilder.elements(); 34.55 for (int i = 0; i < unicodeChars.length; i++) { 34.56 int j = i + 1; 34.57 - contentTree.addContent(getHyperLink("index-" + j + ".html", 34.58 + contentTree.addContent(getHyperLink(DocPaths.indexN(j), 34.59 new StringContent(unicodeChars[i].toString()))); 34.60 contentTree.addContent(getSpace()); 34.61 } 34.62 @@ -159,7 +156,7 @@ 34.63 return HtmlTree.LI(prevletterLabel); 34.64 } 34.65 else { 34.66 - Content prevLink = getHyperLink("index-" + prev + ".html", "", 34.67 + Content prevLink = getHyperLink(DocPaths.indexN(prev), 34.68 prevletterLabel); 34.69 return HtmlTree.LI(prevLink); 34.70 } 34.71 @@ -176,7 +173,7 @@ 34.72 return HtmlTree.LI(nextletterLabel); 34.73 } 34.74 else { 34.75 - Content nextLink = getHyperLink("index-" + next + ".html","", 34.76 + Content nextLink = getHyperLink(DocPaths.indexN(next), 34.77 nextletterLabel); 34.78 return HtmlTree.LI(nextLink); 34.79 }
35.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/SubWriterHolderWriter.java Thu Nov 01 14:13:13 2012 -0700 35.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/SubWriterHolderWriter.java Fri Nov 02 17:55:34 2012 -0700 35.3 @@ -54,18 +54,11 @@ 35.4 */ 35.5 public abstract class SubWriterHolderWriter extends HtmlDocletWriter { 35.6 35.7 - public SubWriterHolderWriter(ConfigurationImpl configuration, 35.8 - String filename) throws IOException { 35.9 + public SubWriterHolderWriter(ConfigurationImpl configuration, DocPath filename) 35.10 + throws IOException { 35.11 super(configuration, filename); 35.12 } 35.13 35.14 - 35.15 - public SubWriterHolderWriter(ConfigurationImpl configuration, 35.16 - String path, String filename, String relpath) 35.17 - throws IOException { 35.18 - super(configuration, path, filename, relpath); 35.19 - } 35.20 - 35.21 /** 35.22 * Add the summary header. 35.23 *
36.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/TagletWriterImpl.java Thu Nov 01 14:13:13 2012 -0700 36.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/TagletWriterImpl.java Fri Nov 02 17:55:34 2012 -0700 36.3 @@ -66,8 +66,10 @@ 36.4 public TagletOutput getDocRootOutput() { 36.5 if (htmlWriter.configuration.docrootparent.length() > 0) 36.6 return new TagletOutputImpl(htmlWriter.configuration.docrootparent); 36.7 + else if (htmlWriter.pathToRoot.isEmpty()) 36.8 + return new TagletOutputImpl("."); 36.9 else 36.10 - return new TagletOutputImpl(htmlWriter.relativepathNoSlash); 36.11 + return new TagletOutputImpl(htmlWriter.pathToRoot.getPath()); 36.12 } 36.13 36.14 /** 36.15 @@ -170,19 +172,24 @@ 36.16 htmlWriter instanceof ClassWriterImpl) { 36.17 //Automatically add link to constant values page for constant fields. 36.18 result = addSeeHeader(result); 36.19 - result += htmlWriter.getHyperLinkString(htmlWriter.relativePath + 36.20 - ConfigurationImpl.CONSTANTS_FILE_NAME 36.21 - + "#" + ((ClassWriterImpl) htmlWriter).getClassDoc().qualifiedName() 36.22 - + "." + ((FieldDoc) holder).name(), 36.23 - htmlWriter.configuration.getText("doclet.Constants_Summary")); 36.24 + DocPath constantsPath = 36.25 + htmlWriter.pathToRoot.resolve(DocPaths.CONSTANT_VALUES); 36.26 + String whichConstant = 36.27 + ((ClassWriterImpl) htmlWriter).getClassDoc().qualifiedName() + "." + ((FieldDoc) holder).name(); 36.28 + DocLink link = constantsPath.fragment(whichConstant); 36.29 + result += htmlWriter.getHyperLinkString(link, 36.30 + htmlWriter.configuration.getText("doclet.Constants_Summary"), 36.31 + false); 36.32 } 36.33 if (holder.isClass() && ((ClassDoc)holder).isSerializable()) { 36.34 //Automatically add link to serialized form page for serializable classes. 36.35 if ((SerializedFormBuilder.serialInclude(holder) && 36.36 SerializedFormBuilder.serialInclude(((ClassDoc)holder).containingPackage()))) { 36.37 result = addSeeHeader(result); 36.38 - result += htmlWriter.getHyperLinkString(htmlWriter.relativePath + "serialized-form.html", 36.39 - ((ClassDoc)holder).qualifiedName(), htmlWriter.configuration.getText("doclet.Serialized_Form"), false); 36.40 + DocPath serialPath = htmlWriter.pathToRoot.resolve(DocPaths.SERIALIZED_FORM); 36.41 + DocLink link = serialPath.fragment(((ClassDoc)holder).qualifiedName()); 36.42 + result += htmlWriter.getHyperLinkString(link, 36.43 + htmlWriter.configuration.getText("doclet.Serialized_Form"), false); 36.44 } 36.45 } 36.46 return result.equals("") ? null : new TagletOutputImpl(result + "</dd>");
37.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/TreeWriter.java Thu Nov 01 14:13:13 2012 -0700 37.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/TreeWriter.java Fri Nov 02 17:55:34 2012 -0700 37.3 @@ -67,7 +67,7 @@ 37.4 * @param classtree the tree being built. 37.5 */ 37.6 public TreeWriter(ConfigurationImpl configuration, 37.7 - String filename, ClassTree classtree) 37.8 + DocPath filename, ClassTree classtree) 37.9 throws IOException { 37.10 super(configuration, filename, classtree); 37.11 packages = configuration.packages; 37.12 @@ -84,7 +84,7 @@ 37.13 public static void generate(ConfigurationImpl configuration, 37.14 ClassTree classtree) { 37.15 TreeWriter treegen; 37.16 - String filename = "overview-tree.html"; 37.17 + DocPath filename = DocPaths.OVERVIEW_TREE; 37.18 try { 37.19 treegen = new TreeWriter(configuration, filename, classtree); 37.20 treegen.generateTreeFile(); 37.21 @@ -144,9 +144,9 @@ 37.22 (configuration.nodeprecated && Util.isDeprecated(packages[i]))) { 37.23 continue; 37.24 } 37.25 - String link = pathString(packages[i], "package-tree.html"); 37.26 + DocPath link = pathString(packages[i], DocPaths.PACKAGE_TREE); 37.27 Content li = HtmlTree.LI(getHyperLink( 37.28 - link, "", new StringContent(packages[i].name()))); 37.29 + link, new StringContent(packages[i].name()))); 37.30 if (i < packages.length - 1) { 37.31 li.addContent(", "); 37.32 }
38.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java Thu Nov 01 14:13:13 2012 -0700 38.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java Fri Nov 02 17:55:34 2012 -0700 38.3 @@ -31,6 +31,9 @@ 38.4 import com.sun.javadoc.*; 38.5 import com.sun.tools.doclets.formats.html.ConfigurationImpl; 38.6 import com.sun.tools.doclets.internal.toolkit.*; 38.7 +import com.sun.tools.doclets.internal.toolkit.util.DocLink; 38.8 +import com.sun.tools.doclets.internal.toolkit.util.DocPath; 38.9 +import com.sun.tools.doclets.internal.toolkit.util.DocPaths; 38.10 38.11 38.12 /** 38.13 @@ -56,25 +59,11 @@ 38.14 * 38.15 * @param filename String file name. 38.16 */ 38.17 - public HtmlDocWriter(Configuration configuration, 38.18 - String filename) throws IOException { 38.19 - super(configuration, 38.20 - null, configuration.destDirName + filename, 38.21 - configuration.docencoding); 38.22 - // use File to normalize file separators 38.23 + public HtmlDocWriter(Configuration configuration, DocPath filename) 38.24 + throws IOException { 38.25 + super(configuration, filename); 38.26 configuration.message.notice("doclet.Generating_0", 38.27 - new File(configuration.destDirName, filename)); 38.28 - } 38.29 - 38.30 - public HtmlDocWriter(Configuration configuration, 38.31 - String path, String filename) throws IOException { 38.32 - super(configuration, 38.33 - configuration.destDirName + path, filename, 38.34 - configuration.docencoding); 38.35 - // use File to normalize file separators 38.36 - configuration.message.notice("doclet.Generating_0", 38.37 - new File(configuration.destDirName, 38.38 - ((path.length() > 0)? path + File.separator: "") + filename)); 38.39 + filename.resolveAgainst(configuration.destDirName)); 38.40 } 38.41 38.42 /** 38.43 @@ -86,77 +75,99 @@ 38.44 * Return Html Hyper Link string. 38.45 * 38.46 * @param link String name of the file. 38.47 - * @param where Position of the link in the file. Character '#' is not 38.48 - * needed. 38.49 * @param label Tag for the link. 38.50 * @param strong Boolean that sets label to strong. 38.51 * @return String Hyper Link. 38.52 */ 38.53 - public String getHyperLinkString(String link, String where, 38.54 + public String getHyperLinkString(DocPath link, 38.55 String label, boolean strong) { 38.56 - return getHyperLinkString(link, where, label, strong, "", "", ""); 38.57 + return getHyperLinkString(link, label, strong, "", "", ""); 38.58 + } 38.59 + 38.60 + public String getHyperLinkString(DocLink link, 38.61 + String label, boolean strong) { 38.62 + return getHyperLinkString(link, label, strong, "", "", ""); 38.63 } 38.64 38.65 /** 38.66 * Get Html Hyper Link string. 38.67 * 38.68 * @param link String name of the file. 38.69 - * @param where Position of the link in the file. Character '#' is not 38.70 - * needed. 38.71 * @param label Tag for the link. 38.72 * @param strong Boolean that sets label to strong. 38.73 * @param stylename String style of text defined in style sheet. 38.74 * @return String Hyper Link. 38.75 */ 38.76 - public String getHyperLinkString(String link, String where, 38.77 + public String getHyperLinkString(DocPath link, 38.78 String label, boolean strong, 38.79 String stylename) { 38.80 - return getHyperLinkString(link, where, label, strong, stylename, "", ""); 38.81 + return getHyperLinkString(link, label, strong, stylename, "", ""); 38.82 + } 38.83 + 38.84 + public String getHyperLinkString(DocLink link, 38.85 + String label, boolean strong, 38.86 + String stylename) { 38.87 + return getHyperLinkString(link, label, strong, stylename, "", ""); 38.88 + } 38.89 + 38.90 + /** 38.91 + * Get Html Hyper Link string. 38.92 + * 38.93 + * @param where Position of the link in the file. Character '#' is not 38.94 + * needed. 38.95 + * @param label Tag for the link. 38.96 + * @return a content tree for the hyper link 38.97 + */ 38.98 + public Content getHyperLink(String where, 38.99 + Content label) { 38.100 + return getHyperLink(DocLink.fragment(where), label, "", ""); 38.101 } 38.102 38.103 /** 38.104 * Get Html Hyper Link string. 38.105 * 38.106 * @param link String name of the file. 38.107 - * @param where Position of the link in the file. Character '#' is not 38.108 - * needed. 38.109 * @param label Tag for the link. 38.110 * @return a content tree for the hyper link 38.111 */ 38.112 - public Content getHyperLink(String link, String where, 38.113 + public Content getHyperLink(DocPath link, 38.114 Content label) { 38.115 - return getHyperLink(link, where, label, "", ""); 38.116 + return getHyperLink(link, label, "", ""); 38.117 + } 38.118 + 38.119 + public Content getHyperLink(DocLink link, 38.120 + Content label) { 38.121 + return getHyperLink(link, label, "", ""); 38.122 } 38.123 38.124 /** 38.125 * Get Html Hyper Link string. 38.126 * 38.127 * @param link String name of the file. 38.128 - * @param where Position of the link in the file. Character '#' is not 38.129 - * needed. 38.130 * @param label Tag for the link. 38.131 * @param strong Boolean that sets label to strong. 38.132 * @param stylename String style of text defined in style sheet. 38.133 - * @param title String that describes the link's content for accessibility. 38.134 + * @param title String that describes the links content for accessibility. 38.135 * @param target Target frame. 38.136 * @return String Hyper Link. 38.137 */ 38.138 - public String getHyperLinkString(String link, String where, 38.139 + public String getHyperLinkString(DocPath link, 38.140 + String label, boolean strong, 38.141 + String stylename, String title, String target) { 38.142 + return getHyperLinkString(new DocLink(link), label, strong, 38.143 + stylename, title, target); 38.144 + } 38.145 + 38.146 + public String getHyperLinkString(DocLink link, 38.147 String label, boolean strong, 38.148 String stylename, String title, String target) { 38.149 StringBuilder retlink = new StringBuilder(); 38.150 - retlink.append("<a href=\""); 38.151 - retlink.append(link); 38.152 - if (where != null && where.length() != 0) { 38.153 - retlink.append("#"); 38.154 - retlink.append(where); 38.155 - } 38.156 - retlink.append("\""); 38.157 + retlink.append("<a href=\"").append(link).append('"'); 38.158 if (title != null && title.length() != 0) { 38.159 - retlink.append(" title=\"").append(title).append("\""); 38.160 + retlink.append(" title=\"").append(title).append('"'); 38.161 } 38.162 if (target != null && target.length() != 0) { 38.163 - retlink.append(" target=\"").append(target).append("\""); 38.164 + retlink.append(" target=\"").append(target).append('"'); 38.165 } 38.166 retlink.append(">"); 38.167 if (stylename != null && stylename.length() != 0) { 38.168 @@ -182,19 +193,19 @@ 38.169 * Get Html Hyper Link. 38.170 * 38.171 * @param link String name of the file. 38.172 - * @param where Position of the link in the file. Character '#' is not 38.173 - * needed. 38.174 * @param label Tag for the link. 38.175 * @param title String that describes the link's content for accessibility. 38.176 * @param target Target frame. 38.177 * @return a content tree for the hyper link. 38.178 */ 38.179 - public Content getHyperLink(String link, String where, 38.180 + public Content getHyperLink(DocPath link, 38.181 Content label, String title, String target) { 38.182 - if (where != null && where.length() != 0) { 38.183 - link += "#" + where; 38.184 - } 38.185 - HtmlTree anchor = HtmlTree.A(link, label); 38.186 + return getHyperLink(new DocLink(link), label, title, target); 38.187 + } 38.188 + 38.189 + public Content getHyperLink(DocLink link, 38.190 + Content label, String title, String target) { 38.191 + HtmlTree anchor = HtmlTree.A(link.toString(), label); 38.192 if (title != null && title.length() != 0) { 38.193 anchor.addAttr(HtmlAttr.TITLE, title); 38.194 } 38.195 @@ -205,25 +216,14 @@ 38.196 } 38.197 38.198 /** 38.199 - * Get a hyperlink to a file. 38.200 - * 38.201 - * @param link String name of the file 38.202 - * @param label Label for the link 38.203 - * @return a content for the hyperlink to the file 38.204 - */ 38.205 - public Content getHyperLink(String link, Content label) { 38.206 - return getHyperLink(link, "", label); 38.207 - } 38.208 - 38.209 - /** 38.210 * Get link string without positioning in the file. 38.211 * 38.212 * @param link String name of the file. 38.213 * @param label Tag for the link. 38.214 * @return Strign Hyper link. 38.215 */ 38.216 - public String getHyperLinkString(String link, String label) { 38.217 - return getHyperLinkString(link, "", label, false); 38.218 + public String getHyperLinkString(DocPath link, String label) { 38.219 + return getHyperLinkString(link, label, false); 38.220 } 38.221 38.222 /**
39.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java Thu Nov 01 14:13:13 2012 -0700 39.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java Fri Nov 02 17:55:34 2012 -0700 39.3 @@ -47,22 +47,11 @@ 39.4 public class HtmlWriter { 39.5 39.6 /** 39.7 - * Name of the file, to which this writer is writing to. 39.8 - */ 39.9 - protected final String htmlFilename; 39.10 - 39.11 - /** 39.12 * The window title of this file 39.13 */ 39.14 protected String winTitle; 39.15 39.16 /** 39.17 - * URL file separator string("/"). 39.18 - */ 39.19 - public static final String fileseparator = 39.20 - DirectoryManager.URL_FILE_SEPARATOR; 39.21 - 39.22 - /** 39.23 * The configuration 39.24 */ 39.25 protected Configuration configuration; 39.26 @@ -160,20 +149,15 @@ 39.27 * 39.28 * @param path The directory path to be created for this file 39.29 * or null if none to be created. 39.30 - * @param filename File Name to which the PrintWriter will 39.31 - * do the Output. 39.32 - * @param docencoding Encoding to be used for this file. 39.33 * @exception IOException Exception raised by the FileWriter is passed on 39.34 * to next level. 39.35 * @exception UnsupportedEncodingException Exception raised by the 39.36 * OutputStreamWriter is passed on to next level. 39.37 */ 39.38 - public HtmlWriter(Configuration configuration, 39.39 - String path, String filename, String docencoding) 39.40 - throws IOException, UnsupportedEncodingException { 39.41 - writer = Util.genWriter(configuration, path, filename, docencoding); 39.42 + public HtmlWriter(Configuration configuration, DocPath path) 39.43 + throws IOException, UnsupportedEncodingException { 39.44 + writer = DocFile.createFileForOutput(configuration, path).openWriter(); 39.45 this.configuration = configuration; 39.46 - htmlFilename = filename; 39.47 this.memberDetailsListPrinted = false; 39.48 packageTableHeader = new String[] { 39.49 configuration.getText("doclet.Package"),
40.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/AbstractDoclet.java Thu Nov 01 14:13:13 2012 -0700 40.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/AbstractDoclet.java Fri Nov 02 17:55:34 2012 -0700 40.3 @@ -106,7 +106,7 @@ 40.4 40.5 /** 40.6 * Start the generation of files. Call generate methods in the individual 40.7 - * writers, which will in turn genrate the documentation files. Call the 40.8 + * writers, which will in turn generate the documentation files. Call the 40.9 * TreeWriter generation first to ensure the Class Hierarchy is built 40.10 * first and then can be used in the later generation. 40.11 * 40.12 @@ -124,17 +124,7 @@ 40.13 ClassTree classtree = new ClassTree(configuration, configuration.nodeprecated); 40.14 40.15 generateClassFiles(root, classtree); 40.16 - if (configuration.sourcepath != null && configuration.sourcepath.length() > 0) { 40.17 - StringTokenizer pathTokens = new StringTokenizer(configuration.sourcepath, 40.18 - String.valueOf(File.pathSeparatorChar)); 40.19 - boolean first = true; 40.20 - while(pathTokens.hasMoreTokens()){ 40.21 - Util.copyDocFiles(configuration, 40.22 - pathTokens.nextToken() + File.separator, 40.23 - DocletConstants.DOC_FILES_DIR_NAME, first); 40.24 - first = false; 40.25 - } 40.26 - } 40.27 + Util.copyDocFiles(configuration, DocPaths.DOC_FILES); 40.28 40.29 PackageListWriter.generate(configuration); 40.30 generatePackageFiles(classtree);
41.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java Thu Nov 01 14:13:13 2012 -0700 41.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java Fri Nov 02 17:55:34 2012 -0700 41.3 @@ -408,11 +408,11 @@ 41.4 group.checkPackageGroups(os[1], os[2]); 41.5 } else if (opt.equals("-link")) { 41.6 String url = os[1]; 41.7 - extern.url(url, url, root, false); 41.8 + extern.link(url, url, root, false); 41.9 } else if (opt.equals("-linkoffline")) { 41.10 String url = os[1]; 41.11 String pkglisturl = os[2]; 41.12 - extern.url(url, pkglisturl, root, true); 41.13 + extern.link(url, pkglisturl, root, true); 41.14 } 41.15 } 41.16 if (sourcepath.length() == 0) { 41.17 @@ -456,7 +456,7 @@ 41.18 tagletManager.addCustomTag(args[1], tagletpath); 41.19 continue; 41.20 } 41.21 - String[] tokens = Util.tokenize(args[1], 41.22 + String[] tokens = tokenize(args[1], 41.23 TagletManager.SIMPLE_TAGLET_OPT_SEPERATOR, 3); 41.24 if (tokens.length == 1) { 41.25 String tagName = args[1]; 41.26 @@ -480,6 +480,47 @@ 41.27 } 41.28 } 41.29 41.30 + /** 41.31 + * Given a string, return an array of tokens. The separator can be escaped 41.32 + * with the '\' character. The '\' character may also be escaped by the 41.33 + * '\' character. 41.34 + * 41.35 + * @param s the string to tokenize. 41.36 + * @param separator the separator char. 41.37 + * @param maxTokens the maximum number of tokens returned. If the 41.38 + * max is reached, the remaining part of s is appended 41.39 + * to the end of the last token. 41.40 + * 41.41 + * @return an array of tokens. 41.42 + */ 41.43 + private String[] tokenize(String s, char separator, int maxTokens) { 41.44 + List<String> tokens = new ArrayList<String>(); 41.45 + StringBuilder token = new StringBuilder (); 41.46 + boolean prevIsEscapeChar = false; 41.47 + for (int i = 0; i < s.length(); i += Character.charCount(i)) { 41.48 + int currentChar = s.codePointAt(i); 41.49 + if (prevIsEscapeChar) { 41.50 + // Case 1: escaped character 41.51 + token.appendCodePoint(currentChar); 41.52 + prevIsEscapeChar = false; 41.53 + } else if (currentChar == separator && tokens.size() < maxTokens-1) { 41.54 + // Case 2: separator 41.55 + tokens.add(token.toString()); 41.56 + token = new StringBuilder(); 41.57 + } else if (currentChar == '\\') { 41.58 + // Case 3: escape character 41.59 + prevIsEscapeChar = true; 41.60 + } else { 41.61 + // Case 4: regular character 41.62 + token.appendCodePoint(currentChar); 41.63 + } 41.64 + } 41.65 + if (token.length() > 0) { 41.66 + tokens.add(token.toString()); 41.67 + } 41.68 + return tokens.toArray(new String[] {}); 41.69 + } 41.70 + 41.71 private void addToSet(Set<String> s, String str){ 41.72 StringTokenizer st = new StringTokenizer(str, ":"); 41.73 String current; 41.74 @@ -532,12 +573,12 @@ 41.75 String opt = os[0].toLowerCase(); 41.76 if (opt.equals("-d")) { 41.77 String destdirname = addTrailingFileSep(os[1]); 41.78 - File destDir = new File(destdirname); 41.79 + DocFile destDir = DocFile.createFileForDirectory(this, destdirname); 41.80 if (!destDir.exists()) { 41.81 //Create the output directory (in case it doesn't exist yet) 41.82 reporter.printNotice(getText("doclet.dest_dir_create", 41.83 destdirname)); 41.84 - (new File(destdirname)).mkdirs(); 41.85 + destDir.mkdirs(); 41.86 } else if (!destDir.isDirectory()) { 41.87 reporter.printError(getText( 41.88 "doclet.destination_directory_not_directory_0", 41.89 @@ -711,7 +752,7 @@ 41.90 public InputStream getBuilderXML() throws FileNotFoundException { 41.91 return builderXMLPath == null ? 41.92 Configuration.class.getResourceAsStream(DEFAULT_BUILDER_XML) : 41.93 - new FileInputStream(new File(builderXMLPath)); 41.94 + DocFile.createFileForInput(this, builderXMLPath).openInputStream(); 41.95 } 41.96 41.97 /**
42.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/PackageSummaryWriter.java Thu Nov 01 14:13:13 2012 -0700 42.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/PackageSummaryWriter.java Fri Nov 02 17:55:34 2012 -0700 42.3 @@ -45,13 +45,6 @@ 42.4 public interface PackageSummaryWriter { 42.5 42.6 /** 42.7 - * Return the name of the output file. 42.8 - * 42.9 - * @return the name of the output file. 42.10 - */ 42.11 - public abstract String getOutputFileName(); 42.12 - 42.13 - /** 42.14 * Get the header for the summary. 42.15 * 42.16 * @param heading Package name.
43.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeBuilder.java Thu Nov 01 14:13:13 2012 -0700 43.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeBuilder.java Fri Nov 02 17:55:34 2012 -0700 43.3 @@ -140,12 +140,7 @@ 43.4 //Only copy doc files dir if the containing package is not 43.5 //documented AND if we have not documented a class from the same 43.6 //package already. Otherwise, we are making duplicate copies. 43.7 - Util.copyDocFiles(configuration, 43.8 - Util.getPackageSourcePath(configuration, 43.9 - annotationTypeDoc.containingPackage()) + 43.10 - DirectoryManager.getDirectoryPath( 43.11 - annotationTypeDoc.containingPackage()) 43.12 - + File.separator, DocletConstants.DOC_FILES_DIR_NAME, true); 43.13 + Util.copyDocFiles(configuration, containingPackage); 43.14 containingPackagesSeen.add(containingPackage.name()); 43.15 } 43.16 }
44.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java Thu Nov 01 14:13:13 2012 -0700 44.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java Fri Nov 02 17:55:34 2012 -0700 44.3 @@ -266,11 +266,7 @@ 44.4 //Only copy doc files dir if the containing package is not 44.5 //documented AND if we have not documented a class from the same 44.6 //package already. Otherwise, we are making duplicate copies. 44.7 - Util.copyDocFiles(configuration, 44.8 - Util.getPackageSourcePath(configuration, 44.9 - classDoc.containingPackage()) + 44.10 - DirectoryManager.getDirectoryPath(classDoc.containingPackage()) 44.11 - + File.separator, DocletConstants.DOC_FILES_DIR_NAME, true); 44.12 + Util.copyDocFiles(configuration, containingPackage); 44.13 containingPackagesSeen.add(containingPackage.name()); 44.14 } 44.15 }
45.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PackageSummaryBuilder.java Thu Nov 01 14:13:13 2012 -0700 45.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PackageSummaryBuilder.java Fri Nov 02 17:55:34 2012 -0700 45.3 @@ -119,13 +119,7 @@ 45.4 packageWriter.addPackageFooter(contentTree); 45.5 packageWriter.printDocument(contentTree); 45.6 packageWriter.close(); 45.7 - Util.copyDocFiles( 45.8 - configuration, 45.9 - Util.getPackageSourcePath(configuration, packageDoc), 45.10 - DirectoryManager.getDirectoryPath(packageDoc) 45.11 - + File.separator 45.12 - + DocletConstants.DOC_FILES_DIR_NAME, 45.13 - true); 45.14 + Util.copyDocFiles(configuration, packageDoc); 45.15 } 45.16 45.17 /**
46.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java Thu Nov 01 14:13:13 2012 -0700 46.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java Fri Nov 02 17:55:34 2012 -0700 46.3 @@ -474,6 +474,8 @@ 46.4 Arrays.sort(tags); 46.5 int tagsLength = tags.length; 46.6 for (int i = 0; i < tagsLength; i++) { 46.7 + if (tags[i].fieldName() == null || tags[i].fieldType() == null) // ignore malformed @serialField tags 46.8 + continue; 46.9 Content fieldsContentTree = fieldWriter.getFieldsContentHeader( 46.10 (i == tagsLength - 1)); 46.11 fieldWriter.addMemberHeader(tags[i].fieldTypeDoc(),
47.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletManager.java Thu Nov 01 14:13:13 2012 -0700 47.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletManager.java Fri Nov 02 17:55:34 2012 -0700 47.3 @@ -161,7 +161,7 @@ 47.4 * @param message the message retriever to print warnings. 47.5 */ 47.6 public TagletManager(boolean nosince, boolean showversion, 47.7 - boolean showauthor, MessageRetriever message){ 47.8 + boolean showauthor, MessageRetriever message) { 47.9 overridenStandardTags = new HashSet<String>(); 47.10 potentiallyConflictingTags = new HashSet<String>(); 47.11 standardTags = new HashSet<String>(); 47.12 @@ -253,47 +253,17 @@ 47.13 * @param path the search path string 47.14 * @return the resulting array of directory and JAR file URLs 47.15 */ 47.16 - private static URL[] pathToURLs(String path) { 47.17 - StringTokenizer st = new StringTokenizer(path, File.pathSeparator); 47.18 - URL[] urls = new URL[st.countTokens()]; 47.19 - int count = 0; 47.20 - while (st.hasMoreTokens()) { 47.21 - URL url = fileToURL(new File(st.nextToken())); 47.22 - if (url != null) { 47.23 - urls[count++] = url; 47.24 + private URL[] pathToURLs(String path) { 47.25 + Set<URL> urls = new LinkedHashSet<URL>(); 47.26 + for (String s: path.split(File.pathSeparator)) { 47.27 + if (s.isEmpty()) continue; 47.28 + try { 47.29 + urls.add(new File(s).getAbsoluteFile().toURI().toURL()); 47.30 + } catch (MalformedURLException e) { 47.31 + message.error("doclet.MalformedURL", s); 47.32 } 47.33 } 47.34 - urls = Arrays.copyOf(urls, count); 47.35 - return urls; 47.36 - } 47.37 - 47.38 - /** 47.39 - * Returns the directory or JAR file URL corresponding to the specified 47.40 - * local file name. 47.41 - * 47.42 - * @param file the File object 47.43 - * @return the resulting directory or JAR file URL, or null if unknown 47.44 - */ 47.45 - private static URL fileToURL(File file) { 47.46 - String name; 47.47 - try { 47.48 - name = file.getCanonicalPath(); 47.49 - } catch (IOException e) { 47.50 - name = file.getAbsolutePath(); 47.51 - } 47.52 - name = name.replace(File.separatorChar, '/'); 47.53 - if (!name.startsWith("/")) { 47.54 - name = "/" + name; 47.55 - } 47.56 - // If the file does not exist, then assume that it's a directory 47.57 - if (!file.isFile()) { 47.58 - name = name + "/"; 47.59 - } 47.60 - try { 47.61 - return new URL("file", "", name); 47.62 - } catch (MalformedURLException e) { 47.63 - throw new IllegalArgumentException("file"); 47.64 - } 47.65 + return urls.toArray(new URL[urls.size()]); 47.66 } 47.67 47.68
48.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DirectoryManager.java Thu Nov 01 14:13:13 2012 -0700 48.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 48.3 @@ -1,317 +0,0 @@ 48.4 -/* 48.5 - * Copyright (c) 1998, 2012, 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. Oracle designates this 48.11 - * particular file as subject to the "Classpath" exception as provided 48.12 - * by Oracle in the LICENSE file that accompanied this code. 48.13 - * 48.14 - * This code is distributed in the hope that it will be useful, but WITHOUT 48.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 48.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 48.17 - * version 2 for more details (a copy is included in the LICENSE file that 48.18 - * accompanied this code). 48.19 - * 48.20 - * You should have received a copy of the GNU General Public License version 48.21 - * 2 along with this work; if not, write to the Free Software Foundation, 48.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 48.23 - * 48.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 48.25 - * or visit www.oracle.com if you need additional information or have any 48.26 - * questions. 48.27 - */ 48.28 - 48.29 -package com.sun.tools.doclets.internal.toolkit.util; 48.30 - 48.31 -import com.sun.tools.doclets.internal.toolkit.*; 48.32 -import com.sun.javadoc.*; 48.33 -import java.io.*; 48.34 - 48.35 - 48.36 -/** 48.37 - * Handle the directory creations and the path string generations. 48.38 - * All static - never instaniated. 48.39 - * 48.40 - * This code is not part of an API. 48.41 - * It is implementation that is subject to change. 48.42 - * Do not use it as an API 48.43 - * 48.44 - * @since 1.2 48.45 - * @author Atul M Dambalkar 48.46 - */ 48.47 -public class DirectoryManager { 48.48 - 48.49 - /** 48.50 - * The file separator string, "/", used in the formation of the URL path. 48.51 - */ 48.52 - public static final String URL_FILE_SEPARATOR = "/"; 48.53 - 48.54 - /** 48.55 - * Never instaniated. 48.56 - */ 48.57 - private DirectoryManager() { 48.58 - } 48.59 - 48.60 - /** 48.61 - * Given a PackageDoc, return its URL path string. 48.62 - * 48.63 - * @param pd PackageDoc 48.64 - * @see #getPath(String) 48.65 - */ 48.66 - public static String createPathString(PackageDoc pd) { 48.67 - if (pd == null) { 48.68 - return ""; 48.69 - } 48.70 - return getPath(pd.name()); 48.71 - } 48.72 - 48.73 - /** 48.74 - * Given a ClassDoc, return its URL path string. 48.75 - * 48.76 - * @param cd ClassDoc 48.77 - * @see #getPath(String) 48.78 - */ 48.79 - public static String createPathString(ClassDoc cd) { 48.80 - if (cd == null) { 48.81 - return ""; 48.82 - } 48.83 - PackageDoc pd = cd.containingPackage(); 48.84 - return (pd == null)? "": getPath(pd.name()); 48.85 - } 48.86 - 48.87 - /** 48.88 - * Given a PackageDoc, return the corresponding directory name 48.89 - * with the platform-dependent file separator between subdirectory names. 48.90 - * For example, if name of the package is "java.lang" , then it 48.91 - * returns "java/lang" on Unix and "java\lang" on Windows. 48.92 - * If name of the package contains no dot, then the value 48.93 - * will be returned unchanged. Because package names cannot 48.94 - * end in a dot, the return value will never end with a slash. 48.95 - * <p> 48.96 - * Also see getPath for the URL separator version of this method 48.97 - * that takes a string instead of a PackageDoc. 48.98 - * 48.99 - * @param pd the PackageDoc 48.100 - * @return the platform-dependent directory path for the package 48.101 - */ 48.102 - public static String getDirectoryPath(PackageDoc pd) { 48.103 - return pd == null || pd.name().length() == 0 ? "" : getDirectoryPath(pd.name()); 48.104 - } 48.105 - 48.106 - /** 48.107 - * Given a package name, return the corresponding directory name 48.108 - * with the platform-dependent file separator between subdirectory names. 48.109 - * For example, if name of the package is "java.lang" , then it 48.110 - * returns "java/lang" on Unix and "java\lang" on Windows. 48.111 - * If name of the package contains no dot, then the value 48.112 - * will be returned unchanged. Because package names cannot 48.113 - * end in a dot, the return value will never end with a slash. 48.114 - * <p> 48.115 - * Also see getPath for the URL separator version of this method 48.116 - * that takes a string instead of a PackageDoc. 48.117 - * 48.118 - * @param packageName the name of the package 48.119 - * @return the platform-dependent directory path for the package 48.120 - */ 48.121 - public static String getDirectoryPath(String packageName) { 48.122 - if (packageName == null || packageName.length() == 0) { 48.123 - return ""; 48.124 - } 48.125 - StringBuilder pathstr = new StringBuilder(); 48.126 - for (int i = 0; i < packageName.length(); i++) { 48.127 - char ch = packageName.charAt(i); 48.128 - if (ch == '.') { 48.129 - pathstr.append(URL_FILE_SEPARATOR); 48.130 - } else { 48.131 - pathstr.append(ch); 48.132 - } 48.133 - } 48.134 - if (pathstr.length() > 0 && ! pathstr.toString().endsWith(URL_FILE_SEPARATOR)) { 48.135 - pathstr.append(URL_FILE_SEPARATOR); 48.136 - } 48.137 - return pathstr.toString(); 48.138 - } 48.139 - 48.140 - /** 48.141 - * Given a package name (a string), return the path string, 48.142 - * with the URL separator "/" separating the subdirectory names. 48.143 - * If name of the package contains no dot, then the value 48.144 - * will be returned unchanged. Because package names cannot 48.145 - * end in a dot, the return value will never end with a slash. 48.146 - * <p> 48.147 - * For example if the string is "com.sun.javadoc" then the URL 48.148 - * path string will be "com/sun/javadoc". 48.149 - * 48.150 - * @param name the package name as a String 48.151 - * @return the String URL path 48.152 - */ 48.153 - public static String getPath(String name) { 48.154 - if (name == null || name.length() == 0) { 48.155 - return ""; 48.156 - } 48.157 - StringBuilder pathstr = new StringBuilder(); 48.158 - for (int i = 0; i < name.length(); i++) { 48.159 - char ch = name.charAt(i); 48.160 - if (ch == '.') { 48.161 - pathstr.append(URL_FILE_SEPARATOR); 48.162 - } else { 48.163 - pathstr.append(ch); 48.164 - } 48.165 - } 48.166 - return pathstr.toString(); 48.167 - } 48.168 - 48.169 - /** 48.170 - * Given two package names as strings, return the relative path 48.171 - * from the package directory corresponding to the first string 48.172 - * to the package directory corresponding to the second string, 48.173 - * with the URL file separator "/" separating subdirectory names. 48.174 - * <p> 48.175 - * For example, if the parameter "from" is "java.lang" 48.176 - * and parameter "to" is "java.applet", return string 48.177 - * "../../java/applet". 48.178 - * 48.179 - * @param from the package name from which path is calculated 48.180 - * @param to the package name to which path is calculated 48.181 - * @return relative path between "from" and "to" with URL 48.182 - * separators 48.183 - * @see #getRelativePath(String) 48.184 - * @see #getPath(String) 48.185 - */ 48.186 - public static String getRelativePath(String from, String to) { 48.187 - StringBuilder pathstr = new StringBuilder(); 48.188 - pathstr.append(getRelativePath(from)); 48.189 - pathstr.append(getPath(to)); 48.190 - pathstr.append(URL_FILE_SEPARATOR); 48.191 - return pathstr.toString(); 48.192 - } 48.193 - 48.194 - /** 48.195 - * Given a package name as a string, return relative path string 48.196 - * from the corresponding package directory to the root of 48.197 - * the documentation, using the URL separator "/" between 48.198 - * subdirectory names. 48.199 - * <p> 48.200 - * For example, if the string "from" is "java.lang", 48.201 - * return "../../" 48.202 - * 48.203 - * @param from the package 48.204 - * @return String relative path from "from". 48.205 - * @see #getRelativePath(String, String) 48.206 - */ 48.207 - public static String getRelativePath(PackageDoc from) { 48.208 - return from == null || from.name().length() == 0 ? "" : getRelativePath(from.name()); 48.209 - } 48.210 - 48.211 - /** 48.212 - * Given a package name as a string, return relative path string 48.213 - * from the corresponding package directory to the root of 48.214 - * the documentation, using the URL separator "/" between 48.215 - * subdirectory names. 48.216 - * <p> 48.217 - * For example, if the string "from" is "java.lang", 48.218 - * return "../../" 48.219 - * 48.220 - * @param from the package name 48.221 - * @return String relative path from "from". 48.222 - * @see #getRelativePath(String, String) 48.223 - */ 48.224 - public static String getRelativePath(String from) { 48.225 - if (from == null || from.length() == 0) { 48.226 - return ""; 48.227 - } 48.228 - StringBuilder pathstr = new StringBuilder(); 48.229 - for (int i = 0; i < from.length(); i++) { 48.230 - char ch = from.charAt(i); 48.231 - if (ch == '.') { 48.232 - pathstr.append(".." + URL_FILE_SEPARATOR); 48.233 - } 48.234 - } 48.235 - pathstr.append(".." + URL_FILE_SEPARATOR); 48.236 - return pathstr.toString(); 48.237 - } 48.238 - 48.239 - /** 48.240 - * Given a relative or absolute path that might be empty, 48.241 - * convert it to a path that does not end with a 48.242 - * URL separator "/". Used for converting 48.243 - * HtmlStandardWriter.relativepath when replacing {@docRoot}. 48.244 - * 48.245 - * @param path the path to convert. An empty path represents 48.246 - * the current directory. 48.247 - */ 48.248 - public static String getPathNoTrailingSlash(String path) { 48.249 - if ( path.equals("") ) { 48.250 - return "."; 48.251 - } 48.252 - if ( path.equals("/") ) { 48.253 - return "/."; 48.254 - } 48.255 - if ( path.endsWith("/") ) { 48.256 - // Remove trailing slash 48.257 - path = path.substring(0, path.length() -1); 48.258 - } 48.259 - return path; 48.260 - } 48.261 - 48.262 - /** 48.263 - * Given a path string create all the directories in the path. For example, 48.264 - * if the path string is "java/applet", the method will create directory 48.265 - * "java" and then "java/applet" if they don't exist. The file separator 48.266 - * string "/" is platform dependent system property. 48.267 - * 48.268 - * @param path Directory path string. 48.269 - */ 48.270 - public static void createDirectory(Configuration configuration, 48.271 - String path) { 48.272 - if (path == null || path.length() == 0) { 48.273 - return; 48.274 - } 48.275 - File dir = new File(path); 48.276 - if (dir.exists()) { 48.277 - return; 48.278 - } else { 48.279 - if (dir.mkdirs()) { 48.280 - return; 48.281 - } else { 48.282 - configuration.message.error( 48.283 - "doclet.Unable_to_create_directory_0", path); 48.284 - throw new DocletAbortException(); 48.285 - } 48.286 - } 48.287 - } 48.288 - 48.289 - /** 48.290 - * Given a package name and a file name, return the full path to that file. 48.291 - * For example, if PackageDoc passed is for "java.lang" and the filename 48.292 - * passed is "package-summary.html", then the string returned is 48.293 - * "java/lang/package-summary.html". 48.294 - * 48.295 - * @param pd PackageDoc. 48.296 - * @param filename File name to be appended to the path of the package. 48.297 - */ 48.298 - public static String getPathToPackage(PackageDoc pd, String filename) { 48.299 - StringBuilder buf = new StringBuilder(); 48.300 - String pathstr = createPathString(pd); 48.301 - if (pathstr.length() > 0) { 48.302 - buf.append(pathstr); 48.303 - buf.append(URL_FILE_SEPARATOR); 48.304 - } 48.305 - buf.append(filename); 48.306 - return buf.toString(); 48.307 - } 48.308 - 48.309 - /** 48.310 - * Given a class name return the full path to the class file. 48.311 - * For example, if ClassDoc passed is for "java.lang.Object" then the 48.312 - * string returned is "java/lang/Object.html". 48.313 - * 48.314 - * @param cd ClassDoc. 48.315 - */ 48.316 - public static String getPathToClass(ClassDoc cd) { 48.317 - return getPathToPackage(cd.containingPackage(), cd.name() + ".html"); 48.318 - } 48.319 - 48.320 -}
49.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 49.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFile.java Fri Nov 02 17:55:34 2012 -0700 49.3 @@ -0,0 +1,399 @@ 49.4 +/* 49.5 + * Copyright (c) 1998, 2012, 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. Oracle designates this 49.11 + * particular file as subject to the "Classpath" exception as provided 49.12 + * by Oracle in the LICENSE file that accompanied this code. 49.13 + * 49.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 49.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 49.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 49.17 + * version 2 for more details (a copy is included in the LICENSE file that 49.18 + * accompanied this code). 49.19 + * 49.20 + * You should have received a copy of the GNU General Public License version 49.21 + * 2 along with this work; if not, write to the Free Software Foundation, 49.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 49.23 + * 49.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 49.25 + * or visit www.oracle.com if you need additional information or have any 49.26 + * questions. 49.27 + */ 49.28 + 49.29 +package com.sun.tools.doclets.internal.toolkit.util; 49.30 + 49.31 +import java.io.BufferedInputStream; 49.32 +import java.io.BufferedOutputStream; 49.33 +import java.io.BufferedReader; 49.34 +import java.io.BufferedWriter; 49.35 +import java.io.File; 49.36 +import java.io.FileInputStream; 49.37 +import java.io.FileNotFoundException; 49.38 +import java.io.FileOutputStream; 49.39 +import java.io.IOException; 49.40 +import java.io.InputStream; 49.41 +import java.io.InputStreamReader; 49.42 +import java.io.OutputStream; 49.43 +import java.io.OutputStreamWriter; 49.44 +import java.io.UnsupportedEncodingException; 49.45 +import java.io.Writer; 49.46 +import java.util.ArrayList; 49.47 +import java.util.LinkedHashSet; 49.48 +import java.util.List; 49.49 +import java.util.Set; 49.50 + 49.51 +import javax.tools.JavaFileManager.Location; 49.52 +import javax.tools.StandardLocation; 49.53 + 49.54 +import com.sun.tools.doclets.internal.toolkit.Configuration; 49.55 + 49.56 +/** 49.57 + * Abstraction for handling files, which may be specified directly 49.58 + * (e.g. via a path on the command line) or relative to a Location. 49.59 + * 49.60 + * <p><b>This is NOT part of any supported API. 49.61 + * If you write code that depends on this, you do so at your own risk. 49.62 + * This code and its internal interfaces are subject to change or 49.63 + * deletion without notice.</b> 49.64 + * 49.65 + * @since 8 49.66 + */ 49.67 +public class DocFile { 49.68 + 49.69 + /** 49.70 + * The doclet configuration. 49.71 + * Provides access to options such as docencoding, output directory, etc. 49.72 + */ 49.73 + private final Configuration configuration; 49.74 + 49.75 + /** 49.76 + * The location for this file. Maybe null if the file was created without 49.77 + * a location or path. 49.78 + */ 49.79 + private final Location location; 49.80 + 49.81 + /** 49.82 + * The path relative to the (output) location. Maybe null if the file was 49.83 + * created without a location or path. 49.84 + */ 49.85 + private final DocPath path; 49.86 + 49.87 + /** 49.88 + * The file object itself. 49.89 + * This is temporary, until we create different subtypes of DocFile. 49.90 + */ 49.91 + private final File file; 49.92 + 49.93 + /** Create a DocFile for a directory. */ 49.94 + public static DocFile createFileForDirectory(Configuration configuration, String file) { 49.95 + return new DocFile(configuration, new File(file)); 49.96 + } 49.97 + 49.98 + /** Create a DocFile for a file that will be opened for reading. */ 49.99 + public static DocFile createFileForInput(Configuration configuration, String file) { 49.100 + return new DocFile(configuration, new File(file)); 49.101 + } 49.102 + 49.103 + /** Create a DocFile for a file that will be opened for writing. */ 49.104 + public static DocFile createFileForOutput(Configuration configuration, DocPath path) { 49.105 + return new DocFile(configuration, StandardLocation.CLASS_OUTPUT, path); 49.106 + } 49.107 + 49.108 + /** 49.109 + * List the directories and files found in subdirectories along the 49.110 + * elements of the given location. 49.111 + * @param configuration the doclet configuration 49.112 + * @param location currently, only {@link StandardLocation#SOURCE_PATH} is supported. 49.113 + * @param path the subdirectory of the directories of the location for which to 49.114 + * list files 49.115 + */ 49.116 + public static Iterable<DocFile> list(Configuration configuration, Location location, DocPath path) { 49.117 + if (location != StandardLocation.SOURCE_PATH) 49.118 + throw new IllegalArgumentException(); 49.119 + 49.120 + Set<DocFile> files = new LinkedHashSet<DocFile>(); 49.121 + for (String s : configuration.sourcepath.split(File.pathSeparator)) { 49.122 + if (s.isEmpty()) 49.123 + continue; 49.124 + File f = new File(s); 49.125 + if (f.isDirectory()) { 49.126 + f = new File(f, path.getPath()); 49.127 + if (f.exists()) 49.128 + files.add(new DocFile(configuration, f)); 49.129 + } 49.130 + } 49.131 + return files; 49.132 + } 49.133 + 49.134 + /** Create a DocFile for a given file. */ 49.135 + private DocFile(Configuration configuration, File file) { 49.136 + this.configuration = configuration; 49.137 + this.location = null; 49.138 + this.path = null; 49.139 + this.file = file; 49.140 + } 49.141 + 49.142 + /** Create a DocFile for a given location and relative path. */ 49.143 + private DocFile(Configuration configuration, Location location, DocPath path) { 49.144 + this.configuration = configuration; 49.145 + this.location = location; 49.146 + this.path = path; 49.147 + this.file = path.resolveAgainst(configuration.destDirName); 49.148 + } 49.149 + 49.150 + /** Open an input stream for the file. */ 49.151 + public InputStream openInputStream() throws FileNotFoundException { 49.152 + return new BufferedInputStream(new FileInputStream(file)); 49.153 + } 49.154 + 49.155 + /** 49.156 + * Open an output stream for the file. 49.157 + * The file must have been created with a location of 49.158 + * {@link StandardLocation#CLASS_OUTPUT} and a corresponding relative path. 49.159 + */ 49.160 + public OutputStream openOutputStream() throws IOException, UnsupportedEncodingException { 49.161 + if (location != StandardLocation.CLASS_OUTPUT) 49.162 + throw new IllegalStateException(); 49.163 + 49.164 + createDirectoryForFile(file); 49.165 + return new BufferedOutputStream(new FileOutputStream(file)); 49.166 + } 49.167 + 49.168 + /** 49.169 + * Open an writer for the file, using the encoding (if any) given in the 49.170 + * doclet configuration. 49.171 + * The file must have been created with a location of 49.172 + * {@link StandardLocation#CLASS_OUTPUT} and a corresponding relative path. 49.173 + */ 49.174 + public Writer openWriter() throws IOException, UnsupportedEncodingException { 49.175 + if (location != StandardLocation.CLASS_OUTPUT) 49.176 + throw new IllegalStateException(); 49.177 + 49.178 + createDirectoryForFile(file); 49.179 + FileOutputStream fos = new FileOutputStream(file); 49.180 + if (configuration.docencoding == null) { 49.181 + return new BufferedWriter(new OutputStreamWriter(fos)); 49.182 + } else { 49.183 + return new BufferedWriter(new OutputStreamWriter(fos, configuration.docencoding)); 49.184 + } 49.185 + } 49.186 + 49.187 + /** 49.188 + * Copy the contents of another file directly to this file. 49.189 + */ 49.190 + public void copyFile(DocFile fromFile) throws IOException { 49.191 + if (location != StandardLocation.CLASS_OUTPUT) 49.192 + throw new IllegalStateException(); 49.193 + 49.194 + createDirectoryForFile(file); 49.195 + 49.196 + InputStream input = fromFile.openInputStream(); 49.197 + OutputStream output = openOutputStream(); 49.198 + try { 49.199 + byte[] bytearr = new byte[1024]; 49.200 + int len; 49.201 + while ((len = input.read(bytearr)) != -1) { 49.202 + output.write(bytearr, 0, len); 49.203 + } 49.204 + } catch (FileNotFoundException exc) { 49.205 + } catch (SecurityException exc) { 49.206 + } finally { 49.207 + input.close(); 49.208 + output.close(); 49.209 + } 49.210 + } 49.211 + 49.212 + /** 49.213 + * Copy the contents of a resource file to this file. 49.214 + * @param resource the path of the resource, relative to the package of this class 49.215 + * @param overwrite whether or not to overwrite the file if it already exists 49.216 + * @param replaceNewLine if false, the file is copied as a binary file; 49.217 + * if true, the file is written line by line, using the platform line 49.218 + * separator 49.219 + */ 49.220 + public void copyResource(DocPath resource, boolean overwrite, boolean replaceNewLine) { 49.221 + if (location != StandardLocation.CLASS_OUTPUT) 49.222 + throw new IllegalStateException(); 49.223 + 49.224 + if (file.exists() && !overwrite) 49.225 + return; 49.226 + 49.227 + createDirectoryForFile(file); 49.228 + 49.229 + try { 49.230 + InputStream in = Configuration.class.getResourceAsStream(resource.getPath()); 49.231 + if (in == null) 49.232 + return; 49.233 + 49.234 + OutputStream out = new FileOutputStream(file); 49.235 + try { 49.236 + if (!replaceNewLine) { 49.237 + byte[] buf = new byte[2048]; 49.238 + int n; 49.239 + while((n = in.read(buf))>0) out.write(buf,0,n); 49.240 + } else { 49.241 + BufferedReader reader = new BufferedReader(new InputStreamReader(in)); 49.242 + BufferedWriter writer; 49.243 + if (configuration.docencoding == null) { 49.244 + writer = new BufferedWriter(new OutputStreamWriter(out)); 49.245 + } else { 49.246 + writer = new BufferedWriter(new OutputStreamWriter(out, 49.247 + configuration.docencoding)); 49.248 + } 49.249 + try { 49.250 + String line; 49.251 + while ((line = reader.readLine()) != null) { 49.252 + writer.write(line); 49.253 + writer.write(DocletConstants.NL); 49.254 + } 49.255 + } finally { 49.256 + reader.close(); 49.257 + writer.close(); 49.258 + } 49.259 + } 49.260 + } finally { 49.261 + in.close(); 49.262 + out.close(); 49.263 + } 49.264 + } catch (IOException e) { 49.265 + e.printStackTrace(System.err); 49.266 + throw new DocletAbortException(); 49.267 + } 49.268 + } 49.269 + 49.270 + /** Return true if the file can be read. */ 49.271 + public boolean canRead() { 49.272 + return file.canRead(); 49.273 + } 49.274 + 49.275 + /** Return true if the file can be written. */ 49.276 + public boolean canWrite() { 49.277 + return file.canRead(); 49.278 + } 49.279 + 49.280 + /** Return true if the file exists. */ 49.281 + public boolean exists() { 49.282 + return file.exists(); 49.283 + } 49.284 + 49.285 + /** Return the base name (last component) of the file name. */ 49.286 + public String getName() { 49.287 + return file.getName(); 49.288 + } 49.289 + 49.290 + /** Return the file system path for this file. */ 49.291 + public String getPath() { 49.292 + return file.getPath(); 49.293 + } 49.294 + 49.295 + /** Return true is file has an absolute path name. */ 49.296 + boolean isAbsolute() { 49.297 + return file.isAbsolute(); 49.298 + } 49.299 + 49.300 + /** Return true is file identifies a directory. */ 49.301 + public boolean isDirectory() { 49.302 + return file.isDirectory(); 49.303 + } 49.304 + 49.305 + /** Return true is file identifies a file. */ 49.306 + public boolean isFile() { 49.307 + return file.isFile(); 49.308 + } 49.309 + 49.310 + /** Return true if this file is the same as another. */ 49.311 + public boolean isSameFile(DocFile other) { 49.312 + try { 49.313 + return file.exists() 49.314 + && file.getCanonicalFile().equals(other.file.getCanonicalFile()); 49.315 + } catch (IOException e) { 49.316 + return false; 49.317 + } 49.318 + } 49.319 + 49.320 + /** If the file is a directory, list its contents. */ 49.321 + public Iterable<DocFile> list() { 49.322 + List<DocFile> files = new ArrayList<DocFile>(); 49.323 + for (File f: file.listFiles()) { 49.324 + files.add(new DocFile(configuration, f)); 49.325 + } 49.326 + return files; 49.327 + } 49.328 + 49.329 + /** Create the file as a directory, including any parent directories. */ 49.330 + public boolean mkdirs() { 49.331 + return file.mkdirs(); 49.332 + } 49.333 + 49.334 + /** 49.335 + * Derive a new file by resolving a relative path against this file. 49.336 + * The new file will inherit the configuration and location of this file 49.337 + * If this file has a path set, the new file will have a corresponding 49.338 + * new path. 49.339 + */ 49.340 + public DocFile resolve(DocPath p) { 49.341 + return resolve(p.getPath()); 49.342 + } 49.343 + 49.344 + /** 49.345 + * Derive a new file by resolving a relative path against this file. 49.346 + * The new file will inherit the configuration and location of this file 49.347 + * If this file has a path set, the new file will have a corresponding 49.348 + * new path. 49.349 + */ 49.350 + public DocFile resolve(String p) { 49.351 + if (location == null && path == null) { 49.352 + return new DocFile(configuration, new File(file, p)); 49.353 + } else { 49.354 + return new DocFile(configuration, location, path.resolve(p)); 49.355 + } 49.356 + } 49.357 + 49.358 + /** 49.359 + * Resolve a relative file against the given output location. 49.360 + * @param locn Currently, only SOURCE_OUTPUT is supported. 49.361 + */ 49.362 + public DocFile resolveAgainst(StandardLocation locn) { 49.363 + if (locn != StandardLocation.CLASS_OUTPUT) 49.364 + throw new IllegalArgumentException(); 49.365 + return new DocFile(configuration, 49.366 + new File(configuration.destDirName, file.getPath())); 49.367 + } 49.368 + 49.369 + /** 49.370 + * Given a path string create all the directories in the path. For example, 49.371 + * if the path string is "java/applet", the method will create directory 49.372 + * "java" and then "java/applet" if they don't exist. The file separator 49.373 + * string "/" is platform dependent system property. 49.374 + * 49.375 + * @param path Directory path string. 49.376 + */ 49.377 + private void createDirectoryForFile(File file) { 49.378 + File dir = file.getParentFile(); 49.379 + if (dir == null || dir.exists() || dir.mkdirs()) 49.380 + return; 49.381 + 49.382 + configuration.message.error( 49.383 + "doclet.Unable_to_create_directory_0", dir.getPath()); 49.384 + throw new DocletAbortException(); 49.385 + } 49.386 + 49.387 + /** Return a string to identify the contents of this object, 49.388 + * for debugging purposes. 49.389 + */ 49.390 + @Override 49.391 + public String toString() { 49.392 + StringBuilder sb = new StringBuilder(); 49.393 + sb.append("DocFile["); 49.394 + if (location != null) 49.395 + sb.append("locn:").append(location).append(","); 49.396 + if (path != null) 49.397 + sb.append("path:").append(path.getPath()).append(","); 49.398 + sb.append("file:").append(file); 49.399 + sb.append("]"); 49.400 + return sb.toString(); 49.401 + } 49.402 +}
50.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 50.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocLink.java Fri Nov 02 17:55:34 2012 -0700 50.3 @@ -0,0 +1,97 @@ 50.4 +/* 50.5 + * Copyright (c) 2012, 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. Oracle designates this 50.11 + * particular file as subject to the "Classpath" exception as provided 50.12 + * by Oracle in the LICENSE file that accompanied this code. 50.13 + * 50.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 50.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 50.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 50.17 + * version 2 for more details (a copy is included in the LICENSE file that 50.18 + * accompanied this code). 50.19 + * 50.20 + * You should have received a copy of the GNU General Public License version 50.21 + * 2 along with this work; if not, write to the Free Software Foundation, 50.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 50.23 + * 50.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 50.25 + * or visit www.oracle.com if you need additional information or have any 50.26 + * questions. 50.27 + */ 50.28 + 50.29 +package com.sun.tools.doclets.internal.toolkit.util; 50.30 + 50.31 +/** 50.32 + * Abstraction for simple relative URIs, consisting of a path, 50.33 + * an optional query, and an optional fragment. DocLink objects can 50.34 + * be created by the constructors below or from a DocPath using the 50.35 + * convenience methods, {@link DocPath#fragment fragment} and 50.36 + * {@link DocPath#query query}. 50.37 + * 50.38 + * <p><b>This is NOT part of any supported API. 50.39 + * If you write code that depends on this, you do so at your own risk. 50.40 + * This code and its internal interfaces are subject to change or 50.41 + * deletion without notice.</b> 50.42 + * 50.43 + */ 50.44 +public class DocLink { 50.45 + final String path; 50.46 + final String query; 50.47 + final String fragment; 50.48 + 50.49 + /** Create a DocLink representing the URI {@code #fragment}. */ 50.50 + public static DocLink fragment(String fragment) { 50.51 + return new DocLink((String) null, (String) null, fragment); 50.52 + } 50.53 + 50.54 + /** Create a DocLink representing the URI {@code path}. */ 50.55 + public DocLink(DocPath path) { 50.56 + this(path.getPath(), null, null); 50.57 + } 50.58 + 50.59 + /** 50.60 + * Create a DocLink representing the URI {@code path?query#fragment}. 50.61 + * query and fragment may be null. 50.62 + */ 50.63 + public DocLink(DocPath path, String query, String fragment) { 50.64 + this(path.getPath(), query, fragment); 50.65 + } 50.66 + 50.67 + /** 50.68 + * Create a DocLink representing the URI {@code path?query#fragment}. 50.69 + * Any of the component parts may be null. 50.70 + */ 50.71 + public DocLink(String path, String query, String fragment) { 50.72 + this.path = path; 50.73 + this.query = query; 50.74 + this.fragment = fragment; 50.75 + } 50.76 + 50.77 + /** 50.78 + * Return the link in the form "path?query#fragment", omitting any empty 50.79 + * components. 50.80 + */ 50.81 + @Override 50.82 + public String toString() { 50.83 + // common fast path 50.84 + if (path != null && isEmpty(query) && isEmpty(fragment)) 50.85 + return path; 50.86 + 50.87 + StringBuilder sb = new StringBuilder(); 50.88 + if (path != null) 50.89 + sb.append(path); 50.90 + if (!isEmpty(query)) 50.91 + sb.append("?").append(query); 50.92 + if (!isEmpty(fragment)) 50.93 + sb.append("#").append(fragment); 50.94 + return sb.toString(); 50.95 + } 50.96 + 50.97 + private static boolean isEmpty(String s) { 50.98 + return (s == null) || s.isEmpty(); 50.99 + } 50.100 +}
51.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 51.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocPath.java Fri Nov 02 17:55:34 2012 -0700 51.3 @@ -0,0 +1,201 @@ 51.4 +/* 51.5 + * Copyright (c) 1998, 2012, 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. Oracle designates this 51.11 + * particular file as subject to the "Classpath" exception as provided 51.12 + * by Oracle in the LICENSE file that accompanied this code. 51.13 + * 51.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 51.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 51.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 51.17 + * version 2 for more details (a copy is included in the LICENSE file that 51.18 + * accompanied this code). 51.19 + * 51.20 + * You should have received a copy of the GNU General Public License version 51.21 + * 2 along with this work; if not, write to the Free Software Foundation, 51.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 51.23 + * 51.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 51.25 + * or visit www.oracle.com if you need additional information or have any 51.26 + * questions. 51.27 + */ 51.28 + 51.29 +package com.sun.tools.doclets.internal.toolkit.util; 51.30 + 51.31 +import com.sun.javadoc.ClassDoc; 51.32 +import com.sun.javadoc.PackageDoc; 51.33 +import java.io.File; 51.34 + 51.35 +/** 51.36 + * Abstraction for immutable relative paths. 51.37 + * Paths always use '/' as a separator, and never begin or end with '/'. 51.38 + * 51.39 + * <p><b>This is NOT part of any supported API. 51.40 + * If you write code that depends on this, you do so at your own risk. 51.41 + * This code and its internal interfaces are subject to change or 51.42 + * deletion without notice.</b> 51.43 + */ 51.44 +public class DocPath { 51.45 + private final String path; 51.46 + 51.47 + /** The empty path. */ 51.48 + public static final DocPath empty = new DocPath(""); 51.49 + 51.50 + /** The empty path. */ 51.51 + public static final DocPath parent = new DocPath(".."); 51.52 + 51.53 + /** 51.54 + * Create a path from a string. 51.55 + */ 51.56 + public static DocPath create(String p) { 51.57 + return (p == null) || p.isEmpty() ? empty : new DocPath(p); 51.58 + } 51.59 + 51.60 + /** 51.61 + * Return the path for a class. 51.62 + * For example, if the class is java.lang.Object, 51.63 + * the path is java/lang/Object.html. 51.64 + */ 51.65 + public static DocPath forClass(ClassDoc cd) { 51.66 + return (cd == null) ? empty : 51.67 + forPackage(cd.containingPackage()).resolve(forName(cd)); 51.68 + } 51.69 + 51.70 + /** 51.71 + * Return the path for the simple name of the class. 51.72 + * For example, if the class is java.lang.Object, 51.73 + * the path is Object.html. 51.74 + */ 51.75 + public static DocPath forName(ClassDoc cd) { 51.76 + return (cd == null) ? empty : new DocPath(cd.name() + ".html"); 51.77 + } 51.78 + 51.79 + /** 51.80 + * Return the path for the package of a class. 51.81 + * For example, if the class is java.lang.Object, 51.82 + * the path is java/lang. 51.83 + */ 51.84 + public static DocPath forPackage(ClassDoc cd) { 51.85 + return (cd == null) ? empty : forPackage(cd.containingPackage()); 51.86 + } 51.87 + 51.88 + /** 51.89 + * Return the path for a package. 51.90 + * For example, if the package is java.lang, 51.91 + * the path is java/lang. 51.92 + */ 51.93 + public static DocPath forPackage(PackageDoc pd) { 51.94 + return (pd == null) ? empty : DocPath.create(pd.name().replace('.', '/')); 51.95 + } 51.96 + 51.97 + /** 51.98 + * Return the inverse path for a package. 51.99 + * For example, if the package is java.lang, 51.100 + * the inverse path is ../... 51.101 + */ 51.102 + public static DocPath forRoot(PackageDoc pd) { 51.103 + String name = (pd == null) ? "" : pd.name(); 51.104 + if (name.isEmpty()) 51.105 + return empty; 51.106 + return new DocPath(name.replace('.', '/').replaceAll("[^/]+", "..")); 51.107 + } 51.108 + 51.109 + /** 51.110 + * Return the relative path from one package to another. 51.111 + */ 51.112 + public static DocPath relativePath(PackageDoc from, PackageDoc to) { 51.113 + return forRoot(from).resolve(forPackage(to)); 51.114 + } 51.115 + 51.116 + protected DocPath(String p) { 51.117 + path = (p.endsWith("/") ? p.substring(0, p.length() - 1) : p); 51.118 + } 51.119 + 51.120 + /** {@inheritDoc} */ 51.121 + @Override 51.122 + public boolean equals(Object other) { 51.123 + return (other instanceof DocPath) && path.equals(((DocPath)other).path); 51.124 + } 51.125 + 51.126 + /** {@inheritDoc} */ 51.127 + @Override 51.128 + public int hashCode() { 51.129 + return path.hashCode(); 51.130 + } 51.131 + 51.132 + public DocPath basename() { 51.133 + int sep = path.lastIndexOf("/"); 51.134 + return (sep == -1) ? this : new DocPath(path.substring(sep + 1)); 51.135 + } 51.136 + 51.137 + public DocPath parent() { 51.138 + int sep = path.lastIndexOf("/"); 51.139 + return (sep == -1) ? empty : new DocPath(path.substring(0, sep)); 51.140 + } 51.141 + 51.142 + /** 51.143 + * Return the path formed by appending the specified string to the current path. 51.144 + */ 51.145 + public DocPath resolve(String p) { 51.146 + if (p == null || p.isEmpty()) 51.147 + return this; 51.148 + if (path.isEmpty()) 51.149 + return new DocPath(p); 51.150 + return new DocPath(path + "/" + p); 51.151 + } 51.152 + 51.153 + /** 51.154 + * Return the path by appending the specified path to the current path. 51.155 + */ 51.156 + public DocPath resolve(DocPath p) { 51.157 + if (p == null || p.isEmpty()) 51.158 + return this; 51.159 + if (path.isEmpty()) 51.160 + return p; 51.161 + return new DocPath(path + "/" + p.getPath()); 51.162 + } 51.163 + 51.164 + /** 51.165 + * Get the file created by evaluating the path against a specified directory. 51.166 + */ 51.167 + // Temporary: this signature should not use String for dir. 51.168 + // Eventually, this should involve javax.tools.Location. 51.169 + public File resolveAgainst(String dir) { 51.170 + return dir.isEmpty() ? new File(path) : new File(dir, path); 51.171 + } 51.172 + 51.173 + /** 51.174 + * Return the inverse path for this path. 51.175 + * For example, if the path is a/b/c, the inverse path is ../../.. 51.176 + */ 51.177 + public DocPath invert() { 51.178 + return new DocPath(path.replaceAll("[^/]+", "..")); 51.179 + } 51.180 + 51.181 + /** 51.182 + * Return true if this path is empty. 51.183 + */ 51.184 + public boolean isEmpty() { 51.185 + return path.isEmpty(); 51.186 + } 51.187 + 51.188 + public DocLink fragment(String fragment) { 51.189 + return new DocLink(path, null, fragment); 51.190 + } 51.191 + 51.192 + public DocLink query(String query) { 51.193 + return new DocLink(path, query, null); 51.194 + } 51.195 + 51.196 + /** 51.197 + * Return this path as a string. 51.198 + */ 51.199 + // This is provided instead of using toString() to help catch 51.200 + // unintended use of toString() in string concatenation sequences. 51.201 + public String getPath() { 51.202 + return path; 51.203 + } 51.204 +}
52.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 52.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocPaths.java Fri Nov 02 17:55:34 2012 -0700 52.3 @@ -0,0 +1,115 @@ 52.4 +/* 52.5 + * Copyright (c) 1998, 2012, 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. Oracle designates this 52.11 + * particular file as subject to the "Classpath" exception as provided 52.12 + * by Oracle in the LICENSE file that accompanied this code. 52.13 + * 52.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 52.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 52.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 52.17 + * version 2 for more details (a copy is included in the LICENSE file that 52.18 + * accompanied this code). 52.19 + * 52.20 + * You should have received a copy of the GNU General Public License version 52.21 + * 2 along with this work; if not, write to the Free Software Foundation, 52.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 52.23 + * 52.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 52.25 + * or visit www.oracle.com if you need additional information or have any 52.26 + * questions. 52.27 + */ 52.28 + 52.29 +package com.sun.tools.doclets.internal.toolkit.util; 52.30 + 52.31 +/** 52.32 + * Standard DocPath objects. 52.33 + * 52.34 + * <p><b>This is NOT part of any supported API. 52.35 + * If you write code that depends on this, you do so at your own risk. 52.36 + * This code and its internal interfaces are subject to change or 52.37 + * deletion without notice.</b> 52.38 + * 52.39 + * @since 8 52.40 + */ 52.41 +public class DocPaths { 52.42 + 52.43 + /** The name of the file for all classes, using frames. */ 52.44 + public static final DocPath ALLCLASSES_FRAME = DocPath.create("allclasses-frame.html"); 52.45 + 52.46 + /** The name of the file for all classes, without using frames. */ 52.47 + public static final DocPath ALLCLASSES_NOFRAME = DocPath.create("allclasses-noframe.html"); 52.48 + 52.49 + /** The name of the sub-directory for storing class usage info. */ 52.50 + public static final DocPath CLASS_USE = DocPath.create("class-use"); 52.51 + 52.52 + /** The name of the file for constant values. */ 52.53 + public static final DocPath CONSTANT_VALUES = DocPath.create("constant-values.html"); 52.54 + 52.55 + /** The name of the fie for deprecated elements. */ 52.56 + public static final DocPath DEPRECATED_LIST = DocPath.create("deprecated-list.html"); 52.57 + 52.58 + /** The name of the subdirectory for user-provided additional documentation files. */ 52.59 + public static final DocPath DOC_FILES = DocPath.create("doc-files"); 52.60 + 52.61 + /** The name of the file for help info. */ 52.62 + public static final DocPath HELP_DOC = DocPath.create("help-doc.html"); 52.63 + 52.64 + /** The name of the main index file. */ 52.65 + public static final DocPath INDEX = DocPath.create("index.html"); 52.66 + 52.67 + /** The name of the single index file for all classes. */ 52.68 + public static final DocPath INDEX_ALL = DocPath.create("index-all.html"); 52.69 + 52.70 + /** The name of the directory for the split index files. */ 52.71 + public static final DocPath INDEX_FILES = DocPath.create("index-files"); 52.72 + 52.73 + /** Generate the name of one of the files in the split index. */ 52.74 + public static final DocPath indexN(int n) { 52.75 + return DocPath.create("index-" + n + ".html"); 52.76 + } 52.77 + 52.78 + /** The name of the file for the overview frame. */ 52.79 + public static final DocPath OVERVIEW_FRAME = DocPath.create("overview-frame.html"); 52.80 + 52.81 + /** The name of the file for the overview summary. */ 52.82 + public static final DocPath OVERVIEW_SUMMARY = DocPath.create("overview-summary.html"); 52.83 + 52.84 + /** The name of the file for the overview tree. */ 52.85 + public static final DocPath OVERVIEW_TREE = DocPath.create("overview-tree.html"); 52.86 + 52.87 + /** The name of the file for the package frame. */ 52.88 + public static final DocPath PACKAGE_FRAME = DocPath.create("package-frame.html"); 52.89 + 52.90 + /** The name of the file for the package list. */ 52.91 + public static final DocPath PACKAGE_LIST = DocPath.create("package-list"); 52.92 + 52.93 + /** The name of the file for the package summary. */ 52.94 + public static final DocPath PACKAGE_SUMMARY = DocPath.create("package-summary.html"); 52.95 + 52.96 + /** The name of the file for the package tree. */ 52.97 + public static final DocPath PACKAGE_TREE = DocPath.create("package-tree.html"); 52.98 + 52.99 + /** The name of the file for the package usage info. */ 52.100 + public static final DocPath PACKAGE_USE = DocPath.create("package-use.html"); 52.101 + 52.102 + /** The name of the directory in which resources are generated. 52.103 + * Also the name of the sub-package from which resources are read. 52.104 + */ 52.105 + public static final DocPath RESOURCES = DocPath.create("resources"); 52.106 + 52.107 + /** The name of the file for the serialized form info. */ 52.108 + public static final DocPath SERIALIZED_FORM = DocPath.create("serialized-form.html"); 52.109 + 52.110 + /** The name of the directory in which HTML versions of the source code 52.111 + * are generated. 52.112 + */ 52.113 + public static final DocPath SOURCE_OUTPUT = DocPath.create("src-html"); 52.114 + 52.115 + /** The name of the default stylesheet. */ 52.116 + public static final DocPath STYLESHEET = DocPath.create("stylesheet.css"); 52.117 + 52.118 +}
53.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocletConstants.java Thu Nov 01 14:13:13 2012 -0700 53.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocletConstants.java Fri Nov 02 17:55:34 2012 -0700 53.3 @@ -40,6 +40,16 @@ 53.4 public class DocletConstants { 53.5 53.6 /** 53.7 + * The default amount of space between tab stops. 53.8 + */ 53.9 + public static final int DEFAULT_TAB_STOP_LENGTH = 8; 53.10 + 53.11 + /** 53.12 + * The line separator for the current operating system. 53.13 + */ 53.14 + public static final String NL = System.getProperty("line.separator"); 53.15 + 53.16 + /** 53.17 * The default package name. 53.18 */ 53.19 public static final String DEFAULT_PACKAGE_NAME = "<Unnamed>"; 53.20 @@ -53,34 +63,4 @@ 53.21 * The anchor for the default package. 53.22 */ 53.23 public static final String UNNAMED_PACKAGE_ANCHOR = "unnamed_package"; 53.24 - 53.25 - /** 53.26 - * The name of the doc files directory. 53.27 - */ 53.28 - public static final String DOC_FILES_DIR_NAME = "doc-files"; 53.29 - 53.30 - /** 53.31 - * The default amount of space between tab stops. 53.32 - */ 53.33 - public static final int DEFAULT_TAB_STOP_LENGTH = 8; 53.34 - 53.35 - /** 53.36 - * The name of the directory where we will copy resource files to. 53.37 - */ 53.38 - public static final String RESOURE_DIR_NAME = "resources"; 53.39 - 53.40 - /** 53.41 - * The source output directory name 53.42 - */ 53.43 - public static final String SOURCE_OUTPUT_DIR_NAME = "src-html/"; 53.44 - 53.45 - /** 53.46 - * The name of the package list file. 53.47 - */ 53.48 - public static final String PACKAGE_LIST_FILE_NAME = "package-list"; 53.49 - 53.50 - /** 53.51 - * The line seperator for the current operating system. 53.52 - */ 53.53 - public static final String NL = System.getProperty("line.separator"); 53.54 }
54.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Extern.java Thu Nov 01 14:13:13 2012 -0700 54.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Extern.java Fri Nov 02 17:55:34 2012 -0700 54.3 @@ -30,6 +30,8 @@ 54.4 import java.util.HashMap; 54.5 import java.util.Map; 54.6 54.7 +import javax.tools.StandardLocation; 54.8 + 54.9 import com.sun.javadoc.*; 54.10 import com.sun.tools.doclets.internal.toolkit.*; 54.11 54.12 @@ -138,21 +140,25 @@ 54.13 * 54.14 * @param pkgName The package name. 54.15 * @param relativepath The relative path. 54.16 - * @param link The link to convert. 54.17 + * @param filename The link to convert. 54.18 * @return if external return converted link else return null 54.19 */ 54.20 - public String getExternalLink(String pkgName, 54.21 - String relativepath, String link) { 54.22 + public DocLink getExternalLink(String pkgName, 54.23 + DocPath relativepath, String filename) { 54.24 + return getExternalLink(pkgName, relativepath, filename, null); 54.25 + } 54.26 + 54.27 + public DocLink getExternalLink(String pkgName, 54.28 + DocPath relativepath, String filename, String memberName) { 54.29 Item fnd = findPackageItem(pkgName); 54.30 - if (fnd != null) { 54.31 - String externlink = fnd.path + link; 54.32 - if (fnd.relative) { // it's a relative path. 54.33 - return relativepath + externlink; 54.34 - } else { 54.35 - return externlink; 54.36 - } 54.37 - } 54.38 - return null; 54.39 + if (fnd == null) 54.40 + return null; 54.41 + 54.42 + DocPath p = fnd.relative ? 54.43 + relativepath.resolve(fnd.path).resolve(filename) : 54.44 + DocPath.create(fnd.path).resolve(filename); 54.45 + 54.46 + return new DocLink(p, "is-external=true", memberName); 54.47 } 54.48 54.49 /** 54.50 @@ -163,17 +169,38 @@ 54.51 * @param pkglisturl This can be another URL for "package-list" or ordinary 54.52 * file. 54.53 * @param reporter The <code>DocErrorReporter</code> used to report errors. 54.54 - * @param linkoffline True if -linkoffline isused and false if -link is used. 54.55 + * @param linkoffline True if -linkoffline is used and false if -link is used. 54.56 */ 54.57 - public boolean url(String url, String pkglisturl, 54.58 + public boolean link(String url, String pkglisturl, 54.59 DocErrorReporter reporter, boolean linkoffline) { 54.60 this.linkoffline = linkoffline; 54.61 - String errMsg = composeExternPackageList(url, pkglisturl); 54.62 - if (errMsg != null) { 54.63 - reporter.printWarning(errMsg); 54.64 + try { 54.65 + url = adjustEndFileSeparator(url); 54.66 + if (isUrl(pkglisturl)) { 54.67 + readPackageListFromURL(url, toURL(pkglisturl)); 54.68 + } else { 54.69 + readPackageListFromFile(url, DocFile.createFileForInput(configuration, pkglisturl)); 54.70 + } 54.71 + return true; 54.72 + } catch (Fault f) { 54.73 + reporter.printWarning(f.getMessage()); 54.74 return false; 54.75 - } else { 54.76 - return true; 54.77 + } 54.78 + } 54.79 + 54.80 + private URL toURL(String url) throws Fault { 54.81 + try { 54.82 + return new URL(url); 54.83 + } catch (MalformedURLException e) { 54.84 + throw new Fault(configuration.getText("doclet.MalformedURL", url), e); 54.85 + } 54.86 + } 54.87 + 54.88 + private class Fault extends Exception { 54.89 + private static final long serialVersionUID = 0; 54.90 + 54.91 + Fault(String msg, Exception cause) { 54.92 + super(msg, cause); 54.93 } 54.94 } 54.95 54.96 @@ -190,31 +217,10 @@ 54.97 } 54.98 54.99 /** 54.100 - * Adjusts the end file separator if it is missing from the URL or the 54.101 - * directory path and depending upon the URL or file path, fetch or 54.102 - * read the "package-list" file. 54.103 - * 54.104 - * @param urlOrDirPath URL or the directory path. 54.105 - * @param pkgListUrlOrDirPath URL or directory path for the "package-list" file or the "package-list" 54.106 - * file itself. 54.107 - */ 54.108 - private String composeExternPackageList(String urlOrDirPath, String pkgListUrlOrDirPath) { 54.109 - urlOrDirPath = adjustEndFileSeparator(urlOrDirPath); 54.110 - pkgListUrlOrDirPath = adjustEndFileSeparator(pkgListUrlOrDirPath); 54.111 - return isUrl(pkgListUrlOrDirPath) ? 54.112 - fetchURLComposeExternPackageList(urlOrDirPath, pkgListUrlOrDirPath) : 54.113 - readFileComposeExternPackageList(urlOrDirPath, pkgListUrlOrDirPath); 54.114 - } 54.115 - 54.116 - /** 54.117 * If the URL or Directory path is missing end file separator, add that. 54.118 */ 54.119 private String adjustEndFileSeparator(String url) { 54.120 - String filesep = "/"; 54.121 - if (!url.endsWith(filesep)) { 54.122 - url += filesep; 54.123 - } 54.124 - return url; 54.125 + return url.endsWith("/") ? url : url + '/'; 54.126 } 54.127 54.128 /** 54.129 @@ -223,17 +229,18 @@ 54.130 * @param urlpath Path to the packages. 54.131 * @param pkglisturlpath URL or the path to the "package-list" file. 54.132 */ 54.133 - private String fetchURLComposeExternPackageList(String urlpath, 54.134 - String pkglisturlpath) { 54.135 - String link = pkglisturlpath + "package-list"; 54.136 + private void readPackageListFromURL(String urlpath, URL pkglisturlpath) 54.137 + throws Fault { 54.138 try { 54.139 - readPackageList((new URL(link)).openStream(), urlpath, false); 54.140 + URL link = pkglisturlpath.toURI().resolve(DocPaths.PACKAGE_LIST.getPath()).toURL(); 54.141 + readPackageList(link.openStream(), urlpath, false); 54.142 + } catch (URISyntaxException exc) { 54.143 + throw new Fault(configuration.getText("doclet.MalformedURL", pkglisturlpath.toString()), exc); 54.144 } catch (MalformedURLException exc) { 54.145 - return configuration.getText("doclet.MalformedURL", link); 54.146 + throw new Fault(configuration.getText("doclet.MalformedURL", pkglisturlpath.toString()), exc); 54.147 } catch (IOException exc) { 54.148 - return configuration.getText("doclet.URL_error", link); 54.149 + throw new Fault(configuration.getText("doclet.URL_error", pkglisturlpath.toString()), exc); 54.150 } 54.151 - return null; 54.152 } 54.153 54.154 /** 54.155 @@ -242,27 +249,24 @@ 54.156 * @param path URL or directory path to the packages. 54.157 * @param pkgListPath Path to the local "package-list" file. 54.158 */ 54.159 - private String readFileComposeExternPackageList(String path, 54.160 - String pkgListPath) { 54.161 - 54.162 - String link = pkgListPath + "package-list"; 54.163 - if (! ((new File(pkgListPath)).isAbsolute() || linkoffline)){ 54.164 - link = configuration.destDirName + link; 54.165 + private void readPackageListFromFile(String path, DocFile pkgListPath) 54.166 + throws Fault { 54.167 + DocFile file = pkgListPath.resolve(DocPaths.PACKAGE_LIST); 54.168 + if (! (file.isAbsolute() || linkoffline)){ 54.169 + file = file.resolveAgainst(StandardLocation.CLASS_OUTPUT); 54.170 } 54.171 try { 54.172 - File file = new File(link); 54.173 if (file.exists() && file.canRead()) { 54.174 - readPackageList(new FileInputStream(file), path, 54.175 - ! ((new File(path)).isAbsolute() || isUrl(path))); 54.176 + boolean pathIsRelative = 54.177 + !DocFile.createFileForInput(configuration, path).isAbsolute() 54.178 + && !isUrl(path); 54.179 + readPackageList(file.openInputStream(), path, pathIsRelative); 54.180 } else { 54.181 - return configuration.getText("doclet.File_error", link); 54.182 + throw new Fault(configuration.getText("doclet.File_error", file.getPath()), null); 54.183 } 54.184 - } catch (FileNotFoundException exc) { 54.185 - return configuration.getText("doclet.File_error", link); 54.186 } catch (IOException exc) { 54.187 - return configuration.getText("doclet.File_error", link); 54.188 + throw new Fault(configuration.getText("doclet.File_error", file.getPath()), exc); 54.189 } 54.190 - return null; 54.191 } 54.192 54.193 /**
55.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/PackageListWriter.java Thu Nov 01 14:13:13 2012 -0700 55.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/PackageListWriter.java Fri Nov 02 17:55:34 2012 -0700 55.3 @@ -52,8 +52,7 @@ 55.4 * @param configuration the current configuration of the doclet. 55.5 */ 55.6 public PackageListWriter(Configuration configuration) throws IOException { 55.7 - super(Util.genWriter(configuration, configuration.destDirName, 55.8 - DocletConstants.PACKAGE_LIST_FILE_NAME, configuration.docencoding)); 55.9 + super(DocFile.createFileForOutput(configuration, DocPaths.PACKAGE_LIST).openWriter()); 55.10 this.configuration = configuration; 55.11 } 55.12 55.13 @@ -71,7 +70,7 @@ 55.14 packgen.close(); 55.15 } catch (IOException exc) { 55.16 configuration.message.error("doclet.exception_encountered", 55.17 - exc.toString(), DocletConstants.PACKAGE_LIST_FILE_NAME); 55.18 + exc.toString(), DocPaths.PACKAGE_LIST); 55.19 throw new DocletAbortException(); 55.20 } 55.21 }
56.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/SourcePath.java Thu Nov 01 14:13:13 2012 -0700 56.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 56.3 @@ -1,133 +0,0 @@ 56.4 -/* 56.5 - * Copyright (c) 1998, 2003, 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. Oracle designates this 56.11 - * particular file as subject to the "Classpath" exception as provided 56.12 - * by Oracle in the LICENSE file that accompanied this code. 56.13 - * 56.14 - * This code is distributed in the hope that it will be useful, but WITHOUT 56.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 56.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 56.17 - * version 2 for more details (a copy is included in the LICENSE file that 56.18 - * accompanied this code). 56.19 - * 56.20 - * You should have received a copy of the GNU General Public License version 56.21 - * 2 along with this work; if not, write to the Free Software Foundation, 56.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 56.23 - * 56.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 56.25 - * or visit www.oracle.com if you need additional information or have any 56.26 - * questions. 56.27 - */ 56.28 - 56.29 -package com.sun.tools.doclets.internal.toolkit.util; 56.30 - 56.31 -import java.io.File; 56.32 - 56.33 -/** 56.34 - * This class is used to represent a source path which can contain only 56.35 - * directories no zip files. If a zip file is specified in the command line it 56.36 - * will not get reflected in the SourcePath. 56.37 - * 56.38 - * This code is not part of an API. 56.39 - * It is implementation that is subject to change. 56.40 - * Do not use it as an API 56.41 - * 56.42 - * @author Atul M Dambalkar 56.43 - */ 56.44 -public 56.45 - class SourcePath { 56.46 - private final char dirSeparator = File.pathSeparatorChar; 56.47 - 56.48 - /** 56.49 - * The original class path string 56.50 - */ 56.51 - private String pathstr; 56.52 - 56.53 - /** 56.54 - * List of source path entries. Each entry is a directory. 56.55 - */ 56.56 - private File[] sourcePath; 56.57 - 56.58 - 56.59 - /** 56.60 - * Build a source path from the specified path string on the command line. 56.61 - */ 56.62 - public SourcePath(String pathstr) { 56.63 - init(pathstr); 56.64 - } 56.65 - 56.66 - /** 56.67 - * Build a default source path from the path strings specified by 56.68 - * the properties env.class.path. 56.69 - */ 56.70 - public SourcePath() { 56.71 - init(System.getProperty("env.class.path")); 56.72 - } 56.73 - 56.74 - /** 56.75 - * Initialize the SourcePath File array, which will contain only the 56.76 - * directory names from the given path string. 56.77 - * 56.78 - * @param pathstr Path String. 56.79 - */ 56.80 - private void init(String pathstr) { 56.81 - if (pathstr == null || pathstr.length() == 0) { 56.82 - pathstr = "."; 56.83 - } 56.84 - 56.85 - int noOfFileSep = 0; 56.86 - int index = 0; 56.87 - this.pathstr = pathstr; // Save original class path string 56.88 - 56.89 - // Count the number of path separators 56.90 - while ((index = pathstr.indexOf(dirSeparator, index)) != -1) { 56.91 - noOfFileSep++; 56.92 - index++; 56.93 - } 56.94 - // Build the source path 56.95 - File[] tempPath = new File[noOfFileSep + 1]; 56.96 - int tempPathIndex = 0; 56.97 - int len = pathstr.length(); 56.98 - int sepPos = 0; 56.99 - for (index = 0; index < len; index = sepPos + 1) { 56.100 - sepPos = pathstr.indexOf(dirSeparator, index); 56.101 - if (sepPos < 0) { 56.102 - sepPos = len; 56.103 - } 56.104 - File file = new File(pathstr.substring(index, sepPos)); 56.105 - if (file.isDirectory()) { 56.106 - tempPath[tempPathIndex++] = file; 56.107 - } // if it is really a file, ignore it. 56.108 - } 56.109 - sourcePath = new File[tempPathIndex]; 56.110 - System.arraycopy((Object)tempPath, 0, (Object)sourcePath, 56.111 - 0, tempPathIndex); 56.112 - } 56.113 - 56.114 - /** 56.115 - * Find the specified directory in the source path. 56.116 - * 56.117 - * @param name Name of the directory to be searched for in the source path. 56.118 - * @return File Return the directory if found else return null. 56.119 - */ 56.120 - public File getDirectory(String name) { 56.121 - for (int i = 0; i < sourcePath.length; i++) { 56.122 - File directoryNeeded = new File(sourcePath[i], name); 56.123 - if (directoryNeeded.isDirectory()) { 56.124 - return directoryNeeded; 56.125 - } 56.126 - } 56.127 - return null; 56.128 - } 56.129 - 56.130 - /** 56.131 - * Return original source path string. 56.132 - */ 56.133 - public String toString() { 56.134 - return pathstr; 56.135 - } 56.136 -}
57.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java Thu Nov 01 14:13:13 2012 -0700 57.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java Fri Nov 02 17:55:34 2012 -0700 57.3 @@ -30,6 +30,7 @@ 57.4 57.5 import com.sun.javadoc.*; 57.6 import com.sun.tools.doclets.internal.toolkit.*; 57.7 +import javax.tools.StandardLocation; 57.8 57.9 /** 57.10 * Utilities Class for Doclets. 57.11 @@ -52,11 +53,6 @@ 57.12 {{"&", "&"}, {"<", "<"}, {">", ">"}}; 57.13 57.14 /** 57.15 - * Name of the resource directory. 57.16 - */ 57.17 - public static final String RESOURCESDIR = "resources"; 57.18 - 57.19 - /** 57.20 * Return array of class members whose documentation is to be generated. 57.21 * If the member is deprecated do not include such a member in the 57.22 * returned array. 57.23 @@ -197,32 +193,6 @@ 57.24 } 57.25 57.26 /** 57.27 - * Copy source file to destination file. 57.28 - * 57.29 - * @throws SecurityException 57.30 - * @throws IOException 57.31 - */ 57.32 - public static void copyFile(File destfile, File srcfile) 57.33 - throws IOException { 57.34 - byte[] bytearr = new byte[512]; 57.35 - int len = 0; 57.36 - FileInputStream input = new FileInputStream(srcfile); 57.37 - File destDir = destfile.getParentFile(); 57.38 - destDir.mkdirs(); 57.39 - FileOutputStream output = new FileOutputStream(destfile); 57.40 - try { 57.41 - while ((len = input.read(bytearr)) != -1) { 57.42 - output.write(bytearr, 0, len); 57.43 - } 57.44 - } catch (FileNotFoundException exc) { 57.45 - } catch (SecurityException exc) { 57.46 - } finally { 57.47 - input.close(); 57.48 - output.close(); 57.49 - } 57.50 - } 57.51 - 57.52 - /** 57.53 * Copy the given directory contents from the source package directory 57.54 * to the generated documentation directory. For example for a package 57.55 * java.lang this method find out the source location of the package using 57.56 @@ -235,45 +205,45 @@ 57.57 * @param dir The original directory name to copy from. 57.58 * @param overwrite Overwrite files if true. 57.59 */ 57.60 - public static void copyDocFiles(Configuration configuration, 57.61 - String path, String dir, boolean overwrite) { 57.62 - if (checkCopyDocFilesErrors(configuration, path, dir)) { 57.63 - return; 57.64 - } 57.65 - String destname = configuration.docFileDestDirName; 57.66 - File srcdir = new File(path + dir); 57.67 - if (destname.length() > 0 && !destname.endsWith( 57.68 - DirectoryManager.URL_FILE_SEPARATOR)) { 57.69 - destname += DirectoryManager.URL_FILE_SEPARATOR; 57.70 - } 57.71 - String dest = destname + dir; 57.72 + public static void copyDocFiles(Configuration configuration, PackageDoc pd) { 57.73 + copyDocFiles(configuration, DocPath.forPackage(pd).resolve(DocPaths.DOC_FILES)); 57.74 + } 57.75 + 57.76 + public static void copyDocFiles(Configuration configuration, DocPath dir) { 57.77 try { 57.78 - File destdir = new File(dest); 57.79 - DirectoryManager.createDirectory(configuration, dest); 57.80 - String[] files = srcdir.list(); 57.81 - for (int i = 0; i < files.length; i++) { 57.82 - File srcfile = new File(srcdir, files[i]); 57.83 - File destfile = new File(destdir, files[i]); 57.84 - if (srcfile.isFile()) { 57.85 - if(destfile.exists() && ! overwrite) { 57.86 - configuration.message.warning((SourcePosition) null, 57.87 - "doclet.Copy_Overwrite_warning", 57.88 - srcfile.toString(), destdir.toString()); 57.89 - } else { 57.90 - configuration.message.notice( 57.91 - "doclet.Copying_File_0_To_Dir_1", 57.92 - srcfile.toString(), destdir.toString()); 57.93 - Util.copyFile(destfile, srcfile); 57.94 - } 57.95 - } else if(srcfile.isDirectory()) { 57.96 - if(configuration.copydocfilesubdirs 57.97 - && ! configuration.shouldExcludeDocFileDir( 57.98 - srcfile.getName())){ 57.99 - copyDocFiles(configuration, path, dir + 57.100 - DirectoryManager.URL_FILE_SEPARATOR + srcfile.getName(), 57.101 - overwrite); 57.102 + boolean first = true; 57.103 + for (DocFile f : DocFile.list(configuration, StandardLocation.SOURCE_PATH, dir)) { 57.104 + if (!f.isDirectory()) { 57.105 + continue; 57.106 + } 57.107 + DocFile srcdir = f; 57.108 + DocFile destdir = DocFile.createFileForOutput(configuration, dir); 57.109 + if (srcdir.isSameFile(destdir)) { 57.110 + continue; 57.111 + } 57.112 + 57.113 + for (DocFile srcfile: srcdir.list()) { 57.114 + DocFile destfile = destdir.resolve(srcfile.getName()); 57.115 + if (srcfile.isFile()) { 57.116 + if (destfile.exists() && !first) { 57.117 + configuration.message.warning((SourcePosition) null, 57.118 + "doclet.Copy_Overwrite_warning", 57.119 + srcfile.getPath(), destdir.getPath()); 57.120 + } else { 57.121 + configuration.message.notice( 57.122 + "doclet.Copying_File_0_To_Dir_1", 57.123 + srcfile.getPath(), destdir.getPath()); 57.124 + destfile.copyFile(srcfile); 57.125 + } 57.126 + } else if (srcfile.isDirectory()) { 57.127 + if (configuration.copydocfilesubdirs 57.128 + && !configuration.shouldExcludeDocFileDir(srcfile.getName())) { 57.129 + copyDocFiles(configuration, dir.resolve(srcfile.getName())); 57.130 + } 57.131 } 57.132 } 57.133 + 57.134 + first = false; 57.135 } 57.136 } catch (SecurityException exc) { 57.137 throw new DocletAbortException(); 57.138 @@ -283,142 +253,6 @@ 57.139 } 57.140 57.141 /** 57.142 - * Given the parameters for copying doc-files, check for errors. 57.143 - * 57.144 - * @param configuration The configuration of the current doclet. 57.145 - * @param path The relative path to the directory to be copied. 57.146 - * @param dirName The original directory name to copy from. 57.147 - */ 57.148 - private static boolean checkCopyDocFilesErrors (Configuration configuration, 57.149 - String path, String dirName) { 57.150 - if ((configuration.sourcepath == null || configuration.sourcepath.length() == 0) && 57.151 - (configuration.destDirName == null || configuration.destDirName.length() == 0)) { 57.152 - //The destination path and source path are definitely equal. 57.153 - return true; 57.154 - } 57.155 - File sourcePath, destPath = new File(configuration.destDirName); 57.156 - StringTokenizer pathTokens = new StringTokenizer( 57.157 - configuration.sourcepath == null ? "" : configuration.sourcepath, 57.158 - File.pathSeparator); 57.159 - //Check if the destination path is equal to the source path. If yes, 57.160 - //do not copy doc-file directories. 57.161 - while(pathTokens.hasMoreTokens()){ 57.162 - sourcePath = new File(pathTokens.nextToken()); 57.163 - if(destPath.equals(sourcePath)){ 57.164 - return true; 57.165 - } 57.166 - } 57.167 - //Make sure the doc-file being copied exists. 57.168 - File srcdir = new File(path + dirName); 57.169 - if (! srcdir.exists()) { 57.170 - return true; 57.171 - } 57.172 - return false; 57.173 - } 57.174 - 57.175 - /** 57.176 - * Copy a file in the resources directory to the destination 57.177 - * directory (if it is not there already). If 57.178 - * <code>overwrite</code> is true and the destination file 57.179 - * already exists, overwrite it. 57.180 - * 57.181 - * @param configuration Holds the destination directory and error message 57.182 - * @param resourcefile The name of the resource file to copy 57.183 - * @param overwrite A flag to indicate whether the file in the 57.184 - * destination directory will be overwritten if 57.185 - * it already exists. 57.186 - */ 57.187 - public static void copyResourceFile(Configuration configuration, 57.188 - String resourcefile, boolean overwrite) { 57.189 - String destresourcesdir = configuration.destDirName + RESOURCESDIR; 57.190 - copyFile(configuration, resourcefile, RESOURCESDIR, destresourcesdir, 57.191 - overwrite, false); 57.192 - } 57.193 - 57.194 - /** 57.195 - * Copy a file from a source directory to a destination directory 57.196 - * (if it is not there already). If <code>overwrite</code> is true and 57.197 - * the destination file already exists, overwrite it. 57.198 - * 57.199 - * @param configuration Holds the error message 57.200 - * @param file The name of the file to copy 57.201 - * @param source The source directory 57.202 - * @param destination The destination directory where the file needs to be copied 57.203 - * @param overwrite A flag to indicate whether the file in the 57.204 - * destination directory will be overwritten if 57.205 - * it already exists. 57.206 - * @param replaceNewLine true if the newline needs to be replaced with platform- 57.207 - * specific newline. 57.208 - */ 57.209 - public static void copyFile(Configuration configuration, String file, String source, 57.210 - String destination, boolean overwrite, boolean replaceNewLine) { 57.211 - DirectoryManager.createDirectory(configuration, destination); 57.212 - File destfile = new File(destination, file); 57.213 - if(destfile.exists() && (! overwrite)) return; 57.214 - try { 57.215 - InputStream in = Configuration.class.getResourceAsStream( 57.216 - source + DirectoryManager.URL_FILE_SEPARATOR + file); 57.217 - if(in==null) return; 57.218 - OutputStream out = new FileOutputStream(destfile); 57.219 - try { 57.220 - if (!replaceNewLine) { 57.221 - byte[] buf = new byte[2048]; 57.222 - int n; 57.223 - while((n = in.read(buf))>0) out.write(buf,0,n); 57.224 - } else { 57.225 - BufferedReader reader = new BufferedReader(new InputStreamReader(in)); 57.226 - BufferedWriter writer; 57.227 - if (configuration.docencoding == null) { 57.228 - writer = new BufferedWriter(new OutputStreamWriter(out)); 57.229 - } else { 57.230 - writer = new BufferedWriter(new OutputStreamWriter(out, 57.231 - configuration.docencoding)); 57.232 - } 57.233 - try { 57.234 - String line; 57.235 - while ((line = reader.readLine()) != null) { 57.236 - writer.write(line); 57.237 - writer.write(DocletConstants.NL); 57.238 - } 57.239 - } finally { 57.240 - reader.close(); 57.241 - writer.close(); 57.242 - } 57.243 - } 57.244 - } finally { 57.245 - in.close(); 57.246 - out.close(); 57.247 - } 57.248 - } catch (IOException ie) { 57.249 - ie.printStackTrace(System.err); 57.250 - throw new DocletAbortException(); 57.251 - } 57.252 - } 57.253 - 57.254 - /** 57.255 - * Given a PackageDoc, return the source path for that package. 57.256 - * @param configuration The Configuration for the current Doclet. 57.257 - * @param pkgDoc The package to seach the path for. 57.258 - * @return A string representing the path to the given package. 57.259 - */ 57.260 - public static String getPackageSourcePath(Configuration configuration, 57.261 - PackageDoc pkgDoc){ 57.262 - try{ 57.263 - String pkgPath = DirectoryManager.getDirectoryPath(pkgDoc); 57.264 - String completePath = new SourcePath(configuration.sourcepath). 57.265 - getDirectory(pkgPath) + DirectoryManager.URL_FILE_SEPARATOR; 57.266 - //Make sure that both paths are using the same separators. 57.267 - completePath = Util.replaceText(completePath, File.separator, 57.268 - DirectoryManager.URL_FILE_SEPARATOR); 57.269 - pkgPath = Util.replaceText(pkgPath, File.separator, 57.270 - DirectoryManager.URL_FILE_SEPARATOR); 57.271 - return completePath.substring(0, completePath.lastIndexOf(pkgPath)); 57.272 - } catch (Exception e){ 57.273 - return ""; 57.274 - } 57.275 - } 57.276 - 57.277 - /** 57.278 * We want the list of types in alphabetical order. However, types are not 57.279 * comparable. We need a comparator for now. 57.280 */ 57.281 @@ -552,7 +386,7 @@ 57.282 } 57.283 57.284 /** 57.285 - * Given a package, return it's name. 57.286 + * Given a package, return its name. 57.287 * @param packageDoc the package to check. 57.288 * @return the name of the given package. 57.289 */ 57.290 @@ -562,7 +396,7 @@ 57.291 } 57.292 57.293 /** 57.294 - * Given a package, return it's file name without the extension. 57.295 + * Given a package, return its file name without the extension. 57.296 * @param packageDoc the package to check. 57.297 * @return the file name of the given package. 57.298 */ 57.299 @@ -572,7 +406,7 @@ 57.300 } 57.301 57.302 /** 57.303 - * Given a string, replace all occurraces of 'newStr' with 'oldStr'. 57.304 + * Given a string, replace all occurrences of 'newStr' with 'oldStr'. 57.305 * @param originalStr the string to modify. 57.306 * @param oldStr the string to replace. 57.307 * @param newStr the string to insert in place of the old string. 57.308 @@ -623,40 +457,6 @@ 57.309 } 57.310 57.311 /** 57.312 - * Create the directory path for the file to be generated, construct 57.313 - * FileOutputStream and OutputStreamWriter depending upon docencoding. 57.314 - * 57.315 - * @param path The directory path to be created for this file. 57.316 - * @param filename File Name to which the PrintWriter will do the Output. 57.317 - * @param docencoding Encoding to be used for this file. 57.318 - * @exception IOException Exception raised by the FileWriter is passed on 57.319 - * to next level. 57.320 - * @exception UnsupportedEncodingException Exception raised by the 57.321 - * OutputStreamWriter is passed on to next level. 57.322 - * @return Writer Writer for the file getting generated. 57.323 - * @see java.io.FileOutputStream 57.324 - * @see java.io.OutputStreamWriter 57.325 - */ 57.326 - public static Writer genWriter(Configuration configuration, 57.327 - String path, String filename, 57.328 - String docencoding) 57.329 - throws IOException, UnsupportedEncodingException { 57.330 - FileOutputStream fos; 57.331 - if (path != null) { 57.332 - DirectoryManager.createDirectory(configuration, path); 57.333 - fos = new FileOutputStream(((path.length() > 0)? 57.334 - path + File.separator: "") + filename); 57.335 - } else { 57.336 - fos = new FileOutputStream(filename); 57.337 - } 57.338 - if (docencoding == null) { 57.339 - return new BufferedWriter(new OutputStreamWriter(fos)); 57.340 - } else { 57.341 - return new BufferedWriter(new OutputStreamWriter(fos, docencoding)); 57.342 - } 57.343 - } 57.344 - 57.345 - /** 57.346 * Given an annotation, return true if it should be documented and false 57.347 * otherwise. 57.348 * 57.349 @@ -676,47 +476,6 @@ 57.350 } 57.351 57.352 /** 57.353 - * Given a string, return an array of tokens. The separator can be escaped 57.354 - * with the '\' character. The '\' character may also be escaped by the 57.355 - * '\' character. 57.356 - * 57.357 - * @param s the string to tokenize. 57.358 - * @param separator the separator char. 57.359 - * @param maxTokens the maxmimum number of tokens returned. If the 57.360 - * max is reached, the remaining part of s is appended 57.361 - * to the end of the last token. 57.362 - * 57.363 - * @return an array of tokens. 57.364 - */ 57.365 - public static String[] tokenize(String s, char separator, int maxTokens) { 57.366 - List<String> tokens = new ArrayList<String>(); 57.367 - StringBuilder token = new StringBuilder (); 57.368 - boolean prevIsEscapeChar = false; 57.369 - for (int i = 0; i < s.length(); i += Character.charCount(i)) { 57.370 - int currentChar = s.codePointAt(i); 57.371 - if (prevIsEscapeChar) { 57.372 - // Case 1: escaped character 57.373 - token.appendCodePoint(currentChar); 57.374 - prevIsEscapeChar = false; 57.375 - } else if (currentChar == separator && tokens.size() < maxTokens-1) { 57.376 - // Case 2: separator 57.377 - tokens.add(token.toString()); 57.378 - token = new StringBuilder(); 57.379 - } else if (currentChar == '\\') { 57.380 - // Case 3: escape character 57.381 - prevIsEscapeChar = true; 57.382 - } else { 57.383 - // Case 4: regular character 57.384 - token.appendCodePoint(currentChar); 57.385 - } 57.386 - } 57.387 - if (token.length() > 0) { 57.388 - tokens.add(token.toString()); 57.389 - } 57.390 - return tokens.toArray(new String[] {}); 57.391 - } 57.392 - 57.393 - /** 57.394 * Return true if this class is linkable and false if we can't link to the 57.395 * desired class. 57.396 * <br>
58.1 --- a/src/share/classes/com/sun/tools/javac/code/Attribute.java Thu Nov 01 14:13:13 2012 -0700 58.2 +++ b/src/share/classes/com/sun/tools/javac/code/Attribute.java Fri Nov 02 17:55:34 2012 -0700 58.3 @@ -34,8 +34,6 @@ 58.4 import com.sun.tools.javac.code.Symbol.*; 58.5 import com.sun.tools.javac.util.*; 58.6 58.7 -import static com.sun.tools.javac.code.TypeTags.*; 58.8 - 58.9 /** An annotation value. 58.10 * 58.11 * <p><b>This is NOT part of any supported API.
59.1 --- a/src/share/classes/com/sun/tools/javac/code/Flags.java Thu Nov 01 14:13:13 2012 -0700 59.2 +++ b/src/share/classes/com/sun/tools/javac/code/Flags.java Fri Nov 02 17:55:34 2012 -0700 59.3 @@ -258,6 +258,12 @@ 59.4 */ 59.5 public static final long DEFAULT = 1L<<43; 59.6 59.7 + /** 59.8 + * Flag that marks class as auxiliary, ie a non-public class following 59.9 + * the public class in a source file, that could block implicit compilation. 59.10 + */ 59.11 + public static final long AUXILIARY = 1L<<43; 59.12 + 59.13 /** Modifier masks. 59.14 */ 59.15 public static final int
60.1 --- a/src/share/classes/com/sun/tools/javac/code/Kinds.java Thu Nov 01 14:13:13 2012 -0700 60.2 +++ b/src/share/classes/com/sun/tools/javac/code/Kinds.java Fri Nov 02 17:55:34 2012 -0700 60.3 @@ -32,7 +32,9 @@ 60.4 import com.sun.tools.javac.api.Formattable; 60.5 import com.sun.tools.javac.api.Messages; 60.6 import static com.sun.tools.javac.code.Flags.*; 60.7 -import static com.sun.tools.javac.code.TypeTags.*; 60.8 +import static com.sun.tools.javac.code.TypeTag.CLASS; 60.9 +import static com.sun.tools.javac.code.TypeTag.PACKAGE; 60.10 +import static com.sun.tools.javac.code.TypeTag.TYPEVAR; 60.11 60.12 /** Internal symbol kinds, which distinguish between elements of 60.13 * different subclasses of Symbol. Symbol kinds are organized so they can be
61.1 --- a/src/share/classes/com/sun/tools/javac/code/Lint.java Thu Nov 01 14:13:13 2012 -0700 61.2 +++ b/src/share/classes/com/sun/tools/javac/code/Lint.java Fri Nov 02 17:55:34 2012 -0700 61.3 @@ -129,6 +129,13 @@ 61.4 */ 61.5 public enum LintCategory { 61.6 /** 61.7 + * Warn when code refers to a auxiliary class that is hidden in a source file (ie source file name is 61.8 + * different from the class name, and the type is not properly nested) and the referring code 61.9 + * is not located in the same source file. 61.10 + */ 61.11 + AUXILIARYCLASS("auxiliaryclass"), 61.12 + 61.13 + /** 61.14 * Warn about use of unnecessary casts. 61.15 */ 61.16 CAST("cast"),
62.1 --- a/src/share/classes/com/sun/tools/javac/code/Printer.java Thu Nov 01 14:13:13 2012 -0700 62.2 +++ b/src/share/classes/com/sun/tools/javac/code/Printer.java Fri Nov 02 17:55:34 2012 -0700 62.3 @@ -32,9 +32,12 @@ 62.4 import com.sun.tools.javac.code.Type.*; 62.5 import com.sun.tools.javac.util.List; 62.6 import com.sun.tools.javac.util.ListBuffer; 62.7 + 62.8 import static com.sun.tools.javac.code.BoundKind.*; 62.9 import static com.sun.tools.javac.code.Flags.*; 62.10 -import static com.sun.tools.javac.code.TypeTags.*; 62.11 +import static com.sun.tools.javac.code.TypeTag.ARRAY; 62.12 +import static com.sun.tools.javac.code.TypeTag.CLASS; 62.13 +import static com.sun.tools.javac.code.TypeTag.FORALL; 62.14 62.15 /** 62.16 * A combined type/symbol visitor for generating non-trivial localized string
63.1 --- a/src/share/classes/com/sun/tools/javac/code/Symbol.java Thu Nov 01 14:13:13 2012 -0700 63.2 +++ b/src/share/classes/com/sun/tools/javac/code/Symbol.java Fri Nov 02 17:55:34 2012 -0700 63.3 @@ -42,7 +42,9 @@ 63.4 import com.sun.tools.javac.util.Name; 63.5 import static com.sun.tools.javac.code.Flags.*; 63.6 import static com.sun.tools.javac.code.Kinds.*; 63.7 -import static com.sun.tools.javac.code.TypeTags.*; 63.8 +import static com.sun.tools.javac.code.TypeTag.CLASS; 63.9 +import static com.sun.tools.javac.code.TypeTag.FORALL; 63.10 +import static com.sun.tools.javac.code.TypeTag.TYPEVAR; 63.11 63.12 /** Root class for Java symbols. It contains subclasses 63.13 * for specific sorts of symbols, such as variables, methods and operators, 63.14 @@ -161,7 +163,7 @@ 63.15 if (owner.name == null || owner.name.isEmpty()) { 63.16 return location(); 63.17 } 63.18 - if (owner.type.tag == CLASS) { 63.19 + if (owner.type.hasTag(CLASS)) { 63.20 Type ownertype = types.asOuterSuper(site, owner); 63.21 if (ownertype != null) return ownertype.tsym; 63.22 } 63.23 @@ -256,7 +258,7 @@ 63.24 /** A class is an inner class if it it has an enclosing instance class. 63.25 */ 63.26 public boolean isInner() { 63.27 - return type.getEnclosingType().tag == CLASS; 63.28 + return type.getEnclosingType().hasTag(CLASS); 63.29 } 63.30 63.31 /** An inner class has an outer instance if it is not an interface 63.32 @@ -269,7 +271,7 @@ 63.33 */ 63.34 public boolean hasOuterInstance() { 63.35 return 63.36 - type.getEnclosingType().tag == CLASS && (flags() & (INTERFACE | NOOUTERTHIS)) == 0; 63.37 + type.getEnclosingType().hasTag(CLASS) && (flags() & (INTERFACE | NOOUTERTHIS)) == 0; 63.38 } 63.39 63.40 /** The closest enclosing class of this symbol's declaration. 63.41 @@ -277,7 +279,7 @@ 63.42 public ClassSymbol enclClass() { 63.43 Symbol c = this; 63.44 while (c != null && 63.45 - ((c.kind & TYP) == 0 || c.type.tag != CLASS)) { 63.46 + ((c.kind & TYP) == 0 || !c.type.hasTag(CLASS))) { 63.47 c = c.owner; 63.48 } 63.49 return (ClassSymbol)c; 63.50 @@ -346,7 +348,7 @@ 63.51 e = e.next(); 63.52 } 63.53 Type superType = types.supertype(clazz.type); 63.54 - if (superType.tag != TypeTags.CLASS) return false; 63.55 + if (!superType.hasTag(CLASS)) return false; 63.56 clazz = (ClassSymbol)superType.tsym; 63.57 } 63.58 } 63.59 @@ -373,7 +375,7 @@ 63.60 for (Symbol sup = clazz; 63.61 sup != null && sup != this.owner; 63.62 sup = types.supertype(sup.type).tsym) { 63.63 - while (sup.type.tag == TYPEVAR) 63.64 + while (sup.type.hasTag(TYPEVAR)) 63.65 sup = sup.type.getUpperBound().tsym; 63.66 if (sup.type.isErroneous()) 63.67 return true; // error recovery 63.68 @@ -520,7 +522,7 @@ 63.69 if (owner == null) return name; 63.70 if (((owner.kind != ERR)) && 63.71 ((owner.kind & (VAR | MTH)) != 0 63.72 - || (owner.kind == TYP && owner.type.tag == TYPEVAR) 63.73 + || (owner.kind == TYP && owner.type.hasTag(TYPEVAR)) 63.74 )) return name; 63.75 Name prefix = owner.getQualifiedName(); 63.76 if (prefix == null || prefix == prefix.table.names.empty) 63.77 @@ -534,7 +536,7 @@ 63.78 static public Name formFlatName(Name name, Symbol owner) { 63.79 if (owner == null || 63.80 (owner.kind & (VAR | MTH)) != 0 63.81 - || (owner.kind == TYP && owner.type.tag == TYPEVAR) 63.82 + || (owner.kind == TYP && owner.type.hasTag(TYPEVAR)) 63.83 ) return name; 63.84 char sep = owner.kind == TYP ? '$' : '.'; 63.85 Name prefix = owner.flatName(); 63.86 @@ -553,16 +555,16 @@ 63.87 if (this == that) 63.88 return false; 63.89 if (this.type.tag == that.type.tag) { 63.90 - if (this.type.tag == CLASS) { 63.91 + if (this.type.hasTag(CLASS)) { 63.92 return 63.93 types.rank(that.type) < types.rank(this.type) || 63.94 types.rank(that.type) == types.rank(this.type) && 63.95 that.getQualifiedName().compareTo(this.getQualifiedName()) < 0; 63.96 - } else if (this.type.tag == TYPEVAR) { 63.97 + } else if (this.type.hasTag(TYPEVAR)) { 63.98 return types.isSubtype(this.type, that.type); 63.99 } 63.100 } 63.101 - return this.type.tag == TYPEVAR; 63.102 + return this.type.hasTag(TYPEVAR); 63.103 } 63.104 63.105 // For type params; overridden in subclasses. 63.106 @@ -572,7 +574,7 @@ 63.107 63.108 public java.util.List<Symbol> getEnclosedElements() { 63.109 List<Symbol> list = List.nil(); 63.110 - if (kind == TYP && type.tag == TYPEVAR) { 63.111 + if (kind == TYP && type.hasTag(TYPEVAR)) { 63.112 return list; 63.113 } 63.114 for (Scope.Entry e = members().elems; e != null; e = e.sibling) { 63.115 @@ -591,7 +593,7 @@ 63.116 } 63.117 63.118 public <R, P> R accept(ElementVisitor<R, P> v, P p) { 63.119 - Assert.check(type.tag == TYPEVAR); // else override will be invoked 63.120 + Assert.check(type.hasTag(TYPEVAR)); // else override will be invoked 63.121 return v.visitTypeParameter(this, p); 63.122 } 63.123 63.124 @@ -798,13 +800,13 @@ 63.125 if (this == base) { 63.126 return true; 63.127 } else if ((base.flags() & INTERFACE) != 0) { 63.128 - for (Type t = type; t.tag == CLASS; t = types.supertype(t)) 63.129 + for (Type t = type; t.hasTag(CLASS); t = types.supertype(t)) 63.130 for (List<Type> is = types.interfaces(t); 63.131 is.nonEmpty(); 63.132 is = is.tail) 63.133 if (is.head.tsym.isSubClass(base, types)) return true; 63.134 } else { 63.135 - for (Type t = type; t.tag == CLASS; t = types.supertype(t)) 63.136 + for (Type t = type; t.hasTag(CLASS); t = types.supertype(t)) 63.137 if (t.tsym == base) return true; 63.138 } 63.139 return false; 63.140 @@ -1048,7 +1050,7 @@ 63.141 */ 63.142 public MethodSymbol(long flags, Name name, Type type, Symbol owner) { 63.143 super(MTH, flags, name, type, owner); 63.144 - if (owner.type.tag == TYPEVAR) Assert.error(owner + "." + name); 63.145 + if (owner.type.hasTag(TYPEVAR)) Assert.error(owner + "." + name); 63.146 } 63.147 63.148 /** Clone this symbol with new owner. 63.149 @@ -1074,7 +1076,7 @@ 63.150 ? owner.name.toString() 63.151 : name.toString(); 63.152 if (type != null) { 63.153 - if (type.tag == FORALL) 63.154 + if (type.hasTag(FORALL)) 63.155 s = "<" + ((ForAll)type).getTypeArguments() + ">" + s; 63.156 s += "(" + type.argtypes((flags() & VARARGS) != 0) + ")"; 63.157 }
64.1 --- a/src/share/classes/com/sun/tools/javac/code/Symtab.java Thu Nov 01 14:13:13 2012 -0700 64.2 +++ b/src/share/classes/com/sun/tools/javac/code/Symtab.java Fri Nov 02 17:55:34 2012 -0700 64.3 @@ -37,6 +37,7 @@ 64.4 import com.sun.tools.javac.util.List; 64.5 import static com.sun.tools.javac.code.Flags.*; 64.6 import static com.sun.tools.javac.jvm.ByteCodes.*; 64.7 +import static com.sun.tools.javac.code.TypeTag.*; 64.8 64.9 /** A class that defines all predefined constants and operators 64.10 * as well as special classes such as java.lang.Object, which need 64.11 @@ -64,16 +65,16 @@ 64.12 64.13 /** Builtin types. 64.14 */ 64.15 - public final Type byteType = new Type(TypeTags.BYTE, null); 64.16 - public final Type charType = new Type(TypeTags.CHAR, null); 64.17 - public final Type shortType = new Type(TypeTags.SHORT, null); 64.18 - public final Type intType = new Type(TypeTags.INT, null); 64.19 - public final Type longType = new Type(TypeTags.LONG, null); 64.20 - public final Type floatType = new Type(TypeTags.FLOAT, null); 64.21 - public final Type doubleType = new Type(TypeTags.DOUBLE, null); 64.22 - public final Type booleanType = new Type(TypeTags.BOOLEAN, null); 64.23 + public final Type byteType = new Type(BYTE, null); 64.24 + public final Type charType = new Type(CHAR, null); 64.25 + public final Type shortType = new Type(SHORT, null); 64.26 + public final Type intType = new Type(INT, null); 64.27 + public final Type longType = new Type(LONG, null); 64.28 + public final Type floatType = new Type(FLOAT, null); 64.29 + public final Type doubleType = new Type(DOUBLE, null); 64.30 + public final Type booleanType = new Type(BOOLEAN, null); 64.31 public final Type botType = new BottomType(); 64.32 - public final JCNoType voidType = new JCNoType(TypeTags.VOID); 64.33 + public final JCNoType voidType = new JCNoType(VOID); 64.34 64.35 private final Names names; 64.36 private final ClassReader reader; 64.37 @@ -126,6 +127,7 @@ 64.38 public final Type cloneableType; 64.39 public final Type serializableType; 64.40 public final Type methodHandleType; 64.41 + public final Type methodHandleLookupType; 64.42 public final Type methodTypeType; 64.43 public final Type nativeHeaderType; 64.44 public final Type throwableType; 64.45 @@ -157,6 +159,7 @@ 64.46 public final Type systemType; 64.47 public final Type autoCloseableType; 64.48 public final Type trustMeType; 64.49 + public final Type lambdaMetafactory; 64.50 public final Type containedByType; 64.51 public final Type containerForType; 64.52 public final Type documentedType; 64.53 @@ -177,11 +180,11 @@ 64.54 64.55 /** The predefined type that belongs to a tag. 64.56 */ 64.57 - public final Type[] typeOfTag = new Type[TypeTags.TypeTagCount]; 64.58 + public final Type[] typeOfTag = new Type[TypeTag.getTypeTagCount()]; 64.59 64.60 /** The name of the class that belongs to a basix type tag. 64.61 */ 64.62 - public final Name[] boxedName = new Name[TypeTags.TypeTagCount]; 64.63 + public final Name[] boxedName = new Name[TypeTag.getTypeTagCount()]; 64.64 64.65 /** A set containing all operator names. 64.66 */ 64.67 @@ -202,7 +205,7 @@ 64.68 64.69 public void initType(Type type, ClassSymbol c) { 64.70 type.tsym = c; 64.71 - typeOfTag[type.tag] = type; 64.72 + typeOfTag[type.tag.ordinal()] = type; 64.73 } 64.74 64.75 public void initType(Type type, String name) { 64.76 @@ -214,7 +217,7 @@ 64.77 64.78 public void initType(Type type, String name, String bname) { 64.79 initType(type, name); 64.80 - boxedName[type.tag] = names.fromString("java.lang." + bname); 64.81 + boxedName[type.tag.ordinal()] = names.fromString("java.lang." + bname); 64.82 } 64.83 64.84 /** The class symbol that owns all predefined symbols. 64.85 @@ -324,7 +327,7 @@ 64.86 } 64.87 64.88 public void synthesizeBoxTypeIfMissing(final Type type) { 64.89 - ClassSymbol sym = reader.enterClass(boxedName[type.tag]); 64.90 + ClassSymbol sym = reader.enterClass(boxedName[type.tag.ordinal()]); 64.91 final Completer completer = sym.completer; 64.92 if (completer != null) { 64.93 sym.completer = new Completer() { 64.94 @@ -366,7 +369,7 @@ 64.95 target = Target.instance(context); 64.96 64.97 // Create the unknown type 64.98 - unknownType = new Type(TypeTags.UNKNOWN, null) { 64.99 + unknownType = new Type(UNKNOWN, null) { 64.100 @Override 64.101 public <R, P> R accept(TypeVisitor<R, P> v, P p) { 64.102 return v.visitUnknown(this, p); 64.103 @@ -455,6 +458,7 @@ 64.104 throwableType = enterClass("java.lang.Throwable"); 64.105 serializableType = enterClass("java.io.Serializable"); 64.106 methodHandleType = enterClass("java.lang.invoke.MethodHandle"); 64.107 + methodHandleLookupType = enterClass("java.lang.invoke.MethodHandles$Lookup"); 64.108 methodTypeType = enterClass("java.lang.invoke.MethodType"); 64.109 errorType = enterClass("java.lang.Error"); 64.110 illegalArgumentExceptionType = enterClass("java.lang.IllegalArgumentException"); 64.111 @@ -502,10 +506,12 @@ 64.112 autoCloseableType.tsym); 64.113 trustMeType = enterClass("java.lang.SafeVarargs"); 64.114 nativeHeaderType = enterClass("javax.tools.annotation.GenerateNativeHeader"); 64.115 + lambdaMetafactory = enterClass("java.lang.invoke.LambdaMetafactory"); 64.116 64.117 synthesizeEmptyInterfaceIfMissing(autoCloseableType); 64.118 synthesizeEmptyInterfaceIfMissing(cloneableType); 64.119 synthesizeEmptyInterfaceIfMissing(serializableType); 64.120 + synthesizeEmptyInterfaceIfMissing(lambdaMetafactory); 64.121 synthesizeBoxTypeIfMissing(doubleType); 64.122 synthesizeBoxTypeIfMissing(floatType); 64.123 synthesizeBoxTypeIfMissing(voidType);
65.1 --- a/src/share/classes/com/sun/tools/javac/code/Type.java Thu Nov 01 14:13:13 2012 -0700 65.2 +++ b/src/share/classes/com/sun/tools/javac/code/Type.java Fri Nov 02 17:55:34 2012 -0700 65.3 @@ -38,7 +38,7 @@ 65.4 import static com.sun.tools.javac.code.BoundKind.*; 65.5 import static com.sun.tools.javac.code.Flags.*; 65.6 import static com.sun.tools.javac.code.Kinds.*; 65.7 -import static com.sun.tools.javac.code.TypeTags.*; 65.8 +import static com.sun.tools.javac.code.TypeTag.*; 65.9 65.10 /** This class represents Java types. The class itself defines the behavior of 65.11 * the following types: 65.12 @@ -66,7 +66,7 @@ 65.13 * This code and its internal interfaces are subject to change or 65.14 * deletion without notice.</b> 65.15 * 65.16 - * @see TypeTags 65.17 + * @see TypeTag 65.18 */ 65.19 public class Type implements PrimitiveType { 65.20 65.21 @@ -83,15 +83,77 @@ 65.22 65.23 /** The tag of this type. 65.24 * 65.25 - * @see TypeTags 65.26 + * @see TypeTag 65.27 */ 65.28 - public int tag; 65.29 + protected TypeTag tag; 65.30 65.31 /** The defining class / interface / package / type variable 65.32 */ 65.33 public TypeSymbol tsym; 65.34 65.35 /** 65.36 + * Checks if the current type tag is equal to the given tag. 65.37 + * @return true if tag is equal to the current type tag. 65.38 + */ 65.39 + public boolean hasTag(TypeTag tag) { 65.40 + return this.tag == tag; 65.41 + } 65.42 + 65.43 + /** 65.44 + * Returns the current type tag. 65.45 + * @return the value of the current type tag. 65.46 + */ 65.47 + public TypeTag getTag() { 65.48 + return tag; 65.49 + } 65.50 + 65.51 + public boolean isNumeric() { 65.52 + switch (tag) { 65.53 + case BYTE: case CHAR: 65.54 + case SHORT: 65.55 + case INT: case LONG: 65.56 + case FLOAT: case DOUBLE: 65.57 + return true; 65.58 + default: 65.59 + return false; 65.60 + } 65.61 + } 65.62 + 65.63 + public boolean isPrimitive() { 65.64 + return (isNumeric() || tag == BOOLEAN); 65.65 + } 65.66 + 65.67 + public boolean isPrimitiveOrVoid() { 65.68 + return (isPrimitive() || tag == VOID); 65.69 + } 65.70 + 65.71 + public boolean isReference() { 65.72 + switch (tag) { 65.73 + case CLASS: 65.74 + case ARRAY: 65.75 + case TYPEVAR: 65.76 + case WILDCARD: 65.77 + case ERROR: 65.78 + return true; 65.79 + default: 65.80 + return false; 65.81 + } 65.82 + } 65.83 + 65.84 + public boolean isNullOrReference() { 65.85 + return (tag == BOT || isReference()); 65.86 + } 65.87 + 65.88 + public boolean isPartial() { 65.89 + switch(tag) { 65.90 + case ERROR: case UNKNOWN: case UNDETVAR: 65.91 + return true; 65.92 + default: 65.93 + return false; 65.94 + } 65.95 + } 65.96 + 65.97 + /** 65.98 * The constant value of this type, null if this type does not 65.99 * have a constant value attribute. Only primitive types and 65.100 * strings (ClassType) can have a constant value attribute. 65.101 @@ -121,7 +183,7 @@ 65.102 65.103 /** Define a type given its tag and type symbol 65.104 */ 65.105 - public Type(int tag, TypeSymbol tsym) { 65.106 + public Type(TypeTag tag, TypeSymbol tsym) { 65.107 this.tag = tag; 65.108 this.tsym = tsym; 65.109 } 65.110 @@ -162,7 +224,7 @@ 65.111 */ 65.112 public Type constType(Object constValue) { 65.113 final Object value = constValue; 65.114 - Assert.check(tag <= BOOLEAN); 65.115 + Assert.check(isPrimitive()); 65.116 return new Type(tag, tsym) { 65.117 @Override 65.118 public Object constValue() { 65.119 @@ -352,10 +414,6 @@ 65.120 return (tsym.flags() & FINAL) != 0; 65.121 } 65.122 65.123 - public boolean isPrimitive() { 65.124 - return tag < VOID; 65.125 - } 65.126 - 65.127 /** 65.128 * Does this type contain occurrences of type t? 65.129 */ 65.130 @@ -808,7 +866,7 @@ 65.131 } 65.132 65.133 public int hashCode() { 65.134 - return (ARRAY << 5) + elemtype.hashCode(); 65.135 + return (ARRAY.ordinal() << 5) + elemtype.hashCode(); 65.136 } 65.137 65.138 public boolean isVarargs() { 65.139 @@ -915,7 +973,7 @@ 65.140 } 65.141 65.142 public int hashCode() { 65.143 - int h = METHOD; 65.144 + int h = METHOD.ordinal(); 65.145 for (List<Type> thisargs = this.argtypes; 65.146 thisargs.tail != null; /*inlined: thisargs.nonEmpty()*/ 65.147 thisargs = thisargs.tail) 65.148 @@ -1099,7 +1157,7 @@ 65.149 65.150 public static abstract class DelegatedType extends Type { 65.151 public Type qtype; 65.152 - public DelegatedType(int tag, Type qtype) { 65.153 + public DelegatedType(TypeTag tag, Type qtype) { 65.154 super(tag, qtype.tsym); 65.155 this.qtype = qtype; 65.156 } 65.157 @@ -1285,7 +1343,7 @@ 65.158 /** Represents VOID or NONE. 65.159 */ 65.160 static class JCNoType extends Type implements NoType { 65.161 - public JCNoType(int tag) { 65.162 + public JCNoType(TypeTag tag) { 65.163 super(tag, null); 65.164 } 65.165 65.166 @@ -1307,7 +1365,7 @@ 65.167 65.168 static class BottomType extends Type implements NullType { 65.169 public BottomType() { 65.170 - super(TypeTags.BOT, null); 65.171 + super(BOT, null); 65.172 } 65.173 65.174 @Override
66.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 66.2 +++ b/src/share/classes/com/sun/tools/javac/code/TypeTag.java Fri Nov 02 17:55:34 2012 -0700 66.3 @@ -0,0 +1,226 @@ 66.4 +/* 66.5 + * Copyright (c) 1999, 2012, 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. Oracle designates this 66.11 + * particular file as subject to the "Classpath" exception as provided 66.12 + * by Oracle in the LICENSE file that accompanied this code. 66.13 + * 66.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 66.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 66.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 66.17 + * version 2 for more details (a copy is included in the LICENSE file that 66.18 + * accompanied this code). 66.19 + * 66.20 + * You should have received a copy of the GNU General Public License version 66.21 + * 2 along with this work; if not, write to the Free Software Foundation, 66.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 66.23 + * 66.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 66.25 + * or visit www.oracle.com if you need additional information or have any 66.26 + * questions. 66.27 + */ 66.28 + 66.29 +package com.sun.tools.javac.code; 66.30 + 66.31 +import com.sun.source.tree.Tree.Kind; 66.32 + 66.33 +import javax.lang.model.type.TypeKind; 66.34 + 66.35 +/** An interface for type tag values, which distinguish between different 66.36 + * sorts of types. 66.37 + * 66.38 + * <p><b>This is NOT part of any supported API. 66.39 + * If you write code that depends on this, you do so at your own risk. 66.40 + * This code and its internal interfaces are subject to change or 66.41 + * deletion without notice.</b> 66.42 + */ 66.43 +public enum TypeTag { 66.44 + /** The tag of the basic type `byte'. 66.45 + */ 66.46 + BYTE(1), 66.47 + 66.48 + /** The tag of the basic type `char'. 66.49 + */ 66.50 + CHAR(2), 66.51 + 66.52 + /** The tag of the basic type `short'. 66.53 + */ 66.54 + SHORT(3), 66.55 + 66.56 + /** The tag of the basic type `int'. 66.57 + */ 66.58 + INT(4), 66.59 + 66.60 + /** The tag of the basic type `long'. 66.61 + */ 66.62 + LONG(5), 66.63 + 66.64 + /** The tag of the basic type `float'. 66.65 + */ 66.66 + FLOAT(6), 66.67 + 66.68 + /** The tag of the basic type `double'. 66.69 + */ 66.70 + DOUBLE(7), 66.71 + 66.72 + /** The tag of the basic type `boolean'. 66.73 + */ 66.74 + BOOLEAN, 66.75 + 66.76 + /** The tag of the type `void'. 66.77 + */ 66.78 + VOID, 66.79 + 66.80 + /** The tag of all class and interface types. 66.81 + */ 66.82 + CLASS, 66.83 + 66.84 + /** The tag of all array types. 66.85 + */ 66.86 + ARRAY, 66.87 + 66.88 + /** The tag of all (monomorphic) method types. 66.89 + */ 66.90 + METHOD, 66.91 + 66.92 + /** The tag of all package "types". 66.93 + */ 66.94 + PACKAGE, 66.95 + 66.96 + /** The tag of all (source-level) type variables. 66.97 + */ 66.98 + TYPEVAR, 66.99 + 66.100 + /** The tag of all type arguments. 66.101 + */ 66.102 + WILDCARD, 66.103 + 66.104 + /** The tag of all polymorphic (method-) types. 66.105 + */ 66.106 + FORALL, 66.107 + 66.108 + /** The tag of deferred expression types in method context 66.109 + */ 66.110 + DEFERRED, 66.111 + 66.112 + /** The tag of the bottom type {@code <null>}. 66.113 + */ 66.114 + BOT, 66.115 + 66.116 + /** The tag of a missing type. 66.117 + */ 66.118 + NONE, 66.119 + 66.120 + /** The tag of the error type. 66.121 + */ 66.122 + ERROR, 66.123 + 66.124 + /** The tag of an unknown type 66.125 + */ 66.126 + UNKNOWN, 66.127 + 66.128 + /** The tag of all instantiatable type variables. 66.129 + */ 66.130 + UNDETVAR, 66.131 + 66.132 + /** Pseudo-types, these are special tags 66.133 + */ 66.134 + UNINITIALIZED_THIS, 66.135 + 66.136 + UNINITIALIZED_OBJECT; 66.137 + 66.138 + /** This field will only be used for tags related with numeric types for 66.139 + * optimization reasons. 66.140 + */ 66.141 + private int order = 0; 66.142 + 66.143 + private TypeTag() {} 66.144 + 66.145 + private TypeTag(int order) { 66.146 + this.order = order; 66.147 + } 66.148 + 66.149 + private static final int MIN_NUMERIC_TAG_ORDER = 1; 66.150 + private static final int MAX_NUMERIC_TAG_ORDER = 7; 66.151 + 66.152 + /** Returns the number of type tags. 66.153 + */ 66.154 + public static int getTypeTagCount() { 66.155 + // last two tags are not included in the total as long as they are pseudo-types 66.156 + return (UNDETVAR.ordinal() + 1); 66.157 + } 66.158 + 66.159 + public boolean isSubRangeOf(TypeTag range) { 66.160 + return (this == range) || isStrictSubRangeOf(range); 66.161 + } 66.162 + 66.163 + public boolean isStrictSubRangeOf(TypeTag range) { 66.164 + if (this.order >= MIN_NUMERIC_TAG_ORDER && this.order <= MAX_NUMERIC_TAG_ORDER && 66.165 + range.order >= MIN_NUMERIC_TAG_ORDER && this.order <= MAX_NUMERIC_TAG_ORDER) { 66.166 + if (this == range) 66.167 + return false; 66.168 + switch (this) { 66.169 + case BYTE: 66.170 + return true; 66.171 + case CHAR: case SHORT: case INT: 66.172 + case LONG: case FLOAT: 66.173 + return this.order < range.order && range.order <= MAX_NUMERIC_TAG_ORDER; 66.174 + default: 66.175 + return false; 66.176 + } 66.177 + } 66.178 + else 66.179 + return false; 66.180 + } 66.181 + 66.182 + public Kind getKindLiteral() { 66.183 + switch (this) { 66.184 + case INT: 66.185 + return Kind.INT_LITERAL; 66.186 + case LONG: 66.187 + return Kind.LONG_LITERAL; 66.188 + case FLOAT: 66.189 + return Kind.FLOAT_LITERAL; 66.190 + case DOUBLE: 66.191 + return Kind.DOUBLE_LITERAL; 66.192 + case BOOLEAN: 66.193 + return Kind.BOOLEAN_LITERAL; 66.194 + case CHAR: 66.195 + return Kind.CHAR_LITERAL; 66.196 + case CLASS: 66.197 + return Kind.STRING_LITERAL; 66.198 + case BOT: 66.199 + return Kind.NULL_LITERAL; 66.200 + default: 66.201 + throw new AssertionError("unknown literal kind " + this); 66.202 + } 66.203 + } 66.204 + 66.205 + public TypeKind getPrimitiveTypeKind() { 66.206 + switch (this) { 66.207 + case BOOLEAN: 66.208 + return TypeKind.BOOLEAN; 66.209 + case BYTE: 66.210 + return TypeKind.BYTE; 66.211 + case SHORT: 66.212 + return TypeKind.SHORT; 66.213 + case INT: 66.214 + return TypeKind.INT; 66.215 + case LONG: 66.216 + return TypeKind.LONG; 66.217 + case CHAR: 66.218 + return TypeKind.CHAR; 66.219 + case FLOAT: 66.220 + return TypeKind.FLOAT; 66.221 + case DOUBLE: 66.222 + return TypeKind.DOUBLE; 66.223 + case VOID: 66.224 + return TypeKind.VOID; 66.225 + default: 66.226 + throw new AssertionError("unknown primitive type " + this); 66.227 + } 66.228 + } 66.229 +}
67.1 --- a/src/share/classes/com/sun/tools/javac/code/TypeTags.java Thu Nov 01 14:13:13 2012 -0700 67.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 67.3 @@ -1,140 +0,0 @@ 67.4 -/* 67.5 - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. 67.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 67.7 - * 67.8 - * This code is free software; you can redistribute it and/or modify it 67.9 - * under the terms of the GNU General Public License version 2 only, as 67.10 - * published by the Free Software Foundation. Oracle designates this 67.11 - * particular file as subject to the "Classpath" exception as provided 67.12 - * by Oracle in the LICENSE file that accompanied this code. 67.13 - * 67.14 - * This code is distributed in the hope that it will be useful, but WITHOUT 67.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 67.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 67.17 - * version 2 for more details (a copy is included in the LICENSE file that 67.18 - * accompanied this code). 67.19 - * 67.20 - * You should have received a copy of the GNU General Public License version 67.21 - * 2 along with this work; if not, write to the Free Software Foundation, 67.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 67.23 - * 67.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 67.25 - * or visit www.oracle.com if you need additional information or have any 67.26 - * questions. 67.27 - */ 67.28 - 67.29 -package com.sun.tools.javac.code; 67.30 - 67.31 - 67.32 -/** An interface for type tag values, which distinguish between different 67.33 - * sorts of types. 67.34 - * 67.35 - * <p><b>This is NOT part of any supported API. 67.36 - * If you write code that depends on this, you do so at your own risk. 67.37 - * This code and its internal interfaces are subject to change or 67.38 - * deletion without notice.</b> 67.39 - */ 67.40 -public class TypeTags { 67.41 - 67.42 - private TypeTags() {} // uninstantiable 67.43 - 67.44 - /** The tag of the basic type `byte'. 67.45 - */ 67.46 - public static final int BYTE = 1; 67.47 - 67.48 - /** The tag of the basic type `char'. 67.49 - */ 67.50 - public static final int CHAR = BYTE+1; 67.51 - 67.52 - /** The tag of the basic type `short'. 67.53 - */ 67.54 - public static final int SHORT = CHAR+1; 67.55 - 67.56 - /** The tag of the basic type `int'. 67.57 - */ 67.58 - public static final int INT = SHORT+1; 67.59 - 67.60 - /** The tag of the basic type `long'. 67.61 - */ 67.62 - public static final int LONG = INT+1; 67.63 - 67.64 - /** The tag of the basic type `float'. 67.65 - */ 67.66 - public static final int FLOAT = LONG+1; 67.67 - 67.68 - /** The tag of the basic type `double'. 67.69 - */ 67.70 - public static final int DOUBLE = FLOAT+1; 67.71 - 67.72 - /** The tag of the basic type `boolean'. 67.73 - */ 67.74 - public static final int BOOLEAN = DOUBLE+1; 67.75 - 67.76 - /** The tag of the type `void'. 67.77 - */ 67.78 - public static final int VOID = BOOLEAN+1; 67.79 - 67.80 - /** The tag of all class and interface types. 67.81 - */ 67.82 - public static final int CLASS = VOID+1; 67.83 - 67.84 - /** The tag of all array types. 67.85 - */ 67.86 - public static final int ARRAY = CLASS+1; 67.87 - 67.88 - /** The tag of all (monomorphic) method types. 67.89 - */ 67.90 - public static final int METHOD = ARRAY+1; 67.91 - 67.92 - /** The tag of all package "types". 67.93 - */ 67.94 - public static final int PACKAGE = METHOD+1; 67.95 - 67.96 - /** The tag of all (source-level) type variables. 67.97 - */ 67.98 - public static final int TYPEVAR = PACKAGE+1; 67.99 - 67.100 - /** The tag of all type arguments. 67.101 - */ 67.102 - public static final int WILDCARD = TYPEVAR+1; 67.103 - 67.104 - /** The tag of all polymorphic (method-) types. 67.105 - */ 67.106 - public static final int FORALL = WILDCARD+1; 67.107 - 67.108 - /** The tag of deferred expression types in method context 67.109 - */ 67.110 - public static final int DEFERRED = FORALL+1; 67.111 - 67.112 - /** The tag of the bottom type {@code <null>}. 67.113 - */ 67.114 - public static final int BOT = DEFERRED+1; 67.115 - 67.116 - /** The tag of a missing type. 67.117 - */ 67.118 - public static final int NONE = BOT+1; 67.119 - 67.120 - /** The tag of the error type. 67.121 - */ 67.122 - public static final int ERROR = NONE+1; 67.123 - 67.124 - /** The tag of an unknown type 67.125 - */ 67.126 - public static final int UNKNOWN = ERROR+1; 67.127 - 67.128 - /** The tag of all instantiatable type variables. 67.129 - */ 67.130 - public static final int UNDETVAR = UNKNOWN+1; 67.131 - 67.132 - /** The number of type tags. 67.133 - */ 67.134 - public static final int TypeTagCount = UNDETVAR+1; 67.135 - 67.136 - /** The maximum tag of a basic type. 67.137 - */ 67.138 - public static final int lastBaseTag = BOOLEAN; 67.139 - 67.140 - /** The minimum tag of a partial type 67.141 - */ 67.142 - public static final int firstPartialTag = ERROR; 67.143 -}
68.1 --- a/src/share/classes/com/sun/tools/javac/code/Types.java Thu Nov 01 14:13:13 2012 -0700 68.2 +++ b/src/share/classes/com/sun/tools/javac/code/Types.java Fri Nov 02 17:55:34 2012 -0700 68.3 @@ -40,7 +40,7 @@ 68.4 import static com.sun.tools.javac.code.Scope.*; 68.5 import static com.sun.tools.javac.code.Symbol.*; 68.6 import static com.sun.tools.javac.code.Type.*; 68.7 -import static com.sun.tools.javac.code.TypeTags.*; 68.8 +import static com.sun.tools.javac.code.TypeTag.*; 68.9 import static com.sun.tools.javac.util.ListBuffer.lb; 68.10 68.11 /** 68.12 @@ -605,8 +605,8 @@ 68.13 } 68.14 //where 68.15 private boolean isSubtypeUncheckedInternal(Type t, Type s, Warner warn) { 68.16 - if (t.tag == ARRAY && s.tag == ARRAY) { 68.17 - if (((ArrayType)t).elemtype.tag <= lastBaseTag) { 68.18 + if (t.hasTag(ARRAY) && s.hasTag(ARRAY)) { 68.19 + if (((ArrayType)t).elemtype.isPrimitive()) { 68.20 return isSameType(elemtype(t), elemtype(s)); 68.21 } else { 68.22 return isSubtypeUnchecked(elemtype(t), elemtype(s), warn); 68.23 @@ -664,7 +664,7 @@ 68.24 if (t == s) 68.25 return true; 68.26 68.27 - if (s.tag >= firstPartialTag) 68.28 + if (s.isPartial()) 68.29 return isSuperType(s, t); 68.30 68.31 if (s.isCompound()) { 68.32 @@ -686,25 +686,27 @@ 68.33 { 68.34 public Boolean visitType(Type t, Type s) { 68.35 switch (t.tag) { 68.36 - case BYTE: case CHAR: 68.37 - return (t.tag == s.tag || 68.38 - t.tag + 2 <= s.tag && s.tag <= DOUBLE); 68.39 - case SHORT: case INT: case LONG: case FLOAT: case DOUBLE: 68.40 - return t.tag <= s.tag && s.tag <= DOUBLE; 68.41 - case BOOLEAN: case VOID: 68.42 - return t.tag == s.tag; 68.43 - case TYPEVAR: 68.44 - return isSubtypeNoCapture(t.getUpperBound(), s); 68.45 - case BOT: 68.46 - return 68.47 - s.tag == BOT || s.tag == CLASS || 68.48 - s.tag == ARRAY || s.tag == TYPEVAR; 68.49 - case WILDCARD: //we shouldn't be here - avoids crash (see 7034495) 68.50 - case NONE: 68.51 - return false; 68.52 - default: 68.53 - throw new AssertionError("isSubtype " + t.tag); 68.54 - } 68.55 + case BYTE: 68.56 + return (!s.hasTag(CHAR) && t.getTag().isSubRangeOf(s.getTag())); 68.57 + case CHAR: 68.58 + return (!s.hasTag(SHORT) && t.getTag().isSubRangeOf(s.getTag())); 68.59 + case SHORT: case INT: case LONG: 68.60 + case FLOAT: case DOUBLE: 68.61 + return t.getTag().isSubRangeOf(s.getTag()); 68.62 + case BOOLEAN: case VOID: 68.63 + return t.hasTag(s.getTag()); 68.64 + case TYPEVAR: 68.65 + return isSubtypeNoCapture(t.getUpperBound(), s); 68.66 + case BOT: 68.67 + return 68.68 + s.hasTag(BOT) || s.hasTag(CLASS) || 68.69 + s.hasTag(ARRAY) || s.hasTag(TYPEVAR); 68.70 + case WILDCARD: //we shouldn't be here - avoids crash (see 7034495) 68.71 + case NONE: 68.72 + return false; 68.73 + default: 68.74 + throw new AssertionError("isSubtype " + t.tag); 68.75 + } 68.76 } 68.77 68.78 private Set<TypePair> cache = new HashSet<TypePair>(); 68.79 @@ -774,7 +776,7 @@ 68.80 @Override 68.81 public Boolean visitArrayType(ArrayType t, Type s) { 68.82 if (s.tag == ARRAY) { 68.83 - if (t.elemtype.tag <= lastBaseTag) 68.84 + if (t.elemtype.isPrimitive()) 68.85 return isSameType(t.elemtype, elemtype(s)); 68.86 else 68.87 return isSubtypeNoCapture(t.elemtype, elemtype(s)); 68.88 @@ -907,7 +909,7 @@ 68.89 if (t == s) 68.90 return true; 68.91 68.92 - if (s.tag >= firstPartialTag) 68.93 + if (s.isPartial()) 68.94 return visit(s, t); 68.95 68.96 switch (t.tag) { 68.97 @@ -936,7 +938,7 @@ 68.98 68.99 @Override 68.100 public Boolean visitWildcardType(WildcardType t, Type s) { 68.101 - if (s.tag >= firstPartialTag) 68.102 + if (s.isPartial()) 68.103 return visit(s, t); 68.104 else 68.105 return false; 68.106 @@ -947,7 +949,7 @@ 68.107 if (t == s) 68.108 return true; 68.109 68.110 - if (s.tag >= firstPartialTag) 68.111 + if (s.isPartial()) 68.112 return visit(s, t); 68.113 68.114 if (s.isSuperBound() && !s.isExtendsBound()) 68.115 @@ -976,10 +978,10 @@ 68.116 if (t == s) 68.117 return true; 68.118 68.119 - if (s.tag >= firstPartialTag) 68.120 + if (s.isPartial()) 68.121 return visit(s, t); 68.122 68.123 - return s.tag == ARRAY 68.124 + return s.hasTag(ARRAY) 68.125 && containsTypeEquivalent(t.elemtype, elemtype(s)); 68.126 } 68.127 68.128 @@ -1120,7 +1122,7 @@ 68.129 } 68.130 68.131 public Boolean visitType(Type t, Type s) { 68.132 - if (s.tag >= firstPartialTag) 68.133 + if (s.isPartial()) 68.134 return containedBy(s, t); 68.135 else 68.136 return isSameType(t, s); 68.137 @@ -1142,7 +1144,7 @@ 68.138 68.139 @Override 68.140 public Boolean visitWildcardType(WildcardType t, Type s) { 68.141 - if (s.tag >= firstPartialTag) 68.142 + if (s.isPartial()) 68.143 return containedBy(s, t); 68.144 else { 68.145 // debugContainsType(t, s); 68.146 @@ -1232,7 +1234,7 @@ 68.147 switch (t.tag) { 68.148 case BYTE: case CHAR: case SHORT: case INT: case LONG: case FLOAT: 68.149 case DOUBLE: 68.150 - return s.tag <= DOUBLE; 68.151 + return s.isNumeric(); 68.152 case BOOLEAN: 68.153 return s.tag == BOOLEAN; 68.154 case VOID: 68.155 @@ -1373,8 +1375,7 @@ 68.156 case CLASS: 68.157 return isSubtype(t, s); 68.158 case ARRAY: 68.159 - if (elemtype(t).tag <= lastBaseTag || 68.160 - elemtype(s).tag <= lastBaseTag) { 68.161 + if (elemtype(t).isPrimitive() || elemtype(s).isPrimitive()) { 68.162 return elemtype(t).tag == elemtype(s).tag; 68.163 } else { 68.164 return visit(elemtype(t), elemtype(s)); 68.165 @@ -1648,8 +1649,8 @@ 68.166 */ 68.167 public ArrayType makeArrayType(Type t) { 68.168 if (t.tag == VOID || 68.169 - t.tag >= PACKAGE) { 68.170 - Assert.error("Type t must not be a a VOID or PACKAGE type, " + t.toString()); 68.171 + t.tag == PACKAGE) { 68.172 + Assert.error("Type t must not be a VOID or PACKAGE type, " + t.toString()); 68.173 } 68.174 return new ArrayType(t, syms.arrayClass); 68.175 } 68.176 @@ -1847,7 +1848,7 @@ 68.177 public boolean isAssignable(Type t, Type s, Warner warn) { 68.178 if (t.tag == ERROR) 68.179 return true; 68.180 - if (t.tag <= INT && t.constValue() != null) { 68.181 + if (t.tag.isSubRangeOf(INT) && t.constValue() != null) { 68.182 int value = ((Number)t.constValue()).intValue(); 68.183 switch (s.tag) { 68.184 case BYTE: 68.185 @@ -1891,11 +1892,11 @@ 68.186 // We don't want to erase primitive types and String type as that 68.187 // operation is idempotent. Also, erasing these could result in loss 68.188 // of information such as constant values attached to such types. 68.189 - return (t.tag <= lastBaseTag) || (syms.stringType.tsym == t.tsym); 68.190 + return (t.isPrimitive()) || (syms.stringType.tsym == t.tsym); 68.191 } 68.192 68.193 private Type erasure(Type t, boolean recurse) { 68.194 - if (t.tag <= lastBaseTag) 68.195 + if (t.isPrimitive()) 68.196 return t; /* fast special case */ 68.197 else 68.198 return erasure.visit(t, recurse); 68.199 @@ -1903,7 +1904,7 @@ 68.200 // where 68.201 private SimpleVisitor<Type, Boolean> erasure = new SimpleVisitor<Type, Boolean>() { 68.202 public Type visitType(Type t, Boolean recurse) { 68.203 - if (t.tag <= lastBaseTag) 68.204 + if (t.isPrimitive()) 68.205 return t; /*fast special case*/ 68.206 else 68.207 return t.map(recurse ? erasureRecFun : erasureFun); 68.208 @@ -3314,7 +3315,7 @@ 68.209 private static final UnaryVisitor<Integer> hashCode = new UnaryVisitor<Integer>() { 68.210 68.211 public Integer visitType(Type t, Void ignored) { 68.212 - return t.tag; 68.213 + return t.tag.ordinal(); 68.214 } 68.215 68.216 @Override 68.217 @@ -3430,7 +3431,7 @@ 68.218 * Return the class that boxes the given primitive. 68.219 */ 68.220 public ClassSymbol boxedClass(Type t) { 68.221 - return reader.enterClass(syms.boxedName[t.tag]); 68.222 + return reader.enterClass(syms.boxedName[t.tag.ordinal()]); 68.223 } 68.224 68.225 /**
69.1 --- a/src/share/classes/com/sun/tools/javac/comp/Annotate.java Thu Nov 01 14:13:13 2012 -0700 69.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Annotate.java Fri Nov 02 17:55:34 2012 -0700 69.3 @@ -34,6 +34,8 @@ 69.4 import com.sun.tools.javac.tree.*; 69.5 import com.sun.tools.javac.tree.JCTree.*; 69.6 69.7 +import static com.sun.tools.javac.code.TypeTag.ARRAY; 69.8 +import static com.sun.tools.javac.code.TypeTag.CLASS; 69.9 import static com.sun.tools.javac.tree.JCTree.Tag.*; 69.10 69.11 /** Enter annotations on symbols. Annotations accumulate in a queue, 69.12 @@ -289,7 +291,7 @@ 69.13 } 69.14 return enterAnnotation((JCAnnotation)tree, expected, env); 69.15 } 69.16 - if (expected.tag == TypeTags.ARRAY) { // should really be isArray() 69.17 + if (expected.hasTag(ARRAY)) { // should really be isArray() 69.18 if (!tree.hasTag(NEWARRAY)) { 69.19 tree = make.at(tree.pos). 69.20 NewArray(null, List.<JCExpression>nil(), List.of(tree)); 69.21 @@ -309,7 +311,7 @@ 69.22 return new Attribute. 69.23 Array(expected, buf.toArray(new Attribute[buf.length()])); 69.24 } 69.25 - if (expected.tag == TypeTags.CLASS && 69.26 + if (expected.hasTag(CLASS) && 69.27 (expected.tsym.flags() & Flags.ENUM) != 0) { 69.28 attr.attribExpr(tree, env, expected); 69.29 Symbol sym = TreeInfo.symbol(tree);
70.1 --- a/src/share/classes/com/sun/tools/javac/comp/Attr.java Thu Nov 01 14:13:13 2012 -0700 70.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java Fri Nov 02 17:55:34 2012 -0700 70.3 @@ -56,8 +56,8 @@ 70.4 import static com.sun.tools.javac.code.Flags.BLOCK; 70.5 import static com.sun.tools.javac.code.Kinds.*; 70.6 import static com.sun.tools.javac.code.Kinds.ERRONEOUS; 70.7 -import static com.sun.tools.javac.code.TypeTags.*; 70.8 -import static com.sun.tools.javac.code.TypeTags.WILDCARD; 70.9 +import static com.sun.tools.javac.code.TypeTag.*; 70.10 +import static com.sun.tools.javac.code.TypeTag.WILDCARD; 70.11 import static com.sun.tools.javac.tree.JCTree.Tag.*; 70.12 70.13 /** This is the main context-dependent analysis phase in GJC. It 70.14 @@ -227,14 +227,13 @@ 70.15 * are correct. 70.16 * 70.17 * @param tree The tree whose kind and type is checked 70.18 - * @param owntype The computed type of the tree 70.19 * @param ownkind The computed kind of the tree 70.20 * @param resultInfo The expected result of the tree 70.21 */ 70.22 Type check(final JCTree tree, final Type found, final int ownkind, final ResultInfo resultInfo) { 70.23 InferenceContext inferenceContext = resultInfo.checkContext.inferenceContext(); 70.24 Type owntype = found; 70.25 - if (owntype.tag != ERROR && resultInfo.pt.tag != METHOD && resultInfo.pt.tag != FORALL) { 70.26 + if (!owntype.hasTag(ERROR) && !resultInfo.pt.hasTag(METHOD) && !resultInfo.pt.hasTag(FORALL)) { 70.27 if (inferenceContext.free(found)) { 70.28 inferenceContext.addFreeTypeListener(List.of(found, resultInfo.pt), new FreeTypeListener() { 70.29 @Override 70.30 @@ -606,7 +605,7 @@ 70.31 /** Derived visitor method: attribute an expression tree. 70.32 */ 70.33 public Type attribExpr(JCTree tree, Env<AttrContext> env, Type pt) { 70.34 - return attribTree(tree, env, new ResultInfo(VAL, pt.tag != ERROR ? pt : Type.noType)); 70.35 + return attribTree(tree, env, new ResultInfo(VAL, !pt.hasTag(ERROR) ? pt : Type.noType)); 70.36 } 70.37 70.38 /** Derived visitor method: attribute an expression tree with 70.39 @@ -806,7 +805,7 @@ 70.40 boolean checkExtensible) { 70.41 if (t.isErroneous()) 70.42 return t; 70.43 - if (t.tag == TYPEVAR && !classExpected && !interfaceExpected) { 70.44 + if (t.hasTag(TYPEVAR) && !classExpected && !interfaceExpected) { 70.45 // check that type variable is already visible 70.46 if (t.getUpperBound() == null) { 70.47 log.error(tree.pos(), "illegal.forward.ref"); 70.48 @@ -1208,7 +1207,7 @@ 70.49 } 70.50 } else { 70.51 Type pattype = attribExpr(c.pat, switchEnv, seltype); 70.52 - if (pattype.tag != ERROR) { 70.53 + if (!pattype.hasTag(ERROR)) { 70.54 if (pattype.constValue() == null) { 70.55 log.error(c.pat.pos(), 70.56 (stringSwitch ? "string.const.req" : "const.expr.req")); 70.57 @@ -1379,10 +1378,10 @@ 70.58 Type condtype = attribExpr(tree.cond, env, syms.booleanType); 70.59 70.60 boolean standaloneConditional = !allowPoly || 70.61 - pt().tag == NONE && pt() != Type.recoveryType || 70.62 + pt().hasTag(NONE) && pt() != Type.recoveryType || 70.63 isBooleanOrNumeric(env, tree); 70.64 70.65 - if (!standaloneConditional && resultInfo.pt.tag == VOID) { 70.66 + if (!standaloneConditional && resultInfo.pt.hasTag(VOID)) { 70.67 //cannot get here (i.e. it means we are returning from void method - which is already an error) 70.68 result = tree.type = types.createErrorType(resultInfo.pt); 70.69 return; 70.70 @@ -1416,7 +1415,8 @@ 70.71 @SuppressWarnings("fallthrough") 70.72 private boolean isBooleanOrNumeric(Env<AttrContext> env, JCExpression tree) { 70.73 switch (tree.getTag()) { 70.74 - case LITERAL: return ((JCLiteral)tree).typetag < CLASS; 70.75 + case LITERAL: return ((JCLiteral)tree).typetag.isSubRangeOf(DOUBLE) || 70.76 + ((JCLiteral)tree).typetag == BOOLEAN; 70.77 case LAMBDA: case REFERENCE: return false; 70.78 case PARENS: return isBooleanOrNumeric(env, ((JCParens)tree).expr); 70.79 case CONDEXPR: 70.80 @@ -1426,7 +1426,7 @@ 70.81 default: 70.82 Type speculativeType = deferredAttr.attribSpeculative(tree, env, unknownExprInfo).type; 70.83 speculativeType = types.unboxedTypeOrType(speculativeType); 70.84 - return speculativeType.tag <= BOOLEAN; 70.85 + return speculativeType.isPrimitive(); 70.86 } 70.87 } 70.88 70.89 @@ -1459,16 +1459,19 @@ 70.90 // If one arm has an integer subrange type (i.e., byte, 70.91 // short, or char), and the other is an integer constant 70.92 // that fits into the subrange, return the subrange type. 70.93 - if (thenUnboxed.tag < INT && elseUnboxed.tag == INT && 70.94 + if (thenUnboxed.getTag().isStrictSubRangeOf(INT) && elseUnboxed.hasTag(INT) && 70.95 types.isAssignable(elseUnboxed, thenUnboxed)) 70.96 return thenUnboxed.baseType(); 70.97 - if (elseUnboxed.tag < INT && thenUnboxed.tag == INT && 70.98 + if (elseUnboxed.getTag().isStrictSubRangeOf(INT) && thenUnboxed.hasTag(INT) && 70.99 types.isAssignable(thenUnboxed, elseUnboxed)) 70.100 return elseUnboxed.baseType(); 70.101 70.102 - for (int i = BYTE; i < VOID; i++) { 70.103 - Type candidate = syms.typeOfTag[i]; 70.104 - if (types.isSubtype(thenUnboxed, candidate) && 70.105 + for (TypeTag tag : TypeTag.values()) { 70.106 + if (tag.ordinal() >= TypeTag.getTypeTagCount()) break; 70.107 + Type candidate = syms.typeOfTag[tag.ordinal()]; 70.108 + if (candidate != null && 70.109 + candidate.isPrimitive() && 70.110 + types.isSubtype(thenUnboxed, candidate) && 70.111 types.isSubtype(elseUnboxed, candidate)) 70.112 return candidate; 70.113 } 70.114 @@ -1487,7 +1490,7 @@ 70.115 if (types.isSubtype(elsetype, thentype)) 70.116 return thentype.baseType(); 70.117 70.118 - if (!allowBoxing || thentype.tag == VOID || elsetype.tag == VOID) { 70.119 + if (!allowBoxing || thentype.hasTag(VOID) || elsetype.hasTag(VOID)) { 70.120 log.error(pos, "neither.conditional.subtype", 70.121 thentype, elsetype); 70.122 return thentype.baseType(); 70.123 @@ -1601,12 +1604,12 @@ 70.124 // Attribute return expression, if it exists, and check that 70.125 // it conforms to result type of enclosing method. 70.126 if (tree.expr != null) { 70.127 - if (env.info.returnResult.pt.tag == VOID) { 70.128 + if (env.info.returnResult.pt.hasTag(VOID)) { 70.129 log.error(tree.expr.pos(), 70.130 "cant.ret.val.from.meth.decl.void"); 70.131 } 70.132 attribTree(tree.expr, env, env.info.returnResult); 70.133 - } else if (env.info.returnResult.pt.tag != VOID) { 70.134 + } else if (!env.info.returnResult.pt.hasTag(VOID)) { 70.135 log.error(tree.pos(), "missing.ret.val"); 70.136 } 70.137 } 70.138 @@ -1671,11 +1674,11 @@ 70.139 } 70.140 } 70.141 70.142 - if (site.tag == CLASS) { 70.143 + if (site.hasTag(CLASS)) { 70.144 Type encl = site.getEnclosingType(); 70.145 - while (encl != null && encl.tag == TYPEVAR) 70.146 + while (encl != null && encl.hasTag(TYPEVAR)) 70.147 encl = encl.getUpperBound(); 70.148 - if (encl.tag == CLASS) { 70.149 + if (encl.hasTag(CLASS)) { 70.150 // we are calling a nested class 70.151 70.152 if (tree.meth.hasTag(SELECT)) { 70.153 @@ -1740,7 +1743,7 @@ 70.154 70.155 // Compute the result type. 70.156 Type restype = mtype.getReturnType(); 70.157 - if (restype.tag == WILDCARD) 70.158 + if (restype.hasTag(WILDCARD)) 70.159 throw new AssertionError(mtype); 70.160 70.161 Type qualifier = (tree.meth.hasTag(SELECT)) 70.162 @@ -1870,7 +1873,7 @@ 70.163 } 70.164 } 70.165 } else if (!clazztype.tsym.isInterface() && 70.166 - clazztype.getEnclosingType().tag == CLASS) { 70.167 + clazztype.getEnclosingType().hasTag(CLASS)) { 70.168 // Check for the existence of an apropos outer instance 70.169 rs.resolveImplicitThis(tree.pos(), env, clazztype); 70.170 } 70.171 @@ -1880,7 +1883,7 @@ 70.172 List<Type> typeargtypes = attribTypes(tree.typeargs, localEnv); 70.173 70.174 // If we have made no mistakes in the class type... 70.175 - if (clazztype.tag == CLASS) { 70.176 + if (clazztype.hasTag(CLASS)) { 70.177 // Enums may not be instantiated except implicitly 70.178 if (allowEnums && 70.179 (clazztype.tsym.flags_field&Flags.ENUM) != 0 && 70.180 @@ -2058,7 +2061,7 @@ 70.181 resultInfo.checkContext.inferenceContext().free(resultInfo.pt) ? Type.noType : pt()); 70.182 Type inferred = deferredAttr.attribSpeculative(tree, env, findDiamondResult).type; 70.183 if (!inferred.isErroneous() && 70.184 - types.isAssignable(inferred, pt().tag == NONE ? syms.objectType : pt(), Warner.noWarnings)) { 70.185 + types.isAssignable(inferred, pt().hasTag(NONE) ? syms.objectType : pt(), Warner.noWarnings)) { 70.186 String key = types.isSameType(clazztype, inferred) ? 70.187 "diamond.redundant.args" : 70.188 "diamond.redundant.args.1"; 70.189 @@ -2073,8 +2076,8 @@ 70.190 private void checkLambdaCandidate(JCNewClass tree, ClassSymbol csym, Type clazztype) { 70.191 if (allowLambda && 70.192 identifyLambdaCandidate && 70.193 - clazztype.tag == CLASS && 70.194 - pt().tag != NONE && 70.195 + clazztype.hasTag(CLASS) && 70.196 + !pt().hasTag(NONE) && 70.197 types.isFunctionalInterface(clazztype.tsym)) { 70.198 Symbol descriptor = types.findDescriptorSymbol(clazztype.tsym); 70.199 int count = 0; 70.200 @@ -2125,10 +2128,10 @@ 70.201 } else { 70.202 // we are seeing an untyped aggregate { ... } 70.203 // this is allowed only if the prototype is an array 70.204 - if (pt().tag == ARRAY) { 70.205 + if (pt().hasTag(ARRAY)) { 70.206 elemtype = types.elemtype(pt()); 70.207 } else { 70.208 - if (pt().tag != ERROR) { 70.209 + if (!pt().hasTag(ERROR)) { 70.210 log.error(tree.pos(), "illegal.initializer.for.type", 70.211 pt()); 70.212 } 70.213 @@ -2152,8 +2155,8 @@ 70.214 */ 70.215 @Override 70.216 public void visitLambda(final JCLambda that) { 70.217 - if (pt().isErroneous() || (pt().tag == NONE && pt() != Type.recoveryType)) { 70.218 - if (pt().tag == NONE) { 70.219 + if (pt().isErroneous() || (pt().hasTag(NONE) && pt() != Type.recoveryType)) { 70.220 + if (pt().hasTag(NONE)) { 70.221 //lambda only allowed in assignment or method invocation/cast context 70.222 log.error(that.pos(), "unexpected.lambda"); 70.223 } 70.224 @@ -2328,7 +2331,7 @@ 70.225 //this amounts at checking that, if a lambda body can complete normally, 70.226 //the descriptor's return type must be void 70.227 if (tree.getBodyKind() == JCLambda.BodyKind.STATEMENT && tree.canCompleteNormally && 70.228 - returnType.tag != VOID && returnType != Type.recoveryType) { 70.229 + !returnType.hasTag(VOID) && returnType != Type.recoveryType) { 70.230 checkContext.report(tree, diags.fragment("incompatible.ret.type.in.lambda", 70.231 diags.fragment("missing.ret.val", returnType))); 70.232 } 70.233 @@ -2363,8 +2366,8 @@ 70.234 70.235 @Override 70.236 public void visitReference(final JCMemberReference that) { 70.237 - if (pt().isErroneous() || (pt().tag == NONE && pt() != Type.recoveryType)) { 70.238 - if (pt().tag == NONE) { 70.239 + if (pt().isErroneous() || (pt().hasTag(NONE) && pt() != Type.recoveryType)) { 70.240 + if (pt().hasTag(NONE)) { 70.241 //method reference only allowed in assignment or method invocation/cast context 70.242 log.error(that.pos(), "unexpected.mref"); 70.243 } 70.244 @@ -2465,7 +2468,7 @@ 70.245 70.246 ResultInfo checkInfo = 70.247 resultInfo.dup(newMethodTemplate( 70.248 - desc.getReturnType().tag == VOID ? Type.noType : desc.getReturnType(), 70.249 + desc.getReturnType().hasTag(VOID) ? Type.noType : desc.getReturnType(), 70.250 lookupHelper.argtypes, 70.251 typeargtypes)); 70.252 70.253 @@ -2510,11 +2513,11 @@ 70.254 70.255 Type incompatibleReturnType = resType; 70.256 70.257 - if (returnType.tag == VOID) { 70.258 + if (returnType.hasTag(VOID)) { 70.259 incompatibleReturnType = null; 70.260 } 70.261 70.262 - if (returnType.tag != VOID && resType.tag != VOID) { 70.263 + if (!returnType.hasTag(VOID) && !resType.hasTag(VOID)) { 70.264 if (resType.isErroneous() || 70.265 new LambdaReturnContext(checkContext).compatible(resType, returnType, Warner.noWarnings)) { 70.266 incompatibleReturnType = null; 70.267 @@ -2711,7 +2714,7 @@ 70.268 attribExpr(tree.index, env, syms.intType); 70.269 if (types.isArray(atype)) 70.270 owntype = types.elemtype(atype); 70.271 - else if (atype.tag != ERROR) 70.272 + else if (!atype.hasTag(ERROR)) 70.273 log.error(tree.pos(), "array.req.but.found", atype); 70.274 if ((pkind() & VAR) == 0) owntype = capture(owntype); 70.275 result = check(tree, owntype, VAR, resultInfo); 70.276 @@ -2721,7 +2724,7 @@ 70.277 Symbol sym; 70.278 70.279 // Find symbol 70.280 - if (pt().tag == METHOD || pt().tag == FORALL) { 70.281 + if (pt().hasTag(METHOD) || pt().hasTag(FORALL)) { 70.282 // If we are looking for a method, the prototype `pt' will be a 70.283 // method type with the type of the call's arguments as parameters. 70.284 env.info.pendingResolutionPhase = null; 70.285 @@ -2811,9 +2814,9 @@ 70.286 // don't allow T.class T[].class, etc 70.287 if (skind == TYP) { 70.288 Type elt = site; 70.289 - while (elt.tag == ARRAY) 70.290 + while (elt.hasTag(ARRAY)) 70.291 elt = ((ArrayType)elt).elemtype; 70.292 - if (elt.tag == TYPEVAR) { 70.293 + if (elt.hasTag(TYPEVAR)) { 70.294 log.error(tree.pos(), "type.var.cant.be.deref"); 70.295 result = types.createErrorType(tree.type); 70.296 return; 70.297 @@ -2839,8 +2842,8 @@ 70.298 boolean varArgs = env.info.lastResolveVarargs(); 70.299 tree.sym = sym; 70.300 70.301 - if (site.tag == TYPEVAR && !isType(sym) && sym.kind != ERR) { 70.302 - while (site.tag == TYPEVAR) site = site.getUpperBound(); 70.303 + if (site.hasTag(TYPEVAR) && !isType(sym) && sym.kind != ERR) { 70.304 + while (site.hasTag(TYPEVAR)) site = site.getUpperBound(); 70.305 site = capture(site); 70.306 } 70.307 70.308 @@ -2929,14 +2932,14 @@ 70.309 ResultInfo resultInfo) { 70.310 DiagnosticPosition pos = tree.pos(); 70.311 Name name = tree.name; 70.312 - switch (site.tag) { 70.313 + switch (site.getTag()) { 70.314 case PACKAGE: 70.315 return rs.accessBase( 70.316 rs.findIdentInPackage(env, site.tsym, name, resultInfo.pkind), 70.317 pos, location, site, name, true); 70.318 case ARRAY: 70.319 case CLASS: 70.320 - if (resultInfo.pt.tag == METHOD || resultInfo.pt.tag == FORALL) { 70.321 + if (resultInfo.pt.hasTag(METHOD) || resultInfo.pt.hasTag(FORALL)) { 70.322 return rs.resolveQualifiedMethod( 70.323 pos, env, location, site, name, resultInfo.pt.getParameterTypes(), resultInfo.pt.getTypeArguments()); 70.324 } else if (name == names._this || name == names._super) { 70.325 @@ -3029,7 +3032,7 @@ 70.326 Symbol sym, 70.327 Env<AttrContext> env, 70.328 ResultInfo resultInfo) { 70.329 - Type pt = resultInfo.pt.tag == FORALL || resultInfo.pt.tag == METHOD ? 70.330 + Type pt = resultInfo.pt.hasTag(FORALL) || resultInfo.pt.hasTag(METHOD) ? 70.331 resultInfo.pt.map(deferredAttr.new DeferredTypeMap(AttrMode.SPECULATIVE, sym, env.info.pendingResolutionPhase)) : 70.332 resultInfo.pt; 70.333 70.334 @@ -3046,7 +3049,8 @@ 70.335 // For types, the computed type equals the symbol's type, 70.336 // except for two situations: 70.337 owntype = sym.type; 70.338 - if (owntype.tag == CLASS) { 70.339 + if (owntype.hasTag(CLASS)) { 70.340 + chk.checkForBadAuxiliaryClassAccess(tree.pos(), env, (ClassSymbol)sym); 70.341 Type ownOuter = owntype.getEnclosingType(); 70.342 70.343 // (a) If the symbol's type is parameterized, erase it 70.344 @@ -3066,9 +3070,9 @@ 70.345 // 70.346 // Then the type of the last expression above is 70.347 // Tree<Point>.Visitor. 70.348 - else if (ownOuter.tag == CLASS && site != ownOuter) { 70.349 + else if (ownOuter.hasTag(CLASS) && site != ownOuter) { 70.350 Type normOuter = site; 70.351 - if (normOuter.tag == CLASS) 70.352 + if (normOuter.hasTag(CLASS)) 70.353 normOuter = types.asEnclosingSuper(site, ownOuter.tsym); 70.354 if (normOuter == null) // perhaps from an import 70.355 normOuter = types.erasure(ownOuter); 70.356 @@ -3087,7 +3091,7 @@ 70.357 resultInfo.pkind == VAR && 70.358 v.owner.kind == TYP && 70.359 (v.flags() & STATIC) == 0 && 70.360 - (site.tag == CLASS || site.tag == TYPEVAR)) { 70.361 + (site.hasTag(CLASS) || site.hasTag(TYPEVAR))) { 70.362 Type s = types.asOuterSuper(site, v.owner); 70.363 if (s != null && 70.364 s.isRaw() && 70.365 @@ -3266,7 +3270,7 @@ 70.366 // an unchecked warning if its argument types change under erasure. 70.367 if (allowGenerics && 70.368 (sym.flags() & STATIC) == 0 && 70.369 - (site.tag == CLASS || site.tag == TYPEVAR)) { 70.370 + (site.hasTag(CLASS) || site.hasTag(TYPEVAR))) { 70.371 Type s = types.asOuterSuper(site, sym.owner); 70.372 if (s != null && s.isRaw() && 70.373 !types.isSameTypes(sym.type.getParameterTypes(), 70.374 @@ -3312,12 +3316,12 @@ 70.375 //where 70.376 /** Return the type of a literal with given type tag. 70.377 */ 70.378 - Type litType(int tag) { 70.379 - return (tag == TypeTags.CLASS) ? syms.stringType : syms.typeOfTag[tag]; 70.380 + Type litType(TypeTag tag) { 70.381 + return (tag == CLASS) ? syms.stringType : syms.typeOfTag[tag.ordinal()]; 70.382 } 70.383 70.384 public void visitTypeIdent(JCPrimitiveTypeTree tree) { 70.385 - result = check(tree, syms.typeOfTag[tree.typetag], TYP, resultInfo); 70.386 + result = check(tree, syms.typeOfTag[tree.typetag.ordinal()], TYP, resultInfo); 70.387 } 70.388 70.389 public void visitTypeArray(JCArrayTypeTree tree) { 70.390 @@ -3339,7 +3343,7 @@ 70.391 // Attribute type parameters 70.392 List<Type> actuals = attribTypes(tree.arguments, env); 70.393 70.394 - if (clazztype.tag == CLASS) { 70.395 + if (clazztype.hasTag(CLASS)) { 70.396 List<Type> formals = clazztype.tsym.type.getTypeArguments(); 70.397 if (actuals.isEmpty()) //diamond 70.398 actuals = formals; 70.399 @@ -3354,7 +3358,7 @@ 70.400 } 70.401 // Compute the proper generic outer 70.402 Type clazzOuter = clazztype.getEnclosingType(); 70.403 - if (clazzOuter.tag == CLASS) { 70.404 + if (clazzOuter.hasTag(CLASS)) { 70.405 Type site; 70.406 JCExpression clazz = TreeInfo.typeIn(tree.clazz); 70.407 if (clazz.hasTag(IDENT)) { 70.408 @@ -3362,8 +3366,8 @@ 70.409 } else if (clazz.hasTag(SELECT)) { 70.410 site = ((JCFieldAccess) clazz).selected.type; 70.411 } else throw new AssertionError(""+tree); 70.412 - if (clazzOuter.tag == CLASS && site != clazzOuter) { 70.413 - if (site.tag == CLASS) 70.414 + if (clazzOuter.hasTag(CLASS) && site != clazzOuter) { 70.415 + if (site.hasTag(CLASS)) 70.416 site = types.asOuterSuper(site, clazzOuter.tsym); 70.417 if (site == null) 70.418 site = types.erasure(clazzOuter); 70.419 @@ -3419,7 +3423,7 @@ 70.420 } 70.421 } 70.422 Type t = check(tree, types.lub(multicatchTypes.toList()), TYP, resultInfo); 70.423 - if (t.tag == CLASS) { 70.424 + if (t.hasTag(CLASS)) { 70.425 List<Type> alternatives = 70.426 ((all_multicatchTypes == null) ? multicatchTypes : all_multicatchTypes).toList(); 70.427 t = new UnionClassType((ClassType) t, alternatives); 70.428 @@ -3440,7 +3444,7 @@ 70.429 if (b.isErroneous()) { 70.430 a.bound = b; 70.431 } 70.432 - else if (b.tag == TYPEVAR) { 70.433 + else if (b.hasTag(TYPEVAR)) { 70.434 // if first bound was a typevar, do not accept further bounds. 70.435 if (tree.bounds.tail.nonEmpty()) { 70.436 log.error(tree.bounds.tail.head.pos(), 70.437 @@ -3456,7 +3460,7 @@ 70.438 Type i = checkBase(bs.head, bound, env, false, true, false); 70.439 if (i.isErroneous()) 70.440 a.bound = i; 70.441 - else if (i.tag == CLASS) 70.442 + else if (i.hasTag(CLASS)) 70.443 chk.checkNotRepeated(bound.pos(), types.erasure(i), boundSet); 70.444 } 70.445 } 70.446 @@ -3568,7 +3572,7 @@ 70.447 * @param c The class symbol whose definition will be attributed. 70.448 */ 70.449 void attribClass(ClassSymbol c) throws CompletionFailure { 70.450 - if (c.type.tag == ERROR) return; 70.451 + if (c.type.hasTag(ERROR)) return; 70.452 70.453 // Check for cycles in the inheritance graph, which can arise from 70.454 // ill-formed class files. 70.455 @@ -3577,11 +3581,11 @@ 70.456 Type st = types.supertype(c.type); 70.457 if ((c.flags_field & Flags.COMPOUND) == 0) { 70.458 // First, attribute superclass. 70.459 - if (st.tag == CLASS) 70.460 + if (st.hasTag(CLASS)) 70.461 attribClass((ClassSymbol)st.tsym); 70.462 70.463 // Next attribute owner, if it is a class. 70.464 - if (c.owner.kind == TYP && c.owner.type.tag == CLASS) 70.465 + if (c.owner.kind == TYP && c.owner.type.hasTag(CLASS)) 70.466 attribClass((ClassSymbol)c.owner); 70.467 } 70.468 70.469 @@ -3793,7 +3797,7 @@ 70.470 TreeInfo.diagnosticPositionFor(svuid, tree), "improper.SVUID", c); 70.471 70.472 // check that it is long 70.473 - else if (svuid.type.tag != TypeTags.LONG) 70.474 + else if (!svuid.type.hasTag(LONG)) 70.475 log.warning(LintCategory.SERIAL, 70.476 TreeInfo.diagnosticPositionFor(svuid, tree), "long.SVUID", c); 70.477
71.1 --- a/src/share/classes/com/sun/tools/javac/comp/Check.java Thu Nov 01 14:13:13 2012 -0700 71.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java Fri Nov 02 17:55:34 2012 -0700 71.3 @@ -27,6 +27,7 @@ 71.4 71.5 import java.util.*; 71.6 import java.util.Set; 71.7 +import javax.tools.JavaFileManager; 71.8 71.9 import com.sun.tools.javac.code.*; 71.10 import com.sun.tools.javac.jvm.*; 71.11 @@ -48,8 +49,8 @@ 71.12 import static com.sun.tools.javac.code.Flags.ANNOTATION; 71.13 import static com.sun.tools.javac.code.Flags.SYNCHRONIZED; 71.14 import static com.sun.tools.javac.code.Kinds.*; 71.15 -import static com.sun.tools.javac.code.TypeTags.*; 71.16 -import static com.sun.tools.javac.code.TypeTags.WILDCARD; 71.17 +import static com.sun.tools.javac.code.TypeTag.*; 71.18 +import static com.sun.tools.javac.code.TypeTag.WILDCARD; 71.19 71.20 import static com.sun.tools.javac.tree.JCTree.Tag.*; 71.21 71.22 @@ -77,6 +78,7 @@ 71.23 private boolean suppressAbortOnBadClassFile; 71.24 private boolean enableSunApiLintControl; 71.25 private final TreeInfo treeinfo; 71.26 + private final JavaFileManager fileManager; 71.27 71.28 // The set of lint options currently in effect. It is initialized 71.29 // from the context, and then is set/reset as needed by Attr as it 71.30 @@ -109,6 +111,7 @@ 71.31 Options options = Options.instance(context); 71.32 lint = Lint.instance(context); 71.33 treeinfo = TreeInfo.instance(context); 71.34 + fileManager = context.get(JavaFileManager.class); 71.35 71.36 Source source = Source.instance(context); 71.37 allowGenerics = source.allowGenerics(); 71.38 @@ -280,7 +283,7 @@ 71.39 Type typeTagError(DiagnosticPosition pos, Object required, Object found) { 71.40 // this error used to be raised by the parser, 71.41 // but has been delayed to this point: 71.42 - if (found instanceof Type && ((Type)found).tag == VOID) { 71.43 + if (found instanceof Type && ((Type)found).hasTag(VOID)) { 71.44 log.error(pos, "illegal.start.of.type"); 71.45 return syms.errType; 71.46 } 71.47 @@ -358,7 +361,7 @@ 71.48 for (Scope.Entry e = s.next.lookup(c.name); 71.49 e.scope != null && e.sym.owner == c.owner; 71.50 e = e.next()) { 71.51 - if (e.sym.kind == TYP && e.sym.type.tag != TYPEVAR && 71.52 + if (e.sym.kind == TYP && !e.sym.type.hasTag(TYPEVAR) && 71.53 (e.sym.owner.kind & (VAR | MTH)) != 0 && 71.54 c.name != names.error) { 71.55 duplicateError(pos, e.sym); 71.56 @@ -527,14 +530,14 @@ 71.57 } 71.58 }); 71.59 } 71.60 - if (req.tag == ERROR) 71.61 + if (req.hasTag(ERROR)) 71.62 return req; 71.63 - if (req.tag == NONE) 71.64 + if (req.hasTag(NONE)) 71.65 return found; 71.66 if (checkContext.compatible(found, req, checkContext.checkWarner(pos, found, req))) { 71.67 return found; 71.68 } else { 71.69 - if (found.tag <= DOUBLE && req.tag <= DOUBLE) { 71.70 + if (found.getTag().isSubRangeOf(DOUBLE) && req.getTag().isSubRangeOf(DOUBLE)) { 71.71 checkContext.report(pos, diags.fragment("possible.loss.of.precision", found, req)); 71.72 return types.createErrorType(found); 71.73 } 71.74 @@ -594,7 +597,7 @@ 71.75 * type variables? 71.76 */ 71.77 boolean isTypeVar(Type t) { 71.78 - return t.tag == TYPEVAR || t.tag == ARRAY && isTypeVar(types.elemtype(t)); 71.79 + return t.hasTag(TYPEVAR) || t.hasTag(ARRAY) && isTypeVar(types.elemtype(t)); 71.80 } 71.81 71.82 /** Check that a type is within some bounds. 71.83 @@ -607,7 +610,7 @@ 71.84 private boolean checkExtends(Type a, Type bound) { 71.85 if (a.isUnbound()) { 71.86 return true; 71.87 - } else if (a.tag != WILDCARD) { 71.88 + } else if (!a.hasTag(WILDCARD)) { 71.89 a = types.upperBound(a); 71.90 return types.isSubtype(a, bound); 71.91 } else if (a.isExtendsBound()) { 71.92 @@ -623,7 +626,7 @@ 71.93 * @param t The type to be checked. 71.94 */ 71.95 Type checkNonVoid(DiagnosticPosition pos, Type t) { 71.96 - if (t.tag == VOID) { 71.97 + if (t.hasTag(VOID)) { 71.98 log.error(pos, "void.not.allowed.here"); 71.99 return types.createErrorType(t); 71.100 } else { 71.101 @@ -636,10 +639,10 @@ 71.102 * @param t The type to be checked. 71.103 */ 71.104 Type checkClassType(DiagnosticPosition pos, Type t) { 71.105 - if (t.tag != CLASS && t.tag != ERROR) 71.106 + if (!t.hasTag(CLASS) && !t.hasTag(ERROR)) 71.107 return typeTagError(pos, 71.108 diags.fragment("type.req.class"), 71.109 - (t.tag == TYPEVAR) 71.110 + (t.hasTag(TYPEVAR)) 71.111 ? diags.fragment("type.parameter", t) 71.112 : t); 71.113 else 71.114 @@ -650,7 +653,7 @@ 71.115 */ 71.116 Type checkConstructorRefType(DiagnosticPosition pos, Type t) { 71.117 t = checkClassType(pos, t); 71.118 - if (t.tag == CLASS) { 71.119 + if (t.hasTag(CLASS)) { 71.120 if ((t.tsym.flags() & (ABSTRACT | INTERFACE)) != 0) { 71.121 log.error(pos, "abstract.cant.be.instantiated"); 71.122 t = types.createErrorType(t); 71.123 @@ -672,7 +675,7 @@ 71.124 if (noBounds && t.isParameterized()) { 71.125 List<Type> args = t.getTypeArguments(); 71.126 while (args.nonEmpty()) { 71.127 - if (args.head.tag == WILDCARD) 71.128 + if (args.head.hasTag(WILDCARD)) 71.129 return typeTagError(pos, 71.130 diags.fragment("type.req.exact"), 71.131 args.head); 71.132 @@ -687,7 +690,7 @@ 71.133 * @param t The type to be checked. 71.134 */ 71.135 Type checkReifiableReferenceType(DiagnosticPosition pos, Type t) { 71.136 - if (t.tag != CLASS && t.tag != ARRAY && t.tag != ERROR) { 71.137 + if (!t.hasTag(CLASS) && !t.hasTag(ARRAY) && !t.hasTag(ERROR)) { 71.138 return typeTagError(pos, 71.139 diags.fragment("type.req.class.array"), 71.140 t); 71.141 @@ -705,18 +708,12 @@ 71.142 * @param t The type to be checked. 71.143 */ 71.144 Type checkRefType(DiagnosticPosition pos, Type t) { 71.145 - switch (t.tag) { 71.146 - case CLASS: 71.147 - case ARRAY: 71.148 - case TYPEVAR: 71.149 - case WILDCARD: 71.150 - case ERROR: 71.151 + if (t.isReference()) 71.152 return t; 71.153 - default: 71.154 + else 71.155 return typeTagError(pos, 71.156 diags.fragment("type.req.ref"), 71.157 t); 71.158 - } 71.159 } 71.160 71.161 /** Check that each type is a reference type, i.e. a class, interface or array type 71.162 @@ -738,19 +735,12 @@ 71.163 * @param t The type to be checked. 71.164 */ 71.165 Type checkNullOrRefType(DiagnosticPosition pos, Type t) { 71.166 - switch (t.tag) { 71.167 - case CLASS: 71.168 - case ARRAY: 71.169 - case TYPEVAR: 71.170 - case WILDCARD: 71.171 - case BOT: 71.172 - case ERROR: 71.173 + if (t.isNullOrReference()) 71.174 return t; 71.175 - default: 71.176 + else 71.177 return typeTagError(pos, 71.178 diags.fragment("type.req.ref"), 71.179 t); 71.180 - } 71.181 } 71.182 71.183 /** Check that flag set does not contain elements of two conflicting sets. s 71.184 @@ -1054,7 +1044,7 @@ 71.185 bounds = bounds_buf.toList(); 71.186 71.187 for (Type arg : types.capture(type).getTypeArguments()) { 71.188 - if (arg.tag == TYPEVAR && 71.189 + if (arg.hasTag(TYPEVAR) && 71.190 arg.getUpperBound().isErroneous() && 71.191 !bounds.head.isErroneous() && 71.192 !isTypeArgErroneous(args.head)) { 71.193 @@ -1309,7 +1299,7 @@ 71.194 71.195 @Override 71.196 public void visitTypeApply(JCTypeApply tree) { 71.197 - if (tree.type.tag == CLASS) { 71.198 + if (tree.type.hasTag(CLASS)) { 71.199 List<JCExpression> args = tree.arguments; 71.200 List<Type> forms = tree.type.tsym.type.getTypeArguments(); 71.201 71.202 @@ -1360,7 +1350,7 @@ 71.203 71.204 @Override 71.205 public void visitSelect(JCFieldAccess tree) { 71.206 - if (tree.type.tag == CLASS) { 71.207 + if (tree.type.hasTag(CLASS)) { 71.208 visitSelectInternal(tree); 71.209 71.210 // Check that this type is either fully parameterized, or 71.211 @@ -1409,7 +1399,7 @@ 71.212 71.213 void checkRaw(JCTree tree, Env<AttrContext> env) { 71.214 if (lint.isEnabled(LintCategory.RAW) && 71.215 - tree.type.tag == CLASS && 71.216 + tree.type.hasTag(CLASS) && 71.217 !TreeInfo.isDiamond(tree) && 71.218 !withinAnonConstr(env) && 71.219 tree.type.isRaw()) { 71.220 @@ -1511,9 +1501,9 @@ 71.221 */ 71.222 boolean isUnchecked(Type exc) { 71.223 return 71.224 - (exc.tag == TYPEVAR) ? isUnchecked(types.supertype(exc)) : 71.225 - (exc.tag == CLASS) ? isUnchecked((ClassSymbol)exc.tsym) : 71.226 - exc.tag == BOT; 71.227 + (exc.hasTag(TYPEVAR)) ? isUnchecked(types.supertype(exc)) : 71.228 + (exc.hasTag(CLASS)) ? isUnchecked((ClassSymbol)exc.tsym) : 71.229 + exc.hasTag(BOT); 71.230 } 71.231 71.232 /** Same, but handling completion failures. 71.233 @@ -1759,7 +1749,7 @@ 71.234 // case, we will have dealt with when examining the supertype classes 71.235 ClassSymbol mc = m.enclClass(); 71.236 Type st = types.supertype(origin.type); 71.237 - if (st.tag != CLASS) 71.238 + if (!st.hasTag(CLASS)) 71.239 return true; 71.240 MethodSymbol stimpl = m.implementation((ClassSymbol)st.tsym, types, false); 71.241 71.242 @@ -1782,7 +1772,7 @@ 71.243 */ 71.244 public void checkCompatibleConcretes(DiagnosticPosition pos, Type site) { 71.245 Type sup = types.supertype(site); 71.246 - if (sup.tag != CLASS) return; 71.247 + if (!sup.hasTag(CLASS)) return; 71.248 71.249 for (Type t1 = sup; 71.250 t1.tsym.type.isParameterized(); 71.251 @@ -1803,7 +1793,7 @@ 71.252 if (st1 == s1.type) continue; 71.253 71.254 for (Type t2 = sup; 71.255 - t2.tag == CLASS; 71.256 + t2.hasTag(CLASS); 71.257 t2 = types.supertype(t2)) { 71.258 for (Scope.Entry e2 = t2.tsym.members().lookup(s1.name); 71.259 e2.scope != null; 71.260 @@ -1876,7 +1866,7 @@ 71.261 71.262 /** Compute all the supertypes of t, indexed by type symbol. */ 71.263 private void closure(Type t, Map<TypeSymbol,Type> typeMap) { 71.264 - if (t.tag != CLASS) return; 71.265 + if (!t.hasTag(CLASS)) return; 71.266 if (typeMap.put(t.tsym, t) == null) { 71.267 closure(types.supertype(t), typeMap); 71.268 for (Type i : types.interfaces(t)) 71.269 @@ -1886,7 +1876,7 @@ 71.270 71.271 /** Compute all the supertypes of t, indexed by type symbol (except thise in typesSkip). */ 71.272 private void closure(Type t, Map<TypeSymbol,Type> typesSkip, Map<TypeSymbol,Type> typeMap) { 71.273 - if (t.tag != CLASS) return; 71.274 + if (!t.hasTag(CLASS)) return; 71.275 if (typesSkip.get(t.tsym) != null) return; 71.276 if (typeMap.put(t.tsym, t) == null) { 71.277 closure(types.supertype(t), typesSkip, typeMap); 71.278 @@ -1916,7 +1906,8 @@ 71.279 Type rt2 = types.subst(st2.getReturnType(), tvars2, tvars1); 71.280 boolean compat = 71.281 types.isSameType(rt1, rt2) || 71.282 - rt1.tag >= CLASS && rt2.tag >= CLASS && 71.283 + !rt1.isPrimitiveOrVoid() && 71.284 + !rt2.isPrimitiveOrVoid() && 71.285 (types.covariantReturnType(rt1, rt2, Warner.noWarnings) || 71.286 types.covariantReturnType(rt2, rt1, Warner.noWarnings)) || 71.287 checkCommonOverriderIn(s1,s2,site); 71.288 @@ -1961,7 +1952,8 @@ 71.289 Type rt13 = types.subst(st3.getReturnType(), tvars3, tvars1); 71.290 Type rt23 = types.subst(st3.getReturnType(), tvars3, tvars2); 71.291 boolean compat = 71.292 - rt13.tag >= CLASS && rt23.tag >= CLASS && 71.293 + !rt13.isPrimitiveOrVoid() && 71.294 + !rt23.isPrimitiveOrVoid() && 71.295 (types.covariantReturnType(rt13, rt1, Warner.noWarnings) && 71.296 types.covariantReturnType(rt23, rt2, Warner.noWarnings)); 71.297 if (compat) 71.298 @@ -1984,7 +1976,7 @@ 71.299 log.error(tree.pos(), "enum.no.finalize"); 71.300 return; 71.301 } 71.302 - for (Type t = origin.type; t.tag == CLASS; 71.303 + for (Type t = origin.type; t.hasTag(CLASS); 71.304 t = types.supertype(t)) { 71.305 if (t != origin.type) { 71.306 checkOverride(tree, t, origin, m); 71.307 @@ -2064,7 +2056,7 @@ 71.308 } 71.309 if (undef == null) { 71.310 Type st = types.supertype(c.type); 71.311 - if (st.tag == CLASS) 71.312 + if (st.hasTag(CLASS)) 71.313 undef = firstUndef(impl, (ClassSymbol)st.tsym); 71.314 } 71.315 for (List<Type> l = types.interfaces(c.type); 71.316 @@ -2155,7 +2147,7 @@ 71.317 } else if (!c.type.isErroneous()) { 71.318 try { 71.319 seenClasses = seenClasses.prepend(c); 71.320 - if (c.type.tag == CLASS) { 71.321 + if (c.type.hasTag(CLASS)) { 71.322 if (supertypes.nonEmpty()) { 71.323 scan(supertypes); 71.324 } 71.325 @@ -2200,13 +2192,13 @@ 71.326 71.327 private void checkNonCyclic1(DiagnosticPosition pos, Type t, List<TypeVar> seen) { 71.328 final TypeVar tv; 71.329 - if (t.tag == TYPEVAR && (t.tsym.flags() & UNATTRIBUTED) != 0) 71.330 + if (t.hasTag(TYPEVAR) && (t.tsym.flags() & UNATTRIBUTED) != 0) 71.331 return; 71.332 if (seen.contains(t)) { 71.333 tv = (TypeVar)t; 71.334 tv.bound = types.createErrorType(t); 71.335 log.error(pos, "cyclic.inheritance", t); 71.336 - } else if (t.tag == TYPEVAR) { 71.337 + } else if (t.hasTag(TYPEVAR)) { 71.338 tv = (TypeVar)t; 71.339 seen = seen.prepend(tv); 71.340 for (Type b : types.getBounds(tv)) 71.341 @@ -2232,14 +2224,14 @@ 71.342 } else if (!c.type.isErroneous()) { 71.343 try { 71.344 c.flags_field |= LOCKED; 71.345 - if (c.type.tag == CLASS) { 71.346 + if (c.type.hasTag(CLASS)) { 71.347 ClassType clazz = (ClassType)c.type; 71.348 if (clazz.interfaces_field != null) 71.349 for (List<Type> l=clazz.interfaces_field; l.nonEmpty(); l=l.tail) 71.350 complete &= checkNonCyclicInternal(pos, l.head); 71.351 if (clazz.supertype_field != null) { 71.352 Type st = clazz.supertype_field; 71.353 - if (st != null && st.tag == CLASS) 71.354 + if (st != null && st.hasTag(CLASS)) 71.355 complete &= checkNonCyclicInternal(pos, st); 71.356 } 71.357 if (c.owner.kind == TYP) 71.358 @@ -2261,7 +2253,7 @@ 71.359 for (List<Type> l=types.interfaces(c.type); l.nonEmpty(); l=l.tail) 71.360 l.head = types.createErrorType((ClassSymbol)l.head.tsym, Type.noType); 71.361 Type st = types.supertype(c.type); 71.362 - if (st.tag == CLASS) 71.363 + if (st.hasTag(CLASS)) 71.364 ((ClassType)c.type).supertype_field = types.createErrorType((ClassSymbol)st.tsym, Type.noType); 71.365 c.type = types.createErrorType(c, c.type); 71.366 c.flags_field |= ACYCLIC; 71.367 @@ -2313,7 +2305,7 @@ 71.368 void checkCompatibleSupertypes(DiagnosticPosition pos, Type c) { 71.369 List<Type> supertypes = types.interfaces(c); 71.370 Type supertype = types.supertype(c); 71.371 - if (supertype.tag == CLASS && 71.372 + if (supertype.hasTag(CLASS) && 71.373 (supertype.tsym.flags() & ABSTRACT) != 0) 71.374 supertypes = supertypes.prepend(supertype); 71.375 for (List<Type> l = supertypes; l.nonEmpty(); l = l.tail) { 71.376 @@ -2542,7 +2534,7 @@ 71.377 * @jls 9.6 Annotation Types 71.378 */ 71.379 void validateAnnotationMethod(DiagnosticPosition pos, MethodSymbol m) { 71.380 - for (Type sup = syms.annotationType; sup.tag == CLASS; sup = types.supertype(sup)) { 71.381 + for (Type sup = syms.annotationType; sup.hasTag(CLASS); sup = types.supertype(sup)) { 71.382 Scope s = sup.tsym.members(); 71.383 for (Scope.Entry e = s.lookup(m.name); e.scope != null; e = e.next()) { 71.384 if (e.sym.kind == MTH && 71.385 @@ -2855,7 +2847,7 @@ 71.386 { if (s.kind == TYP || 71.387 s.kind == VAR || 71.388 (s.kind == MTH && !s.isConstructor() && 71.389 - s.type.getReturnType().tag != VOID)) 71.390 + !s.type.getReturnType().hasTag(VOID))) 71.391 return true; 71.392 } 71.393 else 71.394 @@ -3016,12 +3008,12 @@ 71.395 } 71.396 71.397 void checkAnnotationResType(DiagnosticPosition pos, Type type) { 71.398 - switch (type.tag) { 71.399 - case TypeTags.CLASS: 71.400 + switch (type.getTag()) { 71.401 + case CLASS: 71.402 if ((type.tsym.flags() & ANNOTATION) != 0) 71.403 checkNonCyclicElementsInternal(pos, type.tsym); 71.404 break; 71.405 - case TypeTags.ARRAY: 71.406 + case ARRAY: 71.407 checkAnnotationResType(pos, types.elemtype(type)); 71.408 break; 71.409 default: 71.410 @@ -3114,7 +3106,7 @@ 71.411 void checkDivZero(DiagnosticPosition pos, Symbol operator, Type operand) { 71.412 if (operand.constValue() != null 71.413 && lint.isEnabled(LintCategory.DIVZERO) 71.414 - && operand.tag <= LONG 71.415 + && (operand.getTag().isSubRangeOf(LONG)) 71.416 && ((Number) (operand.constValue())).longValue() == 0) { 71.417 int opc = ((OperatorSymbol)operator).opcode; 71.418 if (opc == ByteCodes.idiv || opc == ByteCodes.imod 71.419 @@ -3241,6 +3233,19 @@ 71.420 return true; 71.421 } 71.422 71.423 + /** Check that an auxiliary class is not accessed from any other file than its own. 71.424 + */ 71.425 + void checkForBadAuxiliaryClassAccess(DiagnosticPosition pos, Env<AttrContext> env, ClassSymbol c) { 71.426 + if (lint.isEnabled(Lint.LintCategory.AUXILIARYCLASS) && 71.427 + (c.flags() & AUXILIARY) != 0 && 71.428 + rs.isAccessible(env, c) && 71.429 + !fileManager.isSameFile(c.sourcefile, env.toplevel.sourcefile)) 71.430 + { 71.431 + log.warning(pos, "auxiliary.class.accessed.from.outside.of.its.source.file", 71.432 + c, c.sourcefile); 71.433 + } 71.434 + } 71.435 + 71.436 private class ConversionWarner extends Warner { 71.437 final String uncheckedKey; 71.438 final Type found;
72.1 --- a/src/share/classes/com/sun/tools/javac/comp/ConstFold.java Thu Nov 01 14:13:13 2012 -0700 72.2 +++ b/src/share/classes/com/sun/tools/javac/comp/ConstFold.java Fri Nov 02 17:55:34 2012 -0700 72.3 @@ -1,5 +1,5 @@ 72.4 /* 72.5 - * Copyright (c) 1999, 2006, Oracle and/or its affiliates. All rights reserved. 72.6 + * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. 72.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 72.8 * 72.9 * This code is free software; you can redistribute it and/or modify it 72.10 @@ -31,7 +31,8 @@ 72.11 72.12 import com.sun.tools.javac.code.Type.*; 72.13 72.14 -import static com.sun.tools.javac.code.TypeTags.*; 72.15 +import static com.sun.tools.javac.code.TypeTag.BOOLEAN; 72.16 + 72.17 import static com.sun.tools.javac.jvm.ByteCodes.*; 72.18 72.19 /** Helper class for constant folding, used by the attribution phase. 72.20 @@ -176,19 +177,19 @@ 72.21 case imod: 72.22 return syms.intType.constType(intValue(l) % intValue(r)); 72.23 case iand: 72.24 - return (left.tag == BOOLEAN 72.25 + return (left.hasTag(BOOLEAN) 72.26 ? syms.booleanType : syms.intType) 72.27 .constType(intValue(l) & intValue(r)); 72.28 case bool_and: 72.29 return syms.booleanType.constType(b2i((intValue(l) & intValue(r)) != 0)); 72.30 case ior: 72.31 - return (left.tag == BOOLEAN 72.32 + return (left.hasTag(BOOLEAN) 72.33 ? syms.booleanType : syms.intType) 72.34 .constType(intValue(l) | intValue(r)); 72.35 case bool_or: 72.36 return syms.booleanType.constType(b2i((intValue(l) | intValue(r)) != 0)); 72.37 case ixor: 72.38 - return (left.tag == BOOLEAN 72.39 + return (left.hasTag(BOOLEAN) 72.40 ? syms.booleanType : syms.intType) 72.41 .constType(intValue(l) ^ intValue(r)); 72.42 case ishl: case ishll: 72.43 @@ -326,7 +327,7 @@ 72.44 72.45 /** Coerce constant type to target type. 72.46 * @param etype The source type of the coercion, 72.47 - * which is assumed to be a constant type compatble with 72.48 + * which is assumed to be a constant type compatible with 72.49 * ttype. 72.50 * @param ttype The target type of the coercion. 72.51 */ 72.52 @@ -334,9 +335,9 @@ 72.53 // WAS if (etype.baseType() == ttype.baseType()) 72.54 if (etype.tsym.type == ttype.tsym.type) 72.55 return etype; 72.56 - if (etype.tag <= DOUBLE) { 72.57 + if (etype.isNumeric()) { 72.58 Object n = etype.constValue(); 72.59 - switch (ttype.tag) { 72.60 + switch (ttype.getTag()) { 72.61 case BYTE: 72.62 return syms.byteType.constType(0 + (byte)intValue(n)); 72.63 case CHAR:
73.1 --- a/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java Thu Nov 01 14:13:13 2012 -0700 73.2 +++ b/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java Fri Nov 02 17:55:34 2012 -0700 73.3 @@ -44,7 +44,8 @@ 73.4 import java.util.Set; 73.5 import java.util.WeakHashMap; 73.6 73.7 -import static com.sun.tools.javac.code.TypeTags.*; 73.8 +import static com.sun.tools.javac.code.TypeTag.DEFERRED; 73.9 +import static com.sun.tools.javac.code.TypeTag.NONE; 73.10 import static com.sun.tools.javac.tree.JCTree.Tag.*; 73.11 73.12 /** 73.13 @@ -203,7 +204,7 @@ 73.14 case SPECULATIVE: 73.15 Assert.check(mode == null || 73.16 (mode == AttrMode.SPECULATIVE && 73.17 - speculativeType(deferredAttrContext.msym, deferredAttrContext.phase).tag == NONE)); 73.18 + speculativeType(deferredAttrContext.msym, deferredAttrContext.phase).hasTag(NONE))); 73.19 JCTree speculativeTree = attribSpeculative(tree, env, resultInfo); 73.20 speculativeCache.put(deferredAttrContext.msym, speculativeTree, deferredAttrContext.phase); 73.21 return speculativeTree.type; 73.22 @@ -442,7 +443,7 @@ 73.23 73.24 @Override 73.25 public Type apply(Type t) { 73.26 - if (t.tag != DEFERRED) { 73.27 + if (!t.hasTag(DEFERRED)) { 73.28 return t.map(this); 73.29 } else { 73.30 DeferredType dt = (DeferredType)t; 73.31 @@ -479,7 +480,7 @@ 73.32 @Override 73.33 protected Type typeOf(DeferredType dt) { 73.34 Type owntype = super.typeOf(dt); 73.35 - return owntype.tag == NONE ? 73.36 + return owntype.hasTag(NONE) ? 73.37 recover(dt) : owntype; 73.38 } 73.39 73.40 @@ -516,7 +517,7 @@ 73.41 */ 73.42 @SuppressWarnings("fallthrough") 73.43 List<Type> stuckVars(JCTree tree, ResultInfo resultInfo) { 73.44 - if (resultInfo.pt.tag == NONE || resultInfo.pt.isErroneous()) { 73.45 + if (resultInfo.pt.hasTag(NONE) || resultInfo.pt.isErroneous()) { 73.46 return List.nil(); 73.47 } else { 73.48 StuckChecker sc = new StuckChecker(resultInfo);
74.1 --- a/src/share/classes/com/sun/tools/javac/comp/Enter.java Thu Nov 01 14:13:13 2012 -0700 74.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Enter.java Fri Nov 02 17:55:34 2012 -0700 74.3 @@ -49,7 +49,7 @@ 74.4 * the symbol table. The pass consists of two phases, organized as 74.5 * follows: 74.6 * 74.7 - * <p>In the first phase, all class symbols are intered into their 74.8 + * <p>In the first phase, all class symbols are entered into their 74.9 * enclosing scope, descending recursively down the tree for classes 74.10 * which are members of other classes. The class symbols are given a 74.11 * MemberEnter object as completer.
75.1 --- a/src/share/classes/com/sun/tools/javac/comp/Flow.java Thu Nov 01 14:13:13 2012 -0700 75.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Flow.java Fri Nov 02 17:55:34 2012 -0700 75.3 @@ -40,7 +40,8 @@ 75.4 import static com.sun.tools.javac.code.Flags.*; 75.5 import static com.sun.tools.javac.code.Flags.BLOCK; 75.6 import static com.sun.tools.javac.code.Kinds.*; 75.7 -import static com.sun.tools.javac.code.TypeTags.*; 75.8 +import static com.sun.tools.javac.code.TypeTag.BOOLEAN; 75.9 +import static com.sun.tools.javac.code.TypeTag.VOID; 75.10 import static com.sun.tools.javac.tree.JCTree.Tag.*; 75.11 75.12 /** This pass implements dataflow analysis for Java programs though 75.13 @@ -473,7 +474,7 @@ 75.14 alive = true; 75.15 scanStat(tree.body); 75.16 75.17 - if (alive && tree.sym.type.getReturnType().tag != VOID) 75.18 + if (alive && !tree.sym.type.getReturnType().hasTag(VOID)) 75.19 log.error(TreeInfo.diagEndPos(tree.body), "missing.ret.stmt"); 75.20 75.21 List<PendingExit> exits = pendingExits.toList(); 75.22 @@ -1976,8 +1977,8 @@ 75.23 Bits uninitsBeforeElse = uninitsWhenFalse; 75.24 inits = initsWhenTrue; 75.25 uninits = uninitsWhenTrue; 75.26 - if (tree.truepart.type.tag == BOOLEAN && 75.27 - tree.falsepart.type.tag == BOOLEAN) { 75.28 + if (tree.truepart.type.hasTag(BOOLEAN) && 75.29 + tree.falsepart.type.hasTag(BOOLEAN)) { 75.30 // if b and c are boolean valued, then 75.31 // v is (un)assigned after a?b:c when true iff 75.32 // v is (un)assigned after b when true and
76.1 --- a/src/share/classes/com/sun/tools/javac/comp/Infer.java Thu Nov 01 14:13:13 2012 -0700 76.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java Fri Nov 02 17:55:34 2012 -0700 76.3 @@ -42,7 +42,7 @@ 76.4 import java.util.HashMap; 76.5 import java.util.Map; 76.6 76.7 -import static com.sun.tools.javac.code.TypeTags.*; 76.8 +import static com.sun.tools.javac.code.TypeTag.*; 76.9 76.10 /** Helper class for type parameter inference, used by the attribution phase. 76.11 * 76.12 @@ -145,7 +145,7 @@ 76.13 private Filter<Type> boundFilter = new Filter<Type>() { 76.14 @Override 76.15 public boolean accepts(Type t) { 76.16 - return !t.isErroneous() && t.tag != BOT; 76.17 + return !t.isErroneous() && !t.hasTag(BOT); 76.18 } 76.19 }; 76.20 76.21 @@ -163,7 +163,7 @@ 76.22 else { 76.23 that.inst = types.lub(lobounds); 76.24 } 76.25 - if (that.inst == null || that.inst.tag == ERROR) 76.26 + if (that.inst == null || that.inst.hasTag(ERROR)) 76.27 throw inferenceException 76.28 .setMessage("no.unique.minimal.instance.exists", 76.29 that.qtype, lobounds); 76.30 @@ -189,13 +189,13 @@ 76.31 Attr.ResultInfo resultInfo, 76.32 Warner warn) throws InferenceException { 76.33 Type to = resultInfo.pt; 76.34 - if (to.tag == NONE || resultInfo.checkContext.inferenceContext().free(resultInfo.pt)) { 76.35 - to = mtype.getReturnType().tag <= VOID ? 76.36 + if (to.hasTag(NONE) || resultInfo.checkContext.inferenceContext().free(resultInfo.pt)) { 76.37 + to = mtype.getReturnType().isPrimitiveOrVoid() ? 76.38 mtype.getReturnType() : syms.objectType; 76.39 } 76.40 Type qtype1 = inferenceContext.asFree(mtype.getReturnType(), types); 76.41 if (!types.isSubtype(qtype1, 76.42 - qtype1.tag == UNDETVAR ? types.boxedTypeOrType(to) : to)) { 76.43 + qtype1.hasTag(UNDETVAR) ? types.boxedTypeOrType(to) : to)) { 76.44 throw inferenceException 76.45 .setMessage("infer.no.conforming.instance.exists", 76.46 inferenceContext.restvars(), mtype.getReturnType(), to); 76.47 @@ -515,7 +515,7 @@ 76.48 //for remaining uninferred type-vars in the functional interface type, 76.49 //simply replace the wildcards with its bound 76.50 for (Type t : formalInterface.getTypeArguments()) { 76.51 - if (actualTypeargs.head.tag == WILDCARD) { 76.52 + if (actualTypeargs.head.hasTag(WILDCARD)) { 76.53 WildcardType wt = (WildcardType)actualTypeargs.head; 76.54 typeargs.append(wt.type); 76.55 } else { 76.56 @@ -592,7 +592,7 @@ 76.57 76.58 public Type apply(Type t) { 76.59 t = types.erasure(super.apply(t)); 76.60 - if (t.tag == BOT) 76.61 + if (t.hasTag(BOT)) 76.62 // nulls type as the marker type Null (which has no instances) 76.63 // infer as java.lang.Void for now 76.64 t = types.boxedClass(syms.voidType).type; 76.65 @@ -614,7 +614,7 @@ 76.66 } 76.67 76.68 public Type apply(Type t) { 76.69 - if (t.tag == TYPEVAR) return new UndetVar((TypeVar)t, types, includeBounds); 76.70 + if (t.hasTag(TYPEVAR)) return new UndetVar((TypeVar)t, types, includeBounds); 76.71 else return t.map(this); 76.72 } 76.73 };
77.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 77.2 +++ b/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java Fri Nov 02 17:55:34 2012 -0700 77.3 @@ -0,0 +1,1398 @@ 77.4 +/* 77.5 + * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. 77.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 77.7 + * 77.8 + * This code is free software; you can redistribute it and/or modify it 77.9 + * under the terms of the GNU General Public License version 2 only, as 77.10 + * published by the Free Software Foundation. Oracle designates this 77.11 + * particular file as subject to the "Classpath" exception as provided 77.12 + * by Oracle in the LICENSE file that accompanied this code. 77.13 + * 77.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 77.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 77.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 77.17 + * version 2 for more details (a copy is included in the LICENSE file that 77.18 + * accompanied this code). 77.19 + * 77.20 + * You should have received a copy of the GNU General Public License version 77.21 + * 2 along with this work; if not, write to the Free Software Foundation, 77.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 77.23 + * 77.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 77.25 + * or visit www.oracle.com if you need additional information or have any 77.26 + * questions. 77.27 + */ 77.28 +package com.sun.tools.javac.comp; 77.29 + 77.30 +import com.sun.tools.javac.tree.*; 77.31 +import com.sun.tools.javac.tree.JCTree; 77.32 +import com.sun.tools.javac.tree.JCTree.*; 77.33 +import com.sun.tools.javac.tree.JCTree.JCMemberReference.ReferenceKind; 77.34 +import com.sun.tools.javac.tree.TreeMaker; 77.35 +import com.sun.tools.javac.tree.TreeScanner; 77.36 +import com.sun.tools.javac.tree.TreeTranslator; 77.37 +import com.sun.tools.javac.code.Flags; 77.38 +import com.sun.tools.javac.code.Kinds; 77.39 +import com.sun.tools.javac.code.Symbol; 77.40 +import com.sun.tools.javac.code.Symbol.ClassSymbol; 77.41 +import com.sun.tools.javac.code.Symbol.DynamicMethodSymbol; 77.42 +import com.sun.tools.javac.code.Symbol.MethodSymbol; 77.43 +import com.sun.tools.javac.code.Symbol.VarSymbol; 77.44 +import com.sun.tools.javac.code.Symtab; 77.45 +import com.sun.tools.javac.code.Type; 77.46 +import com.sun.tools.javac.code.Type.ClassType; 77.47 +import com.sun.tools.javac.code.Type.MethodType; 77.48 +import com.sun.tools.javac.code.Types; 77.49 +import com.sun.tools.javac.comp.LambdaToMethod.LambdaAnalyzer.*; 77.50 +import com.sun.tools.javac.jvm.*; 77.51 +import com.sun.tools.javac.util.*; 77.52 +import com.sun.tools.javac.util.List; 77.53 +import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; 77.54 +import com.sun.source.tree.MemberReferenceTree.ReferenceMode; 77.55 + 77.56 +import java.util.HashMap; 77.57 +import java.util.LinkedHashMap; 77.58 +import java.util.Map; 77.59 + 77.60 +import static com.sun.tools.javac.comp.LambdaToMethod.LambdaSymbolKind.*; 77.61 +import static com.sun.tools.javac.code.Flags.*; 77.62 +import static com.sun.tools.javac.code.Kinds.*; 77.63 +import static com.sun.tools.javac.code.TypeTag.BOT; 77.64 +import static com.sun.tools.javac.code.TypeTag.NONE; 77.65 +import static com.sun.tools.javac.code.TypeTag.VOID; 77.66 +import static com.sun.tools.javac.tree.JCTree.Tag.*; 77.67 + 77.68 +/** 77.69 + * This pass desugars lambda expressions into static methods 77.70 + * 77.71 + * <p><b>This is NOT part of any supported API. 77.72 + * If you write code that depends on this, you do so at your own risk. 77.73 + * This code and its internal interfaces are subject to change or 77.74 + * deletion without notice.</b> 77.75 + */ 77.76 +public class LambdaToMethod extends TreeTranslator { 77.77 + 77.78 + private Names names; 77.79 + private Symtab syms; 77.80 + private Resolve rs; 77.81 + private TreeMaker make; 77.82 + private Types types; 77.83 + private TransTypes transTypes; 77.84 + private Env<AttrContext> attrEnv; 77.85 + 77.86 + /** the analyzer scanner */ 77.87 + private LambdaAnalyzer analyzer; 77.88 + 77.89 + /** map from lambda trees to translation contexts */ 77.90 + private Map<JCTree, TranslationContext<?>> contextMap; 77.91 + 77.92 + /** current translation context (visitor argument) */ 77.93 + private TranslationContext<?> context; 77.94 + 77.95 + /** list of translated methods 77.96 + **/ 77.97 + private ListBuffer<JCTree> translatedMethodList; 77.98 + 77.99 + // <editor-fold defaultstate="collapsed" desc="Instantiating"> 77.100 + private static final Context.Key<LambdaToMethod> unlambdaKey = 77.101 + new Context.Key<LambdaToMethod>(); 77.102 + 77.103 + public static LambdaToMethod instance(Context context) { 77.104 + LambdaToMethod instance = context.get(unlambdaKey); 77.105 + if (instance == null) { 77.106 + instance = new LambdaToMethod(context); 77.107 + } 77.108 + return instance; 77.109 + } 77.110 + 77.111 + private LambdaToMethod(Context context) { 77.112 + names = Names.instance(context); 77.113 + syms = Symtab.instance(context); 77.114 + rs = Resolve.instance(context); 77.115 + make = TreeMaker.instance(context); 77.116 + types = Types.instance(context); 77.117 + transTypes = TransTypes.instance(context); 77.118 + this.analyzer = makeAnalyzer(); 77.119 + } 77.120 + 77.121 + private LambdaAnalyzer makeAnalyzer() { 77.122 + return new LambdaAnalyzer(); 77.123 + } 77.124 + // </editor-fold> 77.125 + 77.126 + // <editor-fold defaultstate="collapsed" desc="translate methods"> 77.127 + @Override 77.128 + public <T extends JCTree> T translate(T tree) { 77.129 + TranslationContext<?> newContext = contextMap.get(tree); 77.130 + return translate(tree, newContext != null ? newContext : context); 77.131 + } 77.132 + 77.133 + public <T extends JCTree> T translate(T tree, TranslationContext<?> newContext) { 77.134 + TranslationContext<?> prevContext = context; 77.135 + try { 77.136 + context = newContext; 77.137 + return super.translate(tree); 77.138 + } 77.139 + finally { 77.140 + context = prevContext; 77.141 + } 77.142 + } 77.143 + 77.144 + public <T extends JCTree> List<T> translate(List<T> trees, TranslationContext<?> newContext) { 77.145 + ListBuffer<T> buf = ListBuffer.lb(); 77.146 + for (T tree : trees) { 77.147 + buf.append(translate(tree, newContext)); 77.148 + } 77.149 + return buf.toList(); 77.150 + } 77.151 + 77.152 + public JCTree translateTopLevelClass(Env<AttrContext> env, JCTree cdef, TreeMaker make) { 77.153 + this.make = make; 77.154 + this.attrEnv = env; 77.155 + this.context = null; 77.156 + this.contextMap = new HashMap<JCTree, TranslationContext<?>>(); 77.157 + return translate(cdef); 77.158 + } 77.159 + // </editor-fold> 77.160 + 77.161 + // <editor-fold defaultstate="collapsed" desc="visitor methods"> 77.162 + /** 77.163 + * Visit a class. 77.164 + * Maintain the translatedMethodList across nested classes. 77.165 + * Append the translatedMethodList to the class after it is translated. 77.166 + * @param tree 77.167 + */ 77.168 + @Override 77.169 + public void visitClassDef(JCClassDecl tree) { 77.170 + if (tree.sym.owner.kind == PCK) { 77.171 + //analyze class 77.172 + analyzer.analyzeClass(tree); 77.173 + } 77.174 + ListBuffer<JCTree> prevTranslated = translatedMethodList; 77.175 + try { 77.176 + translatedMethodList = ListBuffer.lb(); 77.177 + super.visitClassDef(tree); 77.178 + //add all translated instance methods here 77.179 + tree.defs = tree.defs.appendList(translatedMethodList.toList()); 77.180 + for (JCTree lambda : translatedMethodList) { 77.181 + tree.sym.members().enter(((JCMethodDecl)lambda).sym); 77.182 + } 77.183 + result = tree; 77.184 + } finally { 77.185 + translatedMethodList = prevTranslated; 77.186 + } 77.187 + } 77.188 + 77.189 + /** 77.190 + * Translate a lambda into a method to be inserted into the class. 77.191 + * Then replace the lambda site with an invokedynamic call of to lambda 77.192 + * meta-factory, which will use the lambda method. 77.193 + * @param tree 77.194 + */ 77.195 + @Override 77.196 + public void visitLambda(JCLambda tree) { 77.197 + LambdaTranslationContext localContext = (LambdaTranslationContext)context; 77.198 + MethodSymbol sym = (MethodSymbol)localContext.translatedSym; 77.199 + MethodType lambdaType = (MethodType) sym.type; 77.200 + 77.201 + //create the method declaration hoisting the lambda body 77.202 + JCMethodDecl lambdaDecl = make.MethodDef(make.Modifiers(sym.flags_field), 77.203 + sym.name, 77.204 + make.QualIdent(lambdaType.getReturnType().tsym), 77.205 + List.<JCTypeParameter>nil(), 77.206 + localContext.syntheticParams, 77.207 + lambdaType.getThrownTypes() == null ? 77.208 + List.<JCExpression>nil() : 77.209 + make.Types(lambdaType.getThrownTypes()), 77.210 + null, 77.211 + null); 77.212 + lambdaDecl.sym = sym; 77.213 + lambdaDecl.type = lambdaType; 77.214 + 77.215 + //translate lambda body 77.216 + //As the lambda body is translated, all references to lambda locals, 77.217 + //captured variables, enclosing members are adjusted accordingly 77.218 + //to refer to the static method parameters (rather than i.e. acessing to 77.219 + //captured members directly). 77.220 + lambdaDecl.body = translate(makeLambdaBody(tree, lambdaDecl)); 77.221 + 77.222 + //Add the method to the list of methods to be added to this class. 77.223 + translatedMethodList = translatedMethodList.prepend(lambdaDecl); 77.224 + 77.225 + //now that we have generated a method for the lambda expression, 77.226 + //we can translate the lambda into a method reference pointing to the newly 77.227 + //created method. 77.228 + // 77.229 + //Note that we need to adjust the method handle so that it will match the 77.230 + //signature of the SAM descriptor - this means that the method reference 77.231 + //should be added the following synthetic arguments: 77.232 + // 77.233 + // * the "this" argument if it is an instance method 77.234 + // * enclosing locals captured by the lambda expression 77.235 + 77.236 + ListBuffer<JCExpression> syntheticInits = ListBuffer.lb(); 77.237 + 77.238 + if (!sym.isStatic()) { 77.239 + syntheticInits.append(makeThis( 77.240 + sym.owner.asType(), 77.241 + localContext.owner.enclClass())); 77.242 + } 77.243 + 77.244 + //add captured locals 77.245 + for (Symbol fv : localContext.getSymbolMap(CAPTURED_VAR).keySet()) { 77.246 + if (fv != localContext.self) { 77.247 + JCTree captured_local = make.Ident(fv).setType(fv.type); 77.248 + syntheticInits.append((JCExpression) captured_local); 77.249 + } 77.250 + } 77.251 + 77.252 + //then, determine the arguments to the indy call 77.253 + List<JCExpression> indy_args = translate(syntheticInits.toList(), localContext.prev); 77.254 + 77.255 + //build a sam instance using an indy call to the meta-factory 77.256 + int refKind = referenceKind(sym); 77.257 + 77.258 + //convert to an invokedynamic call 77.259 + result = makeMetaFactoryIndyCall(tree, tree.targetType, refKind, sym, indy_args); 77.260 + } 77.261 + 77.262 + private JCIdent makeThis(Type type, Symbol owner) { 77.263 + VarSymbol _this = new VarSymbol(PARAMETER | FINAL | SYNTHETIC, 77.264 + names._this, 77.265 + type, 77.266 + owner); 77.267 + return make.Ident(_this); 77.268 + } 77.269 + 77.270 + /** 77.271 + * Translate a method reference into an invokedynamic call to the 77.272 + * meta-factory. 77.273 + * @param tree 77.274 + */ 77.275 + @Override 77.276 + public void visitReference(JCMemberReference tree) { 77.277 + ReferenceTranslationContext localContext = (ReferenceTranslationContext)context; 77.278 + 77.279 + //first determine the method symbol to be used to generate the sam instance 77.280 + //this is either the method reference symbol, or the bridged reference symbol 77.281 + Symbol refSym = localContext.needsBridge() ? 77.282 + localContext.bridgeSym : 77.283 + tree.sym; 77.284 + 77.285 + //build the bridge method, if needed 77.286 + if (localContext.needsBridge()) { 77.287 + bridgeMemberReference(tree, localContext); 77.288 + } 77.289 + 77.290 + //the qualifying expression is treated as a special captured arg 77.291 + JCExpression init; 77.292 + switch(tree.kind) { 77.293 + 77.294 + case IMPLICIT_INNER: /** Inner # new */ 77.295 + case SUPER: /** super # instMethod */ 77.296 + init = makeThis( 77.297 + localContext.owner.owner.asType(), 77.298 + localContext.owner); 77.299 + break; 77.300 + 77.301 + case BOUND: /** Expr # instMethod */ 77.302 + init = tree.getQualifierExpression(); 77.303 + break; 77.304 + 77.305 + case STATIC_EVAL: /** Expr # staticMethod */ 77.306 + case UNBOUND: /** Type # instMethod */ 77.307 + case STATIC: /** Type # staticMethod */ 77.308 + case TOPLEVEL: /** Top level # new */ 77.309 + init = null; 77.310 + break; 77.311 + 77.312 + default: 77.313 + throw new InternalError("Should not have an invalid kind"); 77.314 + } 77.315 + 77.316 + List<JCExpression> indy_args = init==null? List.<JCExpression>nil() : translate(List.of(init), localContext.prev); 77.317 + 77.318 + 77.319 + //build a sam instance using an indy call to the meta-factory 77.320 + result = makeMetaFactoryIndyCall(tree, tree.targetType, localContext.referenceKind(), refSym, indy_args); 77.321 + 77.322 + //if we had a static reference with non-static qualifier, add a let 77.323 + //expression to force the evaluation of the qualifier expr 77.324 + if (tree.hasKind(ReferenceKind.STATIC_EVAL)) { 77.325 + VarSymbol rec = new VarSymbol(0, names.fromString("rec$"), tree.getQualifierExpression().type, localContext.owner); 77.326 + JCVariableDecl recDef = make.VarDef(rec, tree.getQualifierExpression()); 77.327 + result = make.LetExpr(recDef, result).setType(tree.type); 77.328 + } 77.329 + } 77.330 + 77.331 + /** 77.332 + * Translate identifiers within a lambda to the mapped identifier 77.333 + * @param tree 77.334 + */ 77.335 + @Override 77.336 + public void visitIdent(JCIdent tree) { 77.337 + if (context == null || !analyzer.lambdaIdentSymbolFilter(tree.sym)) { 77.338 + super.visitIdent(tree); 77.339 + } else { 77.340 + LambdaTranslationContext lambdaContext = (LambdaTranslationContext) context; 77.341 + if (lambdaContext.getSymbolMap(PARAM).containsKey(tree.sym)) { 77.342 + Symbol translatedSym = lambdaContext.getSymbolMap(PARAM).get(tree.sym); 77.343 + result = make.Ident(translatedSym).setType(tree.type); 77.344 + } else if (lambdaContext.getSymbolMap(LOCAL_VAR).containsKey(tree.sym)) { 77.345 + Symbol translatedSym = lambdaContext.getSymbolMap(LOCAL_VAR).get(tree.sym); 77.346 + result = make.Ident(translatedSym).setType(tree.type); 77.347 + } else if (lambdaContext.getSymbolMap(CAPTURED_VAR).containsKey(tree.sym)) { 77.348 + Symbol translatedSym = lambdaContext.getSymbolMap(CAPTURED_VAR).get(tree.sym); 77.349 + result = make.Ident(translatedSym).setType(tree.type); 77.350 + } else { 77.351 + if (tree.sym.owner.kind == Kinds.TYP) { 77.352 + for (Map.Entry<Symbol, Symbol> encl_entry : lambdaContext.getSymbolMap(CAPTURED_THIS).entrySet()) { 77.353 + if (tree.sym.isMemberOf((ClassSymbol) encl_entry.getKey(), types)) { 77.354 + JCExpression enclRef = make.Ident(encl_entry.getValue()); 77.355 + result = tree.sym.name == names._this 77.356 + ? enclRef.setType(tree.type) 77.357 + : make.Select(enclRef, tree.sym).setType(tree.type); 77.358 + result = tree; 77.359 + return; 77.360 + } 77.361 + } 77.362 + } 77.363 + //access to untranslated symbols (i.e. compile-time constants, 77.364 + //members defined inside the lambda body, etc.) ) 77.365 + super.visitIdent(tree); 77.366 + } 77.367 + } 77.368 + } 77.369 + 77.370 + @Override 77.371 + public void visitVarDef(JCVariableDecl tree) { 77.372 + LambdaTranslationContext lambdaContext = (LambdaTranslationContext)context; 77.373 + if (context != null && lambdaContext.getSymbolMap(LOCAL_VAR).containsKey(tree.sym)) { 77.374 + JCExpression init = translate(tree.init); 77.375 + result = make.VarDef((VarSymbol)lambdaContext.getSymbolMap(LOCAL_VAR).get(tree.sym), init); 77.376 + } else { 77.377 + super.visitVarDef(tree); 77.378 + } 77.379 + } 77.380 + 77.381 + // </editor-fold> 77.382 + 77.383 + // <editor-fold defaultstate="collapsed" desc="Translation helper methods"> 77.384 + 77.385 + private JCBlock makeLambdaBody(JCLambda tree, JCMethodDecl lambdaMethodDecl) { 77.386 + return tree.getBodyKind() == JCLambda.BodyKind.EXPRESSION ? 77.387 + makeLambdaExpressionBody((JCExpression)tree.body, lambdaMethodDecl) : 77.388 + makeLambdaStatementBody((JCBlock)tree.body, lambdaMethodDecl, tree.canCompleteNormally); 77.389 + } 77.390 + 77.391 + private JCBlock makeLambdaExpressionBody(JCExpression expr, JCMethodDecl lambdaMethodDecl) { 77.392 + Type restype = lambdaMethodDecl.type.getReturnType(); 77.393 + boolean isLambda_void = expr.type.hasTag(VOID); 77.394 + boolean isTarget_void = restype.hasTag(VOID); 77.395 + boolean isTarget_Void = types.isSameType(restype, types.boxedClass(syms.voidType).type); 77.396 + if (isTarget_void) { 77.397 + //target is void: 77.398 + // BODY; 77.399 + JCStatement stat = make.Exec(expr); 77.400 + return make.Block(0, List.<JCStatement>of(stat)); 77.401 + } else if (isLambda_void && isTarget_Void) { 77.402 + //void to Void conversion: 77.403 + // BODY; return null; 77.404 + ListBuffer<JCStatement> stats = ListBuffer.lb(); 77.405 + stats.append(make.Exec(expr)); 77.406 + stats.append(make.Return(make.Literal(BOT, null).setType(syms.botType))); 77.407 + return make.Block(0, stats.toList()); 77.408 + } else { 77.409 + //non-void to non-void conversion: 77.410 + // return (TYPE)BODY; 77.411 + JCExpression retExpr = transTypes.coerce(attrEnv, expr, restype); 77.412 + return make.Block(0, List.<JCStatement>of(make.Return(retExpr))); 77.413 + } 77.414 + } 77.415 + 77.416 + private JCBlock makeLambdaStatementBody(JCBlock block, final JCMethodDecl lambdaMethodDecl, boolean completeNormally) { 77.417 + final Type restype = lambdaMethodDecl.type.getReturnType(); 77.418 + final boolean isTarget_void = restype.hasTag(VOID); 77.419 + boolean isTarget_Void = types.isSameType(restype, types.boxedClass(syms.voidType).type); 77.420 + 77.421 + class LambdaBodyTranslator extends TreeTranslator { 77.422 + 77.423 + @Override 77.424 + public void visitClassDef(JCClassDecl tree) { 77.425 + //do NOT recurse on any inner classes 77.426 + result = tree; 77.427 + } 77.428 + 77.429 + @Override 77.430 + public void visitLambda(JCLambda tree) { 77.431 + //do NOT recurse on any nested lambdas 77.432 + result = tree; 77.433 + } 77.434 + 77.435 + @Override 77.436 + public void visitReturn(JCReturn tree) { 77.437 + boolean isLambda_void = tree.expr == null; 77.438 + if (isTarget_void && !isLambda_void) { 77.439 + //Void to void conversion: 77.440 + // { TYPE $loc = RET-EXPR; return; } 77.441 + VarSymbol loc = makeSyntheticVar(0, names.fromString("$loc"), tree.expr.type, lambdaMethodDecl.sym); 77.442 + JCVariableDecl varDef = make.VarDef(loc, tree.expr); 77.443 + result = make.Block(0, List.<JCStatement>of(varDef, make.Return(null))); 77.444 + } else if (!isTarget_void || !isLambda_void) { 77.445 + //non-void to non-void conversion: 77.446 + // return (TYPE)RET-EXPR; 77.447 + tree.expr = transTypes.coerce(attrEnv, tree.expr, restype); 77.448 + result = tree; 77.449 + } else { 77.450 + result = tree; 77.451 + } 77.452 + 77.453 + } 77.454 + } 77.455 + 77.456 + JCBlock trans_block = new LambdaBodyTranslator().translate(block); 77.457 + if (completeNormally && isTarget_Void) { 77.458 + //there's no return statement and the lambda (possibly inferred) 77.459 + //return type is java.lang.Void; emit a synthetic return statement 77.460 + trans_block.stats = trans_block.stats.append(make.Return(make.Literal(BOT, null).setType(syms.botType))); 77.461 + } 77.462 + return trans_block; 77.463 + } 77.464 + 77.465 + /** 77.466 + * Create new synthetic method with given flags, name, type, owner 77.467 + */ 77.468 + private MethodSymbol makeSyntheticMethod(long flags, Name name, Type type, Symbol owner) { 77.469 + return new MethodSymbol(flags | SYNTHETIC, name, type, owner); 77.470 + } 77.471 + 77.472 + /** 77.473 + * Create new synthetic variable with given flags, name, type, owner 77.474 + */ 77.475 + private VarSymbol makeSyntheticVar(long flags, String name, Type type, Symbol owner) { 77.476 + return makeSyntheticVar(flags, names.fromString(name), type, owner); 77.477 + } 77.478 + 77.479 + /** 77.480 + * Create new synthetic variable with given flags, name, type, owner 77.481 + */ 77.482 + private VarSymbol makeSyntheticVar(long flags, Name name, Type type, Symbol owner) { 77.483 + return new VarSymbol(flags | SYNTHETIC, name, type, owner); 77.484 + } 77.485 + 77.486 + /** 77.487 + * Set varargsElement field on a given tree (must be either a new class tree 77.488 + * or a method call tree) 77.489 + */ 77.490 + private void setVarargsIfNeeded(JCTree tree, Type varargsElement) { 77.491 + if (varargsElement != null) { 77.492 + switch (tree.getTag()) { 77.493 + case APPLY: ((JCMethodInvocation)tree).varargsElement = varargsElement; break; 77.494 + case NEWCLASS: ((JCNewClass)tree).varargsElement = varargsElement; break; 77.495 + default: throw new AssertionError(); 77.496 + } 77.497 + } 77.498 + } 77.499 + 77.500 + /** 77.501 + * Convert method/constructor arguments by inserting appropriate cast 77.502 + * as required by type-erasure - this is needed when bridging a lambda/method 77.503 + * reference, as the bridged signature might require downcast to be compatible 77.504 + * with the generated signature. 77.505 + */ 77.506 + private List<JCExpression> convertArgs(Symbol meth, List<JCExpression> args, Type varargsElement) { 77.507 + Assert.check(meth.kind == Kinds.MTH); 77.508 + List<Type> formals = types.erasure(meth.type).getParameterTypes(); 77.509 + if (varargsElement != null) { 77.510 + Assert.check((meth.flags() & VARARGS) != 0); 77.511 + } 77.512 + return transTypes.translateArgs(args, formals, varargsElement, attrEnv); 77.513 + } 77.514 + 77.515 + // </editor-fold> 77.516 + 77.517 + private MethodSymbol makeSamDescriptor(Type targetType) { 77.518 + return (MethodSymbol)types.findDescriptorSymbol(targetType.tsym); 77.519 + } 77.520 + 77.521 + private Type makeFunctionalDescriptorType(Type targetType, MethodSymbol samDescriptor, boolean erased) { 77.522 + Type descType = types.memberType(targetType, samDescriptor); 77.523 + return erased ? types.erasure(descType) : descType; 77.524 + } 77.525 + 77.526 + private Type makeFunctionalDescriptorType(Type targetType, boolean erased) { 77.527 + return makeFunctionalDescriptorType(targetType, makeSamDescriptor(targetType), erased); 77.528 + } 77.529 + 77.530 + /** 77.531 + * Generate an adapter method "bridge" for a method reference which cannot 77.532 + * be used directly. 77.533 + */ 77.534 + private class MemberReferenceBridger { 77.535 + 77.536 + private final JCMemberReference tree; 77.537 + private final ReferenceTranslationContext localContext; 77.538 + private final ListBuffer<JCExpression> args = ListBuffer.lb(); 77.539 + private final ListBuffer<JCVariableDecl> params = ListBuffer.lb(); 77.540 + 77.541 + MemberReferenceBridger(JCMemberReference tree, ReferenceTranslationContext localContext) { 77.542 + this.tree = tree; 77.543 + this.localContext = localContext; 77.544 + } 77.545 + 77.546 + /** 77.547 + * Generate the bridge 77.548 + */ 77.549 + JCMethodDecl bridge() { 77.550 + int prevPos = make.pos; 77.551 + try { 77.552 + make.at(tree); 77.553 + Type samDesc = localContext.bridgedRefSig(); 77.554 + List<Type> samPTypes = samDesc.getParameterTypes(); 77.555 + 77.556 + //an extra argument is prepended to the signature of the bridge in case 77.557 + //the member reference is an instance method reference (in which case 77.558 + //the receiver expression is passed to the bridge itself). 77.559 + Type recType = null; 77.560 + switch (tree.kind) { 77.561 + case IMPLICIT_INNER: 77.562 + recType = tree.sym.owner.type.getEnclosingType(); 77.563 + break; 77.564 + case BOUND: 77.565 + recType = tree.getQualifierExpression().type; 77.566 + break; 77.567 + case UNBOUND: 77.568 + recType = samPTypes.head; 77.569 + samPTypes = samPTypes.tail; 77.570 + break; 77.571 + } 77.572 + 77.573 + //generate the parameter list for the bridged member reference - the 77.574 + //bridge signature will match the signature of the target sam descriptor 77.575 + 77.576 + VarSymbol rcvr = (recType == null) 77.577 + ? null 77.578 + : addParameter("rec$", recType, false); 77.579 + 77.580 + List<Type> refPTypes = tree.sym.type.getParameterTypes(); 77.581 + int refSize = refPTypes.size(); 77.582 + int samSize = samPTypes.size(); 77.583 + int last = localContext.needsVarArgsConversion() ? refSize - 1 : refSize; // Last parameter to copy from referenced method 77.584 + 77.585 + List<Type> l = refPTypes; 77.586 + // Use parameter types of the referenced method, excluding final var args 77.587 + for (int i = 0; l.nonEmpty() && i < last; ++i) { 77.588 + addParameter("x$" + i, l.head, true); 77.589 + l = l.tail; 77.590 + } 77.591 + // Flatten out the var args 77.592 + for (int i = last; i < samSize; ++i) { 77.593 + addParameter("xva$" + i, tree.varargsElement, true); 77.594 + } 77.595 + 77.596 + //generate the bridge method declaration 77.597 + JCMethodDecl bridgeDecl = make.MethodDef(make.Modifiers(localContext.bridgeSym.flags()), 77.598 + localContext.bridgeSym.name, 77.599 + make.QualIdent(samDesc.getReturnType().tsym), 77.600 + List.<JCTypeParameter>nil(), 77.601 + params.toList(), 77.602 + tree.sym.type.getThrownTypes() == null 77.603 + ? List.<JCExpression>nil() 77.604 + : make.Types(tree.sym.type.getThrownTypes()), 77.605 + null, 77.606 + null); 77.607 + bridgeDecl.sym = (MethodSymbol) localContext.bridgeSym; 77.608 + bridgeDecl.type = localContext.bridgeSym.type = types.createMethodTypeWithParameters(samDesc, TreeInfo.types(params.toList())); 77.609 + 77.610 + //bridge method body generation - this can be either a method call or a 77.611 + //new instance creation expression, depending on the member reference kind 77.612 + JCExpression bridgeExpr = (tree.getMode() == ReferenceMode.INVOKE) 77.613 + ? bridgeExpressionInvoke(rcvr) 77.614 + : bridgeExpressionNew(); 77.615 + 77.616 + //the body is either a return expression containing a method call, 77.617 + //or the method call itself, depending on whether the return type of 77.618 + //the bridge is non-void/void. 77.619 + bridgeDecl.body = makeLambdaExpressionBody(bridgeExpr, bridgeDecl); 77.620 + 77.621 + return bridgeDecl; 77.622 + } finally { 77.623 + make.at(prevPos); 77.624 + } 77.625 + } 77.626 + 77.627 + /** 77.628 + * determine the receiver of the bridged method call - the receiver can 77.629 + * be either the synthetic receiver parameter or a type qualifier; the 77.630 + * original qualifier expression is never used here, as it might refer 77.631 + * to symbols not available in the static context of the bridge 77.632 + */ 77.633 + private JCExpression bridgeExpressionInvoke(VarSymbol rcvr) { 77.634 + JCExpression qualifier = 77.635 + tree.sym.isStatic() ? 77.636 + make.Type(tree.sym.owner.type) : 77.637 + (rcvr != null) ? 77.638 + make.Ident(rcvr) : 77.639 + tree.getQualifierExpression(); 77.640 + 77.641 + //create the qualifier expression 77.642 + JCFieldAccess select = make.Select(qualifier, tree.sym.name); 77.643 + select.sym = tree.sym; 77.644 + select.type = tree.sym.erasure(types); 77.645 + 77.646 + //create the method call expression 77.647 + JCExpression apply = make.Apply(List.<JCExpression>nil(), select, 77.648 + convertArgs(tree.sym, args.toList(), tree.varargsElement)).setType(tree.sym.erasure(types).getReturnType()); 77.649 + 77.650 + apply = transTypes.coerce(apply, localContext.generatedRefSig().getReturnType()); 77.651 + setVarargsIfNeeded(apply, tree.varargsElement); 77.652 + return apply; 77.653 + } 77.654 + 77.655 + /** 77.656 + * the enclosing expression is either 'null' (no enclosing type) or set 77.657 + * to the first bridge synthetic parameter 77.658 + */ 77.659 + private JCExpression bridgeExpressionNew() { 77.660 + JCExpression encl = null; 77.661 + switch (tree.kind) { 77.662 + case UNBOUND: 77.663 + case IMPLICIT_INNER: 77.664 + encl = make.Ident(params.first()); 77.665 + } 77.666 + 77.667 + //create the instance creation expression 77.668 + JCNewClass newClass = make.NewClass(encl, 77.669 + List.<JCExpression>nil(), 77.670 + make.Type(tree.getQualifierExpression().type), 77.671 + convertArgs(tree.sym, args.toList(), tree.varargsElement), 77.672 + null); 77.673 + newClass.constructor = tree.sym; 77.674 + newClass.constructorType = tree.sym.erasure(types); 77.675 + newClass.type = tree.getQualifierExpression().type; 77.676 + setVarargsIfNeeded(newClass, tree.varargsElement); 77.677 + return newClass; 77.678 + } 77.679 + 77.680 + private VarSymbol addParameter(String name, Type p, boolean genArg) { 77.681 + VarSymbol vsym = new VarSymbol(0, names.fromString(name), p, localContext.bridgeSym); 77.682 + params.append(make.VarDef(vsym, null)); 77.683 + if (genArg) { 77.684 + args.append(make.Ident(vsym)); 77.685 + } 77.686 + return vsym; 77.687 + } 77.688 + } 77.689 + 77.690 + /** 77.691 + * Bridges a member reference - this is needed when: 77.692 + * * Var args in the referenced method need to be flattened away 77.693 + * * super is used 77.694 + */ 77.695 + private void bridgeMemberReference(JCMemberReference tree, ReferenceTranslationContext localContext) { 77.696 + JCMethodDecl bridgeDecl = (new MemberReferenceBridger(tree, localContext).bridge()); 77.697 + translatedMethodList = translatedMethodList.prepend(bridgeDecl); 77.698 + } 77.699 + 77.700 + /** 77.701 + * Generate an indy method call to the meta factory 77.702 + */ 77.703 + private JCExpression makeMetaFactoryIndyCall(JCExpression tree, Type targetType, int refKind, Symbol refSym, List<JCExpression> indy_args) { 77.704 + //determine the static bsm args 77.705 + Type mtype = makeFunctionalDescriptorType(targetType, true); 77.706 + List<Object> staticArgs = List.<Object>of( 77.707 + new Pool.MethodHandle(ClassFile.REF_invokeInterface, types.findDescriptorSymbol(targetType.tsym)), 77.708 + new Pool.MethodHandle(refKind, refSym), 77.709 + new MethodType(mtype.getParameterTypes(), 77.710 + mtype.getReturnType(), 77.711 + mtype.getThrownTypes(), 77.712 + syms.methodClass)); 77.713 + 77.714 + //computed indy arg types 77.715 + ListBuffer<Type> indy_args_types = ListBuffer.lb(); 77.716 + for (JCExpression arg : indy_args) { 77.717 + indy_args_types.append(arg.type); 77.718 + } 77.719 + 77.720 + //finally, compute the type of the indy call 77.721 + MethodType indyType = new MethodType(indy_args_types.toList(), 77.722 + tree.type, 77.723 + List.<Type>nil(), 77.724 + syms.methodClass); 77.725 + 77.726 + return makeIndyCall(tree, syms.lambdaMetafactory, names.metaFactory, staticArgs, indyType, indy_args); 77.727 + } 77.728 + 77.729 + /** 77.730 + * Generate an indy method call with given name, type and static bootstrap 77.731 + * arguments types 77.732 + */ 77.733 + private JCExpression makeIndyCall(DiagnosticPosition pos, Type site, Name bsmName, List<Object> staticArgs, MethodType indyType, List<JCExpression> indyArgs) { 77.734 + int prevPos = make.pos; 77.735 + try { 77.736 + make.at(pos); 77.737 + List<Type> bsm_staticArgs = List.of(syms.methodHandleLookupType, 77.738 + syms.stringType, 77.739 + syms.methodTypeType).appendList(bsmStaticArgToTypes(staticArgs)); 77.740 + 77.741 + Symbol bsm = rs.resolveInternalMethod(pos, attrEnv, site, 77.742 + bsmName, bsm_staticArgs, List.<Type>nil()); 77.743 + 77.744 + DynamicMethodSymbol dynSym = 77.745 + new DynamicMethodSymbol(names.lambda, 77.746 + syms.noSymbol, 77.747 + bsm.isStatic() ? ClassFile.REF_invokeStatic : ClassFile.REF_invokeVirtual, 77.748 + (MethodSymbol)bsm, 77.749 + indyType, 77.750 + staticArgs.toArray()); 77.751 + 77.752 + JCFieldAccess qualifier = make.Select(make.QualIdent(site.tsym), bsmName); 77.753 + qualifier.sym = dynSym; 77.754 + qualifier.type = indyType.getReturnType(); 77.755 + 77.756 + JCMethodInvocation proxyCall = make.Apply(List.<JCExpression>nil(), qualifier, indyArgs); 77.757 + proxyCall.type = indyType.getReturnType(); 77.758 + return proxyCall; 77.759 + } finally { 77.760 + make.at(prevPos); 77.761 + } 77.762 + } 77.763 + //where 77.764 + private List<Type> bsmStaticArgToTypes(List<Object> args) { 77.765 + ListBuffer<Type> argtypes = ListBuffer.lb(); 77.766 + for (Object arg : args) { 77.767 + argtypes.append(bsmStaticArgToType(arg)); 77.768 + } 77.769 + return argtypes.toList(); 77.770 + } 77.771 + 77.772 + private Type bsmStaticArgToType(Object arg) { 77.773 + Assert.checkNonNull(arg); 77.774 + if (arg instanceof ClassSymbol) { 77.775 + return syms.classType; 77.776 + } else if (arg instanceof Integer) { 77.777 + return syms.intType; 77.778 + } else if (arg instanceof Long) { 77.779 + return syms.longType; 77.780 + } else if (arg instanceof Float) { 77.781 + return syms.floatType; 77.782 + } else if (arg instanceof Double) { 77.783 + return syms.doubleType; 77.784 + } else if (arg instanceof String) { 77.785 + return syms.stringType; 77.786 + } else if (arg instanceof Pool.MethodHandle) { 77.787 + return syms.methodHandleType; 77.788 + } else if (arg instanceof MethodType) { 77.789 + return syms.methodTypeType; 77.790 + } else { 77.791 + Assert.error("bad static arg " + arg.getClass()); 77.792 + return null; 77.793 + } 77.794 + } 77.795 + 77.796 + /** 77.797 + * Get the opcode associated with this method reference 77.798 + */ 77.799 + private int referenceKind(Symbol refSym) { 77.800 + if (refSym.isConstructor()) { 77.801 + return ClassFile.REF_newInvokeSpecial; 77.802 + } else { 77.803 + if (refSym.isStatic()) { 77.804 + return ClassFile.REF_invokeStatic; 77.805 + } else if (refSym.enclClass().isInterface()) { 77.806 + return ClassFile.REF_invokeInterface; 77.807 + } else { 77.808 + return ClassFile.REF_invokeVirtual; 77.809 + } 77.810 + } 77.811 + } 77.812 + // </editor-fold> 77.813 + 77.814 + // <editor-fold defaultstate="collapsed" desc="Lambda/reference analyzer">\ 77.815 + /** 77.816 + * This visitor collects information about translation of a lambda expression. 77.817 + * More specifically, it keeps track of the enclosing contexts and captured locals 77.818 + * accessed by the lambda being translated (as well as other useful info). 77.819 + */ 77.820 + class LambdaAnalyzer extends TreeScanner { 77.821 + 77.822 + /** the frame stack - used to reconstruct translation info about enclosing scopes */ 77.823 + private List<Frame> frameStack; 77.824 + 77.825 + /** 77.826 + * keep the count of lambda expression (used to generate unambiguous 77.827 + * names) 77.828 + */ 77.829 + private int lambdaCount = 0; 77.830 + 77.831 + private void analyzeClass(JCClassDecl tree) { 77.832 + frameStack = List.nil(); 77.833 + scan(tree); 77.834 + } 77.835 + 77.836 + @Override 77.837 + public void visitBlock(JCBlock tree) { 77.838 + List<Frame> prevStack = frameStack; 77.839 + try { 77.840 + if (frameStack.nonEmpty() && frameStack.head.tree.hasTag(CLASSDEF)) { 77.841 + frameStack = frameStack.prepend(new Frame(tree)); 77.842 + } 77.843 + super.visitBlock(tree); 77.844 + } 77.845 + finally { 77.846 + frameStack = prevStack; 77.847 + } 77.848 + } 77.849 + 77.850 + @Override 77.851 + public void visitClassDef(JCClassDecl tree) { 77.852 + List<Frame> prevStack = frameStack; 77.853 + try { 77.854 + if (frameStack.nonEmpty() && enclosingLambda() != null) { 77.855 + tree.sym.owner = owner(); 77.856 + LambdaTranslationContext lambdaContext = (LambdaTranslationContext)contextMap.get(enclosingLambda()); 77.857 + Type encl = lambdaContext.enclosingType(); 77.858 + if (encl.hasTag(NONE)) { 77.859 + //if the translated lambda body occurs in a static context, 77.860 + //any class declaration within it must be made static 77.861 + tree.sym.flags_field |= STATIC; 77.862 + ((ClassType)tree.sym.type).setEnclosingType(Type.noType); 77.863 + } else { 77.864 + //if the translated lambda body is in an instance context 77.865 + //the enclosing type of any class declaration within it 77.866 + //must be updated to point to the new enclosing type (if any) 77.867 + ((ClassType)tree.sym.type).setEnclosingType(encl); 77.868 + } 77.869 + } 77.870 + frameStack = frameStack.prepend(new Frame(tree)); 77.871 + super.visitClassDef(tree); 77.872 + } 77.873 + finally { 77.874 + frameStack = prevStack; 77.875 + } 77.876 + if (frameStack.nonEmpty() && enclosingLambda() != null) { 77.877 + // Any class defined within a lambda is an implicit 'this' reference 77.878 + // because its constructor will reference the enclosing class 77.879 + ((LambdaTranslationContext) context()).addSymbol(tree.sym.type.getEnclosingType().tsym, CAPTURED_THIS); 77.880 + } 77.881 + } 77.882 + 77.883 + @Override 77.884 + public void visitIdent(JCIdent tree) { 77.885 + if (context() == null || !lambdaIdentSymbolFilter(tree.sym)) { 77.886 + super.visitIdent(tree); 77.887 + } else { 77.888 + if (tree.sym.kind == VAR && 77.889 + tree.sym.owner.kind == MTH && 77.890 + tree.type.constValue() == null) { 77.891 + TranslationContext<?> localContext = context(); 77.892 + while (localContext != null) { 77.893 + if (localContext.tree.getTag() == LAMBDA) { 77.894 + JCTree block = capturedDecl(localContext.depth, tree.sym); 77.895 + if (block == null) break; 77.896 + ((LambdaTranslationContext)localContext).addSymbol(tree.sym, CAPTURED_VAR); 77.897 + } 77.898 + localContext = localContext.prev; 77.899 + } 77.900 + } else if (tree.sym.owner.kind == TYP) { 77.901 + TranslationContext<?> localContext = context(); 77.902 + while (localContext != null) { 77.903 + if (localContext.tree.hasTag(LAMBDA)) { 77.904 + JCTree block = capturedDecl(localContext.depth, tree.sym); 77.905 + if (block == null) break; 77.906 + switch (block.getTag()) { 77.907 + case CLASSDEF: 77.908 + JCClassDecl cdecl = (JCClassDecl)block; 77.909 + ((LambdaTranslationContext)localContext).addSymbol(cdecl.sym, CAPTURED_THIS); 77.910 + break; 77.911 + default: 77.912 + Assert.error("bad block kind"); 77.913 + } 77.914 + } 77.915 + localContext = localContext.prev; 77.916 + } 77.917 + } 77.918 + } 77.919 + } 77.920 + 77.921 + @Override 77.922 + public void visitLambda(JCLambda tree) { 77.923 + List<Frame> prevStack = frameStack; 77.924 + try { 77.925 + LambdaTranslationContext context = (LambdaTranslationContext)makeLambdaContext(tree); 77.926 + frameStack = frameStack.prepend(new Frame(tree)); 77.927 + for (JCVariableDecl param : tree.params) { 77.928 + context.addSymbol(param.sym, PARAM); 77.929 + frameStack.head.addLocal(param.sym); 77.930 + } 77.931 + contextMap.put(tree, context); 77.932 + scan(tree.body); 77.933 + context.complete(); 77.934 + } 77.935 + finally { 77.936 + frameStack = prevStack; 77.937 + } 77.938 + } 77.939 + 77.940 + @Override 77.941 + public void visitMethodDef(JCMethodDecl tree) { 77.942 + List<Frame> prevStack = frameStack; 77.943 + try { 77.944 + frameStack = frameStack.prepend(new Frame(tree)); 77.945 + super.visitMethodDef(tree); 77.946 + } 77.947 + finally { 77.948 + frameStack = prevStack; 77.949 + } 77.950 + } 77.951 + 77.952 + @Override 77.953 + public void visitNewClass(JCNewClass tree) { 77.954 + if (lambdaNewClassFilter(context(), tree)) { 77.955 + ((LambdaTranslationContext) context()).addSymbol(tree.type.getEnclosingType().tsym, CAPTURED_THIS); 77.956 + } 77.957 + super.visitNewClass(tree); 77.958 + } 77.959 + 77.960 + @Override 77.961 + public void visitReference(JCMemberReference tree) { 77.962 + scan(tree.getQualifierExpression()); 77.963 + contextMap.put(tree, makeReferenceContext(tree)); 77.964 + } 77.965 + 77.966 + @Override 77.967 + public void visitSelect(JCFieldAccess tree) { 77.968 + if (context() != null && lambdaSelectSymbolFilter(tree.sym)) { 77.969 + TranslationContext<?> localContext = context(); 77.970 + while (localContext != null) { 77.971 + if (localContext.tree.hasTag(LAMBDA)) { 77.972 + JCClassDecl clazz = (JCClassDecl)capturedDecl(localContext.depth, tree.sym); 77.973 + if (clazz == null) break; 77.974 + ((LambdaTranslationContext)localContext).addSymbol(clazz.sym, CAPTURED_THIS); 77.975 + } 77.976 + localContext = localContext.prev; 77.977 + } 77.978 + scan(tree.selected); 77.979 + } else { 77.980 + super.visitSelect(tree); 77.981 + } 77.982 + } 77.983 + 77.984 + @Override 77.985 + public void visitVarDef(JCVariableDecl tree) { 77.986 + if (frameStack.head.tree.hasTag(LAMBDA)) { 77.987 + ((LambdaTranslationContext)context()).addSymbol(tree.sym, LOCAL_VAR); 77.988 + } 77.989 + List<Frame> prevStack = frameStack; 77.990 + try { 77.991 + if (tree.sym.owner.kind == MTH) { 77.992 + frameStack.head.addLocal(tree.sym); 77.993 + } 77.994 + frameStack = frameStack.prepend(new Frame(tree)); 77.995 + super.visitVarDef(tree); 77.996 + } 77.997 + finally { 77.998 + frameStack = prevStack; 77.999 + } 77.1000 + } 77.1001 + 77.1002 + private Name lambdaName() { 77.1003 + return names.lambda.append(names.fromString("$" + lambdaCount++)); 77.1004 + } 77.1005 + 77.1006 + /** 77.1007 + * Return a valid owner given the current declaration stack 77.1008 + * (required to skip synthetic lambda symbols) 77.1009 + */ 77.1010 + private Symbol owner() { 77.1011 + List<Frame> frameStack2 = frameStack; 77.1012 + while (frameStack2.nonEmpty()) { 77.1013 + switch (frameStack2.head.tree.getTag()) { 77.1014 + case VARDEF: 77.1015 + if (((JCVariableDecl)frameStack2.head.tree).sym.isLocal()) { 77.1016 + frameStack2 = frameStack2.tail; 77.1017 + break; 77.1018 + } 77.1019 + JCClassDecl cdecl = (JCClassDecl)frameStack2.tail.head.tree; 77.1020 + return makeSyntheticMethod(((JCVariableDecl)frameStack2.head.tree).sym.flags() & STATIC, names.empty, null, cdecl.sym); 77.1021 + case BLOCK: 77.1022 + JCClassDecl cdecl2 = (JCClassDecl)frameStack2.tail.head.tree; 77.1023 + return makeSyntheticMethod(((JCBlock)frameStack2.head.tree).flags & STATIC | Flags.BLOCK, names.empty, null, cdecl2.sym); 77.1024 + case CLASSDEF: 77.1025 + return ((JCClassDecl)frameStack2.head.tree).sym; 77.1026 + case METHODDEF: 77.1027 + return ((JCMethodDecl)frameStack2.head.tree).sym; 77.1028 + case LAMBDA: 77.1029 + return ((LambdaTranslationContext)contextMap.get(frameStack2.head.tree)).translatedSym; 77.1030 + default: 77.1031 + frameStack2 = frameStack2.tail; 77.1032 + } 77.1033 + } 77.1034 + Assert.error(); 77.1035 + return null; 77.1036 + } 77.1037 + 77.1038 + private JCTree enclosingLambda() { 77.1039 + List<Frame> frameStack2 = frameStack; 77.1040 + while (frameStack2.nonEmpty()) { 77.1041 + switch (frameStack2.head.tree.getTag()) { 77.1042 + case CLASSDEF: 77.1043 + case METHODDEF: 77.1044 + return null; 77.1045 + case LAMBDA: 77.1046 + return frameStack2.head.tree; 77.1047 + default: 77.1048 + frameStack2 = frameStack2.tail; 77.1049 + } 77.1050 + } 77.1051 + Assert.error(); 77.1052 + return null; 77.1053 + } 77.1054 + 77.1055 + /** 77.1056 + * Return the declaration corresponding to a symbol in the enclosing 77.1057 + * scope; the depth parameter is used to filter out symbols defined 77.1058 + * in nested scopes (which do not need to undergo capture). 77.1059 + */ 77.1060 + private JCTree capturedDecl(int depth, Symbol sym) { 77.1061 + int currentDepth = frameStack.size() - 1; 77.1062 + for (Frame block : frameStack) { 77.1063 + switch (block.tree.getTag()) { 77.1064 + case CLASSDEF: 77.1065 + ClassSymbol clazz = ((JCClassDecl)block.tree).sym; 77.1066 + if (sym.isMemberOf(clazz, types)) { 77.1067 + return currentDepth > depth ? null : block.tree; 77.1068 + } 77.1069 + break; 77.1070 + case VARDEF: 77.1071 + if (((JCVariableDecl)block.tree).sym == sym && 77.1072 + sym.owner.kind == MTH) { //only locals are captured 77.1073 + return currentDepth > depth ? null : block.tree; 77.1074 + } 77.1075 + break; 77.1076 + case BLOCK: 77.1077 + case METHODDEF: 77.1078 + case LAMBDA: 77.1079 + if (block.locals != null && block.locals.contains(sym)) { 77.1080 + return currentDepth > depth ? null : block.tree; 77.1081 + } 77.1082 + break; 77.1083 + default: 77.1084 + Assert.error("bad decl kind " + block.tree.getTag()); 77.1085 + } 77.1086 + currentDepth--; 77.1087 + } 77.1088 + return null; 77.1089 + } 77.1090 + 77.1091 + private TranslationContext<?> context() { 77.1092 + for (Frame frame : frameStack) { 77.1093 + TranslationContext<?> context = contextMap.get(frame.tree); 77.1094 + if (context != null) { 77.1095 + return context; 77.1096 + } 77.1097 + } 77.1098 + return null; 77.1099 + } 77.1100 + 77.1101 + /** 77.1102 + * This is used to filter out those identifiers that needs to be adjusted 77.1103 + * when translating away lambda expressions 77.1104 + */ 77.1105 + private boolean lambdaIdentSymbolFilter(Symbol sym) { 77.1106 + return (sym.kind == VAR || sym.kind == MTH) 77.1107 + && !sym.isStatic() 77.1108 + && sym.name != names.init; 77.1109 + } 77.1110 + 77.1111 + private boolean lambdaSelectSymbolFilter(Symbol sym) { 77.1112 + return (sym.kind == VAR || sym.kind == MTH) && 77.1113 + !sym.isStatic() && 77.1114 + (sym.name == names._this || 77.1115 + sym.name == names._super); 77.1116 + } 77.1117 + 77.1118 + /** 77.1119 + * This is used to filter out those new class expressions that need to 77.1120 + * be qualified with an enclosing tree 77.1121 + */ 77.1122 + private boolean lambdaNewClassFilter(TranslationContext<?> context, JCNewClass tree) { 77.1123 + if (context != null 77.1124 + && tree.encl == null 77.1125 + && tree.def == null 77.1126 + && tree.type.getEnclosingType().hasTag(NONE)) { 77.1127 + Type encl = tree.type.getEnclosingType(); 77.1128 + Type current = context.owner.enclClass().type; 77.1129 + while (current.hasTag(NONE)) { 77.1130 + if (current.tsym.isSubClass(encl.tsym, types)) { 77.1131 + return true; 77.1132 + } 77.1133 + current = current.getEnclosingType(); 77.1134 + } 77.1135 + return false; 77.1136 + } else { 77.1137 + return false; 77.1138 + } 77.1139 + } 77.1140 + 77.1141 + private TranslationContext<JCLambda> makeLambdaContext(JCLambda tree) { 77.1142 + return new LambdaTranslationContext(tree); 77.1143 + } 77.1144 + 77.1145 + private TranslationContext<JCMemberReference> makeReferenceContext(JCMemberReference tree) { 77.1146 + return new ReferenceTranslationContext(tree); 77.1147 + } 77.1148 + 77.1149 + private class Frame { 77.1150 + final JCTree tree; 77.1151 + List<Symbol> locals; 77.1152 + 77.1153 + public Frame(JCTree tree) { 77.1154 + this.tree = tree; 77.1155 + } 77.1156 + 77.1157 + void addLocal(Symbol sym) { 77.1158 + if (locals == null) { 77.1159 + locals = List.nil(); 77.1160 + } 77.1161 + locals = locals.prepend(sym); 77.1162 + } 77.1163 + } 77.1164 + 77.1165 + /** 77.1166 + * This class is used to store important information regarding translation of 77.1167 + * lambda expression/method references (see subclasses). 77.1168 + */ 77.1169 + private abstract class TranslationContext<T extends JCTree> { 77.1170 + 77.1171 + /** the underlying (untranslated) tree */ 77.1172 + T tree; 77.1173 + 77.1174 + /** points to the adjusted enclosing scope in which this lambda/mref expression occurs */ 77.1175 + Symbol owner; 77.1176 + 77.1177 + /** the depth of this lambda expression in the frame stack */ 77.1178 + int depth; 77.1179 + 77.1180 + /** the enclosing translation context (set for nested lambdas/mref) */ 77.1181 + TranslationContext<?> prev; 77.1182 + 77.1183 + TranslationContext(T tree) { 77.1184 + this.tree = tree; 77.1185 + this.owner = owner(); 77.1186 + this.depth = frameStack.size() - 1; 77.1187 + this.prev = context(); 77.1188 + } 77.1189 + } 77.1190 + 77.1191 + /** 77.1192 + * This class retains all the useful information about a lambda expression; 77.1193 + * the contents of this class are filled by the LambdaAnalyzer visitor, 77.1194 + * and the used by the main translation routines in order to adjust references 77.1195 + * to captured locals/members, etc. 77.1196 + */ 77.1197 + private class LambdaTranslationContext extends TranslationContext<JCLambda> { 77.1198 + 77.1199 + /** variable in the enclosing context to which this lambda is assigned */ 77.1200 + Symbol self; 77.1201 + 77.1202 + /** map from original to translated lambda parameters */ 77.1203 + Map<Symbol, Symbol> lambdaParams = new LinkedHashMap<Symbol, Symbol>(); 77.1204 + 77.1205 + /** map from original to translated lambda locals */ 77.1206 + Map<Symbol, Symbol> lambdaLocals = new LinkedHashMap<Symbol, Symbol>(); 77.1207 + 77.1208 + /** map from variables in enclosing scope to translated synthetic parameters */ 77.1209 + Map<Symbol, Symbol> capturedLocals = new LinkedHashMap<Symbol, Symbol>(); 77.1210 + 77.1211 + /** map from class symbols to translated synthetic parameters (for captured member access) */ 77.1212 + Map<Symbol, Symbol> capturedThis = new LinkedHashMap<Symbol, Symbol>(); 77.1213 + 77.1214 + /** the synthetic symbol for the method hoisting the translated lambda */ 77.1215 + Symbol translatedSym; 77.1216 + 77.1217 + List<JCVariableDecl> syntheticParams; 77.1218 + 77.1219 + LambdaTranslationContext(JCLambda tree) { 77.1220 + super(tree); 77.1221 + Frame frame = frameStack.head; 77.1222 + if (frame.tree.hasTag(VARDEF)) { 77.1223 + self = ((JCVariableDecl)frame.tree).sym; 77.1224 + } 77.1225 + this.translatedSym = makeSyntheticMethod(0, lambdaName(), null, owner.enclClass()); 77.1226 + } 77.1227 + 77.1228 + /** 77.1229 + * Translate a symbol of a given kind into something suitable for the 77.1230 + * synthetic lambda body 77.1231 + */ 77.1232 + Symbol translate(String name, Symbol sym, LambdaSymbolKind skind) { 77.1233 + if (skind == CAPTURED_THIS) { 77.1234 + return sym; // self represented 77.1235 + } else { 77.1236 + return makeSyntheticVar(FINAL, name, types.erasure(sym.type), translatedSym); 77.1237 + } 77.1238 + } 77.1239 + 77.1240 + void addSymbol(Symbol sym, LambdaSymbolKind skind) { 77.1241 + Map<Symbol, Symbol> transMap = null; 77.1242 + String preferredName; 77.1243 + switch (skind) { 77.1244 + case CAPTURED_THIS: 77.1245 + transMap = capturedThis; 77.1246 + preferredName = "encl$" + capturedThis.size(); 77.1247 + break; 77.1248 + case CAPTURED_VAR: 77.1249 + transMap = capturedLocals; 77.1250 + preferredName = "cap$" + capturedLocals.size(); 77.1251 + break; 77.1252 + case LOCAL_VAR: 77.1253 + transMap = lambdaLocals; 77.1254 + preferredName = sym.name.toString(); 77.1255 + break; 77.1256 + case PARAM: 77.1257 + transMap = lambdaParams; 77.1258 + preferredName = sym.name.toString(); 77.1259 + break; 77.1260 + default: throw new AssertionError(); 77.1261 + } 77.1262 + if (!transMap.containsKey(sym)) { 77.1263 + transMap.put(sym, translate(preferredName, sym, skind)); 77.1264 + } 77.1265 + } 77.1266 + 77.1267 + Map<Symbol, Symbol> getSymbolMap(LambdaSymbolKind... skinds) { 77.1268 + LinkedHashMap<Symbol, Symbol> translationMap = new LinkedHashMap<Symbol, Symbol>(); 77.1269 + for (LambdaSymbolKind skind : skinds) { 77.1270 + switch (skind) { 77.1271 + case CAPTURED_THIS: 77.1272 + translationMap.putAll(capturedThis); 77.1273 + break; 77.1274 + case CAPTURED_VAR: 77.1275 + translationMap.putAll(capturedLocals); 77.1276 + break; 77.1277 + case LOCAL_VAR: 77.1278 + translationMap.putAll(lambdaLocals); 77.1279 + break; 77.1280 + case PARAM: 77.1281 + translationMap.putAll(lambdaParams); 77.1282 + break; 77.1283 + default: throw new AssertionError(); 77.1284 + } 77.1285 + } 77.1286 + return translationMap; 77.1287 + } 77.1288 + 77.1289 + /** 77.1290 + * The translatedSym is not complete/accurate until the analysis is 77.1291 + * finished. Once the analysis is finished, the translatedSym is 77.1292 + * "completed" -- updated with type information, access modifiers, 77.1293 + * and full parameter list. 77.1294 + */ 77.1295 + void complete() { 77.1296 + if (syntheticParams != null) { 77.1297 + return; 77.1298 + } 77.1299 + boolean inInterface = translatedSym.owner.isInterface(); 77.1300 + boolean thisReferenced = !getSymbolMap(CAPTURED_THIS).isEmpty(); 77.1301 + boolean needInstance = thisReferenced || inInterface; 77.1302 + 77.1303 + // If instance access isn't needed, make it static 77.1304 + // Interface methods much be public default methods, otherwise make it private 77.1305 + translatedSym.flags_field = SYNTHETIC | (needInstance? 0 : STATIC) | (inInterface? PUBLIC | DEFAULT : PRIVATE); 77.1306 + 77.1307 + //compute synthetic params 77.1308 + ListBuffer<JCVariableDecl> params = ListBuffer.lb(); 77.1309 + 77.1310 + // The signature of the method is augmented with the following 77.1311 + // synthetic parameters: 77.1312 + // 77.1313 + // 1) reference to enclosing contexts captured by the lambda expression 77.1314 + // 2) enclosing locals captured by the lambda expression 77.1315 + for (Symbol thisSym : getSymbolMap(CAPTURED_VAR, PARAM).values()) { 77.1316 + params.append(make.VarDef((VarSymbol) thisSym, null)); 77.1317 + } 77.1318 + 77.1319 + syntheticParams = params.toList(); 77.1320 + 77.1321 + //prepend synthetic args to translated lambda method signature 77.1322 + translatedSym.type = (MethodType) types.createMethodTypeWithParameters( 77.1323 + (MethodType) generatedLambdaSig(), 77.1324 + TreeInfo.types(syntheticParams)); 77.1325 + } 77.1326 + 77.1327 + Type enclosingType() { 77.1328 + //local inner classes defined inside a lambda are always non-static 77.1329 + return owner.enclClass().type; 77.1330 + } 77.1331 + 77.1332 + Type generatedLambdaSig() { 77.1333 + return types.erasure(types.findDescriptorType(tree.targetType)); 77.1334 + } 77.1335 + } 77.1336 + 77.1337 + /** 77.1338 + * This class retains all the useful information about a method reference; 77.1339 + * the contents of this class are filled by the LambdaAnalyzer visitor, 77.1340 + * and the used by the main translation routines in order to adjust method 77.1341 + * references (i.e. in case a bridge is needed) 77.1342 + */ 77.1343 + private class ReferenceTranslationContext extends TranslationContext<JCMemberReference> { 77.1344 + 77.1345 + final boolean isSuper; 77.1346 + final Symbol bridgeSym; 77.1347 + 77.1348 + ReferenceTranslationContext(JCMemberReference tree) { 77.1349 + super(tree); 77.1350 + this.isSuper = tree.hasKind(ReferenceKind.SUPER); 77.1351 + this.bridgeSym = needsBridge() 77.1352 + ? makeSyntheticMethod(isSuper ? 0 : STATIC, 77.1353 + lambdaName().append(names.fromString("$bridge")), null, 77.1354 + owner.enclClass()) 77.1355 + : null; 77.1356 + } 77.1357 + 77.1358 + /** 77.1359 + * Get the opcode associated with this method reference 77.1360 + */ 77.1361 + int referenceKind() { 77.1362 + return LambdaToMethod.this.referenceKind(needsBridge() ? bridgeSym : tree.sym); 77.1363 + } 77.1364 + 77.1365 + boolean needsVarArgsConversion() { 77.1366 + return tree.varargsElement != null; 77.1367 + } 77.1368 + 77.1369 + /** 77.1370 + * @return Is this an array operation like clone() 77.1371 + */ 77.1372 + boolean isArrayOp() { 77.1373 + return tree.sym.owner == syms.arrayClass; 77.1374 + } 77.1375 + 77.1376 + /** 77.1377 + * Does this reference needs a bridge (i.e. var args need to be 77.1378 + * expanded or "super" is used) 77.1379 + */ 77.1380 + final boolean needsBridge() { 77.1381 + return isSuper || needsVarArgsConversion() || isArrayOp(); 77.1382 + } 77.1383 + 77.1384 + Type generatedRefSig() { 77.1385 + return types.erasure(tree.sym.type); 77.1386 + } 77.1387 + 77.1388 + Type bridgedRefSig() { 77.1389 + return types.erasure(types.findDescriptorSymbol(tree.targetType.tsym).type); 77.1390 + } 77.1391 + } 77.1392 + } 77.1393 + // </editor-fold> 77.1394 + 77.1395 + enum LambdaSymbolKind { 77.1396 + CAPTURED_VAR, 77.1397 + CAPTURED_THIS, 77.1398 + LOCAL_VAR, 77.1399 + PARAM; 77.1400 + } 77.1401 +}
78.1 --- a/src/share/classes/com/sun/tools/javac/comp/Lower.java Thu Nov 01 14:13:13 2012 -0700 78.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Lower.java Fri Nov 02 17:55:34 2012 -0700 78.3 @@ -45,7 +45,7 @@ 78.4 import static com.sun.tools.javac.code.Flags.*; 78.5 import static com.sun.tools.javac.code.Flags.BLOCK; 78.6 import static com.sun.tools.javac.code.Kinds.*; 78.7 -import static com.sun.tools.javac.code.TypeTags.*; 78.8 +import static com.sun.tools.javac.code.TypeTag.*; 78.9 import static com.sun.tools.javac.jvm.ByteCodes.*; 78.10 import static com.sun.tools.javac.tree.JCTree.Tag.*; 78.11 78.12 @@ -485,7 +485,7 @@ 78.13 * @param value The literal's value. 78.14 */ 78.15 JCExpression makeLit(Type type, Object value) { 78.16 - return make.Literal(type.tag, value).setType(type.constType(value)); 78.17 + return make.Literal(type.getTag(), value).setType(type.constType(value)); 78.18 } 78.19 78.20 /** Make an attributed tree representing null. 78.21 @@ -549,7 +549,7 @@ 78.22 * reference type.. 78.23 */ 78.24 JCExpression makeString(JCExpression tree) { 78.25 - if (tree.type.tag >= CLASS) { 78.26 + if (!tree.type.isPrimitiveOrVoid()) { 78.27 return tree; 78.28 } else { 78.29 Symbol valueOfSym = lookupMethod(tree.pos(), 78.30 @@ -1405,7 +1405,7 @@ 78.31 Name outerThisName(Type type, Symbol owner) { 78.32 Type t = type.getEnclosingType(); 78.33 int nestingLevel = 0; 78.34 - while (t.tag == CLASS) { 78.35 + while (t.hasTag(CLASS)) { 78.36 t = t.getEnclosingType(); 78.37 nestingLevel++; 78.38 } 78.39 @@ -1529,7 +1529,7 @@ 78.40 new VarSymbol(SYNTHETIC | FINAL, 78.41 makeSyntheticName(names.fromString("twrVar" + 78.42 depth), twrVars), 78.43 - (resource.type.tag == TypeTags.BOT) ? 78.44 + (resource.type.hasTag(BOT)) ? 78.45 syms.autoCloseableType : resource.type, 78.46 currentMethodSym); 78.47 twrVars.enter(syntheticTwrVar); 78.48 @@ -1992,7 +1992,7 @@ 78.49 } 78.50 78.51 private JCExpression classOfType(Type type, DiagnosticPosition pos) { 78.52 - switch (type.tag) { 78.53 + switch (type.getTag()) { 78.54 case BYTE: case SHORT: case CHAR: case INT: case LONG: case FLOAT: 78.55 case DOUBLE: case BOOLEAN: case VOID: 78.56 // replace with <BoxedClass>.TYPE 78.57 @@ -2761,7 +2761,7 @@ 78.58 } 78.59 //where 78.60 private JCTree convert(JCTree tree, Type pt) { 78.61 - if (tree.type == pt || tree.type.tag == TypeTags.BOT) 78.62 + if (tree.type == pt || tree.type.hasTag(BOT)) 78.63 return tree; 78.64 JCTree result = make_at(tree.pos()).TypeCast(make.Type(pt), (JCExpression)tree); 78.65 result.type = (tree.type.constValue() != null) ? cfolder.coerce(tree.type, pt) 78.66 @@ -2934,7 +2934,7 @@ 78.67 return tree; 78.68 if (havePrimitive) { 78.69 Type unboxedTarget = types.unboxedType(type); 78.70 - if (unboxedTarget.tag != NONE) { 78.71 + if (!unboxedTarget.hasTag(NONE)) { 78.72 if (!types.isSubtype(tree.type, unboxedTarget)) //e.g. Character c = 89; 78.73 tree.type = unboxedTarget.constType(tree.type.constValue()); 78.74 return (T)boxPrimitive((JCExpression)tree, type); 78.75 @@ -2974,7 +2974,7 @@ 78.76 /** Unbox an object to a primitive value. */ 78.77 JCExpression unbox(JCExpression tree, Type primitive) { 78.78 Type unboxedType = types.unboxedType(tree.type); 78.79 - if (unboxedType.tag == NONE) { 78.80 + if (unboxedType.hasTag(NONE)) { 78.81 unboxedType = primitive; 78.82 if (!unboxedType.isPrimitive()) 78.83 throw new AssertionError(unboxedType); 78.84 @@ -3292,7 +3292,7 @@ 78.85 iteratorTarget = types.erasure(iterableType.getTypeArguments().head); 78.86 Type eType = tree.expr.type; 78.87 tree.expr.type = types.erasure(eType); 78.88 - if (eType.tag == TYPEVAR && eType.getUpperBound().isCompound()) 78.89 + if (eType.hasTag(TYPEVAR) && eType.getUpperBound().isCompound()) 78.90 tree.expr = make.TypeCast(types.erasure(iterableType), tree.expr); 78.91 Symbol iterator = lookupMethod(tree.expr.pos(), 78.92 names.iterator,
79.1 --- a/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java Thu Nov 01 14:13:13 2012 -0700 79.2 +++ b/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java Fri Nov 02 17:55:34 2012 -0700 79.3 @@ -42,7 +42,9 @@ 79.4 import static com.sun.tools.javac.code.Flags.*; 79.5 import static com.sun.tools.javac.code.Flags.ANNOTATION; 79.6 import static com.sun.tools.javac.code.Kinds.*; 79.7 -import static com.sun.tools.javac.code.TypeTags.*; 79.8 +import static com.sun.tools.javac.code.TypeTag.CLASS; 79.9 +import static com.sun.tools.javac.code.TypeTag.ERROR; 79.10 +import static com.sun.tools.javac.code.TypeTag.TYPEVAR; 79.11 import static com.sun.tools.javac.tree.JCTree.Tag.*; 79.12 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag; 79.13 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; 79.14 @@ -370,7 +372,7 @@ 79.15 ListBuffer<Type> thrownbuf = new ListBuffer<Type>(); 79.16 for (List<JCExpression> l = thrown; l.nonEmpty(); l = l.tail) { 79.17 Type exc = attr.attribType(l.head, env); 79.18 - if (exc.tag != TYPEVAR) 79.19 + if (!exc.hasTag(TYPEVAR)) 79.20 exc = chk.checkClassType(l.head.pos(), exc); 79.21 thrownbuf.append(exc); 79.22 } 79.23 @@ -921,7 +923,7 @@ 79.24 } 79.25 for (JCExpression iface : interfaceTrees) { 79.26 Type i = attr.attribBase(iface, baseEnv, false, true, true); 79.27 - if (i.tag == CLASS) { 79.28 + if (i.hasTag(CLASS)) { 79.29 interfaces.append(i); 79.30 if (all_interfaces != null) all_interfaces.append(i); 79.31 chk.checkNotRepeated(iface.pos(), types.erasure(i), interfaceSet); 79.32 @@ -1006,7 +1008,7 @@ 79.33 new VarSymbol(FINAL | HASINIT, names._this, c.type, c); 79.34 thisSym.pos = Position.FIRSTPOS; 79.35 env.info.scope.enter(thisSym); 79.36 - if (ct.supertype_field.tag == CLASS) { 79.37 + if (ct.supertype_field.hasTag(CLASS)) { 79.38 VarSymbol superSym = 79.39 new VarSymbol(FINAL | HASINIT, names._super, 79.40 ct.supertype_field, c); 79.41 @@ -1020,11 +1022,13 @@ 79.42 // name as a top-level package. 79.43 if (checkClash && 79.44 c.owner.kind == PCK && c.owner != syms.unnamedPackage && 79.45 - reader.packageExists(c.fullname)) 79.46 - { 79.47 - log.error(tree.pos, "clash.with.pkg.of.same.name", Kinds.kindName(sym), c); 79.48 - } 79.49 - 79.50 + reader.packageExists(c.fullname)) { 79.51 + log.error(tree.pos, "clash.with.pkg.of.same.name", Kinds.kindName(sym), c); 79.52 + } 79.53 + if (c.owner.kind == PCK && (c.flags_field & PUBLIC) == 0 && 79.54 + !env.toplevel.sourcefile.isNameCompatible(c.name.toString(),JavaFileObject.Kind.SOURCE)) { 79.55 + c.flags_field |= AUXILIARY; 79.56 + } 79.57 } catch (CompletionFailure ex) { 79.58 chk.completionError(tree.pos(), ex); 79.59 } finally { 79.60 @@ -1094,7 +1098,7 @@ 79.61 } 79.62 79.63 Type modelMissingTypes(Type t, final JCExpression tree, final boolean interfaceExpected) { 79.64 - if (t.tag != ERROR) 79.65 + if (!t.hasTag(ERROR)) 79.66 return t; 79.67 79.68 return new ErrorType(((ErrorType) t).getOriginalType(), t.tsym) { 79.69 @@ -1139,7 +1143,7 @@ 79.70 79.71 @Override 79.72 public void visitIdent(JCIdent tree) { 79.73 - if (tree.type.tag != ERROR) { 79.74 + if (!tree.type.hasTag(ERROR)) { 79.75 result = tree.type; 79.76 } else { 79.77 result = synthesizeClass(tree.name, syms.unnamedPackage).type; 79.78 @@ -1148,7 +1152,7 @@ 79.79 79.80 @Override 79.81 public void visitSelect(JCFieldAccess tree) { 79.82 - if (tree.type.tag != ERROR) { 79.83 + if (!tree.type.hasTag(ERROR)) { 79.84 result = tree.type; 79.85 } else { 79.86 Type selectedType; 79.87 @@ -1166,7 +1170,7 @@ 79.88 79.89 @Override 79.90 public void visitTypeApply(JCTypeApply tree) { 79.91 - if (tree.type.tag != ERROR) { 79.92 + if (!tree.type.hasTag(ERROR)) { 79.93 result = tree.type; 79.94 } else { 79.95 ClassType clazzType = (ClassType) visit(tree.clazz);
80.1 --- a/src/share/classes/com/sun/tools/javac/comp/Resolve.java Thu Nov 01 14:13:13 2012 -0700 80.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java Fri Nov 02 17:55:34 2012 -0700 80.3 @@ -59,7 +59,7 @@ 80.4 import static com.sun.tools.javac.code.Flags.BLOCK; 80.5 import static com.sun.tools.javac.code.Kinds.*; 80.6 import static com.sun.tools.javac.code.Kinds.ERRONEOUS; 80.7 -import static com.sun.tools.javac.code.TypeTags.*; 80.8 +import static com.sun.tools.javac.code.TypeTag.*; 80.9 import static com.sun.tools.javac.comp.Resolve.MethodResolutionPhase.*; 80.10 import static com.sun.tools.javac.tree.JCTree.Tag.*; 80.11 80.12 @@ -228,7 +228,7 @@ 80.13 80.14 JCDiagnostic getVerboseApplicableCandidateDiag(int pos, Symbol sym, Type inst) { 80.15 JCDiagnostic subDiag = null; 80.16 - if (sym.type.tag == FORALL) { 80.17 + if (sym.type.hasTag(FORALL)) { 80.18 subDiag = diags.fragment("partial.inst.sig", inst); 80.19 } 80.20 80.21 @@ -331,7 +331,7 @@ 80.22 } 80.23 80.24 boolean isAccessible(Env<AttrContext> env, Type t, boolean checkInner) { 80.25 - return (t.tag == ARRAY) 80.26 + return (t.hasTag(ARRAY)) 80.27 ? isAccessible(env, types.elemtype(t)) 80.28 : isAccessible(env, t.tsym, checkInner); 80.29 } 80.30 @@ -467,10 +467,10 @@ 80.31 // need to inferred. 80.32 List<Type> tvars = List.nil(); 80.33 if (typeargtypes == null) typeargtypes = List.nil(); 80.34 - if (mt.tag != FORALL && typeargtypes.nonEmpty()) { 80.35 + if (!mt.hasTag(FORALL) && typeargtypes.nonEmpty()) { 80.36 // This is not a polymorphic method, but typeargs are supplied 80.37 // which is fine, see JLS 15.12.2.1 80.38 - } else if (mt.tag == FORALL && typeargtypes.nonEmpty()) { 80.39 + } else if (mt.hasTag(FORALL) && typeargtypes.nonEmpty()) { 80.40 ForAll pmt = (ForAll) mt; 80.41 if (typeargtypes.length() != pmt.tvars.length()) 80.42 throw inapplicableMethodException.setMessage("arg.length.mismatch"); // not enough args 80.43 @@ -487,7 +487,7 @@ 80.44 actuals = actuals.tail; 80.45 } 80.46 mt = types.subst(pmt.qtype, pmt.tvars, typeargtypes); 80.47 - } else if (mt.tag == FORALL) { 80.48 + } else if (mt.hasTag(FORALL)) { 80.49 ForAll pmt = (ForAll) mt; 80.50 List<Type> tvars1 = types.newInstances(pmt.tvars); 80.51 tvars = tvars.appendList(tvars1); 80.52 @@ -499,7 +499,7 @@ 80.53 for (List<Type> l = argtypes; 80.54 l.tail != null/*inlined: l.nonEmpty()*/ && !instNeeded; 80.55 l = l.tail) { 80.56 - if (l.head.tag == FORALL) instNeeded = true; 80.57 + if (l.head.hasTag(FORALL)) instNeeded = true; 80.58 } 80.59 80.60 if (instNeeded) 80.61 @@ -807,7 +807,7 @@ 80.62 80.63 @Override 80.64 protected Type check(DiagnosticPosition pos, Type found) { 80.65 - if (found.tag == DEFERRED) { 80.66 + if (found.hasTag(DEFERRED)) { 80.67 DeferredType dt = (DeferredType)found; 80.68 return dt.check(this); 80.69 } else { 80.70 @@ -875,7 +875,7 @@ 80.71 Type site, 80.72 Name name, 80.73 TypeSymbol c) { 80.74 - while (c.type.tag == TYPEVAR) 80.75 + while (c.type.hasTag(TYPEVAR)) 80.76 c = c.type.getUpperBound().tsym; 80.77 Symbol bestSoFar = varNotFound; 80.78 Symbol sym; 80.79 @@ -888,7 +888,7 @@ 80.80 e = e.next(); 80.81 } 80.82 Type st = types.supertype(c.type); 80.83 - if (st != null && (st.tag == CLASS || st.tag == TYPEVAR)) { 80.84 + if (st != null && (st.hasTag(CLASS) || st.hasTag(TYPEVAR))) { 80.85 sym = findField(env, site, name, st.tsym); 80.86 if (sym.kind < bestSoFar.kind) bestSoFar = sym; 80.87 } 80.88 @@ -1184,7 +1184,7 @@ 80.89 lastFormal2 : formals2.head; 80.90 80.91 //is this a structural actual argument? 80.92 - boolean isStructuralPoly = actual.tag == DEFERRED && 80.93 + boolean isStructuralPoly = actual.hasTag(DEFERRED) && 80.94 (((DeferredType)actual).tree.hasTag(LAMBDA) || 80.95 ((DeferredType)actual).tree.hasTag(REFERENCE)); 80.96 80.97 @@ -1301,7 +1301,7 @@ 80.98 Type rt1 = mt1.getReturnType(); 80.99 Type rt2 = mt2.getReturnType(); 80.100 80.101 - if (mt1.tag == FORALL && mt2.tag == FORALL) { 80.102 + if (mt1.hasTag(FORALL) && mt2.hasTag(FORALL)) { 80.103 //if both are generic methods, adjust return type ahead of subtyping check 80.104 rt1 = types.subst(rt1, mt1.getTypeArguments(), mt2.getTypeArguments()); 80.105 } 80.106 @@ -1448,11 +1448,11 @@ 80.107 } 80.108 80.109 TypeSymbol symbolFor(Type t) { 80.110 - if (t.tag != CLASS && 80.111 - t.tag != TYPEVAR) { 80.112 + if (!t.hasTag(CLASS) && 80.113 + !t.hasTag(TYPEVAR)) { 80.114 return null; 80.115 } 80.116 - while (t.tag == TYPEVAR) 80.117 + while (t.hasTag(TYPEVAR)) 80.118 t = t.getUpperBound(); 80.119 if (seen.contains(t.tsym)) { 80.120 //degenerate case in which we have a circular 80.121 @@ -1610,7 +1610,7 @@ 80.122 e = e.next(); 80.123 } 80.124 Type st = types.supertype(c.type); 80.125 - if (st != null && st.tag == CLASS) { 80.126 + if (st != null && st.hasTag(CLASS)) { 80.127 sym = findMemberType(env, site, name, st.tsym); 80.128 if (sym.kind < bestSoFar.kind) bestSoFar = sym; 80.129 } 80.130 @@ -1660,7 +1660,7 @@ 80.131 e = e.next()) { 80.132 if (e.sym.kind == TYP) { 80.133 if (staticOnly && 80.134 - e.sym.type.tag == TYPEVAR && 80.135 + e.sym.type.hasTag(TYPEVAR) && 80.136 e.sym.owner.kind == TYP) return new StaticError(e.sym); 80.137 return e.sym; 80.138 } 80.139 @@ -1669,8 +1669,8 @@ 80.140 sym = findMemberType(env1, env1.enclClass.sym.type, name, 80.141 env1.enclClass.sym); 80.142 if (staticOnly && sym.kind == TYP && 80.143 - sym.type.tag == CLASS && 80.144 - sym.type.getEnclosingType().tag == CLASS && 80.145 + sym.type.hasTag(CLASS) && 80.146 + sym.type.getEnclosingType().hasTag(CLASS) && 80.147 env1.enclClass.sym.type.isParameterized() && 80.148 sym.type.getEnclosingType().isParameterized()) 80.149 return new StaticError(sym); 80.150 @@ -1906,7 +1906,7 @@ 80.151 //method symbol that can be used for lookups in the speculative cache, 80.152 //causing problems in Attr.checkId() 80.153 for (Type t : argtypes) { 80.154 - if (t.tag == DEFERRED) { 80.155 + if (t.hasTag(DEFERRED)) { 80.156 DeferredType dt = (DeferredType)t; 80.157 dt.speculativeCache.dupAllTo(msym, accessedSym); 80.158 } 80.159 @@ -1955,7 +1955,7 @@ 80.160 } 80.161 80.162 public void printscopes(Type t) { 80.163 - while (t.tag == CLASS) { 80.164 + while (t.hasTag(CLASS)) { 80.165 printscopes(t.tsym.members()); 80.166 t = types.supertype(t); 80.167 } 80.168 @@ -2259,7 +2259,7 @@ 80.169 //- System.out.println(" e " + e.sym); 80.170 if (sym.kind == MTH && 80.171 (sym.flags_field & SYNTHETIC) == 0) { 80.172 - List<Type> oldParams = e.sym.type.tag == FORALL ? 80.173 + List<Type> oldParams = e.sym.type.hasTag(FORALL) ? 80.174 ((ForAll)sym.type).tvars : 80.175 List.<Type>nil(); 80.176 Type constrType = new ForAll(site.tsym.type.getTypeArguments().appendList(oldParams), 80.177 @@ -2565,7 +2565,7 @@ 80.178 findMethod(env, site, name, argtypes, typeargtypes, 80.179 phase.isBoxingRequired(), phase.isVarargsRequired(), syms.operatorNames.contains(name)); 80.180 return sym.kind != MTH || 80.181 - site.getEnclosingType().tag == NONE || 80.182 + site.getEnclosingType().hasTag(NONE) || 80.183 hasEnclosingInstance(env, site) ? 80.184 sym : new InvalidSymbolError(Kinds.MISSING_ENCL, sym, null) { 80.185 @Override 80.186 @@ -2578,7 +2578,7 @@ 80.187 80.188 @Override 80.189 ReferenceKind referenceKind(Symbol sym) { 80.190 - return site.getEnclosingType().tag == NONE ? 80.191 + return site.getEnclosingType().hasTag(NONE) ? 80.192 ReferenceKind.TOPLEVEL : ReferenceKind.IMPLICIT_INNER; 80.193 } 80.194 } 80.195 @@ -2847,7 +2847,7 @@ 80.196 } else { 80.197 ListBuffer<Object> diagArgs = ListBuffer.lb(); 80.198 for (Type t : argtypes) { 80.199 - if (t.tag == DEFERRED) { 80.200 + if (t.hasTag(DEFERRED)) { 80.201 diagArgs.append(((DeferredAttr.DeferredType)t).tree); 80.202 } else { 80.203 diagArgs.append(t); 80.204 @@ -3222,7 +3222,7 @@ 80.205 Name name, 80.206 List<Type> argtypes, 80.207 List<Type> typeargtypes) { 80.208 - if (sym.owner.type.tag == ERROR) 80.209 + if (sym.owner.type.hasTag(ERROR)) 80.210 return null; 80.211 80.212 if (sym.name == names.init && sym.owner != site.tsym) { 80.213 @@ -3267,7 +3267,7 @@ 80.214 Name name, 80.215 List<Type> argtypes, 80.216 List<Type> typeargtypes) { 80.217 - Symbol errSym = ((sym.kind == TYP && sym.type.tag == CLASS) 80.218 + Symbol errSym = ((sym.kind == TYP && sym.type.hasTag(CLASS)) 80.219 ? types.erasure(sym.type).tsym 80.220 : sym); 80.221 return diags.create(dkind, log.currentSource(), pos,
81.1 --- a/src/share/classes/com/sun/tools/javac/comp/TransTypes.java Thu Nov 01 14:13:13 2012 -0700 81.2 +++ b/src/share/classes/com/sun/tools/javac/comp/TransTypes.java Fri Nov 02 17:55:34 2012 -0700 81.3 @@ -37,7 +37,9 @@ 81.4 81.5 import static com.sun.tools.javac.code.Flags.*; 81.6 import static com.sun.tools.javac.code.Kinds.*; 81.7 -import static com.sun.tools.javac.code.TypeTags.*; 81.8 +import static com.sun.tools.javac.code.TypeTag.CLASS; 81.9 +import static com.sun.tools.javac.code.TypeTag.TYPEVAR; 81.10 +import static com.sun.tools.javac.code.TypeTag.VOID; 81.11 81.12 /** This pass translates Generic Java to conventional Java. 81.13 * 81.14 @@ -118,6 +120,16 @@ 81.15 * @param tree The expression tree. 81.16 * @param target The target type. 81.17 */ 81.18 + public JCExpression coerce(Env<AttrContext> env, JCExpression tree, Type target) { 81.19 + Env<AttrContext> prevEnv = this.env; 81.20 + try { 81.21 + this.env = env; 81.22 + return coerce(tree, target); 81.23 + } 81.24 + finally { 81.25 + this.env = prevEnv; 81.26 + } 81.27 + } 81.28 JCExpression coerce(JCExpression tree, Type target) { 81.29 Type btarget = target.baseType(); 81.30 if (tree.type.isPrimitive() == target.isPrimitive()) { 81.31 @@ -155,7 +167,7 @@ 81.32 */ 81.33 JCExpression retype(JCExpression tree, Type erasedType, Type target) { 81.34 // System.err.println("retype " + tree + " to " + erasedType);//DEBUG 81.35 - if (erasedType.tag > lastBaseTag) { 81.36 + if (!erasedType.isPrimitive()) { 81.37 if (target != null && target.isPrimitive()) 81.38 target = erasure(tree.type); 81.39 tree.type = erasedType; 81.40 @@ -194,6 +206,20 @@ 81.41 return _args; 81.42 } 81.43 81.44 + public <T extends JCTree> List<T> translateArgs(List<T> _args, 81.45 + List<Type> parameters, 81.46 + Type varargsElement, 81.47 + Env<AttrContext> localEnv) { 81.48 + Env<AttrContext> prevEnv = env; 81.49 + try { 81.50 + env = localEnv; 81.51 + return translateArgs(_args, parameters, varargsElement); 81.52 + } 81.53 + finally { 81.54 + env = prevEnv; 81.55 + } 81.56 + } 81.57 + 81.58 /** Add a bridge definition and enter corresponding method symbol in 81.59 * local scope of origin. 81.60 * 81.61 @@ -245,7 +271,7 @@ 81.62 make.Select(receiver, impl).setType(calltype), 81.63 translateArgs(make.Idents(md.params), origErasure.getParameterTypes(), null)) 81.64 .setType(calltype); 81.65 - JCStatement stat = (origErasure.getReturnType().tag == VOID) 81.66 + JCStatement stat = (origErasure.getReturnType().hasTag(VOID)) 81.67 ? make.Exec(call) 81.68 : make.Return(coerce(call, bridgeType.getReturnType())); 81.69 md.body = make.Block(0, List.of(stat)); 81.70 @@ -400,7 +426,7 @@ 81.71 */ 81.72 void addBridges(DiagnosticPosition pos, ClassSymbol origin, ListBuffer<JCTree> bridges) { 81.73 Type st = types.supertype(origin.type); 81.74 - while (st.tag == CLASS) { 81.75 + while (st.hasTag(CLASS)) { 81.76 // if (isSpecialization(st)) 81.77 addBridges(pos, st.tsym, origin, bridges); 81.78 st = types.supertype(st); 81.79 @@ -449,9 +475,9 @@ 81.80 result = tree; 81.81 } 81.82 81.83 - JCMethodDecl currentMethod = null; 81.84 + JCTree currentMethod = null; 81.85 public void visitMethodDef(JCMethodDecl tree) { 81.86 - JCMethodDecl previousMethod = currentMethod; 81.87 + JCTree previousMethod = currentMethod; 81.88 try { 81.89 currentMethod = tree; 81.90 tree.restype = translate(tree.restype, null); 81.91 @@ -517,6 +543,22 @@ 81.92 result = tree; 81.93 } 81.94 81.95 + public void visitLambda(JCLambda tree) { 81.96 + JCTree prevMethod = currentMethod; 81.97 + try { 81.98 + currentMethod = null; 81.99 + tree.params = translate(tree.params); 81.100 + tree.body = translate(tree.body, null); 81.101 + //save non-erased target 81.102 + tree.targetType = tree.type; 81.103 + tree.type = erasure(tree.type); 81.104 + result = tree; 81.105 + } 81.106 + finally { 81.107 + currentMethod = prevMethod; 81.108 + } 81.109 + } 81.110 + 81.111 public void visitSwitch(JCSwitch tree) { 81.112 Type selsuper = types.supertype(tree.selector.type); 81.113 boolean enumSwitch = selsuper != null && 81.114 @@ -568,7 +610,7 @@ 81.115 } 81.116 81.117 public void visitReturn(JCReturn tree) { 81.118 - tree.expr = translate(tree.expr, currentMethod.sym.erasure(types).getReturnType()); 81.119 + tree.expr = translate(tree.expr, currentMethod != null ? types.erasure(currentMethod.type).getReturnType() : null); 81.120 result = tree; 81.121 } 81.122 81.123 @@ -599,6 +641,7 @@ 81.124 Assert.check(tree.args.length() == argtypes.length()); 81.125 tree.args = translateArgs(tree.args, argtypes, tree.varargsElement); 81.126 81.127 + tree.type = types.erasure(tree.type); 81.128 // Insert casts of method invocation results as needed. 81.129 result = retype(tree, mt.getReturnType(), pt); 81.130 } 81.131 @@ -612,6 +655,8 @@ 81.132 tree.args = translateArgs( 81.133 tree.args, tree.constructor.erasure(types).getParameterTypes(), tree.varargsElement); 81.134 tree.def = translate(tree.def, null); 81.135 + if (tree.constructorType != null) 81.136 + tree.constructorType = erasure(tree.constructorType); 81.137 tree.type = erasure(tree.type); 81.138 result = tree; 81.139 } 81.140 @@ -629,16 +674,6 @@ 81.141 result = tree; 81.142 } 81.143 81.144 - @Override 81.145 - public void visitLambda(JCLambda tree) { 81.146 - Assert.error("Translation of lambda expression not supported yet"); 81.147 - } 81.148 - 81.149 - @Override 81.150 - public void visitReference(JCMemberReference tree) { 81.151 - Assert.error("Translation of method reference not supported yet"); 81.152 - } 81.153 - 81.154 public void visitParens(JCParens tree) { 81.155 tree.expr = translate(tree.expr, pt); 81.156 tree.type = erasure(tree.type); 81.157 @@ -701,7 +736,7 @@ 81.158 Type et = tree.sym.erasure(types); 81.159 81.160 // Map type variables to their bounds. 81.161 - if (tree.sym.kind == TYP && tree.sym.type.tag == TYPEVAR) { 81.162 + if (tree.sym.kind == TYP && tree.sym.type.hasTag(TYPEVAR)) { 81.163 result = make.at(tree.pos).Type(et); 81.164 } else 81.165 // Map constants expressions to themselves. 81.166 @@ -720,7 +755,7 @@ 81.167 81.168 public void visitSelect(JCFieldAccess tree) { 81.169 Type t = tree.selected.type; 81.170 - while (t.tag == TYPEVAR) 81.171 + while (t.hasTag(TYPEVAR)) 81.172 t = t.getUpperBound(); 81.173 if (t.isCompound()) { 81.174 if ((tree.sym.flags() & IPROXY) != 0) { 81.175 @@ -747,6 +782,14 @@ 81.176 } 81.177 } 81.178 81.179 + public void visitReference(JCMemberReference tree) { 81.180 + tree.expr = translate(tree.expr, null); 81.181 + //save non-erased target 81.182 + tree.targetType = tree.type; 81.183 + tree.type = erasure(tree.type); 81.184 + result = tree; 81.185 + } 81.186 + 81.187 public void visitTypeArray(JCArrayTypeTree tree) { 81.188 tree.elemtype = translate(tree.elemtype, null); 81.189 tree.type = erasure(tree.type); 81.190 @@ -844,7 +887,7 @@ 81.191 translateArgs(make.Idents(md.params), 81.192 implErasure.getParameterTypes(), null)) 81.193 .setType(calltype); 81.194 - JCStatement stat = (member.getReturnType().tag == VOID) 81.195 + JCStatement stat = (member.getReturnType().hasTag(VOID)) 81.196 ? make.Exec(call) 81.197 : make.Return(coerce(call, member.erasure(types).getReturnType())); 81.198 md.body = make.Block(0, List.of(stat)); 81.199 @@ -862,7 +905,7 @@ 81.200 Type st = types.supertype(c.type); 81.201 81.202 // process superclass before derived 81.203 - if (st.tag == CLASS) 81.204 + if (st.hasTag(CLASS)) 81.205 translateClass((ClassSymbol)st.tsym); 81.206 81.207 Env<AttrContext> myEnv = enter.typeEnvs.remove(c);
82.1 --- a/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java Thu Nov 01 14:13:13 2012 -0700 82.2 +++ b/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java Fri Nov 02 17:55:34 2012 -0700 82.3 @@ -90,7 +90,7 @@ 82.4 EnumSet.of(JavaFileObject.Kind.SOURCE, JavaFileObject.Kind.CLASS); 82.5 82.6 protected boolean mmappedIO; 82.7 - protected boolean ignoreSymbolFile; 82.8 + protected boolean symbolFileEnabled; 82.9 82.10 protected enum SortFiles implements Comparator<File> { 82.11 FORWARD { 82.12 @@ -142,7 +142,7 @@ 82.13 zipFileIndexCache = ZipFileIndexCache.getSharedInstance(); 82.14 82.15 mmappedIO = options.isSet("mmappedIO"); 82.16 - ignoreSymbolFile = options.isSet("ignore.symbol.file"); 82.17 + symbolFileEnabled = !options.isSet("ignore.symbol.file"); 82.18 82.19 String sf = options.get("sortFiles"); 82.20 if (sf != null) { 82.21 @@ -150,6 +150,13 @@ 82.22 } 82.23 } 82.24 82.25 + /** 82.26 + * Set whether or not to use ct.sym as an alternate to rt.jar. 82.27 + */ 82.28 + public void setSymbolFileEnabled(boolean b) { 82.29 + symbolFileEnabled = b; 82.30 + } 82.31 + 82.32 @Override 82.33 public boolean isDefaultBootClassPath() { 82.34 return locations.isDefaultBootClassPath(); 82.35 @@ -466,7 +473,7 @@ 82.36 */ 82.37 private Archive openArchive(File zipFileName, boolean useOptimizedZip) throws IOException { 82.38 File origZipFileName = zipFileName; 82.39 - if (!ignoreSymbolFile && locations.isDefaultBootClassPathRtJar(zipFileName)) { 82.40 + if (symbolFileEnabled && locations.isDefaultBootClassPathRtJar(zipFileName)) { 82.41 File file = zipFileName.getParentFile().getParentFile(); // ${java.home} 82.42 if (new File(file.getName()).equals(new File("jre"))) 82.43 file = file.getParentFile();
83.1 --- a/src/share/classes/com/sun/tools/javac/file/Locations.java Thu Nov 01 14:13:13 2012 -0700 83.2 +++ b/src/share/classes/com/sun/tools/javac/file/Locations.java Fri Nov 02 17:55:34 2012 -0700 83.3 @@ -420,14 +420,10 @@ 83.4 if (!options.contains(option)) 83.5 return false; 83.6 searchPath = value == null ? null : 83.7 - Collections.unmodifiableCollection(computePath(value)); 83.8 + Collections.unmodifiableCollection(createPath().addFiles(value)); 83.9 return true; 83.10 } 83.11 83.12 - protected Path computePath(String value) { 83.13 - return new Path().addFiles(value); 83.14 - } 83.15 - 83.16 @Override 83.17 Collection<File> getLocation() { 83.18 return searchPath; 83.19 @@ -439,10 +435,18 @@ 83.20 if (files == null) { 83.21 p = computePath(null); 83.22 } else { 83.23 - p = new Path().addFiles(files); 83.24 + p = createPath().addFiles(files); 83.25 } 83.26 searchPath = Collections.unmodifiableCollection(p); 83.27 } 83.28 + 83.29 + protected Path computePath(String value) { 83.30 + return createPath().addFiles(value); 83.31 + } 83.32 + 83.33 + protected Path createPath() { 83.34 + return new Path(); 83.35 + } 83.36 } 83.37 83.38 /** 83.39 @@ -477,11 +481,15 @@ 83.40 // Default to current working directory. 83.41 if (cp == null) cp = "."; 83.42 83.43 + return createPath().addFiles(cp); 83.44 + } 83.45 + 83.46 + @Override 83.47 + protected Path createPath() { 83.48 return new Path() 83.49 - .expandJarClassPaths(true) // Only search user jars for Class-Paths 83.50 - .emptyPathDefault(new File(".")) // Empty path elt ==> current directory 83.51 - .addFiles(cp); 83.52 - } 83.53 + .expandJarClassPaths(true) // Only search user jars for Class-Paths 83.54 + .emptyPathDefault(new File(".")); // Empty path elt ==> current directory 83.55 + } 83.56 83.57 private void lazy() { 83.58 if (searchPath == null) 83.59 @@ -591,7 +599,6 @@ 83.60 String extdirsOpt = optionValues.get(EXTDIRS); 83.61 String xbootclasspathPrependOpt = optionValues.get(XBOOTCLASSPATH_PREPEND); 83.62 String xbootclasspathAppendOpt = optionValues.get(XBOOTCLASSPATH_APPEND); 83.63 - 83.64 path.addFiles(xbootclasspathPrependOpt); 83.65 83.66 if (endorseddirsOpt != null)
84.1 --- a/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java Thu Nov 01 14:13:13 2012 -0700 84.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java Fri Nov 02 17:55:34 2012 -0700 84.3 @@ -55,7 +55,7 @@ 84.4 84.5 import static com.sun.tools.javac.code.Flags.*; 84.6 import static com.sun.tools.javac.code.Kinds.*; 84.7 -import static com.sun.tools.javac.code.TypeTags.*; 84.8 +import static com.sun.tools.javac.code.TypeTag.CLASS; 84.9 import static com.sun.tools.javac.jvm.ClassFile.*; 84.10 import static com.sun.tools.javac.jvm.ClassFile.Version.*; 84.11 84.12 @@ -1018,6 +1018,15 @@ 84.13 ClassSymbol c = (ClassSymbol) sym; 84.14 Name n = readName(nextChar()); 84.15 c.sourcefile = new SourceFileObject(n, c.flatname); 84.16 + // If the class is a toplevel class, originating from a Java source file, 84.17 + // but the class name does not match the file name, then it is 84.18 + // an auxiliary class. 84.19 + String sn = n.toString(); 84.20 + if (c.owner.kind == Kinds.PCK && 84.21 + sn.endsWith(".java") && 84.22 + !sn.equals(c.name.toString()+".java")) { 84.23 + c.flags_field |= AUXILIARY; 84.24 + } 84.25 } 84.26 }, 84.27 84.28 @@ -1870,7 +1879,7 @@ 84.29 * `typevars'. 84.30 */ 84.31 protected void enterTypevars(Type t) { 84.32 - if (t.getEnclosingType() != null && t.getEnclosingType().tag == CLASS) 84.33 + if (t.getEnclosingType() != null && t.getEnclosingType().hasTag(CLASS)) 84.34 enterTypevars(t.getEnclosingType()); 84.35 for (List<Type> xs = t.getTypeArguments(); xs.nonEmpty(); xs = xs.tail) 84.36 typevars.enter(xs.head.tsym); 84.37 @@ -1895,7 +1904,7 @@ 84.38 84.39 // prepare type variable table 84.40 typevars = typevars.dup(currentOwner); 84.41 - if (ct.getEnclosingType().tag == CLASS) 84.42 + if (ct.getEnclosingType().hasTag(CLASS)) 84.43 enterTypevars(ct.getEnclosingType()); 84.44 84.45 // read flags, or skip if this is an inner class
85.1 --- a/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java Thu Nov 01 14:13:13 2012 -0700 85.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java Fri Nov 02 17:55:34 2012 -0700 85.3 @@ -45,7 +45,7 @@ 85.4 import static com.sun.tools.javac.code.BoundKind.*; 85.5 import static com.sun.tools.javac.code.Flags.*; 85.6 import static com.sun.tools.javac.code.Kinds.*; 85.7 -import static com.sun.tools.javac.code.TypeTags.*; 85.8 +import static com.sun.tools.javac.code.TypeTag.*; 85.9 import static com.sun.tools.javac.jvm.UninitializedType.*; 85.10 import static com.sun.tools.javac.main.Option.*; 85.11 import static javax.tools.StandardLocation.CLASS_OUTPUT; 85.12 @@ -274,7 +274,7 @@ 85.13 /** Assemble signature of given type in string buffer. 85.14 */ 85.15 void assembleSig(Type type) { 85.16 - switch (type.tag) { 85.17 + switch (type.getTag()) { 85.18 case BYTE: 85.19 sigbuf.appendByte('B'); 85.20 break; 85.21 @@ -361,13 +361,13 @@ 85.22 assembleSig(types.erasure(((UninitializedType)type).qtype)); 85.23 break; 85.24 default: 85.25 - throw new AssertionError("typeSig " + type.tag); 85.26 + throw new AssertionError("typeSig " + type.getTag()); 85.27 } 85.28 } 85.29 85.30 boolean hasTypeVar(List<Type> l) { 85.31 while (l.nonEmpty()) { 85.32 - if (l.head.tag == TypeTags.TYPEVAR) return true; 85.33 + if (l.head.hasTag(TYPEVAR)) return true; 85.34 l = l.tail; 85.35 } 85.36 return false; 85.37 @@ -439,9 +439,9 @@ 85.38 * external representation. 85.39 */ 85.40 public Name xClassName(Type t) { 85.41 - if (t.tag == CLASS) { 85.42 + if (t.hasTag(CLASS)) { 85.43 return names.fromUtf(externalize(t.tsym.flatName())); 85.44 - } else if (t.tag == ARRAY) { 85.45 + } else if (t.hasTag(ARRAY)) { 85.46 return typeSig(types.erasure(t)); 85.47 } else { 85.48 throw new AssertionError("xClassName"); 85.49 @@ -521,7 +521,7 @@ 85.50 ClassSymbol c = (ClassSymbol)value; 85.51 if (c.owner.kind == TYP) pool.put(c.owner); 85.52 poolbuf.appendByte(CONSTANT_Class); 85.53 - if (c.type.tag == ARRAY) { 85.54 + if (c.type.hasTag(ARRAY)) { 85.55 poolbuf.appendChar(pool.put(typeSig(c.type))); 85.56 } else { 85.57 poolbuf.appendChar(pool.put(names.fromUtf(externalize(c.flatname)))); 85.58 @@ -555,7 +555,7 @@ 85.59 poolbuf.appendChar(pool.put(typeSig(mtype))); 85.60 } else if (value instanceof Type) { 85.61 Type type = (Type)value; 85.62 - if (type.tag == CLASS) enterInner((ClassSymbol)type.tsym); 85.63 + if (type.hasTag(CLASS)) enterInner((ClassSymbol)type.tsym); 85.64 poolbuf.appendByte(CONSTANT_Class); 85.65 poolbuf.appendChar(pool.put(xClassName(type))); 85.66 } else if (value instanceof Pool.MethodHandle) { 85.67 @@ -815,7 +815,7 @@ 85.68 class AttributeWriter implements Attribute.Visitor { 85.69 public void visitConstant(Attribute.Constant _value) { 85.70 Object value = _value.value; 85.71 - switch (_value.type.tag) { 85.72 + switch (_value.type.getTag()) { 85.73 case BYTE: 85.74 databuf.appendByte('B'); 85.75 break; 85.76 @@ -901,7 +901,7 @@ 85.77 System.err.println("error: " + c + ": " + ex.getMessage()); 85.78 throw ex; 85.79 } 85.80 - if (c.type.tag != CLASS) return; // arrays 85.81 + if (!c.type.hasTag(CLASS)) return; // arrays 85.82 if (pool != null && // pool might be null if called from xClassName 85.83 c.owner.enclClass() != null && 85.84 (innerClasses == null || !innerClasses.contains(c))) { 85.85 @@ -1207,7 +1207,7 @@ 85.86 if (debugstackmap) System.out.print("empty"); 85.87 databuf.appendByte(0); 85.88 } 85.89 - else switch(t.tag) { 85.90 + else switch(t.getTag()) { 85.91 case BYTE: 85.92 case CHAR: 85.93 case SHORT: 85.94 @@ -1430,7 +1430,7 @@ 85.95 } 85.96 85.97 static boolean isInt(Type t) { 85.98 - return (t.tag < TypeTags.INT || t.tag == TypeTags.BOOLEAN); 85.99 + return (t.getTag().isStrictSubRangeOf(INT) || t.hasTag(BOOLEAN)); 85.100 } 85.101 85.102 static boolean isSameType(Type t1, Type t2, Types types) { 85.103 @@ -1439,15 +1439,15 @@ 85.104 85.105 if (isInt(t1) && isInt(t2)) { return true; } 85.106 85.107 - if (t1.tag == UNINITIALIZED_THIS) { 85.108 - return t2.tag == UNINITIALIZED_THIS; 85.109 - } else if (t1.tag == UNINITIALIZED_OBJECT) { 85.110 - if (t2.tag == UNINITIALIZED_OBJECT) { 85.111 + if (t1.hasTag(UNINITIALIZED_THIS)) { 85.112 + return t2.hasTag(UNINITIALIZED_THIS); 85.113 + } else if (t1.hasTag(UNINITIALIZED_OBJECT)) { 85.114 + if (t2.hasTag(UNINITIALIZED_OBJECT)) { 85.115 return ((UninitializedType)t1).offset == ((UninitializedType)t2).offset; 85.116 } else { 85.117 return false; 85.118 } 85.119 - } else if (t2.tag == UNINITIALIZED_THIS || t2.tag == UNINITIALIZED_OBJECT) { 85.120 + } else if (t2.hasTag(UNINITIALIZED_THIS) || t2.hasTag(UNINITIALIZED_OBJECT)) { 85.121 return false; 85.122 } 85.123 85.124 @@ -1554,7 +1554,7 @@ 85.125 databuf.appendChar(flags); 85.126 85.127 databuf.appendChar(pool.put(c)); 85.128 - databuf.appendChar(supertype.tag == CLASS ? pool.put(supertype.tsym) : 0); 85.129 + databuf.appendChar(supertype.hasTag(CLASS) ? pool.put(supertype.tsym) : 0); 85.130 databuf.appendChar(interfaces.length()); 85.131 for (List<Type> l = interfaces; l.nonEmpty(); l = l.tail) 85.132 databuf.appendChar(pool.put(l.head.tsym));
86.1 --- a/src/share/classes/com/sun/tools/javac/jvm/Code.java Thu Nov 01 14:13:13 2012 -0700 86.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/Code.java Fri Nov 02 17:55:34 2012 -0700 86.3 @@ -30,7 +30,8 @@ 86.4 import com.sun.tools.javac.util.*; 86.5 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; 86.6 86.7 -import static com.sun.tools.javac.code.TypeTags.*; 86.8 +import static com.sun.tools.javac.code.TypeTag.BOT; 86.9 +import static com.sun.tools.javac.code.TypeTag.INT; 86.10 import static com.sun.tools.javac.jvm.ByteCodes.*; 86.11 import static com.sun.tools.javac.jvm.UninitializedType.*; 86.12 import static com.sun.tools.javac.jvm.ClassWriter.StackMapTableFrame; 86.13 @@ -224,7 +225,7 @@ 86.14 * JVM architecture). 86.15 */ 86.16 public static int typecode(Type type) { 86.17 - switch (type.tag) { 86.18 + switch (type.getTag()) { 86.19 case BYTE: return BYTEcode; 86.20 case SHORT: return SHORTcode; 86.21 case CHAR: return CHARcode; 86.22 @@ -242,7 +243,7 @@ 86.23 case UNINITIALIZED_THIS: 86.24 case UNINITIALIZED_OBJECT: 86.25 return OBJECTcode; 86.26 - default: throw new AssertionError("typecode " + type.tag); 86.27 + default: throw new AssertionError("typecode " + type.getTag()); 86.28 } 86.29 } 86.30 86.31 @@ -281,7 +282,7 @@ 86.32 /** Given a type, return its code for allocating arrays of that type. 86.33 */ 86.34 public static int arraycode(Type type) { 86.35 - switch (type.tag) { 86.36 + switch (type.getTag()) { 86.37 case BYTE: return 8; 86.38 case BOOLEAN: return 4; 86.39 case SHORT: return 9; 86.40 @@ -477,7 +478,7 @@ 86.41 state.pop(1); 86.42 //sometimes 'null type' is treated as a one-dimensional array type 86.43 //see Gen.visitLiteral - we should handle this case accordingly 86.44 - Type stackType = a.tag == BOT ? 86.45 + Type stackType = a.hasTag(BOT) ? 86.46 syms.objectType : 86.47 types.erasure(types.elemtype(a)); 86.48 state.push(stackType); } 86.49 @@ -1656,13 +1657,13 @@ 86.50 86.51 void push(Type t) { 86.52 if (debugCode) System.err.println(" pushing " + t); 86.53 - switch (t.tag) { 86.54 - case TypeTags.VOID: 86.55 + switch (t.getTag()) { 86.56 + case VOID: 86.57 return; 86.58 - case TypeTags.BYTE: 86.59 - case TypeTags.CHAR: 86.60 - case TypeTags.SHORT: 86.61 - case TypeTags.BOOLEAN: 86.62 + case BYTE: 86.63 + case CHAR: 86.64 + case SHORT: 86.65 + case BOOLEAN: 86.66 t = syms.intType; 86.67 break; 86.68 default: 86.69 @@ -1722,7 +1723,7 @@ 86.70 * of its current type. */ 86.71 void forceStackTop(Type t) { 86.72 if (!alive) return; 86.73 - switch (t.tag) { 86.74 + switch (t.getTag()) { 86.75 case CLASS: 86.76 case ARRAY: 86.77 int width = width(t); 86.78 @@ -1824,7 +1825,7 @@ 86.79 } 86.80 } 86.81 86.82 - static Type jsrReturnValue = new Type(TypeTags.INT, null); 86.83 + static Type jsrReturnValue = new Type(INT, null); 86.84 86.85 86.86 /* **************************************************************************
87.1 --- a/src/share/classes/com/sun/tools/javac/jvm/Gen.java Thu Nov 01 14:13:13 2012 -0700 87.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/Gen.java Fri Nov 02 17:55:34 2012 -0700 87.3 @@ -42,7 +42,7 @@ 87.4 87.5 import static com.sun.tools.javac.code.Flags.*; 87.6 import static com.sun.tools.javac.code.Kinds.*; 87.7 -import static com.sun.tools.javac.code.TypeTags.*; 87.8 +import static com.sun.tools.javac.code.TypeTag.*; 87.9 import static com.sun.tools.javac.jvm.ByteCodes.*; 87.10 import static com.sun.tools.javac.jvm.CRTFlags.*; 87.11 import static com.sun.tools.javac.main.Option.*; 87.12 @@ -258,7 +258,7 @@ 87.13 */ 87.14 Symbol binaryQualifier(Symbol sym, Type site) { 87.15 87.16 - if (site.tag == ARRAY) { 87.17 + if (site.hasTag(ARRAY)) { 87.18 if (sym == syms.lengthVar || 87.19 sym.owner != syms.arrayClass) 87.20 return sym; 87.21 @@ -305,13 +305,13 @@ 87.22 */ 87.23 int makeRef(DiagnosticPosition pos, Type type) { 87.24 checkDimension(pos, type); 87.25 - return pool.put(type.tag == CLASS ? (Object)type.tsym : (Object)type); 87.26 + return pool.put(type.hasTag(CLASS) ? (Object)type.tsym : (Object)type); 87.27 } 87.28 87.29 /** Check if the given type is an array with too many dimensions. 87.30 */ 87.31 private void checkDimension(DiagnosticPosition pos, Type t) { 87.32 - switch (t.tag) { 87.33 + switch (t.getTag()) { 87.34 case METHOD: 87.35 checkDimension(pos, t.getReturnType()); 87.36 for (List<Type> args = t.getParameterTypes(); args.nonEmpty(); args = args.tail) 87.37 @@ -922,7 +922,7 @@ 87.38 if (code.isAlive()) { 87.39 code.statBegin(TreeInfo.endPos(tree.body)); 87.40 if (env.enclMethod == null || 87.41 - env.enclMethod.sym.type.getReturnType().tag == VOID) { 87.42 + env.enclMethod.sym.type.getReturnType().hasTag(VOID)) { 87.43 code.emitop0(return_); 87.44 } else { 87.45 // sometime dead code seems alive (4415991); 87.46 @@ -1110,7 +1110,7 @@ 87.47 87.48 public void visitSwitch(JCSwitch tree) { 87.49 int limit = code.nextreg; 87.50 - Assert.check(tree.selector.type.tag != CLASS); 87.51 + Assert.check(!tree.selector.type.hasTag(CLASS)); 87.52 int startpcCrt = genCrt ? code.curPc() : 0; 87.53 Item sel = genExpr(tree.selector, syms.intType); 87.54 List<JCCase> cases = tree.cases; 87.55 @@ -1817,8 +1817,8 @@ 87.56 // proceeding further. 87.57 if ((tree.hasTag(PLUS_ASG) || tree.hasTag(MINUS_ASG)) && 87.58 l instanceof LocalItem && 87.59 - tree.lhs.type.tag <= INT && 87.60 - tree.rhs.type.tag <= INT && 87.61 + tree.lhs.type.getTag().isSubRangeOf(INT) && 87.62 + tree.rhs.type.getTag().isSubRangeOf(INT) && 87.63 tree.rhs.type.constValue() != null) { 87.64 int ival = ((Number) tree.rhs.type.constValue()).intValue(); 87.65 if (tree.hasTag(MINUS_ASG)) ival = -ival; 87.66 @@ -1969,7 +1969,7 @@ 87.67 */ 87.68 void appendString(JCTree tree) { 87.69 Type t = tree.type.baseType(); 87.70 - if (t.tag > lastBaseTag && t.tsym != syms.stringType.tsym) { 87.71 + if (!t.isPrimitive() && t.tsym != syms.stringType.tsym) { 87.72 t = syms.objectType; 87.73 } 87.74 items.makeMemberItem(getStringBufferAppend(tree, t), false).invoke(); 87.75 @@ -2067,7 +2067,7 @@ 87.76 // which is not statically a supertype of the expression's type. 87.77 // For basic types, the coerce(...) in genExpr(...) will do 87.78 // the conversion. 87.79 - if (tree.clazz.type.tag > lastBaseTag && 87.80 + if (!tree.clazz.type.isPrimitive() && 87.81 types.asSuper(tree.expr.type, tree.clazz.type.tsym) == null) { 87.82 code.emitop2(checkcast, makeRef(tree.pos(), tree.clazz.type)); 87.83 } 87.84 @@ -2185,7 +2185,7 @@ 87.85 } 87.86 87.87 public void visitLiteral(JCLiteral tree) { 87.88 - if (tree.type.tag == TypeTags.BOT) { 87.89 + if (tree.type.hasTag(BOT)) { 87.90 code.emitop0(aconst_null); 87.91 if (types.dimensions(pt) > 1) { 87.92 code.emitop2(checkcast, makeRef(tree.pos(), pt));
88.1 --- a/src/share/classes/com/sun/tools/javac/jvm/UninitializedType.java Thu Nov 01 14:13:13 2012 -0700 88.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/UninitializedType.java Fri Nov 02 17:55:34 2012 -0700 88.3 @@ -1,5 +1,5 @@ 88.4 /* 88.5 - * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved. 88.6 + * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. 88.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 88.8 * 88.9 * This code is free software; you can redistribute it and/or modify it 88.10 @@ -27,6 +27,8 @@ 88.11 88.12 import com.sun.tools.javac.code.*; 88.13 88.14 +import static com.sun.tools.javac.code.TypeTag.UNINITIALIZED_OBJECT; 88.15 +import static com.sun.tools.javac.code.TypeTag.UNINITIALIZED_THIS; 88.16 88.17 /** These pseudo-types appear in the generated verifier tables to 88.18 * indicate objects that have been allocated but not yet constructed. 88.19 @@ -37,8 +39,6 @@ 88.20 * deletion without notice.</b> 88.21 */ 88.22 class UninitializedType extends Type.DelegatedType { 88.23 - public static final int UNINITIALIZED_THIS = TypeTags.TypeTagCount; 88.24 - public static final int UNINITIALIZED_OBJECT = UNINITIALIZED_THIS + 1; 88.25 88.26 public static UninitializedType uninitializedThis(Type qtype) { 88.27 return new UninitializedType(UNINITIALIZED_THIS, qtype, -1); 88.28 @@ -49,7 +49,7 @@ 88.29 } 88.30 88.31 public final int offset; // PC where allocation took place 88.32 - private UninitializedType(int tag, Type qtype, int offset) { 88.33 + private UninitializedType(TypeTag tag, Type qtype, int offset) { 88.34 super(tag, qtype); 88.35 this.offset = offset; 88.36 }
89.1 --- a/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java Thu Nov 01 14:13:13 2012 -0700 89.2 +++ b/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java Fri Nov 02 17:55:34 2012 -0700 89.3 @@ -63,6 +63,7 @@ 89.4 import com.sun.tools.javac.util.*; 89.5 import com.sun.tools.javac.util.Log.WriterKind; 89.6 89.7 +import static com.sun.tools.javac.code.TypeTag.CLASS; 89.8 import static com.sun.tools.javac.main.Option.*; 89.9 import static com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag.*; 89.10 import static com.sun.tools.javac.util.ListBuffer.lb; 89.11 @@ -270,6 +271,10 @@ 89.12 */ 89.13 protected TransTypes transTypes; 89.14 89.15 + /** The lambda translator. 89.16 + */ 89.17 + protected LambdaToMethod lambdaToMethod; 89.18 + 89.19 /** The syntactic sugar desweetener. 89.20 */ 89.21 protected Lower lower; 89.22 @@ -368,6 +373,8 @@ 89.23 89.24 options = Options.instance(context); 89.25 89.26 + lambdaToMethod = LambdaToMethod.instance(context); 89.27 + 89.28 verbose = options.isSet(VERBOSE); 89.29 sourceOutput = options.isSet(PRINTSOURCE); // used to be -s 89.30 stubOutput = options.isSet("-stubs"); 89.31 @@ -523,8 +530,10 @@ 89.32 ATTR(4), 89.33 FLOW(5), 89.34 TRANSTYPES(6), 89.35 - LOWER(7), 89.36 - GENERATE(8); 89.37 + UNLAMBDA(7), 89.38 + LOWER(8), 89.39 + GENERATE(9); 89.40 + 89.41 CompileState(int value) { 89.42 this.value = value; 89.43 } 89.44 @@ -1349,7 +1358,7 @@ 89.45 @Override 89.46 public void visitClassDef(JCClassDecl node) { 89.47 Type st = types.supertype(node.sym.type); 89.48 - if (st.tag == TypeTags.CLASS) { 89.49 + if (st.hasTag(CLASS)) { 89.50 ClassSymbol c = st.tsym.outermostClass(); 89.51 Env<AttrContext> stEnv = enter.getEnv(c); 89.52 if (stEnv != null && env != stEnv) { 89.53 @@ -1417,6 +1426,12 @@ 89.54 env.tree = transTypes.translateTopLevelClass(env.tree, localMake); 89.55 compileStates.put(env, CompileState.TRANSTYPES); 89.56 89.57 + if (shouldStop(CompileState.UNLAMBDA)) 89.58 + return; 89.59 + 89.60 + env.tree = lambdaToMethod.translateTopLevelClass(env, env.tree, localMake); 89.61 + compileStates.put(env, CompileState.UNLAMBDA); 89.62 + 89.63 if (shouldStop(CompileState.LOWER)) 89.64 return; 89.65
90.1 --- a/src/share/classes/com/sun/tools/javac/model/JavacElements.java Thu Nov 01 14:13:13 2012 -0700 90.2 +++ b/src/share/classes/com/sun/tools/javac/model/JavacElements.java Fri Nov 02 17:55:34 2012 -0700 90.3 @@ -38,7 +38,7 @@ 90.4 90.5 import com.sun.tools.javac.code.*; 90.6 import com.sun.tools.javac.code.Symbol.*; 90.7 -import com.sun.tools.javac.code.TypeTags; 90.8 +import com.sun.tools.javac.code.TypeTag; 90.9 import com.sun.tools.javac.comp.AttrContext; 90.10 import com.sun.tools.javac.comp.Enter; 90.11 import com.sun.tools.javac.comp.Env; 90.12 @@ -50,6 +50,7 @@ 90.13 import com.sun.tools.javac.tree.TreeScanner; 90.14 import com.sun.tools.javac.util.*; 90.15 import com.sun.tools.javac.util.Name; 90.16 +import static com.sun.tools.javac.code.TypeTag.CLASS; 90.17 import static com.sun.tools.javac.tree.JCTree.Tag.*; 90.18 90.19 /** 90.20 @@ -124,7 +125,7 @@ 90.21 if (result != null || !inherited) 90.22 break; 90.23 Type sup = annotated.getSuperclass(); 90.24 - if (sup.tag != TypeTags.CLASS || sup.isErroneous()) 90.25 + if (!sup.hasTag(CLASS) || sup.isErroneous()) 90.26 break; 90.27 annotated = (ClassSymbol) sup.tsym; 90.28 } 90.29 @@ -444,7 +445,7 @@ 90.30 List<Attribute.Compound> annos = sym.getAnnotationMirrors(); 90.31 while (sym.getKind() == ElementKind.CLASS) { 90.32 Type sup = ((ClassSymbol) sym).getSuperclass(); 90.33 - if (sup.tag != TypeTags.CLASS || sup.isErroneous() || 90.34 + if (!sup.hasTag(CLASS) || sup.isErroneous() || 90.35 sup.tsym == syms.objectType.tsym) { 90.36 break; 90.37 }
91.1 --- a/src/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java Thu Nov 01 14:13:13 2012 -0700 91.2 +++ b/src/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java Fri Nov 02 17:55:34 2012 -0700 91.3 @@ -662,7 +662,10 @@ 91.4 tk = TokenKind.EOF; 91.5 pos = reader.buflen; 91.6 } else { 91.7 - lexError(pos, "illegal.char", String.valueOf((int)reader.ch)); 91.8 + String arg = (32 < reader.ch && reader.ch < 127) ? 91.9 + String.format("%s", reader.ch) : 91.10 + String.format("\\u%04x", (int)reader.ch); 91.11 + lexError(pos, "illegal.char", arg); 91.12 reader.scanChar(); 91.13 } 91.14 }
92.1 --- a/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Thu Nov 01 14:13:13 2012 -0700 92.2 +++ b/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Fri Nov 02 17:55:34 2012 -0700 92.3 @@ -560,7 +560,7 @@ 92.4 case INTLITERAL: 92.5 try { 92.6 t = F.at(pos).Literal( 92.7 - TypeTags.INT, 92.8 + TypeTag.INT, 92.9 Convert.string2int(strval(prefix), token.radix())); 92.10 } catch (NumberFormatException ex) { 92.11 error(token.pos, "int.number.too.large", strval(prefix)); 92.12 @@ -569,7 +569,7 @@ 92.13 case LONGLITERAL: 92.14 try { 92.15 t = F.at(pos).Literal( 92.16 - TypeTags.LONG, 92.17 + TypeTag.LONG, 92.18 new Long(Convert.string2long(strval(prefix), token.radix()))); 92.19 } catch (NumberFormatException ex) { 92.20 error(token.pos, "int.number.too.large", strval(prefix)); 92.21 @@ -591,7 +591,7 @@ 92.22 else if (n.floatValue() == Float.POSITIVE_INFINITY) 92.23 error(token.pos, "fp.number.too.large"); 92.24 else 92.25 - t = F.at(pos).Literal(TypeTags.FLOAT, n); 92.26 + t = F.at(pos).Literal(TypeTag.FLOAT, n); 92.27 break; 92.28 } 92.29 case DOUBLELITERAL: { 92.30 @@ -610,27 +610,27 @@ 92.31 else if (n.doubleValue() == Double.POSITIVE_INFINITY) 92.32 error(token.pos, "fp.number.too.large"); 92.33 else 92.34 - t = F.at(pos).Literal(TypeTags.DOUBLE, n); 92.35 + t = F.at(pos).Literal(TypeTag.DOUBLE, n); 92.36 break; 92.37 } 92.38 case CHARLITERAL: 92.39 t = F.at(pos).Literal( 92.40 - TypeTags.CHAR, 92.41 + TypeTag.CHAR, 92.42 token.stringVal().charAt(0) + 0); 92.43 break; 92.44 case STRINGLITERAL: 92.45 t = F.at(pos).Literal( 92.46 - TypeTags.CLASS, 92.47 + TypeTag.CLASS, 92.48 token.stringVal()); 92.49 break; 92.50 case TRUE: case FALSE: 92.51 t = F.at(pos).Literal( 92.52 - TypeTags.BOOLEAN, 92.53 + TypeTag.BOOLEAN, 92.54 (token.kind == TRUE ? 1 : 0)); 92.55 break; 92.56 case NULL: 92.57 t = F.at(pos).Literal( 92.58 - TypeTags.BOT, 92.59 + TypeTag.BOT, 92.60 null); 92.61 break; 92.62 default: 92.63 @@ -814,7 +814,7 @@ 92.64 if (t.hasTag(JCTree.Tag.PLUS)) { 92.65 StringBuilder buf = foldStrings(t); 92.66 if (buf != null) { 92.67 - t = toP(F.at(startPos).Literal(TypeTags.CLASS, buf.toString())); 92.68 + t = toP(F.at(startPos).Literal(TypeTag.CLASS, buf.toString())); 92.69 } 92.70 } 92.71 92.72 @@ -846,7 +846,7 @@ 92.73 while (true) { 92.74 if (tree.hasTag(LITERAL)) { 92.75 JCLiteral lit = (JCLiteral) tree; 92.76 - if (lit.typetag == TypeTags.CLASS) { 92.77 + if (lit.typetag == TypeTag.CLASS) { 92.78 StringBuilder sbuf = 92.79 new StringBuilder((String)lit.value); 92.80 while (buf.nonEmpty()) { 92.81 @@ -859,7 +859,7 @@ 92.82 JCBinary op = (JCBinary)tree; 92.83 if (op.rhs.hasTag(LITERAL)) { 92.84 JCLiteral lit = (JCLiteral) op.rhs; 92.85 - if (lit.typetag == TypeTags.CLASS) { 92.86 + if (lit.typetag == TypeTag.CLASS) { 92.87 buf = buf.prepend((String) lit.value); 92.88 tree = op.lhs; 92.89 continue; 92.90 @@ -1211,7 +1211,7 @@ 92.91 if ((mode & EXPR) != 0) { 92.92 nextToken(); 92.93 if (token.kind == DOT) { 92.94 - JCPrimitiveTypeTree ti = toP(F.at(pos).TypeIdent(TypeTags.VOID)); 92.95 + JCPrimitiveTypeTree ti = toP(F.at(pos).TypeIdent(TypeTag.VOID)); 92.96 t = bracketsSuffix(ti); 92.97 } else { 92.98 return illegal(pos); 92.99 @@ -1220,7 +1220,7 @@ 92.100 // Support the corner case of myMethodHandle.<void>invoke() by passing 92.101 // a void type (like other primitive types) to the next phase. 92.102 // The error will be reported in Attr.attribTypes or Attr.visitApply. 92.103 - JCPrimitiveTypeTree ti = to(F.at(pos).TypeIdent(TypeTags.VOID)); 92.104 + JCPrimitiveTypeTree ti = to(F.at(pos).TypeIdent(TypeTag.VOID)); 92.105 nextToken(); 92.106 return ti; 92.107 //return illegal(); 92.108 @@ -2920,7 +2920,7 @@ 92.109 JCExpression type; 92.110 boolean isVoid = token.kind == VOID; 92.111 if (isVoid) { 92.112 - type = to(F.at(pos).TypeIdent(TypeTags.VOID)); 92.113 + type = to(F.at(pos).TypeIdent(TypeTag.VOID)); 92.114 nextToken(); 92.115 } else { 92.116 type = parseType(); 92.117 @@ -3283,28 +3283,28 @@ 92.118 } 92.119 92.120 /** Return type tag of basic type represented by token, 92.121 - * -1 if token is not a basic type identifier. 92.122 + * NONE if token is not a basic type identifier. 92.123 */ 92.124 - static int typetag(TokenKind token) { 92.125 + static TypeTag typetag(TokenKind token) { 92.126 switch (token) { 92.127 case BYTE: 92.128 - return TypeTags.BYTE; 92.129 + return TypeTag.BYTE; 92.130 case CHAR: 92.131 - return TypeTags.CHAR; 92.132 + return TypeTag.CHAR; 92.133 case SHORT: 92.134 - return TypeTags.SHORT; 92.135 + return TypeTag.SHORT; 92.136 case INT: 92.137 - return TypeTags.INT; 92.138 + return TypeTag.INT; 92.139 case LONG: 92.140 - return TypeTags.LONG; 92.141 + return TypeTag.LONG; 92.142 case FLOAT: 92.143 - return TypeTags.FLOAT; 92.144 + return TypeTag.FLOAT; 92.145 case DOUBLE: 92.146 - return TypeTags.DOUBLE; 92.147 + return TypeTag.DOUBLE; 92.148 case BOOLEAN: 92.149 - return TypeTags.BOOLEAN; 92.150 + return TypeTag.BOOLEAN; 92.151 default: 92.152 - return -1; 92.153 + return TypeTag.NONE; 92.154 } 92.155 } 92.156
93.1 --- a/src/share/classes/com/sun/tools/javac/resources/compiler.properties Thu Nov 01 14:13:13 2012 -0700 93.2 +++ b/src/share/classes/com/sun/tools/javac/resources/compiler.properties Fri Nov 02 17:55:34 2012 -0700 93.3 @@ -475,7 +475,7 @@ 93.4 93.5 # 0: string 93.6 compiler.err.illegal.char=\ 93.7 - illegal character: \\{0} 93.8 + illegal character: ''{0}'' 93.9 93.10 compiler.err.illegal.char.for.encoding=\ 93.11 unmappable character for encoding {0} 93.12 @@ -1847,6 +1847,11 @@ 93.13 93.14 ##### 93.15 93.16 +# 0: type, 1: file name 93.17 +compiler.warn.auxiliary.class.accessed.from.outside.of.its.source.file=\ 93.18 + auxiliary class {0} in {1} should not be accessed from outside its own source file 93.19 + 93.20 + 93.21 ## The first argument ({0}) is a "kindname". 93.22 # 0: symbol kind, 1: symbol, 2: symbol 93.23 compiler.err.abstract.cant.be.accessed.directly=\
94.1 --- a/src/share/classes/com/sun/tools/javac/tree/JCTree.java Thu Nov 01 14:13:13 2012 -0700 94.2 +++ b/src/share/classes/com/sun/tools/javac/tree/JCTree.java Fri Nov 02 17:55:34 2012 -0700 94.3 @@ -81,7 +81,7 @@ 94.4 public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition { 94.5 94.6 /* Tree tag values, identifying kinds of trees */ 94.7 - public enum Tag{ 94.8 + public enum Tag { 94.9 /** For methods that return an invalid tag if a given condition is not met 94.10 */ 94.11 NO_TAG, 94.12 @@ -1912,10 +1912,10 @@ 94.13 * A constant value given literally. 94.14 */ 94.15 public static class JCLiteral extends JCExpression implements LiteralTree { 94.16 - public int typetag; 94.17 + public TypeTag typetag; 94.18 /** value representation */ 94.19 public Object value; 94.20 - protected JCLiteral(int typetag, Object value) { 94.21 + protected JCLiteral(TypeTag typetag, Object value) { 94.22 this.typetag = typetag; 94.23 this.value = value; 94.24 } 94.25 @@ -1923,33 +1923,15 @@ 94.26 public void accept(Visitor v) { v.visitLiteral(this); } 94.27 94.28 public Kind getKind() { 94.29 - switch (typetag) { 94.30 - case TypeTags.INT: 94.31 - return Kind.INT_LITERAL; 94.32 - case TypeTags.LONG: 94.33 - return Kind.LONG_LITERAL; 94.34 - case TypeTags.FLOAT: 94.35 - return Kind.FLOAT_LITERAL; 94.36 - case TypeTags.DOUBLE: 94.37 - return Kind.DOUBLE_LITERAL; 94.38 - case TypeTags.BOOLEAN: 94.39 - return Kind.BOOLEAN_LITERAL; 94.40 - case TypeTags.CHAR: 94.41 - return Kind.CHAR_LITERAL; 94.42 - case TypeTags.CLASS: 94.43 - return Kind.STRING_LITERAL; 94.44 - case TypeTags.BOT: 94.45 - return Kind.NULL_LITERAL; 94.46 - default: 94.47 - throw new AssertionError("unknown literal kind " + this); 94.48 - } 94.49 + return typetag.getKindLiteral(); 94.50 } 94.51 + 94.52 public Object getValue() { 94.53 switch (typetag) { 94.54 - case TypeTags.BOOLEAN: 94.55 + case BOOLEAN: 94.56 int bi = (Integer) value; 94.57 return (bi != 0); 94.58 - case TypeTags.CHAR: 94.59 + case CHAR: 94.60 int ci = (Integer) value; 94.61 char c = (char) ci; 94.62 if (c != ci) 94.63 @@ -1976,12 +1958,12 @@ 94.64 94.65 /** 94.66 * Identifies a basic type. 94.67 - * @see TypeTags 94.68 + * @see TypeTag 94.69 */ 94.70 public static class JCPrimitiveTypeTree extends JCExpression implements PrimitiveTypeTree { 94.71 /** the basic type id */ 94.72 - public int typetag; 94.73 - protected JCPrimitiveTypeTree(int typetag) { 94.74 + public TypeTag typetag; 94.75 + protected JCPrimitiveTypeTree(TypeTag typetag) { 94.76 this.typetag = typetag; 94.77 } 94.78 @Override 94.79 @@ -1989,29 +1971,9 @@ 94.80 94.81 public Kind getKind() { return Kind.PRIMITIVE_TYPE; } 94.82 public TypeKind getPrimitiveTypeKind() { 94.83 - switch (typetag) { 94.84 - case TypeTags.BOOLEAN: 94.85 - return TypeKind.BOOLEAN; 94.86 - case TypeTags.BYTE: 94.87 - return TypeKind.BYTE; 94.88 - case TypeTags.SHORT: 94.89 - return TypeKind.SHORT; 94.90 - case TypeTags.INT: 94.91 - return TypeKind.INT; 94.92 - case TypeTags.LONG: 94.93 - return TypeKind.LONG; 94.94 - case TypeTags.CHAR: 94.95 - return TypeKind.CHAR; 94.96 - case TypeTags.FLOAT: 94.97 - return TypeKind.FLOAT; 94.98 - case TypeTags.DOUBLE: 94.99 - return TypeKind.DOUBLE; 94.100 - case TypeTags.VOID: 94.101 - return TypeKind.VOID; 94.102 - default: 94.103 - throw new AssertionError("unknown primitive type " + this); 94.104 - } 94.105 + return typetag.getPrimitiveTypeKind(); 94.106 } 94.107 + 94.108 @Override 94.109 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 94.110 return v.visitPrimitiveType(this, d); 94.111 @@ -2161,7 +2123,7 @@ 94.112 } 94.113 @Override 94.114 public Tag getTag() { 94.115 - return WILDCARD; 94.116 + return Tag.WILDCARD; 94.117 } 94.118 } 94.119 94.120 @@ -2362,8 +2324,8 @@ 94.121 JCArrayAccess Indexed(JCExpression indexed, JCExpression index); 94.122 JCFieldAccess Select(JCExpression selected, Name selector); 94.123 JCIdent Ident(Name idname); 94.124 - JCLiteral Literal(int tag, Object value); 94.125 - JCPrimitiveTypeTree TypeIdent(int typetag); 94.126 + JCLiteral Literal(TypeTag tag, Object value); 94.127 + JCPrimitiveTypeTree TypeIdent(TypeTag typetag); 94.128 JCArrayTypeTree TypeArray(JCExpression elemtype); 94.129 JCTypeApply TypeApply(JCExpression clazz, List<JCExpression> arguments); 94.130 JCTypeParameter TypeParameter(Name name, List<JCExpression> bounds);
95.1 --- a/src/share/classes/com/sun/tools/javac/tree/Pretty.java Thu Nov 01 14:13:13 2012 -0700 95.2 +++ b/src/share/classes/com/sun/tools/javac/tree/Pretty.java Fri Nov 02 17:55:34 2012 -0700 95.3 @@ -1133,28 +1133,28 @@ 95.4 public void visitLiteral(JCLiteral tree) { 95.5 try { 95.6 switch (tree.typetag) { 95.7 - case TypeTags.INT: 95.8 + case INT: 95.9 print(tree.value.toString()); 95.10 break; 95.11 - case TypeTags.LONG: 95.12 + case LONG: 95.13 print(tree.value + "L"); 95.14 break; 95.15 - case TypeTags.FLOAT: 95.16 + case FLOAT: 95.17 print(tree.value + "F"); 95.18 break; 95.19 - case TypeTags.DOUBLE: 95.20 + case DOUBLE: 95.21 print(tree.value.toString()); 95.22 break; 95.23 - case TypeTags.CHAR: 95.24 + case CHAR: 95.25 print("\'" + 95.26 Convert.quote( 95.27 String.valueOf((char)((Number)tree.value).intValue())) + 95.28 "\'"); 95.29 break; 95.30 - case TypeTags.BOOLEAN: 95.31 + case BOOLEAN: 95.32 print(((Number)tree.value).intValue() == 1 ? "true" : "false"); 95.33 break; 95.34 - case TypeTags.BOT: 95.35 + case BOT: 95.36 print("null"); 95.37 break; 95.38 default: 95.39 @@ -1169,31 +1169,31 @@ 95.40 public void visitTypeIdent(JCPrimitiveTypeTree tree) { 95.41 try { 95.42 switch(tree.typetag) { 95.43 - case TypeTags.BYTE: 95.44 + case BYTE: 95.45 print("byte"); 95.46 break; 95.47 - case TypeTags.CHAR: 95.48 + case CHAR: 95.49 print("char"); 95.50 break; 95.51 - case TypeTags.SHORT: 95.52 + case SHORT: 95.53 print("short"); 95.54 break; 95.55 - case TypeTags.INT: 95.56 + case INT: 95.57 print("int"); 95.58 break; 95.59 - case TypeTags.LONG: 95.60 + case LONG: 95.61 print("long"); 95.62 break; 95.63 - case TypeTags.FLOAT: 95.64 + case FLOAT: 95.65 print("float"); 95.66 break; 95.67 - case TypeTags.DOUBLE: 95.68 + case DOUBLE: 95.69 print("double"); 95.70 break; 95.71 - case TypeTags.BOOLEAN: 95.72 + case BOOLEAN: 95.73 print("boolean"); 95.74 break; 95.75 - case TypeTags.VOID: 95.76 + case VOID: 95.77 print("void"); 95.78 break; 95.79 default:
96.1 --- a/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java Thu Nov 01 14:13:13 2012 -0700 96.2 +++ b/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java Fri Nov 02 17:55:34 2012 -0700 96.3 @@ -34,6 +34,7 @@ 96.4 import com.sun.tools.javac.util.*; 96.5 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; 96.6 import static com.sun.tools.javac.code.Flags.*; 96.7 +import static com.sun.tools.javac.code.TypeTag.BOT; 96.8 import static com.sun.tools.javac.tree.JCTree.Tag.*; 96.9 import static com.sun.tools.javac.tree.JCTree.Tag.BLOCK; 96.10 import static com.sun.tools.javac.tree.JCTree.Tag.SYNCHRONIZED; 96.11 @@ -300,7 +301,7 @@ 96.12 if (!tree.hasTag(LITERAL)) 96.13 return false; 96.14 JCLiteral lit = (JCLiteral) tree; 96.15 - return (lit.typetag == TypeTags.BOT); 96.16 + return (lit.typetag == BOT); 96.17 } 96.18 96.19 public static String getCommentText(Env<?> env, JCTree tree) {
97.1 --- a/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java Thu Nov 01 14:13:13 2012 -0700 97.2 +++ b/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java Fri Nov 02 17:55:34 2012 -0700 97.3 @@ -35,7 +35,7 @@ 97.4 97.5 import static com.sun.tools.javac.code.Flags.*; 97.6 import static com.sun.tools.javac.code.Kinds.*; 97.7 -import static com.sun.tools.javac.code.TypeTags.*; 97.8 +import static com.sun.tools.javac.code.TypeTag.*; 97.9 97.10 /** Factory class for trees. 97.11 * 97.12 @@ -426,13 +426,13 @@ 97.13 return tree; 97.14 } 97.15 97.16 - public JCLiteral Literal(int tag, Object value) { 97.17 + public JCLiteral Literal(TypeTag tag, Object value) { 97.18 JCLiteral tree = new JCLiteral(tag, value); 97.19 tree.pos = pos; 97.20 return tree; 97.21 } 97.22 97.23 - public JCPrimitiveTypeTree TypeIdent(int typetag) { 97.24 + public JCPrimitiveTypeTree TypeIdent(TypeTag typetag) { 97.25 JCPrimitiveTypeTree tree = new JCPrimitiveTypeTree(typetag); 97.26 tree.pos = pos; 97.27 return tree; 97.28 @@ -629,10 +629,10 @@ 97.29 public JCExpression Type(Type t) { 97.30 if (t == null) return null; 97.31 JCExpression tp; 97.32 - switch (t.tag) { 97.33 + switch (t.getTag()) { 97.34 case BYTE: case CHAR: case SHORT: case INT: case LONG: case FLOAT: 97.35 case DOUBLE: case BOOLEAN: case VOID: 97.36 - tp = TypeIdent(t.tag); 97.37 + tp = TypeIdent(t.getTag()); 97.38 break; 97.39 case TYPEVAR: 97.40 tp = Ident(t.tsym); 97.41 @@ -644,7 +644,7 @@ 97.42 } 97.43 case CLASS: 97.44 Type outer = t.getEnclosingType(); 97.45 - JCExpression clazz = outer.tag == CLASS && t.tsym.owner.kind == TYP 97.46 + JCExpression clazz = outer.hasTag(CLASS) && t.tsym.owner.kind == TYP 97.47 ? Select(Type(outer), t.tsym) 97.48 : QualIdent(t.tsym); 97.49 tp = t.getTypeArguments().isEmpty() 97.50 @@ -849,7 +849,7 @@ 97.51 * depending on whether the method invocation expression's type is void. 97.52 */ 97.53 public JCStatement Call(JCExpression apply) { 97.54 - return apply.type.tag == VOID ? Exec(apply) : Return(apply); 97.55 + return apply.type.hasTag(VOID) ? Exec(apply) : Return(apply); 97.56 } 97.57 97.58 /** Construct an assignment from a variable symbol and a right hand side.
98.1 --- a/src/share/classes/com/sun/tools/javac/util/Constants.java Thu Nov 01 14:13:13 2012 -0700 98.2 +++ b/src/share/classes/com/sun/tools/javac/util/Constants.java Fri Nov 02 17:55:34 2012 -0700 98.3 @@ -1,5 +1,5 @@ 98.4 /* 98.5 - * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. 98.6 + * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. 98.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 98.8 * 98.9 * This code is free software; you can redistribute it and/or modify it 98.10 @@ -27,8 +27,6 @@ 98.11 98.12 import com.sun.tools.javac.code.Type; 98.13 98.14 -import static com.sun.tools.javac.code.TypeTags.*; 98.15 - 98.16 /** 98.17 * Utilities for operating on constant values. 98.18 * 98.19 @@ -48,7 +46,7 @@ 98.20 public static Object decode(Object value, Type type) { 98.21 if (value instanceof Integer) { 98.22 int i = (Integer) value; 98.23 - switch (type.tag) { 98.24 + switch (type.getTag()) { 98.25 case BOOLEAN: return i != 0; 98.26 case CHAR: return (char) i; 98.27 case BYTE: return (byte) i; 98.28 @@ -64,7 +62,7 @@ 98.29 */ 98.30 public static String format(Object value, Type type) { 98.31 value = decode(value, type); 98.32 - switch (type.tag) { 98.33 + switch (type.getTag()) { 98.34 case BYTE: return formatByte((Byte) value); 98.35 case LONG: return formatLong((Long) value); 98.36 case FLOAT: return formatFloat((Float) value);
99.1 --- a/src/share/classes/com/sun/tools/javac/util/Names.java Thu Nov 01 14:13:13 2012 -0700 99.2 +++ b/src/share/classes/com/sun/tools/javac/util/Names.java Fri Nov 02 17:55:34 2012 -0700 99.3 @@ -170,6 +170,10 @@ 99.4 public final Name ex; 99.5 public final Name package_info; 99.6 99.7 + //lambda-related 99.8 + public final Name lambda; 99.9 + public final Name metaFactory; 99.10 + 99.11 public final Name.Table table; 99.12 99.13 public Names(Context context) { 99.14 @@ -298,6 +302,10 @@ 99.15 deprecated = fromString("deprecated"); 99.16 ex = fromString("ex"); 99.17 package_info = fromString("package-info"); 99.18 + 99.19 + //lambda-related 99.20 + lambda = fromString("lambda"); 99.21 + metaFactory = fromString("metaFactory"); 99.22 } 99.23 99.24 protected Name.Table createTable(Options options) {
100.1 --- a/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java Thu Nov 01 14:13:13 2012 -0700 100.2 +++ b/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java Fri Nov 02 17:55:34 2012 -0700 100.3 @@ -39,7 +39,7 @@ 100.4 import com.sun.tools.javac.code.Type.*; 100.5 import com.sun.tools.javac.code.Types; 100.6 100.7 -import static com.sun.tools.javac.code.TypeTags.*; 100.8 +import static com.sun.tools.javac.code.TypeTag.*; 100.9 import static com.sun.tools.javac.code.Flags.*; 100.10 import static com.sun.tools.javac.util.LayoutCharacters.*; 100.11 import static com.sun.tools.javac.util.RichDiagnosticFormatter.RichConfiguration.*; 100.12 @@ -295,7 +295,7 @@ 100.13 conflicts.contains(s))) { 100.14 List<Name> l = List.nil(); 100.15 Symbol s2 = s; 100.16 - while (s2.type.getEnclosingType().tag == CLASS 100.17 + while (s2.type.getEnclosingType().hasTag(CLASS) 100.18 && s2.owner.kind == Kinds.TYP) { 100.19 l = l.prepend(s2.getSimpleName()); 100.20 s2 = s2.owner; 100.21 @@ -414,7 +414,7 @@ 100.22 ? ownerName 100.23 : s.name.toString(); 100.24 if (s.type != null) { 100.25 - if (s.type.tag == FORALL) { 100.26 + if (s.type.hasTag(FORALL)) { 100.27 ms = "<" + visitTypes(s.type.getTypeArguments(), locale) + ">" + ms; 100.28 } 100.29 ms += "(" + printMethodArgs( 100.30 @@ -532,8 +532,8 @@ 100.31 nameSimplifier.addUsage(t.tsym); 100.32 100.33 boolean boundErroneous = bounds.head == null || 100.34 - bounds.head.tag == NONE || 100.35 - bounds.head.tag == ERROR; 100.36 + bounds.head.hasTag(NONE) || 100.37 + bounds.head.hasTag(ERROR); 100.38 100.39 if ((t.tsym.flags() & SYNTHETIC) == 0) { 100.40 //this is a true typevar
101.1 --- a/src/share/classes/com/sun/tools/javadoc/AnnotationValueImpl.java Thu Nov 01 14:13:13 2012 -0700 101.2 +++ b/src/share/classes/com/sun/tools/javadoc/AnnotationValueImpl.java Fri Nov 02 17:55:34 2012 -0700 101.3 @@ -29,8 +29,8 @@ 101.4 101.5 import com.sun.tools.javac.code.Attribute; 101.6 import com.sun.tools.javac.code.Symbol.*; 101.7 -import com.sun.tools.javac.code.TypeTags; 101.8 101.9 +import static com.sun.tools.javac.code.TypeTag.BOOLEAN; 101.10 101.11 /** 101.12 * Represents a value of an annotation type element. 101.13 @@ -76,7 +76,7 @@ 101.14 public Object value; 101.15 101.16 public void visitConstant(Attribute.Constant c) { 101.17 - if (c.type.tag == TypeTags.BOOLEAN) { 101.18 + if (c.type.hasTag(BOOLEAN)) { 101.19 // javac represents false and true as integers 0 and 1 101.20 value = Boolean.valueOf( 101.21 ((Integer)c.value).intValue() != 0); 101.22 @@ -133,7 +133,7 @@ 101.23 } 101.24 101.25 public void visitConstant(Attribute.Constant c) { 101.26 - if (c.type.tag == TypeTags.BOOLEAN) { 101.27 + if (c.type.hasTag(BOOLEAN)) { 101.28 // javac represents false and true as integers 0 and 1 101.29 sb.append(((Integer)c.value).intValue() != 0); 101.30 } else {
102.1 --- a/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java Thu Nov 01 14:13:13 2012 -0700 102.2 +++ b/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java Fri Nov 02 17:55:34 2012 -0700 102.3 @@ -45,7 +45,6 @@ 102.4 import com.sun.tools.javac.code.Symbol.*; 102.5 import com.sun.tools.javac.code.Type; 102.6 import com.sun.tools.javac.code.Type.ClassType; 102.7 -import com.sun.tools.javac.code.TypeTags; 102.8 102.9 import com.sun.tools.javac.comp.AttrContext; 102.10 import com.sun.tools.javac.comp.Env; 102.11 @@ -63,6 +62,7 @@ 102.12 import com.sun.tools.javac.util.Position; 102.13 102.14 import static com.sun.tools.javac.code.Kinds.*; 102.15 +import static com.sun.tools.javac.code.TypeTag.CLASS; 102.16 import static com.sun.tools.javac.tree.JCTree.Tag.*; 102.17 102.18 /** 102.19 @@ -164,7 +164,7 @@ 102.20 if (isEnum() || isInterface() || isAnnotationType()) { 102.21 return false; 102.22 } 102.23 - for (Type t = type; t.tag == TypeTags.CLASS; t = env.types.supertype(t)) { 102.24 + for (Type t = type; t.hasTag(CLASS); t = env.types.supertype(t)) { 102.25 if (t.tsym == env.syms.errorType.tsym || 102.26 t.tsym == env.syms.exceptionType.tsym) { 102.27 return false; 102.28 @@ -201,7 +201,7 @@ 102.29 if (isEnum() || isInterface() || isAnnotationType()) { 102.30 return false; 102.31 } 102.32 - for (Type t = type; t.tag == TypeTags.CLASS; t = env.types.supertype(t)) { 102.33 + for (Type t = type; t.hasTag(CLASS); t = env.types.supertype(t)) { 102.34 if (t.tsym == env.syms.exceptionType.tsym) { 102.35 return true; 102.36 } 102.37 @@ -217,7 +217,7 @@ 102.38 if (isEnum() || isInterface() || isAnnotationType()) { 102.39 return false; 102.40 } 102.41 - for (Type t = type; t.tag == TypeTags.CLASS; t = env.types.supertype(t)) { 102.42 + for (Type t = type; t.hasTag(CLASS); t = env.types.supertype(t)) { 102.43 if (t.tsym == env.syms.errorType.tsym) { 102.44 return true; 102.45 } 102.46 @@ -232,7 +232,7 @@ 102.47 if (isEnum() || isInterface() || isAnnotationType()) { 102.48 return false; 102.49 } 102.50 - for (Type t = type; t.tag == TypeTags.CLASS; t = env.types.supertype(t)) { 102.51 + for (Type t = type; t.hasTag(CLASS); t = env.types.supertype(t)) { 102.52 if (t.tsym == env.syms.throwableType.tsym) { 102.53 return true; 102.54 }
103.1 --- a/src/share/classes/com/sun/tools/javadoc/FieldDocImpl.java Thu Nov 01 14:13:13 2012 -0700 103.2 +++ b/src/share/classes/com/sun/tools/javadoc/FieldDocImpl.java Fri Nov 02 17:55:34 2012 -0700 103.3 @@ -32,12 +32,13 @@ 103.4 import com.sun.tools.javac.code.Flags; 103.5 import com.sun.tools.javac.code.Symbol.ClassSymbol; 103.6 import com.sun.tools.javac.code.Symbol.VarSymbol; 103.7 -import com.sun.tools.javac.code.TypeTags; 103.8 103.9 import com.sun.tools.javac.tree.JCTree.JCVariableDecl; 103.10 103.11 import com.sun.tools.javac.util.Position; 103.12 103.13 +import static com.sun.tools.javac.code.TypeTag.BOOLEAN; 103.14 + 103.15 /** 103.16 * Represents a field in a java class. 103.17 * 103.18 @@ -103,7 +104,7 @@ 103.19 */ 103.20 public Object constantValue() { 103.21 Object result = sym.getConstValue(); 103.22 - if (result != null && sym.type.tag == TypeTags.BOOLEAN) 103.23 + if (result != null && sym.type.hasTag(BOOLEAN)) 103.24 // javac represents false and true as Integers 0 and 1 103.25 result = Boolean.valueOf(((Integer)result).intValue() != 0); 103.26 return result;
104.1 --- a/src/share/classes/com/sun/tools/javadoc/MethodDocImpl.java Thu Nov 01 14:13:13 2012 -0700 104.2 +++ b/src/share/classes/com/sun/tools/javadoc/MethodDocImpl.java Fri Nov 02 17:55:34 2012 -0700 104.3 @@ -31,10 +31,11 @@ 104.4 import com.sun.tools.javac.code.*; 104.5 import com.sun.tools.javac.code.Symbol.*; 104.6 import com.sun.tools.javac.code.Type; 104.7 -import com.sun.tools.javac.code.TypeTags; 104.8 import com.sun.tools.javac.tree.JCTree.JCMethodDecl; 104.9 import com.sun.tools.javac.util.Position; 104.10 104.11 +import static com.sun.tools.javac.code.TypeTag.CLASS; 104.12 + 104.13 /** 104.14 * Represents a method of a java class. 104.15 * 104.16 @@ -129,7 +130,7 @@ 104.17 104.18 ClassSymbol origin = (ClassSymbol)sym.owner; 104.19 for (Type t = env.types.supertype(origin.type); 104.20 - t.tag == TypeTags.CLASS; 104.21 + t.hasTag(CLASS); 104.22 t = env.types.supertype(t)) { 104.23 ClassSymbol c = (ClassSymbol)t.tsym; 104.24 for (Scope.Entry e = c.members().lookup(sym.name); e.scope != null; e = e.next()) { 104.25 @@ -161,7 +162,7 @@ 104.26 104.27 ClassSymbol origin = (ClassSymbol)sym.owner; 104.28 for (Type t = env.types.supertype(origin.type); 104.29 - t.tag == TypeTags.CLASS; 104.30 + t.hasTag(CLASS); 104.31 t = env.types.supertype(t)) { 104.32 ClassSymbol c = (ClassSymbol)t.tsym; 104.33 for (Scope.Entry e = c.members().lookup(sym.name); e.scope != null; e = e.next()) {
105.1 --- a/src/share/classes/com/sun/tools/javadoc/ParameterizedTypeImpl.java Thu Nov 01 14:13:13 2012 -0700 105.2 +++ b/src/share/classes/com/sun/tools/javadoc/ParameterizedTypeImpl.java Fri Nov 02 17:55:34 2012 -0700 105.3 @@ -31,7 +31,7 @@ 105.4 import com.sun.tools.javac.code.Type; 105.5 import com.sun.tools.javac.code.Type.ClassType; 105.6 105.7 -import static com.sun.tools.javac.code.TypeTags.*; 105.8 +import static com.sun.tools.javac.code.TypeTag.CLASS; 105.9 105.10 105.11 /** 105.12 @@ -95,7 +95,7 @@ 105.13 * Return null is this is a top-level type. 105.14 */ 105.15 public com.sun.javadoc.Type containingType() { 105.16 - if (type.getEnclosingType().tag == CLASS) { 105.17 + if (type.getEnclosingType().hasTag(CLASS)) { 105.18 // This is the type of an inner class. 105.19 return TypeMaker.getType(env, type.getEnclosingType()); 105.20 } 105.21 @@ -134,7 +134,7 @@ 105.22 return TypeMaker.getTypeName(cl, full); 105.23 } 105.24 StringBuilder s = new StringBuilder(); 105.25 - if (cl.getEnclosingType().tag != CLASS) { // if not an inner class... 105.26 + if (!(cl.getEnclosingType().hasTag(CLASS))) { // if not an inner class... 105.27 s.append(TypeMaker.getTypeName(cl, full)); 105.28 } else { 105.29 ClassType encl = (ClassType)cl.getEnclosingType();
106.1 --- a/src/share/classes/com/sun/tools/javadoc/SerializedForm.java Thu Nov 01 14:13:13 2012 -0700 106.2 +++ b/src/share/classes/com/sun/tools/javadoc/SerializedForm.java Fri Nov 02 17:55:34 2012 -0700 106.3 @@ -237,6 +237,9 @@ 106.4 106.5 SerialFieldTag[] sfTag = spfDoc.serialFieldTags(); 106.6 for (int i = 0; i < sfTag.length; i++) { 106.7 + if (sfTag[i].fieldName() == null || sfTag[i].fieldType() == null) // ignore malformed @serialField tags 106.8 + continue; 106.9 + 106.10 Name fieldName = names.fromString(sfTag[i].fieldName()); 106.11 106.12 // Look for a FieldDocImpl that is documented by serialFieldTagImpl.
107.1 --- a/src/share/classes/com/sun/tools/javadoc/TypeMaker.java Thu Nov 01 14:13:13 2012 -0700 107.2 +++ b/src/share/classes/com/sun/tools/javadoc/TypeMaker.java Fri Nov 02 17:55:34 2012 -0700 107.3 @@ -33,7 +33,7 @@ 107.4 import com.sun.tools.javac.code.Type.ClassType; 107.5 import com.sun.tools.javac.code.Type.TypeVar; 107.6 import com.sun.tools.javac.util.List; 107.7 -import static com.sun.tools.javac.code.TypeTags.*; 107.8 +import static com.sun.tools.javac.code.TypeTag.ARRAY; 107.9 107.10 /** 107.11 * <p><b>This is NOT part of any supported API. 107.12 @@ -57,7 +57,7 @@ 107.13 if (env.legacyDoclet) { 107.14 t = env.types.erasure(t); 107.15 } 107.16 - switch (t.tag) { 107.17 + switch (t.getTag()) { 107.18 case CLASS: 107.19 if (ClassDocImpl.isGeneric((ClassSymbol)t.tsym)) { 107.20 return env.getParameterizedType((ClassType)t); 107.21 @@ -107,10 +107,10 @@ 107.22 } 107.23 107.24 public static String getTypeName(Type t, boolean full) { 107.25 - switch (t.tag) { 107.26 + switch (t.getTag()) { 107.27 case ARRAY: 107.28 StringBuilder s = new StringBuilder(); 107.29 - while (t.tag == ARRAY) { 107.30 + while (t.hasTag(ARRAY)) { 107.31 s.append("[]"); 107.32 t = ((ArrayType)t).elemtype; 107.33 } 107.34 @@ -129,10 +129,10 @@ 107.35 * Class names are qualified if "full" is true. 107.36 */ 107.37 static String getTypeString(DocEnv env, Type t, boolean full) { 107.38 - switch (t.tag) { 107.39 + switch (t.getTag()) { 107.40 case ARRAY: 107.41 StringBuilder s = new StringBuilder(); 107.42 - while (t.tag == ARRAY) { 107.43 + while (t.hasTag(ARRAY)) { 107.44 s.append("[]"); 107.45 t = env.types.elemtype(t); 107.46 } 107.47 @@ -203,7 +203,7 @@ 107.48 private com.sun.javadoc.Type skipArrays() { 107.49 if (skipArraysCache == null) { 107.50 Type t; 107.51 - for (t = arrayType; t.tag == ARRAY; t = env.types.elemtype(t)) { } 107.52 + for (t = arrayType; t.hasTag(ARRAY); t = env.types.elemtype(t)) { } 107.53 skipArraysCache = TypeMaker.getType(env, t); 107.54 } 107.55 return skipArraysCache; 107.56 @@ -216,7 +216,7 @@ 107.57 */ 107.58 public String dimension() { 107.59 StringBuilder dimension = new StringBuilder(); 107.60 - for (Type t = arrayType; t.tag == ARRAY; t = env.types.elemtype(t)) { 107.61 + for (Type t = arrayType; t.hasTag(ARRAY); t = env.types.elemtype(t)) { 107.62 dimension.append("[]"); 107.63 } 107.64 return dimension.toString();
108.1 --- a/src/share/classes/com/sun/tools/javah/JavahFileManager.java Thu Nov 01 14:13:13 2012 -0700 108.2 +++ b/src/share/classes/com/sun/tools/javah/JavahFileManager.java Fri Nov 02 17:55:34 2012 -0700 108.3 @@ -1,5 +1,5 @@ 108.4 /* 108.5 - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. 108.6 + * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved. 108.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 108.8 * 108.9 * This code is free software; you can redistribute it and/or modify it 108.10 @@ -44,7 +44,7 @@ 108.11 class JavahFileManager extends JavacFileManager { 108.12 private JavahFileManager(Context context, Charset charset) { 108.13 super(context, true, charset); 108.14 - setIgnoreSymbolFile(true); 108.15 + setSymbolFileEnabled(false); 108.16 } 108.17 108.18 static JavahFileManager create(final DiagnosticListener<? super JavaFileObject> dl, PrintWriter log) { 108.19 @@ -56,8 +56,4 @@ 108.20 108.21 return new JavahFileManager(javac_context, null); 108.22 } 108.23 - 108.24 - void setIgnoreSymbolFile(boolean b) { 108.25 - ignoreSymbolFile = b; 108.26 - } 108.27 }
109.1 --- a/src/share/classes/com/sun/tools/javah/JavahTask.java Thu Nov 01 14:13:13 2012 -0700 109.2 +++ b/src/share/classes/com/sun/tools/javah/JavahTask.java Fri Nov 02 17:55:34 2012 -0700 109.3 @@ -500,7 +500,7 @@ 109.4 g.setForce(force); 109.5 109.6 if (fileManager instanceof JavahFileManager) 109.7 - ((JavahFileManager) fileManager).setIgnoreSymbolFile(true); 109.8 + ((JavahFileManager) fileManager).setSymbolFileEnabled(false); 109.9 109.10 JavaCompiler c = ToolProvider.getSystemJavaCompiler(); 109.11 List<String> opts = new ArrayList<String>();
110.1 --- a/src/share/classes/com/sun/tools/javap/JavapFileManager.java Thu Nov 01 14:13:13 2012 -0700 110.2 +++ b/src/share/classes/com/sun/tools/javap/JavapFileManager.java Fri Nov 02 17:55:34 2012 -0700 110.3 @@ -1,5 +1,5 @@ 110.4 /* 110.5 - * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. 110.6 + * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved. 110.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 110.8 * 110.9 * This code is free software; you can redistribute it and/or modify it 110.10 @@ -44,7 +44,7 @@ 110.11 public class JavapFileManager extends JavacFileManager { 110.12 private JavapFileManager(Context context, Charset charset) { 110.13 super(context, true, charset); 110.14 - setIgnoreSymbolFile(true); 110.15 + setSymbolFileEnabled(false); 110.16 } 110.17 110.18 public static JavapFileManager create(final DiagnosticListener<? super JavaFileObject> dl, PrintWriter log) { 110.19 @@ -56,8 +56,4 @@ 110.20 110.21 return new JavapFileManager(javac_context, null); 110.22 } 110.23 - 110.24 - void setIgnoreSymbolFile(boolean b) { 110.25 - ignoreSymbolFile = b; 110.26 - } 110.27 }
111.1 --- a/test/com/sun/javadoc/testDocFileDir/TestDocFileDir.java Thu Nov 01 14:13:13 2012 -0700 111.2 +++ b/test/com/sun/javadoc/testDocFileDir/TestDocFileDir.java Fri Nov 02 17:55:34 2012 -0700 111.3 @@ -1,5 +1,5 @@ 111.4 /* 111.5 - * Copyright (c) 2002, 2004, Oracle and/or its affiliates. All rights reserved. 111.6 + * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. 111.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 111.8 * 111.9 * This code is free software; you can redistribute it and/or modify it 111.10 @@ -77,17 +77,19 @@ 111.11 //Output dir = Input Dir 111.12 private static final String[] ARGS1 = 111.13 new String[] { 111.14 - "-d", BUG_ID + "-1", "-sourcepath", 111.15 - "blah" + String.valueOf(File.pathSeparatorChar) + 111.16 - BUG_ID + "-1" + String.valueOf(File.pathSeparatorChar) + 111.17 - "blah", "pkg"}; 111.18 + "-d", BUG_ID + "-1", 111.19 + "-sourcepath", 111.20 + "blah" + File.pathSeparator + BUG_ID + "-1" + File.pathSeparator + "blah", 111.21 + "pkg"}; 111.22 111.23 //Exercising -docfilessubdirs and -excludedocfilessubdir 111.24 private static final String[] ARGS2 = 111.25 new String[] { 111.26 - "-d", BUG_ID + "-2", "-sourcepath", SRC_DIR, 111.27 - "-docfilessubdirs", "-excludedocfilessubdir", 111.28 - "subdir-excluded1:subdir-excluded2", "pkg"}; 111.29 + "-d", BUG_ID + "-2", 111.30 + "-sourcepath", SRC_DIR, 111.31 + "-docfilessubdirs", 111.32 + "-excludedocfilessubdir", "subdir-excluded1:subdir-excluded2", 111.33 + "pkg"}; 111.34 111.35 //Output dir = "", Input dir = "" 111.36 private static final String[] ARGS0 =
112.1 --- a/test/com/sun/javadoc/testIndex/TestIndex.java Thu Nov 01 14:13:13 2012 -0700 112.2 +++ b/test/com/sun/javadoc/testIndex/TestIndex.java Fri Nov 02 17:55:34 2012 -0700 112.3 @@ -1,5 +1,5 @@ 112.4 /* 112.5 - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 112.6 + * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. 112.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 112.8 * 112.9 * This code is free software; you can redistribute it and/or modify it 112.10 @@ -53,28 +53,28 @@ 112.11 112.12 //Test index-all.html 112.13 {BUG_ID + FS + "index-all.html", 112.14 - "<a href=\"./pkg/C.html\" title=\"class in pkg\"><span class=\"strong\">C</span></a>" + 112.15 - " - Class in <a href=\"./pkg/package-summary.html\">pkg</a>"}, 112.16 + "<a href=\"pkg/C.html\" title=\"class in pkg\"><span class=\"strong\">C</span></a>" + 112.17 + " - Class in <a href=\"pkg/package-summary.html\">pkg</a>"}, 112.18 {BUG_ID + FS + "index-all.html", 112.19 - "<a href=\"./pkg/Interface.html\" title=\"interface in pkg\">" + 112.20 + "<a href=\"pkg/Interface.html\" title=\"interface in pkg\">" + 112.21 "<span class=\"strong\">Interface</span></a> - Interface in " + 112.22 - "<a href=\"./pkg/package-summary.html\">pkg</a>"}, 112.23 + "<a href=\"pkg/package-summary.html\">pkg</a>"}, 112.24 {BUG_ID + FS + "index-all.html", 112.25 - "<a href=\"./pkg/AnnotationType.html\" title=\"annotation in pkg\">" + 112.26 + "<a href=\"pkg/AnnotationType.html\" title=\"annotation in pkg\">" + 112.27 "<span class=\"strong\">AnnotationType</span></a> - Annotation Type in " + 112.28 - "<a href=\"./pkg/package-summary.html\">pkg</a>"}, 112.29 + "<a href=\"pkg/package-summary.html\">pkg</a>"}, 112.30 {BUG_ID + FS + "index-all.html", 112.31 - "<a href=\"./pkg/Coin.html\" title=\"enum in pkg\">" + 112.32 + "<a href=\"pkg/Coin.html\" title=\"enum in pkg\">" + 112.33 "<span class=\"strong\">Coin</span></a> - Enum in " + 112.34 - "<a href=\"./pkg/package-summary.html\">pkg</a>"}, 112.35 + "<a href=\"pkg/package-summary.html\">pkg</a>"}, 112.36 {BUG_ID + FS + "index-all.html", 112.37 - "Class in <a href=\"./package-summary.html\"><Unnamed></a>"}, 112.38 + "Class in <a href=\"package-summary.html\"><Unnamed></a>"}, 112.39 {BUG_ID + FS + "index-all.html", 112.40 - "<dl>" + NL + "<dt><span class=\"strong\"><a href=\"./pkg/C.html#Java\">" + 112.41 - "Java</a></span> - Static variable in class pkg.<a href=\"./pkg/C.html\" " + 112.42 + "<dl>" + NL + "<dt><span class=\"strong\"><a href=\"pkg/C.html#Java\">" + 112.43 + "Java</a></span> - Static variable in class pkg.<a href=\"pkg/C.html\" " + 112.44 "title=\"class in pkg\">C</a></dt>" + NL + "<dd> </dd>" + NL + 112.45 - "<dt><span class=\"strong\"><a href=\"./pkg/C.html#JDK\">JDK</a></span> " + 112.46 - "- Static variable in class pkg.<a href=\"./pkg/C.html\" title=\"class in pkg\">" + 112.47 + "<dt><span class=\"strong\"><a href=\"pkg/C.html#JDK\">JDK</a></span> " + 112.48 + "- Static variable in class pkg.<a href=\"pkg/C.html\" title=\"class in pkg\">" + 112.49 "C</a></dt>" + NL + "<dd> </dd>" + NL + "</dl>"}, 112.50 }; 112.51 private static final String[][] NEGATED_TEST = NO_TEST;
113.1 --- a/test/com/sun/javadoc/testNewLanguageFeatures/TestNewLanguageFeatures.java Thu Nov 01 14:13:13 2012 -0700 113.2 +++ b/test/com/sun/javadoc/testNewLanguageFeatures/TestNewLanguageFeatures.java Fri Nov 02 17:55:34 2012 -0700 113.3 @@ -1,5 +1,5 @@ 113.4 /* 113.5 - * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. 113.6 + * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. 113.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 113.8 * 113.9 * This code is free software; you can redistribute it and/or modify it 113.10 @@ -663,14 +663,14 @@ 113.11 // TYPE PARAMETER IN INDEX 113.12 //================================= 113.13 {BUG_ID + FS + "index-all.html", 113.14 - "<span class=\"strong\"><a href=\"./pkg2/Foo.html#method(java.util.Vector)\">" + 113.15 + "<span class=\"strong\"><a href=\"pkg2/Foo.html#method(java.util.Vector)\">" + 113.16 "method(Vector<Object>)</a></span>" 113.17 }, 113.18 //================================= 113.19 // TYPE PARAMETER IN INDEX 113.20 //================================= 113.21 {BUG_ID + FS + "index-all.html", 113.22 - "<span class=\"strong\"><a href=\"./pkg2/Foo.html#method(java.util.Vector)\">" + 113.23 + "<span class=\"strong\"><a href=\"pkg2/Foo.html#method(java.util.Vector)\">" + 113.24 "method(Vector<Object>)</a></span>" 113.25 }, 113.26 };
114.1 --- a/test/com/sun/javadoc/testPackagePage/TestPackagePage.java Thu Nov 01 14:13:13 2012 -0700 114.2 +++ b/test/com/sun/javadoc/testPackagePage/TestPackagePage.java Fri Nov 02 17:55:34 2012 -0700 114.3 @@ -1,5 +1,5 @@ 114.4 /* 114.5 - * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. 114.6 + * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. 114.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 114.8 * 114.9 * This code is free software; you can redistribute it and/or modify it 114.10 @@ -52,7 +52,7 @@ 114.11 "<li><a href=\"com/pkg/package-summary.html\">Package</a></li>" 114.12 }, 114.13 {BUG_ID + "-1" + FS + "index-all.html", 114.14 - "<li><a href=\"./com/pkg/package-summary.html\">Package</a></li>" 114.15 + "<li><a href=\"com/pkg/package-summary.html\">Package</a></li>" 114.16 }, 114.17 {BUG_ID + "-1" + FS + "help-doc.html", 114.18 "<li><a href=\"com/pkg/package-summary.html\">Package</a></li>"
115.1 --- a/test/tools/javac/6889255/T6889255.java Thu Nov 01 14:13:13 2012 -0700 115.2 +++ b/test/tools/javac/6889255/T6889255.java Fri Nov 02 17:55:34 2012 -0700 115.3 @@ -1,5 +1,5 @@ 115.4 /* 115.5 - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. 115.6 + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. 115.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 115.8 * 115.9 * This code is free software; you can redistribute it and/or modify it 115.10 @@ -36,7 +36,7 @@ 115.11 import com.sun.tools.javac.code.Symbol.*; 115.12 import com.sun.tools.javac.code.Type; 115.13 import com.sun.tools.javac.code.Type.ClassType; 115.14 -import com.sun.tools.javac.code.TypeTags; 115.15 +import com.sun.tools.javac.code.TypeTag; 115.16 import com.sun.tools.javac.file.JavacFileManager; 115.17 import com.sun.tools.javac.jvm.ClassReader; 115.18 import com.sun.tools.javac.util.Context; 115.19 @@ -436,7 +436,7 @@ 115.20 // The rest of this method assumes the local conventions in the test program 115.21 Type t = v.type; 115.22 String s; 115.23 - if (t.tag == TypeTags.CLASS) 115.24 + if (t.hasTag(TypeTag.CLASS)) 115.25 s = ((ClassType) t).tsym.name.toString(); 115.26 else 115.27 s = t.toString();
116.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 116.2 +++ b/test/tools/javac/Paths/TestCompileJARInClassPath.java Fri Nov 02 17:55:34 2012 -0700 116.3 @@ -0,0 +1,132 @@ 116.4 +/* 116.5 + * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. 116.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 116.7 + * 116.8 + * This code is free software; you can redistribute it and/or modify it 116.9 + * under the terms of the GNU General Public License version 2 only, as 116.10 + * published by the Free Software Foundation. 116.11 + * 116.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 116.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 116.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 116.15 + * version 2 for more details (a copy is included in the LICENSE file that 116.16 + * accompanied this code). 116.17 + * 116.18 + * You should have received a copy of the GNU General Public License version 116.19 + * 2 along with this work; if not, write to the Free Software Foundation, 116.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 116.21 + * 116.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 116.23 + * or visit www.oracle.com if you need additional information or have any 116.24 + * questions. 116.25 + */ 116.26 + 116.27 +/* 116.28 + * @test 116.29 + * @bug 6725230 116.30 + * @summary Test to make sure that java Compilation with JSR199 does not ignore 116.31 + * Class-Path in manifest 116.32 + * @author vicente.romero 116.33 + * @build TestCompileJARInClassPath 116.34 + * @run main TestCompileJARInClassPath 116.35 + */ 116.36 + 116.37 +import java.io.File; 116.38 +import java.io.FileOutputStream; 116.39 +import java.io.IOException; 116.40 +import java.io.PrintStream; 116.41 +import java.util.ArrayList; 116.42 +import java.util.List; 116.43 +import javax.tools.DiagnosticCollector; 116.44 +import javax.tools.JavaFileObject; 116.45 +import javax.tools.StandardJavaFileManager; 116.46 +import javax.tools.StandardLocation; 116.47 +import javax.tools.ToolProvider; 116.48 + 116.49 +public class TestCompileJARInClassPath { 116.50 + 116.51 + public static void main(String args[]) throws Exception { 116.52 + TestCompileJARInClassPath theTest = new TestCompileJARInClassPath(); 116.53 + theTest.run(); 116.54 + } 116.55 + 116.56 + void run() throws Exception { 116.57 + try { 116.58 + clean(); 116.59 + generateFilesNeeded(); 116.60 + compileWithJSR199(); 116.61 + } finally { 116.62 + clean(); 116.63 + } 116.64 + } 116.65 + 116.66 + void writeFile(String f, String contents) throws IOException { 116.67 + PrintStream s = new PrintStream(new FileOutputStream(f)); 116.68 + s.println(contents); 116.69 + s.close(); 116.70 + } 116.71 + 116.72 + void rm(String filename) throws Exception { 116.73 + File f = new File(filename); 116.74 + f.delete(); 116.75 + if (f.exists()) 116.76 + throw new Exception(filename + ": couldn't remove"); 116.77 + } 116.78 + 116.79 + void clean() throws Exception { 116.80 + rm("C1.java"); 116.81 + rm("C1.class"); 116.82 + rm("C1.jar"); 116.83 + 116.84 + rm("C2.java"); 116.85 + rm("C2.class"); 116.86 + rm("C2.jar"); 116.87 + rm("MANIFEST.MF"); 116.88 + 116.89 + rm("C3.java"); 116.90 + rm("C3.class"); 116.91 + } 116.92 + 116.93 + void generateFilesNeeded() throws Exception { 116.94 + sun.tools.jar.Main jarGenerator = new sun.tools.jar.Main(System.out, System.err, "jar"); 116.95 + 116.96 + writeFile("C1.java", 116.97 + "public class C1 {public static void f() {}}"); 116.98 + com.sun.tools.javac.Main.compile(new String[]{"C1.java"}); 116.99 + jarGenerator.run(new String[] {"cf", "C1.jar", "C1.class"}); 116.100 + 116.101 + writeFile("C2.java", 116.102 + "public class C2 {public static void g() {}}"); 116.103 + writeFile("MANIFEST.MF", 116.104 + "Manifest-Version: 1.0\n" + 116.105 + "Class-Path: C1.jar\n" + 116.106 + "Main-Class: C2"); 116.107 + com.sun.tools.javac.Main.compile(new String[]{"C2.java"}); 116.108 + jarGenerator.run(new String[] {"cfm", "C2.jar", "MANIFEST.MF", "C2.class"}); 116.109 + 116.110 + writeFile("C3.java", 116.111 + "public class C3 {public static void h() {C2.g(); C1.f();}}"); 116.112 + } 116.113 + 116.114 + void compileWithJSR199() throws IOException { 116.115 + String cpath = "C2.jar"; 116.116 + File clientJarFile = new File(cpath); 116.117 + File sourceFileToCompile = new File("C3.java"); 116.118 + 116.119 + 116.120 + javax.tools.JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); 116.121 + DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<>(); 116.122 + StandardJavaFileManager stdFileManager = javac.getStandardFileManager(diagnostics, null, null); 116.123 + 116.124 + List<File> files = new ArrayList<>(); 116.125 + files.add(clientJarFile); 116.126 + 116.127 + stdFileManager.setLocation(StandardLocation.CLASS_PATH, files); 116.128 + 116.129 + Iterable<? extends JavaFileObject> sourceFiles = stdFileManager.getJavaFileObjects(sourceFileToCompile); 116.130 + 116.131 + if (!javac.getTask(null, stdFileManager, diagnostics, null, null, sourceFiles).call()) { 116.132 + throw new AssertionError("compilation failed"); 116.133 + } 116.134 + } 116.135 +}
117.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 117.2 +++ b/test/tools/javac/annotations/repeatingAnnotations/BaseAnnoAsContainerAnno.java Fri Nov 02 17:55:34 2012 -0700 117.3 @@ -0,0 +1,20 @@ 117.4 +/** 117.5 + * @test /nodynamiccopyright/ 117.6 + * @bug 7169362 117.7 + * @author sogoel 117.8 + * @summary Base annotation specify itself as ContainerAnnotation 117.9 + * @compile/fail/ref=BaseAnnoAsContainerAnno.out -XDrawDiagnostics BaseAnnoAsContainerAnno.java 117.10 + */ 117.11 + 117.12 +import java.lang.annotation.ContainedBy; 117.13 +import java.lang.annotation.ContainerFor; 117.14 + 117.15 +@ContainedBy(Foo.class) 117.16 +@ContainerFor(Foo.class) 117.17 +@interface Foo { 117.18 + Foo[] value() default {}; 117.19 +} 117.20 + 117.21 +@Foo() @Foo() 117.22 +public class BaseAnnoAsContainerAnno {} 117.23 +
118.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 118.2 +++ b/test/tools/javac/annotations/repeatingAnnotations/BaseAnnoAsContainerAnno.out Fri Nov 02 17:55:34 2012 -0700 118.3 @@ -0,0 +1,2 @@ 118.4 +BaseAnnoAsContainerAnno.java:15:11: compiler.err.cyclic.annotation.element 118.5 +1 error
119.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 119.2 +++ b/test/tools/javac/annotations/repeatingAnnotations/ClassReaderDefault.java Fri Nov 02 17:55:34 2012 -0700 119.3 @@ -0,0 +1,46 @@ 119.4 +/* 119.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 119.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 119.7 + * 119.8 + * This code is free software; you can redistribute it and/or modify it 119.9 + * under the terms of the GNU General Public License version 2 only, as 119.10 + * published by the Free Software Foundation. 119.11 + * 119.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 119.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 119.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 119.15 + * version 2 for more details (a copy is included in the LICENSE file that 119.16 + * accompanied this code). 119.17 + * 119.18 + * You should have received a copy of the GNU General Public License version 119.19 + * 2 along with this work; if not, write to the Free Software Foundation, 119.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 119.21 + * 119.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 119.23 + * or visit www.oracle.com if you need additional information or have any 119.24 + * questions. 119.25 + */ 119.26 + 119.27 +/** 119.28 + * @test 119.29 + * 119.30 + * @bug 7199925 119.31 + * 119.32 + * @clean ClassReaderDefault SeparateCompile 119.33 + * @compile ClassReaderDefault.java 119.34 + * @compile SeparateCompile.java 119.35 + */ 119.36 +import java.lang.annotation.ContainedBy; 119.37 +import java.lang.annotation.ContainerFor; 119.38 + 119.39 +public class ClassReaderDefault { 119.40 +} 119.41 + 119.42 +@ContainerFor(Foo.class) 119.43 +@interface FooContainer { 119.44 + Foo[] value(); 119.45 + int f() default 0; 119.46 +} 119.47 + 119.48 +@ContainedBy(FooContainer.class) 119.49 +@interface Foo {}
120.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 120.2 +++ b/test/tools/javac/annotations/repeatingAnnotations/CyclicAnnotation.java Fri Nov 02 17:55:34 2012 -0700 120.3 @@ -0,0 +1,26 @@ 120.4 +/** 120.5 + * @test /nodynamiccopyright/ 120.6 + * @bug 7169362 120.7 + * @author sogoel 120.8 + * @summary Cyclic annotation not allowed 120.9 + * @compile/fail/ref=CyclicAnnotation.out -XDrawDiagnostics CyclicAnnotation.java 120.10 + */ 120.11 + 120.12 +import java.lang.annotation.ContainedBy; 120.13 +import java.lang.annotation.ContainerFor; 120.14 + 120.15 +@ContainedBy(Foo.class) 120.16 +@ContainerFor(Baz.class) 120.17 +@interface Baz { 120.18 + Foo[] value() default {}; 120.19 +} 120.20 + 120.21 +@ContainedBy(Baz.class) 120.22 +@ContainerFor(Foo.class) 120.23 +@interface Foo{ 120.24 + Baz[] value() default {}; 120.25 +} 120.26 + 120.27 +@Foo(value = {@Baz,@Baz}) 120.28 +@Baz(value = {@Foo,@Foo}) 120.29 +public class CyclicAnnotation {}
121.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 121.2 +++ b/test/tools/javac/annotations/repeatingAnnotations/CyclicAnnotation.out Fri Nov 02 17:55:34 2012 -0700 121.3 @@ -0,0 +1,6 @@ 121.4 +CyclicAnnotation.java:12:1: compiler.err.invalid.container.wrong.containerfor: Foo, Baz 121.5 +CyclicAnnotation.java:13:1: compiler.err.invalid.container.wrong.containedby: Foo, Baz 121.6 +CyclicAnnotation.java:15:11: compiler.err.cyclic.annotation.element 121.7 +CyclicAnnotation.java:18:1: compiler.err.invalid.container.wrong.containerfor: Baz, Foo 121.8 +CyclicAnnotation.java:19:1: compiler.err.invalid.container.wrong.containedby: Baz, Foo 121.9 +5 errors
122.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 122.2 +++ b/test/tools/javac/annotations/repeatingAnnotations/DefaultCasePresent.java Fri Nov 02 17:55:34 2012 -0700 122.3 @@ -0,0 +1,46 @@ 122.4 +/* 122.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 122.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 122.7 + * 122.8 + * This code is free software; you can redistribute it and/or modify it 122.9 + * under the terms of the GNU General Public License version 2 only, as 122.10 + * published by the Free Software Foundation. 122.11 + * 122.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 122.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 122.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 122.15 + * version 2 for more details (a copy is included in the LICENSE file that 122.16 + * accompanied this code). 122.17 + * 122.18 + * You should have received a copy of the GNU General Public License version 122.19 + * 2 along with this work; if not, write to the Free Software Foundation, 122.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 122.21 + * 122.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 122.23 + * or visit www.oracle.com if you need additional information or have any 122.24 + * questions. 122.25 + */ 122.26 + 122.27 +/** 122.28 + * @test 122.29 + * @bug 7169362 122.30 + * @author sogoel 122.31 + * @summary Default case for methods other than value() in ContainerAnno 122.32 + * @compile DefaultCasePresent.java 122.33 + */ 122.34 + 122.35 +import java.lang.annotation.ContainedBy; 122.36 +import java.lang.annotation.ContainerFor; 122.37 + 122.38 +@ContainedBy(FooContainer.class) 122.39 +@interface Foo {} 122.40 + 122.41 +@ContainerFor(Foo.class) 122.42 +@interface FooContainer { 122.43 + Foo[] value(); 122.44 + String other() default "other-method"; 122.45 +} 122.46 + 122.47 +@Foo @Foo 122.48 +public class DefaultCasePresent {} 122.49 +
123.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 123.2 +++ b/test/tools/javac/annotations/repeatingAnnotations/DocumentedContainerAnno.java Fri Nov 02 17:55:34 2012 -0700 123.3 @@ -0,0 +1,23 @@ 123.4 +/** 123.5 + * @test /nodynamiccopyright/ 123.6 + * @bug 7169362 123.7 + * @author sogoel 123.8 + * @summary Base anno is Documented but Container anno is not 123.9 + * @compile/fail/ref=DocumentedContainerAnno.out -XDrawDiagnostics DocumentedContainerAnno.java 123.10 + */ 123.11 + 123.12 +import java.lang.annotation.ContainedBy; 123.13 +import java.lang.annotation.ContainerFor; 123.14 +import java.lang.annotation.Documented; 123.15 + 123.16 +@Documented 123.17 +@ContainedBy(FooContainer.class) 123.18 +@interface Foo {} 123.19 + 123.20 +@ContainerFor(Foo.class) 123.21 +@interface FooContainer{ 123.22 + Foo[] value(); 123.23 +} 123.24 + 123.25 +@Foo @Foo 123.26 +public class DocumentedContainerAnno {}
124.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 124.2 +++ b/test/tools/javac/annotations/repeatingAnnotations/DocumentedContainerAnno.out Fri Nov 02 17:55:34 2012 -0700 124.3 @@ -0,0 +1,2 @@ 124.4 +DocumentedContainerAnno.java:14:1: compiler.err.invalid.containedby.annotation.not.documented: FooContainer, Foo 124.5 +1 error
125.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 125.2 +++ b/test/tools/javac/annotations/repeatingAnnotations/InheritedContainerAnno.java Fri Nov 02 17:55:34 2012 -0700 125.3 @@ -0,0 +1,24 @@ 125.4 +/** 125.5 + * @test /nodynamiccopyright/ 125.6 + * @bug 7169362 125.7 + * @author sogoel 125.8 + * @summary Base anno is Inherited but Container anno is not 125.9 + * @compile/fail/ref=InheritedContainerAnno.out -XDrawDiagnostics InheritedContainerAnno.java 125.10 + */ 125.11 + 125.12 +import java.lang.annotation.ContainedBy; 125.13 +import java.lang.annotation.ContainerFor; 125.14 +import java.lang.annotation.Inherited; 125.15 + 125.16 +@Inherited 125.17 +@ContainedBy(FooContainer.class) 125.18 +@interface Foo {} 125.19 + 125.20 +@ContainerFor(Foo.class) 125.21 +@interface FooContainer{ 125.22 + Foo[] value(); 125.23 +} 125.24 + 125.25 +@Foo @Foo 125.26 +public class InheritedContainerAnno {} 125.27 +
126.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 126.2 +++ b/test/tools/javac/annotations/repeatingAnnotations/InheritedContainerAnno.out Fri Nov 02 17:55:34 2012 -0700 126.3 @@ -0,0 +1,2 @@ 126.4 +InheritedContainerAnno.java:14:1: compiler.err.invalid.containedby.annotation.not.inherited: FooContainer, Foo 126.5 +1 error
127.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 127.2 +++ b/test/tools/javac/annotations/repeatingAnnotations/MissingContainer.java Fri Nov 02 17:55:34 2012 -0700 127.3 @@ -0,0 +1,21 @@ 127.4 +/** 127.5 + * @test /nodynamiccopyright/ 127.6 + * @bug 7169362 127.7 + * @author sogoel 127.8 + * @summary ContainerAnnotation does not have FooContainer.class specified 127.9 + * @compile/fail/ref=MissingContainer.out -XDrawDiagnostics MissingContainer.java 127.10 + */ 127.11 + 127.12 +import java.lang.annotation.ContainedBy; 127.13 +import java.lang.annotation.ContainerFor; 127.14 + 127.15 +@ContainedBy() 127.16 +@interface Foo {} 127.17 + 127.18 +@ContainerFor(Foo.class) 127.19 +@interface FooContainer { 127.20 + Foo[] value(); 127.21 +} 127.22 + 127.23 +@Foo @Foo 127.24 +public class MissingContainer {}
128.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 128.2 +++ b/test/tools/javac/annotations/repeatingAnnotations/MissingContainer.out Fri Nov 02 17:55:34 2012 -0700 128.3 @@ -0,0 +1,5 @@ 128.4 +MissingContainer.java:20:1: compiler.err.invalid.containedby.annotation: Foo 128.5 +MissingContainer.java:20:6: compiler.err.invalid.containedby.annotation: Foo 128.6 +MissingContainer.java:12:1: compiler.err.annotation.missing.default.value: java.lang.annotation.ContainedBy, value 128.7 +MissingContainer.java:15:1: compiler.err.invalid.container.wrong.containedby: Foo, FooContainer 128.8 +4 errors
129.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 129.2 +++ b/test/tools/javac/annotations/repeatingAnnotations/MissingDefaultCase1.java Fri Nov 02 17:55:34 2012 -0700 129.3 @@ -0,0 +1,23 @@ 129.4 +/** 129.5 + * @test /nodynamiccopyright/ 129.6 + * @bug 7169362 129.7 + * @author sogoel 129.8 + * @summary Default case not specified for other methods in container annotation 129.9 + * @compile/fail/ref=MissingDefaultCase1.out -XDrawDiagnostics MissingDefaultCase1.java 129.10 + */ 129.11 + 129.12 +import java.lang.annotation.ContainedBy; 129.13 +import java.lang.annotation.ContainerFor; 129.14 + 129.15 +@ContainedBy(FooContainer.class) 129.16 +@interface Foo {} 129.17 + 129.18 +@ContainerFor(Foo.class) 129.19 +@interface FooContainer { 129.20 + Foo[] value(); 129.21 + String other(); // missing default clause 129.22 +} 129.23 + 129.24 +@Foo @Foo 129.25 +public class MissingDefaultCase1 {} 129.26 +
130.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 130.2 +++ b/test/tools/javac/annotations/repeatingAnnotations/MissingDefaultCase1.out Fri Nov 02 17:55:34 2012 -0700 130.3 @@ -0,0 +1,2 @@ 130.4 +MissingDefaultCase1.java:12:1: compiler.err.invalid.containedby.annotation.elem.nondefault: FooContainer, other() 130.5 +1 error
131.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 131.2 +++ b/test/tools/javac/annotations/repeatingAnnotations/MissingDefaultCase2.java Fri Nov 02 17:55:34 2012 -0700 131.3 @@ -0,0 +1,23 @@ 131.4 +/** 131.5 + * @test /nodynamiccopyright/ 131.6 + * @bug 7169362 131.7 + * @author sogoel 131.8 + * @summary Missing default case for other method and return type is base annotation 131.9 + * @compile/fail/ref=MissingDefaultCase2.out -XDrawDiagnostics MissingDefaultCase2.java 131.10 + */ 131.11 + 131.12 +import java.lang.annotation.ContainedBy; 131.13 +import java.lang.annotation.ContainerFor; 131.14 + 131.15 +@ContainedBy(FooContainer.class) 131.16 +@interface Foo {} 131.17 + 131.18 +@ContainerFor(Foo.class) 131.19 +@interface FooContainer { 131.20 + Foo[] value(); 131.21 + Foo other(); // missing default clause and return type is an annotation 131.22 +} 131.23 + 131.24 +@Foo @Foo 131.25 +public class MissingDefaultCase2 {} 131.26 +
132.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 132.2 +++ b/test/tools/javac/annotations/repeatingAnnotations/MissingDefaultCase2.out Fri Nov 02 17:55:34 2012 -0700 132.3 @@ -0,0 +1,2 @@ 132.4 +MissingDefaultCase2.java:12:1: compiler.err.invalid.containedby.annotation.elem.nondefault: FooContainer, other() 132.5 +1 error
133.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 133.2 +++ b/test/tools/javac/annotations/repeatingAnnotations/MissingValueMethod.java Fri Nov 02 17:55:34 2012 -0700 133.3 @@ -0,0 +1,22 @@ 133.4 +/** 133.5 + * @test /nodynamiccopyright/ 133.6 + * @bug 7169362 133.7 + * @author sogoel 133.8 + * @summary Missing value() method in ContainerAnnotation 133.9 + * @compile/fail/ref=MissingValueMethod.out -XDrawDiagnostics MissingValueMethod.java 133.10 + */ 133.11 + 133.12 +import java.lang.annotation.ContainedBy; 133.13 +import java.lang.annotation.ContainerFor; 133.14 + 133.15 +@ContainedBy(FooContainer.class) 133.16 +@interface Foo {} 133.17 + 133.18 +@ContainerFor(Foo.class) 133.19 +@interface FooContainer{ 133.20 + Foo[] values(); // wrong method name 133.21 +} 133.22 + 133.23 +@Foo @Foo 133.24 +public class MissingValueMethod {} 133.25 +
134.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 134.2 +++ b/test/tools/javac/annotations/repeatingAnnotations/MissingValueMethod.out Fri Nov 02 17:55:34 2012 -0700 134.3 @@ -0,0 +1,4 @@ 134.4 +MissingValueMethod.java:20:1: compiler.err.invalid.containedby.annotation.no.value: FooContainer 134.5 +MissingValueMethod.java:20:6: compiler.err.invalid.containedby.annotation.no.value: FooContainer 134.6 +MissingValueMethod.java:12:1: compiler.err.invalid.containedby.annotation.elem.nondefault: FooContainer, values() 134.7 +3 errors
135.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 135.2 +++ b/test/tools/javac/annotations/repeatingAnnotations/MultiLevelRepeatableAnno.java Fri Nov 02 17:55:34 2012 -0700 135.3 @@ -0,0 +1,51 @@ 135.4 +/* 135.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 135.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 135.7 + * 135.8 + * This code is free software; you can redistribute it and/or modify it 135.9 + * under the terms of the GNU General Public License version 2 only, as 135.10 + * published by the Free Software Foundation. 135.11 + * 135.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 135.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 135.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 135.15 + * version 2 for more details (a copy is included in the LICENSE file that 135.16 + * accompanied this code). 135.17 + * 135.18 + * You should have received a copy of the GNU General Public License version 135.19 + * 2 along with this work; if not, write to the Free Software Foundation, 135.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 135.21 + * 135.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 135.23 + * or visit www.oracle.com if you need additional information or have any 135.24 + * questions. 135.25 + */ 135.26 + 135.27 +/** 135.28 + * @test 135.29 + * @bug 7169362 135.30 + * @author sogoel 135.31 + * @summary ContainerType can have its own container 135.32 + * @compile MultiLevelRepeatableAnno.java 135.33 + */ 135.34 + 135.35 +import java.lang.annotation.ContainedBy; 135.36 +import java.lang.annotation.ContainerFor; 135.37 + 135.38 +@ContainedBy(FooContainer.class) 135.39 +@interface Foo {} 135.40 + 135.41 +@ContainedBy(FooContainerContainer.class) 135.42 +@ContainerFor(Foo.class) 135.43 +@interface FooContainer { 135.44 + Foo[] value(); 135.45 +} 135.46 + 135.47 +@ContainerFor(FooContainer.class) 135.48 +@interface FooContainerContainer { 135.49 + FooContainer[] value(); 135.50 +} 135.51 + 135.52 +@Foo @Foo 135.53 +public class MultiLevelRepeatableAnno {} 135.54 +
136.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 136.2 +++ b/test/tools/javac/annotations/repeatingAnnotations/MultipleAnnoMixedOrder.java Fri Nov 02 17:55:34 2012 -0700 136.3 @@ -0,0 +1,60 @@ 136.4 +/* 136.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 136.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 136.7 + * 136.8 + * This code is free software; you can redistribute it and/or modify it 136.9 + * under the terms of the GNU General Public License version 2 only, as 136.10 + * published by the Free Software Foundation. 136.11 + * 136.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 136.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 136.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 136.15 + * version 2 for more details (a copy is included in the LICENSE file that 136.16 + * accompanied this code). 136.17 + * 136.18 + * You should have received a copy of the GNU General Public License version 136.19 + * 2 along with this work; if not, write to the Free Software Foundation, 136.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 136.21 + * 136.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 136.23 + * or visit www.oracle.com if you need additional information or have any 136.24 + * questions. 136.25 + */ 136.26 + 136.27 +/** 136.28 + * @test 136.29 + * @bug 7169362 136.30 + * @author sogoel 136.31 + * @summary Repeatable annotations in random order 136.32 + * @compile MultipleAnnoMixedOrder.java 136.33 + */ 136.34 + 136.35 +import java.lang.annotation.ContainedBy; 136.36 +import java.lang.annotation.ContainerFor; 136.37 + 136.38 +@ContainedBy(FooContainer.class) 136.39 +@interface Foo { 136.40 + int getNumbers(); 136.41 +} 136.42 + 136.43 +@ContainerFor(Foo.class) 136.44 +@interface FooContainer { 136.45 + Foo[] value(); 136.46 +} 136.47 + 136.48 +@ContainedBy(BazContainer.class) 136.49 +@interface Baz { 136.50 + String getStr(); 136.51 +} 136.52 + 136.53 +@ContainerFor(Baz.class) 136.54 +@interface BazContainer { 136.55 + Baz[] value(); 136.56 +} 136.57 + 136.58 +@Foo(getNumbers=1) 136.59 +@Baz(getStr="hello") 136.60 +@Foo(getNumbers=2) 136.61 +@Baz(getStr="world") 136.62 +public class MultipleAnnoMixedOrder {} 136.63 +
137.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 137.2 +++ b/test/tools/javac/annotations/repeatingAnnotations/NoRepeatableAnno.java Fri Nov 02 17:55:34 2012 -0700 137.3 @@ -0,0 +1,12 @@ 137.4 +/** 137.5 + * @test /nodynamiccopyright/ 137.6 + * @bug 7169362 137.7 + * @author sogoel 137.8 + * @summary Foo is not a repeatable annotation but used as one. 137.9 + * @compile/fail/ref=NoRepeatableAnno.out -XDrawDiagnostics NoRepeatableAnno.java 137.10 + */ 137.11 + 137.12 +@interface Foo {} 137.13 + 137.14 +@Foo @Foo 137.15 +public class NoRepeatableAnno {}
138.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 138.2 +++ b/test/tools/javac/annotations/repeatingAnnotations/NoRepeatableAnno.out Fri Nov 02 17:55:34 2012 -0700 138.3 @@ -0,0 +1,3 @@ 138.4 +NoRepeatableAnno.java:11:1: compiler.err.duplicate.annotation.missing.container: Foo 138.5 +NoRepeatableAnno.java:11:6: compiler.err.duplicate.annotation.missing.container: Foo 138.6 +2 errors
139.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 139.2 +++ b/test/tools/javac/annotations/repeatingAnnotations/SeparateCompile.java Fri Nov 02 17:55:34 2012 -0700 139.3 @@ -0,0 +1,30 @@ 139.4 +/* 139.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 139.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 139.7 + * 139.8 + * This code is free software; you can redistribute it and/or modify it 139.9 + * under the terms of the GNU General Public License version 2 only, as 139.10 + * published by the Free Software Foundation. 139.11 + * 139.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 139.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 139.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 139.15 + * version 2 for more details (a copy is included in the LICENSE file that 139.16 + * accompanied this code). 139.17 + * 139.18 + * You should have received a copy of the GNU General Public License version 139.19 + * 2 along with this work; if not, write to the Free Software Foundation, 139.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 139.21 + * 139.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 139.23 + * or visit www.oracle.com if you need additional information or have any 139.24 + * questions. 139.25 + */ 139.26 + 139.27 +/** 139.28 + * part of test for bug: 7199925 139.29 + * see: ClassReaderDefault.java 139.30 + */ 139.31 +@Foo @Foo 139.32 +public class SeparateCompile { 139.33 +}
140.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 140.2 +++ b/test/tools/javac/annotations/repeatingAnnotations/WrongReturnTypeForValue.java Fri Nov 02 17:55:34 2012 -0700 140.3 @@ -0,0 +1,23 @@ 140.4 +/** 140.5 + * @test /nodynamiccopyright/ 140.6 + * @bug 7169362 140.7 + * @author sogoel 140.8 + * @summary Wrong return type for value() in ContainerAnnotation 140.9 + * @compile/fail/ref=WrongReturnTypeForValue.out -XDrawDiagnostics WrongReturnTypeForValue.java 140.10 + */ 140.11 + 140.12 +import java.lang.annotation.ContainedBy; 140.13 +import java.lang.annotation.ContainerFor; 140.14 + 140.15 +@ContainedBy(FooContainer.class) 140.16 +@interface Foo { 140.17 + int getNumbers(); 140.18 +} 140.19 + 140.20 +@ContainerFor(Foo.class) 140.21 +@interface FooContainer{ 140.22 + Foo value(); // wrong return type 140.23 +} 140.24 + 140.25 +@Foo @Foo 140.26 +public class WrongReturnTypeForValue {}
141.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 141.2 +++ b/test/tools/javac/annotations/repeatingAnnotations/WrongReturnTypeForValue.out Fri Nov 02 17:55:34 2012 -0700 141.3 @@ -0,0 +1,3 @@ 141.4 +WrongReturnTypeForValue.java:22:1: compiler.err.invalid.containedby.annotation.value.return: FooContainer, Foo, Foo[] 141.5 +WrongReturnTypeForValue.java:22:6: compiler.err.invalid.containedby.annotation.value.return: FooContainer, Foo, Foo[] 141.6 +2 errors
142.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 142.2 +++ b/test/tools/javac/diags/examples/AuxiliaryClassWarning/ClassUsingAuxiliary.java Fri Nov 02 17:55:34 2012 -0700 142.3 @@ -0,0 +1,29 @@ 142.4 +/* 142.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 142.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 142.7 + * 142.8 + * This code is free software; you can redistribute it and/or modify it 142.9 + * under the terms of the GNU General Public License version 2 only, as 142.10 + * published by the Free Software Foundation. 142.11 + * 142.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 142.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 142.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 142.15 + * version 2 for more details (a copy is included in the LICENSE file that 142.16 + * accompanied this code). 142.17 + * 142.18 + * You should have received a copy of the GNU General Public License version 142.19 + * 2 along with this work; if not, write to the Free Software Foundation, 142.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 142.21 + * 142.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 142.23 + * or visit www.oracle.com if you need additional information or have any 142.24 + * questions. 142.25 + */ 142.26 + 142.27 +// key: compiler.warn.auxiliary.class.accessed.from.outside.of.its.source.file 142.28 +// options: -Xlint:auxiliaryclass 142.29 + 142.30 +class ClassUsingAuxiliary { 142.31 + AuxiliaryClass ahem; 142.32 +}
143.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 143.2 +++ b/test/tools/javac/diags/examples/AuxiliaryClassWarning/ClassWithAuxiliary.java Fri Nov 02 17:55:34 2012 -0700 143.3 @@ -0,0 +1,29 @@ 143.4 +/* 143.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 143.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 143.7 + * 143.8 + * This code is free software; you can redistribute it and/or modify it 143.9 + * under the terms of the GNU General Public License version 2 only, as 143.10 + * published by the Free Software Foundation. 143.11 + * 143.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 143.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 143.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 143.15 + * version 2 for more details (a copy is included in the LICENSE file that 143.16 + * accompanied this code). 143.17 + * 143.18 + * You should have received a copy of the GNU General Public License version 143.19 + * 2 along with this work; if not, write to the Free Software Foundation, 143.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 143.21 + * 143.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 143.23 + * or visit www.oracle.com if you need additional information or have any 143.24 + * questions. 143.25 + */ 143.26 + 143.27 +class ClassWithAuxiliaryClass { 143.28 +} 143.29 + 143.30 +// Auxiliary class that cannot be found through implicit compilation. 143.31 +class AuxiliaryClass { 143.32 +}
144.1 --- a/test/tools/javac/quid/T6999438.out Thu Nov 01 14:13:13 2012 -0700 144.2 +++ b/test/tools/javac/quid/T6999438.out Fri Nov 02 17:55:34 2012 -0700 144.3 @@ -1,4 +1,4 @@ 144.4 -T6999438.java:8:9: compiler.err.illegal.char: 35 144.5 +T6999438.java:8:9: compiler.err.illegal.char: # 144.6 T6999438.java:8:10: compiler.err.illegal.start.of.type 144.7 T6999438.java:8:25: compiler.err.expected: token.identifier 144.8 T6999438.java:8:26: compiler.err.expected: ';'
145.1 --- a/test/tools/javac/tree/MakeLiteralTest.java Thu Nov 01 14:13:13 2012 -0700 145.2 +++ b/test/tools/javac/tree/MakeLiteralTest.java Fri Nov 02 17:55:34 2012 -0700 145.3 @@ -1,7 +1,5 @@ 145.4 - 145.5 - 145.6 /* 145.7 - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 145.8 + * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. 145.9 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 145.10 * 145.11 * This code is free software; you can redistribute it and/or modify it 145.12 @@ -30,13 +28,14 @@ 145.13 */ 145.14 145.15 import com.sun.tools.javac.code.Type; 145.16 +import com.sun.tools.javac.code.TypeTag; 145.17 import com.sun.tools.javac.code.Symtab; 145.18 import com.sun.tools.javac.code.Types; 145.19 import com.sun.tools.javac.file.JavacFileManager; 145.20 import com.sun.tools.javac.tree.JCTree.JCLiteral; 145.21 import com.sun.tools.javac.util.Context; 145.22 import com.sun.tools.javac.tree.TreeMaker; 145.23 -import static com.sun.tools.javac.code.TypeTags.*; 145.24 +import static com.sun.tools.javac.code.TypeTag.*; 145.25 145.26 public class MakeLiteralTest { 145.27 public static void main(String... args) throws Exception { 145.28 @@ -65,9 +64,9 @@ 145.29 throw new Exception(errors + " errors found"); 145.30 } 145.31 145.32 - void test(Object value, int tag, Type type, Object constValue) { 145.33 + void test(Object value, TypeTag tag, Type type, Object constValue) { 145.34 JCLiteral l = maker.Literal(value); 145.35 - if (l.type.tag != tag) 145.36 + if (!l.type.hasTag(tag)) 145.37 error("unexpected tag: " + l.getTag() + ": expected: " + tag); 145.38 if (!types.isSameType(l.type, type)) 145.39 error("unexpected type: " + l.type + ": expected: " + type);
146.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 146.2 +++ b/test/tools/javac/warnings/AuxiliaryClass/ClassUsingAnotherAuxiliary.java Fri Nov 02 17:55:34 2012 -0700 146.3 @@ -0,0 +1,34 @@ 146.4 +/* 146.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 146.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 146.7 + * 146.8 + * This code is free software; you can redistribute it and/or modify it 146.9 + * under the terms of the GNU General Public License version 2 only, as 146.10 + * published by the Free Software Foundation. 146.11 + * 146.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 146.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 146.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 146.15 + * version 2 for more details (a copy is included in the LICENSE file that 146.16 + * accompanied this code). 146.17 + * 146.18 + * You should have received a copy of the GNU General Public License version 146.19 + * 2 along with this work; if not, write to the Free Software Foundation, 146.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 146.21 + * 146.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 146.23 + * or visit www.oracle.com if you need additional information or have any 146.24 + * questions. 146.25 + */ 146.26 + 146.27 +/** 146.28 + * @test 146.29 + * @compile ClassUsingAnotherAuxiliary.java NotAClassName.java 146.30 + * @compile -Xlint:auxiliaryclass ClassUsingAnotherAuxiliary.java NotAClassName.java 146.31 + * @compile/fail/ref=ClassUsingAnotherAuxiliary.out -XDrawDiagnostics -Werror -Xlint:auxiliaryclass ClassUsingAnotherAuxiliary.java NotAClassName.java 146.32 + */ 146.33 + 146.34 +class ClassUsingAnotherAuxiliary { 146.35 + AnAuxiliaryClass ahem; 146.36 +} 146.37 +
147.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 147.2 +++ b/test/tools/javac/warnings/AuxiliaryClass/ClassUsingAnotherAuxiliary.out Fri Nov 02 17:55:34 2012 -0700 147.3 @@ -0,0 +1,4 @@ 147.4 +ClassUsingAnotherAuxiliary.java:32:5: compiler.warn.auxiliary.class.accessed.from.outside.of.its.source.file: AnAuxiliaryClass, NotAClassName.java 147.5 +- compiler.err.warnings.and.werror 147.6 +1 error 147.7 +1 warning
148.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 148.2 +++ b/test/tools/javac/warnings/AuxiliaryClass/ClassUsingAuxiliary.java Fri Nov 02 17:55:34 2012 -0700 148.3 @@ -0,0 +1,34 @@ 148.4 +/* 148.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 148.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 148.7 + * 148.8 + * This code is free software; you can redistribute it and/or modify it 148.9 + * under the terms of the GNU General Public License version 2 only, as 148.10 + * published by the Free Software Foundation. 148.11 + * 148.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 148.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 148.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 148.15 + * version 2 for more details (a copy is included in the LICENSE file that 148.16 + * accompanied this code). 148.17 + * 148.18 + * You should have received a copy of the GNU General Public License version 148.19 + * 2 along with this work; if not, write to the Free Software Foundation, 148.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 148.21 + * 148.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 148.23 + * or visit www.oracle.com if you need additional information or have any 148.24 + * questions. 148.25 + */ 148.26 + 148.27 +/** 148.28 + * @test 148.29 + * @clean ClassUsingAuxiliary ClassWithAuxiliary AuxiliaryClass ClassWithAuxiliary$NotAnAuxiliaryClass ClassWithAuxiliary$NotAnAuxiliaryClassEither 148.30 + * @run compile ClassUsingAuxiliary.java ClassWithAuxiliary.java 148.31 + * @run compile/fail/ref=ClassUsingAuxiliary1.out -XDrawDiagnostics -Werror -Xlint:auxiliaryclass ClassUsingAuxiliary.java ClassWithAuxiliary.java 148.32 + * @run compile/fail/ref=ClassUsingAuxiliary2.out -XDrawDiagnostics -Werror -Xlint:auxiliaryclass ClassUsingAuxiliary.java 148.33 + */ 148.34 + 148.35 +class ClassUsingAuxiliary { 148.36 + AuxiliaryClass ahem; 148.37 +}
149.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 149.2 +++ b/test/tools/javac/warnings/AuxiliaryClass/ClassUsingAuxiliary1.out Fri Nov 02 17:55:34 2012 -0700 149.3 @@ -0,0 +1,4 @@ 149.4 +ClassUsingAuxiliary.java:33:5: compiler.warn.auxiliary.class.accessed.from.outside.of.its.source.file: AuxiliaryClass, ClassWithAuxiliary.java 149.5 +- compiler.err.warnings.and.werror 149.6 +1 error 149.7 +1 warning
150.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 150.2 +++ b/test/tools/javac/warnings/AuxiliaryClass/ClassUsingAuxiliary2.out Fri Nov 02 17:55:34 2012 -0700 150.3 @@ -0,0 +1,4 @@ 150.4 +ClassUsingAuxiliary.java:33:5: compiler.warn.auxiliary.class.accessed.from.outside.of.its.source.file: AuxiliaryClass, ClassWithAuxiliary.java 150.5 +- compiler.err.warnings.and.werror 150.6 +1 error 150.7 +1 warning
151.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 151.2 +++ b/test/tools/javac/warnings/AuxiliaryClass/ClassWithAuxiliary.java Fri Nov 02 17:55:34 2012 -0700 151.3 @@ -0,0 +1,31 @@ 151.4 +/* 151.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 151.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 151.7 + * 151.8 + * This code is free software; you can redistribute it and/or modify it 151.9 + * under the terms of the GNU General Public License version 2 only, as 151.10 + * published by the Free Software Foundation. 151.11 + * 151.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 151.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 151.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 151.15 + * version 2 for more details (a copy is included in the LICENSE file that 151.16 + * accompanied this code). 151.17 + * 151.18 + * You should have received a copy of the GNU General Public License version 151.19 + * 2 along with this work; if not, write to the Free Software Foundation, 151.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 151.21 + * 151.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 151.23 + * or visit www.oracle.com if you need additional information or have any 151.24 + * questions. 151.25 + */ 151.26 + 151.27 +public class ClassWithAuxiliary { 151.28 + public static class NotAnAuxiliaryClass { } 151.29 + public class NotAnAuxiliaryClassEither { } 151.30 +} 151.31 + 151.32 +// Auxiliary class that cannot be found through implicit compilation. 151.33 +class AuxiliaryClass { 151.34 +}
152.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 152.2 +++ b/test/tools/javac/warnings/AuxiliaryClass/NotAClassName.java Fri Nov 02 17:55:34 2012 -0700 152.3 @@ -0,0 +1,25 @@ 152.4 +/* 152.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 152.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 152.7 + * 152.8 + * This code is free software; you can redistribute it and/or modify it 152.9 + * under the terms of the GNU General Public License version 2 only, as 152.10 + * published by the Free Software Foundation. 152.11 + * 152.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 152.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 152.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 152.15 + * version 2 for more details (a copy is included in the LICENSE file that 152.16 + * accompanied this code). 152.17 + * 152.18 + * You should have received a copy of the GNU General Public License version 152.19 + * 2 along with this work; if not, write to the Free Software Foundation, 152.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 152.21 + * 152.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 152.23 + * or visit www.oracle.com if you need additional information or have any 152.24 + * questions. 152.25 + */ 152.26 + 152.27 +class AnAuxiliaryClass { 152.28 +}
153.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 153.2 +++ b/test/tools/javac/warnings/AuxiliaryClass/SelfClassWithAux.java Fri Nov 02 17:55:34 2012 -0700 153.3 @@ -0,0 +1,44 @@ 153.4 +/* 153.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 153.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 153.7 + * 153.8 + * This code is free software; you can redistribute it and/or modify it 153.9 + * under the terms of the GNU General Public License version 2 only, as 153.10 + * published by the Free Software Foundation. 153.11 + * 153.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 153.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 153.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 153.15 + * version 2 for more details (a copy is included in the LICENSE file that 153.16 + * accompanied this code). 153.17 + * 153.18 + * You should have received a copy of the GNU General Public License version 153.19 + * 2 along with this work; if not, write to the Free Software Foundation, 153.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 153.21 + * 153.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 153.23 + * or visit www.oracle.com if you need additional information or have any 153.24 + * questions. 153.25 + */ 153.26 + 153.27 +/* 153.28 + * Test that an auxiliary class referenced from its own source file, 153.29 + * does not trigger the warning. Such code does not prevent implicit 153.30 + * compilation. Also test that references to inner classes do not trigger the warning. 153.31 + */ 153.32 + 153.33 +/* 153.34 + * @test 153.35 + * @run compile -Werror -Xlint:auxiliaryclass SelfClassWithAux.java ClassWithAuxiliary.java 153.36 + * @run compile -Werror -Xlint:auxiliaryclass SelfClassWithAux.java 153.37 + */ 153.38 + 153.39 +class SelfClassWithAux { 153.40 + Aux aux; 153.41 + ClassWithAuxiliary.NotAnAuxiliaryClass alfa; 153.42 + ClassWithAuxiliary.NotAnAuxiliaryClassEither beta; 153.43 +} 153.44 + 153.45 +class Aux { 153.46 + Aux aux; 153.47 +}