# HG changeset patch # User chegar # Date 1370854374 -3600 # Node ID da8d0ee0938e9e1caa216d0445642c619a5472db # Parent 76d08c649607d634551de0ff3043eaafb59478e0# Parent fd31bf97340fabcd57d111b258cdd74f295efeaa Merge diff -r 76d08c649607 -r da8d0ee0938e make/tools/genstubs/GenStubs.java --- a/make/tools/genstubs/GenStubs.java Fri May 31 10:28:30 2013 +0100 +++ b/make/tools/genstubs/GenStubs.java Mon Jun 10 09:52:54 2013 +0100 @@ -230,9 +230,9 @@ tree.typarams = translateTypeParams(tree.typarams); tree.params = translateVarDefs(tree.params); tree.thrown = translate(tree.thrown); - if (tree.restype != null && tree.body != null) { + if (tree.body != null) { if ((currClassMods & Flags.INTERFACE) != 0) { - tree.mods.flags &= ~Flags.DEFAULT; + tree.mods.flags &= ~(Flags.DEFAULT | Flags.STATIC); } else { tree.mods.flags |= Flags.NATIVE; } diff -r 76d08c649607 -r da8d0ee0938e src/share/classes/com/sun/javadoc/Tag.java --- a/src/share/classes/com/sun/javadoc/Tag.java Fri May 31 10:28:30 2013 +0100 +++ b/src/share/classes/com/sun/javadoc/Tag.java Mon Jun 10 09:52:54 2013 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -54,36 +54,44 @@ * {@link}, the curly brackets * are not part of the name, so in this example the name * would be simply @link. + * + * @return the name of this tag */ String name(); /** * Return the containing {@link Doc} of this Tag element. + * + * @return the containing {@link Doc} of this Tag element */ Doc holder(); /** * Return the kind of this tag. - * similar or synonymous tags. For most tags, + * For most tags, * kind() == name(); * the following table lists those cases where there is more * than one tag of a given kind: *

- * - * - * - * - * - * - * - * - * + *
kind() name()
@throws @throws
@throws @exception
@see @see
@see @link
@see @linkplain
@serial @serial
@serial @serialData
+ * + * + * + * + * + * + * + * *
{@code kind() } {@code name() }
{@code @throws } {@code @throws }
{@code @throws } {@code @exception }
{@code @see } {@code @see }
{@code @see } {@code @link }
{@code @see } {@code @linkplain }
{@code @serial } {@code @serial }
{@code @serial } {@code @serialData }
+ * + * @return the kind of this tag. */ String kind(); /** - * Return the text of this tag, that is, portion beyond tag name. + * Return the text of this tag, that is, the portion beyond tag name. + * + * @return the text of this tag */ String text(); diff -r 76d08c649607 -r da8d0ee0938e src/share/classes/com/sun/tools/classfile/ClassFile.java --- a/src/share/classes/com/sun/tools/classfile/ClassFile.java Fri May 31 10:28:30 2013 +0100 +++ b/src/share/classes/com/sun/tools/classfile/ClassFile.java Mon Jun 10 09:52:54 2013 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,6 +29,7 @@ import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; +import java.nio.file.Path; import static com.sun.tools.classfile.AccessFlags.*; @@ -46,6 +47,11 @@ return read(file, new Attribute.Factory()); } + public static ClassFile read(Path path) + throws IOException, ConstantPoolException { + return read(path.toFile(), new Attribute.Factory()); + } + public static ClassFile read(File file, Attribute.Factory attributeFactory) throws IOException, ConstantPoolException { FileInputStream in = new FileInputStream(file); diff -r 76d08c649607 -r da8d0ee0938e src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java --- a/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java Fri May 31 10:28:30 2013 +0100 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java Mon Jun 10 09:52:54 2013 +0100 @@ -324,8 +324,19 @@ option.startsWith("-xdoclint:")) { return 1; } else if (option.equals("-help")) { + // Uugh: first, this should not be hidden inside optionLength, + // and second, we should not be writing directly to stdout. + // But we have no access to a DocErrorReporter, which would + // allow use of reporter.printNotice System.out.println(getText("doclet.usage")); return 1; + } else if (option.equals("-x")) { + // Uugh: first, this should not be hidden inside optionLength, + // and second, we should not be writing directly to stdout. + // But we have no access to a DocErrorReporter, which would + // allow use of reporter.printNotice + System.out.println(getText("doclet.X.usage")); + return 1; } else if (option.equals("-footer") || option.equals("-header") || option.equals("-packagesheader") || diff -r 76d08c649607 -r da8d0ee0938e src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties --- a/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties Fri May 31 10:28:30 2013 +0100 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties Mon Jun 10 09:52:54 2013 +0100 @@ -186,45 +186,50 @@ doclet.Same_package_name_used=Package name format used twice: {0} doclet.exception_encountered=Exception encountered while processing {1}\n{0} doclet.usage=Provided by Standard doclet:\n\ - -d Destination directory for output files\n\ - -use Create class and package usage pages\n\ - -version Include @version paragraphs\n\ - -author Include @author paragraphs\n\ - -docfilessubdirs Recursively copy doc-file subdirectories\n\ - -splitindex Split index into one file per letter\n\ - -windowtitle Browser window title for the documenation\n\ - -doctitle Include title for the overview page\n\ - -header Include header text for each page\n\ - -footer Include footer text for each page\n\ - -top Include top text for each page\n\ - -bottom Include bottom text for each page\n\ - -link Create links to javadoc output at \n\ - -linkoffline Link to docs at using package list at \n\ - -excludedocfilessubdir :.. Exclude any doc-files subdirectories with given name.\n\ - -group :.. Group specified packages together in overview page\n\ - -nocomment Supress description and tags, generate only declarations.\n\ - -nodeprecated Do not include @deprecated information\n\ - -noqualifier ::... Exclude the list of qualifiers from the output.\n\ - -nosince Do not include @since information\n\ - -notimestamp Do not include hidden time stamp\n\ - -nodeprecatedlist Do not generate deprecated list\n\ - -notree Do not generate class hierarchy\n\ - -noindex Do not generate index\n\ - -nohelp Do not generate help link\n\ - -nonavbar Do not generate navigation bar\n\ - -serialwarn Generate warning about @serial tag\n\ - -tag ::

Specify single argument custom tags\n\ - -taglet The fully qualified name of Taglet to register\n\ - -tagletpath The path to Taglets\n\ - -Xdocrootparent Replaces all appearances of @docRoot followed by /.. in doc comments with \n\ - -charset Charset for cross-platform viewing of generated documentation.\n\ - -helpfile Include file that help link links to\n\ - -linksource Generate source in HTML\n\ - -sourcetab Specify the number of spaces each tab takes up in the source\n\ - -keywords Include HTML meta tags with package, class and member info\n\ - -stylesheetfile File to change style of the generated documentation\n\ - -docencoding Output encoding name +\ -d Destination directory for output files\n\ +\ -use Create class and package usage pages\n\ +\ -version Include @version paragraphs\n\ +\ -author Include @author paragraphs\n\ +\ -docfilessubdirs Recursively copy doc-file subdirectories\n\ +\ -splitindex Split index into one file per letter\n\ +\ -windowtitle Browser window title for the documentation\n\ +\ -doctitle Include title for the overview page\n\ +\ -header Include header text for each page\n\ +\ -footer Include footer text for each page\n\ +\ -top Include top text for each page\n\ +\ -bottom Include bottom text for each page\n\ +\ -link Create links to javadoc output at \n\ +\ -linkoffline Link to docs at using package list at \n\ +\ -excludedocfilessubdir :.. Exclude any doc-files subdirectories with given name.\n\ +\ -group :.. Group specified packages together in overview page\n\ +\ -nocomment Suppress description and tags, generate only declarations.\n\ +\ -nodeprecated Do not include @deprecated information\n\ +\ -noqualifier ::... Exclude the list of qualifiers from the output.\n\ +\ -nosince Do not include @since information\n\ +\ -notimestamp Do not include hidden time stamp\n\ +\ -nodeprecatedlist Do not generate deprecated list\n\ +\ -notree Do not generate class hierarchy\n\ +\ -noindex Do not generate index\n\ +\ -nohelp Do not generate help link\n\ +\ -nonavbar Do not generate navigation bar\n\ +\ -serialwarn Generate warning about @serial tag\n\ +\ -tag ::
Specify single argument custom tags\n\ +\ -taglet The fully qualified name of Taglet to register\n\ +\ -tagletpath The path to Taglets\n\ +\ -charset Charset for cross-platform viewing of generated documentation.\n\ +\ -helpfile Include file that help link links to\n\ +\ -linksource Generate source in HTML\n\ +\ -sourcetab Specify the number of spaces each tab takes up in the source\n\ +\ -keywords Include HTML meta tags with package, class and member info\n\ +\ -stylesheetfile File to change style of the generated documentation\n\ +\ -docencoding Specify the character encoding for the output - - +# L10N: do not localize these words: all none accessibility html missing reference syntax +doclet.X.usage=Provided by standard doclet:\n\ +\ -Xdocrootparent Replaces all appearances of @docRoot followed\n\ +\ by /.. in doc comments with \n\ +\ -Xdoclint Enable recommended checks for problems in javadoc comments\n\ +\ -Xdoclint:(all|none|[-]) \n\ +\ Enable or disable specific checks for problems in javadoc comments,\n\ +\ where is one of accessibility, html, missing, reference, or syntax.\n diff -r 76d08c649607 -r da8d0ee0938e src/share/classes/com/sun/tools/doclint/Checker.java --- a/src/share/classes/com/sun/tools/doclint/Checker.java Fri May 31 10:28:30 2013 +0100 +++ b/src/share/classes/com/sun/tools/doclint/Checker.java Mon Jun 10 09:52:54 2013 +0100 @@ -531,6 +531,17 @@ } } break; + + case VALUE: + if (currTag == HtmlTag.LI) { + String v = getAttrValue(tree); + if (v == null || v.isEmpty()) { + env.messages.error(HTML, tree, "dc.attr.lacks.value"); + } else if (!validNumber.matcher(v).matches()) { + env.messages.error(HTML, tree, "dc.attr.not.number"); + } + } + break; } } } @@ -543,6 +554,8 @@ // http://www.w3.org/TR/html401/types.html#type-name private static final Pattern validName = Pattern.compile("[A-Za-z][A-Za-z0-9-_:.]*"); + private static final Pattern validNumber = Pattern.compile("-?[0-9]+"); + // pattern to remove leading {@docRoot}/? private static final Pattern docRoot = Pattern.compile("(?i)(\\{@docRoot *\\}/?)?(.*)"); diff -r 76d08c649607 -r da8d0ee0938e src/share/classes/com/sun/tools/doclint/DocLint.java --- a/src/share/classes/com/sun/tools/doclint/DocLint.java Fri May 31 10:28:30 2013 +0100 +++ b/src/share/classes/com/sun/tools/doclint/DocLint.java Mon Jun 10 09:52:54 2013 +0100 @@ -77,13 +77,14 @@ // public static void main(String... args) { + DocLint dl = new DocLint(); try { - new DocLint().run(args); + dl.run(args); } catch (BadArgs e) { System.err.println(e.getMessage()); System.exit(1); } catch (IOException e) { - System.err.println(e); + System.err.println(dl.localize("dc.main.ioerror", e.getLocalizedMessage())); System.exit(2); } } @@ -92,9 +93,10 @@ // - public static class BadArgs extends Exception { + public class BadArgs extends Exception { private static final long serialVersionUID = 0; BadArgs(String code, Object... args) { + super(localize(code, args)); this.code = code; this.args = args; } @@ -124,7 +126,7 @@ if (javacFiles.isEmpty()) { if (!needHelp) - out.println("no files given"); + out.println(localize("dc.main.no.files.given")); } JavacTool tool = JavacTool.create(); @@ -204,49 +206,9 @@ } void showHelp(PrintWriter out) { - out.println("Usage:"); - out.println(" doclint [options] source-files..."); - out.println(""); - out.println("Options:"); - out.println(" -Xmsgs "); - out.println(" Same as -Xmsgs:all"); - out.println(" -Xmsgs:values"); - out.println(" Specify categories of issues to be checked, where 'values'"); - out.println(" is a comma-separated list of any of the following:"); - out.println(" reference show places where comments contain incorrect"); - out.println(" references to Java source code elements"); - out.println(" syntax show basic syntax errors within comments"); - out.println(" html show issues with HTML tags and attributes"); - out.println(" accessibility show issues for accessibility"); - out.println(" missing show issues with missing documentation"); - out.println(" all all of the above"); - out.println(" Precede a value with '-' to negate it"); - out.println(" Categories may be qualified by one of:"); - out.println(" /public /protected /package /private"); - out.println(" For positive categories (not beginning with '-')"); - out.println(" the qualifier applies to that access level and above."); - out.println(" For negative categories (beginning with '-')"); - out.println(" the qualifier applies to that access level and below."); - out.println(" If a qualifier is missing, the category applies to"); - out.println(" all access levels."); - out.println(" For example, -Xmsgs:all,-syntax/private"); - out.println(" This will enable all messages, except syntax errors"); - out.println(" in the doc comments of private methods."); - out.println(" If no -Xmsgs options are provided, the default is"); - out.println(" equivalent to -Xmsgs:all/protected, meaning that"); - out.println(" all messages are reported for protected and public"); - out.println(" declarations only. "); - out.println(" -stats"); - out.println(" Report statistics on the reported issues."); - out.println(" -h -help --help -usage -?"); - out.println(" Show this message."); - out.println(""); - out.println("The following javac options are also supported"); - out.println(" -bootclasspath, -classpath, -sourcepath, -Xmaxerrs, -Xmaxwarns"); - out.println(""); - out.println("To run doclint on part of a project, put the compiled classes for your"); - out.println("project on the classpath (or bootclasspath), then specify the source files"); - out.println("to be checked on the command line."); + String msg = localize("dc.main.usage"); + for (String line: msg.split("\n")) + out.println(line); } List splitPath(String path) { @@ -353,6 +315,11 @@ return false; } + private String localize(String code, Object... args) { + Messages m = (env != null) ? env.messages : new Messages(null); + return m.localize(code, args); + } + // static abstract class DeclScanner extends TreePathScanner { diff -r 76d08c649607 -r da8d0ee0938e src/share/classes/com/sun/tools/doclint/HtmlTag.java --- a/src/share/classes/com/sun/tools/doclint/HtmlTag.java Fri May 31 10:28:30 2013 +0100 +++ b/src/share/classes/com/sun/tools/doclint/HtmlTag.java Mon Jun 10 09:52:54 2013 +0100 @@ -131,7 +131,8 @@ attrs(AttrKind.USE_CSS, ALIGN, HSPACE, VSPACE, BORDER)), LI(BlockType.LIST_ITEM, EndKind.OPTIONAL, - EnumSet.of(Flag.ACCEPTS_BLOCK, Flag.ACCEPTS_INLINE)), + EnumSet.of(Flag.ACCEPTS_BLOCK, Flag.ACCEPTS_INLINE), + attrs(AttrKind.OK, VALUE)), LINK(BlockType.OTHER, EndKind.NONE), @@ -339,6 +340,7 @@ TARGET, TYPE, VALIGN, + VALUE, VSPACE, WIDTH; diff -r 76d08c649607 -r da8d0ee0938e src/share/classes/com/sun/tools/doclint/resources/doclint.properties --- a/src/share/classes/com/sun/tools/doclint/resources/doclint.properties Fri May 31 10:28:30 2013 +0100 +++ b/src/share/classes/com/sun/tools/doclint/resources/doclint.properties Mon Jun 10 09:52:54 2013 +0100 @@ -26,6 +26,7 @@ dc.anchor.already.defined = anchor already defined: {0} dc.anchor.value.missing = no value given for anchor dc.attr.lacks.value = attribute lacks value +dc.attr.not.number = attribute value is not a number dc.attr.obsolete = attribute obsolete: {0} dc.attr.obsolete.use.css = attribute obsolete, use CSS instead: {0} dc.attr.repeated = repeated attribute: {0} @@ -66,3 +67,50 @@ dc.tag.start.unmatched = end tag missing: dc.tag.unknown = unknown tag: {0} dc.text.not.allowed = text not allowed in <{0}> element + +dc.main.ioerror=IO error: {0} +dc.main.no.files.given=No files given +dc.main.usage=\ +Usage:\n\ +\ doclint [options] source-files...\n\ +\n\ +Options:\n\ +\ -Xmsgs \n\ +\ Same as -Xmsgs:all\n\ +\ -Xmsgs:values\n\ +\ Specify categories of issues to be checked, where ''values''\n\ +\ is a comma-separated list of any of the following:\n\ +\ reference show places where comments contain incorrect\n\ +\ references to Java source code elements\n\ +\ syntax show basic syntax errors within comments\n\ +\ html show issues with HTML tags and attributes\n\ +\ accessibility show issues for accessibility\n\ +\ missing show issues with missing documentation\n\ +\ all all of the above\n\ +\ Precede a value with ''-'' to negate it\n\ +\ Categories may be qualified by one of:\n\ +\ /public /protected /package /private\n\ +\ For positive categories (not beginning with ''-'')\n\ +\ the qualifier applies to that access level and above.\n\ +\ For negative categories (beginning with ''-'')\n\ +\ the qualifier applies to that access level and below.\n\ +\ If a qualifier is missing, the category applies to\n\ +\ all access levels.\n\ +\ For example, -Xmsgs:all,-syntax/private\n\ +\ This will enable all messages, except syntax errors\n\ +\ in the doc comments of private methods.\n\ +\ If no -Xmsgs options are provided, the default is\n\ +\ equivalent to -Xmsgs:all/protected, meaning that\n\ +\ all messages are reported for protected and public\n\ +\ declarations only. \n\ +\ -stats\n\ +\ Report statistics on the reported issues.\n\ +\ -h -help --help -usage -?\n\ +\ Show this message.\n\ +\n\ +The following javac options are also supported\n\ +\ -bootclasspath, -classpath, -sourcepath, -Xmaxerrs, -Xmaxwarns\n\ +\n\ +To run doclint on part of a project, put the compiled classes for your\n\ +project on the classpath (or bootclasspath), then specify the source files\n\ +to be checked on the command line. diff -r 76d08c649607 -r da8d0ee0938e src/share/classes/com/sun/tools/javac/code/Lint.java --- a/src/share/classes/com/sun/tools/javac/code/Lint.java Fri May 31 10:28:30 2013 +0100 +++ b/src/share/classes/com/sun/tools/javac/code/Lint.java Mon Jun 10 09:52:54 2013 +0100 @@ -68,19 +68,11 @@ /** * Returns the result of combining the values in this object with - * the given annotations. + * the metadata on the given symbol. */ - public Lint augment(Annotations annots) { - return augmentor.augment(this, annots.getDeclarationAttributes()); - } - - /** - * Returns the result of combining the values in this object with - * the given annotations and flags. - */ - public Lint augment(Annotations annots, long flags) { - Lint l = augmentor.augment(this, annots.getDeclarationAttributes()); - if ((flags & DEPRECATED) != 0) { + public Lint augment(Symbol sym) { + Lint l = augmentor.augment(this, sym.getDeclarationAttributes()); + if (sym.isDeprecated()) { if (l == this) l = new Lint(this); l.values.remove(LintCategory.DEPRECATION); diff -r 76d08c649607 -r da8d0ee0938e src/share/classes/com/sun/tools/javac/code/Symbol.java --- a/src/share/classes/com/sun/tools/javac/code/Symbol.java Fri May 31 10:28:30 2013 +0100 +++ b/src/share/classes/com/sun/tools/javac/code/Symbol.java Mon Jun 10 09:52:54 2013 +0100 @@ -32,6 +32,7 @@ import javax.tools.JavaFileObject; import com.sun.tools.javac.code.Type.*; +import com.sun.tools.javac.comp.Annotate; import com.sun.tools.javac.comp.Attr; import com.sun.tools.javac.comp.AttrContext; import com.sun.tools.javac.comp.Env; @@ -74,35 +75,6 @@ */ public long flags() { return flags_field; } - /** The attributes of this symbol are contained in this - * Annotations. The Annotations instance is NOT immutable. - */ - public final Annotations annotations = new Annotations(this); - - /** An accessor method for the attributes of this symbol. - * Attributes of class symbols should be accessed through the accessor - * method to make sure that the class symbol is loaded. - */ - public List getRawAttributes() { - return annotations.getDeclarationAttributes(); - } - - /** An accessor method for the type attributes of this symbol. - * Attributes of class symbols should be accessed through the accessor - * method to make sure that the class symbol is loaded. - */ - public List getRawTypeAttributes() { - return annotations.getTypeAttributes(); - } - - /** Fetch a particular annotation from a symbol. */ - public Attribute.Compound attribute(Symbol anno) { - for (Attribute.Compound a : getRawAttributes()) { - if (a.type.tsym == anno) return a; - } - return null; - } - /** The name of this symbol in Utf8 representation. */ public Name name; @@ -123,6 +95,146 @@ */ public Type erasure_field; + // + + /** The attributes of this symbol are contained in this + * Annotations. The Annotations instance is NOT immutable. + */ + protected Annotations annotations; + + /** An accessor method for the attributes of this symbol. + * Attributes of class symbols should be accessed through the accessor + * method to make sure that the class symbol is loaded. + */ + public List getRawAttributes() { + return (annotations == null) + ? List.nil() + : annotations.getDeclarationAttributes(); + } + + /** An accessor method for the type attributes of this symbol. + * Attributes of class symbols should be accessed through the accessor + * method to make sure that the class symbol is loaded. + */ + public List getRawTypeAttributes() { + return (annotations == null) + ? List.nil() + : annotations.getTypeAttributes(); + } + + /** Fetch a particular annotation from a symbol. */ + public Attribute.Compound attribute(Symbol anno) { + for (Attribute.Compound a : getRawAttributes()) { + if (a.type.tsym == anno) return a; + } + return null; + } + + public boolean annotationsPendingCompletion() { + return annotations == null ? false : annotations.pendingCompletion(); + } + + public void appendAttributes(List l) { + if (l.nonEmpty()) { + initedAnnos().append(l); + } + } + + public void appendClassInitTypeAttributes(List l) { + if (l.nonEmpty()) { + initedAnnos().appendClassInitTypeAttributes(l); + } + } + + public void appendInitTypeAttributes(List l) { + if (l.nonEmpty()) { + initedAnnos().appendInitTypeAttributes(l); + } + } + + public void appendTypeAttributesWithCompletion(final Annotate.AnnotateRepeatedContext ctx) { + initedAnnos().appendTypeAttributesWithCompletion(ctx); + } + + public void appendUniqueTypeAttributes(List l) { + if (l.nonEmpty()) { + initedAnnos().appendUniqueTypes(l); + } + } + + public List getClassInitTypeAttributes() { + return (annotations == null) + ? List.nil() + : annotations.getClassInitTypeAttributes(); + } + + public List getInitTypeAttributes() { + return (annotations == null) + ? List.nil() + : annotations.getInitTypeAttributes(); + } + + public List getDeclarationAttributes() { + return (annotations == null) + ? List.nil() + : annotations.getDeclarationAttributes(); + } + + public boolean hasAnnotations() { + return (annotations != null && !annotations.isEmpty()); + } + + public boolean hasTypeAnnotations() { + return (annotations != null && !annotations.isTypesEmpty()); + } + + public void prependAttributes(List l) { + if (l.nonEmpty()) { + initedAnnos().prepend(l); + } + } + + public void resetAnnotations() { + initedAnnos().reset(); + } + + public void setAttributes(Symbol other) { + if (annotations != null || other.annotations != null) { + initedAnnos().setAttributes(other.annotations); + } + } + + public void setDeclarationAttributes(List a) { + if (annotations != null || a.nonEmpty()) { + initedAnnos().setDeclarationAttributes(a); + } + } + + public void setDeclarationAttributesWithCompletion(final Annotate.AnnotateRepeatedContext ctx) { + initedAnnos().setDeclarationAttributesWithCompletion(ctx); + } + + public void setTypeAttributes(List a) { + if (annotations != null || a.nonEmpty()) { + if (annotations == null) + annotations = new Annotations(this); + annotations.setTypeAttributes(a); + } + } + + private Annotations initedAnnos() { + if (annotations == null) + annotations = new Annotations(this); + return annotations; + } + + /** This method is intended for debugging only. */ + public Annotations getAnnotations() { + return annotations; + } + + // + /** Construct a symbol with given kind, flags, name, type and owner. */ public Symbol(int kind, long flags, Name name, Type type, Symbol owner) { @@ -207,6 +319,10 @@ } } + public boolean isDeprecated() { + return (flags_field & DEPRECATED) != 0; + } + public boolean isStatic() { return (flags() & STATIC) != 0 || @@ -726,8 +842,9 @@ } private void mergeAttributes() { - if (annotations.isEmpty() && - !package_info.annotations.isEmpty()) { + if (annotations == null && + package_info.annotations != null) { + annotations = new Annotations(this); annotations.setAttributes(package_info.annotations); } } diff -r 76d08c649607 -r da8d0ee0938e src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java --- a/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java Fri May 31 10:28:30 2013 +0100 +++ b/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java Mon Jun 10 09:52:54 2013 +0100 @@ -271,8 +271,8 @@ } } - sym.annotations.reset(); - sym.annotations.setDeclarationAttributes(declAnnos.toList()); + sym.resetAnnotations(); + sym.setDeclarationAttributes(declAnnos.toList()); if (typeAnnos.isEmpty()) { return; @@ -284,7 +284,7 @@ // When type is null, put the type annotations to the symbol. // This is used for constructor return annotations, for which // no appropriate type exists. - sym.annotations.appendUniqueTypes(typeAnnotations); + sym.appendUniqueTypeAttributes(typeAnnotations); return; } @@ -318,7 +318,7 @@ sym.type = type; } - sym.annotations.appendUniqueTypes(typeAnnotations); + sym.appendUniqueTypeAttributes(typeAnnotations); if (sym.getKind() == ElementKind.PARAMETER || sym.getKind() == ElementKind.LOCAL_VARIABLE || @@ -326,7 +326,7 @@ sym.getKind() == ElementKind.EXCEPTION_PARAMETER) { // Make sure all type annotations from the symbol are also // on the owner. - sym.owner.annotations.appendUniqueTypes(sym.getRawTypeAttributes()); + sym.owner.appendUniqueTypeAttributes(sym.getRawTypeAttributes()); } } @@ -855,7 +855,7 @@ Assert.error("Found unexpected type annotation for variable: " + v + " with kind: " + v.getKind()); } if (v.getKind() != ElementKind.FIELD) { - v.owner.annotations.appendUniqueTypes(v.getRawTypeAttributes()); + v.owner.appendUniqueTypeAttributes(v.getRawTypeAttributes()); } return; diff -r 76d08c649607 -r da8d0ee0938e src/share/classes/com/sun/tools/javac/comp/Attr.java --- a/src/share/classes/com/sun/tools/javac/comp/Attr.java Fri May 31 10:28:30 2013 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java Mon Jun 10 09:52:54 2013 +0100 @@ -757,11 +757,10 @@ // env.info.enclVar.attributes_field might not yet have been evaluated, and so might be // null. In that case, calling augment will throw an NPE. To avoid this, for now we // revert to the jdk 6 behavior and ignore the (unevaluated) attributes. - if (env.info.enclVar.annotations.pendingCompletion()) { + if (env.info.enclVar.annotationsPendingCompletion()) { env.info.lint = lintEnv.info.lint; } else { - env.info.lint = lintEnv.info.lint.augment(env.info.enclVar.annotations, - env.info.enclVar.flags()); + env.info.lint = lintEnv.info.lint.augment(env.info.enclVar); } Lint prevLint = chk.setLint(env.info.lint); @@ -881,7 +880,7 @@ MethodSymbol m = tree.sym; boolean isDefaultMethod = (m.flags() & DEFAULT) != 0; - Lint lint = env.info.lint.augment(m.annotations, m.flags()); + Lint lint = env.info.lint.augment(m); Lint prevLint = chk.setLint(lint); MethodSymbol prevMethod = chk.setMethod(m); try { @@ -1052,7 +1051,7 @@ } VarSymbol v = tree.sym; - Lint lint = env.info.lint.augment(v.annotations, v.flags()); + Lint lint = env.info.lint.augment(v); Lint prevLint = chk.setLint(lint); // Check that the variable's declared type is well-formed. @@ -1121,9 +1120,9 @@ ClassSymbol cs = (ClassSymbol)env.info.scope.owner; List tas = localEnv.info.scope.owner.getRawTypeAttributes(); if ((tree.flags & STATIC) != 0) { - cs.annotations.appendClassInitTypeAttributes(tas); + cs.appendClassInitTypeAttributes(tas); } else { - cs.annotations.appendInitTypeAttributes(tas); + cs.appendInitTypeAttributes(tas); } } @@ -1173,8 +1172,11 @@ Env loopEnv = env.dup(env.tree, env.info.dup(env.info.scope.dup())); try { + //the Formal Parameter of a for-each loop is not in the scope when + //attributing the for-each expression; we mimick this by attributing + //the for-each expression first (against original scope). + Type exprType = types.upperBound(attribExpr(tree.expr, loopEnv)); attribStat(tree.var, loopEnv); - Type exprType = types.upperBound(attribExpr(tree.expr, loopEnv)); chk.checkNonVoid(tree.pos(), exprType); Type elemtype = types.elemtype(exprType); // perhaps expr is an array? if (elemtype == null) { @@ -1831,9 +1833,6 @@ // Check that value of resulting type is admissible in the // current context. Also, capture the return type result = check(tree, capture(restype), VAL, resultInfo); - - if (localEnv.info.lastResolveVarargs()) - Assert.check(result.isErroneous() || tree.varargsElement != null); } chk.validate(tree.typeargs, localEnv); } @@ -2610,7 +2609,7 @@ //field initializer lambdaEnv = env.dup(that, env.info.dup(env.info.scope.dupUnshared())); lambdaEnv.info.scope.owner = - new MethodSymbol(0, names.empty, null, + new MethodSymbol((owner.flags() & STATIC) | BLOCK, names.empty, null, env.info.scope.owner); } else { lambdaEnv = env.dup(that, env.info.dup(env.info.scope.dup())); @@ -3731,8 +3730,28 @@ typeargtypes, noteWarner); + DeferredAttr.DeferredTypeMap checkDeferredMap = + deferredAttr.new DeferredTypeMap(DeferredAttr.AttrMode.CHECK, sym, env.info.pendingResolutionPhase); + + argtypes = Type.map(argtypes, checkDeferredMap); + + if (noteWarner.hasNonSilentLint(LintCategory.UNCHECKED)) { + chk.warnUnchecked(env.tree.pos(), + "unchecked.meth.invocation.applied", + kindName(sym), + sym.name, + rs.methodArguments(sym.type.getParameterTypes()), + rs.methodArguments(Type.map(argtypes, checkDeferredMap)), + kindName(sym.location()), + sym.location()); + owntype = new MethodType(owntype.getParameterTypes(), + types.erasure(owntype.getReturnType()), + types.erasure(owntype.getThrownTypes()), + syms.methodClass); + } + return chk.checkMethod(owntype, sym, env, argtrees, argtypes, env.info.lastResolveVarargs(), - noteWarner.hasNonSilentLint(LintCategory.UNCHECKED)); + resultInfo.checkContext.inferenceContext()); } catch (Infer.InferenceException ex) { //invalid target type - propagate exception outwards or report error //depending on the current check context @@ -4118,7 +4137,7 @@ lintEnv = lintEnv.next; // Having found the enclosing lint value, we can initialize the lint value for this class - env.info.lint = lintEnv.info.lint.augment(c.annotations, c.flags()); + env.info.lint = lintEnv.info.lint.augment(c); Lint prevLint = chk.setLint(env.info.lint); JavaFileObject prev = log.useSource(c.sourcefile); diff -r 76d08c649607 -r da8d0ee0938e src/share/classes/com/sun/tools/javac/comp/Check.java --- a/src/share/classes/com/sun/tools/javac/comp/Check.java Fri May 31 10:28:30 2013 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java Mon Jun 10 09:52:54 2013 +0100 @@ -847,24 +847,31 @@ (s.flags() & (STATIC | FINAL)) != 0); } - Type checkMethod(Type owntype, - Symbol sym, - Env env, - final List argtrees, - List argtypes, - boolean useVarargs, - boolean unchecked) { + Type checkMethod(final Type mtype, + final Symbol sym, + final Env env, + final List argtrees, + final List argtypes, + final boolean useVarargs, + InferenceContext inferenceContext) { // System.out.println("call : " + env.tree); // System.out.println("method : " + owntype); // System.out.println("actuals: " + argtypes); + if (inferenceContext.free(mtype)) { + inferenceContext.addFreeTypeListener(List.of(mtype), new FreeTypeListener() { + public void typesInferred(InferenceContext inferenceContext) { + checkMethod(inferenceContext.asInstType(mtype), sym, env, argtrees, argtypes, useVarargs, inferenceContext); + } + }); + return mtype; + } + Type owntype = mtype; List formals = owntype.getParameterTypes(); Type last = useVarargs ? formals.last() : null; if (sym.name == names.init && sym.owner == syms.enumSym) formals = formals.tail.tail; List args = argtrees; - DeferredAttr.DeferredTypeMap checkDeferredMap = - deferredAttr.new DeferredTypeMap(DeferredAttr.AttrMode.CHECK, sym, env.info.pendingResolutionPhase); if (args != null) { //this is null when type-checking a method reference while (formals.head != last) { @@ -885,27 +892,13 @@ } else if ((sym.flags() & VARARGS) != 0 && allowVarargs) { // non-varargs call to varargs method Type varParam = owntype.getParameterTypes().last(); - Type lastArg = checkDeferredMap.apply(argtypes.last()); + Type lastArg = argtypes.last(); if (types.isSubtypeUnchecked(lastArg, types.elemtype(varParam)) && !types.isSameType(types.erasure(varParam), types.erasure(lastArg))) log.warning(argtrees.last().pos(), "inexact.non-varargs.call", types.elemtype(varParam), varParam); } } - if (unchecked) { - warnUnchecked(env.tree.pos(), - "unchecked.meth.invocation.applied", - kindName(sym), - sym.name, - rs.methodArguments(sym.type.getParameterTypes()), - rs.methodArguments(Type.map(argtypes, checkDeferredMap)), - kindName(sym.location()), - sym.location()); - owntype = new MethodType(owntype.getParameterTypes(), - types.erasure(owntype.getReturnType()), - types.erasure(owntype.getThrownTypes()), - syms.methodClass); - } if (useVarargs) { Type argtype = owntype.getParameterTypes().last(); if (!types.isReifiable(argtype) && @@ -1912,24 +1905,11 @@ Symbol s3 = e.sym; if (s3 == s1 || s3 == s2 || s3.kind != MTH || (s3.flags() & (BRIDGE|SYNTHETIC)) != 0) continue; Type st3 = types.memberType(site,s3); - if (types.overrideEquivalent(st3, st1) && types.overrideEquivalent(st3, st2)) { - if (s3.owner == site.tsym) { - return true; - } - List tvars1 = st1.getTypeArguments(); - List tvars2 = st2.getTypeArguments(); - List tvars3 = st3.getTypeArguments(); - Type rt1 = st1.getReturnType(); - Type rt2 = st2.getReturnType(); - Type rt13 = types.subst(st3.getReturnType(), tvars3, tvars1); - Type rt23 = types.subst(st3.getReturnType(), tvars3, tvars2); - boolean compat = - !rt13.isPrimitiveOrVoid() && - !rt23.isPrimitiveOrVoid() && - (types.covariantReturnType(rt13, rt1, types.noWarnings) && - types.covariantReturnType(rt23, rt2, types.noWarnings)); - if (compat) - return true; + if (types.overrideEquivalent(st3, st1) && + types.overrideEquivalent(st3, st2) && + types.returnTypeSubstitutable(st3, st1) && + types.returnTypeSubstitutable(st3, st2)) { + return true; } } } diff -r 76d08c649607 -r da8d0ee0938e src/share/classes/com/sun/tools/javac/comp/Enter.java --- a/src/share/classes/com/sun/tools/javac/comp/Enter.java Fri May 31 10:28:30 2013 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/Enter.java Mon Jun 10 09:52:54 2013 +0100 @@ -161,7 +161,7 @@ Env lintEnv = localEnv; while (lintEnv.info.lint == null) lintEnv = lintEnv.next; - localEnv.info.lint = lintEnv.info.lint.augment(sym.annotations, sym.flags()); + localEnv.info.lint = lintEnv.info.lint.augment(sym); return localEnv; } diff -r 76d08c649607 -r da8d0ee0938e src/share/classes/com/sun/tools/javac/comp/Flow.java --- a/src/share/classes/com/sun/tools/javac/comp/Flow.java Fri May 31 10:28:30 2013 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/Flow.java Mon Jun 10 09:52:54 2013 +0100 @@ -434,7 +434,7 @@ Lint lintPrev = lint; pendingExits = new ListBuffer(); - lint = lint.augment(tree.sym.annotations); + lint = lint.augment(tree.sym); try { // process all the static initializers @@ -470,7 +470,7 @@ if (tree.body == null) return; Lint lintPrev = lint; - lint = lint.augment(tree.sym.annotations); + lint = lint.augment(tree.sym); Assert.check(pendingExits.isEmpty()); @@ -496,7 +496,7 @@ public void visitVarDef(JCVariableDecl tree) { if (tree.init != null) { Lint lintPrev = lint; - lint = lint.augment(tree.sym.annotations); + lint = lint.augment(tree.sym); try{ scan(tree.init); } finally { @@ -808,9 +808,10 @@ */ void markThrown(JCTree tree, Type exc) { if (!chk.isUnchecked(tree.pos(), exc)) { - if (!chk.isHandled(exc, caught)) + if (!chk.isHandled(exc, caught)) { pendingExits.append(new FlowPendingExit(tree, exc)); - thrown = chk.incl(exc, thrown); + } + thrown = chk.incl(exc, thrown); } } @@ -835,7 +836,7 @@ } classDef = tree; thrown = List.nil(); - lint = lint.augment(tree.sym.annotations); + lint = lint.augment(tree.sym); try { // process all the static initializers @@ -915,7 +916,7 @@ List mthrown = tree.sym.type.getThrownTypes(); Lint lintPrev = lint; - lint = lint.augment(tree.sym.annotations); + lint = lint.augment(tree.sym); Assert.check(pendingExits.isEmpty()); @@ -954,7 +955,7 @@ public void visitVarDef(JCVariableDecl tree) { if (tree.init != null) { Lint lintPrev = lint; - lint = lint.augment(tree.sym.annotations); + lint = lint.augment(tree.sym); try{ scan(tree.init); } finally { @@ -1066,8 +1067,9 @@ names.close, List.nil(), List.nil()); + Type mt = types.memberType(resource.type, closeMethod); if (closeMethod.kind == MTH) { - for (Type t : ((MethodSymbol)closeMethod).getThrownTypes()) { + for (Type t : mt.getThrownTypes()) { markThrown(resource, t); } } @@ -1578,7 +1580,7 @@ firstadr = nextadr; } classDef = tree; - lint = lint.augment(tree.sym.annotations); + lint = lint.augment(tree.sym); try { // define all the static fields @@ -1646,7 +1648,7 @@ int returnadrPrev = returnadr; Lint lintPrev = lint; - lint = lint.augment(tree.sym.annotations); + lint = lint.augment(tree.sym); Assert.check(pendingExits.isEmpty()); @@ -1698,7 +1700,7 @@ if (track && tree.sym.owner.kind == MTH) newVar(tree.sym); if (tree.init != null) { Lint lintPrev = lint; - lint = lint.augment(tree.sym.annotations); + lint = lint.augment(tree.sym); try{ scanExpr(tree.init); if (track) letInit(tree.pos(), tree.sym); diff -r 76d08c649607 -r da8d0ee0938e src/share/classes/com/sun/tools/javac/comp/Infer.java --- a/src/share/classes/com/sun/tools/javac/comp/Infer.java Fri May 31 10:28:30 2013 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java Mon Jun 10 09:52:54 2013 +0100 @@ -218,8 +218,8 @@ //we need to skip capture? Warner retWarn = new Warner(); if (!resultInfo.checkContext.compatible(qtype1, resultInfo.checkContext.inferenceContext().asFree(to), retWarn) || - //unchecked conversion is not allowed - retWarn.hasLint(Lint.LintCategory.UNCHECKED)) { + //unchecked conversion is not allowed in source 7 mode + (!allowGraphInference && retWarn.hasLint(Lint.LintCategory.UNCHECKED))) { throw inferenceException .setMessage("infer.no.conforming.instance.exists", inferenceContext.restvars(), mt.getReturnType(), to); diff -r 76d08c649607 -r da8d0ee0938e src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java --- a/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java Fri May 31 10:28:30 2013 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java Mon Jun 10 09:52:54 2013 +0100 @@ -249,8 +249,8 @@ } } if (lambdaTypeAnnos.nonEmpty()) { - owner.annotations.setTypeAttributes(ownerTypeAnnos.toList()); - sym.annotations.setTypeAttributes(lambdaTypeAnnos.toList()); + owner.setTypeAttributes(ownerTypeAnnos.toList()); + sym.setTypeAttributes(lambdaTypeAnnos.toList()); } } @@ -389,15 +389,15 @@ if (lambdaContext.getSymbolMap(PARAM).containsKey(tree.sym)) { Symbol translatedSym = lambdaContext.getSymbolMap(PARAM).get(tree.sym); result = make.Ident(translatedSym).setType(tree.type); - translatedSym.annotations.setTypeAttributes(tree.sym.getRawTypeAttributes()); + translatedSym.setTypeAttributes(tree.sym.getRawTypeAttributes()); } else if (lambdaContext.getSymbolMap(LOCAL_VAR).containsKey(tree.sym)) { Symbol translatedSym = lambdaContext.getSymbolMap(LOCAL_VAR).get(tree.sym); result = make.Ident(translatedSym).setType(tree.type); - translatedSym.annotations.setTypeAttributes(tree.sym.getRawTypeAttributes()); + translatedSym.setTypeAttributes(tree.sym.getRawTypeAttributes()); } else if (lambdaContext.getSymbolMap(TYPE_VAR).containsKey(tree.sym)) { Symbol translatedSym = lambdaContext.getSymbolMap(TYPE_VAR).get(tree.sym); result = make.Ident(translatedSym).setType(translatedSym.type); - translatedSym.annotations.setTypeAttributes(tree.sym.getRawTypeAttributes()); + translatedSym.setTypeAttributes(tree.sym.getRawTypeAttributes()); } else if (lambdaContext.getSymbolMap(CAPTURED_VAR).containsKey(tree.sym)) { Symbol translatedSym = lambdaContext.getSymbolMap(CAPTURED_VAR).get(tree.sym); result = make.Ident(translatedSym).setType(tree.type); @@ -1715,8 +1715,8 @@ ret = makeSyntheticVar(FINAL, name, types.erasure(sym.type), translatedSym); } if (ret != sym) { - ret.annotations.setDeclarationAttributes(sym.getRawAttributes()); - ret.annotations.setTypeAttributes(sym.getRawTypeAttributes()); + ret.setDeclarationAttributes(sym.getRawAttributes()); + ret.setTypeAttributes(sym.getRawTypeAttributes()); } return ret; } diff -r 76d08c649607 -r da8d0ee0938e src/share/classes/com/sun/tools/javac/comp/Lower.java --- a/src/share/classes/com/sun/tools/javac/comp/Lower.java Fri May 31 10:28:30 2013 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/Lower.java Mon Jun 10 09:52:54 2013 +0100 @@ -2002,7 +2002,7 @@ JCStatement rethrow; if (target.hasInitCause()) { // rethrow = "throw new NoClassDefFoundError().initCause(e); - JCTree throwExpr = + JCExpression throwExpr = makeCall(makeNewClass(syms.noClassDefFoundErrorType, List.nil()), names.initCause, @@ -2360,7 +2360,7 @@ null, List.nil(), List.nil()); ClassSymbol c = tree.packge.package_info; c.flags_field |= flags; - c.annotations.setAttributes(tree.packge.annotations); + c.setAttributes(tree.packge); ClassType ctype = (ClassType) c.type; ctype.supertype_field = syms.objectType; ctype.interfaces_field = List.nil(); @@ -2378,7 +2378,7 @@ return tree.packageAnnotations.nonEmpty(); case NONEMPTY: for (Attribute.Compound a : - tree.packge.annotations.getDeclarationAttributes()) { + tree.packge.getDeclarationAttributes()) { Attribute.RetentionPolicy p = types.getRetention(a); if (p != Attribute.RetentionPolicy.SOURCE) return true; @@ -2711,9 +2711,14 @@ if (fvs.nonEmpty()) { List addedargtypes = List.nil(); for (List l = fvs; l.nonEmpty(); l = l.tail) { - if (TreeInfo.isInitialConstructor(tree)) + if (TreeInfo.isInitialConstructor(tree)) { + final Name pName = proxyName(l.head.name); + m.extraParams = + m.extraParams.append((VarSymbol) + (proxies.lookup(pName).sym)); added = added.prepend( - initField(tree.body.pos, proxyName(l.head.name))); + initField(tree.body.pos, pName)); + } addedargtypes = addedargtypes.prepend(l.head.erasure(types)); } Type olderasure = m.erasure(types); @@ -2931,7 +2936,7 @@ } result = make.If(cond, - make_at(detailPos). + make_at(tree). Throw(makeNewClass(syms.assertionErrorType, exnArgs)), null); } else { diff -r 76d08c649607 -r da8d0ee0938e src/share/classes/com/sun/tools/javac/comp/MemberEnter.java --- a/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java Fri May 31 10:28:30 2013 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java Mon Jun 10 09:52:54 2013 +0100 @@ -712,7 +712,7 @@ public Env getMethodEnv(JCMethodDecl tree, Env env) { Env mEnv = methodEnv(tree, env); - mEnv.info.lint = mEnv.info.lint.augment(tree.sym.annotations, tree.sym.flags()); + mEnv.info.lint = mEnv.info.lint.augment(tree.sym); for (List l = tree.typarams; l.nonEmpty(); l = l.tail) mEnv.info.scope.enterIfAbsent(l.head.type.tsym); for (List l = tree.params; l.nonEmpty(); l = l.tail) @@ -753,7 +753,7 @@ return; } if (s.kind != PCK) { - s.annotations.reset(); // mark Annotations as incomplete for now + s.resetAnnotations(); // mark Annotations as incomplete for now } annotate.normal(new Annotate.Annotator() { @Override @@ -763,10 +763,10 @@ @Override public void enterAnnotation() { - Assert.check(s.kind == PCK || s.annotations.pendingCompletion()); + Assert.check(s.kind == PCK || s.annotationsPendingCompletion()); JavaFileObject prev = log.useSource(localEnv.toplevel.sourcefile); try { - if (!s.annotations.isEmpty() && + if (s.hasAnnotations() && annotations.nonEmpty()) log.error(annotations.head.pos, "already.annotated", @@ -832,7 +832,7 @@ } } - s.annotations.setDeclarationAttributesWithCompletion( + s.setDeclarationAttributesWithCompletion( annotate.new AnnotateRepeatedContext(env, annotated, pos, log, false)); } @@ -996,8 +996,9 @@ long ctorFlags = 0; boolean based = false; boolean addConstructor = true; + JCNewClass nc = null; if (c.name.isEmpty()) { - JCNewClass nc = (JCNewClass)env.next.tree; + nc = (JCNewClass)env.next.tree; if (nc.constructor != null) { addConstructor = nc.constructor.kind != ERR; Type superConstrType = types.memberType(c.type, @@ -1013,7 +1014,10 @@ } } if (addConstructor) { + MethodSymbol basedConstructor = nc != null ? + (MethodSymbol)nc.constructor : null; JCTree constrDef = DefaultConstructor(make.at(tree.pos), c, + basedConstructor, typarams, argtypes, thrown, ctorFlags, based); tree.defs = tree.defs.prepend(constrDef); @@ -1103,7 +1107,7 @@ } if (s != null) { - s.annotations.appendTypeAttributesWithCompletion( + s.appendTypeAttributesWithCompletion( annotate.new AnnotateRepeatedContext(env, annotated, pos, log, true)); } } @@ -1399,34 +1403,78 @@ */ JCTree DefaultConstructor(TreeMaker make, ClassSymbol c, + MethodSymbol baseInit, List typarams, List argtypes, List thrown, long flags, boolean based) { - List params = make.Params(argtypes, syms.noSymbol); - List stats = List.nil(); - if (c.type != syms.objectType) - stats = stats.prepend(SuperCall(make, typarams, params, based)); + JCTree result; if ((c.flags() & ENUM) != 0 && (types.supertype(c.type).tsym == syms.enumSym)) { // constructors of true enums are private flags = (flags & ~AccessFlags) | PRIVATE | GENERATEDCONSTR; } else flags |= (c.flags() & AccessFlags) | GENERATEDCONSTR; - if (c.name.isEmpty()) flags |= ANONCONSTR; - JCTree result = make.MethodDef( - make.Modifiers(flags), - names.init, - null, - make.TypeParams(typarams), - params, - make.Types(thrown), - make.Block(0, stats), - null); + if (c.name.isEmpty()) { + flags |= ANONCONSTR; + } + Type mType = new MethodType(argtypes, null, thrown, c); + Type initType = typarams.nonEmpty() ? + new ForAll(typarams, mType) : + mType; + MethodSymbol init = new MethodSymbol(flags, names.init, + initType, c); + init.params = createDefaultConstructorParams(make, baseInit, init, + argtypes, based); + List params = make.Params(argtypes, init); + List stats = List.nil(); + if (c.type != syms.objectType) { + stats = stats.prepend(SuperCall(make, typarams, params, based)); + } + result = make.MethodDef(init, make.Block(0, stats)); return result; } + private List createDefaultConstructorParams( + TreeMaker make, + MethodSymbol baseInit, + MethodSymbol init, + List argtypes, + boolean based) { + List initParams = null; + List argTypesList = argtypes; + if (based) { + /* In this case argtypes will have an extra type, compared to baseInit, + * corresponding to the type of the enclosing instance i.e.: + * + * Inner i = outer.new Inner(1){} + * + * in the above example argtypes will be (Outer, int) and baseInit + * will have parameter's types (int). So in this case we have to add + * first the extra type in argtypes and then get the names of the + * parameters from baseInit. + */ + initParams = List.nil(); + VarSymbol param = new VarSymbol(0, make.paramName(0), argtypes.head, init); + initParams = initParams.append(param); + argTypesList = argTypesList.tail; + } + if (baseInit != null && baseInit.params != null && + baseInit.params.nonEmpty() && argTypesList.nonEmpty()) { + initParams = (initParams == null) ? List.nil() : initParams; + List baseInitParams = baseInit.params; + while (baseInitParams.nonEmpty() && argTypesList.nonEmpty()) { + VarSymbol param = new VarSymbol(baseInitParams.head.flags(), + baseInitParams.head.name, argTypesList.head, init); + initParams = initParams.append(param); + baseInitParams = baseInitParams.tail; + argTypesList = argTypesList.tail; + } + } + return initParams; + } + /** Generate call to superclass constructor. This is: * * super(id_0, ..., id_n) diff -r 76d08c649607 -r da8d0ee0938e src/share/classes/com/sun/tools/javac/comp/Resolve.java --- a/src/share/classes/com/sun/tools/javac/comp/Resolve.java Fri May 31 10:28:30 2013 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java Mon Jun 10 09:52:54 2013 +0100 @@ -349,7 +349,7 @@ : isAccessible(env, t.tsym, checkInner); } - /** Is symbol accessible as a member of given type in given evironment? + /** Is symbol accessible as a member of given type in given environment? * @param env The current environment. * @param site The type of which the tested symbol is regarded * as a member. @@ -490,11 +490,11 @@ }; /** Try to instantiate the type of a method so that it fits - * given type arguments and argument types. If succesful, return + * given type arguments and argument types. If successful, return * the method's instantiated type, else return null. * The instantiation will take into account an additional leading * formal parameter if the method is an instance method seen as a member - * of un underdetermined site In this case, we treat site as an additional + * of an under determined site. In this case, we treat site as an additional * parameter and the parameters of the class containing the method as * additional type variables that get instantiated. * @@ -1207,7 +1207,7 @@ bestSoFar.kind != AMBIGUOUS && l.nonEmpty(); l = l.tail) { sym = findField(env, site, name, l.head.tsym); - if (bestSoFar.kind < AMBIGUOUS && sym.kind < AMBIGUOUS && + if (bestSoFar.exists() && sym.exists() && sym.owner != bestSoFar.owner) bestSoFar = new AmbiguityError(bestSoFar, sym); else if (sym.kind < bestSoFar.kind) @@ -1343,7 +1343,7 @@ try { Type mt = rawInstantiate(env, site, sym, null, argtypes, typeargtypes, allowBoxing, useVarargs, types.noWarnings); - if (!operator) + if (!operator || verboseResolutionMode.contains(VerboseResolutionMode.PREDEF)) currentResolutionContext.addApplicableCandidate(sym, mt); } catch (InapplicableMethodException ex) { if (!operator) @@ -2500,17 +2500,21 @@ try { currentResolutionContext = new MethodResolutionContext(); Name name = treeinfo.operatorName(optag); - env.info.pendingResolutionPhase = currentResolutionContext.step = BASIC; - Symbol sym = findMethod(env, syms.predefClass.type, name, argtypes, - null, false, false, true); - if (boxingEnabled && sym.kind >= WRONG_MTHS) - env.info.pendingResolutionPhase = currentResolutionContext.step = BOX; - sym = findMethod(env, syms.predefClass.type, name, argtypes, - null, true, false, true); - return accessMethod(sym, pos, env.enclClass.sym.type, name, + return lookupMethod(env, pos, syms.predefClass, currentResolutionContext, + new BasicLookupHelper(name, syms.predefClass.type, argtypes, null, BOX) { + @Override + Symbol lookup(Env env, MethodResolutionPhase phase) { + return findMethod(env, site, name, argtypes, typeargtypes, + phase.isBoxingRequired(), + phase.isVarargsRequired(), true); + } + @Override + Symbol access(Env env, DiagnosticPosition pos, Symbol location, Symbol sym) { + return accessMethod(sym, pos, env.enclClass.sym.type, name, false, argtypes, null); - } - finally { + } + }); + } finally { currentResolutionContext = prevResolutionContext; } } @@ -2673,7 +2677,11 @@ abstract class BasicLookupHelper extends LookupHelper { BasicLookupHelper(Name name, Type site, List argtypes, List typeargtypes) { - super(name, site, argtypes, typeargtypes, MethodResolutionPhase.VARARITY); + this(name, site, argtypes, typeargtypes, MethodResolutionPhase.VARARITY); + } + + BasicLookupHelper(Name name, Type site, List argtypes, List typeargtypes, MethodResolutionPhase maxPhase) { + super(name, site, argtypes, typeargtypes, maxPhase); } @Override diff -r 76d08c649607 -r da8d0ee0938e src/share/classes/com/sun/tools/javac/comp/TransTypes.java --- a/src/share/classes/com/sun/tools/javac/comp/TransTypes.java Fri May 31 10:28:30 2013 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/TransTypes.java Mon Jun 10 09:52:54 2013 +0100 @@ -172,10 +172,13 @@ JCExpression retype(JCExpression tree, Type erasedType, Type target) { // System.err.println("retype " + tree + " to " + erasedType);//DEBUG if (!erasedType.isPrimitive()) { - if (target != null && target.isPrimitive()) + if (target != null && target.isPrimitive()) { target = erasure(tree.type); + } tree.type = erasedType; - if (target != null) return coerce(tree, target); + if (target != null) { + return coerce(tree, target); + } } return tree; } @@ -255,6 +258,12 @@ meth.name, bridgeType, origin); + /* once JDK-6996415 is solved it should be checked if this approach can + * be applied to method addOverrideBridgesIfNeeded + */ + bridge.params = createBridgeParams(impl, bridge, bridgeType); + bridge.setAttributes(impl); + if (!hypothetical) { JCMethodDecl md = make.MethodDef(bridge, null); @@ -289,6 +298,26 @@ overridden.put(bridge, meth); } + private List createBridgeParams(MethodSymbol impl, MethodSymbol bridge, + Type bridgeType) { + List bridgeParams = null; + if (impl.params != null) { + bridgeParams = List.nil(); + List implParams = impl.params; + Type.MethodType mType = (Type.MethodType)bridgeType; + List argTypes = mType.argtypes; + while (implParams.nonEmpty() && argTypes.nonEmpty()) { + VarSymbol param = new VarSymbol(implParams.head.flags() | SYNTHETIC, + implParams.head.name, argTypes.head, bridge); + param.setAttributes(implParams.head); + bridgeParams = bridgeParams.append(param); + implParams = implParams.tail; + argTypes = argTypes.tail; + } + } + return bridgeParams; + } + /** Add bridge if given symbol is a non-private, non-static member * of the given class, which is either defined in the class or non-final * inherited, and one of the two following conditions holds: @@ -686,8 +715,8 @@ public void visitAssign(JCAssign tree) { tree.lhs = translate(tree.lhs, null); tree.rhs = translate(tree.rhs, erasure(tree.lhs.type)); - tree.type = erasure(tree.type); - result = tree; + tree.type = erasure(tree.lhs.type); + result = retype(tree, tree.type, pt); } public void visitAssignop(JCAssignOp tree) { diff -r 76d08c649607 -r da8d0ee0938e src/share/classes/com/sun/tools/javac/jvm/ClassReader.java --- a/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java Fri May 31 10:28:30 2013 +0100 +++ b/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java Mon Jun 10 09:52:54 2013 +0100 @@ -1896,12 +1896,11 @@ JavaFileObject previousClassFile = currentClassFile; try { currentClassFile = classFile; - Annotations annotations = sym.annotations; List newList = deproxyCompoundList(l); - if (annotations.pendingCompletion()) { - annotations.setDeclarationAttributes(newList); + if (sym.annotationsPendingCompletion()) { + sym.setDeclarationAttributes(newList); } else { - annotations.append(newList); + sym.appendAttributes(newList); } } finally { currentClassFile = previousClassFile; @@ -1935,7 +1934,7 @@ try { currentClassFile = classFile; List newList = deproxyTypeCompoundList(proxies); - sym.annotations.setTypeAttributes(newList.prependList(sym.getRawTypeAttributes())); + sym.setTypeAttributes(newList.prependList(sym.getRawTypeAttributes())); } finally { currentClassFile = previousClassFile; } diff -r 76d08c649607 -r da8d0ee0938e src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java --- a/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java Fri May 31 10:28:30 2013 +0100 +++ b/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java Mon Jun 10 09:52:54 2013 +0100 @@ -31,7 +31,6 @@ import java.util.Set; import java.util.HashSet; -import javax.lang.model.type.TypeKind; import javax.tools.JavaFileManager; import javax.tools.FileObject; import javax.tools.JavaFileObject; @@ -39,9 +38,6 @@ import com.sun.tools.javac.code.*; import com.sun.tools.javac.code.Attribute.RetentionPolicy; import com.sun.tools.javac.code.Attribute.TypeCompound; -import static com.sun.tools.javac.code.BoundKind.EXTENDS; -import static com.sun.tools.javac.code.BoundKind.SUPER; -import static com.sun.tools.javac.code.BoundKind.UNBOUND; import com.sun.tools.javac.code.Symbol.*; import com.sun.tools.javac.code.Type.*; import com.sun.tools.javac.code.Types.UniqueType; @@ -674,13 +670,15 @@ int writeParameterAttrs(MethodSymbol m) { boolean hasVisible = false; boolean hasInvisible = false; - if (m.params != null) for (VarSymbol s : m.params) { - for (Attribute.Compound a : s.getRawAttributes()) { - switch (types.getRetention(a)) { - case SOURCE: break; - case CLASS: hasInvisible = true; break; - case RUNTIME: hasVisible = true; break; - default: ;// /* fail soft */ throw new AssertionError(vis); + if (m.params != null) { + for (VarSymbol s : m.params) { + for (Attribute.Compound a : s.getRawAttributes()) { + switch (types.getRetention(a)) { + case SOURCE: break; + case CLASS: hasInvisible = true; break; + case RUNTIME: hasVisible = true; break; + default: ;// /* fail soft */ throw new AssertionError(vis); + } } } } @@ -1026,6 +1024,7 @@ char flags = (char) adjustFlags(inner.flags_field); if ((flags & INTERFACE) != 0) flags |= ABSTRACT; // Interfaces are always ABSTRACT if (inner.name.isEmpty()) flags &= ~FINAL; // Anonymous class: unset FINAL flag + flags &= ~STRICTFP; //inner classes should not have the strictfp flag set. if (dumpInnerClassModifiers) { PrintWriter pw = log.getWriter(Log.WriterKind.ERROR); pw.println("INNERCLASS " + inner.name); diff -r 76d08c649607 -r da8d0ee0938e src/share/classes/com/sun/tools/javac/jvm/Code.java --- a/src/share/classes/com/sun/tools/javac/jvm/Code.java Fri May 31 10:28:30 2013 +0100 +++ b/src/share/classes/com/sun/tools/javac/jvm/Code.java Mon Jun 10 09:52:54 2013 +0100 @@ -1960,8 +1960,7 @@ } private void fillLocalVarPosition(LocalVar lv) { - if (lv == null || lv.sym == null - || lv.sym.annotations.isTypesEmpty()) + if (lv == null || lv.sym == null || !lv.sym.hasTypeAnnotations()) return; for (Attribute.TypeCompound ta : lv.sym.getRawTypeAttributes()) { TypeAnnotationPosition p = ta.position; @@ -1979,7 +1978,7 @@ for (int i = 0; i < varBufferSize; ++i) { LocalVar lv = varBuffer[i]; if (lv == null || lv.sym == null - || lv.sym.annotations.isTypesEmpty() + || !lv.sym.hasTypeAnnotations() || !lv.sym.isExceptionParameter()) continue; @@ -2028,7 +2027,7 @@ // 2) it is an exception type and it contains type annotations if (!varDebugInfo && (!var.sym.isExceptionParameter() || - var.sym.annotations.isTypesEmpty())) return; + var.sym.hasTypeAnnotations())) return; if ((var.sym.flags() & Flags.SYNTHETIC) != 0) return; if (varBuffer == null) varBuffer = new LocalVar[20]; diff -r 76d08c649607 -r da8d0ee0938e src/share/classes/com/sun/tools/javac/jvm/Gen.java --- a/src/share/classes/com/sun/tools/javac/jvm/Gen.java Fri May 31 10:28:30 2013 +0100 +++ b/src/share/classes/com/sun/tools/javac/jvm/Gen.java Mon Jun 10 09:52:54 2013 +0100 @@ -518,7 +518,7 @@ // Insert any instance initializers into all constructors. if (initCode.length() != 0) { List inits = initCode.toList(); - initTAs.addAll(c.annotations.getInitTypeAttributes()); + initTAs.addAll(c.getInitTypeAttributes()); List initTAlist = initTAs.toList(); for (JCTree t : methodDefs) { normalizeMethod((JCMethodDecl)t, inits, initTAlist); @@ -541,9 +541,9 @@ methodDefs.append(make.MethodDef(clinit, block)); if (!clinitTAs.isEmpty()) - clinit.annotations.appendUniqueTypes(clinitTAs.toList()); - if (!c.annotations.getClassInitTypeAttributes().isEmpty()) - clinit.annotations.appendUniqueTypes(c.annotations.getClassInitTypeAttributes()); + clinit.appendUniqueTypeAttributes(clinitTAs.toList()); + if (!c.getClassInitTypeAttributes().isEmpty()) + clinit.appendUniqueTypeAttributes(c.getClassInitTypeAttributes()); } // Return all method definitions. return methodDefs.toList(); @@ -560,7 +560,7 @@ nonfieldTAs.add(ta); } } - sym.annotations.setTypeAttributes(fieldTAs.toList()); + sym.setTypeAttributes(fieldTAs.toList()); return nonfieldTAs.toList(); } @@ -618,7 +618,7 @@ if (md.body.endpos == Position.NOPOS) md.body.endpos = TreeInfo.endPos(md.body.stats.last()); - md.sym.annotations.appendUniqueTypes(initTAs); + md.sym.appendUniqueTypeAttributes(initTAs); } } diff -r 76d08c649607 -r da8d0ee0938e src/share/classes/com/sun/tools/javac/jvm/JNIWriter.java --- a/src/share/classes/com/sun/tools/javac/jvm/JNIWriter.java Fri May 31 10:28:30 2013 +0100 +++ b/src/share/classes/com/sun/tools/javac/jvm/JNIWriter.java Mon Jun 10 09:52:54 2013 +0100 @@ -160,7 +160,7 @@ for (Scope.Entry i = c.members_field.elems; i != null; i = i.sibling) { if (i.sym.kind == Kinds.MTH && (i.sym.flags() & Flags.NATIVE) != 0) return true; - for (Attribute.Compound a: i.sym.annotations.getDeclarationAttributes()) { + for (Attribute.Compound a: i.sym.getDeclarationAttributes()) { if (a.type.tsym == syms.nativeHeaderType.tsym) return true; } diff -r 76d08c649607 -r da8d0ee0938e src/share/classes/com/sun/tools/javac/parser/JavacParser.java --- a/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Fri May 31 10:28:30 2013 +0100 +++ b/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Mon Jun 10 09:52:54 2013 +0100 @@ -1535,11 +1535,18 @@ outer: for (int lookahead = 0 ; ; lookahead++) { TokenKind tk = S.token(lookahead).kind; switch (tk) { - case EXTENDS: case SUPER: case COMMA: + case COMMA: type = true; - case QUES: case DOT: case AMP: + case EXTENDS: case SUPER: case DOT: case AMP: //skip break; + case QUES: + if (peekToken(lookahead, EXTENDS) || + peekToken(lookahead, SUPER)) { + //wildcards + type = true; + } + break; case BYTE: case SHORT: case INT: case LONG: case FLOAT: case DOUBLE: case BOOLEAN: case CHAR: if (peekToken(lookahead, RPAREN)) { diff -r 76d08c649607 -r da8d0ee0938e src/share/classes/com/sun/tools/javac/resources/javac.properties --- a/src/share/classes/com/sun/tools/javac/resources/javac.properties Fri May 31 10:28:30 2013 +0100 +++ b/src/share/classes/com/sun/tools/javac/resources/javac.properties Mon Jun 10 09:52:54 2013 +0100 @@ -1,5 +1,5 @@ # -# Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -146,11 +146,15 @@ Enable or disable specific warnings javac.opt.Xdoclint=\ Enable recommended checks for problems in javadoc comments +# L10N: do not localize: all none javac.opt.Xdoclint.subopts = \ - (all|[-])[/] + (all|none|[-])[/] + +# L10N: do not localize: accessibility html missing reference syntax +# L10N: do not localize: public protected package private javac.opt.Xdoclint.custom=\n\ \ Enable or disable specific checks for problems in javadoc comments,\n\ -\ where is one of accessibility, html, reference, or syntax,\n\ +\ where is one of accessibility, html, missing, reference, or syntax,\n\ \ and is one of public, protected, package, or private. javac.opt.Xstdout=\ Redirect standard output diff -r 76d08c649607 -r da8d0ee0938e src/share/classes/com/sun/tools/javac/sym/CreateSymbols.java --- a/src/share/classes/com/sun/tools/javac/sym/CreateSymbols.java Fri May 31 10:28:30 2013 +0100 +++ b/src/share/classes/com/sun/tools/javac/sym/CreateSymbols.java Mon Jun 10 09:52:54 2013 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -225,11 +225,11 @@ } ClassSymbol cs = (ClassSymbol) sym; if (addLegacyAnnotation) { - cs.annotations.prepend(List.of(proprietaryAnno)); + cs.prependAttributes(List.of(proprietaryAnno)); } int p = profiles.getProfile(cs.fullname.toString().replace(".", "/")); if (0 < p && p < profileAnnos.length) - cs.annotations.prepend(List.of(profileAnnos[p])); + cs.prependAttributes(List.of(profileAnnos[p])); writeClass(pool, cs, writer); } diff -r 76d08c649607 -r da8d0ee0938e src/share/classes/com/sun/tools/javac/tree/JCTree.java --- a/src/share/classes/com/sun/tools/javac/tree/JCTree.java Fri May 31 10:28:30 2013 +0100 +++ b/src/share/classes/com/sun/tools/javac/tree/JCTree.java Mon Jun 10 09:52:54 2013 +0100 @@ -700,7 +700,7 @@ public List getTypeParameters() { return typarams; } - public JCTree getExtendsClause() { return extending; } + public JCExpression getExtendsClause() { return extending; } public List getImplementsClause() { return implementing; } @@ -1175,7 +1175,7 @@ return v.visitTry(this, d); } @Override - public List getResources() { + public List getResources() { return resources; } @Override @@ -1392,8 +1392,8 @@ */ public static class JCThrow extends JCStatement implements ThrowTree { public JCExpression expr; - protected JCThrow(JCTree expr) { - this.expr = (JCExpression)expr; + protected JCThrow(JCExpression expr) { + this.expr = expr; } @Override public void accept(Visitor v) { v.visitThrow(this); } @@ -2466,7 +2466,7 @@ JCBreak Break(Name label); JCContinue Continue(Name label); JCReturn Return(JCExpression expr); - JCThrow Throw(JCTree expr); + JCThrow Throw(JCExpression expr); JCAssert Assert(JCExpression cond, JCExpression detail); JCMethodInvocation Apply(List typeargs, JCExpression fn, diff -r 76d08c649607 -r da8d0ee0938e src/share/classes/com/sun/tools/javac/tree/TreeCopier.java --- a/src/share/classes/com/sun/tools/javac/tree/TreeCopier.java Fri May 31 10:28:30 2013 +0100 +++ b/src/share/classes/com/sun/tools/javac/tree/TreeCopier.java Mon Jun 10 09:52:54 2013 +0100 @@ -340,7 +340,7 @@ public JCTree visitThrow(ThrowTree node, P p) { JCThrow t = (JCThrow) node; - JCTree expr = copy(t.expr, p); + JCExpression expr = copy(t.expr, p); return M.at(t.pos).Throw(expr); } diff -r 76d08c649607 -r da8d0ee0938e src/share/classes/com/sun/tools/javac/tree/TreeInfo.java --- a/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java Fri May 31 10:28:30 2013 +0100 +++ b/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java Mon Jun 10 09:52:54 2013 +0100 @@ -1131,6 +1131,14 @@ private static class TypeAnnotationFinder extends TreeScanner { public boolean foundTypeAnno = false; + + @Override + public void scan(JCTree tree) { + if (foundTypeAnno || tree == null) + return; + super.scan(tree); + } + public void visitAnnotation(JCAnnotation tree) { foundTypeAnno = foundTypeAnno || tree.hasTag(TYPE_ANNOTATION); } diff -r 76d08c649607 -r da8d0ee0938e src/share/classes/com/sun/tools/javac/tree/TreeMaker.java --- a/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java Fri May 31 10:28:30 2013 +0100 +++ b/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java Mon Jun 10 09:52:54 2013 +0100 @@ -332,7 +332,7 @@ return tree; } - public JCThrow Throw(JCTree expr) { + public JCThrow Throw(JCExpression expr) { JCThrow tree = new JCThrow(expr); tree.pos = pos; return tree; diff -r 76d08c649607 -r da8d0ee0938e src/share/classes/com/sun/tools/javac/util/Convert.java --- a/src/share/classes/com/sun/tools/javac/util/Convert.java Fri May 31 10:28:30 2013 +0100 +++ b/src/share/classes/com/sun/tools/javac/util/Convert.java Mon Jun 10 09:52:54 2013 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,6 +28,24 @@ /** Utility class for static conversion methods between numbers * and strings in various formats. * + *

Note regarding UTF-8. + * The JVMS defines its own version of the UTF-8 format so that it + * contains no zero bytes (modified UTF-8). This is not actually the same + * as Charset.forName("UTF-8"). + * + *

+ * See also: + *

+ * + * The methods here support modified UTF-8. + * *

This is NOT part of any supported API. * If you write code that depends on this, you do so at your own risk. * This code and its internal interfaces are subject to change or diff -r 76d08c649607 -r da8d0ee0938e src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java --- a/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java Fri May 31 10:28:30 2013 +0100 +++ b/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java Mon Jun 10 09:52:54 2013 +0100 @@ -125,6 +125,13 @@ return sb.toString(); } + @Override + public String formatMessage(JCDiagnostic diag, Locale l) { + nameSimplifier = new ClassNameSimplifier(); + preprocessDiagnostic(diag); + return super.formatMessage(diag, l); + } + /** * Sets the type/symbol printer used by this formatter. * @param printer the rich printer to be set diff -r 76d08c649607 -r da8d0ee0938e src/share/classes/com/sun/tools/javac/util/UnsharedNameTable.java --- a/src/share/classes/com/sun/tools/javac/util/UnsharedNameTable.java Fri May 31 10:28:30 2013 +0100 +++ b/src/share/classes/com/sun/tools/javac/util/UnsharedNameTable.java Mon Jun 10 09:52:54 2013 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -125,8 +125,6 @@ System.arraycopy(cs, start, bytes, 0, len); n = new NameImpl(this, bytes, index++); - System.arraycopy(cs, start, n.bytes, 0, len); - HashEntry newEntry = new HashEntry(n); if (previousNonNullTableEntry == null) { // We are not the first name with that hashCode. diff -r 76d08c649607 -r da8d0ee0938e src/share/classes/com/sun/tools/javadoc/Start.java --- a/src/share/classes/com/sun/tools/javadoc/Start.java Fri May 31 10:28:30 2013 +0100 +++ b/src/share/classes/com/sun/tools/javadoc/Start.java Mon Jun 10 09:52:54 2013 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -156,21 +156,8 @@ usage(true); } - - /** - * Usage - */ - private void usage(boolean exit) { - // RFE: it would be better to replace the following with code to - // write a header, then help for each option, then a footer. - messager.notice("main.usage"); - - // let doclet print usage information (does nothing on error) - if (docletInvoker != null) { - docletInvoker.optionLength("-help"); - } - - if (exit) exit(); + void usage(boolean exit) { + usage("main.usage", "-help", null, exit); } @Override @@ -178,11 +165,28 @@ Xusage(true); } - /** - * Usage - */ - private void Xusage(boolean exit) { - messager.notice("main.Xusage"); + void Xusage(boolean exit) { + usage("main.Xusage", "-X", "main.Xusage.foot", exit); + } + + private void usage(String main, String doclet, String foot, boolean exit) { + // RFE: it would be better to replace the following with code to + // write a header, then help for each option, then a footer. + messager.notice(main); + + // let doclet print usage information (does nothing on error) + if (docletInvoker != null) { + // RFE: this is a pretty bad way to get the doclet to show + // help info. Moreover, the output appears on stdout, + // and not on any of the standard streams passed + // to javadoc, and in particular, not to the noticeWriter + // But, to fix this, we need to fix the Doclet API. + docletInvoker.optionLength(doclet); + } + + if (foot != null) + messager.notice(foot); + if (exit) exit(); } diff -r 76d08c649607 -r da8d0ee0938e src/share/classes/com/sun/tools/javadoc/resources/javadoc.properties --- a/src/share/classes/com/sun/tools/javadoc/resources/javadoc.properties Fri May 31 10:28:30 2013 +0100 +++ b/src/share/classes/com/sun/tools/javadoc/resources/javadoc.properties Mon Jun 10 09:52:54 2013 +0100 @@ -1,5 +1,5 @@ # -# Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -27,35 +27,39 @@ main.error={0} error main.warnings={0} warnings main.warning={0} warning -main.usage=usage: javadoc [options] [packagenames] [sourcefiles] [@files]\n\ - -overview Read overview documentation from HTML file\n\ - -public Show only public classes and members\n\ - -protected Show protected/public classes and members (default)\n\ - -package Show package/protected/public classes and members\n\ - -private Show all classes and members\n\ - -help Display command line options and exit\n\ - -doclet Generate output via alternate doclet\n\ - -docletpath Specify where to find doclet class files\n\ - -sourcepath Specify where to find source files\n\ - -classpath Specify where to find user class files\n\ - -exclude Specify a list of packages to exclude\n\ - -subpackages Specify subpackages to recursively load\n\ - -breakiterator Compute 1st sentence with BreakIterator\n\ - -bootclasspath Override location of class files loaded\n\ -\t\t\t by the bootstrap class loader\n\ - -source Provide source compatibility with specified release\n\ - -extdirs Override location of installed extensions\n\ - -verbose Output messages about what Javadoc is doing\n\ - -locale Locale to be used, e.g. en_US or en_US_WIN\n\ - -encoding Source file encoding name\n\ - -quiet Do not display status messages\n\ - -J Pass directly to the runtime system\n\ - -X Print a synopsis of nonstandard options\n + +main.usage=Usage: javadoc [options] [packagenames] [sourcefiles] [@files]\n\ +\ -overview Read overview documentation from HTML file\n\ +\ -public Show only public classes and members\n\ +\ -protected Show protected/public classes and members (default)\n\ +\ -package Show package/protected/public classes and members\n\ +\ -private Show all classes and members\n\ +\ -help Display command line options and exit\n\ +\ -doclet Generate output via alternate doclet\n\ +\ -docletpath Specify where to find doclet class files\n\ +\ -sourcepath Specify where to find source files\n\ +\ -classpath Specify where to find user class files\n\ +\ -exclude Specify a list of packages to exclude\n\ +\ -subpackages Specify subpackages to recursively load\n\ +\ -breakiterator Compute first sentence with BreakIterator\n\ +\ -bootclasspath Override location of class files loaded\n\ +\ by the bootstrap class loader\n\ +\ -source Provide source compatibility with specified release\n\ +\ -extdirs Override location of installed extensions\n\ +\ -verbose Output messages about what Javadoc is doing\n\ +\ -locale Locale to be used, e.g. en_US or en_US_WIN\n\ +\ -encoding Source file encoding name\n\ +\ -quiet Do not display status messages\n\ +\ -J Pass directly to the runtime system\n\ +\ -X Print a synopsis of nonstandard options and exit\n + main.Xusage=\ - -Xmaxerrs Set the maximum number of errors to print\n\ - -Xmaxwarns Set the maximum number of warnings to print\n\ -\n\ +\ -Xmaxerrs Set the maximum number of errors to print\n\ +\ -Xmaxwarns Set the maximum number of warnings to print\n + +main.Xusage.foot=\ These options are non-standard and subject to change without notice. + main.option.already.seen=The {0} option may be specified no more than once. main.requires_argument=option {0} requires an argument. main.locale_first=option -locale must be first on the command line. diff -r 76d08c649607 -r da8d0ee0938e src/share/classes/javax/lang/model/AnnotatedConstruct.java --- a/src/share/classes/javax/lang/model/AnnotatedConstruct.java Fri May 31 10:28:30 2013 +0100 +++ b/src/share/classes/javax/lang/model/AnnotatedConstruct.java Mon Jun 10 09:52:54 2013 +0100 @@ -39,35 +39,76 @@ * are on a declaration, whereas annotations on a type are on * a specific use of a type name. * - * The terms directly present and present are used + * The terms directly present, present, + * indirectly present, and associated are used * throughout this interface to describe precisely which annotations - * are returned by methods: + * are returned by the methods defined herein. * - *

An annotation A is directly present on a - * construct E if E is annotated, and: + *

In the definitions below, an annotation A has an + * annotation type AT. If AT is a repeatable annotation + * type, the type of the containing annotation is ATC. + * + *

Annotation A is directly present on a construct + * C if either: * *

    * - *
  • for an invocation of {@code getAnnotation(Class)} or - * {@code getAnnotationMirrors()}, E's annotations contain A. + *
  • A is explicitly or implicitly declared as applying to + * the source code representation of C. * - *
  • for an invocation of {@code getAnnotationsByType(Class)}, - * E's annotations either contain A or, if the type of - * A is repeatable, contain exactly one annotation whose value - * element contains A and whose type is the containing - * annotation type of A's type. + *

    Typically, if exactly one annotation of type AT appears in + * the source code of representation of C, then A is + * explicitly declared as applying to C. + * + * If there are multiple annotations of type AT present on + * C, then if AT is repeatable annotation type, an + * annotation of type ATC is implicitly declared on C. + * + *

  • A representation of A appears in the executable output + * for C, such as the {@code RuntimeVisibleAnnotations} or + * {@code RuntimeVisibleParameterAnnotations} attributes of a class + * file. * *
* - *

An annotation A is present on a construct E if either: + *

An annotation A is present on a + * construct C if either: + *

    + * + *
  • A is directly present on C. + * + *
  • No annotation of type AT is directly present on + * C, and C is a class and AT is inheritable + * and A is present on the superclass of C. + * + *
+ * + * An annotation A is indirectly present on a construct + * C if both: * *
    - *
  • A is directly present on E; or * - *
  • A is not directly present on E, and - * E is an element representing a class, and A's type - * is inheritable, and A is present on the element - * representing the superclass of E. + *
  • AT is a repeatable annotation type with a containing + * annotation type ATC. + * + *
  • An annotation of type ATC is directly present on + * C and A is an annotation included in the result of + * calling the {@code value} method of the directly present annotation + * of type ATC. + * + *
+ * + * An annotation A is associated with a construct + * C if either: + * + *
    + * + *
  • A is directly or indirectly present on C. + * + *
  • No annotation of type AT is directly or indirectly + * present on C, and C is a class, and AT is + * inheritable, and A is associated with the superclass of + * C. * *
* @@ -86,9 +127,8 @@ List getAnnotationMirrors(); /** - * Returns this construct's annotation of the - * specified type if such an annotation is present, else {@code - * null}. + * Returns this construct's annotation of the specified type if + * such an annotation is present, else {@code null}. * *

The annotation returned by this method could contain an element * whose value is of type {@code Class}. @@ -118,9 +158,8 @@ * @param the annotation type * @param annotationType the {@code Class} object corresponding to * the annotation type - * @return this element's or type use's annotation for the - * specified annotation type if present on this element, else - * {@code null} + * @return this construct's annotation for the specified + * annotation type if present, else {@code null} * * @see #getAnnotationMirrors() * @see java.lang.reflect.AnnotatedElement#getAnnotation @@ -134,10 +173,16 @@ A getAnnotation(Class annotationType); /** - * Returns annotations that are present on this construct. + * Returns annotations that are associated with this construct. * - * If there are no annotations present on this construct, - * the return value is an array of length 0. + * If there are no annotations associated with this construct, the + * return value is an array of length 0. + * + * The order of annotations which are directly or indirectly + * present on a construct C is computed as if indirectly present + * annotations on C are directly present on C in place of their + * container annotation, in the order in which they appear in the + * value element of the container annotation. * * The difference between this method and {@link #getAnnotation(Class)} * is that this method detects if its argument is a repeatable @@ -172,8 +217,8 @@ * @param the annotation type * @param annotationType the {@code Class} object corresponding to * the annotation type - * @return this element's annotations for the specified annotation - * type if present on this element, else an empty array + * @return this construct's annotations for the specified annotation + * type if present on this construct, else an empty array * * @see #getAnnotationMirrors() * @see #getAnnotation(java.lang.Class) diff -r 76d08c649607 -r da8d0ee0938e src/share/classes/javax/lang/model/util/Elements.java --- a/src/share/classes/javax/lang/model/util/Elements.java Fri May 31 10:28:30 2013 +0100 +++ b/src/share/classes/javax/lang/model/util/Elements.java Mon Jun 10 09:52:54 2013 +0100 @@ -143,12 +143,13 @@ List getAllMembers(TypeElement type); /** - * Returns all annotations of an element, whether - * inherited or directly present. + * Returns all annotations present on an element, whether + * directly present or present via inheritance. * * @param e the element being examined * @return all annotations of the element * @see Element#getAnnotationMirrors + * @see javax.lang.model.AnnotatedConstruct */ List getAllAnnotationMirrors(Element e); diff -r 76d08c649607 -r da8d0ee0938e src/share/sample/language/model/CoreReflectionFactory.java --- a/src/share/sample/language/model/CoreReflectionFactory.java Fri May 31 10:28:30 2013 +0100 +++ b/src/share/sample/language/model/CoreReflectionFactory.java Mon Jun 10 09:52:54 2013 +0100 @@ -439,15 +439,11 @@ ReflectionElement getGenericElement(); // Functionality specific to the specialization - - // Conceptually should have an override for getSource - // returning GenericDeclaration, but GenericDeclaration - // doesn't currently implement AnnotatedElement. -// /** -// * {@inheritDoc} -// */ -// @Override -// java.lang.reflect.GenericDeclaration getSource(); + /** + * {@inheritDoc} + */ + @Override + java.lang.reflect.TypeVariable getSource(); } /** @@ -1296,8 +1292,8 @@ } @Override - public AnnotatedElement getSource() { - return (AnnotatedElement)source; + public java.lang.reflect.TypeVariable getSource() { + return sourceTypeVar; } protected java.lang.reflect.TypeVariable getSourceTypeVar() { diff -r 76d08c649607 -r da8d0ee0938e test/com/sun/javadoc/testHelpOption/TestHelpOption.java --- a/test/com/sun/javadoc/testHelpOption/TestHelpOption.java Fri May 31 10:28:30 2013 +0100 +++ b/test/com/sun/javadoc/testHelpOption/TestHelpOption.java Mon Jun 10 09:52:54 2013 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -78,7 +78,6 @@ {STANDARD_OUTPUT, "-tag "}, {STANDARD_OUTPUT, "-taglet "}, {STANDARD_OUTPUT, "-tagletpath "}, - {STANDARD_OUTPUT, "-Xdocrootparent "}, {STANDARD_OUTPUT, "-charset "}, {STANDARD_OUTPUT, "-helpfile "}, {STANDARD_OUTPUT, "-linksource "}, diff -r 76d08c649607 -r da8d0ee0938e test/com/sun/javadoc/testXOption/TestXOption.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/com/sun/javadoc/testXOption/TestXOption.java Mon Jun 10 09:52:54 2013 +0100 @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8007687 + * @summary Make sure that the -X option works properly. + * @library ../lib/ + * @build JavadocTester TestXOption + * @run main TestXOption + */ + +public class TestXOption extends JavadocTester { + + //Test information. + private static final String BUG_ID = "8007687"; + + //Javadoc arguments. + private static final String[] ARGS = new String[] { + "-d", BUG_ID, "-sourcepath", SRC_DIR, "-X", + SRC_DIR + FS + "TestXOption.java" + }; + + private static final String[] ARGS2 = new String[] { + "-d", BUG_ID, "-sourcepath", SRC_DIR, + SRC_DIR + FS + "TestXOption.java" + }; + + private static final String[][] TEST = { + {NOTICE_OUTPUT, "-Xmaxerrs "}, + {NOTICE_OUTPUT, "-Xmaxwarns "}, + {STANDARD_OUTPUT, "-Xdocrootparent "}, + {STANDARD_OUTPUT, "-Xdoclint "}, + {STANDARD_OUTPUT, "-Xdoclint:"}, + }; + private static final String[][] NEGATED_TEST = NO_TEST; + + //The help option should not crash the doclet. + private static final int EXPECTED_EXIT_CODE = 0; + + /** + * The entry point of the test. + * @param args the array of command line arguments. + */ + public static void main(String[] args) { + TestXOption tester = new TestXOption(); + int actualExitCode = run(tester, ARGS, TEST, NEGATED_TEST); + tester.checkExitCode(EXPECTED_EXIT_CODE, actualExitCode); + tester.printSummary(); + } + + /** + * {@inheritDoc} + */ + public String getBugId() { + return BUG_ID; + } + + /** + * {@inheritDoc} + */ + public String getBugName() { + return getClass().getName(); + } +} diff -r 76d08c649607 -r da8d0ee0938e test/tools/doclint/ResourceTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/doclint/ResourceTest.java Mon Jun 10 09:52:54 2013 +0100 @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8006615 + * @summary move remaining messages into resource bundle + */ + +import java.io.IOException; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Arrays; +import java.util.List; +import java.util.Locale; + +import com.sun.tools.doclint.DocLint; + +public class ResourceTest { + public static void main(String... args) throws Exception { + Locale prev = Locale.getDefault(); + Locale.setDefault(Locale.ENGLISH); + try { + new ResourceTest().run(); + } finally { + Locale.setDefault(prev); + } + } + + public void run() throws Exception { + test(Arrays.asList("-help"), + Arrays.asList("Usage:", "Options")); + test(Arrays.asList("-foo"), + Arrays.asList("bad option: -foo")); + } + + void test(List opts, List expects) throws Exception { + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + try { + new DocLint().run(pw, opts.toArray(new String[opts.size()])); + } catch (DocLint.BadArgs e) { + pw.println("BadArgs: " + e.getMessage()); + } catch (IOException e) { + pw.println("IOException: " + e.getMessage()); + } finally { + pw.close(); + } + + String out = sw.toString(); + if (!out.isEmpty()) { + System.err.println(out); + } + + for (String e: expects) { + if (!out.contains(e)) + throw new Exception("expected string not found: " + e); + } + } +} + diff -r 76d08c649607 -r da8d0ee0938e test/tools/doclint/RunTest.java --- a/test/tools/doclint/RunTest.java Fri May 31 10:28:30 2013 +0100 +++ b/test/tools/doclint/RunTest.java Mon Jun 10 09:52:54 2013 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,20 +22,13 @@ */ /* @test - * @bug 8004832 + * @bug 8004832 8000103 * @summary Add new doclint package - * @bug 8000103 * @summary Create doclint utility */ -import com.sun.tools.doclint.DocLint; -import com.sun.tools.doclint.DocLint.BadArgs; -import java.io.ByteArrayOutputStream; import java.io.File; -import java.io.FilterOutputStream; import java.io.IOException; -import java.io.OutputStream; -import java.io.PrintStream; import java.io.PrintWriter; import java.io.StringWriter; import java.lang.annotation.Annotation; @@ -44,6 +37,9 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import com.sun.tools.doclint.DocLint; +import com.sun.tools.doclint.DocLint.BadArgs; + /** javadoc error on toplevel: a & b. */ public class RunTest { /** javadoc error on member: a < b */ diff -r 76d08c649607 -r da8d0ee0938e test/tools/doclint/html/ListTagsTest.java --- a/test/tools/doclint/html/ListTagsTest.java Fri May 31 10:28:30 2013 +0100 +++ b/test/tools/doclint/html/ListTagsTest.java Mon Jun 10 09:52:54 2013 +0100 @@ -1,33 +1,10 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 8006251 + * @test /nodynamiccopyright/ + * @bug 8006251 8013405 * @summary test list tags * @library .. * @build DocLintTester - * @run main DocLintTester -Xmsgs ListTagsTest.java + * @run main DocLintTester -Xmsgs -ref ListTagsTest.out ListTagsTest.java */ /** */ @@ -35,6 +12,9 @@ /** *

abc
def
*
  1. abc
+ *
  1. abc
+ *
  1. bad
+ *
  1. bad
*
  • abc
*/ public void supportedTags() { } diff -r 76d08c649607 -r da8d0ee0938e test/tools/doclint/html/ListTagsTest.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/doclint/html/ListTagsTest.out Mon Jun 10 09:52:54 2013 +0100 @@ -0,0 +1,7 @@ +ListTagsTest.java:16: error: attribute lacks value + *
  1. bad
+ ^ +ListTagsTest.java:17: error: attribute value is not a number + *
  1. bad
+ ^ +2 errors diff -r 76d08c649607 -r da8d0ee0938e test/tools/doclint/tool/RunTest.java --- a/test/tools/doclint/tool/RunTest.java Fri May 31 10:28:30 2013 +0100 +++ b/test/tools/doclint/tool/RunTest.java Mon Jun 10 09:52:54 2013 +0100 @@ -173,7 +173,7 @@ pw.close(); String out = sw.toString(); - String expect = "no files given"; + String expect = "No files given"; if (!Objects.equals(out.trim(), expect)) { error("unexpected output"); System.err.println("EXPECT>>" + expect + "<<"); diff -r 76d08c649607 -r da8d0ee0938e test/tools/javac/5045412/Bar.java --- a/test/tools/javac/5045412/Bar.java Fri May 31 10:28:30 2013 +0100 +++ b/test/tools/javac/5045412/Bar.java Mon Jun 10 09:52:54 2013 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,12 +24,6 @@ /** * @test * @bug 5045412 6627366 - * @compile -Xlint:serial -XDfailcomplete=java.io.Serializable Bar.java - */ - -/** - * @test - * @bug 5045412 6627366 * @compile -Xlint:serial -XDfailcomplete=java.io.Serializable Bar.java Foo.java */ diff -r 76d08c649607 -r da8d0ee0938e test/tools/javac/5045412/Foo.java --- a/test/tools/javac/5045412/Foo.java Fri May 31 10:28:30 2013 +0100 +++ b/test/tools/javac/5045412/Foo.java Mon Jun 10 09:52:54 2013 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,11 +25,6 @@ * @test * @bug 5045412 6627366 * @compile -Xlint:serial -XDfailcomplete=java.io.Serializable Foo.java - */ - -/** - * @test - * @bug 5045412 6627366 * @compile -Xlint:serial -XDfailcomplete=java.io.Serializable Foo.java Bar.java */ diff -r 76d08c649607 -r da8d0ee0938e test/tools/javac/6360970/T6360970.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/6360970/T6360970.java Mon Jun 10 09:52:54 2013 +0100 @@ -0,0 +1,25 @@ +/* + * @test /nodynamiccopyright/ + * @bug 6360970 + * @summary javac erroneously accept ambiguous field reference + * @compile/fail/ref=T6360970.out -XDrawDiagnostics T6360970.java + */ +class T6360970 { + interface A { + int i = 1; + } + + interface B { + int i = 2; + } + + interface C extends A, B { } + + static class D { + public static final int i = 0; + } + + static class E extends D implements C { } + + int i = E.i; //ambiguous +} diff -r 76d08c649607 -r da8d0ee0938e test/tools/javac/6360970/T6360970.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/6360970/T6360970.out Mon Jun 10 09:52:54 2013 +0100 @@ -0,0 +1,2 @@ +T6360970.java:24:14: compiler.err.ref.ambiguous: i, kindname.variable, i, T6360970.D, kindname.variable, i, T6360970.A +1 error diff -r 76d08c649607 -r da8d0ee0938e test/tools/javac/6567415/T6567415.java --- a/test/tools/javac/6567415/T6567415.java Fri May 31 10:28:30 2013 +0100 +++ b/test/tools/javac/6567415/T6567415.java Mon Jun 10 09:52:54 2013 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2013 Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -137,7 +137,7 @@ } }; t.start(); - t.join(1000*10); + t.join(1000*60); System.out.println(t.getState()); if (t.isAlive()) { throw new RuntimeException("Error: compilation is looping"); diff -r 76d08c649607 -r da8d0ee0938e test/tools/javac/6758789/T6758789b.out --- a/test/tools/javac/6758789/T6758789b.out Fri May 31 10:28:30 2013 +0100 +++ b/test/tools/javac/6758789/T6758789b.out Mon Jun 10 09:52:54 2013 +0100 @@ -1,5 +1,5 @@ +T6758789b.java:16:10: compiler.warn.unchecked.meth.invocation.applied: kindname.method, m, T6758789a.Foo, T6758789a.Foo, kindname.class, T6758789a T6758789b.java:16:11: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), T6758789a.Foo, T6758789a.Foo -T6758789b.java:16:10: compiler.warn.unchecked.meth.invocation.applied: kindname.method, m, T6758789a.Foo, T6758789a.Foo, kindname.class, T6758789a - compiler.err.warnings.and.werror 1 error 2 warnings diff -r 76d08c649607 -r da8d0ee0938e test/tools/javac/6889255/T6889255.java --- a/test/tools/javac/6889255/T6889255.java Fri May 31 10:28:30 2013 +0100 +++ b/test/tools/javac/6889255/T6889255.java Mon Jun 10 09:52:54 2013 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -429,9 +429,9 @@ // -- no Code attribute for the LocalVariableTable attribute if ((v.owner.flags() & Flags.ABSTRACT) != 0) return "arg" + (i - 1); - // bridge methods use xN + // bridge methods use argN. No LVT for them anymore if ((v.owner.flags() & Flags.BRIDGE) != 0) - return "x" + (i - 1); + return "arg" + (i - 1); // The rest of this method assumes the local conventions in the test program Type t = v.type; diff -r 76d08c649607 -r da8d0ee0938e test/tools/javac/8015701/AnonymousParameters.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/8015701/AnonymousParameters.java Mon Jun 10 09:52:54 2013 +0100 @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8015701 + * @summary javac should generate method parameters correctly. + * @compile -parameters AnonymousParameters.java + * @run main AnonymousParameters + */ +import java.lang.Class; +import java.lang.reflect.Constructor; +import java.lang.reflect.Parameter; +import java.util.concurrent.Callable; + +public class AnonymousParameters { + + String[] names = { + "this$0", + "val$message" + }; + + public static void main(String... args) throws Exception { + new AnonymousParameters().run(); + } + + void run() throws Exception { + Class cls = new ParameterNames().makeInner("hello").getClass(); + Constructor ctor = cls.getDeclaredConstructors()[0]; + Parameter[] params = ctor.getParameters(); + + if(params.length == 2) { + for(int i = 0; i < 2; i++) { + System.err.println("Testing parameter " + params[i].getName()); + if(!params[i].getName().equals(names[i])) + error("Expected parameter name " + names[i] + + " got " + params[i].getName()); + } + } else + error("Expected 2 parameters"); + + if(0 != errors) + throw new Exception("MethodParameters test failed with " + + errors + " errors"); + } + + void error(String msg) { + System.err.println("Error: " + msg); + errors++; + } + + int errors; +} + +class ParameterNames { + + public Callable makeInner(final String message) { + return new Callable() { + public String call() throws Exception { + return message; + } + }; + } + + public static void main(String... args) throws Exception { + ParameterNames test = new ParameterNames(); + System.out.println(test.makeInner("Hello").call()); + } +} diff -r 76d08c649607 -r da8d0ee0938e test/tools/javac/Diagnostics/7116676/T7116676.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/Diagnostics/7116676/T7116676.java Mon Jun 10 09:52:54 2013 +0100 @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7116676 + * @summary RichDiagnosticFormatter throws NPE when formatMessage is called directly + */ + +import com.sun.source.util.JavacTask; +import com.sun.tools.javac.api.ClientCodeWrapper.Trusted; +import com.sun.tools.javac.api.DiagnosticFormatter; +import com.sun.tools.javac.api.JavacTaskImpl; +import com.sun.tools.javac.util.Assert; +import com.sun.tools.javac.util.JCDiagnostic; +import com.sun.tools.javac.util.Log; +import java.io.IOException; +import java.net.URI; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Locale; +import javax.tools.Diagnostic; +import javax.tools.DiagnosticListener; +import javax.tools.JavaCompiler; +import javax.tools.JavaFileObject; +import javax.tools.SimpleJavaFileObject; +import javax.tools.ToolProvider; + +public class T7116676 { + + public static void main(String[] args) throws Exception { + T7116676 test = new T7116676(); + test.testThroughFormatterFormat(); + } + + static class JavaSource extends SimpleJavaFileObject { + private String text = "package test;\n" + + "public class Test {\n" + + " private void t(java.util.List l) {\n" + + " t(java.util.Collections.singleton(l));\n" + + "} }"; + + public JavaSource() { + super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE); + } + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) { + return text; + } + } + + void assertEquals(String req, String found) { + if (!found.equals(req)) { + throw new AssertionError(String.format("Error. Found: \n\n%s ; Expected: \n\n%s", found, req)); + } + } + + public void testThroughFormatterFormat() throws IOException { + final JavaCompiler tool = ToolProvider.getSystemJavaCompiler(); + DiagnosticChecker dc = new DiagnosticChecker("compiler.err.prob.found.req"); + JavacTask ct = (JavacTask)tool.getTask(null, null, dc, null, null, Arrays.asList(new JavaSource())); + ct.analyze(); + DiagnosticFormatter formatter = + Log.instance(((JavacTaskImpl) ct).getContext()).getDiagnosticFormatter(); + String msg = formatter.formatMessage(dc.diag, Locale.getDefault()); + //no redundant package qualifiers + Assert.check(msg.indexOf("java.") == -1, msg); + } + + @Trusted + private static final class DiagnosticChecker implements DiagnosticListener { + + String expectedKey; + JCDiagnostic diag; + + DiagnosticChecker(String expectedKey) { + this.expectedKey = expectedKey; + } + + @Override + public void report(Diagnostic diagnostic) { + JCDiagnostic diag = (JCDiagnostic)diagnostic; + if (diagnostic.getCode().equals(expectedKey)) { + this.diag = diag; + } + } + } +} diff -r 76d08c649607 -r da8d0ee0938e test/tools/javac/HiddenAbstractMethod/Test --- a/test/tools/javac/HiddenAbstractMethod/Test Fri May 31 10:28:30 2013 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,12 +0,0 @@ -/* - * @test - * @bug 1240831 - * @summary Certain classes should have been reported as abstract, but - * the compiler failed to detect this. This comes up when a - * subclass declares a method with the same name as an - * unimplemented, unaccessible method in a superclass. Even though - * the method has the same name, it does not override. - * @author turnidge - * - * @compile/fail -nowrite one/Parent.java two/Child.java - */ diff -r 76d08c649607 -r da8d0ee0938e test/tools/javac/HiddenAbstractMethod/Test.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/HiddenAbstractMethod/Test.java Mon Jun 10 09:52:54 2013 +0100 @@ -0,0 +1,12 @@ +/* + * @test + * @bug 1240831 + * @summary Certain classes should have been reported as abstract, but + * the compiler failed to detect this. This comes up when a + * subclass declares a method with the same name as an + * unimplemented, unaccessible method in a superclass. Even though + * the method has the same name, it does not override. + * @author turnidge + * + * @compile/fail one/Parent.java two/Child.java + */ diff -r 76d08c649607 -r da8d0ee0938e test/tools/javac/MethodParameters/ClassFileVisitor.java --- a/test/tools/javac/MethodParameters/ClassFileVisitor.java Fri May 31 10:28:30 2013 +0100 +++ b/test/tools/javac/MethodParameters/ClassFileVisitor.java Mon Jun 10 09:52:54 2013 +0100 @@ -21,10 +21,8 @@ * questions. */ +import java.io.*; import com.sun.tools.classfile.*; -import java.io.*; -import javax.lang.model.element.*; -import java.util.*; /** * The {@code ClassFileVisitor} reads a class file using the @@ -150,6 +148,7 @@ public int mNumParams; public boolean mSynthetic; public boolean mIsConstructor; + public boolean mIsBridge; public String prefix; void visitMethod(Method method, StringBuilder sb) throws Exception { @@ -162,6 +161,7 @@ mSynthetic = method.access_flags.is(AccessFlags.ACC_SYNTHETIC); mIsConstructor = mName.equals(""); prefix = cname + "." + mName + "() - "; + mIsBridge = method.access_flags.is(AccessFlags.ACC_BRIDGE); sb.append(cname).append(".").append(mName).append("("); @@ -316,13 +316,16 @@ } expect = "this\\$[0-n]*"; } - } else if (isAnon) { - // not an implementation gurantee, but okay for now - expect = "x[0-n]*"; } } else if (isEnum && mNumParams == 1 && index == 0 && mName.equals("valueOf")) { expect = "name"; allowMandated = true; + } else if (mIsBridge) { + allowSynthetic = true; + /* you can't expect an special name for bridges' parameters. + * The name of the original parameters are now copied. + */ + expect = null; } if (mandated) sb.append("!"); if (synthetic) sb.append("!!"); diff -r 76d08c649607 -r da8d0ee0938e test/tools/javac/MethodParameters/ReflectionVisitor.java --- a/test/tools/javac/MethodParameters/ReflectionVisitor.java Fri May 31 10:28:30 2013 +0100 +++ b/test/tools/javac/MethodParameters/ReflectionVisitor.java Mon Jun 10 09:52:54 2013 +0100 @@ -22,8 +22,6 @@ */ import java.io.*; -import java.util.*; -import java.net.*; import java.lang.reflect.*; /** @@ -151,9 +149,6 @@ } expect = "this\\$[0-n]*"; } - } else if (isAnon) { - // not an implementation gurantee, but okay for now - expect = "x[0-n]*"; } // Check expected flags @@ -253,7 +248,7 @@ String expect = m.isSynthetic() ? ("arg" + i) : ((++c) + param); param = p.getName(); sb.append(sep).append(param); - if (!expect.equals(param)) { + if (!m.isBridge() && !expect.equals(param)) { error(prefix + "param[" + i + "]='" + param + "' expected '" + expect + "'"); break; diff -r 76d08c649607 -r da8d0ee0938e test/tools/javac/MethodParameters/Tester.java --- a/test/tools/javac/MethodParameters/Tester.java Fri May 31 10:28:30 2013 +0100 +++ b/test/tools/javac/MethodParameters/Tester.java Mon Jun 10 09:52:54 2013 +0100 @@ -22,7 +22,6 @@ */ import java.io.*; -import java.util.*; import java.lang.reflect.Constructor; /** diff -r 76d08c649607 -r da8d0ee0938e test/tools/javac/NonAmbiguousField/Test --- a/test/tools/javac/NonAmbiguousField/Test Fri May 31 10:28:30 2013 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,10 +0,0 @@ -/* - * @test - * @bug 4053724 - * @summary Certain non-ambiguous field references were reported by the - * compiler as ambigous. - * @author turnidge - * - * @compile -nowrite one/Parent.java two/Child.java - * @compile -nowrite one/Parent2.java two/Child2.java - */ diff -r 76d08c649607 -r da8d0ee0938e test/tools/javac/NonAmbiguousField/Test.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/NonAmbiguousField/Test.java Mon Jun 10 09:52:54 2013 +0100 @@ -0,0 +1,10 @@ +/* + * @test + * @bug 4053724 + * @summary Certain non-ambiguous field references were reported by the + * compiler as ambigous. + * @author turnidge + * + * @compile one/Parent.java two/Child.java + * @compile/fail one/Parent2.java two/Child2.java + */ diff -r 76d08c649607 -r da8d0ee0938e test/tools/javac/NonAmbiguousField/two/Child2.java --- a/test/tools/javac/NonAmbiguousField/two/Child2.java Fri May 31 10:28:30 2013 +0100 +++ b/test/tools/javac/NonAmbiguousField/two/Child2.java Mon Jun 10 09:52:54 2013 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,9 +28,7 @@ } public class Child2 extends one.Parent2 implements I { - class inner { - void method() { - System.out.println(i); - } + void method() { + System.out.println(i); } } diff -r 76d08c649607 -r da8d0ee0938e test/tools/javac/T6695379/AnnotationsAreNotCopiedToBridgeMethodsTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/T6695379/AnnotationsAreNotCopiedToBridgeMethodsTest.java Mon Jun 10 09:52:54 2013 +0100 @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6695379 + * @summary Copy method annotations and parameter annotations to synthetic + * bridge methods + * @run main AnnotationsAreNotCopiedToBridgeMethodsTest + */ + +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; +import java.io.BufferedInputStream; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import com.sun.tools.classfile.AccessFlags; +import com.sun.tools.classfile.Attribute; +import com.sun.tools.classfile.Attributes; +import com.sun.tools.classfile.ClassFile; +import com.sun.tools.classfile.Method; +import com.sun.tools.javac.util.Assert; + +public class AnnotationsAreNotCopiedToBridgeMethodsTest { + + public static void main(String[] args) throws Exception { + new AnnotationsAreNotCopiedToBridgeMethodsTest().run(); + } + + void run() throws Exception { + checkClassFile(Paths.get(System.getProperty("test.classes"), + this.getClass().getSimpleName() + "$CovariantReturnType.class")); + checkClassFile(Paths.get(System.getProperty("test.classes"), + this.getClass().getSimpleName() + + "$CovariantReturnType$VisibilityChange.class")); + } + + void checkClassFile(final Path cfilePath) throws Exception { + ClassFile classFile = ClassFile.read( + new BufferedInputStream(Files.newInputStream(cfilePath))); + for (Method method : classFile.methods) { + if (method.access_flags.is(AccessFlags.ACC_BRIDGE)) { + checkForAttr(method.attributes, + "Annotations hasn't been copied to bridge method", + Attribute.RuntimeVisibleAnnotations, + Attribute.RuntimeVisibleParameterAnnotations); + } + } + } + + void checkForAttr(Attributes attrs, String errorMsg, String... attrNames) { + for (String attrName : attrNames) { + Assert.checkNonNull(attrs.get(attrName), errorMsg); + } + } + + @Target(value = {ElementType.PARAMETER}) + @Retention(RetentionPolicy.RUNTIME) + @interface ParamAnnotation {} + + @Target(value = {ElementType.METHOD}) + @Retention(RetentionPolicy.RUNTIME) + @interface MethodAnnotation {} + + abstract class T { + B m(A a){return null;} + } + + class CovariantReturnType extends T { + @MethodAnnotation + Integer m(@ParamAnnotation Integer i) { + return i; + } + + public class VisibilityChange extends CovariantReturnType {} + + } + +} diff -r 76d08c649607 -r da8d0ee0938e test/tools/javac/T6970173/DebugPointerAtBadPositionTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/T6970173/DebugPointerAtBadPositionTest.java Mon Jun 10 09:52:54 2013 +0100 @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6970173 + * @summary Debug pointer at bad position + * @library /tools/javac/lib + * @build ToolBox + * @run main DebugPointerAtBadPositionTest + */ + +import java.io.File; +import java.nio.file.Paths; + +import com.sun.tools.classfile.ClassFile; +import com.sun.tools.classfile.Code_attribute; +import com.sun.tools.classfile.LineNumberTable_attribute; +import com.sun.tools.classfile.Method; +import com.sun.tools.javac.util.Assert; + +public class DebugPointerAtBadPositionTest { + + static final String testSource = + "public class AssertionTest {\n" + + " void lookForThisMethod() {\n" + + " int i;\n" + + " i = 33;\n" + + " assert // line 5\n" + + " i < 89:\n" + + " i < 100; // line 7\n" + + " }\n" + + "}"; + + static final int[][] expectedLNT = { + {4, 0}, + {5, 3}, + {8, 34} + }; + + static final String methodToLookFor = "lookForThisMethod"; + static final String seekMethodNotFoundMsg = + "The seek method was not found"; + static final String foundLNTLengthDifferentThanExpMsg = + "The LineNumberTable found has a length different to the expected one"; + + public static void main(String[] args) throws Exception { + new DebugPointerAtBadPositionTest().run(); + } + + void run() throws Exception { + compileTestClass(); + checkClassFile(new File(Paths.get(System.getProperty("user.dir"), + "AssertionTest.class").toUri()), methodToLookFor); + } + + void compileTestClass() throws Exception { + ToolBox.JavaToolArgs javacSuccessArgs = + new ToolBox.JavaToolArgs().setSources(testSource); + ToolBox.javac(javacSuccessArgs); + } + + void checkClassFile(final File cfile, String methodToFind) throws Exception { + ClassFile classFile = ClassFile.read(cfile); + boolean methodFound = false; + for (Method method : classFile.methods) { + if (method.getName(classFile.constant_pool).equals(methodToFind)) { + methodFound = true; + Code_attribute code = (Code_attribute) method.attributes.get("Code"); + LineNumberTable_attribute lnt = + (LineNumberTable_attribute) code.attributes.get("LineNumberTable"); + Assert.check(lnt.line_number_table_length == expectedLNT.length, + foundLNTLengthDifferentThanExpMsg); + int i = 0; + for (LineNumberTable_attribute.Entry entry: lnt.line_number_table) { + Assert.check(entry.line_number == expectedLNT[i][0] && + entry.start_pc == expectedLNT[i][1], + "LNT entry at pos " + i + " differ from expected." + + "Found " + entry.line_number + ":" + entry.start_pc + + ". Expected " + expectedLNT[i][0] + ":" + expectedLNT[i][1]); + i++; + } + } + } + Assert.check(methodFound, seekMethodNotFoundMsg); + } + + void error(String msg) { + throw new AssertionError(msg); + } + +} diff -r 76d08c649607 -r da8d0ee0938e test/tools/javac/T7053059/VerifyErrorWithDoubleAssignmentTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/T7053059/VerifyErrorWithDoubleAssignmentTest.java Mon Jun 10 09:52:54 2013 +0100 @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7053059 + * @summary VerifyError with double Assignment using a Generic Member of a Superclass + * @run main VerifyErrorWithDoubleAssignmentTest + */ + +public class VerifyErrorWithDoubleAssignmentTest { + + static class A { + D d; + + D getD() { + return null; + } + } + + static class B extends A { + Integer y; + B() { + y = d = getD(); + } + } + + public static void main(String[] args) { + new B(); + } +} diff -r 76d08c649607 -r da8d0ee0938e test/tools/javac/T7165659/InnerClassAttrMustNotHaveStrictFPFlagTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/T7165659/InnerClassAttrMustNotHaveStrictFPFlagTest.java Mon Jun 10 09:52:54 2013 +0100 @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7165659 + * @summary javac incorrectly sets strictfp access flag on inner-classes + */ + +import java.io.File; + +import com.sun.tools.classfile.AccessFlags; +import com.sun.tools.classfile.Attribute; +import com.sun.tools.classfile.ClassFile; +import com.sun.tools.classfile.InnerClasses_attribute; +import com.sun.tools.classfile.InnerClasses_attribute.Info; +import com.sun.tools.javac.util.Assert; + +public class InnerClassAttrMustNotHaveStrictFPFlagTest { + + public static void main(String[] args) throws Exception { + new InnerClassAttrMustNotHaveStrictFPFlagTest().run(); + } + + private void run() throws Exception { + File classPath = new File(System.getProperty("test.classes"), getClass().getSimpleName() + ".class"); + analyzeClassFile(classPath); + } + + void analyzeClassFile(File path) throws Exception { + ClassFile classFile = ClassFile.read(path); + InnerClasses_attribute innerClasses = + (InnerClasses_attribute) classFile.attributes.get(Attribute.InnerClasses); + for (Info classInfo : innerClasses.classes) { + Assert.check(!classInfo.inner_class_access_flags.is(AccessFlags.ACC_STRICT), + "Inner classes attribute must not have the ACC_STRICT flag set"); + } + } + + strictfp void m() { + new Runnable() { + @Override + public void run() {} + }; + } + + static strictfp class Strict extends InnerClassAttrMustNotHaveStrictFPFlagTest {} + +} diff -r 76d08c649607 -r da8d0ee0938e test/tools/javac/T7179353/GenericsAndTWRCompileErrorTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/T7179353/GenericsAndTWRCompileErrorTest.java Mon Jun 10 09:52:54 2013 +0100 @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7179353 + * @summary try-with-resources fails to compile with generic exception parameters + * @compile GenericsAndTWRCompileErrorTest.java + */ + +public class GenericsAndTWRCompileErrorTest { + + public static class Resource implements AutoCloseable { + public void close() throws E { } + } + + public void test() throws E { + try (Resource r = new Resource()) { + + } + } +} diff -r 76d08c649607 -r da8d0ee0938e test/tools/javac/T8010737/ParameterNamesAreNotCopiedToAnonymousInitTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/T8010737/ParameterNamesAreNotCopiedToAnonymousInitTest.java Mon Jun 10 09:52:54 2013 +0100 @@ -0,0 +1,239 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8010737 + * @summary javac, known parameter's names should be copied to automatically + * generated constructors for inner classes + * @run main ParameterNamesAreNotCopiedToAnonymousInitTest check_class_file check_init_symbol + */ + +import java.io.File; +import java.io.IOException; +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; +import java.nio.file.Paths; +import java.util.Arrays; + +import javax.tools.JavaCompiler; +import javax.tools.JavaFileObject; +import javax.tools.StandardJavaFileManager; +import javax.tools.ToolProvider; + +import com.sun.source.tree.CompilationUnitTree; +import com.sun.source.tree.Tree; +import com.sun.source.util.JavacTask; +import com.sun.source.util.TaskEvent; +import com.sun.source.util.TaskListener; +import com.sun.tools.classfile.ClassFile; +import com.sun.tools.classfile.Method; +import com.sun.tools.javac.api.BasicJavacTask; +import com.sun.tools.javac.code.Attribute.Compound; +import com.sun.tools.javac.code.Symbol.ClassSymbol; +import com.sun.tools.javac.code.Symbol.VarSymbol; +import com.sun.tools.javac.tree.JCTree; +import com.sun.tools.javac.tree.TreeScanner; +import com.sun.tools.javac.util.Assert; +import com.sun.tools.javac.util.Context; +import com.sun.tools.javac.util.List; +import com.sun.tools.javac.util.Names; + +public class ParameterNamesAreNotCopiedToAnonymousInitTest { + + static final String noParamsErrorMsg = + "Test most be invoked with at least one parameter: check_class_file " + + "and/or check_init_symbol"; + static final String wrongParamsErrorMsg = + "Accepted arguments are: check_class_file and check_init_symbol"; + static final String paramNameNotCopiedAssertionMsg = + "The param name hasn't been copied to the init method"; + static final String noAnnotationsForParameterMsg = + "No annotations for seek parameter"; + static final String seekMethodNotFound = + "The seek init method was not found or conditions were not met"; + static final String nonNullParamPositionsMsg = + "Parameter positions shold not be null"; + static final String compilationFailed = + "Compilation failed"; + static final String seekMethodNotFoundMsg = + "The seek method was not found"; + + static final String ParamAnnotationClassName = + ParameterNamesAreNotCopiedToAnonymousInitTest.class.getSimpleName() + "." + + ParamAnnotation.class.getSimpleName(); + + public static void main(String[] args) throws Exception { + if (args.length == 0) { + throw new Error(noParamsErrorMsg); + } + new ParameterNamesAreNotCopiedToAnonymousInitTest().run(args); + } + + void run(String[] args) throws Exception { + for (String arg : args) { + if (arg.equals("check_class_file")) { + checkClassFile(new File(Paths.get(System.getProperty("test.classes"), + this.getClass().getName() + "$initParams$1.class").toUri()), 1); + checkClassFile(new File(Paths.get(System.getProperty("test.classes"), + this.getClass().getName() + "$Generics$1.class").toUri()), 2); + } else if (arg.equals("check_init_symbol")) { + checkInitSymbol("m1", Arrays.asList(0), Arrays.asList("i")); + checkInitSymbol("m2", Arrays.asList(0, 1), Arrays.asList("t1", "t2")); + } else { + error(wrongParamsErrorMsg); + } + } + } + + void checkClassFile(final File cfile, int numberOfParams) throws Exception { + ClassFile classFile = ClassFile.read(cfile); + boolean methodFound = false; + for (Method method : classFile.methods) { + if (method.getName(classFile.constant_pool).equals("")) { + methodFound = true; + } + } + Assert.check(methodFound, seekMethodNotFoundMsg); + } + + /* This method expect a non-null ordered list of integers, listing the + * position of the parameters to be checked on the init method. Position 0 + * corresponds to the first parameter. + * + * As we are looking for a constructor of an anonymous class, the + * classOwnerName parameter must be the name of the method where the + * anonymous class is declared. + */ + void checkInitSymbol( + final String classOwnerName, + final java.util.List paramsToCheck, + final java.util.List paramNames) + throws IOException { + Assert.checkNonNull(paramsToCheck, nonNullParamPositionsMsg); + JavaCompiler c = ToolProvider.getSystemJavaCompiler(); + StandardJavaFileManager fm = c.getStandardFileManager(null, null, null); + Iterable fos = + fm.getJavaFileObjectsFromFiles( + Arrays.asList(new File(System.getProperty("test.src"), + this.getClass().getName() + ".java"))); + JavacTask task = (JavacTask) c.getTask(null, fm, null, + Arrays.asList("-d", System.getProperty("user.dir")), null, fos); + + BasicJavacTask impl = (BasicJavacTask)task; + Context context = impl.getContext(); + final Names names = Names.instance(context); + + task.addTaskListener(new TaskListener() { + + @Override + public void started(TaskEvent e) {} + + @Override + public void finished(TaskEvent e) { + class TheTreeScanner extends TreeScanner { + boolean foundAndCorrect = false; + + @Override + public void visitMethodDef(JCTree.JCMethodDecl tree) { + ClassSymbol clazz = (ClassSymbol)tree.sym.owner; + if (clazz.owner.name.toString().equals(classOwnerName) && + tree.sym.name == names.init) { + + int currentParamPos = 0; + int paramArrayIndex = 0; + + List params = tree.sym.params; + while (params.nonEmpty() && paramArrayIndex < paramsToCheck.size()) { + VarSymbol param = params.head; + if (currentParamPos == paramsToCheck.get(paramArrayIndex)) { + if (!param.name.toString() + .equals(paramNames.get(paramArrayIndex))) { + error(paramNameNotCopiedAssertionMsg); + } + paramArrayIndex++; + } + currentParamPos++; + params = params.tail; + } + foundAndCorrect = paramArrayIndex >= paramsToCheck.size(); + } + super.visitMethodDef(tree); + } + } + + if (e.getKind() == TaskEvent.Kind.ANALYZE) { + CompilationUnitTree compUnitTree = e.getCompilationUnit(); + boolean foundAndCorrect = false; + for (Tree tree : compUnitTree.getTypeDecls()) { + TheTreeScanner scanner = new TheTreeScanner(); + scanner.scan((JCTree) tree); + foundAndCorrect = foundAndCorrect | scanner.foundAndCorrect; + } + if (!foundAndCorrect) { + error(seekMethodNotFound); + } + } + } + }); + + if (!task.call()) { + error(compilationFailed); + } + } + + void error(String msg) { + throw new AssertionError(msg); + } + + @Target(value = {ElementType.PARAMETER}) + @interface ParamAnnotation {} + + /* If more cases are added in the future, it should be taken into account + * that method checkInitSymbol locates the inner class looking for its + * container method, which in the cases below are m1 and m2. So new cases + * must have different names for container methods or method checkInitSymbol + * should be changed. + */ + public class initParams { + public initParams(@ParamAnnotation int i) {} + + public void m1() { + new initParams(2) {}; + } + } + + class Generics { + T1 obj1; + Object obj2; + Generics(@ParamAnnotation T1 t1, @ParamAnnotation T2 t2) { + obj1 = t1; + obj2 = t2; + } + + void m2() { + Generics a = new Generics( + new Integer(11), "foo") {}; + } + } +} diff -r 76d08c649607 -r da8d0ee0938e test/tools/javac/annotations/typeAnnotations/8013180/QualifiedName.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/annotations/typeAnnotations/8013180/QualifiedName.java Mon Jun 10 09:52:54 2013 +0100 @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; + +/* + * @test + * @bug 8013180 + * @summary Qualified type annotation name used to crash javac + * @compile QualifiedName.java + */ + +public class QualifiedName { + @Target(ElementType.TYPE_USE) @interface TA { } + class E extends Exception { } + + void m() throws @TA QualifiedName.@TA E { } +} diff -r 76d08c649607 -r da8d0ee0938e test/tools/javac/diags/Example.java --- a/test/tools/javac/diags/Example.java Fri May 31 10:28:30 2013 +0100 +++ b/test/tools/javac/diags/Example.java Mon Jun 10 09:52:54 2013 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -296,7 +296,10 @@ private Set actualKeys; private Set declaredKeys; - static File tempDir = new File(System.getProperty("java.io.tmpdir")); + static File tempDir = (System.getProperty("test.src") != null) ? + new File(System.getProperty("user.dir")): + new File(System.getProperty("java.io.tmpdir")); + static void setTempDir(File tempDir) { Example.tempDir = tempDir; } diff -r 76d08c649607 -r da8d0ee0938e test/tools/javac/foreach/7139681/T7139681neg.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/foreach/7139681/T7139681neg.java Mon Jun 10 09:52:54 2013 +0100 @@ -0,0 +1,16 @@ +/* + * @test /nodynamiccopyright/ + * @bug 7139681 + * @summary Enhanced for loop: local variable scope inconsistent with JLS + * + * @compile/fail/ref=T7139681neg.out -XDrawDiagnostics T7139681neg.java + */ +class T7139681neg { + void testArray() { + for (int a : a) { } + } + + void testIterable() { + for (Integer b : b) { } + } +} diff -r 76d08c649607 -r da8d0ee0938e test/tools/javac/foreach/7139681/T7139681neg.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/foreach/7139681/T7139681neg.out Mon Jun 10 09:52:54 2013 +0100 @@ -0,0 +1,3 @@ +T7139681neg.java:10:22: compiler.err.cant.resolve.location: kindname.variable, a, , , (compiler.misc.location: kindname.class, T7139681neg, null) +T7139681neg.java:14:26: compiler.err.cant.resolve.location: kindname.variable, b, , , (compiler.misc.location: kindname.class, T7139681neg, null) +2 errors diff -r 76d08c649607 -r da8d0ee0938e test/tools/javac/foreach/7139681/T7139681pos.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/foreach/7139681/T7139681pos.java Mon Jun 10 09:52:54 2013 +0100 @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7139681 + * @summary Enhanced for loop: local variable scope inconsistent with JLS + * + * @compile T7139681pos.java + */ +class T7139681pos { + int[] a; + Iterable b; + + void testArray() { + for (int a : a) { + int a2 = a; + } + } + + void testIterable() { + for (Integer b : b) { + Integer b2 = b; + } + } +} diff -r 76d08c649607 -r da8d0ee0938e test/tools/javac/generics/7015430/T7015430.out --- a/test/tools/javac/generics/7015430/T7015430.out Fri May 31 10:28:30 2013 +0100 +++ b/test/tools/javac/generics/7015430/T7015430.out Mon Jun 10 09:52:54 2013 +0100 @@ -1,15 +1,15 @@ +T7015430.java:41:14: compiler.warn.unchecked.meth.invocation.applied: kindname.method, empty, java.lang.Iterable, java.lang.Iterable, kindname.class, T7015430 T7015430.java:41:15: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable -T7015430.java:41:14: compiler.warn.unchecked.meth.invocation.applied: kindname.method, empty, java.lang.Iterable, java.lang.Iterable, kindname.class, T7015430 +T7015430.java:50:41: compiler.warn.unchecked.meth.invocation.applied: kindname.method, empty, java.lang.Iterable, java.lang.Iterable, kindname.class, T7015430 T7015430.java:50:42: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable -T7015430.java:50:41: compiler.warn.unchecked.meth.invocation.applied: kindname.method, empty, java.lang.Iterable, java.lang.Iterable, kindname.class, T7015430 +T7015430.java:68:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, , java.lang.Iterable, java.lang.Iterable, kindname.class, T7015430 T7015430.java:68:22: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable -T7015430.java:68:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, , java.lang.Iterable, java.lang.Iterable, kindname.class, T7015430 +T7015430.java:77:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, , java.lang.Iterable, java.lang.Iterable, kindname.class, T7015430 T7015430.java:77:40: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable -T7015430.java:77:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, , java.lang.Iterable, java.lang.Iterable, kindname.class, T7015430 +T7015430.java:104:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, , java.lang.Iterable, java.lang.Iterable, kindname.class, T7015430 T7015430.java:104:41: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable -T7015430.java:104:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, , java.lang.Iterable, java.lang.Iterable, kindname.class, T7015430 +T7015430.java:113:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, , java.lang.Iterable, java.lang.Iterable, kindname.class, T7015430 T7015430.java:113:22: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable -T7015430.java:113:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, , java.lang.Iterable, java.lang.Iterable, kindname.class, T7015430 T7015430.java:41:14: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception T7015430.java:68:9: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception T7015430.java:95:15: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception diff -r 76d08c649607 -r da8d0ee0938e test/tools/javac/generics/7151802/T7151802.out --- a/test/tools/javac/generics/7151802/T7151802.out Fri May 31 10:28:30 2013 +0100 +++ b/test/tools/javac/generics/7151802/T7151802.out Mon Jun 10 09:52:54 2013 +0100 @@ -1,9 +1,9 @@ T7151802.java:14:31: compiler.warn.unchecked.meth.invocation.applied: kindname.method, get1, Z, T7151802.Foo, kindname.class, T7151802 +T7151802.java:22:30: compiler.warn.unchecked.meth.invocation.applied: kindname.method, get3, T7151802.Foo, T7151802.Foo, kindname.class, T7151802 T7151802.java:22:31: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), T7151802.Foo, T7151802.Foo -T7151802.java:22:30: compiler.warn.unchecked.meth.invocation.applied: kindname.method, get3, T7151802.Foo, T7151802.Foo, kindname.class, T7151802 T7151802.java:30:36: compiler.warn.unchecked.meth.invocation.applied: kindname.method, get5, compiler.misc.no.args, compiler.misc.no.args, kindname.class, T7151802 +T7151802.java:38:31: compiler.warn.unchecked.meth.invocation.applied: kindname.method, get7, T7151802.Foo, T7151802.Foo, kindname.class, T7151802 T7151802.java:38:32: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), T7151802.Foo, T7151802.Foo -T7151802.java:38:31: compiler.warn.unchecked.meth.invocation.applied: kindname.method, get7, T7151802.Foo, T7151802.Foo, kindname.class, T7151802 - compiler.err.warnings.and.werror 1 error 6 warnings diff -r 76d08c649607 -r da8d0ee0938e test/tools/javac/generics/inference/6718364/T6718364.out --- a/test/tools/javac/generics/inference/6718364/T6718364.out Fri May 31 10:28:30 2013 +0100 +++ b/test/tools/javac/generics/inference/6718364/T6718364.out Mon Jun 10 09:52:54 2013 +0100 @@ -1,3 +1,3 @@ +T6718364.java:13:10: compiler.warn.unchecked.meth.invocation.applied: kindname.method, m, T6718364.X,T, T6718364.X>,T6718364.X, kindname.class, T6718364 T6718364.java:13:32: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), T6718364.X, T6718364.X -T6718364.java:13:10: compiler.warn.unchecked.meth.invocation.applied: kindname.method, m, T6718364.X,T, T6718364.X>,T6718364.X, kindname.class, T6718364 2 warnings diff -r 76d08c649607 -r da8d0ee0938e test/tools/javac/generics/inference/7177306/T7177306a.out --- a/test/tools/javac/generics/inference/7177306/T7177306a.out Fri May 31 10:28:30 2013 +0100 +++ b/test/tools/javac/generics/inference/7177306/T7177306a.out Mon Jun 10 09:52:54 2013 +0100 @@ -1,5 +1,5 @@ +T7177306a.java:13:33: compiler.warn.unchecked.meth.invocation.applied: kindname.method, m, java.util.List, java.util.List, kindname.class, T7177306a T7177306a.java:13:34: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.util.List, java.util.List -T7177306a.java:13:33: compiler.warn.unchecked.meth.invocation.applied: kindname.method, m, java.util.List, java.util.List, kindname.class, T7177306a T7177306a.java:13:33: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), T7177306a, T7177306a - compiler.err.warnings.and.werror 1 error diff -r 76d08c649607 -r da8d0ee0938e test/tools/javac/generics/inference/8015505/T8015505.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/generics/inference/8015505/T8015505.java Mon Jun 10 09:52:54 2013 +0100 @@ -0,0 +1,18 @@ +/** + * @test /nodynamiccopyright/ + * @bug 8015505 + * @summary Spurious inference error when return type of generic method requires unchecked conversion to target + * @compile/fail/ref=T8015505.out -Xlint:-options -source 7 -XDrawDiagnostics T8015505.java + * @compile T8015505.java + */ + +import java.util.List; + +class T8015505 { + + List m() { return null; } + + void test() { + List l = m(); + } +} diff -r 76d08c649607 -r da8d0ee0938e test/tools/javac/generics/inference/8015505/T8015505.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/generics/inference/8015505/T8015505.out Mon Jun 10 09:52:54 2013 +0100 @@ -0,0 +1,2 @@ +T8015505.java:16:22: compiler.err.prob.found.req: (compiler.misc.infer.no.conforming.instance.exists: Z, java.util.List, java.util.List) +1 error diff -r 76d08c649607 -r da8d0ee0938e test/tools/javac/generics/rawOverride/7062745/GenericOverrideTest.java --- a/test/tools/javac/generics/rawOverride/7062745/GenericOverrideTest.java Fri May 31 10:28:30 2013 +0100 +++ b/test/tools/javac/generics/rawOverride/7062745/GenericOverrideTest.java Mon Jun 10 09:52:54 2013 +0100 @@ -46,6 +46,17 @@ extends JavacTestingAbstractThreadedTest implements Runnable { + enum SourceLevel { + SOURCE_7("-source", "7"), + SOURCE_DEFAULT(); + + String[] opts; + + SourceLevel(String... opts) { + this.opts = opts; + } + } + enum SignatureKind { NON_GENERIC(""), GENERIC(""); @@ -112,12 +123,13 @@ } } - boolean assignableTo(TypeArgumentKind that, SignatureKind sig) { + boolean assignableTo(TypeArgumentKind that, SignatureKind sig, SourceLevel level) { switch (this) { case NONE: //this case needs to workaround to javac's impl of 15.12.2.8 being too strict - //ideally should be just 'return true' (see 7067746) - return sig == SignatureKind.NON_GENERIC || that == NONE; + //ideally should be just 'return true' (see 7067746/8015505) + return level == SourceLevel.SOURCE_DEFAULT || + sig == SignatureKind.NON_GENERIC || that == NONE; case UNBOUND: return that == this || that == NONE; case INTEGER: @@ -143,10 +155,12 @@ for (TypeArgumentKind ta3 : TypeArgumentKind.values()) { if (!ta3.compatibleWith(SignatureKind.NON_GENERIC)) continue; - pool.execute( - new GenericOverrideTest(sig1, - rt1, ta1, sig2, rt2, - ta2, rt3, ta3)); + for (SourceLevel level : SourceLevel.values()) { + pool.execute( + new GenericOverrideTest(sig1, + rt1, ta1, sig2, rt2, + ta2, rt3, ta3, level)); + } } } } @@ -162,12 +176,13 @@ SignatureKind sig1, sig2; ReturnTypeKind rt1, rt2, rt3; TypeArgumentKind ta1, ta2, ta3; + SourceLevel level; JavaSource source; DiagnosticChecker diagChecker; GenericOverrideTest(SignatureKind sig1, ReturnTypeKind rt1, TypeArgumentKind ta1, SignatureKind sig2, ReturnTypeKind rt2, TypeArgumentKind ta2, - ReturnTypeKind rt3, TypeArgumentKind ta3) { + ReturnTypeKind rt3, TypeArgumentKind ta3, SourceLevel level) { this.sig1 = sig1; this.sig2 = sig2; this.rt1 = rt1; @@ -176,6 +191,7 @@ this.ta1 = ta1; this.ta2 = ta2; this.ta3 = ta3; + this.level = level; this.source = new JavaSource(); this.diagChecker = new DiagnosticChecker(); } @@ -213,7 +229,8 @@ @Override public void run() { JavacTask ct = (JavacTask)comp.getTask(null, fm.get(), diagChecker, - null, null, Arrays.asList(source)); + level.opts != null ? Arrays.asList(level.opts) : null, + null, Arrays.asList(source)); try { ct.analyze(); } catch (Throwable ex) { @@ -271,7 +288,7 @@ SignatureKind mssig = mostSpecific == 1 ? sig1 : sig2; if (!msrt.moreSpecificThan(rt3) || - !msta.assignableTo(ta3, mssig)) { + !msta.assignableTo(ta3, mssig, level)) { errorExpected = true; } } diff -r 76d08c649607 -r da8d0ee0938e test/tools/javac/generics/rawOverride/T8008627.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/generics/rawOverride/T8008627.java Mon Jun 10 09:52:54 2013 +0100 @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8008627 + * @summary Compiler mishandles three-way return-type-substitutability + * @compile T8008627.java + */ + +class T8008627 { + + interface I { + Object m(Iterable l); + } + + interface J { + S m(Iterable l); + } + + interface K { + T m(Iterable l); + } + + @FunctionalInterface + interface Functional extends I, J, K {} +} diff -r 76d08c649607 -r da8d0ee0938e test/tools/javac/lambda/LambdaScope05.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/LambdaScope05.java Mon Jun 10 09:52:54 2013 +0100 @@ -0,0 +1,31 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8015648 + * @summary Duplicate variable in lambda causes javac crash + * @compile/fail/ref=LambdaScope05.out -XDrawDiagnostics LambdaScope05.java + */ + +class LambdaScope05 { + interface VoidFun1 { + void m(int i); + } + + static Runnable r1 = () -> { VoidFun1 p = p -> { }; }; + Runnable r2 = () -> { VoidFun1 p = p -> { }; }; + + static { + Runnable r = () -> { VoidFun1 p = p -> { }; }; + } + + { + Runnable r = () -> { VoidFun1 p = p -> { }; }; + } + + static void m_static() { + Runnable r = () -> { VoidFun1 p = p -> { }; }; + } + + void m() { + Runnable r = () -> { VoidFun1 p = p -> { }; }; + } +} diff -r 76d08c649607 -r da8d0ee0938e test/tools/javac/lambda/LambdaScope05.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/LambdaScope05.out Mon Jun 10 09:52:54 2013 +0100 @@ -0,0 +1,7 @@ +LambdaScope05.java:13:47: compiler.err.already.defined.in.clinit: kindname.variable, p, kindname.static.init, kindname.class, LambdaScope05 +LambdaScope05.java:14:40: compiler.err.already.defined.in.clinit: kindname.variable, p, kindname.instance.init, kindname.class, LambdaScope05 +LambdaScope05.java:17:43: compiler.err.already.defined.in.clinit: kindname.variable, p, kindname.static.init, kindname.class, LambdaScope05 +LambdaScope05.java:21:43: compiler.err.already.defined.in.clinit: kindname.variable, p, kindname.instance.init, kindname.class, LambdaScope05 +LambdaScope05.java:25:43: compiler.err.already.defined: kindname.variable, p, kindname.method, m_static() +LambdaScope05.java:29:43: compiler.err.already.defined: kindname.variable, p, kindname.method, m() +6 errors diff -r 76d08c649607 -r da8d0ee0938e test/tools/javac/lambda/MethodReferenceParserTest.java --- a/test/tools/javac/lambda/MethodReferenceParserTest.java Fri May 31 10:28:30 2013 +0100 +++ b/test/tools/javac/lambda/MethodReferenceParserTest.java Mon Jun 10 09:52:54 2013 +0100 @@ -23,8 +23,7 @@ /* * @test - * @bug 7115052 - * @bug 8003280 8006694 + * @bug 7115052 8003280 8006694 * @summary Add lambda tests * Add parser support for method references * temporarily workaround combo tests are causing time out in several platforms diff -r 76d08c649607 -r da8d0ee0938e test/tools/javac/lambda/TargetType53.java --- a/test/tools/javac/lambda/TargetType53.java Fri May 31 10:28:30 2013 +0100 +++ b/test/tools/javac/lambda/TargetType53.java Mon Jun 10 09:52:54 2013 +0100 @@ -26,7 +26,6 @@ * @bug 8007464 * @summary Add graph inference support * smoke test for graph inference - * @ignore 8008682: Core stream API classes * @compile TargetType53.java */ import java.util.*; diff -r 76d08c649607 -r da8d0ee0938e test/tools/javac/lambda/TargetType54.java --- a/test/tools/javac/lambda/TargetType54.java Fri May 31 10:28:30 2013 +0100 +++ b/test/tools/javac/lambda/TargetType54.java Mon Jun 10 09:52:54 2013 +0100 @@ -26,7 +26,6 @@ * @bug 8007464 * @summary Add graph inference support * smoke test for graph inference - * @ignore 8008682: Core stream API classes * @compile TargetType54.java */ import java.util.stream.*; diff -r 76d08c649607 -r da8d0ee0938e test/tools/javac/lambda/TargetType58.java --- a/test/tools/javac/lambda/TargetType58.java Fri May 31 10:28:30 2013 +0100 +++ b/test/tools/javac/lambda/TargetType58.java Mon Jun 10 09:52:54 2013 +0100 @@ -26,7 +26,6 @@ * @bug 8007464 * @summary Add graph inference support * more smoke tests for graph inference - * @ignore 8008682: Core stream API classes * @compile TargetType58.java */ import java.util.*; diff -r 76d08c649607 -r da8d0ee0938e test/tools/javac/lambda/TargetType59.java --- a/test/tools/javac/lambda/TargetType59.java Fri May 31 10:28:30 2013 +0100 +++ b/test/tools/javac/lambda/TargetType59.java Mon Jun 10 09:52:54 2013 +0100 @@ -26,7 +26,6 @@ * @bug 8007464 * @summary Add graph inference support * more smoke tests for graph inference - * @ignore 8008682: Core stream API classes * @compile TargetType59.java */ import java.util.*; diff -r 76d08c649607 -r da8d0ee0938e test/tools/javac/lambda/TargetType62.java --- a/test/tools/javac/lambda/TargetType62.java Fri May 31 10:28:30 2013 +0100 +++ b/test/tools/javac/lambda/TargetType62.java Mon Jun 10 09:52:54 2013 +0100 @@ -26,7 +26,6 @@ * @bug 8007464 * @summary Add graph inference support * check that new wildcards inference strategy doesn't run into 7190296 - * @ignore 8008682: Core stream API classes * @compile TargetType62.java */ import java.util.*; diff -r 76d08c649607 -r da8d0ee0938e test/tools/javac/lambda/TargetType73.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/TargetType73.java Mon Jun 10 09:52:54 2013 +0100 @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8014494 + * @summary javac crashes when varargs element of a method reference is inferred from the context + * @compile TargetType73.java + */ +import java.util.List; + +class TargetType73 { + + interface Function { + Y m(X x); + } + + static void test() { + m(TargetType73::g); + } + + public static List g(T... a) { + return null; + } + + public static void m(Function zipper) { } +} diff -r 76d08c649607 -r da8d0ee0938e test/tools/javac/lambda/TargetType74.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/TargetType74.java Mon Jun 10 09:52:54 2013 +0100 @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8015432 + * @summary javac crashes with stack overflow when method called recursively from nested generic call + * @compile TargetType74.java + */ +class TargetType74 { + + static class LazySeq { } + + LazySeq cons(LazySeq tailFun) { return null; } + + > LazySeq mergeSorted(LazySeq a) { + return cons(mergeSorted(a)); + } +} diff -r 76d08c649607 -r da8d0ee0938e test/tools/javac/lambda/TestInvokeDynamic.java --- a/test/tools/javac/lambda/TestInvokeDynamic.java Fri May 31 10:28:30 2013 +0100 +++ b/test/tools/javac/lambda/TestInvokeDynamic.java Mon Jun 10 09:52:54 2013 +0100 @@ -23,8 +23,7 @@ /* * @test - * @bug 7194586 - * @bug 8003280 8006694 8010404 + * @bug 7194586 8003280 8006694 8010404 * @summary Add lambda tests * Add back-end support for invokedynamic * temporarily workaround combo tests are causing time out in several platforms @@ -36,6 +35,16 @@ // use /othervm to avoid jtreg timeout issues (CODETOOLS-7900047) // see JDK-8006746 +import java.io.File; +import java.net.URI; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Locale; + +import javax.tools.Diagnostic; +import javax.tools.JavaFileObject; +import javax.tools.SimpleJavaFileObject; + import com.sun.source.tree.MethodInvocationTree; import com.sun.source.tree.MethodTree; import com.sun.source.util.TaskEvent; @@ -63,16 +72,6 @@ import com.sun.tools.javac.util.Context; import com.sun.tools.javac.util.Names; -import java.io.File; -import java.net.URI; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Locale; - -import javax.tools.Diagnostic; -import javax.tools.JavaFileObject; -import javax.tools.SimpleJavaFileObject; - import static com.sun.tools.javac.jvm.ClassFile.*; public class TestInvokeDynamic diff -r 76d08c649607 -r da8d0ee0938e test/tools/javac/lambda/funcInterfaces/NonSAM2.java --- a/test/tools/javac/lambda/funcInterfaces/NonSAM2.java Fri May 31 10:28:30 2013 +0100 +++ b/test/tools/javac/lambda/funcInterfaces/NonSAM2.java Mon Jun 10 09:52:54 2013 +0100 @@ -13,7 +13,7 @@ interface Foo1Bar1 extends Foo1, Bar1 {} //types Bar1 and Foo1 are incompatible; both define getAge(String), but with unrelated return types interface AC extends A, C {} //name clash: getOldest(List) in C and getOldest(List) in A have the same erasure, yet neither overrides the other -interface ABC extends A, B, C {} //name clash: getOldest(List) in C and getOldest(List) in A have the same erasure, yet neither overrides the other +interface ABC extends A, B, C {} //ok - raw override interface AD extends A, D {} //name clash: getOldest(List) in D and getOldest(List) in A have the same erasure, yet neither overrides the other interface Foo2 { void m(T arg);} diff -r 76d08c649607 -r da8d0ee0938e test/tools/javac/lambda/funcInterfaces/NonSAM2.out --- a/test/tools/javac/lambda/funcInterfaces/NonSAM2.out Fri May 31 10:28:30 2013 +0100 +++ b/test/tools/javac/lambda/funcInterfaces/NonSAM2.out Mon Jun 10 09:52:54 2013 +0100 @@ -1,6 +1,5 @@ NonSAM2.java:13:1: compiler.err.types.incompatible.diff.ret: Bar1, Foo1, getAge(java.lang.String) NonSAM2.java:15:1: compiler.err.name.clash.same.erasure.no.override: getOldest(java.util.List), C, getOldest(java.util.List), A -NonSAM2.java:16:1: compiler.err.name.clash.same.erasure.no.override: getOldest(java.util.List), C, getOldest(java.util.List), A NonSAM2.java:17:1: compiler.err.name.clash.same.erasure.no.override: getOldest(java.util.List), D, getOldest(java.util.List), A NonSAM2.java:21:1: compiler.err.name.clash.same.erasure.no.override: m(S), Bar2, m(T), Foo2 -5 errors +4 errors diff -r 76d08c649607 -r da8d0ee0938e test/tools/javac/lib/DPrinter.java --- a/test/tools/javac/lib/DPrinter.java Fri May 31 10:28:30 2013 +0100 +++ b/test/tools/javac/lib/DPrinter.java Mon Jun 10 09:52:54 2013 +0100 @@ -403,7 +403,7 @@ printType("type", sym.type, Details.SUMMARY); printType("erasure", sym.erasure_field, Details.SUMMARY); sym.accept(symVisitor, null); - printAnnotations("annotations", sym.annotations, Details.SUMMARY); + printAnnotations("annotations", sym.getAnnotations(), Details.SUMMARY); indent(-1); } } diff -r 76d08c649607 -r da8d0ee0938e test/tools/javac/mandatoryWarnings/deprecated/Test.java --- a/test/tools/javac/mandatoryWarnings/deprecated/Test.java Fri May 31 10:28:30 2013 +0100 +++ b/test/tools/javac/mandatoryWarnings/deprecated/Test.java Mon Jun 10 09:52:54 2013 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,109 +29,19 @@ * @bug 5047307 * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test1.out -XDrawDiagnostics A.java - */ - -/* - * @test - * @bug 5047307 - * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test1.out -XDrawDiagnostics -nowarn A.java - */ - -/* - * @test - * @bug 5047307 - * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test1.out -XDrawDiagnostics -Xmaxwarns 1 A.java - */ - -/* - * @test - * @bug 5047307 - * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test2.out -XDrawDiagnostics A.java B.java - */ - -/* - * @test - * @bug 5047307 - * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test2.out -XDrawDiagnostics -nowarn A.java B.java - */ - -/* - * @test - * @bug 5047307 - * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test2.out -XDrawDiagnostics -Xmaxwarns 1 A.java B.java - */ - -/* - * @test - * @bug 5047307 - * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test3.out -XDrawDiagnostics -Xlint:deprecation A.java - */ - -/* - * @test - * @bug 5047307 - * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test3.out -XDrawDiagnostics -nowarn -Xlint:deprecation A.java - */ - -/* - * @test - * @bug 5047307 - * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test3b.out -XDrawDiagnostics -nowarn -Xlint:deprecation -Xmaxwarns 1 A.java - */ - -/* - * @test - * @bug 5047307 - * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test4.out -XDrawDiagnostics -Xlint:deprecation A.java B.java - */ - -/* - * @test - * @bug 5047307 - * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test4.out -XDrawDiagnostics -nowarn -Xlint:deprecation A.java B.java - */ - -/* - * @test - * @bug 5047307 - * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test4b.out -XDrawDiagnostics -nowarn -Xlint:deprecation -Xmaxwarns 1 A.java B.java - */ - -/* - * @test - * @bug 5047307 - * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test4c.out -XDrawDiagnostics -nowarn -Xlint:deprecation -Xmaxwarns 2 A.java B.java - */ - -/* - * @test - * @bug 5047307 - * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test4d.out -XDrawDiagnostics -nowarn -Xlint:deprecation -Xmaxwarns 3 A.java B.java - */ - -/* - * @test - * @bug 5047307 - * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test5.out -XDrawDiagnostics -Xlint:deprecation P.java Q.java - */ - -/* - * @test - * @bug 5047307 - * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test5b.out -XDrawDiagnostics -Xlint:deprecation -Xmaxwarns 2 P.java Q.java */ diff -r 76d08c649607 -r da8d0ee0938e test/tools/javac/mandatoryWarnings/unchecked/Test.java --- a/test/tools/javac/mandatoryWarnings/unchecked/Test.java Fri May 31 10:28:30 2013 +0100 +++ b/test/tools/javac/mandatoryWarnings/unchecked/Test.java Mon Jun 10 09:52:54 2013 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,95 +29,17 @@ * @bug 5047307 * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test1.out -XDrawDiagnostics A.java - */ - -/* - * @test - * @bug 5047307 - * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test1.out -XDrawDiagnostics -nowarn A.java - */ - -/* - * @test - * @bug 5047307 - * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test1.out -XDrawDiagnostics -Xmaxwarns 1 A.java - */ - -/* - * @test - * @bug 5047307 - * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test2.out -XDrawDiagnostics A.java B.java - */ - -/* - * @test - * @bug 5047307 - * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test2.out -XDrawDiagnostics -nowarn A.java B.java - */ - -/* - * @test - * @bug 5047307 - * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test2.out -XDrawDiagnostics -Xmaxwarns 1 A.java B.java - */ - -/* - * @test - * @bug 5047307 - * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test3.out -XDrawDiagnostics -Xlint:unchecked A.java - */ - -/* - * @test - * @bug 5047307 - * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test3.out -XDrawDiagnostics -nowarn -Xlint:unchecked A.java - */ - -/* - * @test - * @bug 5047307 - * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test3b.out -XDrawDiagnostics -nowarn -Xlint:unchecked -Xmaxwarns 1 A.java - */ - -/* - * @test - * @bug 5047307 - * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test4.out -XDrawDiagnostics -Xlint:unchecked A.java B.java - */ - -/* - * @test - * @bug 5047307 - * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test4.out -XDrawDiagnostics -nowarn -Xlint:unchecked A.java B.java - */ - -/* - * @test - * @bug 5047307 - * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test4b.out -XDrawDiagnostics -nowarn -Xlint:unchecked -Xmaxwarns 1 A.java B.java - */ - -/* - * @test - * @bug 5047307 - * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test4c.out -XDrawDiagnostics -nowarn -Xlint:unchecked -Xmaxwarns 2 A.java B.java - */ - -/* - * @test - * @bug 5047307 - * @summary javac -nowarn improperly suppresses JLS-mandated warnings * @compile/ref=Test4d.out -XDrawDiagnostics -nowarn -Xlint:unchecked -Xmaxwarns 3 A.java B.java */ diff -r 76d08c649607 -r da8d0ee0938e test/tools/javac/parser/8014643/T8014643.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/parser/8014643/T8014643.java Mon Jun 10 09:52:54 2013 +0100 @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8014643 + * @summary Parser regression in JDK 8 when compiling super.x + * @compile T8014643.java + */ +class T8014643 { + + static class A { + int b = 1; + } + + static class B extends A { + int b = 12; + + int m() { return (super.b); } + } +} diff -r 76d08c649607 -r da8d0ee0938e test/tools/javac/policy/test3/Test.java --- a/test/tools/javac/policy/test3/Test.java Fri May 31 10:28:30 2013 +0100 +++ b/test/tools/javac/policy/test3/Test.java Mon Jun 10 09:52:54 2013 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -123,47 +123,3 @@ int errors; } - - - - - - - - - - - - -// These tests test the ability of the compiler to continue in the face of -// errors, accordining to the shouldStopPolicy - -/* @ test /nodynamiccopyright/ - * @bug 6813059 - * @summary - * @compile/fail/ref=flow.out -XDrawDiagnostics -XDcompilePolicy=byfile -XDverboseCompilePolicy -XDshouldStopPolicy=FLOW Test.java - - * @compile/fail/ref=default.out -XDrawDiagnostics -XDcompilePolicy=byfile -XDverboseCompilePolicy Test.java - * @compile/fail/ref=enter.out -XDrawDiagnostics -XDcompilePolicy=byfile -XDverboseCompilePolicy -XDshouldStopPolicy=ENTER Test.java - * @compile/fail/ref=attr.out -XDrawDiagnostics -XDcompilePolicy=byfile -XDverboseCompilePolicy -XDshouldStopPolicy=ATTR Test.java - * @compile/fail/ref=transtypes.out -XDrawDiagnostics -XDcompilePolicy=byfile -XDverboseCompilePolicy -XDshouldStopPolicy=TRANSTYPES Test.java - * @compile/fail/ref=lower.out -XDrawDiagnostics -XDcompilePolicy=byfile -XDverboseCompilePolicy -XDshouldStopPolicy=LOWER Test.java - * @compile/fail/ref=generate.out -XDrawDiagnostics -XDcompilePolicy=byfile -XDverboseCompilePolicy -XDshouldStopPolicy=GENERATE Test.java - */ - -/* -class Test { - void m1() { - System.err.println("hello"); - 0 // syntax error - System.err.println("world"); - } - - void m2() { - } -} - -class Test2 { -} -*/ - diff -r 76d08c649607 -r da8d0ee0938e test/tools/javac/resolve/ResolveHarness.java --- a/test/tools/javac/resolve/ResolveHarness.java Fri May 31 10:28:30 2013 +0100 +++ b/test/tools/javac/resolve/ResolveHarness.java Mon Jun 10 09:52:54 2013 +0100 @@ -43,6 +43,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Map; import javax.annotation.processing.AbstractProcessor; @@ -85,6 +86,7 @@ Set declaredKeys = new HashSet<>(); List> diags = new ArrayList<>(); List seenCandidates = new ArrayList<>(); + Map predefTranslationMap = new HashMap<>(); protected ResolveHarness(JavaFileObject jfo) { this.jfo = jfo; @@ -93,12 +95,36 @@ new VerboseDeferredInferenceNoteProcessor(), new ErrorProcessor() }; + predefTranslationMap.put("+", "_plus"); + predefTranslationMap.put("-", "_minus"); + predefTranslationMap.put("~", "_not"); + predefTranslationMap.put("++", "_plusplus"); + predefTranslationMap.put("--", "_minusminus"); + predefTranslationMap.put("!", "_bang"); + predefTranslationMap.put("*", "_mul"); + predefTranslationMap.put("/", "_div"); + predefTranslationMap.put("%", "_mod"); + predefTranslationMap.put("&", "_and"); + predefTranslationMap.put("|", "_or"); + predefTranslationMap.put("^", "_xor"); + predefTranslationMap.put("<<", "_lshift"); + predefTranslationMap.put(">>", "_rshift"); + predefTranslationMap.put("<<<", "_lshiftshift"); + predefTranslationMap.put(">>>", "_rshiftshift"); + predefTranslationMap.put("<", "_lt"); + predefTranslationMap.put(">", "_gt"); + predefTranslationMap.put("<=", "_lteq"); + predefTranslationMap.put(">=", "_gteq"); + predefTranslationMap.put("==", "_eq"); + predefTranslationMap.put("!=", "_neq"); + predefTranslationMap.put("&&", "_andand"); + predefTranslationMap.put("||", "_oror"); } protected void check() throws Exception { String[] options = { "-XDshouldStopPolicy=ATTR", - "-XDverboseResolution=success,failure,applicable,inapplicable,deferred-inference" + "-XDverboseResolution=success,failure,applicable,inapplicable,deferred-inference,predef" }; AbstractProcessor[] processors = { new ResolveCandidateFinder(), null }; @@ -223,7 +249,8 @@ @Override void process(Diagnostic diagnostic) { Element siteSym = getSiteSym(diagnostic); - if (siteSym.getAnnotation(TraceResolve.class) == null) { + if (siteSym.getSimpleName().length() != 0 && + siteSym.getAnnotation(TraceResolve.class) == null) { return; } int candidateIdx = 0; @@ -307,7 +334,7 @@ if (Arrays.asList(c.applicable()).contains(phase)) { //applicable if (c.mostSpecific() != mostSpecific) { - error("Invalid most specific value for method " + methodSym); + error("Invalid most specific value for method " + methodSym + " " + new ElementKey(methodSym).key); } MethodType mtype = getSig(diagnostic); if (mtype != null) { @@ -444,11 +471,21 @@ String computeKey(Element e) { StringBuilder buf = new StringBuilder(); - while (e != null) { + if (predefTranslationMap.containsKey(e.getSimpleName().toString())) { + //predef element + buf.append("."); + String replacedName = predefTranslationMap.get(e.getSimpleName().toString()); + buf.append(e.toString().replace(e.getSimpleName().toString(), replacedName)); + } else if (e.getSimpleName().toString().startsWith("_")) { + buf.append("."); buf.append(e.toString()); - e = e.getEnclosingElement(); + } else { + while (e != null) { + buf.append(e.toString()); + e = e.getEnclosingElement(); + } + buf.append(jfo.getName()); } - buf.append(jfo.getName()); return buf.toString(); } diff -r 76d08c649607 -r da8d0ee0938e test/tools/javac/resolve/tests/PrimitiveBinopOverload.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/resolve/tests/PrimitiveBinopOverload.java Mon Jun 10 09:52:54 2013 +0100 @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +@TraceResolve +class PrimitiveBinopOverload { + + @Candidate(applicable=Phase.BASIC, mostSpecific=true) + int _plus(int x, int y) { return -1; } + @Candidate(applicable=Phase.BASIC) + long _plus(long x, long y) { return -1; } + @Candidate(applicable=Phase.BASIC) + float _plus(float x, float y) { return -1; } + @Candidate(applicable=Phase.BASIC) + double _plus(double x, double y) { return -1; } + //not a candidate + Object _plus(Object x, Object y) { return -1; } + + @Candidate(applicable= { Phase.BASIC, Phase.BOX }, mostSpecific=true) + int _minus(int x, int y) { return -1; } + @Candidate(applicable= { Phase.BASIC, Phase.BOX }) + long _minus(long x, long y) { return -1; } + @Candidate(applicable= { Phase.BASIC, Phase.BOX }) + float _minus(float x, float y) { return -1; } + @Candidate(applicable= { Phase.BASIC, Phase.BOX }) + double _minus(double x, double y) { return -1; } + + @Candidate(applicable= { Phase.BASIC, Phase.BOX }, mostSpecific=true) + int _mul(int x, int y) { return -1; } + @Candidate(applicable= { Phase.BASIC, Phase.BOX }) + long _mul(long x, long y) { return -1; } + @Candidate(applicable= { Phase.BASIC, Phase.BOX }) + float _mul(float x, float y) { return -1; } + @Candidate(applicable= { Phase.BASIC, Phase.BOX }) + double _mul(double x, double y) { return -1; } + + @Candidate(applicable= { Phase.BASIC, Phase.BOX }, mostSpecific=true) + int _div(int x, int y) { return -1; } + @Candidate(applicable= { Phase.BASIC, Phase.BOX }) + long _div(long x, long y) { return -1; } + @Candidate(applicable= { Phase.BASIC, Phase.BOX }) + float _div(float x, float y) { return -1; } + @Candidate(applicable= { Phase.BASIC, Phase.BOX }) + double _div(double x, double y) { return -1; } + + { + int i1 = 1 + 1; + int i2 = 5 - new Integer(3); + int i3 = new Integer(5) * 3; + int i4 = new Integer(6) / new Integer(2); + } +}